UNPKG

85.3 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('ngx-bootstrap/utils'), require('ngx-bootstrap/positioning'), require('rxjs'), require('@angular/animations'), require('@angular/forms'), require('ngx-bootstrap/component-loader'), require('rxjs/operators'), require('@angular/common')) :
3 typeof define === 'function' && define.amd ? define('ngx-bootstrap/typeahead', ['exports', '@angular/core', 'ngx-bootstrap/utils', 'ngx-bootstrap/positioning', 'rxjs', '@angular/animations', '@angular/forms', 'ngx-bootstrap/component-loader', 'rxjs/operators', '@angular/common'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global['ngx-bootstrap'] = global['ngx-bootstrap'] || {}, global['ngx-bootstrap'].typeahead = {}), global.ng.core, global.utils, global.positioning, global.rxjs, global.ng.animations, global.ng.forms, global.componentLoader, global.rxjs.operators, global.ng.common));
5}(this, (function (exports, i0, utils, positioning, rxjs, animations, forms, componentLoader, operators, common) { 'use strict';
6
7 var latinMap = {
8 'Á': 'A',
9 'Ă': 'A',
10 'Ắ': 'A',
11 'Ặ': 'A',
12 'Ằ': 'A',
13 'Ẳ': 'A',
14 'Ẵ': 'A',
15 'Ǎ': 'A',
16 'Â': 'A',
17 'Ấ': 'A',
18 'Ậ': 'A',
19 'Ầ': 'A',
20 'Ẩ': 'A',
21 'Ẫ': 'A',
22 'Ä': 'A',
23 'Ǟ': 'A',
24 'Ȧ': 'A',
25 'Ǡ': 'A',
26 'Ạ': 'A',
27 'Ȁ': 'A',
28 'À': 'A',
29 'Ả': 'A',
30 'Ȃ': 'A',
31 'Ā': 'A',
32 'Ą': 'A',
33 'Å': 'A',
34 'Ǻ': 'A',
35 'Ḁ': 'A',
36 'Ⱥ': 'A',
37 'Ã': 'A',
38 'Ꜳ': 'AA',
39 'Æ': 'AE',
40 'Ǽ': 'AE',
41 'Ǣ': 'AE',
42 'Ꜵ': 'AO',
43 'Ꜷ': 'AU',
44 'Ꜹ': 'AV',
45 'Ꜻ': 'AV',
46 'Ꜽ': 'AY',
47 'Ḃ': 'B',
48 'Ḅ': 'B',
49 'Ɓ': 'B',
50 'Ḇ': 'B',
51 'Ƀ': 'B',
52 'Ƃ': 'B',
53 'Ć': 'C',
54 'Č': 'C',
55 'Ç': 'C',
56 'Ḉ': 'C',
57 'Ĉ': 'C',
58 'Ċ': 'C',
59 'Ƈ': 'C',
60 'Ȼ': 'C',
61 'Ď': 'D',
62 'Ḑ': 'D',
63 'Ḓ': 'D',
64 'Ḋ': 'D',
65 'Ḍ': 'D',
66 'Ɗ': 'D',
67 'Ḏ': 'D',
68 'Dz': 'D',
69 'Dž': 'D',
70 'Đ': 'D',
71 'Ƌ': 'D',
72 'DZ': 'DZ',
73 'DŽ': 'DZ',
74 'É': 'E',
75 'Ĕ': 'E',
76 'Ě': 'E',
77 'Ȩ': 'E',
78 'Ḝ': 'E',
79 'Ê': 'E',
80 'Ế': 'E',
81 'Ệ': 'E',
82 'Ề': 'E',
83 'Ể': 'E',
84 'Ễ': 'E',
85 'Ḙ': 'E',
86 'Ë': 'E',
87 'Ė': 'E',
88 'Ẹ': 'E',
89 'Ȅ': 'E',
90 'È': 'E',
91 'Ẻ': 'E',
92 'Ȇ': 'E',
93 'Ē': 'E',
94 'Ḗ': 'E',
95 'Ḕ': 'E',
96 'Ę': 'E',
97 'Ɇ': 'E',
98 'Ẽ': 'E',
99 'Ḛ': 'E',
100 'Ꝫ': 'ET',
101 'Ḟ': 'F',
102 'Ƒ': 'F',
103 'Ǵ': 'G',
104 'Ğ': 'G',
105 'Ǧ': 'G',
106 'Ģ': 'G',
107 'Ĝ': 'G',
108 'Ġ': 'G',
109 'Ɠ': 'G',
110 'Ḡ': 'G',
111 'Ǥ': 'G',
112 'Ḫ': 'H',
113 'Ȟ': 'H',
114 'Ḩ': 'H',
115 'Ĥ': 'H',
116 'Ⱨ': 'H',
117 'Ḧ': 'H',
118 'Ḣ': 'H',
119 'Ḥ': 'H',
120 'Ħ': 'H',
121 'Í': 'I',
122 'Ĭ': 'I',
123 'Ǐ': 'I',
124 'Î': 'I',
125 'Ï': 'I',
126 'Ḯ': 'I',
127 'İ': 'I',
128 'Ị': 'I',
129 'Ȉ': 'I',
130 'Ì': 'I',
131 'Ỉ': 'I',
132 'Ȋ': 'I',
133 'Ī': 'I',
134 'Į': 'I',
135 'Ɨ': 'I',
136 'Ĩ': 'I',
137 'Ḭ': 'I',
138 'Ꝺ': 'D',
139 'Ꝼ': 'F',
140 'Ᵹ': 'G',
141 'Ꞃ': 'R',
142 'Ꞅ': 'S',
143 'Ꞇ': 'T',
144 'Ꝭ': 'IS',
145 'Ĵ': 'J',
146 'Ɉ': 'J',
147 'Ḱ': 'K',
148 'Ǩ': 'K',
149 'Ķ': 'K',
150 'Ⱪ': 'K',
151 'Ꝃ': 'K',
152 'Ḳ': 'K',
153 'Ƙ': 'K',
154 'Ḵ': 'K',
155 'Ꝁ': 'K',
156 'Ꝅ': 'K',
157 'Ĺ': 'L',
158 'Ƚ': 'L',
159 'Ľ': 'L',
160 'Ļ': 'L',
161 'Ḽ': 'L',
162 'Ḷ': 'L',
163 'Ḹ': 'L',
164 'Ⱡ': 'L',
165 'Ꝉ': 'L',
166 'Ḻ': 'L',
167 'Ŀ': 'L',
168 'Ɫ': 'L',
169 'Lj': 'L',
170 'Ł': 'L',
171 'LJ': 'LJ',
172 'Ḿ': 'M',
173 'Ṁ': 'M',
174 'Ṃ': 'M',
175 'Ɱ': 'M',
176 'Ń': 'N',
177 'Ň': 'N',
178 'Ņ': 'N',
179 'Ṋ': 'N',
180 'Ṅ': 'N',
181 'Ṇ': 'N',
182 'Ǹ': 'N',
183 'Ɲ': 'N',
184 'Ṉ': 'N',
185 'Ƞ': 'N',
186 'Nj': 'N',
187 'Ñ': 'N',
188 'NJ': 'NJ',
189 'Ó': 'O',
190 'Ŏ': 'O',
191 'Ǒ': 'O',
192 'Ô': 'O',
193 'Ố': 'O',
194 'Ộ': 'O',
195 'Ồ': 'O',
196 'Ổ': 'O',
197 'Ỗ': 'O',
198 'Ö': 'O',
199 'Ȫ': 'O',
200 'Ȯ': 'O',
201 'Ȱ': 'O',
202 'Ọ': 'O',
203 'Ő': 'O',
204 'Ȍ': 'O',
205 'Ò': 'O',
206 'Ỏ': 'O',
207 'Ơ': 'O',
208 'Ớ': 'O',
209 'Ợ': 'O',
210 'Ờ': 'O',
211 'Ở': 'O',
212 'Ỡ': 'O',
213 'Ȏ': 'O',
214 'Ꝋ': 'O',
215 'Ꝍ': 'O',
216 'Ō': 'O',
217 'Ṓ': 'O',
218 'Ṑ': 'O',
219 'Ɵ': 'O',
220 'Ǫ': 'O',
221 'Ǭ': 'O',
222 'Ø': 'O',
223 'Ǿ': 'O',
224 'Õ': 'O',
225 'Ṍ': 'O',
226 'Ṏ': 'O',
227 'Ȭ': 'O',
228 'Ƣ': 'OI',
229 'Ꝏ': 'OO',
230 'Ɛ': 'E',
231 'Ɔ': 'O',
232 'Ȣ': 'OU',
233 'Ṕ': 'P',
234 'Ṗ': 'P',
235 'Ꝓ': 'P',
236 'Ƥ': 'P',
237 'Ꝕ': 'P',
238 'Ᵽ': 'P',
239 'Ꝑ': 'P',
240 'Ꝙ': 'Q',
241 'Ꝗ': 'Q',
242 'Ŕ': 'R',
243 'Ř': 'R',
244 'Ŗ': 'R',
245 'Ṙ': 'R',
246 'Ṛ': 'R',
247 'Ṝ': 'R',
248 'Ȑ': 'R',
249 'Ȓ': 'R',
250 'Ṟ': 'R',
251 'Ɍ': 'R',
252 'Ɽ': 'R',
253 'Ꜿ': 'C',
254 'Ǝ': 'E',
255 'Ś': 'S',
256 'Ṥ': 'S',
257 'Š': 'S',
258 'Ṧ': 'S',
259 'Ş': 'S',
260 'Ŝ': 'S',
261 'Ș': 'S',
262 'Ṡ': 'S',
263 'Ṣ': 'S',
264 'Ṩ': 'S',
265 'Ť': 'T',
266 'Ţ': 'T',
267 'Ṱ': 'T',
268 'Ț': 'T',
269 'Ⱦ': 'T',
270 'Ṫ': 'T',
271 'Ṭ': 'T',
272 'Ƭ': 'T',
273 'Ṯ': 'T',
274 'Ʈ': 'T',
275 'Ŧ': 'T',
276 'Ɐ': 'A',
277 'Ꞁ': 'L',
278 'Ɯ': 'M',
279 'Ʌ': 'V',
280 'Ꜩ': 'TZ',
281 'Ú': 'U',
282 'Ŭ': 'U',
283 'Ǔ': 'U',
284 'Û': 'U',
285 'Ṷ': 'U',
286 'Ü': 'U',
287 'Ǘ': 'U',
288 'Ǚ': 'U',
289 'Ǜ': 'U',
290 'Ǖ': 'U',
291 'Ṳ': 'U',
292 'Ụ': 'U',
293 'Ű': 'U',
294 'Ȕ': 'U',
295 'Ù': 'U',
296 'Ủ': 'U',
297 'Ư': 'U',
298 'Ứ': 'U',
299 'Ự': 'U',
300 'Ừ': 'U',
301 'Ử': 'U',
302 'Ữ': 'U',
303 'Ȗ': 'U',
304 'Ū': 'U',
305 'Ṻ': 'U',
306 'Ų': 'U',
307 'Ů': 'U',
308 'Ũ': 'U',
309 'Ṹ': 'U',
310 'Ṵ': 'U',
311 'Ꝟ': 'V',
312 'Ṿ': 'V',
313 'Ʋ': 'V',
314 'Ṽ': 'V',
315 'Ꝡ': 'VY',
316 'Ẃ': 'W',
317 'Ŵ': 'W',
318 'Ẅ': 'W',
319 'Ẇ': 'W',
320 'Ẉ': 'W',
321 'Ẁ': 'W',
322 'Ⱳ': 'W',
323 'Ẍ': 'X',
324 'Ẋ': 'X',
325 'Ý': 'Y',
326 'Ŷ': 'Y',
327 'Ÿ': 'Y',
328 'Ẏ': 'Y',
329 'Ỵ': 'Y',
330 'Ỳ': 'Y',
331 'Ƴ': 'Y',
332 'Ỷ': 'Y',
333 'Ỿ': 'Y',
334 'Ȳ': 'Y',
335 'Ɏ': 'Y',
336 'Ỹ': 'Y',
337 'Ź': 'Z',
338 'Ž': 'Z',
339 'Ẑ': 'Z',
340 'Ⱬ': 'Z',
341 'Ż': 'Z',
342 'Ẓ': 'Z',
343 'Ȥ': 'Z',
344 'Ẕ': 'Z',
345 'Ƶ': 'Z',
346 'IJ': 'IJ',
347 'Œ': 'OE',
348 'ᴀ': 'A',
349 'ᴁ': 'AE',
350 'ʙ': 'B',
351 'ᴃ': 'B',
352 'ᴄ': 'C',
353 'ᴅ': 'D',
354 'ᴇ': 'E',
355 'ꜰ': 'F',
356 'ɢ': 'G',
357 'ʛ': 'G',
358 'ʜ': 'H',
359 'ɪ': 'I',
360 'ʁ': 'R',
361 'ᴊ': 'J',
362 'ᴋ': 'K',
363 'ʟ': 'L',
364 'ᴌ': 'L',
365 'ᴍ': 'M',
366 'ɴ': 'N',
367 'ᴏ': 'O',
368 'ɶ': 'OE',
369 'ᴐ': 'O',
370 'ᴕ': 'OU',
371 'ᴘ': 'P',
372 'ʀ': 'R',
373 'ᴎ': 'N',
374 'ᴙ': 'R',
375 'ꜱ': 'S',
376 'ᴛ': 'T',
377 'ⱻ': 'E',
378 'ᴚ': 'R',
379 'ᴜ': 'U',
380 'ᴠ': 'V',
381 'ᴡ': 'W',
382 'ʏ': 'Y',
383 'ᴢ': 'Z',
384 'á': 'a',
385 'ă': 'a',
386 'ắ': 'a',
387 'ặ': 'a',
388 'ằ': 'a',
389 'ẳ': 'a',
390 'ẵ': 'a',
391 'ǎ': 'a',
392 'â': 'a',
393 'ấ': 'a',
394 'ậ': 'a',
395 'ầ': 'a',
396 'ẩ': 'a',
397 'ẫ': 'a',
398 'ä': 'a',
399 'ǟ': 'a',
400 'ȧ': 'a',
401 'ǡ': 'a',
402 'ạ': 'a',
403 'ȁ': 'a',
404 'à': 'a',
405 'ả': 'a',
406 'ȃ': 'a',
407 'ā': 'a',
408 'ą': 'a',
409 'ᶏ': 'a',
410 'ẚ': 'a',
411 'å': 'a',
412 'ǻ': 'a',
413 'ḁ': 'a',
414 'ⱥ': 'a',
415 'ã': 'a',
416 'ꜳ': 'aa',
417 'æ': 'ae',
418 'ǽ': 'ae',
419 'ǣ': 'ae',
420 'ꜵ': 'ao',
421 'ꜷ': 'au',
422 'ꜹ': 'av',
423 'ꜻ': 'av',
424 'ꜽ': 'ay',
425 'ḃ': 'b',
426 'ḅ': 'b',
427 'ɓ': 'b',
428 'ḇ': 'b',
429 'ᵬ': 'b',
430 'ᶀ': 'b',
431 'ƀ': 'b',
432 'ƃ': 'b',
433 'ɵ': 'o',
434 'ć': 'c',
435 'č': 'c',
436 'ç': 'c',
437 'ḉ': 'c',
438 'ĉ': 'c',
439 'ɕ': 'c',
440 'ċ': 'c',
441 'ƈ': 'c',
442 'ȼ': 'c',
443 'ď': 'd',
444 'ḑ': 'd',
445 'ḓ': 'd',
446 'ȡ': 'd',
447 'ḋ': 'd',
448 'ḍ': 'd',
449 'ɗ': 'd',
450 'ᶑ': 'd',
451 'ḏ': 'd',
452 'ᵭ': 'd',
453 'ᶁ': 'd',
454 'đ': 'd',
455 'ɖ': 'd',
456 'ƌ': 'd',
457 'ı': 'i',
458 'ȷ': 'j',
459 'ɟ': 'j',
460 'ʄ': 'j',
461 'dz': 'dz',
462 'dž': 'dz',
463 'é': 'e',
464 'ĕ': 'e',
465 'ě': 'e',
466 'ȩ': 'e',
467 'ḝ': 'e',
468 'ê': 'e',
469 'ế': 'e',
470 'ệ': 'e',
471 'ề': 'e',
472 'ể': 'e',
473 'ễ': 'e',
474 'ḙ': 'e',
475 'ë': 'e',
476 'ė': 'e',
477 'ẹ': 'e',
478 'ȅ': 'e',
479 'è': 'e',
480 'ẻ': 'e',
481 'ȇ': 'e',
482 'ē': 'e',
483 'ḗ': 'e',
484 'ḕ': 'e',
485 'ⱸ': 'e',
486 'ę': 'e',
487 'ᶒ': 'e',
488 'ɇ': 'e',
489 'ẽ': 'e',
490 'ḛ': 'e',
491 'ꝫ': 'et',
492 'ḟ': 'f',
493 'ƒ': 'f',
494 'ᵮ': 'f',
495 'ᶂ': 'f',
496 'ǵ': 'g',
497 'ğ': 'g',
498 'ǧ': 'g',
499 'ģ': 'g',
500 'ĝ': 'g',
501 'ġ': 'g',
502 'ɠ': 'g',
503 'ḡ': 'g',
504 'ᶃ': 'g',
505 'ǥ': 'g',
506 'ḫ': 'h',
507 'ȟ': 'h',
508 'ḩ': 'h',
509 'ĥ': 'h',
510 'ⱨ': 'h',
511 'ḧ': 'h',
512 'ḣ': 'h',
513 'ḥ': 'h',
514 'ɦ': 'h',
515 'ẖ': 'h',
516 'ħ': 'h',
517 'ƕ': 'hv',
518 'í': 'i',
519 'ĭ': 'i',
520 'ǐ': 'i',
521 'î': 'i',
522 'ï': 'i',
523 'ḯ': 'i',
524 'ị': 'i',
525 'ȉ': 'i',
526 'ì': 'i',
527 'ỉ': 'i',
528 'ȋ': 'i',
529 'ī': 'i',
530 'į': 'i',
531 'ᶖ': 'i',
532 'ɨ': 'i',
533 'ĩ': 'i',
534 'ḭ': 'i',
535 'ꝺ': 'd',
536 'ꝼ': 'f',
537 'ᵹ': 'g',
538 'ꞃ': 'r',
539 'ꞅ': 's',
540 'ꞇ': 't',
541 'ꝭ': 'is',
542 'ǰ': 'j',
543 'ĵ': 'j',
544 'ʝ': 'j',
545 'ɉ': 'j',
546 'ḱ': 'k',
547 'ǩ': 'k',
548 'ķ': 'k',
549 'ⱪ': 'k',
550 'ꝃ': 'k',
551 'ḳ': 'k',
552 'ƙ': 'k',
553 'ḵ': 'k',
554 'ᶄ': 'k',
555 'ꝁ': 'k',
556 'ꝅ': 'k',
557 'ĺ': 'l',
558 'ƚ': 'l',
559 'ɬ': 'l',
560 'ľ': 'l',
561 'ļ': 'l',
562 'ḽ': 'l',
563 'ȴ': 'l',
564 'ḷ': 'l',
565 'ḹ': 'l',
566 'ⱡ': 'l',
567 'ꝉ': 'l',
568 'ḻ': 'l',
569 'ŀ': 'l',
570 'ɫ': 'l',
571 'ᶅ': 'l',
572 'ɭ': 'l',
573 'ł': 'l',
574 'lj': 'lj',
575 'ſ': 's',
576 'ẜ': 's',
577 'ẛ': 's',
578 'ẝ': 's',
579 'ḿ': 'm',
580 'ṁ': 'm',
581 'ṃ': 'm',
582 'ɱ': 'm',
583 'ᵯ': 'm',
584 'ᶆ': 'm',
585 'ń': 'n',
586 'ň': 'n',
587 'ņ': 'n',
588 'ṋ': 'n',
589 'ȵ': 'n',
590 'ṅ': 'n',
591 'ṇ': 'n',
592 'ǹ': 'n',
593 'ɲ': 'n',
594 'ṉ': 'n',
595 'ƞ': 'n',
596 'ᵰ': 'n',
597 'ᶇ': 'n',
598 'ɳ': 'n',
599 'ñ': 'n',
600 'nj': 'nj',
601 'ó': 'o',
602 'ŏ': 'o',
603 'ǒ': 'o',
604 'ô': 'o',
605 'ố': 'o',
606 'ộ': 'o',
607 'ồ': 'o',
608 'ổ': 'o',
609 'ỗ': 'o',
610 'ö': 'o',
611 'ȫ': 'o',
612 'ȯ': 'o',
613 'ȱ': 'o',
614 'ọ': 'o',
615 'ő': 'o',
616 'ȍ': 'o',
617 'ò': 'o',
618 'ỏ': 'o',
619 'ơ': 'o',
620 'ớ': 'o',
621 'ợ': 'o',
622 'ờ': 'o',
623 'ở': 'o',
624 'ỡ': 'o',
625 'ȏ': 'o',
626 'ꝋ': 'o',
627 'ꝍ': 'o',
628 'ⱺ': 'o',
629 'ō': 'o',
630 'ṓ': 'o',
631 'ṑ': 'o',
632 'ǫ': 'o',
633 'ǭ': 'o',
634 'ø': 'o',
635 'ǿ': 'o',
636 'õ': 'o',
637 'ṍ': 'o',
638 'ṏ': 'o',
639 'ȭ': 'o',
640 'ƣ': 'oi',
641 'ꝏ': 'oo',
642 'ɛ': 'e',
643 'ᶓ': 'e',
644 'ɔ': 'o',
645 'ᶗ': 'o',
646 'ȣ': 'ou',
647 'ṕ': 'p',
648 'ṗ': 'p',
649 'ꝓ': 'p',
650 'ƥ': 'p',
651 'ᵱ': 'p',
652 'ᶈ': 'p',
653 'ꝕ': 'p',
654 'ᵽ': 'p',
655 'ꝑ': 'p',
656 'ꝙ': 'q',
657 'ʠ': 'q',
658 'ɋ': 'q',
659 'ꝗ': 'q',
660 'ŕ': 'r',
661 'ř': 'r',
662 'ŗ': 'r',
663 'ṙ': 'r',
664 'ṛ': 'r',
665 'ṝ': 'r',
666 'ȑ': 'r',
667 'ɾ': 'r',
668 'ᵳ': 'r',
669 'ȓ': 'r',
670 'ṟ': 'r',
671 'ɼ': 'r',
672 'ᵲ': 'r',
673 'ᶉ': 'r',
674 'ɍ': 'r',
675 'ɽ': 'r',
676 'ↄ': 'c',
677 'ꜿ': 'c',
678 'ɘ': 'e',
679 'ɿ': 'r',
680 'ś': 's',
681 'ṥ': 's',
682 'š': 's',
683 'ṧ': 's',
684 'ş': 's',
685 'ŝ': 's',
686 'ș': 's',
687 'ṡ': 's',
688 'ṣ': 's',
689 'ṩ': 's',
690 'ʂ': 's',
691 'ᵴ': 's',
692 'ᶊ': 's',
693 'ȿ': 's',
694 'ɡ': 'g',
695 'ᴑ': 'o',
696 'ᴓ': 'o',
697 'ᴝ': 'u',
698 'ť': 't',
699 'ţ': 't',
700 'ṱ': 't',
701 'ț': 't',
702 'ȶ': 't',
703 'ẗ': 't',
704 'ⱦ': 't',
705 'ṫ': 't',
706 'ṭ': 't',
707 'ƭ': 't',
708 'ṯ': 't',
709 'ᵵ': 't',
710 'ƫ': 't',
711 'ʈ': 't',
712 'ŧ': 't',
713 'ᵺ': 'th',
714 'ɐ': 'a',
715 'ᴂ': 'ae',
716 'ǝ': 'e',
717 'ᵷ': 'g',
718 'ɥ': 'h',
719 'ʮ': 'h',
720 'ʯ': 'h',
721 'ᴉ': 'i',
722 'ʞ': 'k',
723 'ꞁ': 'l',
724 'ɯ': 'm',
725 'ɰ': 'm',
726 'ᴔ': 'oe',
727 'ɹ': 'r',
728 'ɻ': 'r',
729 'ɺ': 'r',
730 'ⱹ': 'r',
731 'ʇ': 't',
732 'ʌ': 'v',
733 'ʍ': 'w',
734 'ʎ': 'y',
735 'ꜩ': 'tz',
736 'ú': 'u',
737 'ŭ': 'u',
738 'ǔ': 'u',
739 'û': 'u',
740 'ṷ': 'u',
741 'ü': 'u',
742 'ǘ': 'u',
743 'ǚ': 'u',
744 'ǜ': 'u',
745 'ǖ': 'u',
746 'ṳ': 'u',
747 'ụ': 'u',
748 'ű': 'u',
749 'ȕ': 'u',
750 'ù': 'u',
751 'ủ': 'u',
752 'ư': 'u',
753 'ứ': 'u',
754 'ự': 'u',
755 'ừ': 'u',
756 'ử': 'u',
757 'ữ': 'u',
758 'ȗ': 'u',
759 'ū': 'u',
760 'ṻ': 'u',
761 'ų': 'u',
762 'ᶙ': 'u',
763 'ů': 'u',
764 'ũ': 'u',
765 'ṹ': 'u',
766 'ṵ': 'u',
767 'ᵫ': 'ue',
768 'ꝸ': 'um',
769 'ⱴ': 'v',
770 'ꝟ': 'v',
771 'ṿ': 'v',
772 'ʋ': 'v',
773 'ᶌ': 'v',
774 'ⱱ': 'v',
775 'ṽ': 'v',
776 'ꝡ': 'vy',
777 'ẃ': 'w',
778 'ŵ': 'w',
779 'ẅ': 'w',
780 'ẇ': 'w',
781 'ẉ': 'w',
782 'ẁ': 'w',
783 'ⱳ': 'w',
784 'ẘ': 'w',
785 'ẍ': 'x',
786 'ẋ': 'x',
787 'ᶍ': 'x',
788 'ý': 'y',
789 'ŷ': 'y',
790 'ÿ': 'y',
791 'ẏ': 'y',
792 'ỵ': 'y',
793 'ỳ': 'y',
794 'ƴ': 'y',
795 'ỷ': 'y',
796 'ỿ': 'y',
797 'ȳ': 'y',
798 'ẙ': 'y',
799 'ɏ': 'y',
800 'ỹ': 'y',
801 'ź': 'z',
802 'ž': 'z',
803 'ẑ': 'z',
804 'ʑ': 'z',
805 'ⱬ': 'z',
806 'ż': 'z',
807 'ẓ': 'z',
808 'ȥ': 'z',
809 'ẕ': 'z',
810 'ᵶ': 'z',
811 'ᶎ': 'z',
812 'ʐ': 'z',
813 'ƶ': 'z',
814 'ɀ': 'z',
815 'ff': 'ff',
816 'ffi': 'ffi',
817 'ffl': 'ffl',
818 'fi': 'fi',
819 'fl': 'fl',
820 'ij': 'ij',
821 'œ': 'oe',
822 'st': 'st',
823 'ₐ': 'a',
824 'ₑ': 'e',
825 'ᵢ': 'i',
826 'ⱼ': 'j',
827 'ₒ': 'o',
828 'ᵣ': 'r',
829 'ᵤ': 'u',
830 'ᵥ': 'v',
831 'ₓ': 'x'
832 };
833
834 var TypeaheadOptions = /** @class */ (function () {
835 function TypeaheadOptions(options) {
836 this.placement = options.placement;
837 this.animation = options.animation;
838 this.typeaheadRef = options.typeaheadRef;
839 }
840 return TypeaheadOptions;
841 }());
842
843 var TypeaheadMatch = /** @class */ (function () {
844 // eslint-disable-next-line @typescript-eslint/no-explicit-any
845 function TypeaheadMatch(item, value, header) {
846 if (value === void 0) { value = item; }
847 if (header === void 0) { header = false; }
848 this.item = item;
849 this.value = value;
850 this.header = header;
851 }
852 TypeaheadMatch.prototype.isHeader = function () {
853 return this.header;
854 };
855 TypeaheadMatch.prototype.toString = function () {
856 return this.value;
857 };
858 return TypeaheadMatch;
859 }());
860
861 /*! *****************************************************************************
862 Copyright (c) Microsoft Corporation.
863
864 Permission to use, copy, modify, and/or distribute this software for any
865 purpose with or without fee is hereby granted.
866
867 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
868 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
869 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
870 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
871 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
872 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
873 PERFORMANCE OF THIS SOFTWARE.
874 ***************************************************************************** */
875 /* global Reflect, Promise */
876 var extendStatics = function (d, b) {
877 extendStatics = Object.setPrototypeOf ||
878 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
879 function (d, b) { for (var p in b)
880 if (Object.prototype.hasOwnProperty.call(b, p))
881 d[p] = b[p]; };
882 return extendStatics(d, b);
883 };
884 function __extends(d, b) {
885 if (typeof b !== "function" && b !== null)
886 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
887 extendStatics(d, b);
888 function __() { this.constructor = d; }
889 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
890 }
891 var __assign = function () {
892 __assign = Object.assign || function __assign(t) {
893 for (var s, i = 1, n = arguments.length; i < n; i++) {
894 s = arguments[i];
895 for (var p in s)
896 if (Object.prototype.hasOwnProperty.call(s, p))
897 t[p] = s[p];
898 }
899 return t;
900 };
901 return __assign.apply(this, arguments);
902 };
903 function __rest(s, e) {
904 var t = {};
905 for (var p in s)
906 if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
907 t[p] = s[p];
908 if (s != null && typeof Object.getOwnPropertySymbols === "function")
909 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
910 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
911 t[p[i]] = s[p[i]];
912 }
913 return t;
914 }
915 function __decorate(decorators, target, key, desc) {
916 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
917 if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
918 r = Reflect.decorate(decorators, target, key, desc);
919 else
920 for (var i = decorators.length - 1; i >= 0; i--)
921 if (d = decorators[i])
922 r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
923 return c > 3 && r && Object.defineProperty(target, key, r), r;
924 }
925 function __param(paramIndex, decorator) {
926 return function (target, key) { decorator(target, key, paramIndex); };
927 }
928 function __metadata(metadataKey, metadataValue) {
929 if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
930 return Reflect.metadata(metadataKey, metadataValue);
931 }
932 function __awaiter(thisArg, _arguments, P, generator) {
933 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
934 return new (P || (P = Promise))(function (resolve, reject) {
935 function fulfilled(value) { try {
936 step(generator.next(value));
937 }
938 catch (e) {
939 reject(e);
940 } }
941 function rejected(value) { try {
942 step(generator["throw"](value));
943 }
944 catch (e) {
945 reject(e);
946 } }
947 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
948 step((generator = generator.apply(thisArg, _arguments || [])).next());
949 });
950 }
951 function __generator(thisArg, body) {
952 var _ = { label: 0, sent: function () { if (t[0] & 1)
953 throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
954 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g;
955 function verb(n) { return function (v) { return step([n, v]); }; }
956 function step(op) {
957 if (f)
958 throw new TypeError("Generator is already executing.");
959 while (_)
960 try {
961 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
962 return t;
963 if (y = 0, t)
964 op = [op[0] & 2, t.value];
965 switch (op[0]) {
966 case 0:
967 case 1:
968 t = op;
969 break;
970 case 4:
971 _.label++;
972 return { value: op[1], done: false };
973 case 5:
974 _.label++;
975 y = op[1];
976 op = [0];
977 continue;
978 case 7:
979 op = _.ops.pop();
980 _.trys.pop();
981 continue;
982 default:
983 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
984 _ = 0;
985 continue;
986 }
987 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
988 _.label = op[1];
989 break;
990 }
991 if (op[0] === 6 && _.label < t[1]) {
992 _.label = t[1];
993 t = op;
994 break;
995 }
996 if (t && _.label < t[2]) {
997 _.label = t[2];
998 _.ops.push(op);
999 break;
1000 }
1001 if (t[2])
1002 _.ops.pop();
1003 _.trys.pop();
1004 continue;
1005 }
1006 op = body.call(thisArg, _);
1007 }
1008 catch (e) {
1009 op = [6, e];
1010 y = 0;
1011 }
1012 finally {
1013 f = t = 0;
1014 }
1015 if (op[0] & 5)
1016 throw op[1];
1017 return { value: op[0] ? op[1] : void 0, done: true };
1018 }
1019 }
1020 var __createBinding = Object.create ? (function (o, m, k, k2) {
1021 if (k2 === undefined)
1022 k2 = k;
1023 Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } });
1024 }) : (function (o, m, k, k2) {
1025 if (k2 === undefined)
1026 k2 = k;
1027 o[k2] = m[k];
1028 });
1029 function __exportStar(m, o) {
1030 for (var p in m)
1031 if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
1032 __createBinding(o, m, p);
1033 }
1034 function __values(o) {
1035 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
1036 if (m)
1037 return m.call(o);
1038 if (o && typeof o.length === "number")
1039 return {
1040 next: function () {
1041 if (o && i >= o.length)
1042 o = void 0;
1043 return { value: o && o[i++], done: !o };
1044 }
1045 };
1046 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
1047 }
1048 function __read(o, n) {
1049 var m = typeof Symbol === "function" && o[Symbol.iterator];
1050 if (!m)
1051 return o;
1052 var i = m.call(o), r, ar = [], e;
1053 try {
1054 while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
1055 ar.push(r.value);
1056 }
1057 catch (error) {
1058 e = { error: error };
1059 }
1060 finally {
1061 try {
1062 if (r && !r.done && (m = i["return"]))
1063 m.call(i);
1064 }
1065 finally {
1066 if (e)
1067 throw e.error;
1068 }
1069 }
1070 return ar;
1071 }
1072 /** @deprecated */
1073 function __spread() {
1074 for (var ar = [], i = 0; i < arguments.length; i++)
1075 ar = ar.concat(__read(arguments[i]));
1076 return ar;
1077 }
1078 /** @deprecated */
1079 function __spreadArrays() {
1080 for (var s = 0, i = 0, il = arguments.length; i < il; i++)
1081 s += arguments[i].length;
1082 for (var r = Array(s), k = 0, i = 0; i < il; i++)
1083 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1084 r[k] = a[j];
1085 return r;
1086 }
1087 function __spreadArray(to, from) {
1088 for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
1089 to[j] = from[i];
1090 return to;
1091 }
1092 function __await(v) {
1093 return this instanceof __await ? (this.v = v, this) : new __await(v);
1094 }
1095 function __asyncGenerator(thisArg, _arguments, generator) {
1096 if (!Symbol.asyncIterator)
1097 throw new TypeError("Symbol.asyncIterator is not defined.");
1098 var g = generator.apply(thisArg, _arguments || []), i, q = [];
1099 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
1100 function verb(n) { if (g[n])
1101 i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
1102 function resume(n, v) { try {
1103 step(g[n](v));
1104 }
1105 catch (e) {
1106 settle(q[0][3], e);
1107 } }
1108 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
1109 function fulfill(value) { resume("next", value); }
1110 function reject(value) { resume("throw", value); }
1111 function settle(f, v) { if (f(v), q.shift(), q.length)
1112 resume(q[0][0], q[0][1]); }
1113 }
1114 function __asyncDelegator(o) {
1115 var i, p;
1116 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
1117 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
1118 }
1119 function __asyncValues(o) {
1120 if (!Symbol.asyncIterator)
1121 throw new TypeError("Symbol.asyncIterator is not defined.");
1122 var m = o[Symbol.asyncIterator], i;
1123 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
1124 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
1125 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); }
1126 }
1127 function __makeTemplateObject(cooked, raw) {
1128 if (Object.defineProperty) {
1129 Object.defineProperty(cooked, "raw", { value: raw });
1130 }
1131 else {
1132 cooked.raw = raw;
1133 }
1134 return cooked;
1135 }
1136 ;
1137 var __setModuleDefault = Object.create ? (function (o, v) {
1138 Object.defineProperty(o, "default", { enumerable: true, value: v });
1139 }) : function (o, v) {
1140 o["default"] = v;
1141 };
1142 function __importStar(mod) {
1143 if (mod && mod.__esModule)
1144 return mod;
1145 var result = {};
1146 if (mod != null)
1147 for (var k in mod)
1148 if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
1149 __createBinding(result, mod, k);
1150 __setModuleDefault(result, mod);
1151 return result;
1152 }
1153 function __importDefault(mod) {
1154 return (mod && mod.__esModule) ? mod : { default: mod };
1155 }
1156 function __classPrivateFieldGet(receiver, privateMap) {
1157 if (!privateMap.has(receiver)) {
1158 throw new TypeError("attempted to get private field on non-instance");
1159 }
1160 return privateMap.get(receiver);
1161 }
1162 function __classPrivateFieldSet(receiver, privateMap, value) {
1163 if (!privateMap.has(receiver)) {
1164 throw new TypeError("attempted to set private field on non-instance");
1165 }
1166 privateMap.set(receiver, value);
1167 return value;
1168 }
1169
1170 function latinize(str) {
1171 if (!str) {
1172 return '';
1173 }
1174 return str.replace(/[^A-Za-z0-9[\] ]/g, function (a) {
1175 return latinMap[a] || a;
1176 });
1177 }
1178 function escapeRegexp(queryToEscape) {
1179 // Regex: capture the whole query string and replace it with the string
1180 // that will be used to match the results, for example if the capture is
1181 // 'a' the result will be \a
1182 return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
1183 }
1184 function tokenize(str, wordRegexDelimiters, phraseRegexDelimiters, delimitersForMultipleSearch) {
1185 if (wordRegexDelimiters === void 0) { wordRegexDelimiters = ' '; }
1186 if (phraseRegexDelimiters === void 0) { phraseRegexDelimiters = ''; }
1187 var result = [];
1188 if (!delimitersForMultipleSearch) {
1189 result = tokenizeWordsAndPhrases(str, wordRegexDelimiters, phraseRegexDelimiters);
1190 }
1191 else {
1192 var multipleSearchRegexStr = "([" + delimitersForMultipleSearch + "]+)";
1193 var delimitedTokens = str.split(new RegExp(multipleSearchRegexStr, 'g'));
1194 var lastToken = delimitedTokens[delimitedTokens.length - 1];
1195 if (lastToken > '') {
1196 if (wordRegexDelimiters && phraseRegexDelimiters) {
1197 result = tokenizeWordsAndPhrases(lastToken, wordRegexDelimiters, phraseRegexDelimiters);
1198 }
1199 else {
1200 result.push(lastToken);
1201 }
1202 }
1203 }
1204 return result;
1205 }
1206 function tokenizeWordsAndPhrases(str, wordRegexDelimiters, phraseRegexDelimiters) {
1207 var result = [];
1208 var regexStr = "(?:[" + phraseRegexDelimiters + "])([^" + phraseRegexDelimiters + "]+)" +
1209 ("(?:[" + phraseRegexDelimiters + "])|([^" + wordRegexDelimiters + "]+)");
1210 var preTokenized = str.split(new RegExp(regexStr, 'g'));
1211 var preTokenizedLength = preTokenized.length;
1212 var token;
1213 var replacePhraseDelimiters = new RegExp("[" + phraseRegexDelimiters + "]+", 'g');
1214 for (var i = 0; i < preTokenizedLength; i += 1) {
1215 token = preTokenized[i];
1216 if (token && token.length && token !== wordRegexDelimiters) {
1217 result.push(token.replace(replacePhraseDelimiters, ''));
1218 }
1219 }
1220 return result;
1221 }
1222 // eslint-disable-next-line
1223 function getValueFromObject(object, option) {
1224 var e_1, _a;
1225 if (!option || typeof object !== 'object') {
1226 return object.toString();
1227 }
1228 if (option.endsWith('()')) {
1229 var functionName = option.slice(0, option.length - 2);
1230 return object[functionName]().toString();
1231 }
1232 var properties = option
1233 .replace(/\[(\w+)\]/g, '.$1')
1234 .replace(/^\./, '');
1235 var propertiesArray = properties.split('.');
1236 try {
1237 for (var propertiesArray_1 = __values(propertiesArray), propertiesArray_1_1 = propertiesArray_1.next(); !propertiesArray_1_1.done; propertiesArray_1_1 = propertiesArray_1.next()) {
1238 var property = propertiesArray_1_1.value;
1239 if (property in object) {
1240 // eslint-disable-next-line @typescript-eslint/ban-ts-comment
1241 // @ts-ignore
1242 object = object[property];
1243 }
1244 }
1245 }
1246 catch (e_1_1) { e_1 = { error: e_1_1 }; }
1247 finally {
1248 try {
1249 if (propertiesArray_1_1 && !propertiesArray_1_1.done && (_a = propertiesArray_1.return)) _a.call(propertiesArray_1);
1250 }
1251 finally { if (e_1) throw e_1.error; }
1252 }
1253 if (!object) {
1254 return '';
1255 }
1256 return object.toString();
1257 }
1258
1259 var TYPEAHEAD_ANIMATION_TIMING = '220ms cubic-bezier(0, 0, 0.2, 1)';
1260 var typeaheadAnimation = animations.trigger('typeaheadAnimation', [
1261 animations.state('animated-down', animations.style({ height: '*', overflow: 'hidden' })),
1262 animations.transition('* => animated-down', [
1263 animations.style({ height: 0, overflow: 'hidden' }),
1264 animations.animate(TYPEAHEAD_ANIMATION_TIMING)
1265 ]),
1266 animations.state('animated-up', animations.style({ height: '*', overflow: 'hidden' })),
1267 animations.transition('* => animated-up', [
1268 animations.style({ height: '*', overflow: 'hidden' }),
1269 animations.animate(TYPEAHEAD_ANIMATION_TIMING)
1270 ]),
1271 animations.transition('* => unanimated', animations.animate('0s'))
1272 ]);
1273
1274 var nextWindowId = 0;
1275 var TypeaheadContainerComponent = /** @class */ (function () {
1276 function TypeaheadContainerComponent(positionService, renderer, element, changeDetectorRef) {
1277 var _this = this;
1278 var _a;
1279 this.positionService = positionService;
1280 this.renderer = renderer;
1281 this.element = element;
1282 this.changeDetectorRef = changeDetectorRef;
1283 // eslint-disable-next-line @angular-eslint/no-output-rename
1284 this.activeChangeEvent = new i0.EventEmitter();
1285 this.isFocused = false;
1286 this.positionServiceSubscription = new rxjs.Subscription();
1287 this.height = 0;
1288 this.popupId = "ngb-typeahead-" + nextWindowId++;
1289 this._matches = [];
1290 this.renderer.setAttribute(this.element.nativeElement, 'id', this.popupId);
1291 this.positionServiceSubscription.add((_a = this.positionService.event$) === null || _a === void 0 ? void 0 : _a.subscribe(function () {
1292 if (_this.isAnimated) {
1293 _this.animationState = _this.isTopPosition ? 'animated-up' : 'animated-down';
1294 _this.changeDetectorRef.detectChanges();
1295 return;
1296 }
1297 _this.animationState = 'unanimated';
1298 _this.changeDetectorRef.detectChanges();
1299 }));
1300 }
1301 Object.defineProperty(TypeaheadContainerComponent.prototype, "isBs4", {
1302 get: function () {
1303 return !utils.isBs3();
1304 },
1305 enumerable: false,
1306 configurable: true
1307 });
1308 Object.defineProperty(TypeaheadContainerComponent.prototype, "typeaheadTemplateMethods", {
1309 get: function () {
1310 return {
1311 selectMatch: this.selectMatch.bind(this),
1312 selectActive: this.selectActive.bind(this),
1313 isActive: this.isActive.bind(this)
1314 };
1315 },
1316 enumerable: false,
1317 configurable: true
1318 });
1319 Object.defineProperty(TypeaheadContainerComponent.prototype, "active", {
1320 get: function () {
1321 return this._active;
1322 },
1323 set: function (active) {
1324 this._active = active;
1325 this.activeChanged();
1326 },
1327 enumerable: false,
1328 configurable: true
1329 });
1330 Object.defineProperty(TypeaheadContainerComponent.prototype, "matches", {
1331 get: function () {
1332 return this._matches;
1333 },
1334 set: function (value) {
1335 var _this = this;
1336 var _a;
1337 this.positionService.setOptions({
1338 modifiers: { flip: { enabled: this.adaptivePosition } },
1339 allowedPositions: ['top', 'bottom']
1340 });
1341 this._matches = value;
1342 this.needScrollbar = this.typeaheadScrollable && this.typeaheadOptionsInScrollableView < this.matches.length;
1343 if (this.typeaheadScrollable) {
1344 setTimeout(function () {
1345 _this.setScrollableMode();
1346 });
1347 }
1348 if (this.typeaheadIsFirstItemActive && this._matches.length > 0) {
1349 this.setActive(this._matches[0]);
1350 if ((_a = this._active) === null || _a === void 0 ? void 0 : _a.isHeader()) {
1351 this.nextActiveMatch();
1352 }
1353 }
1354 if (this._active && !this.typeaheadIsFirstItemActive) {
1355 var concurrency = this._matches.find(function (match) { var _a; return match.value === ((_a = _this._active) === null || _a === void 0 ? void 0 : _a.value); });
1356 if (concurrency) {
1357 this.selectActive(concurrency);
1358 return;
1359 }
1360 this.active = void 0;
1361 }
1362 },
1363 enumerable: false,
1364 configurable: true
1365 });
1366 Object.defineProperty(TypeaheadContainerComponent.prototype, "isTopPosition", {
1367 get: function () {
1368 return this.element.nativeElement.classList.contains('top');
1369 },
1370 enumerable: false,
1371 configurable: true
1372 });
1373 Object.defineProperty(TypeaheadContainerComponent.prototype, "optionsListTemplate", {
1374 get: function () {
1375 return this.parent ? this.parent.optionsListTemplate : undefined;
1376 },
1377 enumerable: false,
1378 configurable: true
1379 });
1380 Object.defineProperty(TypeaheadContainerComponent.prototype, "isAnimated", {
1381 get: function () {
1382 return this.parent ? this.parent.isAnimated : false;
1383 },
1384 enumerable: false,
1385 configurable: true
1386 });
1387 Object.defineProperty(TypeaheadContainerComponent.prototype, "adaptivePosition", {
1388 get: function () {
1389 return this.parent ? this.parent.adaptivePosition : false;
1390 },
1391 enumerable: false,
1392 configurable: true
1393 });
1394 Object.defineProperty(TypeaheadContainerComponent.prototype, "typeaheadScrollable", {
1395 get: function () {
1396 return this.parent ? this.parent.typeaheadScrollable : false;
1397 },
1398 enumerable: false,
1399 configurable: true
1400 });
1401 Object.defineProperty(TypeaheadContainerComponent.prototype, "typeaheadOptionsInScrollableView", {
1402 get: function () {
1403 return this.parent ? this.parent.typeaheadOptionsInScrollableView : 5;
1404 },
1405 enumerable: false,
1406 configurable: true
1407 });
1408 Object.defineProperty(TypeaheadContainerComponent.prototype, "typeaheadIsFirstItemActive", {
1409 get: function () {
1410 return this.parent ? this.parent.typeaheadIsFirstItemActive : true;
1411 },
1412 enumerable: false,
1413 configurable: true
1414 });
1415 Object.defineProperty(TypeaheadContainerComponent.prototype, "itemTemplate", {
1416 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1417 get: function () {
1418 return this.parent ? this.parent.typeaheadItemTemplate : undefined;
1419 },
1420 enumerable: false,
1421 configurable: true
1422 });
1423 TypeaheadContainerComponent.prototype.selectActiveMatch = function (isActiveItemChanged) {
1424 var _a, _b;
1425 if (this._active && ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.typeaheadSelectFirstItem)) {
1426 this.selectMatch(this._active);
1427 }
1428 if (!((_b = this.parent) === null || _b === void 0 ? void 0 : _b.typeaheadSelectFirstItem) && isActiveItemChanged) {
1429 this.selectMatch(this._active);
1430 }
1431 };
1432 TypeaheadContainerComponent.prototype.activeChanged = function () {
1433 if (!this._active) {
1434 return;
1435 }
1436 var index = this.matches.indexOf(this._active);
1437 this.activeChangeEvent.emit(this.popupId + "-" + index);
1438 };
1439 TypeaheadContainerComponent.prototype.prevActiveMatch = function () {
1440 if (!this._active) {
1441 return;
1442 }
1443 var index = this.matches.indexOf(this._active);
1444 this.setActive(this.matches[index - 1 < 0 ? this.matches.length - 1 : index - 1]);
1445 if (this._active.isHeader()) {
1446 this.prevActiveMatch();
1447 }
1448 if (this.typeaheadScrollable) {
1449 this.scrollPrevious(index);
1450 }
1451 };
1452 TypeaheadContainerComponent.prototype.nextActiveMatch = function () {
1453 var _a;
1454 var index = this._active ? this.matches.indexOf(this._active) : -1;
1455 this.setActive(this.matches[index + 1 > this.matches.length - 1 ? 0 : index + 1]);
1456 if ((_a = this._active) === null || _a === void 0 ? void 0 : _a.isHeader()) {
1457 this.nextActiveMatch();
1458 }
1459 if (this.typeaheadScrollable) {
1460 this.scrollNext(index);
1461 }
1462 };
1463 TypeaheadContainerComponent.prototype.selectActive = function (value) {
1464 this.isFocused = true;
1465 this.setActive(value);
1466 };
1467 TypeaheadContainerComponent.prototype.highlight = function (match, query) {
1468 var itemStr = match.value;
1469 var itemStrHelper = (this.parent && this.parent.typeaheadLatinize
1470 ? latinize(itemStr)
1471 : itemStr).toLowerCase();
1472 var startIdx;
1473 var tokenLen;
1474 // Replaces the capture string with the same string inside of a "strong" tag
1475 if (typeof query === 'object') {
1476 var queryLen = query.length;
1477 for (var i = 0; i < queryLen; i += 1) {
1478 // query[i] is already latinized and lower case
1479 startIdx = itemStrHelper.indexOf(query[i]);
1480 tokenLen = query[i].length;
1481 if (startIdx >= 0 && tokenLen > 0) {
1482 itemStr =
1483 itemStr.substring(0, startIdx) + "<strong>" + itemStr.substring(startIdx, startIdx + tokenLen) + "</strong>" +
1484 ("" + itemStr.substring(startIdx + tokenLen));
1485 itemStrHelper =
1486 itemStrHelper.substring(0, startIdx) + " " + ' '.repeat(tokenLen) + " " +
1487 ("" + itemStrHelper.substring(startIdx + tokenLen));
1488 }
1489 }
1490 }
1491 else if (query) {
1492 // query is already latinized and lower case
1493 startIdx = itemStrHelper.indexOf(query);
1494 tokenLen = query.length;
1495 if (startIdx >= 0 && tokenLen > 0) {
1496 itemStr =
1497 itemStr.substring(0, startIdx) + "<strong>" + itemStr.substring(startIdx, startIdx + tokenLen) + "</strong>" +
1498 ("" + itemStr.substring(startIdx + tokenLen));
1499 }
1500 }
1501 return itemStr;
1502 };
1503 TypeaheadContainerComponent.prototype.focusLost = function () {
1504 this.isFocused = false;
1505 this.setActive(void 0);
1506 };
1507 TypeaheadContainerComponent.prototype.isActive = function (value) {
1508 return this.active === value;
1509 };
1510 TypeaheadContainerComponent.prototype.selectMatch = function (value, event) {
1511 var _this = this;
1512 var _a;
1513 if (event) {
1514 event.stopPropagation();
1515 event.preventDefault();
1516 }
1517 (_a = this.parent) === null || _a === void 0 ? void 0 : _a.changeModel(value);
1518 setTimeout(function () { var _a; return (_a = _this.parent) === null || _a === void 0 ? void 0 : _a.typeaheadOnSelect.emit(value); }, 0);
1519 return false;
1520 };
1521 TypeaheadContainerComponent.prototype.setScrollableMode = function () {
1522 var _a;
1523 if (!this.ulElement) {
1524 this.ulElement = this.element;
1525 }
1526 if ((_a = this.liElements) === null || _a === void 0 ? void 0 : _a.first) {
1527 var ulStyles = utils.Utils.getStyles(this.ulElement.nativeElement);
1528 var liStyles = utils.Utils.getStyles(this.liElements.first.nativeElement);
1529 var ulPaddingBottom = parseFloat((ulStyles['padding-bottom'] ? ulStyles['padding-bottom'] : '')
1530 .replace('px', ''));
1531 var ulPaddingTop = parseFloat((ulStyles['padding-top'] ? ulStyles['padding-top'] : '0')
1532 .replace('px', ''));
1533 var optionHeight = parseFloat((liStyles.height ? liStyles.height : '0')
1534 .replace('px', ''));
1535 var height = this.typeaheadOptionsInScrollableView * optionHeight;
1536 this.guiHeight = height + ulPaddingTop + ulPaddingBottom + "px";
1537 }
1538 this.renderer.setStyle(this.element.nativeElement, 'visibility', 'visible');
1539 };
1540 TypeaheadContainerComponent.prototype.scrollPrevious = function (index) {
1541 if (index === 0) {
1542 this.scrollToBottom();
1543 return;
1544 }
1545 if (this.liElements && this.ulElement) {
1546 var liElement = this.liElements.toArray()[index - 1];
1547 if (liElement && !this.isScrolledIntoView(liElement.nativeElement)) {
1548 this.ulElement.nativeElement.scrollTop = liElement.nativeElement.offsetTop;
1549 }
1550 }
1551 };
1552 TypeaheadContainerComponent.prototype.scrollNext = function (index) {
1553 if (index + 1 > this.matches.length - 1) {
1554 this.scrollToTop();
1555 return;
1556 }
1557 if (this.liElements && this.ulElement) {
1558 var liElement = this.liElements.toArray()[index + 1];
1559 if (liElement && !this.isScrolledIntoView(liElement.nativeElement)) {
1560 this.ulElement.nativeElement.scrollTop =
1561 liElement.nativeElement.offsetTop -
1562 Number(this.ulElement.nativeElement.offsetHeight) +
1563 Number(liElement.nativeElement.offsetHeight);
1564 }
1565 }
1566 };
1567 TypeaheadContainerComponent.prototype.ngOnDestroy = function () {
1568 this.positionServiceSubscription.unsubscribe();
1569 };
1570 TypeaheadContainerComponent.prototype.setActive = function (value) {
1571 var _a;
1572 this._active = value;
1573 var preview;
1574 if (!(this._active == null || this._active.isHeader())) {
1575 preview = value;
1576 }
1577 (_a = this.parent) === null || _a === void 0 ? void 0 : _a.typeaheadOnPreview.emit(preview);
1578 };
1579 TypeaheadContainerComponent.prototype.isScrolledIntoView = function (elem) {
1580 if (!this.ulElement) {
1581 return false;
1582 }
1583 var containerViewTop = this.ulElement.nativeElement.scrollTop;
1584 var containerViewBottom = containerViewTop + Number(this.ulElement.nativeElement.offsetHeight);
1585 var elemTop = elem.offsetTop;
1586 var elemBottom = elemTop + elem.offsetHeight;
1587 return ((elemBottom <= containerViewBottom) && (elemTop >= containerViewTop));
1588 };
1589 ;
1590 TypeaheadContainerComponent.prototype.scrollToBottom = function () {
1591 var _a;
1592 if (!((_a = this.ulElement) === null || _a === void 0 ? void 0 : _a.nativeElement)) {
1593 return;
1594 }
1595 this.ulElement.nativeElement.scrollTop = this.ulElement.nativeElement.scrollHeight;
1596 };
1597 TypeaheadContainerComponent.prototype.scrollToTop = function () {
1598 var _a;
1599 if (!((_a = this.ulElement) === null || _a === void 0 ? void 0 : _a.nativeElement)) {
1600 return;
1601 }
1602 this.ulElement.nativeElement.scrollTop = 0;
1603 };
1604 return TypeaheadContainerComponent;
1605 }());
1606 TypeaheadContainerComponent.decorators = [
1607 { type: i0.Component, args: [{
1608 selector: 'typeahead-container',
1609 template: "<!-- inject options list template -->\n<ng-template [ngTemplateOutlet]=\"optionsListTemplate || (isBs4 ? bs4Template : bs3Template)\"\n [ngTemplateOutletContext]=\"{\n matches: matches,\n itemTemplate: itemTemplate || bsItemTemplate,\n query: query,\n $implicit: typeaheadTemplateMethods\n }\">\n</ng-template>\n\n<!-- default options item template -->\n<ng-template #bsItemTemplate let-match=\"match\" let-query=\"query\">\n <span [innerHtml]=\"highlight(match, query)\"></span>\n</ng-template>\n\n<!-- Bootstrap 3 options list template -->\n<ng-template #bs3Template>\n <ul class=\"dropdown-menu\"\n #ulElement\n role=\"listbox\"\n [style.overflow-y]=\"needScrollbar ? 'scroll': 'auto'\"\n [style.height]=\"needScrollbar ? guiHeight: 'auto'\">\n <ng-template ngFor let-match let-i=\"index\" [ngForOf]=\"matches\">\n <li #liElements *ngIf=\"match.isHeader()\" class=\"dropdown-header\">{{ match }}</li>\n <li #liElements\n *ngIf=\"!match.isHeader()\"\n [id]=\"popupId + '-' + i\"\n role=\"option\"\n [@typeaheadAnimation]=\"animationState\"\n [class.active]=\"isActive(match)\"\n (mouseenter)=\"selectActive(match)\">\n\n <a href=\"#\" (click)=\"selectMatch(match, $event)\" tabindex=\"-1\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate || bsItemTemplate\"\n [ngTemplateOutletContext]=\"{item: match.item, index: i, match: match, query: query}\">\n </ng-template>\n </a>\n </li>\n </ng-template>\n </ul>\n</ng-template>\n\n<!-- Bootstrap 4 options list template -->\n<ng-template #bs4Template>\n <ng-template ngFor let-match let-i=\"index\" [ngForOf]=\"matches\">\n <h6 *ngIf=\"match.isHeader()\" class=\"dropdown-header\">{{ match }}</h6>\n <ng-template [ngIf]=\"!match.isHeader()\">\n <button #liElements\n [id]=\"popupId + '-' + i\"\n role=\"option\"\n [@typeaheadAnimation]=\"animationState\"\n class=\"dropdown-item\"\n (click)=\"selectMatch(match, $event)\"\n (mouseenter)=\"selectActive(match)\"\n [class.active]=\"isActive(match)\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate || bsItemTemplate\"\n [ngTemplateOutletContext]=\"{item: match.item, index: i, match: match, query: query}\">\n </ng-template>\n </button>\n </ng-template>\n </ng-template>\n</ng-template>\n",
1610 // eslint-disable-next-line @angular-eslint/no-host-metadata-property
1611 host: {
1612 class: 'dropdown open bottom',
1613 '[class.dropdown-menu]': 'isBs4',
1614 '[style.height]': "isBs4 && needScrollbar ? guiHeight: 'auto'",
1615 '[style.visibility]': "'inherit'",
1616 '[class.dropup]': 'dropup',
1617 style: 'position: absolute;display: block;',
1618 '[attr.role]': "isBs4 ? 'listbox' : null "
1619 },
1620 animations: [typeaheadAnimation],
1621 styles: ["\n :host.dropdown {\n z-index: 1000;\n }\n\n :host.dropdown-menu, .dropdown-menu {\n overflow-y: auto;\n height: 100px;\n }\n "]
1622 },] }
1623 ];
1624 TypeaheadContainerComponent.ctorParameters = function () { return [
1625 { type: positioning.PositioningService },
1626 { type: i0.Renderer2 },
1627 { type: i0.ElementRef },
1628 { type: i0.ChangeDetectorRef }
1629 ]; };
1630 TypeaheadContainerComponent.propDecorators = {
1631 activeChangeEvent: [{ type: i0.Output, args: ['activeChange',] }],
1632 ulElement: [{ type: i0.ViewChild, args: ['ulElement', { static: false },] }],
1633 liElements: [{ type: i0.ViewChildren, args: ['liElements',] }],
1634 focusLost: [{ type: i0.HostListener, args: ['mouseleave',] }, { type: i0.HostListener, args: ['blur',] }]
1635 };
1636
1637 /** Default values provider for typeahead */
1638 var TypeaheadConfig = /** @class */ (function () {
1639 function TypeaheadConfig() {
1640 /** sets use adaptive position */
1641 this.adaptivePosition = false;
1642 /** turn on/off animation */
1643 this.isAnimated = false;
1644 /** used to hide results on blur */
1645 this.hideResultsOnBlur = true;
1646 /** if true, typeahead will cancel async request on blur */
1647 this.cancelRequestOnFocusLost = false;
1648 /** used to choose the first item in typeahead container */
1649 this.selectFirstItem = true;
1650 /** used to active/inactive the first item in typeahead container */
1651 this.isFirstItemActive = true;
1652 /** used to choose set minimal no of characters that needs to
1653 * be entered before typeahead kicks-in
1654 */
1655 this.minLength = 1;
1656 }
1657 return TypeaheadConfig;
1658 }());
1659 TypeaheadConfig.ɵprov = i0.ɵɵdefineInjectable({ factory: function TypeaheadConfig_Factory() { return new TypeaheadConfig(); }, token: TypeaheadConfig, providedIn: "root" });
1660 TypeaheadConfig.decorators = [
1661 { type: i0.Injectable, args: [{ providedIn: 'root' },] }
1662 ];
1663
1664 var TypeaheadDirective = /** @class */ (function () {
1665 function TypeaheadDirective(cis, config, changeDetection, element, ngControl, renderer, viewContainerRef) {
1666 this.changeDetection = changeDetection;
1667 this.element = element;
1668 this.ngControl = ngControl;
1669 this.renderer = renderer;
1670 /** minimal no of characters that needs to be entered before
1671 * typeahead kicks-in. When set to 0, typeahead shows on focus with full
1672 * list of options (limited as normal by typeaheadOptionsLimit)
1673 */
1674 this.typeaheadMinLength = 1;
1675 /** sets use adaptive position */
1676 this.adaptivePosition = false;
1677 /** turn on/off animation */
1678 this.isAnimated = false;
1679 /** minimal wait time after last character typed before typeahead kicks-in */
1680 this.typeaheadWaitMs = 0;
1681 /** match latin symbols.
1682 * If true the word súper would match super and vice versa.
1683 */
1684 this.typeaheadLatinize = true;
1685 /** Can be use to search words by inserting a single white space between each characters
1686 * for example 'C a l i f o r n i a' will match 'California'.
1687 */
1688 this.typeaheadSingleWords = true;
1689 /** should be used only in case typeaheadSingleWords attribute is true.
1690 * Sets the word delimiter to break words. Defaults to space.
1691 */
1692 this.typeaheadWordDelimiters = ' ';
1693 /** should be used only in case typeaheadMultipleSearch attribute is true.
1694 * Sets the multiple search delimiter to know when to start a new search. Defaults to comma.
1695 * If space needs to be used, then explicitly set typeaheadWordDelimiters to something else than space
1696 * because space is used by default OR set typeaheadSingleWords attribute to false if you don't need
1697 * to use it together with multiple search.
1698 */
1699 this.typeaheadMultipleSearchDelimiters = ',';
1700 /** should be used only in case typeaheadSingleWords attribute is true.
1701 * Sets the word delimiter to match exact phrase.
1702 * Defaults to simple and double quotes.
1703 */
1704 this.typeaheadPhraseDelimiters = '\'"';
1705 /** specifies if typeahead is scrollable */
1706 this.typeaheadScrollable = false;
1707 /** specifies number of options to show in scroll view */
1708 this.typeaheadOptionsInScrollableView = 5;
1709 /** fired when an options list was opened and the user clicked Tab
1710 * If a value equal true, it will be chosen first or active item in the list
1711 * If value equal false, it will be chosen an active item in the list or nothing
1712 */
1713 this.typeaheadSelectFirstItem = true;
1714 /** makes active first item in a list */
1715 this.typeaheadIsFirstItemActive = true;
1716 /** fired when 'busy' state of this component was changed,
1717 * fired on async mode only, returns boolean
1718 */
1719 this.typeaheadLoading = new i0.EventEmitter();
1720 /** fired on every key event and returns true
1721 * in case of matches are not detected
1722 */
1723 this.typeaheadNoResults = new i0.EventEmitter();
1724 /** fired when option was selected, return object with data of this option. */
1725 this.typeaheadOnSelect = new i0.EventEmitter();
1726 /** fired when option was previewed, return object with data of this option. */
1727 this.typeaheadOnPreview = new i0.EventEmitter();
1728 /** fired when blur event occurs. returns the active item */
1729 this.typeaheadOnBlur = new i0.EventEmitter();
1730 /** This attribute indicates that the dropdown should be opened upwards */
1731 this.dropup = false;
1732 this.isOpen = false;
1733 this.list = 'list';
1734 this.isActiveItemChanged = false;
1735 this.isFocused = false;
1736 this.cancelRequestOnFocusLost = false;
1737 this.keyUpEventEmitter = new i0.EventEmitter();
1738 this.placement = 'bottom left';
1739 this._matches = [];
1740 this._subscriptions = [];
1741 this._outsideClickListener = function () { return void 0; };
1742 this._typeahead = cis.createLoader(element, viewContainerRef, renderer)
1743 .provide({ provide: TypeaheadConfig, useValue: config });
1744 Object.assign(this, {
1745 typeaheadHideResultsOnBlur: config.hideResultsOnBlur,
1746 cancelRequestOnFocusLost: config.cancelRequestOnFocusLost,
1747 typeaheadSelectFirstItem: config.selectFirstItem,
1748 typeaheadIsFirstItemActive: config.isFirstItemActive,
1749 typeaheadMinLength: config.minLength,
1750 adaptivePosition: config.adaptivePosition,
1751 isAnimated: config.isAnimated
1752 });
1753 }
1754 Object.defineProperty(TypeaheadDirective.prototype, "matches", {
1755 get: function () {
1756 return this._matches;
1757 },
1758 enumerable: false,
1759 configurable: true
1760 });
1761 TypeaheadDirective.prototype.ngOnInit = function () {
1762 this.typeaheadOptionsLimit = this.typeaheadOptionsLimit || 20;
1763 this.typeaheadMinLength =
1764 this.typeaheadMinLength === void 0 ? 1 : this.typeaheadMinLength;
1765 // async should be false in case of array
1766 if (this.typeaheadAsync === undefined && !(rxjs.isObservable(this.typeahead))) {
1767 this.typeaheadAsync = false;
1768 }
1769 if (rxjs.isObservable(this.typeahead)) {
1770 this.typeaheadAsync = true;
1771 }
1772 if (this.typeaheadAsync) {
1773 this.asyncActions();
1774 }
1775 else {
1776 this.syncActions();
1777 }
1778 this.checkDelimitersConflict();
1779 };
1780 // eslint-disable-next-line @typescript-eslint/no-explicit-any
1781 TypeaheadDirective.prototype.onInput = function (e) {
1782 // For `<input>`s, use the `value` property. For others that don't have a
1783 // `value` (such as `<span contenteditable="true">`), use either
1784 // `textContent` or `innerText` (depending on which one is supported, i.e.
1785 // Firefox or IE).
1786 var value = e.target.value !== undefined
1787 ? e.target.value
1788 : e.target.textContent !== undefined
1789 ? e.target.textContent
1790 : e.target.innerText;
1791 if (value != null && value.trim().length >= this.typeaheadMinLength) {
1792 this.typeaheadLoading.emit(true);
1793 this.keyUpEventEmitter.emit(e.target.value);
1794 }
1795 else {
1796 this.typeaheadLoading.emit(false);
1797 this.typeaheadNoResults.emit(false);
1798 this.hide();
1799 }
1800 };
1801 TypeaheadDirective.prototype.onChange = function (event) {
1802 if (this._container) {
1803 // esc
1804 if (event.keyCode === 27 || event.key === 'Escape') {
1805 this.hide();
1806 return;
1807 }
1808 // up
1809 if (event.keyCode === 38 || event.key === 'ArrowUp') {
1810 this.isActiveItemChanged = true;
1811 this._container.prevActiveMatch();
1812 return;
1813 }
1814 // down
1815 if (event.keyCode === 40 || event.key === 'ArrowDown') {
1816 this.isActiveItemChanged = true;
1817 this._container.nextActiveMatch();
1818 return;
1819 }
1820 // enter
1821 if (event.keyCode === 13 || event.key === 'Enter') {
1822 this._container.selectActiveMatch();
1823 return;
1824 }
1825 }
1826 };
1827 TypeaheadDirective.prototype.onFocus = function () {
1828 var _this = this;
1829 this.isFocused = true;
1830 // add setTimeout to fix issue #5251
1831 // to get and emit updated value if it's changed on focus
1832 setTimeout(function () {
1833 if (_this.typeaheadMinLength === 0) {
1834 _this.typeaheadLoading.emit(true);
1835 _this.keyUpEventEmitter.emit(_this.element.nativeElement.value || '');
1836 }
1837 }, 0);
1838 };
1839 TypeaheadDirective.prototype.onBlur = function () {
1840 var _a;
1841 this.isFocused = false;
1842 if (this._container && !this._container.isFocused) {
1843 this.typeaheadOnBlur.emit(this._container.active);
1844 }
1845 if (!this.container && ((_a = this._matches) === null || _a === void 0 ? void 0 : _a.length) === 0) {
1846 this.typeaheadOnBlur.emit(new TypeaheadMatch(this.element.nativeElement.value, this.element.nativeElement.value, false));
1847 }
1848 };
1849 TypeaheadDirective.prototype.onKeydown = function (event) {
1850 // no container - no problems
1851 if (!this._container) {
1852 return;
1853 }
1854 if (event.keyCode === 9 || event.key === 'Tab') {
1855 this.onBlur();
1856 }
1857 if (event.keyCode === 9 || event.key === 'Tab' || event.keyCode === 13 || event.key === 'Enter') {
1858 event.preventDefault();
1859 if (this.typeaheadSelectFirstItem) {
1860 this._container.selectActiveMatch();
1861 return;
1862 }
1863 if (!this.typeaheadSelectFirstItem) {
1864 this._container.selectActiveMatch(this.isActiveItemChanged);
1865 this.isActiveItemChanged = false;
1866 this.hide();
1867 }
1868 }
1869 };
1870 TypeaheadDirective.prototype.changeModel = function (match) {
1871 var _a;
1872 if (!match) {
1873 return;
1874 }
1875 var valueStr;
1876 if (this.typeaheadMultipleSearch && this._allEnteredValue) {
1877 var tokens = this._allEnteredValue.split(new RegExp("([" + this.typeaheadMultipleSearchDelimiters + "]+)"));
1878 this._allEnteredValue = tokens.slice(0, tokens.length - 1).concat(match.value).join('');
1879 valueStr = this._allEnteredValue;
1880 }
1881 else {
1882 valueStr = match.value;
1883 }
1884 this.ngControl.viewToModelUpdate(valueStr);
1885 (_a = this.ngControl.control) === null || _a === void 0 ? void 0 : _a.setValue(valueStr);
1886 this.changeDetection.markForCheck();
1887 this.hide();
1888 };
1889 TypeaheadDirective.prototype.show = function () {
1890 var _this = this;
1891 this._typeahead
1892 .attach(TypeaheadContainerComponent)
1893 .to(this.container)
1894 .position({ attachment: (this.dropup ? 'top' : 'bottom') + " left" })
1895 .show({
1896 typeaheadRef: this,
1897 placement: this.placement,
1898 animation: false,
1899 dropup: this.dropup
1900 });
1901 this._outsideClickListener = this.renderer
1902 .listen('document', 'click', function (event) {
1903 if (_this.typeaheadMinLength === 0 && _this.element.nativeElement.contains(event.target)) {
1904 return;
1905 }
1906 if (!_this.typeaheadHideResultsOnBlur || _this.element.nativeElement.contains(event.target)) {
1907 return;
1908 }
1909 _this.onOutsideClick();
1910 });
1911 if (!this._typeahead.instance || !this.ngControl.control) {
1912 return;
1913 }
1914 this._container = this._typeahead.instance;
1915 this._container.parent = this;
1916 // This improves the speed as it won't have to be done for each list item
1917 var normalizedQuery = (this.typeaheadLatinize
1918 ? latinize(this.ngControl.control.value)
1919 : this.ngControl.control.value)
1920 .toString()
1921 .toLowerCase();
1922 this._container.query = this.tokenizeQuery(normalizedQuery);
1923 this._container.matches = this._matches;
1924 this.element.nativeElement.focus();
1925 this._container.activeChangeEvent.subscribe(function (activeId) {
1926 _this.activeDescendant = activeId;
1927 _this.changeDetection.markForCheck();
1928 });
1929 this.isOpen = true;
1930 };
1931 TypeaheadDirective.prototype.hide = function () {
1932 if (this._typeahead.isShown) {
1933 this._typeahead.hide();
1934 this._outsideClickListener();
1935 this._container = void 0;
1936 this.isOpen = false;
1937 this.changeDetection.markForCheck();
1938 }
1939 this.typeaheadOnPreview.emit();
1940 };
1941 TypeaheadDirective.prototype.onOutsideClick = function () {
1942 if (this._container && !this._container.isFocused) {
1943 this.hide();
1944 }
1945 };
1946 TypeaheadDirective.prototype.ngOnDestroy = function () {
1947 var e_1, _b;
1948 try {
1949 // clean up subscriptions
1950 for (var _c = __values(this._subscriptions), _d = _c.next(); !_d.done; _d = _c.next()) {
1951 var sub = _d.value;
1952 sub.unsubscribe();
1953 }
1954 }
1955 catch (e_1_1) { e_1 = { error: e_1_1 }; }
1956 finally {
1957 try {
1958 if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
1959 }
1960 finally { if (e_1) throw e_1.error; }
1961 }
1962 this._typeahead.dispose();
1963 };
1964 TypeaheadDirective.prototype.asyncActions = function () {
1965 var _this = this;
1966 this._subscriptions.push(this.keyUpEventEmitter
1967 .pipe(operators.debounceTime(this.typeaheadWaitMs), operators.tap(function (value) { return _this._allEnteredValue = value; }), operators.switchMap(function () {
1968 if (!_this.typeahead) {
1969 return rxjs.EMPTY;
1970 }
1971 return _this.typeahead;
1972 }))
1973 .subscribe(function (matches) {
1974 _this.finalizeAsyncCall(matches);
1975 }));
1976 };
1977 TypeaheadDirective.prototype.syncActions = function () {
1978 var _this = this;
1979 this._subscriptions.push(this.keyUpEventEmitter
1980 .pipe(operators.debounceTime(this.typeaheadWaitMs), operators.mergeMap(function (value) {
1981 _this._allEnteredValue = value;
1982 var normalizedQuery = _this.normalizeQuery(value);
1983 if (!_this.typeahead) {
1984 return rxjs.EMPTY;
1985 }
1986 var typeahead = rxjs.isObservable(_this.typeahead) ? _this.typeahead : rxjs.from(_this.typeahead);
1987 return typeahead
1988 .pipe(operators.filter(function (option) {
1989 return !!option && _this.testMatch(_this.normalizeOption(option), normalizedQuery);
1990 }), operators.toArray());
1991 }))
1992 .subscribe(function (matches) {
1993 _this.finalizeAsyncCall(matches);
1994 }));
1995 };
1996 TypeaheadDirective.prototype.normalizeOption = function (option) {
1997 var optionValue = getValueFromObject(option, this.typeaheadOptionField);
1998 var normalizedOption = this.typeaheadLatinize
1999 ? latinize(optionValue)
2000 : optionValue;
2001 return normalizedOption.toLowerCase();
2002 };
2003 TypeaheadDirective.prototype.tokenizeQuery = function (currentQuery) {
2004 var query = currentQuery;
2005 if (this.typeaheadMultipleSearch && this.typeaheadSingleWords) {
2006 if (!this.haveCommonCharacters("" + this.typeaheadPhraseDelimiters + this.typeaheadWordDelimiters, this.typeaheadMultipleSearchDelimiters)) {
2007 // single words and multiple search delimiters are different, can be used together
2008 query = tokenize(query, this.typeaheadWordDelimiters, this.typeaheadPhraseDelimiters, this.typeaheadMultipleSearchDelimiters);
2009 }
2010 }
2011 else if (this.typeaheadSingleWords) {
2012 query = tokenize(query, this.typeaheadWordDelimiters, this.typeaheadPhraseDelimiters);
2013 }
2014 else {
2015 // multiple searches
2016 query = tokenize(query, void 0, void 0, this.typeaheadMultipleSearchDelimiters);
2017 }
2018 return query;
2019 };
2020 TypeaheadDirective.prototype.normalizeQuery = function (value) {
2021 // If singleWords, break model here to not be doing extra work on each iteration
2022 var normalizedQuery = (this.typeaheadLatinize
2023 ? latinize(value)
2024 : value)
2025 .toString()
2026 .toLowerCase();
2027 normalizedQuery = this.tokenizeQuery(normalizedQuery);
2028 return normalizedQuery;
2029 };
2030 TypeaheadDirective.prototype.testMatch = function (match, test) {
2031 var spaceLength;
2032 if (typeof test === 'object') {
2033 spaceLength = test.length;
2034 for (var i = 0; i < spaceLength; i += 1) {
2035 if (test[i].length > 0 && match.indexOf(test[i]) < 0) {
2036 return false;
2037 }
2038 }
2039 return true;
2040 }
2041 return match.indexOf(test) >= 0;
2042 };
2043 TypeaheadDirective.prototype.finalizeAsyncCall = function (matches) {
2044 this.prepareMatches(matches || []);
2045 this.typeaheadLoading.emit(false);
2046 this.typeaheadNoResults.emit(!this.hasMatches());
2047 if (!this.hasMatches()) {
2048 this.hide();
2049 return;
2050 }
2051 if (!this.isFocused && this.cancelRequestOnFocusLost) {
2052 return;
2053 }
2054 if (this._container && this.ngControl.control) {
2055 // fix: remove usage of ngControl internals
2056 var _controlValue = (this.typeaheadLatinize
2057 ? latinize(this.ngControl.control.value)
2058 : this.ngControl.control.value) || '';
2059 // This improves the speed as it won't have to be done for each list item
2060 var normalizedQuery = _controlValue.toString().toLowerCase();
2061 this._container.query = this.tokenizeQuery(normalizedQuery);
2062 this._container.matches = this._matches;
2063 }
2064 else {
2065 this.show();
2066 }
2067 };
2068 TypeaheadDirective.prototype.prepareMatches = function (options) {
2069 var _this = this;
2070 var limited = options.slice(0, this.typeaheadOptionsLimit);
2071 var sorted = !this.typeaheadOrderBy ? limited : this.orderMatches(limited);
2072 if (this.typeaheadGroupField) {
2073 var matches_1 = [];
2074 // extract all group names
2075 var groups = sorted
2076 .map(function (option) { return getValueFromObject(option, _this.typeaheadGroupField); })
2077 .filter(function (v, i, a) { return a.indexOf(v) === i; });
2078 groups.forEach(function (group) {
2079 // add group header to array of matches
2080 matches_1.push(new TypeaheadMatch(group, group, true));
2081 // add each item of group to array of matches
2082 matches_1 = matches_1.concat(sorted
2083 .filter(function (option) { return getValueFromObject(option, _this.typeaheadGroupField) === group; })
2084 .map(function (option) { return new TypeaheadMatch(option, getValueFromObject(option, _this.typeaheadOptionField)); }));
2085 });
2086 this._matches = matches_1;
2087 }
2088 else {
2089 this._matches = sorted.map(
2090 // eslint-disable-next-line @typescript-eslint/no-explicit-any
2091 function (option) { return new TypeaheadMatch(option, getValueFromObject(option, _this.typeaheadOptionField)); });
2092 }
2093 };
2094 TypeaheadDirective.prototype.orderMatches = function (options) {
2095 if (!options.length) {
2096 return options;
2097 }
2098 if (this.typeaheadOrderBy !== null
2099 && this.typeaheadOrderBy !== undefined
2100 && typeof this.typeaheadOrderBy === 'object'
2101 && Object.keys(this.typeaheadOrderBy).length === 0) {
2102 console.error('Field and direction properties for typeaheadOrderBy have to be set according to documentation!');
2103 return options;
2104 }
2105 var _b = (this.typeaheadOrderBy || {}), field = _b.field, direction = _b.direction;
2106 if (!direction || !(direction === 'asc' || direction === 'desc')) {
2107 console.error('typeaheadOrderBy direction has to equal "asc" or "desc". Please follow the documentation.');
2108 return options;
2109 }
2110 if (typeof options[0] === 'string') {
2111 return direction === 'asc' ? options.sort() : options.sort().reverse();
2112 }
2113 if (!field || typeof field !== 'string') {
2114 console.error('typeaheadOrderBy field has to set according to the documentation.');
2115 return options;
2116 }
2117 return options.sort(function (a, b) {
2118 var stringA = getValueFromObject(a, field);
2119 var stringB = getValueFromObject(b, field);
2120 if (stringA < stringB) {
2121 return direction === 'asc' ? -1 : 1;
2122 }
2123 if (stringA > stringB) {
2124 return direction === 'asc' ? 1 : -1;
2125 }
2126 return 0;
2127 });
2128 };
2129 TypeaheadDirective.prototype.hasMatches = function () {
2130 return this._matches.length > 0;
2131 };
2132 TypeaheadDirective.prototype.checkDelimitersConflict = function () {
2133 if (this.typeaheadMultipleSearch && this.typeaheadSingleWords
2134 && (this.haveCommonCharacters("" + this.typeaheadPhraseDelimiters + this.typeaheadWordDelimiters, this.typeaheadMultipleSearchDelimiters))) {
2135 throw new Error("Delimiters used in typeaheadMultipleSearchDelimiters must be different\n from delimiters used in typeaheadWordDelimiters (current value: " + this.typeaheadWordDelimiters + ") and\n typeaheadPhraseDelimiters (current value: " + this.typeaheadPhraseDelimiters + ").\n Please refer to the documentation");
2136 }
2137 };
2138 TypeaheadDirective.prototype.haveCommonCharacters = function (str1, str2) {
2139 for (var i = 0; i < str1.length; i++) {
2140 if (str1.charAt(i).indexOf(str2) > -1) {
2141 return true;
2142 }
2143 }
2144 return false;
2145 };
2146 return TypeaheadDirective;
2147 }());
2148 TypeaheadDirective.decorators = [
2149 { type: i0.Directive, args: [{
2150 selector: '[typeahead]',
2151 exportAs: 'bs-typeahead',
2152 // eslint-disable-next-line @angular-eslint/no-host-metadata-property
2153 host: {
2154 '[attr.aria-activedescendant]': 'activeDescendant',
2155 '[attr.aria-owns]': 'isOpen ? this._container.popupId : null',
2156 '[attr.aria-expanded]': 'isOpen',
2157 '[attr.aria-autocomplete]': 'list'
2158 }
2159 },] }
2160 ];
2161 TypeaheadDirective.ctorParameters = function () { return [
2162 { type: componentLoader.ComponentLoaderFactory },
2163 { type: TypeaheadConfig },
2164 { type: i0.ChangeDetectorRef },
2165 { type: i0.ElementRef },
2166 { type: forms.NgControl },
2167 { type: i0.Renderer2 },
2168 { type: i0.ViewContainerRef }
2169 ]; };
2170 TypeaheadDirective.propDecorators = {
2171 typeahead: [{ type: i0.Input }],
2172 typeaheadMinLength: [{ type: i0.Input }],
2173 adaptivePosition: [{ type: i0.Input }],
2174 isAnimated: [{ type: i0.Input }],
2175 typeaheadWaitMs: [{ type: i0.Input }],
2176 typeaheadOptionsLimit: [{ type: i0.Input }],
2177 typeaheadOptionField: [{ type: i0.Input }],
2178 typeaheadGroupField: [{ type: i0.Input }],
2179 typeaheadOrderBy: [{ type: i0.Input }],
2180 typeaheadAsync: [{ type: i0.Input }],
2181 typeaheadLatinize: [{ type: i0.Input }],
2182 typeaheadSingleWords: [{ type: i0.Input }],
2183 typeaheadWordDelimiters: [{ type: i0.Input }],
2184 typeaheadMultipleSearch: [{ type: i0.Input }],
2185 typeaheadMultipleSearchDelimiters: [{ type: i0.Input }],
2186 typeaheadPhraseDelimiters: [{ type: i0.Input }],
2187 typeaheadItemTemplate: [{ type: i0.Input }],
2188 optionsListTemplate: [{ type: i0.Input }],
2189 typeaheadScrollable: [{ type: i0.Input }],
2190 typeaheadOptionsInScrollableView: [{ type: i0.Input }],
2191 typeaheadHideResultsOnBlur: [{ type: i0.Input }],
2192 typeaheadSelectFirstItem: [{ type: i0.Input }],
2193 typeaheadIsFirstItemActive: [{ type: i0.Input }],
2194 typeaheadLoading: [{ type: i0.Output }],
2195 typeaheadNoResults: [{ type: i0.Output }],
2196 typeaheadOnSelect: [{ type: i0.Output }],
2197 typeaheadOnPreview: [{ type: i0.Output }],
2198 typeaheadOnBlur: [{ type: i0.Output }],
2199 container: [{ type: i0.Input }],
2200 dropup: [{ type: i0.Input }],
2201 onInput: [{ type: i0.HostListener, args: ['input', ['$event'],] }],
2202 onChange: [{ type: i0.HostListener, args: ['keyup', ['$event'],] }],
2203 onFocus: [{ type: i0.HostListener, args: ['click',] }, { type: i0.HostListener, args: ['focus',] }],
2204 onBlur: [{ type: i0.HostListener, args: ['blur',] }],
2205 onKeydown: [{ type: i0.HostListener, args: ['keydown', ['$event'],] }]
2206 };
2207
2208 var TypeaheadModule = /** @class */ (function () {
2209 function TypeaheadModule() {
2210 }
2211 TypeaheadModule.forRoot = function () {
2212 return {
2213 ngModule: TypeaheadModule,
2214 providers: [componentLoader.ComponentLoaderFactory, positioning.PositioningService]
2215 };
2216 };
2217 return TypeaheadModule;
2218 }());
2219 TypeaheadModule.decorators = [
2220 { type: i0.NgModule, args: [{
2221 imports: [common.CommonModule],
2222 declarations: [TypeaheadContainerComponent, TypeaheadDirective],
2223 exports: [TypeaheadContainerComponent, TypeaheadDirective],
2224 entryComponents: [TypeaheadContainerComponent]
2225 },] }
2226 ];
2227
2228 /**
2229 * Generated bundle index. Do not edit.
2230 */
2231
2232 exports.TypeaheadConfig = TypeaheadConfig;
2233 exports.TypeaheadContainerComponent = TypeaheadContainerComponent;
2234 exports.TypeaheadDirective = TypeaheadDirective;
2235 exports.TypeaheadMatch = TypeaheadMatch;
2236 exports.TypeaheadModule = TypeaheadModule;
2237 exports.TypeaheadOptions = TypeaheadOptions;
2238 exports.escapeRegexp = escapeRegexp;
2239 exports.getValueFromObject = getValueFromObject;
2240 exports.latinMap = latinMap;
2241 exports.latinize = latinize;
2242 exports.tokenize = tokenize;
2243 exports.ɵa = typeaheadAnimation;
2244
2245 Object.defineProperty(exports, '__esModule', { value: true });
2246
2247})));
2248//# sourceMappingURL=ngx-bootstrap-typeahead.umd.js.map