PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.6
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.6
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / js / dist / admin / admin-tools.js

admin-tools.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.6, at assets/js/dist/admin/admin-tools.js

7,177 lines 242.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ "use strict";
3 /******/ var __webpack_modules__ = ({
4
5 /***/ "./assets/src/js/admin/tools/assign-user-course.js"
6 /*!*********************************************************!*\
7 !*** ./assets/src/js/admin/tools/assign-user-course.js ***!
8 \*********************************************************/
9 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
10
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ "default": () => (/* binding */ assignUserCourse)
14 /* harmony export */ });
15 /* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
16 /**
17 * Assign user to course
18 *
19 * @since 4.2.5.6
20 * @version 1.0.1
21 */
22
23 function assignUserCourse() {
24 let elFormAssignUserCourse;
25 let elFormUnAssignUserCourse;
26 let elUserUnAssign, elCourseUnAssign, elUserAssign, elCourseAssign;
27 const limitHandle = 5;
28 const getAllElements = () => {
29 elFormAssignUserCourse = document.querySelector('#lp-assign-user-course-form');
30 elFormUnAssignUserCourse = document.querySelector('#lp-unassign-user-course-form');
31 if (elFormAssignUserCourse) {
32 elUserUnAssign = elFormUnAssignUserCourse.querySelector('[name=user_ids]');
33 elCourseUnAssign = elFormUnAssignUserCourse.querySelector('[name=course_ids]');
34 }
35 if (elFormUnAssignUserCourse) {
36 elUserAssign = elFormAssignUserCourse.querySelector('[name=user_ids]');
37 elCourseAssign = elFormAssignUserCourse.querySelector('[name=course_ids]');
38 }
39 };
40 const events = () => {
41 const elForm = document.querySelector('form');
42 if (!elForm) {
43 return;
44 }
45 document.addEventListener('submit', e => {
46 const elForm = e.target;
47 const formData = new FormData(e.target); // Create a FormData object from the form
48
49 // get values of form.
50 const obj = Object.fromEntries(Array.from(formData.keys(), key => {
51 const val = formData.getAll(key);
52 return [key, val.length > 1 ? val : val.pop()];
53 }));
54 if (elForm.id === 'lp-assign-user-course-form') {
55 e.preventDefault();
56 if (!confirm('Are you sure you want to Assign?')) {
57 return;
58 }
59 const {
60 packages,
61 data,
62 totalPage
63 } = handleDataBeforeSend(obj);
64 fetchAPIAssignCourse(packages, data, 1, totalPage);
65 } else if (elForm.id === 'lp-unassign-user-course-form') {
66 e.preventDefault();
67 if (!confirm('Are you sure you want to Unassign?')) {
68 return;
69 }
70 const {
71 packages,
72 data,
73 totalPage
74 } = handleDataBeforeSend(obj);
75 fetchAPIUnAssignCourse(packages, data, 1, totalPage);
76 }
77 });
78 };
79 const handleDataBeforeSend = dataRaw => {
80 // Cut to packages to send, 1 packages has 5 items.
81 let arrCourseIds = [];
82 let arrUserIds = [];
83 if (typeof dataRaw.course_ids === 'string') {
84 arrCourseIds.push(dataRaw.course_ids);
85 } else if (typeof dataRaw.course_ids === 'object') {
86 arrCourseIds = dataRaw.course_ids;
87 }
88 if (typeof dataRaw.user_ids === 'string') {
89 arrUserIds.push(dataRaw.user_ids);
90 } else if (typeof dataRaw.user_ids === 'object') {
91 arrUserIds = dataRaw.user_ids;
92 }
93 const packages = [];
94 arrCourseIds.map((courseId, indexCourse) => {
95 const item = {};
96 item.course_id = courseId;
97 arrUserIds.map((userID, indexUser) => {
98 const newItem = {
99 ...item,
100 user_id: userID
101 };
102 packages.push(newItem);
103 });
104 });
105 const data = packages.slice(0, limitHandle);
106 const totalPage = Math.ceil(packages.length / limitHandle);
107 return {
108 packages,
109 data,
110 totalPage
111 };
112 };
113 const fetchAPIAssignCourse = (packages, data, page, totalPage) => {
114 const url = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiAssignUserCourse;
115 const params = {
116 headers: {
117 'Content-Type': 'application/json',
118 'X-WP-Nonce': lpDataAdmin.nonce
119 },
120 method: 'POST',
121 body: JSON.stringify({
122 data,
123 page,
124 totalPage
125 })
126 };
127 const elProgress = elFormAssignUserCourse.querySelector('.percent');
128 const elButtonAssign = elFormAssignUserCourse.querySelector('.lp-button-assign-course');
129 const elMessage = elFormAssignUserCourse.querySelector('.message');
130 elButtonAssign.disabled = true;
131 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, {
132 success: response => {
133 const {
134 status,
135 message
136 } = response;
137 if (status === 'success') {
138 let page = parseInt(response.data.page);
139 const begin = page * limitHandle;
140 const end = begin + limitHandle;
141 data = packages.slice(begin, end);
142 elProgress.innerHTML = response.data.percent;
143 fetchAPIAssignCourse(packages, data, ++page, totalPage);
144 } else if (status === 'finished') {
145 elProgress.innerHTML = '';
146 elMessage.style.color = 'green';
147 elMessage.innerHTML = message;
148 setTimeout(() => {
149 elMessage.innerHTML = '';
150 }, 2000);
151 elButtonAssign.disabled = false;
152 // Clear data selected on Tom Select.
153 if (!elUserAssign.tomselect || !elCourseAssign.tomselect) {
154 return;
155 }
156 elUserAssign.tomselect.clear();
157 elCourseAssign.tomselect.clear();
158 } else if (status === 'error') {
159 elButtonAssign.disabled = false;
160 elMessage.style.color = 'red';
161 elMessage.innerHTML = message;
162 setTimeout(() => {
163 elMessage.innerHTML = '';
164 }, 2000);
165 }
166 },
167 error: err => {
168 elButtonAssign.disabled = false;
169 elMessage.innerHTML = err.message;
170 },
171 completed: () => {}
172 });
173 };
174 const fetchAPIUnAssignCourse = (packages, data, page, totalPage) => {
175 const url = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiUnAssignUserCourse;
176 const params = {
177 headers: {
178 'Content-Type': 'application/json',
179 'X-WP-Nonce': lpDataAdmin.nonce
180 },
181 method: 'POST',
182 body: JSON.stringify({
183 data,
184 page,
185 totalPage
186 })
187 };
188 const elProgress = elFormUnAssignUserCourse.querySelector('.percent');
189 const elButtonAssign = elFormUnAssignUserCourse.querySelector('.lp-button-unassign-course');
190 const elMessage = elFormUnAssignUserCourse.querySelector('.message');
191 elButtonAssign.disabled = true;
192 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, {
193 success: response => {
194 const {
195 status,
196 message
197 } = response;
198 if (status === 'success') {
199 let page = parseInt(response.data.page);
200 const begin = page * limitHandle;
201 const end = begin + limitHandle;
202 data = packages.slice(begin, end);
203 elProgress.innerHTML = response.data.percent;
204 fetchAPIUnAssignCourse(packages, data, ++page, totalPage);
205 } else if (status === 'finished') {
206 elProgress.innerHTML = '';
207 elMessage.style.color = 'green';
208 elMessage.innerHTML = message;
209 setTimeout(() => {
210 elMessage.innerHTML = '';
211 }, 2000);
212 elButtonAssign.disabled = false;
213 // Clear data selected on Tom Select.
214 if (!elUserUnAssign.tomselect || !elCourseUnAssign.tomselect) {
215 return;
216 }
217 elUserUnAssign.tomselect.clear();
218 elCourseUnAssign.tomselect.clear();
219 } else if (status === 'error') {
220 elButtonAssign.disabled = false;
221 elMessage.style.color = 'red';
222 elMessage.innerHTML = message;
223 setTimeout(() => {
224 elMessage.innerHTML = '';
225 }, 2000);
226 }
227 },
228 error: err => {
229 elButtonAssign.disabled = false;
230 elMessage.innerHTML = err.message;
231 },
232 completed: () => {}
233 });
234 };
235
236 // DOMContentLoaded.
237 document.addEventListener('DOMContentLoaded', () => {
238 getAllElements();
239 if (!elFormAssignUserCourse) {
240 return;
241 }
242 events();
243 });
244 }
245
246 /***/ },
247
248 /***/ "./assets/src/js/admin/utils-admin.js"
249 /*!********************************************!*\
250 !*** ./assets/src/js/admin/utils-admin.js ***!
251 \********************************************/
252 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
253
254 __webpack_require__.r(__webpack_exports__);
255 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
256 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
257 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
258 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
259 /* harmony export */ });
260 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
261 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
262 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
263 /**
264 * Library run on Admin
265 *
266 * @since 4.2.6.9
267 * @version 1.0.1
268 */
269
270
271
272 const AdminUtilsFunctions = {
273 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
274 if (!elTomSelect) {
275 return;
276 }
277 const optionDefault = {
278 plugins: {
279 remove_button: {
280 title: 'Remove this item'
281 },
282 dropdown_input: {}
283 },
284 onInitialize() {},
285 onItemAdd(e) {
286 // Get list without current item.
287 if (fetchAPI) {
288 const selectedOptions = Array.from(elTomSelect.selectedOptions);
289 const selectedValues = selectedOptions.map(option => option.value);
290 selectedValues.push(e);
291 dataSend.id_not_in = selectedValues.join(',');
292 fetchAPI('', dataSend, callBackHandleData);
293 }
294 }
295 };
296 if (fetchAPI) {
297 optionDefault.load = (keySearch, callbackTom) => {
298 const selectedOptions = Array.from(elTomSelect.selectedOptions);
299 const selectedValues = selectedOptions.map(option => option.value);
300 dataSend.id_not_in = selectedValues.join(',');
301 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
302 };
303 }
304 options = {
305 ...optionDefault,
306 ...options
307 };
308 const items_selected = options.options;
309 /*if ( options?.options?.length > 20 ) {
310 const chunkSize = 20;
311 const length = options.options.length;
312 let i = 0;
313 const chunkedOptions = { ...options };
314 chunkedOptions.options = items_selected.slice( i, chunkSize );
315 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
316 i += chunkSize;
317 const interval = setInterval( () => {
318 if ( i > ( length - 1 ) ) {
319 clearInterval( interval );
320 }
321 const optionsSlice = items_selected.slice( i, i + chunkSize );
322 i += chunkSize;
323 tomSelect.addOptions( optionsSlice );
324 tomSelect.setValue( options.items );
325 }, 200 );
326 return tomSelect;
327 }*/
328
329 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
330 },
331 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
332 return {
333 success: response => {
334 const options = callBackHandleData.success(response);
335 callbackTom(options);
336 }
337 };
338 },
339 fetchCourses(keySearch = '', dataSend = {}, callback) {
340 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
341 dataSend.search = keySearch;
342 const params = {
343 headers: {
344 'Content-Type': 'application/json',
345 'X-WP-Nonce': lpDataAdmin.nonce
346 },
347 method: 'POST',
348 body: JSON.stringify(dataSend)
349 };
350 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
351 },
352 fetchUsers(keySearch = '', dataSend = {}, callback) {
353 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
354 dataSend.search = keySearch;
355 const params = {
356 headers: {
357 'Content-Type': 'application/json',
358 'X-WP-Nonce': lpDataAdmin.nonce
359 },
360 method: 'POST',
361 body: JSON.stringify(dataSend)
362 };
363 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
364 }
365 };
366
367
368 /***/ },
369
370 /***/ "./assets/src/js/api.js"
371 /*!******************************!*\
372 !*** ./assets/src/js/api.js ***!
373 \******************************/
374 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
375
376 __webpack_require__.r(__webpack_exports__);
377 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
378 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
379 /* harmony export */ });
380 /**
381 * List API on backend
382 *
383 * @since 4.2.6
384 * @version 1.0.2
385 */
386
387 const lplistAPI = {};
388 let lp_rest_url;
389 if ('undefined' !== typeof lpDataAdmin) {
390 lp_rest_url = lpDataAdmin.lp_rest_url;
391 lplistAPI.admin = {
392 apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
393 apiAddons: lp_rest_url + 'lp/v1/addon/all',
394 apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
395 apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
396 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
397 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
398 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
399 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
400 };
401 }
402 if ('undefined' !== typeof lpData) {
403 lp_rest_url = lpData.lp_rest_url;
404 lplistAPI.frontend = {
405 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
406 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
407 // Deprecated API, don't load from v4.3.7
408 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
409 // Deprecated since 4.3.0
410 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
411 };
412 }
413 if (lp_rest_url) {
414 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
415 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
416 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
417 }
418 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
419
420 /***/ },
421
422 /***/ "./assets/src/js/utils.js"
423 /*!********************************!*\
424 !*** ./assets/src/js/utils.js ***!
425 \********************************/
426 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
427
428 __webpack_require__.r(__webpack_exports__);
429 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
430 /* harmony export */ debounce: () => (/* binding */ debounce),
431 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
432 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
433 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
434 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
435 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
436 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
437 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
438 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
439 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
440 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
441 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
442 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
443 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
444 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
445 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
446 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
447 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
448 /* harmony export */ });
449 /**
450 * Utils functions
451 *
452 * @param url
453 * @param data
454 * @param functions
455 * @since 4.2.5.1
456 * @version 1.0.7
457 */
458 const lpClassName = {
459 hidden: 'lp-hidden',
460 loading: 'loading',
461 elCollapse: 'lp-collapse',
462 elSectionToggle: '.lp-section-toggle',
463 elTriggerToggle: '.lp-trigger-toggle',
464 elBtnFullScreen: '.lp-btn-full-screen-view',
465 elFullScreen: 'lp-full-screen-view',
466 elBtnFullScreenClose: 'lp-full-screen-view__close'
467 };
468 const lpFetchAPI = (url, data = {}, functions = {}) => {
469 if ('function' === typeof functions.before) {
470 functions.before();
471 }
472 fetch(url, {
473 method: 'GET',
474 ...data
475 }).then(response => response.json()).then(response => {
476 if ('function' === typeof functions.success) {
477 functions.success(response);
478 }
479 }).catch(err => {
480 if ('function' === typeof functions.error) {
481 functions.error(err);
482 }
483 }).finally(() => {
484 if ('function' === typeof functions.completed) {
485 functions.completed();
486 }
487 });
488 };
489
490 /**
491 * Get current URL without params.
492 *
493 * @since 4.2.5.1
494 */
495 const lpGetCurrentURLNoParam = () => {
496 let currentUrl = window.location.href;
497 const hasParams = currentUrl.includes('?');
498 if (hasParams) {
499 currentUrl = currentUrl.split('?')[0];
500 }
501 return currentUrl;
502 };
503 const lpAddQueryArgs = (endpoint, args) => {
504 const url = new URL(endpoint);
505 Object.keys(args).forEach(arg => {
506 url.searchParams.set(arg, args[arg]);
507 });
508 return url;
509 };
510
511 /**
512 * Listen element viewed.
513 *
514 * @param el
515 * @param callback
516 * @since 4.2.5.8
517 */
518 const listenElementViewed = (el, callback) => {
519 const observerSeeItem = new IntersectionObserver(function (entries) {
520 for (const entry of entries) {
521 if (entry.isIntersecting) {
522 callback(entry);
523 }
524 }
525 });
526 observerSeeItem.observe(el);
527 };
528
529 /**
530 * Listen element created.
531 *
532 * @param callback
533 * @since 4.2.5.8
534 */
535 const listenElementCreated = callback => {
536 const observerCreateItem = new MutationObserver(function (mutations) {
537 mutations.forEach(function (mutation) {
538 if (mutation.addedNodes) {
539 mutation.addedNodes.forEach(function (node) {
540 if (node.nodeType === 1) {
541 callback(node);
542 }
543 });
544 }
545 });
546 });
547 observerCreateItem.observe(document, {
548 childList: true,
549 subtree: true
550 });
551 // End.
552 };
553
554 /**
555 * Listen element created.
556 *
557 * @param selector
558 * @param callback
559 * @since 4.2.7.1
560 */
561 const lpOnElementReady = (selector, callback) => {
562 const element = document.querySelector(selector);
563 if (element) {
564 callback(element);
565 return;
566 }
567 const observer = new MutationObserver((mutations, obs) => {
568 const element = document.querySelector(selector);
569 if (element) {
570 obs.disconnect();
571 callback(element);
572 }
573 });
574 observer.observe(document.documentElement, {
575 childList: true,
576 subtree: true
577 });
578 };
579
580 // Parse JSON from string with content include LP_AJAX_START.
581 const lpAjaxParseJsonOld = data => {
582 if (typeof data !== 'string') {
583 return data;
584 }
585 const m = String.raw({
586 raw: data
587 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
588 try {
589 if (m) {
590 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
591 } else {
592 data = JSON.parse(data);
593 }
594 } catch (e) {
595 data = {};
596 }
597 return data;
598 };
599
600 // status 0: hide, 1: show
601 const lpShowHideEl = (el, status = 0) => {
602 if (!el) {
603 return;
604 }
605 if (!status) {
606 el.classList.add(lpClassName.hidden);
607 } else {
608 el.classList.remove(lpClassName.hidden);
609 }
610 };
611
612 // status 0: hide, 1: show
613 const lpSetLoadingEl = (el, status) => {
614 if (!el) {
615 return;
616 }
617 if (!status) {
618 el.classList.remove(lpClassName.loading);
619 } else {
620 el.classList.add(lpClassName.loading);
621 }
622 };
623
624 // Toggle collapse section
625 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
626 if (!elTriggerClassName) {
627 elTriggerClassName = lpClassName.elTriggerToggle;
628 }
629
630 // Exclude elements, which should not trigger the collapse toggle
631 if (elsExclude && elsExclude.length > 0) {
632 for (const elExclude of elsExclude) {
633 if (target.closest(elExclude)) {
634 return;
635 }
636 }
637 }
638 const elTrigger = target.closest(elTriggerClassName);
639 if (!elTrigger) {
640 return;
641 }
642
643 //console.log( 'elTrigger', elTrigger );
644
645 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
646 if (!elSectionToggle) {
647 return;
648 }
649 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
650 if ('function' === typeof callback) {
651 callback(elSectionToggle);
652 }
653 };
654
655 // Get data of form
656 const getDataOfForm = form => {
657 const dataSend = {};
658 const formData = new FormData(form);
659 for (const pair of formData.entries()) {
660 const key = pair[0];
661 const value = formData.getAll(key);
662 if (!dataSend.hasOwnProperty(key)) {
663 // Convert value array to string.
664 dataSend[key] = value.join(',');
665 }
666 }
667 return dataSend;
668 };
669
670 // Get field keys of form
671 const getFieldKeysOfForm = form => {
672 const keys = [];
673 const elements = form.elements;
674 for (let i = 0; i < elements.length; i++) {
675 const name = elements[i].name;
676 if (name && !keys.includes(name)) {
677 keys.push(name);
678 }
679 }
680 return keys;
681 };
682
683 // Merge data handle with data form.
684 const mergeDataWithDatForm = (elForm, dataHandle) => {
685 const dataForm = getDataOfForm(elForm);
686 const keys = getFieldKeysOfForm(elForm);
687 keys.forEach(key => {
688 if (!dataForm.hasOwnProperty(key)) {
689 delete dataHandle[key];
690 } else if (dataForm[key][0] === '') {
691 delete dataForm[key];
692 delete dataHandle[key];
693 }
694 });
695 dataHandle = {
696 ...dataHandle,
697 ...dataForm
698 };
699 return dataHandle;
700 };
701
702 /**
703 * Event trigger
704 * For each list of event handlers, listen event on document.
705 *
706 * eventName: 'click', 'change', ...
707 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
708 *
709 * @param eventName
710 * @param eventHandlers
711 */
712 const eventHandlers = (eventName, eventHandlers) => {
713 document.addEventListener(eventName, e => {
714 const target = e.target;
715 let args = {
716 e,
717 target
718 };
719 eventHandlers.forEach(eventHandler => {
720 args = {
721 ...args,
722 ...eventHandler
723 };
724
725 //console.log( args );
726
727 // Check condition before call back
728 if (eventHandler.conditionBeforeCallBack) {
729 if (eventHandler.conditionBeforeCallBack(args) !== true) {
730 return;
731 }
732 }
733
734 // Special check for keydown event with checkIsEventEnter = true
735 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
736 if (e.key !== 'Enter') {
737 return;
738 }
739 }
740 if (target.closest(eventHandler.selector)) {
741 if (eventHandler.class) {
742 // Call method of class, function callBack will understand exactly {this} is class object.
743 eventHandler.class[eventHandler.callBack](args);
744 } else {
745 // For send args is objected, {this} is eventHandler object, not class object.
746 eventHandler.callBack(args);
747 }
748 }
749 });
750 });
751 };
752
753 /**
754 * Debounce - delays function execution until after `wait` ms of inactivity.
755 *
756 * Each call resets the timer. Only the last call in a burst executes.
757 *
758 * USE CASES:
759 * - Search inputs, form validation, window resize
760 * - Multiple elements need independent timers
761 * - When you need to call with different arguments
762 *
763 * EXAMPLES:
764 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
765 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
766 *
767 * const debouncedResize = debounce( recalculateLayout, 250 );
768 * window.addEventListener('resize', debouncedResize);
769 *
770 * ⚠️ Create ONCE outside event handlers, not inside.
771 *
772 * @param {Function} func - Function to debounce (can be anonymous)
773 * @param {number} wait - Milliseconds to wait (default: 500)
774 * @return {Function} Debounced wrapper function
775 * @since 4.3.7
776 * @version 1.0.0
777 */
778 const debounce = (func, wait = 500) => {
779 let timer;
780 return args => {
781 clearTimeout(timer);
782 timer = setTimeout(() => func(args), wait);
783 };
784 };
785
786 /**
787 * Initialize lp-toggle-enable components.
788 *
789 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
790 * Reads initial state from `data-enabled` attribute ("true"/"false").
791 * Calls `data-on-toggle` callback (if provided via options) on state change.
792 *
793 * HTML structure:
794 * <label class="lp-toggle-enable" data-enabled="true">
795 * <input type="checkbox" class="lp-toggle-enable__input" />
796 * <span class="lp-toggle-enable__track"></span>
797 * </label>
798 *
799 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
800 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
801 * @since 4.4.5
802 * @version 1.0.0
803 */
804 window.lpToggleEnableInit = 0;
805 const toggleEnable = (onToggle = null) => {
806 if (window.lpToggleEnableInit) {
807 return;
808 }
809 window.lpToggleEnableInit = 1;
810 const selector = '.lp-toggle-enable';
811 const updateUI = (toggle, isEnabled) => {
812 toggle.classList.toggle('is-enabled', isEnabled);
813 const input = toggle.querySelector('.lp-toggle-enable__input');
814 if (input) {
815 input.checked = isEnabled;
816 input.value = isEnabled ? '1' : '0';
817 }
818 };
819
820 // Delegate click handling via eventHandlers.
821 eventHandlers('click', [{
822 selector,
823 callBack: args => {
824 const {
825 e,
826 target
827 } = args;
828 const toggle = target.closest(selector);
829 if (!toggle || toggle.classList.contains('is-disabled')) {
830 return;
831 }
832 e.preventDefault();
833 const isEnabled = !toggle.classList.contains('is-enabled');
834 updateUI(toggle, isEnabled);
835 if ('function' === typeof onToggle) {
836 onToggle(toggle, isEnabled);
837 }
838 }
839 }]);
840 };
841
842 /**
843 * Initialize custom fullscreen view buttons.
844 *
845 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
846 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
847 * target element. Falls back to the button's parent element when
848 * `data-target` is not provided.
849 *
850 * @since 4.4.5
851 * @version 1.0.0
852 */
853 window.lpFullScreenViewInit = 0;
854 const fullScreenView = () => {
855 if (window.lpFullScreenViewInit) {
856 return;
857 }
858 window.lpFullScreenViewInit = 1;
859 let lastScrollY = 0;
860 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
861 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
862 if (isFullscreen) {
863 elTarget.classList.remove(lpClassName.elFullScreen);
864 document.documentElement.classList.remove('lp-full-screen-active');
865 window.scrollTo(0, lastScrollY);
866 } else {
867 lastScrollY = window.scrollY;
868 elTarget.classList.add(lpClassName.elFullScreen);
869 document.documentElement.classList.add('lp-full-screen-active');
870 }
871 if (!isFullscreen) {
872 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
873 const closeButton = document.createElement('button');
874 closeButton.type = 'button';
875 closeButton.className = lpClassName.elBtnFullScreenClose;
876 closeButton.setAttribute('aria-label', 'Close');
877 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
878 closeButton.addEventListener('click', e => {
879 e.preventDefault();
880 lpToggleFullscreenView(elTarget);
881 });
882 elTarget.appendChild(closeButton);
883 }
884 } else {
885 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
886 if (closeButton) {
887 closeButton.remove();
888 }
889 }
890 };
891 eventHandlers('click', [{
892 selector: lpClassName.elBtnFullScreen,
893 callBack: args => {
894 const {
895 e,
896 target
897 } = args;
898 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
899 if (!elBtnFullScreen) {
900 console.log('No full screen button found');
901 return;
902 }
903 e.preventDefault();
904 let elTarget = null;
905 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
906 console.log(targetSelector);
907 if (targetSelector) {
908 elTarget = document.querySelector(targetSelector);
909 }
910 if (!elTarget) {
911 console.log('No target element found');
912 return;
913 }
914 lpToggleFullscreenView(elTarget, elBtnFullScreen);
915 }
916 }]);
917 };
918
919 /***/ },
920
921 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
922 /*!**********************************************************!*\
923 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
924 \**********************************************************/
925 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
926
927 __webpack_require__.r(__webpack_exports__);
928 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
929 /* harmony export */ Sifter: () => (/* binding */ Sifter),
930 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
931 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
932 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
933 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
934 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
935 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
936 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
937 /* harmony export */ });
938 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
939 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
940 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
941 /**
942 * sifter.js
943 * Copyright (c) 2013–2020 Brian Reavis & contributors
944 *
945 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
946 * file except in compliance with the License. You may obtain a copy of the License at:
947 * http://www.apache.org/licenses/LICENSE-2.0
948 *
949 * Unless required by applicable law or agreed to in writing, software distributed under
950 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
951 * ANY KIND, either express or implied. See the License for the specific language
952 * governing permissions and limitations under the License.
953 *
954 * @author Brian Reavis <brian@thirdroute.com>
955 */
956
957
958 class Sifter {
959 items; // []|{};
960 settings;
961 /**
962 * Textually searches arrays and hashes of objects
963 * by property (or multiple properties). Designed
964 * specifically for autocomplete.
965 *
966 */
967 constructor(items, settings) {
968 this.items = items;
969 this.settings = settings || { diacritics: true };
970 }
971 ;
972 /**
973 * Splits a search string into an array of individual
974 * regexps to be used to match results.
975 *
976 */
977 tokenize(query, respect_word_boundaries, weights) {
978 if (!query || !query.length)
979 return [];
980 const tokens = [];
981 const words = query.split(/\s+/);
982 var field_regex;
983 if (weights) {
984 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
985 }
986 words.forEach((word) => {
987 let field_match;
988 let field = null;
989 let regex = null;
990 // look for "field:query" tokens
991 if (field_regex && (field_match = word.match(field_regex))) {
992 field = field_match[1];
993 word = field_match[2];
994 }
995 if (word.length > 0) {
996 if (this.settings.diacritics) {
997 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
998 }
999 else {
1000 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
1001 }
1002 if (regex && respect_word_boundaries)
1003 regex = "\\b" + regex;
1004 }
1005 tokens.push({
1006 string: word,
1007 regex: regex ? new RegExp(regex, 'iu') : null,
1008 field: field,
1009 });
1010 });
1011 return tokens;
1012 }
1013 ;
1014 /**
1015 * Returns a function to be used to score individual results.
1016 *
1017 * Good matches will have a higher score than poor matches.
1018 * If an item is not a match, 0 will be returned by the function.
1019 *
1020 * @returns {T.ScoreFn}
1021 */
1022 getScoreFunction(query, options) {
1023 var search = this.prepareSearch(query, options);
1024 return this._getScoreFunction(search);
1025 }
1026 /**
1027 * @returns {T.ScoreFn}
1028 *
1029 */
1030 _getScoreFunction(search) {
1031 const tokens = search.tokens, token_count = tokens.length;
1032 if (!token_count) {
1033 return function () { return 0; };
1034 }
1035 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
1036 if (!field_count) {
1037 return function () { return 1; };
1038 }
1039 /**
1040 * Calculates the score of an object
1041 * against the search query.
1042 *
1043 */
1044 const scoreObject = (function () {
1045 if (field_count === 1) {
1046 return function (token, data) {
1047 const field = fields[0].field;
1048 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
1049 };
1050 }
1051 return function (token, data) {
1052 var sum = 0;
1053 // is the token specific to a field?
1054 if (token.field) {
1055 const value = getAttrFn(data, token.field);
1056 if (!token.regex && value) {
1057 sum += (1 / field_count);
1058 }
1059 else {
1060 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
1061 }
1062 }
1063 else {
1064 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
1065 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
1066 });
1067 }
1068 return sum / field_count;
1069 };
1070 })();
1071 if (token_count === 1) {
1072 return function (data) {
1073 return scoreObject(tokens[0], data);
1074 };
1075 }
1076 if (search.options.conjunction === 'and') {
1077 return function (data) {
1078 var score, sum = 0;
1079 for (let token of tokens) {
1080 score = scoreObject(token, data);
1081 if (score <= 0)
1082 return 0;
1083 sum += score;
1084 }
1085 return sum / token_count;
1086 };
1087 }
1088 else {
1089 return function (data) {
1090 var sum = 0;
1091 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
1092 sum += scoreObject(token, data);
1093 });
1094 return sum / token_count;
1095 };
1096 }
1097 }
1098 ;
1099 /**
1100 * Returns a function that can be used to compare two
1101 * results, for sorting purposes. If no sorting should
1102 * be performed, `null` will be returned.
1103 *
1104 * @return function(a,b)
1105 */
1106 getSortFunction(query, options) {
1107 var search = this.prepareSearch(query, options);
1108 return this._getSortFunction(search);
1109 }
1110 _getSortFunction(search) {
1111 var implicit_score, sort_flds = [];
1112 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
1113 if (typeof sort == 'function') {
1114 return sort.bind(this);
1115 }
1116 /**
1117 * Fetches the specified sort field value
1118 * from a search result item.
1119 *
1120 */
1121 const get_field = function (name, result) {
1122 if (name === '$score')
1123 return result.score;
1124 return search.getAttrFn(self.items[result.id], name);
1125 };
1126 // parse options
1127 if (sort) {
1128 for (let s of sort) {
1129 if (search.query || s.field !== '$score') {
1130 sort_flds.push(s);
1131 }
1132 }
1133 }
1134 // the "$score" field is implied to be the primary
1135 // sort field, unless it's manually specified
1136 if (search.query) {
1137 implicit_score = true;
1138 for (let fld of sort_flds) {
1139 if (fld.field === '$score') {
1140 implicit_score = false;
1141 break;
1142 }
1143 }
1144 if (implicit_score) {
1145 sort_flds.unshift({ field: '$score', direction: 'desc' });
1146 }
1147 // without a search.query, all items will have the same score
1148 }
1149 else {
1150 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
1151 }
1152 // build function
1153 const sort_flds_count = sort_flds.length;
1154 if (!sort_flds_count) {
1155 return null;
1156 }
1157 return function (a, b) {
1158 var result, field;
1159 for (let sort_fld of sort_flds) {
1160 field = sort_fld.field;
1161 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
1162 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
1163 if (result)
1164 return result;
1165 }
1166 return 0;
1167 };
1168 }
1169 ;
1170 /**
1171 * Parses a search query and returns an object
1172 * with tokens and fields ready to be populated
1173 * with results.
1174 *
1175 */
1176 prepareSearch(query, optsUser) {
1177 const weights = {};
1178 var options = Object.assign({}, optsUser);
1179 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
1180 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
1181 // convert fields to new format
1182 if (options.fields) {
1183 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
1184 const fields = [];
1185 options.fields.forEach((field) => {
1186 if (typeof field == 'string') {
1187 field = { field: field, weight: 1 };
1188 }
1189 fields.push(field);
1190 weights[field.field] = ('weight' in field) ? field.weight : 1;
1191 });
1192 options.fields = fields;
1193 }
1194 return {
1195 options: options,
1196 query: query.toLowerCase().trim(),
1197 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
1198 total: 0,
1199 items: [],
1200 weights: weights,
1201 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
1202 };
1203 }
1204 ;
1205 /**
1206 * Searches through all items and returns a sorted array of matches.
1207 *
1208 */
1209 search(query, options) {
1210 var self = this, score, search;
1211 search = this.prepareSearch(query, options);
1212 options = search.options;
1213 query = search.query;
1214 // generate result scoring function
1215 const fn_score = options.score || self._getScoreFunction(search);
1216 // perform search and sort
1217 if (query.length) {
1218 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
1219 score = fn_score(item);
1220 if (options.filter === false || score > 0) {
1221 search.items.push({ 'score': score, 'id': id });
1222 }
1223 });
1224 }
1225 else {
1226 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
1227 search.items.push({ 'score': 1, 'id': id });
1228 });
1229 }
1230 const fn_sort = self._getSortFunction(search);
1231 if (fn_sort)
1232 search.items.sort(fn_sort);
1233 // apply limits
1234 search.total = search.items.length;
1235 if (typeof options.limit === 'number') {
1236 search.items = search.items.slice(0, options.limit);
1237 }
1238 return search;
1239 }
1240 ;
1241 }
1242
1243
1244 //# sourceMappingURL=sifter.js.map
1245
1246 /***/ },
1247
1248 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
1249 /*!*********************************************************!*\
1250 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
1251 \*********************************************************/
1252 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1253
1254 __webpack_require__.r(__webpack_exports__);
1255
1256 //# sourceMappingURL=types.js.map
1257
1258 /***/ },
1259
1260 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
1261 /*!*********************************************************!*\
1262 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
1263 \*********************************************************/
1264 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1265
1266 __webpack_require__.r(__webpack_exports__);
1267 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1268 /* harmony export */ cmp: () => (/* binding */ cmp),
1269 /* harmony export */ getAttr: () => (/* binding */ getAttr),
1270 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
1271 /* harmony export */ iterate: () => (/* binding */ iterate),
1272 /* harmony export */ propToArray: () => (/* binding */ propToArray),
1273 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
1274 /* harmony export */ });
1275 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
1276
1277 /**
1278 * A property getter resolving dot-notation
1279 * @param {Object} obj The root object to fetch property on
1280 * @param {String} name The optionally dotted property name to fetch
1281 * @return {Object} The resolved property value
1282 */
1283 const getAttr = (obj, name) => {
1284 if (!obj)
1285 return;
1286 return obj[name];
1287 };
1288 /**
1289 * A property getter resolving dot-notation
1290 * @param {Object} obj The root object to fetch property on
1291 * @param {String} name The optionally dotted property name to fetch
1292 * @return {Object} The resolved property value
1293 */
1294 const getAttrNesting = (obj, name) => {
1295 if (!obj)
1296 return;
1297 var part, names = name.split(".");
1298 while ((part = names.shift()) && (obj = obj[part]))
1299 ;
1300 return obj;
1301 };
1302 /**
1303 * Calculates how close of a match the
1304 * given value is against a search token.
1305 *
1306 */
1307 const scoreValue = (value, token, weight) => {
1308 var score, pos;
1309 if (!value)
1310 return 0;
1311 value = value + '';
1312 if (token.regex == null)
1313 return 0;
1314 pos = value.search(token.regex);
1315 if (pos === -1)
1316 return 0;
1317 score = token.string.length / value.length;
1318 if (pos === 0)
1319 score += 0.5;
1320 return score * weight;
1321 };
1322 /**
1323 * Cast object property to an array if it exists and has a value
1324 *
1325 */
1326 const propToArray = (obj, key) => {
1327 var value = obj[key];
1328 if (typeof value == 'function')
1329 return value;
1330 if (value && !Array.isArray(value)) {
1331 obj[key] = [value];
1332 }
1333 };
1334 /**
1335 * Iterates over arrays and hashes.
1336 *
1337 * ```
1338 * iterate(this.items, function(item, id) {
1339 * // invoked for each item
1340 * });
1341 * ```
1342 *
1343 */
1344 const iterate = (object, callback) => {
1345 if (Array.isArray(object)) {
1346 object.forEach(callback);
1347 }
1348 else {
1349 for (var key in object) {
1350 if (object.hasOwnProperty(key)) {
1351 callback(object[key], key);
1352 }
1353 }
1354 }
1355 };
1356 const cmp = (a, b) => {
1357 if (typeof a === 'number' && typeof b === 'number') {
1358 return a > b ? 1 : (a < b ? -1 : 0);
1359 }
1360 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
1361 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
1362 if (a > b)
1363 return 1;
1364 if (b > a)
1365 return -1;
1366 return 0;
1367 };
1368 //# sourceMappingURL=utils.js.map
1369
1370 /***/ },
1371
1372 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
1373 /*!*******************************************************************!*\
1374 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
1375 \*******************************************************************/
1376 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1377
1378 __webpack_require__.r(__webpack_exports__);
1379 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1380 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
1381 /* harmony export */ asciifold: () => (/* binding */ asciifold),
1382 /* harmony export */ code_points: () => (/* binding */ code_points),
1383 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
1384 /* harmony export */ generateMap: () => (/* binding */ generateMap),
1385 /* harmony export */ generateSets: () => (/* binding */ generateSets),
1386 /* harmony export */ generator: () => (/* binding */ generator),
1387 /* harmony export */ getPattern: () => (/* binding */ getPattern),
1388 /* harmony export */ initialize: () => (/* binding */ initialize),
1389 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
1390 /* harmony export */ normalize: () => (/* binding */ normalize),
1391 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
1392 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
1393 /* harmony export */ });
1394 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
1395 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
1396
1397
1398 const code_points = [[0, 65535]];
1399 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
1400 let unicode_map;
1401 let multi_char_reg;
1402 const max_char_length = 3;
1403 const latin_convert = {};
1404 const latin_condensed = {
1405 '/': '⁄∕',
1406 '0': '߀',
1407 "a": "ⱥɐɑ",
1408 "aa": "",
1409 "ae": "æǽǣ",
1410 "ao": "",
1411 "au": "",
1412 "av": "ꜹꜻ",
1413 "ay": "",
1414 "b": "ƀɓƃ",
1415 "c": "ꜿƈȼↄ",
1416 "d": "đɗɖ�
1417 ƌꮷԁɦ",
1418 "e": "ɛǝᴇɇ",
1419 "f": "ꝼƒ",
1420 "g": "ǥɠꞡᵹꝿɢ",
1421 "h": "ħⱨⱶɥ",
1422 "i": "ɨı",
1423 "j": "ɉȷ",
1424 "k": "ƙⱪꝁꝃ�
1425 ",
1426 "l": "łƚɫⱡꝉꝇꞁɭ",
1427 "m": "ɱɯϻ",
1428 "n": "ꞥƞɲꞑᴎлԉ",
1429 "o": "øǿɔɵꝋꝍᴑ",
1430 "oe": "œ",
1431 "oi": "ƣ",
1432 "oo": "",
1433 "ou": "ȣ",
1434 "p": "ƥᵽꝑꝓꝕρ",
1435 "q": "ꝗꝙɋ",
1436 "r": "ɍɽꝛꞧꞃ",
1437 "s": "ßȿꞩ�
1438 ʂ",
1439 "t": "ŧƭʈⱦꞇ",
1440 "th": "þ",
1441 "tz": "",
1442 "u": "ʉ",
1443 "v": "ʋꝟʌ",
1444 "vy": "",
1445 "w": "",
1446 "y": "ƴɏỿ",
1447 "z": "ƶȥɀⱬꝣ",
1448 "hv": "ƕ"
1449 };
1450 for (let latin in latin_condensed) {
1451 let unicode = latin_condensed[latin] || '';
1452 for (let i = 0; i < unicode.length; i++) {
1453 let char = unicode.substring(i, i + 1);
1454 latin_convert[char] = latin;
1455 }
1456 }
1457 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
1458 /**
1459 * Initialize the unicode_map from the give code point ranges
1460 */
1461 const initialize = (_code_points) => {
1462 if (unicode_map !== undefined)
1463 return;
1464 unicode_map = generateMap(_code_points || code_points);
1465 };
1466 /**
1467 * Helper method for normalize a string
1468 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
1469 */
1470 const normalize = (str, form = 'NFKD') => str.normalize(form);
1471 /**
1472 * Remove accents without reordering string
1473 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
1474 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
1475 */
1476 const asciifold = (str) => {
1477 return Array.from(str).reduce(
1478 /**
1479 * @param {string} result
1480 * @param {string} char
1481 */
1482 (result, char) => {
1483 return result + _asciifold(char);
1484 }, '');
1485 };
1486 const _asciifold = (str) => {
1487 str = normalize(str)
1488 .toLowerCase()
1489 .replace(convert_pat, (/** @type {string} */ char) => {
1490 return latin_convert[char] || '';
1491 });
1492 //return str;
1493 return normalize(str, 'NFC');
1494 };
1495 /**
1496 * Generate a list of unicode variants from the list of code points
1497 */
1498 function* generator(code_points) {
1499 for (const [code_point_min, code_point_max] of code_points) {
1500 for (let i = code_point_min; i <= code_point_max; i++) {
1501 let composed = String.fromCharCode(i);
1502 let folded = asciifold(composed);
1503 if (folded == composed.toLowerCase()) {
1504 continue;
1505 }
1506 // skip when folded is a string longer than 3 characters long
1507 // bc the resulting regex patterns will be long
1508 // eg:
1509 // folded صلى الله عليه وسل�
1510 length 18 code point 65018
1511 // folded جل جلاله length 8 code point 65019
1512 if (folded.length > max_char_length) {
1513 continue;
1514 }
1515 if (folded.length == 0) {
1516 continue;
1517 }
1518 yield { folded: folded, composed: composed, code_point: i };
1519 }
1520 }
1521 }
1522 /**
1523 * Generate a unicode map from the list of code points
1524 */
1525 const generateSets = (code_points) => {
1526 const unicode_sets = {};
1527 const addMatching = (folded, to_add) => {
1528 /** @type {Set<string>} */
1529 const folded_set = unicode_sets[folded] || new Set();
1530 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
1531 if (to_add.match(patt)) {
1532 return;
1533 }
1534 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
1535 unicode_sets[folded] = folded_set;
1536 };
1537 for (let value of generator(code_points)) {
1538 addMatching(value.folded, value.folded);
1539 addMatching(value.folded, value.composed);
1540 }
1541 return unicode_sets;
1542 };
1543 /**
1544 * Generate a unicode map from the list of code points
1545 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
1546 */
1547 const generateMap = (code_points) => {
1548 const unicode_sets = generateSets(code_points);
1549 const unicode_map = {};
1550 let multi_char = [];
1551 for (let folded in unicode_sets) {
1552 let set = unicode_sets[folded];
1553 if (set) {
1554 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
1555 }
1556 if (folded.length > 1) {
1557 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
1558 }
1559 }
1560 multi_char.sort((a, b) => b.length - a.length);
1561 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
1562 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
1563 return unicode_map;
1564 };
1565 /**
1566 * Map each element of an array from its folded value to all possible unicode matches
1567 */
1568 const mapSequence = (strings, min_replacement = 1) => {
1569 let chars_replaced = 0;
1570 strings = strings.map((str) => {
1571 if (unicode_map[str]) {
1572 chars_replaced += str.length;
1573 }
1574 return unicode_map[str] || str;
1575 });
1576 if (chars_replaced >= min_replacement) {
1577 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
1578 }
1579 return '';
1580 };
1581 /**
1582 * Convert a short string and split it into all possible patterns
1583 * Keep a pattern only if min_replacement is met
1584 *
1585 * 'abc'
1586 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
1587 * => ['abc-pattern','ab-c-pattern'...]
1588 */
1589 const substringsToPattern = (str, min_replacement = 1) => {
1590 min_replacement = Math.max(min_replacement, str.length - 1);
1591 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
1592 return mapSequence(sub_pat, min_replacement);
1593 }));
1594 };
1595 /**
1596 * Convert an array of sequences into a pattern
1597 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
1598 */
1599 const sequencesToPattern = (sequences, all = true) => {
1600 let min_replacement = sequences.length > 1 ? 1 : 0;
1601 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
1602 let seq = [];
1603 const len = all ? sequence.length() : sequence.length() - 1;
1604 for (let j = 0; j < len; j++) {
1605 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
1606 }
1607 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
1608 }));
1609 };
1610 /**
1611 * Return true if the sequence is already in the sequences
1612 */
1613 const inSequences = (needle_seq, sequences) => {
1614 for (const seq of sequences) {
1615 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
1616 continue;
1617 }
1618 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
1619 continue;
1620 }
1621 let needle_parts = needle_seq.parts;
1622 const filter = (part) => {
1623 for (const needle_part of needle_parts) {
1624 if (needle_part.start === part.start && needle_part.substr === part.substr) {
1625 return false;
1626 }
1627 if (part.length == 1 || needle_part.length == 1) {
1628 continue;
1629 }
1630 // check for overlapping parts
1631 // a = ['::=','==']
1632 // b = ['::','===']
1633 // a = ['r','sm']
1634 // b = ['rs','m']
1635 if (part.start < needle_part.start && part.end > needle_part.start) {
1636 return true;
1637 }
1638 if (needle_part.start < part.start && needle_part.end > part.start) {
1639 return true;
1640 }
1641 }
1642 return false;
1643 };
1644 let filtered = seq.parts.filter(filter);
1645 if (filtered.length > 0) {
1646 continue;
1647 }
1648 return true;
1649 }
1650 return false;
1651 };
1652 class Sequence {
1653 parts;
1654 substrs;
1655 start;
1656 end;
1657 constructor() {
1658 this.parts = [];
1659 this.substrs = [];
1660 this.start = 0;
1661 this.end = 0;
1662 }
1663 add(part) {
1664 if (part) {
1665 this.parts.push(part);
1666 this.substrs.push(part.substr);
1667 this.start = Math.min(part.start, this.start);
1668 this.end = Math.max(part.end, this.end);
1669 }
1670 }
1671 last() {
1672 return this.parts[this.parts.length - 1];
1673 }
1674 length() {
1675 return this.parts.length;
1676 }
1677 clone(position, last_piece) {
1678 let clone = new Sequence();
1679 let parts = JSON.parse(JSON.stringify(this.parts));
1680 let last_part = parts.pop();
1681 for (const part of parts) {
1682 clone.add(part);
1683 }
1684 let last_substr = last_piece.substr.substring(0, position - last_part.start);
1685 let clone_last_len = last_substr.length;
1686 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
1687 return clone;
1688 }
1689 }
1690 /**
1691 * Expand a regular expression pattern to include unicode variants
1692 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁ�
1693 ⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢ�
1694 ǺǍȀȂẠẬẶḀĄȺⱯ/
1695 *
1696 * Issue:
1697 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
1698 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
1699 *
1700 * İIJ = IIJ = �
1701 �J
1702 *
1703 * 1/2/4
1704 */
1705 const getPattern = (str) => {
1706 initialize();
1707 str = asciifold(str);
1708 let pattern = '';
1709 let sequences = [new Sequence()];
1710 for (let i = 0; i < str.length; i++) {
1711 let substr = str.substring(i);
1712 let match = substr.match(multi_char_reg);
1713 const char = str.substring(i, i + 1);
1714 const match_str = match ? match[0] : null;
1715 // loop through sequences
1716 // add either the char or multi_match
1717 let overlapping = [];
1718 let added_types = new Set();
1719 for (const sequence of sequences) {
1720 const last_piece = sequence.last();
1721 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
1722 // if we have a multi match
1723 if (match_str) {
1724 const len = match_str.length;
1725 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
1726 added_types.add('1');
1727 }
1728 else {
1729 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
1730 added_types.add('2');
1731 }
1732 }
1733 else if (match_str) {
1734 let clone = sequence.clone(i, last_piece);
1735 const len = match_str.length;
1736 clone.add({ start: i, end: i + len, length: len, substr: match_str });
1737 overlapping.push(clone);
1738 }
1739 else {
1740 // don't add char
1741 // adding would create invalid patterns: 234 => [2,34,4]
1742 added_types.add('3');
1743 }
1744 }
1745 // if we have overlapping
1746 if (overlapping.length > 0) {
1747 // ['ii','iii'] before ['i','i','iii']
1748 overlapping = overlapping.sort((a, b) => {
1749 return a.length() - b.length();
1750 });
1751 for (let clone of overlapping) {
1752 // don't add if we already have an equivalent sequence
1753 if (inSequences(clone, sequences)) {
1754 continue;
1755 }
1756 sequences.push(clone);
1757 }
1758 continue;
1759 }
1760 // if we haven't done anything unique
1761 // clean up the patterns
1762 // helps keep patterns smaller
1763 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
1764 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
1765 pattern += sequencesToPattern(sequences, false);
1766 let new_seq = new Sequence();
1767 const old_seq = sequences[0];
1768 if (old_seq) {
1769 new_seq.add(old_seq.last());
1770 }
1771 sequences = [new_seq];
1772 }
1773 }
1774 pattern += sequencesToPattern(sequences, true);
1775 return pattern;
1776 };
1777
1778 //# sourceMappingURL=index.js.map
1779
1780 /***/ },
1781
1782 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
1783 /*!*******************************************************************!*\
1784 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
1785 \*******************************************************************/
1786 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1787
1788 __webpack_require__.r(__webpack_exports__);
1789 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1790 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
1791 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
1792 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
1793 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
1794 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
1795 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
1796 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
1797 /* harmony export */ });
1798 /**
1799 * Convert array of strings to a regular expression
1800 * ex ['ab','a'] => (?:ab|a)
1801 * ex ['a','b'] => [ab]
1802 */
1803 const arrayToPattern = (chars) => {
1804 chars = chars.filter(Boolean);
1805 if (chars.length < 2) {
1806 return chars[0] || '';
1807 }
1808 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
1809 };
1810 const sequencePattern = (array) => {
1811 if (!hasDuplicates(array)) {
1812 return array.join('');
1813 }
1814 let pattern = '';
1815 let prev_char_count = 0;
1816 const prev_pattern = () => {
1817 if (prev_char_count > 1) {
1818 pattern += '{' + prev_char_count + '}';
1819 }
1820 };
1821 array.forEach((char, i) => {
1822 if (char === array[i - 1]) {
1823 prev_char_count++;
1824 return;
1825 }
1826 prev_pattern();
1827 pattern += char;
1828 prev_char_count = 1;
1829 });
1830 prev_pattern();
1831 return pattern;
1832 };
1833 /**
1834 * Convert array of strings to a regular expression
1835 * ex ['ab','a'] => (?:ab|a)
1836 * ex ['a','b'] => [ab]
1837 */
1838 const setToPattern = (chars) => {
1839 let array = Array.from(chars);
1840 return arrayToPattern(array);
1841 };
1842 /**
1843 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
1844 */
1845 const hasDuplicates = (array) => {
1846 return (new Set(array)).size !== array.length;
1847 };
1848 /**
1849 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
1850 */
1851 const escape_regex = (str) => {
1852 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
1853 };
1854 /**
1855 * Return the max length of array values
1856 */
1857 const maxValueLength = (array) => {
1858 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
1859 };
1860 const unicodeLength = (str) => {
1861 return Array.from(str).length;
1862 };
1863 //# sourceMappingURL=regex.js.map
1864
1865 /***/ },
1866
1867 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
1868 /*!*********************************************************************!*\
1869 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
1870 \*********************************************************************/
1871 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1872
1873 __webpack_require__.r(__webpack_exports__);
1874 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1875 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
1876 /* harmony export */ });
1877 /**
1878 * Get all possible combinations of substrings that add up to the given string
1879 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
1880 */
1881 const allSubstrings = (input) => {
1882 if (input.length === 1)
1883 return [[input]];
1884 let result = [];
1885 const start = input.substring(1);
1886 const suba = allSubstrings(start);
1887 suba.forEach(function (subresult) {
1888 let tmp = subresult.slice(0);
1889 tmp[0] = input.charAt(0) + tmp[0];
1890 result.push(tmp);
1891 tmp = subresult.slice(0);
1892 tmp.unshift(input.charAt(0));
1893 result.push(tmp);
1894 });
1895 return result;
1896 };
1897 //# sourceMappingURL=strings.js.map
1898
1899 /***/ },
1900
1901 /***/ "./node_modules/tom-select/dist/esm/constants.js"
1902 /*!*******************************************************!*\
1903 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
1904 \*******************************************************/
1905 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1906
1907 __webpack_require__.r(__webpack_exports__);
1908 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1909 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
1910 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
1911 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
1912 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
1913 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
1914 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
1915 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
1916 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
1917 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
1918 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
1919 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
1920 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
1921 /* harmony export */ });
1922 const KEY_A = 65;
1923 const KEY_RETURN = 13;
1924 const KEY_ESC = 27;
1925 const KEY_LEFT = 37;
1926 const KEY_UP = 38;
1927 const KEY_RIGHT = 39;
1928 const KEY_DOWN = 40;
1929 const KEY_BACKSPACE = 8;
1930 const KEY_DELETE = 46;
1931 const KEY_TAB = 9;
1932 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
1933 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
1934 //# sourceMappingURL=constants.js.map
1935
1936 /***/ },
1937
1938 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
1939 /*!***************************************************************!*\
1940 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
1941 \***************************************************************/
1942 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
1943
1944 __webpack_require__.r(__webpack_exports__);
1945 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1946 /* harmony export */ highlight: () => (/* binding */ highlight),
1947 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
1948 /* harmony export */ });
1949 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
1950 /**
1951 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
1952 * Highlights arbitrary terms in a node.
1953 *
1954 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
1955 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
1956 */
1957
1958 const highlight = (element, regex) => {
1959 if (regex === null)
1960 return;
1961 // convet string to regex
1962 if (typeof regex === 'string') {
1963 if (!regex.length)
1964 return;
1965 regex = new RegExp(regex, 'i');
1966 }
1967 // Wrap matching part of text node with highlighting <span>, e.g.
1968 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
1969 const highlightText = (node) => {
1970 var match = node.data.match(regex);
1971 if (match && node.data.length > 0) {
1972 var spannode = document.createElement('span');
1973 spannode.className = 'highlight';
1974 var middlebit = node.splitText(match.index);
1975 middlebit.splitText(match[0].length);
1976 var middleclone = middlebit.cloneNode(true);
1977 spannode.appendChild(middleclone);
1978 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
1979 return 1;
1980 }
1981 return 0;
1982 };
1983 // Recurse element node, looking for child text nodes to highlight, unless element
1984 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
1985 const highlightChildren = (node) => {
1986 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
1987 Array.from(node.childNodes).forEach(element => {
1988 highlightRecursive(element);
1989 });
1990 }
1991 };
1992 const highlightRecursive = (node) => {
1993 if (node.nodeType === 3) {
1994 return highlightText(node);
1995 }
1996 highlightChildren(node);
1997 return 0;
1998 };
1999 highlightRecursive(element);
2000 };
2001 /**
2002 * removeHighlight fn copied from highlight v5 and
2003 * edited to remove with(), pass js strict mode, and use without jquery
2004 */
2005 const removeHighlight = (el) => {
2006 var elements = el.querySelectorAll("span.highlight");
2007 Array.prototype.forEach.call(elements, function (el) {
2008 var parent = el.parentNode;
2009 parent.replaceChild(el.firstChild, el);
2010 parent.normalize();
2011 });
2012 };
2013 //# sourceMappingURL=highlight.js.map
2014
2015 /***/ },
2016
2017 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
2018 /*!****************************************************************!*\
2019 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
2020 \****************************************************************/
2021 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2022
2023 __webpack_require__.r(__webpack_exports__);
2024 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2025 /* harmony export */ "default": () => (/* binding */ MicroEvent)
2026 /* harmony export */ });
2027 /**
2028 * MicroEvent - to make any js object an event emitter
2029 *
2030 * - pure javascript - server compatible, browser compatible
2031 * - dont rely on the browser doms
2032 * - super simple - you get it immediatly, no mistery, no magic involved
2033 *
2034 * @author Jerome Etienne (https://github.com/jeromeetienne)
2035 */
2036 /**
2037 * Execute callback for each event in space separated list of event names
2038 *
2039 */
2040 function forEvents(events, callback) {
2041 events.split(/\s+/).forEach((event) => {
2042 callback(event);
2043 });
2044 }
2045 class MicroEvent {
2046 constructor() {
2047 this._events = {};
2048 }
2049 on(events, fct) {
2050 forEvents(events, (event) => {
2051 const event_array = this._events[event] || [];
2052 event_array.push(fct);
2053 this._events[event] = event_array;
2054 });
2055 }
2056 off(events, fct) {
2057 var n = arguments.length;
2058 if (n === 0) {
2059 this._events = {};
2060 return;
2061 }
2062 forEvents(events, (event) => {
2063 if (n === 1) {
2064 delete this._events[event];
2065 return;
2066 }
2067 const event_array = this._events[event];
2068 if (event_array === undefined)
2069 return;
2070 event_array.splice(event_array.indexOf(fct), 1);
2071 this._events[event] = event_array;
2072 });
2073 }
2074 trigger(events, ...args) {
2075 var self = this;
2076 forEvents(events, (event) => {
2077 const event_array = self._events[event];
2078 if (event_array === undefined)
2079 return;
2080 event_array.forEach(fct => {
2081 fct.apply(self, args);
2082 });
2083 });
2084 }
2085 }
2086 ;
2087 //# sourceMappingURL=microevent.js.map
2088
2089 /***/ },
2090
2091 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
2092 /*!*****************************************************************!*\
2093 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
2094 \*****************************************************************/
2095 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2096
2097 __webpack_require__.r(__webpack_exports__);
2098 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2099 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
2100 /* harmony export */ });
2101 /**
2102 * microplugin.js
2103 * Copyright (c) 2013 Brian Reavis & contributors
2104 *
2105 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2106 * file except in compliance with the License. You may obtain a copy of the License at:
2107 * http://www.apache.org/licenses/LICENSE-2.0
2108 *
2109 * Unless required by applicable law or agreed to in writing, software distributed under
2110 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2111 * ANY KIND, either express or implied. See the License for the specific language
2112 * governing permissions and limitations under the License.
2113 *
2114 * @author Brian Reavis <brian@thirdroute.com>
2115 */
2116 function MicroPlugin(Interface) {
2117 Interface.plugins = {};
2118 return class extends Interface {
2119 constructor() {
2120 super(...arguments);
2121 this.plugins = {
2122 names: [],
2123 settings: {},
2124 requested: {},
2125 loaded: {}
2126 };
2127 }
2128 /**
2129 * Registers a plugin.
2130 *
2131 * @param {function} fn
2132 */
2133 static define(name, fn) {
2134 Interface.plugins[name] = {
2135 'name': name,
2136 'fn': fn
2137 };
2138 }
2139 /**
2140 * Initializes the listed plugins (with options).
2141 * Acceptable formats:
2142 *
2143 * List (without options):
2144 * ['a', 'b', 'c']
2145 *
2146 * List (with options):
2147 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
2148 *
2149 * Hash (with options):
2150 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
2151 *
2152 * @param {array|object} plugins
2153 */
2154 initializePlugins(plugins) {
2155 var key, name;
2156 const self = this;
2157 const queue = [];
2158 if (Array.isArray(plugins)) {
2159 plugins.forEach((plugin) => {
2160 if (typeof plugin === 'string') {
2161 queue.push(plugin);
2162 }
2163 else {
2164 self.plugins.settings[plugin.name] = plugin.options;
2165 queue.push(plugin.name);
2166 }
2167 });
2168 }
2169 else if (plugins) {
2170 for (key in plugins) {
2171 if (plugins.hasOwnProperty(key)) {
2172 self.plugins.settings[key] = plugins[key];
2173 queue.push(key);
2174 }
2175 }
2176 }
2177 while (name = queue.shift()) {
2178 self.require(name);
2179 }
2180 }
2181 loadPlugin(name) {
2182 var self = this;
2183 var plugins = self.plugins;
2184 var plugin = Interface.plugins[name];
2185 if (!Interface.plugins.hasOwnProperty(name)) {
2186 throw new Error('Unable to find "' + name + '" plugin');
2187 }
2188 plugins.requested[name] = true;
2189 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
2190 plugins.names.push(name);
2191 }
2192 /**
2193 * Initializes a plugin.
2194 *
2195 */
2196 require(name) {
2197 var self = this;
2198 var plugins = self.plugins;
2199 if (!self.plugins.loaded.hasOwnProperty(name)) {
2200 if (plugins.requested[name]) {
2201 throw new Error('Plugin has circular dependency ("' + name + '")');
2202 }
2203 self.loadPlugin(name);
2204 }
2205 return plugins.loaded[name];
2206 }
2207 };
2208 }
2209 //# sourceMappingURL=microplugin.js.map
2210
2211 /***/ },
2212
2213 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
2214 /*!******************************************************!*\
2215 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
2216 \******************************************************/
2217 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2218
2219 __webpack_require__.r(__webpack_exports__);
2220 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2221 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2222 /* harmony export */ });
2223 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
2224 options: [],
2225 optgroups: [],
2226 plugins: [],
2227 delimiter: ',',
2228 splitOn: null, // regexp or string for splitting up values from a paste command
2229 persist: true,
2230 diacritics: true,
2231 create: null,
2232 createOnBlur: false,
2233 createFilter: null,
2234 highlight: true,
2235 openOnFocus: true,
2236 shouldOpen: null,
2237 maxOptions: 50,
2238 maxItems: null,
2239 hideSelected: null,
2240 duplicates: false,
2241 addPrecedence: false,
2242 selectOnTab: false,
2243 preload: null,
2244 allowEmptyOption: false,
2245 //closeAfterSelect: false,
2246 refreshThrottle: 300,
2247 loadThrottle: 300,
2248 loadingClass: 'loading',
2249 dataAttr: null, //'data-data',
2250 optgroupField: 'optgroup',
2251 valueField: 'value',
2252 labelField: 'text',
2253 disabledField: 'disabled',
2254 optgroupLabelField: 'label',
2255 optgroupValueField: 'value',
2256 lockOptgroupOrder: false,
2257 sortField: '$order',
2258 searchField: ['text'],
2259 searchConjunction: 'and',
2260 mode: null,
2261 wrapperClass: 'ts-wrapper',
2262 controlClass: 'ts-control',
2263 dropdownClass: 'ts-dropdown',
2264 dropdownContentClass: 'ts-dropdown-content',
2265 itemClass: 'item',
2266 optionClass: 'option',
2267 dropdownParent: null,
2268 controlInput: '<input type="text" autocomplete="off" size="1" />',
2269 copyClassesToDropdown: false,
2270 placeholder: null,
2271 hidePlaceholder: null,
2272 shouldLoad: function (query) {
2273 return query.length > 0;
2274 },
2275 /*
2276 load : null, // function(query, callback) { ... }
2277 score : null, // function(search) { ... }
2278 onInitialize : null, // function() { ... }
2279 onChange : null, // function(value) { ... }
2280 onItemAdd : null, // function(value, $item) { ... }
2281 onItemRemove : null, // function(value) { ... }
2282 onClear : null, // function() { ... }
2283 onOptionAdd : null, // function(value, data) { ... }
2284 onOptionRemove : null, // function(value) { ... }
2285 onOptionClear : null, // function() { ... }
2286 onOptionGroupAdd : null, // function(id, data) { ... }
2287 onOptionGroupRemove : null, // function(id) { ... }
2288 onOptionGroupClear : null, // function() { ... }
2289 onDropdownOpen : null, // function(dropdown) { ... }
2290 onDropdownClose : null, // function(dropdown) { ... }
2291 onType : null, // function(str) { ... }
2292 onDelete : null, // function(values) { ... }
2293 */
2294 render: {
2295 /*
2296 item: null,
2297 optgroup: null,
2298 optgroup_header: null,
2299 option: null,
2300 option_create: null
2301 */
2302 }
2303 });
2304 //# sourceMappingURL=defaults.js.map
2305
2306 /***/ },
2307
2308 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
2309 /*!*********************************************************!*\
2310 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
2311 \*********************************************************/
2312 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2313
2314 __webpack_require__.r(__webpack_exports__);
2315 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2316 /* harmony export */ "default": () => (/* binding */ getSettings)
2317 /* harmony export */ });
2318 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
2319 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
2320
2321
2322 function getSettings(input, settings_user) {
2323 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
2324 var attr_data = settings.dataAttr;
2325 var field_label = settings.labelField;
2326 var field_value = settings.valueField;
2327 var field_disabled = settings.disabledField;
2328 var field_optgroup = settings.optgroupField;
2329 var field_optgroup_label = settings.optgroupLabelField;
2330 var field_optgroup_value = settings.optgroupValueField;
2331 var tag_name = input.tagName.toLowerCase();
2332 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
2333 if (!placeholder && !settings.allowEmptyOption) {
2334 let option = input.querySelector('option[value=""]');
2335 if (option) {
2336 placeholder = option.textContent;
2337 }
2338 }
2339 var settings_element = {
2340 placeholder: placeholder,
2341 options: [],
2342 optgroups: [],
2343 items: [],
2344 maxItems: null,
2345 };
2346 /**
2347 * Initialize from a <select> element.
2348 *
2349 */
2350 var init_select = () => {
2351 var tagName;
2352 var options = settings_element.options;
2353 var optionsMap = {};
2354 var group_count = 1;
2355 let $order = 0;
2356 var readData = (el) => {
2357 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
2358 var json = attr_data && data[attr_data];
2359 if (typeof json === 'string' && json.length) {
2360 data = Object.assign(data, JSON.parse(json));
2361 }
2362 return data;
2363 };
2364 var addOption = (option, group) => {
2365 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
2366 if (value == null)
2367 return;
2368 if (!value && !settings.allowEmptyOption)
2369 return;
2370 // if the option already exists, it's probably been
2371 // duplicated in another optgroup. in this case, push
2372 // the current group to the "optgroup" property on the
2373 // existing option so that it's rendered in both places.
2374 if (optionsMap.hasOwnProperty(value)) {
2375 if (group) {
2376 var arr = optionsMap[value][field_optgroup];
2377 if (!arr) {
2378 optionsMap[value][field_optgroup] = group;
2379 }
2380 else if (!Array.isArray(arr)) {
2381 optionsMap[value][field_optgroup] = [arr, group];
2382 }
2383 else {
2384 arr.push(group);
2385 }
2386 }
2387 }
2388 else {
2389 var option_data = readData(option);
2390 option_data[field_label] = option_data[field_label] || option.textContent;
2391 option_data[field_value] = option_data[field_value] || value;
2392 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
2393 option_data[field_optgroup] = option_data[field_optgroup] || group;
2394 option_data.$option = option;
2395 option_data.$order = option_data.$order || ++$order;
2396 optionsMap[value] = option_data;
2397 options.push(option_data);
2398 }
2399 if (option.selected) {
2400 settings_element.items.push(value);
2401 }
2402 };
2403 var addGroup = (optgroup) => {
2404 var id, optgroup_data;
2405 optgroup_data = readData(optgroup);
2406 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
2407 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
2408 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
2409 optgroup_data.$order = optgroup_data.$order || ++$order;
2410 settings_element.optgroups.push(optgroup_data);
2411 id = optgroup_data[field_optgroup_value];
2412 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
2413 addOption(option, id);
2414 });
2415 };
2416 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
2417 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
2418 tagName = child.tagName.toLowerCase();
2419 if (tagName === 'optgroup') {
2420 addGroup(child);
2421 }
2422 else if (tagName === 'option') {
2423 addOption(child);
2424 }
2425 });
2426 };
2427 /**
2428 * Initialize from a <input type="text"> element.
2429 *
2430 */
2431 var init_textbox = () => {
2432 const data_raw = input.getAttribute(attr_data);
2433 if (!data_raw) {
2434 var value = input.value.trim() || '';
2435 if (!settings.allowEmptyOption && !value.length)
2436 return;
2437 const values = value.split(settings.delimiter);
2438 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
2439 const option = {};
2440 option[field_label] = value;
2441 option[field_value] = value;
2442 settings_element.options.push(option);
2443 });
2444 settings_element.items = values;
2445 }
2446 else {
2447 settings_element.options = JSON.parse(data_raw);
2448 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
2449 settings_element.items.push(opt[field_value]);
2450 });
2451 }
2452 };
2453 if (tag_name === 'select') {
2454 init_select();
2455 }
2456 else {
2457 init_textbox();
2458 }
2459 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
2460 }
2461 ;
2462 //# sourceMappingURL=getSettings.js.map
2463
2464 /***/ },
2465
2466 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
2467 /*!***************************************************************************!*\
2468 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
2469 \***************************************************************************/
2470 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2471
2472 __webpack_require__.r(__webpack_exports__);
2473 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2474 /* harmony export */ "default": () => (/* binding */ plugin)
2475 /* harmony export */ });
2476 /**
2477 * Tom Select v2.4.3
2478 * Licensed under the Apache License, Version 2.0 (the "License");
2479 */
2480
2481 /**
2482 * Converts a scalar to its best string representation
2483 * for hash keys and HTML attribute values.
2484 *
2485 * Transformations:
2486 * 'str' -> 'str'
2487 * null -> ''
2488 * undefined -> ''
2489 * true -> '1'
2490 * false -> '0'
2491 * 0 -> '0'
2492 * 1 -> '1'
2493 *
2494 */
2495
2496 /**
2497 * Iterates over arrays and hashes.
2498 *
2499 * ```
2500 * iterate(this.items, function(item, id) {
2501 * // invoked for each item
2502 * });
2503 * ```
2504 *
2505 */
2506 const iterate = (object, callback) => {
2507 if (Array.isArray(object)) {
2508 object.forEach(callback);
2509 } else {
2510 for (var key in object) {
2511 if (object.hasOwnProperty(key)) {
2512 callback(object[key], key);
2513 }
2514 }
2515 }
2516 };
2517
2518 /**
2519 * Remove css classes
2520 *
2521 */
2522 const removeClasses = (elmts, ...classes) => {
2523 var norm_classes = classesArray(classes);
2524 elmts = castAsArray(elmts);
2525 elmts.map(el => {
2526 norm_classes.map(cls => {
2527 el.classList.remove(cls);
2528 });
2529 });
2530 };
2531
2532 /**
2533 * Return arguments
2534 *
2535 */
2536 const classesArray = args => {
2537 var classes = [];
2538 iterate(args, _classes => {
2539 if (typeof _classes === 'string') {
2540 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
2541 }
2542 if (Array.isArray(_classes)) {
2543 classes = classes.concat(_classes);
2544 }
2545 });
2546 return classes.filter(Boolean);
2547 };
2548
2549 /**
2550 * Create an array from arg if it's not already an array
2551 *
2552 */
2553 const castAsArray = arg => {
2554 if (!Array.isArray(arg)) {
2555 arg = [arg];
2556 }
2557 return arg;
2558 };
2559
2560 /**
2561 * Get the index of an element amongst sibling nodes of the same type
2562 *
2563 */
2564 const nodeIndex = (el, amongst) => {
2565 if (!el) return -1;
2566 amongst = amongst || el.nodeName;
2567 var i = 0;
2568 while (el = el.previousElementSibling) {
2569 if (el.matches(amongst)) {
2570 i++;
2571 }
2572 }
2573 return i;
2574 };
2575
2576 /**
2577 * Plugin: "dropdown_input" (Tom Select)
2578 * Copyright (c) contributors
2579 *
2580 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2581 * file except in compliance with the License. You may obtain a copy of the License at:
2582 * http://www.apache.org/licenses/LICENSE-2.0
2583 *
2584 * Unless required by applicable law or agreed to in writing, software distributed under
2585 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2586 * ANY KIND, either express or implied. See the License for the specific language
2587 * governing permissions and limitations under the License.
2588 *
2589 */
2590
2591 function plugin () {
2592 var self = this;
2593
2594 /**
2595 * Moves the caret to the specified index.
2596 *
2597 * The input must be moved by leaving it in place and moving the
2598 * siblings, due to the fact that focus cannot be restored once lost
2599 * on mobile webkit devices
2600 *
2601 */
2602 self.hook('instead', 'setCaret', new_pos => {
2603 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
2604 new_pos = self.items.length;
2605 } else {
2606 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
2607 if (new_pos != self.caretPos && !self.isPending) {
2608 self.controlChildren().forEach((child, j) => {
2609 if (j < new_pos) {
2610 self.control_input.insertAdjacentElement('beforebegin', child);
2611 } else {
2612 self.control.appendChild(child);
2613 }
2614 });
2615 }
2616 }
2617 self.caretPos = new_pos;
2618 });
2619 self.hook('instead', 'moveCaret', direction => {
2620 if (!self.isFocused) return;
2621
2622 // move caret before or after selected items
2623 const last_active = self.getLastActive(direction);
2624 if (last_active) {
2625 const idx = nodeIndex(last_active);
2626 self.setCaret(direction > 0 ? idx + 1 : idx);
2627 self.setActiveItem();
2628 removeClasses(last_active, 'last-active');
2629
2630 // move caret left or right of current position
2631 } else {
2632 self.setCaret(self.caretPos + direction);
2633 }
2634 });
2635 }
2636
2637
2638 //# sourceMappingURL=plugin.js.map
2639
2640
2641 /***/ },
2642
2643 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
2644 /*!****************************************************************************!*\
2645 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
2646 \****************************************************************************/
2647 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2648
2649 __webpack_require__.r(__webpack_exports__);
2650 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2651 /* harmony export */ "default": () => (/* binding */ plugin)
2652 /* harmony export */ });
2653 /**
2654 * Tom Select v2.4.3
2655 * Licensed under the Apache License, Version 2.0 (the "License");
2656 */
2657
2658 /**
2659 * Converts a scalar to its best string representation
2660 * for hash keys and HTML attribute values.
2661 *
2662 * Transformations:
2663 * 'str' -> 'str'
2664 * null -> ''
2665 * undefined -> ''
2666 * true -> '1'
2667 * false -> '0'
2668 * 0 -> '0'
2669 * 1 -> '1'
2670 *
2671 */
2672
2673 /**
2674 * Add event helper
2675 *
2676 */
2677 const addEvent = (target, type, callback, options) => {
2678 target.addEventListener(type, callback, options);
2679 };
2680
2681 /**
2682 * Plugin: "change_listener" (Tom Select)
2683 * Copyright (c) contributors
2684 *
2685 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2686 * file except in compliance with the License. You may obtain a copy of the License at:
2687 * http://www.apache.org/licenses/LICENSE-2.0
2688 *
2689 * Unless required by applicable law or agreed to in writing, software distributed under
2690 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2691 * ANY KIND, either express or implied. See the License for the specific language
2692 * governing permissions and limitations under the License.
2693 *
2694 */
2695
2696 function plugin () {
2697 addEvent(this.input, 'change', () => {
2698 this.sync();
2699 });
2700 }
2701
2702
2703 //# sourceMappingURL=plugin.js.map
2704
2705
2706 /***/ },
2707
2708 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
2709 /*!*****************************************************************************!*\
2710 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
2711 \*****************************************************************************/
2712 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2713
2714 __webpack_require__.r(__webpack_exports__);
2715 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2716 /* harmony export */ "default": () => (/* binding */ plugin)
2717 /* harmony export */ });
2718 /**
2719 * Tom Select v2.4.3
2720 * Licensed under the Apache License, Version 2.0 (the "License");
2721 */
2722
2723 /**
2724 * Converts a scalar to its best string representation
2725 * for hash keys and HTML attribute values.
2726 *
2727 * Transformations:
2728 * 'str' -> 'str'
2729 * null -> ''
2730 * undefined -> ''
2731 * true -> '1'
2732 * false -> '0'
2733 * 0 -> '0'
2734 * 1 -> '1'
2735 *
2736 */
2737 const hash_key = value => {
2738 if (typeof value === 'undefined' || value === null) return null;
2739 return get_hash(value);
2740 };
2741 const get_hash = value => {
2742 if (typeof value === 'boolean') return value ? '1' : '0';
2743 return value + '';
2744 };
2745
2746 /**
2747 * Prevent default
2748 *
2749 */
2750 const preventDefault = (evt, stop = false) => {
2751 if (evt) {
2752 evt.preventDefault();
2753 if (stop) {
2754 evt.stopPropagation();
2755 }
2756 }
2757 };
2758
2759 /**
2760 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
2761 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
2762 *
2763 * param query should be {}
2764 */
2765 const getDom = query => {
2766 if (query.jquery) {
2767 return query[0];
2768 }
2769 if (query instanceof HTMLElement) {
2770 return query;
2771 }
2772 if (isHtmlString(query)) {
2773 var tpl = document.createElement('template');
2774 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
2775 return tpl.content.firstChild;
2776 }
2777 return document.querySelector(query);
2778 };
2779 const isHtmlString = arg => {
2780 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
2781 return true;
2782 }
2783 return false;
2784 };
2785
2786 /**
2787 * Plugin: "checkbox_options" (Tom Select)
2788 * Copyright (c) contributors
2789 *
2790 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2791 * file except in compliance with the License. You may obtain a copy of the License at:
2792 * http://www.apache.org/licenses/LICENSE-2.0
2793 *
2794 * Unless required by applicable law or agreed to in writing, software distributed under
2795 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2796 * ANY KIND, either express or implied. See the License for the specific language
2797 * governing permissions and limitations under the License.
2798 *
2799 */
2800
2801 function plugin (userOptions) {
2802 var self = this;
2803 var orig_onOptionSelect = self.onOptionSelect;
2804 self.settings.hideSelected = false;
2805 const cbOptions = Object.assign({
2806 // so that the user may add different ones as well
2807 className: "tomselect-checkbox",
2808 // the following default to the historic plugin's values
2809 checkedClassNames: undefined,
2810 uncheckedClassNames: undefined
2811 }, userOptions);
2812 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
2813 if (toCheck) {
2814 checkbox.checked = true;
2815 if (cbOptions.uncheckedClassNames) {
2816 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
2817 }
2818 if (cbOptions.checkedClassNames) {
2819 checkbox.classList.add(...cbOptions.checkedClassNames);
2820 }
2821 } else {
2822 checkbox.checked = false;
2823 if (cbOptions.checkedClassNames) {
2824 checkbox.classList.remove(...cbOptions.checkedClassNames);
2825 }
2826 if (cbOptions.uncheckedClassNames) {
2827 checkbox.classList.add(...cbOptions.uncheckedClassNames);
2828 }
2829 }
2830 };
2831
2832 // update the checkbox for an option
2833 var UpdateCheckbox = function UpdateCheckbox(option) {
2834 setTimeout(() => {
2835 var checkbox = option.querySelector('input.' + cbOptions.className);
2836 if (checkbox instanceof HTMLInputElement) {
2837 UpdateChecked(checkbox, option.classList.contains('selected'));
2838 }
2839 }, 1);
2840 };
2841
2842 // add checkbox to option template
2843 self.hook('after', 'setupTemplates', () => {
2844 var orig_render_option = self.settings.render.option;
2845 self.settings.render.option = (data, escape_html) => {
2846 var rendered = getDom(orig_render_option.call(self, data, escape_html));
2847 var checkbox = document.createElement('input');
2848 if (cbOptions.className) {
2849 checkbox.classList.add(cbOptions.className);
2850 }
2851 checkbox.addEventListener('click', function (evt) {
2852 preventDefault(evt);
2853 });
2854 checkbox.type = 'checkbox';
2855 const hashed = hash_key(data[self.settings.valueField]);
2856 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
2857 rendered.prepend(checkbox);
2858 return rendered;
2859 };
2860 });
2861
2862 // uncheck when item removed
2863 self.on('item_remove', value => {
2864 var option = self.getOption(value);
2865 if (option) {
2866 // if dropdown hasn't been opened yet, the option won't exist
2867 option.classList.remove('selected'); // selected class won't be removed yet
2868 UpdateCheckbox(option);
2869 }
2870 });
2871
2872 // check when item added
2873 self.on('item_add', value => {
2874 var option = self.getOption(value);
2875 if (option) {
2876 // if dropdown hasn't been opened yet, the option won't exist
2877 UpdateCheckbox(option);
2878 }
2879 });
2880
2881 // remove items when selected option is clicked
2882 self.hook('instead', 'onOptionSelect', (evt, option) => {
2883 if (option.classList.contains('selected')) {
2884 option.classList.remove('selected');
2885 self.removeItem(option.dataset.value);
2886 self.refreshOptions();
2887 preventDefault(evt, true);
2888 return;
2889 }
2890 orig_onOptionSelect.call(self, evt, option);
2891 UpdateCheckbox(option);
2892 });
2893 }
2894
2895
2896 //# sourceMappingURL=plugin.js.map
2897
2898
2899 /***/ },
2900
2901 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
2902 /*!*************************************************************************!*\
2903 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
2904 \*************************************************************************/
2905 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2906
2907 __webpack_require__.r(__webpack_exports__);
2908 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2909 /* harmony export */ "default": () => (/* binding */ plugin)
2910 /* harmony export */ });
2911 /**
2912 * Tom Select v2.4.3
2913 * Licensed under the Apache License, Version 2.0 (the "License");
2914 */
2915
2916 /**
2917 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
2918 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
2919 *
2920 * param query should be {}
2921 */
2922 const getDom = query => {
2923 if (query.jquery) {
2924 return query[0];
2925 }
2926 if (query instanceof HTMLElement) {
2927 return query;
2928 }
2929 if (isHtmlString(query)) {
2930 var tpl = document.createElement('template');
2931 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
2932 return tpl.content.firstChild;
2933 }
2934 return document.querySelector(query);
2935 };
2936 const isHtmlString = arg => {
2937 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
2938 return true;
2939 }
2940 return false;
2941 };
2942
2943 /**
2944 * Plugin: "dropdown_header" (Tom Select)
2945 * Copyright (c) contributors
2946 *
2947 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
2948 * file except in compliance with the License. You may obtain a copy of the License at:
2949 * http://www.apache.org/licenses/LICENSE-2.0
2950 *
2951 * Unless required by applicable law or agreed to in writing, software distributed under
2952 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
2953 * ANY KIND, either express or implied. See the License for the specific language
2954 * governing permissions and limitations under the License.
2955 *
2956 */
2957
2958 function plugin (userOptions) {
2959 const self = this;
2960 const options = Object.assign({
2961 className: 'clear-button',
2962 title: 'Clear All',
2963 html: data => {
2964 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
2965 }
2966 }, userOptions);
2967 self.on('initialize', () => {
2968 var button = getDom(options.html(options));
2969 button.addEventListener('click', evt => {
2970 if (self.isLocked) return;
2971 self.clear();
2972 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
2973 self.addItem('');
2974 }
2975 evt.preventDefault();
2976 evt.stopPropagation();
2977 });
2978 self.control.appendChild(button);
2979 });
2980 }
2981
2982
2983 //# sourceMappingURL=plugin.js.map
2984
2985
2986 /***/ },
2987
2988 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
2989 /*!**********************************************************************!*\
2990 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
2991 \**********************************************************************/
2992 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
2993
2994 __webpack_require__.r(__webpack_exports__);
2995 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2996 /* harmony export */ "default": () => (/* binding */ plugin)
2997 /* harmony export */ });
2998 /**
2999 * Tom Select v2.4.3
3000 * Licensed under the Apache License, Version 2.0 (the "License");
3001 */
3002
3003 /**
3004 * Converts a scalar to its best string representation
3005 * for hash keys and HTML attribute values.
3006 *
3007 * Transformations:
3008 * 'str' -> 'str'
3009 * null -> ''
3010 * undefined -> ''
3011 * true -> '1'
3012 * false -> '0'
3013 * 0 -> '0'
3014 * 1 -> '1'
3015 *
3016 */
3017
3018 /**
3019 * Prevent default
3020 *
3021 */
3022 const preventDefault = (evt, stop = false) => {
3023 if (evt) {
3024 evt.preventDefault();
3025 if (stop) {
3026 evt.stopPropagation();
3027 }
3028 }
3029 };
3030
3031 /**
3032 * Add event helper
3033 *
3034 */
3035 const addEvent = (target, type, callback, options) => {
3036 target.addEventListener(type, callback, options);
3037 };
3038
3039 /**
3040 * Iterates over arrays and hashes.
3041 *
3042 * ```
3043 * iterate(this.items, function(item, id) {
3044 * // invoked for each item
3045 * });
3046 * ```
3047 *
3048 */
3049 const iterate = (object, callback) => {
3050 if (Array.isArray(object)) {
3051 object.forEach(callback);
3052 } else {
3053 for (var key in object) {
3054 if (object.hasOwnProperty(key)) {
3055 callback(object[key], key);
3056 }
3057 }
3058 }
3059 };
3060
3061 /**
3062 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3063 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3064 *
3065 * param query should be {}
3066 */
3067 const getDom = query => {
3068 if (query.jquery) {
3069 return query[0];
3070 }
3071 if (query instanceof HTMLElement) {
3072 return query;
3073 }
3074 if (isHtmlString(query)) {
3075 var tpl = document.createElement('template');
3076 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3077 return tpl.content.firstChild;
3078 }
3079 return document.querySelector(query);
3080 };
3081 const isHtmlString = arg => {
3082 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3083 return true;
3084 }
3085 return false;
3086 };
3087
3088 /**
3089 * Set attributes of an element
3090 *
3091 */
3092 const setAttr = (el, attrs) => {
3093 iterate(attrs, (val, attr) => {
3094 if (val == null) {
3095 el.removeAttribute(attr);
3096 } else {
3097 el.setAttribute(attr, '' + val);
3098 }
3099 });
3100 };
3101
3102 /**
3103 * Plugin: "drag_drop" (Tom Select)
3104 * Copyright (c) contributors
3105 *
3106 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3107 * file except in compliance with the License. You may obtain a copy of the License at:
3108 * http://www.apache.org/licenses/LICENSE-2.0
3109 *
3110 * Unless required by applicable law or agreed to in writing, software distributed under
3111 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3112 * ANY KIND, either express or implied. See the License for the specific language
3113 * governing permissions and limitations under the License.
3114 *
3115 */
3116
3117 const insertAfter = (referenceNode, newNode) => {
3118 var _referenceNode$parent;
3119 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
3120 };
3121 const insertBefore = (referenceNode, newNode) => {
3122 var _referenceNode$parent2;
3123 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
3124 };
3125 const isBefore = (referenceNode, newNode) => {
3126 do {
3127 var _newNode;
3128 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
3129 if (referenceNode == newNode) {
3130 return true;
3131 }
3132 } while (newNode && newNode.previousElementSibling);
3133 return false;
3134 };
3135 function plugin () {
3136 var self = this;
3137 if (self.settings.mode !== 'multi') return;
3138 var orig_lock = self.lock;
3139 var orig_unlock = self.unlock;
3140 let sortable = true;
3141 let drag_item;
3142
3143 /**
3144 * Add draggable attribute to item
3145 */
3146 self.hook('after', 'setupTemplates', () => {
3147 var orig_render_item = self.settings.render.item;
3148 self.settings.render.item = (data, escape) => {
3149 const item = getDom(orig_render_item.call(self, data, escape));
3150 setAttr(item, {
3151 'draggable': 'true'
3152 });
3153
3154 // prevent doc_mousedown (see tom-select.ts)
3155 const mousedown = evt => {
3156 if (!sortable) preventDefault(evt);
3157 evt.stopPropagation();
3158 };
3159 const dragStart = evt => {
3160 drag_item = item;
3161 setTimeout(() => {
3162 item.classList.add('ts-dragging');
3163 }, 0);
3164 };
3165 const dragOver = evt => {
3166 evt.preventDefault();
3167 item.classList.add('ts-drag-over');
3168 moveitem(item, drag_item);
3169 };
3170 const dragLeave = () => {
3171 item.classList.remove('ts-drag-over');
3172 };
3173 const moveitem = (targetitem, dragitem) => {
3174 if (dragitem === undefined) return;
3175 if (isBefore(dragitem, item)) {
3176 insertAfter(targetitem, dragitem);
3177 } else {
3178 insertBefore(targetitem, dragitem);
3179 }
3180 };
3181 const dragend = () => {
3182 var _drag_item;
3183 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
3184 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
3185 drag_item = undefined;
3186 var values = [];
3187 self.control.querySelectorAll(`[data-value]`).forEach(el => {
3188 if (el.dataset.value) {
3189 let value = el.dataset.value;
3190 if (value) {
3191 values.push(value);
3192 }
3193 }
3194 });
3195 self.setValue(values);
3196 };
3197 addEvent(item, 'mousedown', mousedown);
3198 addEvent(item, 'dragstart', dragStart);
3199 addEvent(item, 'dragenter', dragOver);
3200 addEvent(item, 'dragover', dragOver);
3201 addEvent(item, 'dragleave', dragLeave);
3202 addEvent(item, 'dragend', dragend);
3203 return item;
3204 };
3205 });
3206 self.hook('instead', 'lock', () => {
3207 sortable = false;
3208 return orig_lock.call(self);
3209 });
3210 self.hook('instead', 'unlock', () => {
3211 sortable = true;
3212 return orig_unlock.call(self);
3213 });
3214 }
3215
3216
3217 //# sourceMappingURL=plugin.js.map
3218
3219
3220 /***/ },
3221
3222 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
3223 /*!****************************************************************************!*\
3224 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
3225 \****************************************************************************/
3226 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3227
3228 __webpack_require__.r(__webpack_exports__);
3229 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3230 /* harmony export */ "default": () => (/* binding */ plugin)
3231 /* harmony export */ });
3232 /**
3233 * Tom Select v2.4.3
3234 * Licensed under the Apache License, Version 2.0 (the "License");
3235 */
3236
3237 /**
3238 * Converts a scalar to its best string representation
3239 * for hash keys and HTML attribute values.
3240 *
3241 * Transformations:
3242 * 'str' -> 'str'
3243 * null -> ''
3244 * undefined -> ''
3245 * true -> '1'
3246 * false -> '0'
3247 * 0 -> '0'
3248 * 1 -> '1'
3249 *
3250 */
3251
3252 /**
3253 * Prevent default
3254 *
3255 */
3256 const preventDefault = (evt, stop = false) => {
3257 if (evt) {
3258 evt.preventDefault();
3259 if (stop) {
3260 evt.stopPropagation();
3261 }
3262 }
3263 };
3264
3265 /**
3266 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3267 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3268 *
3269 * param query should be {}
3270 */
3271 const getDom = query => {
3272 if (query.jquery) {
3273 return query[0];
3274 }
3275 if (query instanceof HTMLElement) {
3276 return query;
3277 }
3278 if (isHtmlString(query)) {
3279 var tpl = document.createElement('template');
3280 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3281 return tpl.content.firstChild;
3282 }
3283 return document.querySelector(query);
3284 };
3285 const isHtmlString = arg => {
3286 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3287 return true;
3288 }
3289 return false;
3290 };
3291
3292 /**
3293 * Plugin: "dropdown_header" (Tom Select)
3294 * Copyright (c) contributors
3295 *
3296 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3297 * file except in compliance with the License. You may obtain a copy of the License at:
3298 * http://www.apache.org/licenses/LICENSE-2.0
3299 *
3300 * Unless required by applicable law or agreed to in writing, software distributed under
3301 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3302 * ANY KIND, either express or implied. See the License for the specific language
3303 * governing permissions and limitations under the License.
3304 *
3305 */
3306
3307 function plugin (userOptions) {
3308 const self = this;
3309 const options = Object.assign({
3310 title: 'Untitled',
3311 headerClass: 'dropdown-header',
3312 titleRowClass: 'dropdown-header-title',
3313 labelClass: 'dropdown-header-label',
3314 closeClass: 'dropdown-header-close',
3315 html: data => {
3316 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
3317 }
3318 }, userOptions);
3319 self.on('initialize', () => {
3320 var header = getDom(options.html(options));
3321 var close_link = header.querySelector('.' + options.closeClass);
3322 if (close_link) {
3323 close_link.addEventListener('click', evt => {
3324 preventDefault(evt, true);
3325 self.close();
3326 });
3327 }
3328 self.dropdown.insertBefore(header, self.dropdown.firstChild);
3329 });
3330 }
3331
3332
3333 //# sourceMappingURL=plugin.js.map
3334
3335
3336 /***/ },
3337
3338 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
3339 /*!***************************************************************************!*\
3340 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
3341 \***************************************************************************/
3342 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3343
3344 __webpack_require__.r(__webpack_exports__);
3345 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3346 /* harmony export */ "default": () => (/* binding */ plugin)
3347 /* harmony export */ });
3348 /**
3349 * Tom Select v2.4.3
3350 * Licensed under the Apache License, Version 2.0 (the "License");
3351 */
3352
3353 const KEY_ESC = 27;
3354 const KEY_TAB = 9;
3355 // ctrl key or apple key for ma
3356
3357 /**
3358 * Converts a scalar to its best string representation
3359 * for hash keys and HTML attribute values.
3360 *
3361 * Transformations:
3362 * 'str' -> 'str'
3363 * null -> ''
3364 * undefined -> ''
3365 * true -> '1'
3366 * false -> '0'
3367 * 0 -> '0'
3368 * 1 -> '1'
3369 *
3370 */
3371
3372 /**
3373 * Prevent default
3374 *
3375 */
3376 const preventDefault = (evt, stop = false) => {
3377 if (evt) {
3378 evt.preventDefault();
3379 if (stop) {
3380 evt.stopPropagation();
3381 }
3382 }
3383 };
3384
3385 /**
3386 * Add event helper
3387 *
3388 */
3389 const addEvent = (target, type, callback, options) => {
3390 target.addEventListener(type, callback, options);
3391 };
3392
3393 /**
3394 * Iterates over arrays and hashes.
3395 *
3396 * ```
3397 * iterate(this.items, function(item, id) {
3398 * // invoked for each item
3399 * });
3400 * ```
3401 *
3402 */
3403 const iterate = (object, callback) => {
3404 if (Array.isArray(object)) {
3405 object.forEach(callback);
3406 } else {
3407 for (var key in object) {
3408 if (object.hasOwnProperty(key)) {
3409 callback(object[key], key);
3410 }
3411 }
3412 }
3413 };
3414
3415 /**
3416 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3417 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3418 *
3419 * param query should be {}
3420 */
3421 const getDom = query => {
3422 if (query.jquery) {
3423 return query[0];
3424 }
3425 if (query instanceof HTMLElement) {
3426 return query;
3427 }
3428 if (isHtmlString(query)) {
3429 var tpl = document.createElement('template');
3430 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3431 return tpl.content.firstChild;
3432 }
3433 return document.querySelector(query);
3434 };
3435 const isHtmlString = arg => {
3436 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3437 return true;
3438 }
3439 return false;
3440 };
3441
3442 /**
3443 * Add css classes
3444 *
3445 */
3446 const addClasses = (elmts, ...classes) => {
3447 var norm_classes = classesArray(classes);
3448 elmts = castAsArray(elmts);
3449 elmts.map(el => {
3450 norm_classes.map(cls => {
3451 el.classList.add(cls);
3452 });
3453 });
3454 };
3455
3456 /**
3457 * Return arguments
3458 *
3459 */
3460 const classesArray = args => {
3461 var classes = [];
3462 iterate(args, _classes => {
3463 if (typeof _classes === 'string') {
3464 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
3465 }
3466 if (Array.isArray(_classes)) {
3467 classes = classes.concat(_classes);
3468 }
3469 });
3470 return classes.filter(Boolean);
3471 };
3472
3473 /**
3474 * Create an array from arg if it's not already an array
3475 *
3476 */
3477 const castAsArray = arg => {
3478 if (!Array.isArray(arg)) {
3479 arg = [arg];
3480 }
3481 return arg;
3482 };
3483
3484 /**
3485 * Plugin: "dropdown_input" (Tom Select)
3486 * Copyright (c) contributors
3487 *
3488 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3489 * file except in compliance with the License. You may obtain a copy of the License at:
3490 * http://www.apache.org/licenses/LICENSE-2.0
3491 *
3492 * Unless required by applicable law or agreed to in writing, software distributed under
3493 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3494 * ANY KIND, either express or implied. See the License for the specific language
3495 * governing permissions and limitations under the License.
3496 *
3497 */
3498
3499 function plugin () {
3500 const self = this;
3501 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
3502
3503 self.hook('before', 'setup', () => {
3504 self.focus_node = self.control;
3505 addClasses(self.control_input, 'dropdown-input');
3506 const div = getDom('<div class="dropdown-input-wrap">');
3507 div.append(self.control_input);
3508 self.dropdown.insertBefore(div, self.dropdown.firstChild);
3509
3510 // set a placeholder in the select control
3511 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
3512 placeholder.placeholder = self.settings.placeholder || '';
3513 self.control.append(placeholder);
3514 });
3515 self.on('initialize', () => {
3516 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
3517 self.control_input.addEventListener('keydown', evt => {
3518 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
3519 switch (evt.keyCode) {
3520 case KEY_ESC:
3521 if (self.isOpen) {
3522 preventDefault(evt, true);
3523 self.close();
3524 }
3525 self.clearActiveItems();
3526 return;
3527 case KEY_TAB:
3528 self.focus_node.tabIndex = -1;
3529 break;
3530 }
3531 return self.onKeyDown.call(self, evt);
3532 });
3533 self.on('blur', () => {
3534 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
3535 });
3536
3537 // give the control_input focus when the dropdown is open
3538 self.on('dropdown_open', () => {
3539 self.control_input.focus();
3540 });
3541
3542 // prevent onBlur from closing when focus is on the control_input
3543 const orig_onBlur = self.onBlur;
3544 self.hook('instead', 'onBlur', evt => {
3545 if (evt && evt.relatedTarget == self.control_input) return;
3546 return orig_onBlur.call(self);
3547 });
3548 addEvent(self.control_input, 'blur', () => self.onBlur());
3549
3550 // return focus to control to allow further keyboard input
3551 self.hook('before', 'close', () => {
3552 if (!self.isOpen) return;
3553 self.focus_node.focus({
3554 preventScroll: true
3555 });
3556 });
3557 });
3558 }
3559
3560
3561 //# sourceMappingURL=plugin.js.map
3562
3563
3564 /***/ },
3565
3566 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
3567 /*!***************************************************************************!*\
3568 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
3569 \***************************************************************************/
3570 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3571
3572 __webpack_require__.r(__webpack_exports__);
3573 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3574 /* harmony export */ "default": () => (/* binding */ plugin)
3575 /* harmony export */ });
3576 /**
3577 * Tom Select v2.4.3
3578 * Licensed under the Apache License, Version 2.0 (the "License");
3579 */
3580
3581 /**
3582 * Converts a scalar to its best string representation
3583 * for hash keys and HTML attribute values.
3584 *
3585 * Transformations:
3586 * 'str' -> 'str'
3587 * null -> ''
3588 * undefined -> ''
3589 * true -> '1'
3590 * false -> '0'
3591 * 0 -> '0'
3592 * 1 -> '1'
3593 *
3594 */
3595
3596 /**
3597 * Add event helper
3598 *
3599 */
3600 const addEvent = (target, type, callback, options) => {
3601 target.addEventListener(type, callback, options);
3602 };
3603
3604 /**
3605 * Plugin: "input_autogrow" (Tom Select)
3606 *
3607 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3608 * file except in compliance with the License. You may obtain a copy of the License at:
3609 * http://www.apache.org/licenses/LICENSE-2.0
3610 *
3611 * Unless required by applicable law or agreed to in writing, software distributed under
3612 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3613 * ANY KIND, either express or implied. See the License for the specific language
3614 * governing permissions and limitations under the License.
3615 *
3616 */
3617
3618 function plugin () {
3619 var self = this;
3620 self.on('initialize', () => {
3621 var test_input = document.createElement('span');
3622 var control = self.control_input;
3623 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
3624 self.wrapper.appendChild(test_input);
3625 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
3626 for (const style_name of transfer_styles) {
3627 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
3628 test_input.style[style_name] = control.style[style_name];
3629 }
3630
3631 /**
3632 * Set the control width
3633 *
3634 */
3635 var resize = () => {
3636 test_input.textContent = control.value;
3637 control.style.width = test_input.clientWidth + 'px';
3638 };
3639 resize();
3640 self.on('update item_add item_remove', resize);
3641 addEvent(control, 'input', resize);
3642 addEvent(control, 'keyup', resize);
3643 addEvent(control, 'blur', resize);
3644 addEvent(control, 'update', resize);
3645 });
3646 }
3647
3648
3649 //# sourceMappingURL=plugin.js.map
3650
3651
3652 /***/ },
3653
3654 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
3655 /*!****************************************************************************!*\
3656 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
3657 \****************************************************************************/
3658 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3659
3660 __webpack_require__.r(__webpack_exports__);
3661 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3662 /* harmony export */ "default": () => (/* binding */ plugin)
3663 /* harmony export */ });
3664 /**
3665 * Tom Select v2.4.3
3666 * Licensed under the Apache License, Version 2.0 (the "License");
3667 */
3668
3669 /**
3670 * Plugin: "no_active_items" (Tom Select)
3671 *
3672 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3673 * file except in compliance with the License. You may obtain a copy of the License at:
3674 * http://www.apache.org/licenses/LICENSE-2.0
3675 *
3676 * Unless required by applicable law or agreed to in writing, software distributed under
3677 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3678 * ANY KIND, either express or implied. See the License for the specific language
3679 * governing permissions and limitations under the License.
3680 *
3681 */
3682
3683 function plugin () {
3684 this.hook('instead', 'setActiveItem', () => {});
3685 this.hook('instead', 'selectAll', () => {});
3686 }
3687
3688
3689 //# sourceMappingURL=plugin.js.map
3690
3691
3692 /***/ },
3693
3694 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
3695 /*!********************************************************************************!*\
3696 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
3697 \********************************************************************************/
3698 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3699
3700 __webpack_require__.r(__webpack_exports__);
3701 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3702 /* harmony export */ "default": () => (/* binding */ plugin)
3703 /* harmony export */ });
3704 /**
3705 * Tom Select v2.4.3
3706 * Licensed under the Apache License, Version 2.0 (the "License");
3707 */
3708
3709 /**
3710 * Plugin: "input_autogrow" (Tom Select)
3711 *
3712 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3713 * file except in compliance with the License. You may obtain a copy of the License at:
3714 * http://www.apache.org/licenses/LICENSE-2.0
3715 *
3716 * Unless required by applicable law or agreed to in writing, software distributed under
3717 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3718 * ANY KIND, either express or implied. See the License for the specific language
3719 * governing permissions and limitations under the License.
3720 *
3721 */
3722
3723 function plugin () {
3724 var self = this;
3725 var orig_deleteSelection = self.deleteSelection;
3726 this.hook('instead', 'deleteSelection', evt => {
3727 if (self.activeItems.length) {
3728 return orig_deleteSelection.call(self, evt);
3729 }
3730 return false;
3731 });
3732 }
3733
3734
3735 //# sourceMappingURL=plugin.js.map
3736
3737
3738 /***/ },
3739
3740 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
3741 /*!*****************************************************************************!*\
3742 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
3743 \*****************************************************************************/
3744 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3745
3746 __webpack_require__.r(__webpack_exports__);
3747 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3748 /* harmony export */ "default": () => (/* binding */ plugin)
3749 /* harmony export */ });
3750 /**
3751 * Tom Select v2.4.3
3752 * Licensed under the Apache License, Version 2.0 (the "License");
3753 */
3754
3755 const KEY_LEFT = 37;
3756 const KEY_RIGHT = 39;
3757 // ctrl key or apple key for ma
3758
3759 /**
3760 * Get the closest node to the evt.target matching the selector
3761 * Stops at wrapper
3762 *
3763 */
3764 const parentMatch = (target, selector, wrapper) => {
3765 while (target && target.matches) {
3766 if (target.matches(selector)) {
3767 return target;
3768 }
3769 target = target.parentNode;
3770 }
3771 };
3772
3773 /**
3774 * Get the index of an element amongst sibling nodes of the same type
3775 *
3776 */
3777 const nodeIndex = (el, amongst) => {
3778 if (!el) return -1;
3779 amongst = amongst || el.nodeName;
3780 var i = 0;
3781 while (el = el.previousElementSibling) {
3782 if (el.matches(amongst)) {
3783 i++;
3784 }
3785 }
3786 return i;
3787 };
3788
3789 /**
3790 * Plugin: "optgroup_columns" (Tom Select.js)
3791 * Copyright (c) contributors
3792 *
3793 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3794 * file except in compliance with the License. You may obtain a copy of the License at:
3795 * http://www.apache.org/licenses/LICENSE-2.0
3796 *
3797 * Unless required by applicable law or agreed to in writing, software distributed under
3798 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3799 * ANY KIND, either express or implied. See the License for the specific language
3800 * governing permissions and limitations under the License.
3801 *
3802 */
3803
3804 function plugin () {
3805 var self = this;
3806 var orig_keydown = self.onKeyDown;
3807 self.hook('instead', 'onKeyDown', evt => {
3808 var index, option, options, optgroup;
3809 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
3810 return orig_keydown.call(self, evt);
3811 }
3812 self.ignoreHover = true;
3813 optgroup = parentMatch(self.activeOption, '[data-group]');
3814 index = nodeIndex(self.activeOption, '[data-selectable]');
3815 if (!optgroup) {
3816 return;
3817 }
3818 if (evt.keyCode === KEY_LEFT) {
3819 optgroup = optgroup.previousSibling;
3820 } else {
3821 optgroup = optgroup.nextSibling;
3822 }
3823 if (!optgroup) {
3824 return;
3825 }
3826 options = optgroup.querySelectorAll('[data-selectable]');
3827 option = options[Math.min(options.length - 1, index)];
3828 if (option) {
3829 self.setActiveOption(option);
3830 }
3831 });
3832 }
3833
3834
3835 //# sourceMappingURL=plugin.js.map
3836
3837
3838 /***/ },
3839
3840 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
3841 /*!**************************************************************************!*\
3842 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
3843 \**************************************************************************/
3844 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3845
3846 __webpack_require__.r(__webpack_exports__);
3847 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3848 /* harmony export */ "default": () => (/* binding */ plugin)
3849 /* harmony export */ });
3850 /**
3851 * Tom Select v2.4.3
3852 * Licensed under the Apache License, Version 2.0 (the "License");
3853 */
3854
3855 /**
3856 * Converts a scalar to its best string representation
3857 * for hash keys and HTML attribute values.
3858 *
3859 * Transformations:
3860 * 'str' -> 'str'
3861 * null -> ''
3862 * undefined -> ''
3863 * true -> '1'
3864 * false -> '0'
3865 * 0 -> '0'
3866 * 1 -> '1'
3867 *
3868 */
3869
3870 /**
3871 * Escapes a string for use within HTML.
3872 *
3873 */
3874 const escape_html = str => {
3875 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
3876 };
3877
3878 /**
3879 * Prevent default
3880 *
3881 */
3882 const preventDefault = (evt, stop = false) => {
3883 if (evt) {
3884 evt.preventDefault();
3885 if (stop) {
3886 evt.stopPropagation();
3887 }
3888 }
3889 };
3890
3891 /**
3892 * Add event helper
3893 *
3894 */
3895 const addEvent = (target, type, callback, options) => {
3896 target.addEventListener(type, callback, options);
3897 };
3898
3899 /**
3900 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
3901 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
3902 *
3903 * param query should be {}
3904 */
3905 const getDom = query => {
3906 if (query.jquery) {
3907 return query[0];
3908 }
3909 if (query instanceof HTMLElement) {
3910 return query;
3911 }
3912 if (isHtmlString(query)) {
3913 var tpl = document.createElement('template');
3914 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
3915 return tpl.content.firstChild;
3916 }
3917 return document.querySelector(query);
3918 };
3919 const isHtmlString = arg => {
3920 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
3921 return true;
3922 }
3923 return false;
3924 };
3925
3926 /**
3927 * Plugin: "remove_button" (Tom Select)
3928 * Copyright (c) contributors
3929 *
3930 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
3931 * file except in compliance with the License. You may obtain a copy of the License at:
3932 * http://www.apache.org/licenses/LICENSE-2.0
3933 *
3934 * Unless required by applicable law or agreed to in writing, software distributed under
3935 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
3936 * ANY KIND, either express or implied. See the License for the specific language
3937 * governing permissions and limitations under the License.
3938 *
3939 */
3940
3941 function plugin (userOptions) {
3942 const options = Object.assign({
3943 label: '&times;',
3944 title: 'Remove',
3945 className: 'remove',
3946 append: true
3947 }, userOptions);
3948
3949 //options.className = 'remove-single';
3950 var self = this;
3951
3952 // override the render method to add remove button to each item
3953 if (!options.append) {
3954 return;
3955 }
3956 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
3957 self.hook('after', 'setupTemplates', () => {
3958 var orig_render_item = self.settings.render.item;
3959 self.settings.render.item = (data, escape) => {
3960 var item = getDom(orig_render_item.call(self, data, escape));
3961 var close_button = getDom(html);
3962 item.appendChild(close_button);
3963 addEvent(close_button, 'mousedown', evt => {
3964 preventDefault(evt, true);
3965 });
3966 addEvent(close_button, 'click', evt => {
3967 if (self.isLocked) return;
3968
3969 // propagating will trigger the dropdown to show for single mode
3970 preventDefault(evt, true);
3971 if (self.isLocked) return;
3972 if (!self.shouldDelete([item], evt)) return;
3973 self.removeItem(item);
3974 self.refreshOptions(false);
3975 self.inputState();
3976 });
3977 return item;
3978 };
3979 });
3980 }
3981
3982
3983 //# sourceMappingURL=plugin.js.map
3984
3985
3986 /***/ },
3987
3988 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
3989 /*!*********************************************************************************!*\
3990 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
3991 \*********************************************************************************/
3992 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
3993
3994 __webpack_require__.r(__webpack_exports__);
3995 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
3996 /* harmony export */ "default": () => (/* binding */ plugin)
3997 /* harmony export */ });
3998 /**
3999 * Tom Select v2.4.3
4000 * Licensed under the Apache License, Version 2.0 (the "License");
4001 */
4002
4003 /**
4004 * Plugin: "restore_on_backspace" (Tom Select)
4005 * Copyright (c) contributors
4006 *
4007 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4008 * file except in compliance with the License. You may obtain a copy of the License at:
4009 * http://www.apache.org/licenses/LICENSE-2.0
4010 *
4011 * Unless required by applicable law or agreed to in writing, software distributed under
4012 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4013 * ANY KIND, either express or implied. See the License for the specific language
4014 * governing permissions and limitations under the License.
4015 *
4016 */
4017
4018 function plugin (userOptions) {
4019 const self = this;
4020 const options = Object.assign({
4021 text: option => {
4022 return option[self.settings.labelField];
4023 }
4024 }, userOptions);
4025 self.on('item_remove', function (value) {
4026 if (!self.isFocused) {
4027 return;
4028 }
4029 if (self.control_input.value.trim() === '') {
4030 var option = self.options[value];
4031 if (option) {
4032 self.setTextboxValue(options.text.call(self, option));
4033 }
4034 }
4035 });
4036 }
4037
4038
4039 //# sourceMappingURL=plugin.js.map
4040
4041
4042 /***/ },
4043
4044 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
4045 /*!***************************************************************************!*\
4046 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
4047 \***************************************************************************/
4048 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4049
4050 __webpack_require__.r(__webpack_exports__);
4051 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4052 /* harmony export */ "default": () => (/* binding */ plugin)
4053 /* harmony export */ });
4054 /**
4055 * Tom Select v2.4.3
4056 * Licensed under the Apache License, Version 2.0 (the "License");
4057 */
4058
4059 /**
4060 * Converts a scalar to its best string representation
4061 * for hash keys and HTML attribute values.
4062 *
4063 * Transformations:
4064 * 'str' -> 'str'
4065 * null -> ''
4066 * undefined -> ''
4067 * true -> '1'
4068 * false -> '0'
4069 * 0 -> '0'
4070 * 1 -> '1'
4071 *
4072 */
4073
4074 /**
4075 * Iterates over arrays and hashes.
4076 *
4077 * ```
4078 * iterate(this.items, function(item, id) {
4079 * // invoked for each item
4080 * });
4081 * ```
4082 *
4083 */
4084 const iterate = (object, callback) => {
4085 if (Array.isArray(object)) {
4086 object.forEach(callback);
4087 } else {
4088 for (var key in object) {
4089 if (object.hasOwnProperty(key)) {
4090 callback(object[key], key);
4091 }
4092 }
4093 }
4094 };
4095
4096 /**
4097 * Add css classes
4098 *
4099 */
4100 const addClasses = (elmts, ...classes) => {
4101 var norm_classes = classesArray(classes);
4102 elmts = castAsArray(elmts);
4103 elmts.map(el => {
4104 norm_classes.map(cls => {
4105 el.classList.add(cls);
4106 });
4107 });
4108 };
4109
4110 /**
4111 * Return arguments
4112 *
4113 */
4114 const classesArray = args => {
4115 var classes = [];
4116 iterate(args, _classes => {
4117 if (typeof _classes === 'string') {
4118 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
4119 }
4120 if (Array.isArray(_classes)) {
4121 classes = classes.concat(_classes);
4122 }
4123 });
4124 return classes.filter(Boolean);
4125 };
4126
4127 /**
4128 * Create an array from arg if it's not already an array
4129 *
4130 */
4131 const castAsArray = arg => {
4132 if (!Array.isArray(arg)) {
4133 arg = [arg];
4134 }
4135 return arg;
4136 };
4137
4138 /**
4139 * Plugin: "restore_on_backspace" (Tom Select)
4140 * Copyright (c) contributors
4141 *
4142 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
4143 * file except in compliance with the License. You may obtain a copy of the License at:
4144 * http://www.apache.org/licenses/LICENSE-2.0
4145 *
4146 * Unless required by applicable law or agreed to in writing, software distributed under
4147 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
4148 * ANY KIND, either express or implied. See the License for the specific language
4149 * governing permissions and limitations under the License.
4150 *
4151 */
4152
4153 function plugin () {
4154 const self = this;
4155 const orig_canLoad = self.canLoad;
4156 const orig_clearActiveOption = self.clearActiveOption;
4157 const orig_loadCallback = self.loadCallback;
4158 var pagination = {};
4159 var dropdown_content;
4160 var loading_more = false;
4161 var load_more_opt;
4162 var default_values = [];
4163 if (!self.settings.shouldLoadMore) {
4164 // return true if additional results should be loaded
4165 self.settings.shouldLoadMore = () => {
4166 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
4167 if (scroll_percent > 0.9) {
4168 return true;
4169 }
4170 if (self.activeOption) {
4171 var selectable = self.selectable();
4172 var index = Array.from(selectable).indexOf(self.activeOption);
4173 if (index >= selectable.length - 2) {
4174 return true;
4175 }
4176 }
4177 return false;
4178 };
4179 }
4180 if (!self.settings.firstUrl) {
4181 throw 'virtual_scroll plugin requires a firstUrl() method';
4182 }
4183
4184 // in order for virtual scrolling to work,
4185 // options need to be ordered the same way they're returned from the remote data source
4186 self.settings.sortField = [{
4187 field: '$order'
4188 }, {
4189 field: '$score'
4190 }];
4191
4192 // can we load more results for given query?
4193 const canLoadMore = query => {
4194 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
4195 return false;
4196 }
4197 if (query in pagination && pagination[query]) {
4198 return true;
4199 }
4200 return false;
4201 };
4202 const clearFilter = (option, value) => {
4203 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
4204 return true;
4205 }
4206 return false;
4207 };
4208
4209 // set the next url that will be
4210 self.setNextUrl = (value, next_url) => {
4211 pagination[value] = next_url;
4212 };
4213
4214 // getUrl() to be used in settings.load()
4215 self.getUrl = query => {
4216 if (query in pagination) {
4217 const next_url = pagination[query];
4218 pagination[query] = false;
4219 return next_url;
4220 }
4221
4222 // if the user goes back to a previous query
4223 // we need to load the first page again
4224 self.clearPagination();
4225 return self.settings.firstUrl.call(self, query);
4226 };
4227
4228 // clear pagination
4229 self.clearPagination = () => {
4230 pagination = {};
4231 };
4232
4233 // don't clear the active option (and cause unwanted dropdown scroll)
4234 // while loading more results
4235 self.hook('instead', 'clearActiveOption', () => {
4236 if (loading_more) {
4237 return;
4238 }
4239 return orig_clearActiveOption.call(self);
4240 });
4241
4242 // override the canLoad method
4243 self.hook('instead', 'canLoad', query => {
4244 // first time the query has been seen
4245 if (!(query in pagination)) {
4246 return orig_canLoad.call(self, query);
4247 }
4248 return canLoadMore(query);
4249 });
4250
4251 // wrap the load
4252 self.hook('instead', 'loadCallback', (options, optgroups) => {
4253 if (!loading_more) {
4254 self.clearOptions(clearFilter);
4255 } else if (load_more_opt) {
4256 const first_option = options[0];
4257 if (first_option !== undefined) {
4258 load_more_opt.dataset.value = first_option[self.settings.valueField];
4259 }
4260 }
4261 orig_loadCallback.call(self, options, optgroups);
4262 loading_more = false;
4263 });
4264
4265 // add templates to dropdown
4266 // loading_more if we have another url in the queue
4267 // no_more_results if we don't have another url in the queue
4268 self.hook('after', 'refreshOptions', () => {
4269 const query = self.lastValue;
4270 var option;
4271 if (canLoadMore(query)) {
4272 option = self.render('loading_more', {
4273 query: query
4274 });
4275 if (option) {
4276 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
4277 load_more_opt = option;
4278 }
4279 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
4280 option = self.render('no_more_results', {
4281 query: query
4282 });
4283 }
4284 if (option) {
4285 addClasses(option, self.settings.optionClass);
4286 dropdown_content.append(option);
4287 }
4288 });
4289
4290 // add scroll listener and default templates
4291 self.on('initialize', () => {
4292 default_values = Object.keys(self.options);
4293 dropdown_content = self.dropdown_content;
4294
4295 // default templates
4296 self.settings.render = Object.assign({}, {
4297 loading_more: () => {
4298 return `<div class="loading-more-results">Loading more results ... </div>`;
4299 },
4300 no_more_results: () => {
4301 return `<div class="no-more-results">No more results</div>`;
4302 }
4303 }, self.settings.render);
4304
4305 // watch dropdown content scroll position
4306 dropdown_content.addEventListener('scroll', () => {
4307 if (!self.settings.shouldLoadMore.call(self)) {
4308 return;
4309 }
4310
4311 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
4312 if (!canLoadMore(self.lastValue)) {
4313 return;
4314 }
4315
4316 // don't call load() too much
4317 if (loading_more) return;
4318 loading_more = true;
4319 self.load.call(self, self.lastValue);
4320 });
4321 });
4322 }
4323
4324
4325 //# sourceMappingURL=plugin.js.map
4326
4327
4328 /***/ },
4329
4330 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
4331 /*!*****************************************************************!*\
4332 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
4333 \*****************************************************************/
4334 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4335
4336 __webpack_require__.r(__webpack_exports__);
4337 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4338 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
4339 /* harmony export */ });
4340 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
4341 /* harmony import */ var _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./plugins/change_listener/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js");
4342 /* harmony import */ var _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./plugins/checkbox_options/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js");
4343 /* harmony import */ var _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./plugins/clear_button/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js");
4344 /* harmony import */ var _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./plugins/drag_drop/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js");
4345 /* harmony import */ var _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./plugins/dropdown_header/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js");
4346 /* harmony import */ var _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./plugins/caret_position/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js");
4347 /* harmony import */ var _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./plugins/dropdown_input/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js");
4348 /* harmony import */ var _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./plugins/input_autogrow/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js");
4349 /* harmony import */ var _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./plugins/no_backspace_delete/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js");
4350 /* harmony import */ var _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./plugins/no_active_items/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js");
4351 /* harmony import */ var _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./plugins/optgroup_columns/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js");
4352 /* harmony import */ var _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./plugins/remove_button/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js");
4353 /* harmony import */ var _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./plugins/restore_on_backspace/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js");
4354 /* harmony import */ var _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./plugins/virtual_scroll/plugin.js */ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js");
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
4366
4367
4368
4369
4370 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
4371 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
4372 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
4373 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
4374 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
4375 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
4376 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
4377 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
4378 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
4379 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
4380 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
4381 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
4382 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
4383 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
4384 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
4385 //# sourceMappingURL=tom-select.complete.js.map
4386
4387 /***/ },
4388
4389 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
4390 /*!********************************************************!*\
4391 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
4392 \********************************************************/
4393 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
4394
4395 __webpack_require__.r(__webpack_exports__);
4396 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4397 /* harmony export */ "default": () => (/* binding */ TomSelect)
4398 /* harmony export */ });
4399 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
4400 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
4401 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
4402 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
4403 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
4404 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
4405 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
4406 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
4407 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417 var instance_i = 0;
4418 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
4419 constructor(input_arg, user_settings) {
4420 super();
4421 this.order = 0;
4422 this.isOpen = false;
4423 this.isDisabled = false;
4424 this.isReadOnly = false;
4425 this.isInvalid = false; // @deprecated 1.8
4426 this.isValid = true;
4427 this.isLocked = false;
4428 this.isFocused = false;
4429 this.isInputHidden = false;
4430 this.isSetup = false;
4431 this.ignoreFocus = false;
4432 this.ignoreHover = false;
4433 this.hasOptions = false;
4434 this.lastValue = '';
4435 this.caretPos = 0;
4436 this.loading = 0;
4437 this.loadedSearches = {};
4438 this.activeOption = null;
4439 this.activeItems = [];
4440 this.optgroups = {};
4441 this.options = {};
4442 this.userOptions = {};
4443 this.items = [];
4444 this.refreshTimeout = null;
4445 instance_i++;
4446 var dir;
4447 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
4448 if (input.tomselect) {
4449 throw new Error('Tom Select already initialized on this element');
4450 }
4451 input.tomselect = this;
4452 // detect rtl environment
4453 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
4454 dir = computedStyle.getPropertyValue('direction');
4455 // setup default state
4456 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
4457 this.settings = settings;
4458 this.input = input;
4459 this.tabIndex = input.tabIndex || 0;
4460 this.is_select_tag = input.tagName.toLowerCase() === 'select';
4461 this.rtl = /rtl/i.test(dir);
4462 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
4463 this.isRequired = input.required;
4464 // search system
4465 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
4466 // option-dependent defaults
4467 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
4468 if (typeof settings.hideSelected !== 'boolean') {
4469 settings.hideSelected = settings.mode === 'multi';
4470 }
4471 if (typeof settings.hidePlaceholder !== 'boolean') {
4472 settings.hidePlaceholder = settings.mode !== 'multi';
4473 }
4474 // set up createFilter callback
4475 var filter = settings.createFilter;
4476 if (typeof filter !== 'function') {
4477 if (typeof filter === 'string') {
4478 filter = new RegExp(filter);
4479 }
4480 if (filter instanceof RegExp) {
4481 settings.createFilter = (input) => filter.test(input);
4482 }
4483 else {
4484 settings.createFilter = (value) => {
4485 return this.settings.duplicates || !this.options[value];
4486 };
4487 }
4488 }
4489 this.initializePlugins(settings.plugins);
4490 this.setupCallbacks();
4491 this.setupTemplates();
4492 // Create all elements
4493 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
4494 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
4495 const dropdown = this._render('dropdown');
4496 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
4497 const classes = this.input.getAttribute('class') || '';
4498 const inputMode = settings.mode;
4499 var control_input;
4500 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
4501 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
4502 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
4503 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
4504 if (settings.copyClassesToDropdown) {
4505 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
4506 }
4507 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
4508 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
4509 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
4510 // default controlInput
4511 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
4512 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
4513 // set attributes
4514 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
4515 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
4516 if (input.getAttribute(attr)) {
4517 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
4518 }
4519 });
4520 control_input.tabIndex = -1;
4521 control.appendChild(control_input);
4522 this.focus_node = control_input;
4523 // dom element
4524 }
4525 else if (settings.controlInput) {
4526 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
4527 this.focus_node = control_input;
4528 }
4529 else {
4530 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
4531 this.focus_node = control;
4532 }
4533 this.wrapper = wrapper;
4534 this.dropdown = dropdown;
4535 this.dropdown_content = dropdown_content;
4536 this.control = control;
4537 this.control_input = control_input;
4538 this.setup();
4539 }
4540 /**
4541 * set up event bindings.
4542 *
4543 */
4544 setup() {
4545 const self = this;
4546 const settings = self.settings;
4547 const control_input = self.control_input;
4548 const dropdown = self.dropdown;
4549 const dropdown_content = self.dropdown_content;
4550 const wrapper = self.wrapper;
4551 const control = self.control;
4552 const input = self.input;
4553 const focus_node = self.focus_node;
4554 const passive_event = { passive: true };
4555 const listboxId = self.inputId + '-ts-dropdown';
4556 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
4557 id: listboxId
4558 });
4559 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
4560 role: 'combobox',
4561 'aria-haspopup': 'listbox',
4562 'aria-expanded': 'false',
4563 'aria-controls': listboxId
4564 });
4565 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
4566 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
4567 const label = document.querySelector(query);
4568 const label_click = self.focus.bind(self);
4569 if (label) {
4570 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
4571 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
4572 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
4573 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
4574 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
4575 }
4576 wrapper.style.width = input.style.width;
4577 if (self.plugins.names.length) {
4578 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
4579 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
4580 }
4581 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
4582 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
4583 }
4584 if (settings.placeholder) {
4585 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
4586 }
4587 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
4588 if (!settings.splitOn && settings.delimiter) {
4589 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
4590 }
4591 // debounce user defined load() if loadThrottle > 0
4592 // after initializePlugins() so plugins can create/modify user defined loaders
4593 if (settings.load && settings.loadThrottle) {
4594 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
4595 }
4596 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
4597 self.ignoreHover = false;
4598 });
4599 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
4600 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
4601 if (target_match)
4602 self.onOptionHover(e, target_match);
4603 }, { capture: true });
4604 // clicking on an option should select it
4605 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
4606 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
4607 if (option) {
4608 self.onOptionSelect(evt, option);
4609 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4610 }
4611 });
4612 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
4613 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
4614 if (target_match && self.onItemSelect(evt, target_match)) {
4615 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4616 return;
4617 }
4618 // retain focus (see control_input mousedown)
4619 if (control_input.value != '') {
4620 return;
4621 }
4622 self.onClick();
4623 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4624 });
4625 // keydown on focus_node for arrow_down/arrow_up
4626 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
4627 // keypress and input/keyup
4628 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
4629 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
4630 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
4631 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
4632 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
4633 const doc_mousedown = (evt) => {
4634 // blur if target is outside of this instance
4635 // dropdown is not always inside wrapper
4636 const target = evt.composedPath()[0];
4637 if (!wrapper.contains(target) && !dropdown.contains(target)) {
4638 if (self.isFocused) {
4639 self.blur();
4640 }
4641 self.inputState();
4642 return;
4643 }
4644 // retain focus by preventing native handling. if the
4645 // event target is the input it should not be modified.
4646 // otherwise, text selection within the input won't work.
4647 // Fixes bug #212 which is no covered by tests
4648 if (target == control_input && self.isOpen) {
4649 evt.stopPropagation();
4650 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
4651 }
4652 else {
4653 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
4654 }
4655 };
4656 const win_scroll = () => {
4657 if (self.isOpen) {
4658 self.positionDropdown();
4659 }
4660 };
4661 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
4662 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
4663 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
4664 this._destroy = () => {
4665 document.removeEventListener('mousedown', doc_mousedown);
4666 window.removeEventListener('scroll', win_scroll);
4667 window.removeEventListener('resize', win_scroll);
4668 if (label)
4669 label.removeEventListener('click', label_click);
4670 };
4671 // store original html and tab index so that they can be
4672 // restored when the destroy() method is called.
4673 this.revertSettings = {
4674 innerHTML: input.innerHTML,
4675 tabIndex: input.tabIndex
4676 };
4677 input.tabIndex = -1;
4678 input.insertAdjacentElement('afterend', self.wrapper);
4679 self.sync(false);
4680 settings.items = [];
4681 delete settings.optgroups;
4682 delete settings.options;
4683 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
4684 if (self.isValid) {
4685 self.isValid = false;
4686 self.isInvalid = true;
4687 self.refreshState();
4688 }
4689 });
4690 self.updateOriginalInput();
4691 self.refreshItems();
4692 self.close(false);
4693 self.inputState();
4694 self.isSetup = true;
4695 if (input.disabled) {
4696 self.disable();
4697 }
4698 else if (input.readOnly) {
4699 self.setReadOnly(true);
4700 }
4701 else {
4702 self.enable(); //sets tabIndex
4703 }
4704 self.on('change', this.onChange);
4705 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
4706 self.trigger('initialize');
4707 // preload options
4708 if (settings.preload === true) {
4709 self.preload();
4710 }
4711 }
4712 /**
4713 * Register options and optgroups
4714 *
4715 */
4716 setupOptions(options = [], optgroups = []) {
4717 // build options table
4718 this.addOptions(options);
4719 // build optgroup table
4720 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
4721 this.registerOptionGroup(optgroup);
4722 });
4723 }
4724 /**
4725 * Sets up default rendering functions.
4726 */
4727 setupTemplates() {
4728 var self = this;
4729 var field_label = self.settings.labelField;
4730 var field_optgroup = self.settings.optgroupLabelField;
4731 var templates = {
4732 'optgroup': (data) => {
4733 let optgroup = document.createElement('div');
4734 optgroup.className = 'optgroup';
4735 optgroup.appendChild(data.options);
4736 return optgroup;
4737 },
4738 'optgroup_header': (data, escape) => {
4739 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
4740 },
4741 'option': (data, escape) => {
4742 return '<div>' + escape(data[field_label]) + '</div>';
4743 },
4744 'item': (data, escape) => {
4745 return '<div>' + escape(data[field_label]) + '</div>';
4746 },
4747 'option_create': (data, escape) => {
4748 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
4749 },
4750 'no_results': () => {
4751 return '<div class="no-results">No results found</div>';
4752 },
4753 'loading': () => {
4754 return '<div class="spinner"></div>';
4755 },
4756 'not_loading': () => { },
4757 'dropdown': () => {
4758 return '<div></div>';
4759 }
4760 };
4761 self.settings.render = Object.assign({}, templates, self.settings.render);
4762 }
4763 /**
4764 * Maps fired events to callbacks provided
4765 * in the settings used when creating the control.
4766 */
4767 setupCallbacks() {
4768 var key, fn;
4769 var callbacks = {
4770 'initialize': 'onInitialize',
4771 'change': 'onChange',
4772 'item_add': 'onItemAdd',
4773 'item_remove': 'onItemRemove',
4774 'item_select': 'onItemSelect',
4775 'clear': 'onClear',
4776 'option_add': 'onOptionAdd',
4777 'option_remove': 'onOptionRemove',
4778 'option_clear': 'onOptionClear',
4779 'optgroup_add': 'onOptionGroupAdd',
4780 'optgroup_remove': 'onOptionGroupRemove',
4781 'optgroup_clear': 'onOptionGroupClear',
4782 'dropdown_open': 'onDropdownOpen',
4783 'dropdown_close': 'onDropdownClose',
4784 'type': 'onType',
4785 'load': 'onLoad',
4786 'focus': 'onFocus',
4787 'blur': 'onBlur'
4788 };
4789 for (key in callbacks) {
4790 fn = this.settings[callbacks[key]];
4791 if (fn)
4792 this.on(key, fn);
4793 }
4794 }
4795 /**
4796 * Sync the Tom Select instance with the original input or select
4797 *
4798 */
4799 sync(get_settings = true) {
4800 const self = this;
4801 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
4802 self.setupOptions(settings.options, settings.optgroups);
4803 self.setValue(settings.items || [], true); // silent prevents recursion
4804 self.lastQuery = null; // so updated options will be displayed in dropdown
4805 }
4806 /**
4807 * Triggered when the main control element
4808 * has a click event.
4809 *
4810 */
4811 onClick() {
4812 var self = this;
4813 if (self.activeItems.length > 0) {
4814 self.clearActiveItems();
4815 self.focus();
4816 return;
4817 }
4818 if (self.isFocused && self.isOpen) {
4819 self.blur();
4820 }
4821 else {
4822 self.focus();
4823 }
4824 }
4825 /**
4826 * @deprecated v1.7
4827 *
4828 */
4829 onMouseDown() { }
4830 /**
4831 * Triggered when the value of the control has been changed.
4832 * This should propagate the event to the original DOM
4833 * input / select element.
4834 */
4835 onChange() {
4836 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
4837 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
4838 }
4839 /**
4840 * Triggered on <input> paste.
4841 *
4842 */
4843 onPaste(e) {
4844 var self = this;
4845 if (self.isInputHidden || self.isLocked) {
4846 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4847 return;
4848 }
4849 // If a regex or string is included, this will split the pasted
4850 // input and create Items for each separate value
4851 if (!self.settings.splitOn) {
4852 return;
4853 }
4854 // Wait for pasted text to be recognized in value
4855 setTimeout(() => {
4856 var pastedText = self.inputValue();
4857 if (!pastedText.match(self.settings.splitOn)) {
4858 return;
4859 }
4860 var splitInput = pastedText.trim().split(self.settings.splitOn);
4861 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
4862 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
4863 if (hash) {
4864 if (this.options[piece]) {
4865 self.addItem(piece);
4866 }
4867 else {
4868 self.createItem(piece);
4869 }
4870 }
4871 });
4872 }, 0);
4873 }
4874 /**
4875 * Triggered on <input> keypress.
4876 *
4877 */
4878 onKeyPress(e) {
4879 var self = this;
4880 if (self.isLocked) {
4881 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4882 return;
4883 }
4884 var character = String.fromCharCode(e.keyCode || e.which);
4885 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
4886 self.createItem();
4887 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4888 return;
4889 }
4890 }
4891 /**
4892 * Triggered on <input> keydown.
4893 *
4894 */
4895 onKeyDown(e) {
4896 var self = this;
4897 self.ignoreHover = true;
4898 if (self.isLocked) {
4899 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
4900 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4901 }
4902 return;
4903 }
4904 switch (e.keyCode) {
4905 // ctrl+A: select all
4906 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
4907 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
4908 if (self.control_input.value == '') {
4909 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4910 self.selectAll();
4911 return;
4912 }
4913 }
4914 break;
4915 // esc: close dropdown
4916 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
4917 if (self.isOpen) {
4918 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
4919 self.close();
4920 }
4921 self.clearActiveItems();
4922 return;
4923 // down: open dropdown or move selection down
4924 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
4925 if (!self.isOpen && self.hasOptions) {
4926 self.open();
4927 }
4928 else if (self.activeOption) {
4929 let next = self.getAdjacent(self.activeOption, 1);
4930 if (next)
4931 self.setActiveOption(next);
4932 }
4933 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4934 return;
4935 // up: move selection up
4936 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
4937 if (self.activeOption) {
4938 let prev = self.getAdjacent(self.activeOption, -1);
4939 if (prev)
4940 self.setActiveOption(prev);
4941 }
4942 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4943 return;
4944 // return: select active option
4945 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
4946 if (self.canSelect(self.activeOption)) {
4947 self.onOptionSelect(e, self.activeOption);
4948 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4949 // if the option_create=null, the dropdown might be closed
4950 }
4951 else if (self.settings.create && self.createItem()) {
4952 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4953 // don't submit form when searching for a value
4954 }
4955 else if (document.activeElement == self.control_input && self.isOpen) {
4956 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4957 }
4958 return;
4959 // left: modifiy item selection to the left
4960 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
4961 self.advanceSelection(-1, e);
4962 return;
4963 // right: modifiy item selection to the right
4964 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
4965 self.advanceSelection(1, e);
4966 return;
4967 // tab: select active option and/or create item
4968 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
4969 if (self.settings.selectOnTab) {
4970 if (self.canSelect(self.activeOption)) {
4971 self.onOptionSelect(e, self.activeOption);
4972 // prevent default [tab] behaviour of jump to the next field
4973 // if select isFull, then the dropdown won't be open and [tab] will work normally
4974 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4975 }
4976 if (self.settings.create && self.createItem()) {
4977 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4978 }
4979 }
4980 return;
4981 // delete|backspace: delete items
4982 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
4983 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
4984 self.deleteSelection(e);
4985 return;
4986 }
4987 // don't enter text in the control_input when active items are selected
4988 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
4989 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
4990 }
4991 }
4992 /**
4993 * Triggered on <input> keyup.
4994 *
4995 */
4996 onInput(e) {
4997 if (this.isLocked) {
4998 return;
4999 }
5000 const value = this.inputValue();
5001 if (this.lastValue === value)
5002 return;
5003 this.lastValue = value;
5004 if (value == '') {
5005 this._onInput();
5006 return;
5007 }
5008 if (this.refreshTimeout) {
5009 window.clearTimeout(this.refreshTimeout);
5010 }
5011 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
5012 this.refreshTimeout = null;
5013 this._onInput();
5014 }, this.settings.refreshThrottle);
5015 }
5016 _onInput() {
5017 const value = this.lastValue;
5018 if (this.settings.shouldLoad.call(this, value)) {
5019 this.load(value);
5020 }
5021 this.refreshOptions();
5022 this.trigger('type', value);
5023 }
5024 /**
5025 * Triggered when the user rolls over
5026 * an option in the autocomplete dropdown menu.
5027 *
5028 */
5029 onOptionHover(evt, option) {
5030 if (this.ignoreHover)
5031 return;
5032 this.setActiveOption(option, false);
5033 }
5034 /**
5035 * Triggered on <input> focus.
5036 *
5037 */
5038 onFocus(e) {
5039 var self = this;
5040 var wasFocused = self.isFocused;
5041 if (self.isDisabled || self.isReadOnly) {
5042 self.blur();
5043 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5044 return;
5045 }
5046 if (self.ignoreFocus)
5047 return;
5048 self.isFocused = true;
5049 if (self.settings.preload === 'focus')
5050 self.preload();
5051 if (!wasFocused)
5052 self.trigger('focus');
5053 if (!self.activeItems.length) {
5054 self.inputState();
5055 self.refreshOptions(!!self.settings.openOnFocus);
5056 }
5057 self.refreshState();
5058 }
5059 /**
5060 * Triggered on <input> blur.
5061 *
5062 */
5063 onBlur(e) {
5064 if (document.hasFocus() === false)
5065 return;
5066 var self = this;
5067 if (!self.isFocused)
5068 return;
5069 self.isFocused = false;
5070 self.ignoreFocus = false;
5071 var deactivate = () => {
5072 self.close();
5073 self.setActiveItem();
5074 self.setCaret(self.items.length);
5075 self.trigger('blur');
5076 };
5077 if (self.settings.create && self.settings.createOnBlur) {
5078 self.createItem(null, deactivate);
5079 }
5080 else {
5081 deactivate();
5082 }
5083 }
5084 /**
5085 * Triggered when the user clicks on an option
5086 * in the autocomplete dropdown menu.
5087 *
5088 */
5089 onOptionSelect(evt, option) {
5090 var value, self = this;
5091 // should not be possible to trigger a option under a disabled optgroup
5092 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
5093 return;
5094 }
5095 if (option.classList.contains('create')) {
5096 self.createItem(null, () => {
5097 if (self.settings.closeAfterSelect) {
5098 self.close();
5099 }
5100 });
5101 }
5102 else {
5103 value = option.dataset.value;
5104 if (typeof value !== 'undefined') {
5105 self.lastQuery = null;
5106 self.addItem(value);
5107 if (self.settings.closeAfterSelect) {
5108 self.close();
5109 }
5110 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
5111 self.setActiveOption(option);
5112 }
5113 }
5114 }
5115 }
5116 /**
5117 * Return true if the given option can be selected
5118 *
5119 */
5120 canSelect(option) {
5121 if (this.isOpen && option && this.dropdown_content.contains(option)) {
5122 return true;
5123 }
5124 return false;
5125 }
5126 /**
5127 * Triggered when the user clicks on an item
5128 * that has been selected.
5129 *
5130 */
5131 onItemSelect(evt, item) {
5132 var self = this;
5133 if (!self.isLocked && self.settings.mode === 'multi') {
5134 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
5135 self.setActiveItem(item, evt);
5136 return true;
5137 }
5138 return false;
5139 }
5140 /**
5141 * Determines whether or not to invoke
5142 * the user-provided option provider / loader
5143 *
5144 * Note, there is a subtle difference between
5145 * this.canLoad() and this.settings.shouldLoad();
5146 *
5147 * - settings.shouldLoad() is a user-input validator.
5148 * When false is returned, the not_loading template
5149 * will be added to the dropdown
5150 *
5151 * - canLoad() is lower level validator that checks
5152 * the Tom Select instance. There is no inherent user
5153 * feedback when canLoad returns false
5154 *
5155 */
5156 canLoad(value) {
5157 if (!this.settings.load)
5158 return false;
5159 if (this.loadedSearches.hasOwnProperty(value))
5160 return false;
5161 return true;
5162 }
5163 /**
5164 * Invokes the user-provided option provider / loader.
5165 *
5166 */
5167 load(value) {
5168 const self = this;
5169 if (!self.canLoad(value))
5170 return;
5171 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
5172 self.loading++;
5173 const callback = self.loadCallback.bind(self);
5174 self.settings.load.call(self, value, callback);
5175 }
5176 /**
5177 * Invoked by the user-provided option provider
5178 *
5179 */
5180 loadCallback(options, optgroups) {
5181 const self = this;
5182 self.loading = Math.max(self.loading - 1, 0);
5183 self.lastQuery = null;
5184 self.clearActiveOption(); // when new results load, focus should be on first option
5185 self.setupOptions(options, optgroups);
5186 self.refreshOptions(self.isFocused && !self.isInputHidden);
5187 if (!self.loading) {
5188 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
5189 }
5190 self.trigger('load', options, optgroups);
5191 }
5192 preload() {
5193 var classList = this.wrapper.classList;
5194 if (classList.contains('preloaded'))
5195 return;
5196 classList.add('preloaded');
5197 this.load('');
5198 }
5199 /**
5200 * Sets the input field of the control to the specified value.
5201 *
5202 */
5203 setTextboxValue(value = '') {
5204 var input = this.control_input;
5205 var changed = input.value !== value;
5206 if (changed) {
5207 input.value = value;
5208 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
5209 this.lastValue = value;
5210 }
5211 }
5212 /**
5213 * Returns the value of the control. If multiple items
5214 * can be selected (e.g. <select multiple>), this returns
5215 * an array. If only one item can be selected, this
5216 * returns a string.
5217 *
5218 */
5219 getValue() {
5220 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
5221 return this.items;
5222 }
5223 return this.items.join(this.settings.delimiter);
5224 }
5225 /**
5226 * Resets the selected items to the given value.
5227 *
5228 */
5229 setValue(value, silent) {
5230 var events = silent ? [] : ['change'];
5231 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
5232 this.clear(silent);
5233 this.addItems(value, silent);
5234 });
5235 }
5236 /**
5237 * Resets the number of max items to the given value
5238 *
5239 */
5240 setMaxItems(value) {
5241 if (value === 0)
5242 value = null; //reset to unlimited items.
5243 this.settings.maxItems = value;
5244 this.refreshState();
5245 }
5246 /**
5247 * Sets the selected item.
5248 *
5249 */
5250 setActiveItem(item, e) {
5251 var self = this;
5252 var eventName;
5253 var i, begin, end, swap;
5254 var last;
5255 if (self.settings.mode === 'single')
5256 return;
5257 // clear the active selection
5258 if (!item) {
5259 self.clearActiveItems();
5260 if (self.isFocused) {
5261 self.inputState();
5262 }
5263 return;
5264 }
5265 // modify selection
5266 eventName = e && e.type.toLowerCase();
5267 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
5268 last = self.getLastActive();
5269 begin = Array.prototype.indexOf.call(self.control.children, last);
5270 end = Array.prototype.indexOf.call(self.control.children, item);
5271 if (begin > end) {
5272 swap = begin;
5273 begin = end;
5274 end = swap;
5275 }
5276 for (i = begin; i <= end; i++) {
5277 item = self.control.children[i];
5278 if (self.activeItems.indexOf(item) === -1) {
5279 self.setActiveItemClass(item);
5280 }
5281 }
5282 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
5283 }
5284 else if ((eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) || (eventName === 'keydown' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e))) {
5285 if (item.classList.contains('active')) {
5286 self.removeActiveItem(item);
5287 }
5288 else {
5289 self.setActiveItemClass(item);
5290 }
5291 }
5292 else {
5293 self.clearActiveItems();
5294 self.setActiveItemClass(item);
5295 }
5296 // ensure control has focus
5297 self.inputState();
5298 if (!self.isFocused) {
5299 self.focus();
5300 }
5301 }
5302 /**
5303 * Set the active and last-active classes
5304 *
5305 */
5306 setActiveItemClass(item) {
5307 const self = this;
5308 const last_active = self.control.querySelector('.last-active');
5309 if (last_active)
5310 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
5311 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
5312 self.trigger('item_select', item);
5313 if (self.activeItems.indexOf(item) == -1) {
5314 self.activeItems.push(item);
5315 }
5316 }
5317 /**
5318 * Remove active item
5319 *
5320 */
5321 removeActiveItem(item) {
5322 var idx = this.activeItems.indexOf(item);
5323 this.activeItems.splice(idx, 1);
5324 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
5325 }
5326 /**
5327 * Clears all the active items
5328 *
5329 */
5330 clearActiveItems() {
5331 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
5332 this.activeItems = [];
5333 }
5334 /**
5335 * Sets the selected item in the dropdown menu
5336 * of available options.
5337 *
5338 */
5339 setActiveOption(option, scroll = true) {
5340 if (option === this.activeOption) {
5341 return;
5342 }
5343 this.clearActiveOption();
5344 if (!option)
5345 return;
5346 this.activeOption = option;
5347 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
5348 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
5349 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
5350 if (scroll)
5351 this.scrollToOption(option);
5352 }
5353 /**
5354 * Sets the dropdown_content scrollTop to display the option
5355 *
5356 */
5357 scrollToOption(option, behavior) {
5358 if (!option)
5359 return;
5360 const content = this.dropdown_content;
5361 const height_menu = content.clientHeight;
5362 const scrollTop = content.scrollTop || 0;
5363 const height_item = option.offsetHeight;
5364 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
5365 if (y + height_item > height_menu + scrollTop) {
5366 this.scroll(y - height_menu + height_item, behavior);
5367 }
5368 else if (y < scrollTop) {
5369 this.scroll(y, behavior);
5370 }
5371 }
5372 /**
5373 * Scroll the dropdown to the given position
5374 *
5375 */
5376 scroll(scrollTop, behavior) {
5377 const content = this.dropdown_content;
5378 if (behavior) {
5379 content.style.scrollBehavior = behavior;
5380 }
5381 content.scrollTop = scrollTop;
5382 content.style.scrollBehavior = '';
5383 }
5384 /**
5385 * Clears the active option
5386 *
5387 */
5388 clearActiveOption() {
5389 if (this.activeOption) {
5390 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
5391 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
5392 }
5393 this.activeOption = null;
5394 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
5395 }
5396 /**
5397 * Selects all items (CTRL + A).
5398 */
5399 selectAll() {
5400 const self = this;
5401 if (self.settings.mode === 'single')
5402 return;
5403 const activeItems = self.controlChildren();
5404 if (!activeItems.length)
5405 return;
5406 self.inputState();
5407 self.close();
5408 self.activeItems = activeItems;
5409 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
5410 self.setActiveItemClass(item);
5411 });
5412 }
5413 /**
5414 * Determines if the control_input should be in a hidden or visible state
5415 *
5416 */
5417 inputState() {
5418 var self = this;
5419 if (!self.control.contains(self.control_input))
5420 return;
5421 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
5422 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
5423 self.setTextboxValue();
5424 self.isInputHidden = true;
5425 }
5426 else {
5427 if (self.settings.hidePlaceholder && self.items.length > 0) {
5428 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
5429 }
5430 self.isInputHidden = false;
5431 }
5432 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
5433 }
5434 /**
5435 * Get the input value
5436 */
5437 inputValue() {
5438 return this.control_input.value.trim();
5439 }
5440 /**
5441 * Gives the control focus.
5442 */
5443 focus() {
5444 var self = this;
5445 if (self.isDisabled || self.isReadOnly)
5446 return;
5447 self.ignoreFocus = true;
5448 if (self.control_input.offsetWidth) {
5449 self.control_input.focus();
5450 }
5451 else {
5452 self.focus_node.focus();
5453 }
5454 setTimeout(() => {
5455 self.ignoreFocus = false;
5456 self.onFocus();
5457 }, 0);
5458 }
5459 /**
5460 * Forces the control out of focus.
5461 *
5462 */
5463 blur() {
5464 this.focus_node.blur();
5465 this.onBlur();
5466 }
5467 /**
5468 * Returns a function that scores an object
5469 * to show how good of a match it is to the
5470 * provided query.
5471 *
5472 * @return {function}
5473 */
5474 getScoreFunction(query) {
5475 return this.sifter.getScoreFunction(query, this.getSearchOptions());
5476 }
5477 /**
5478 * Returns search options for sifter (the system
5479 * for scoring and sorting results).
5480 *
5481 * @see https://github.com/orchidjs/sifter.js
5482 * @return {object}
5483 */
5484 getSearchOptions() {
5485 var settings = this.settings;
5486 var sort = settings.sortField;
5487 if (typeof settings.sortField === 'string') {
5488 sort = [{ field: settings.sortField }];
5489 }
5490 return {
5491 fields: settings.searchField,
5492 conjunction: settings.searchConjunction,
5493 sort: sort,
5494 nesting: settings.nesting
5495 };
5496 }
5497 /**
5498 * Searches through available options and returns
5499 * a sorted array of matches.
5500 *
5501 */
5502 search(query) {
5503 var result, calculateScore;
5504 var self = this;
5505 var options = this.getSearchOptions();
5506 // validate user-provided result scoring function
5507 if (self.settings.score) {
5508 calculateScore = self.settings.score.call(self, query);
5509 if (typeof calculateScore !== 'function') {
5510 throw new Error('Tom Select "score" setting must be a function that returns a function');
5511 }
5512 }
5513 // perform search
5514 if (query !== self.lastQuery) {
5515 self.lastQuery = query;
5516 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
5517 self.currentResults = result;
5518 }
5519 else {
5520 result = Object.assign({}, self.currentResults);
5521 }
5522 // filter out selected items
5523 if (self.settings.hideSelected) {
5524 result.items = result.items.filter((item) => {
5525 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
5526 return !(hashed && self.items.indexOf(hashed) !== -1);
5527 });
5528 }
5529 return result;
5530 }
5531 /**
5532 * Refreshes the list of available options shown
5533 * in the autocomplete dropdown menu.
5534 *
5535 */
5536 refreshOptions(triggerDropdown = true) {
5537 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
5538 var create;
5539 const groups = {};
5540 const groups_order = [];
5541 var self = this;
5542 var query = self.inputValue();
5543 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
5544 var results = self.search(query);
5545 var active_option = null;
5546 var show_dropdown = self.settings.shouldOpen || false;
5547 var dropdown_content = self.dropdown_content;
5548 if (same_query) {
5549 active_option = self.activeOption;
5550 if (active_option) {
5551 active_group = active_option.closest('[data-group]');
5552 }
5553 }
5554 // build markup
5555 n = results.items.length;
5556 if (typeof self.settings.maxOptions === 'number') {
5557 n = Math.min(n, self.settings.maxOptions);
5558 }
5559 if (n > 0) {
5560 show_dropdown = true;
5561 }
5562 // get fragment for group and the position of the group in group_order
5563 const getGroupFragment = (optgroup, order) => {
5564 let group_order_i = groups[optgroup];
5565 if (group_order_i !== undefined) {
5566 let order_group = groups_order[group_order_i];
5567 if (order_group !== undefined) {
5568 return [group_order_i, order_group.fragment];
5569 }
5570 }
5571 let group_fragment = document.createDocumentFragment();
5572 group_order_i = groups_order.length;
5573 groups_order.push({ fragment: group_fragment, order, optgroup });
5574 return [group_order_i, group_fragment];
5575 };
5576 // render and group available options individually
5577 for (i = 0; i < n; i++) {
5578 // get option dom element
5579 let item = results.items[i];
5580 if (!item)
5581 continue;
5582 let opt_value = item.id;
5583 let option = self.options[opt_value];
5584 if (option === undefined)
5585 continue;
5586 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
5587 let option_el = self.getOption(opt_hash, true);
5588 // toggle 'selected' class
5589 if (!self.settings.hideSelected) {
5590 option_el.classList.toggle('selected', self.items.includes(opt_hash));
5591 }
5592 optgroup = option[self.settings.optgroupField] || '';
5593 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
5594 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
5595 optgroup = optgroups[j];
5596 let order = option.$order;
5597 let self_optgroup = self.optgroups[optgroup];
5598 if (self_optgroup === undefined) {
5599 optgroup = '';
5600 }
5601 else {
5602 order = self_optgroup.$order;
5603 }
5604 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
5605 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
5606 if (j > 0) {
5607 option_el = option_el.cloneNode(true);
5608 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
5609 option_el.classList.add('ts-cloned');
5610 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
5611 // make sure we keep the activeOption in the same group
5612 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
5613 if (active_group && active_group.dataset.group === optgroup.toString()) {
5614 active_option = option_el;
5615 }
5616 }
5617 }
5618 group_fragment.appendChild(option_el);
5619 if (optgroup != '') {
5620 groups[optgroup] = group_order_i;
5621 }
5622 }
5623 }
5624 // sort optgroups
5625 if (self.settings.lockOptgroupOrder) {
5626 groups_order.sort((a, b) => {
5627 return a.order - b.order;
5628 });
5629 }
5630 // render optgroup headers & join groups
5631 html = document.createDocumentFragment();
5632 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
5633 let group_fragment = group_order.fragment;
5634 let optgroup = group_order.optgroup;
5635 if (!group_fragment || !group_fragment.children.length)
5636 return;
5637 let group_heading = self.optgroups[optgroup];
5638 if (group_heading !== undefined) {
5639 let group_options = document.createDocumentFragment();
5640 let header = self.render('optgroup_header', group_heading);
5641 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
5642 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
5643 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
5644 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
5645 }
5646 else {
5647 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
5648 }
5649 });
5650 dropdown_content.innerHTML = '';
5651 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
5652 // highlight matching terms inline
5653 if (self.settings.highlight) {
5654 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
5655 if (results.query.length && results.tokens.length) {
5656 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
5657 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
5658 });
5659 }
5660 }
5661 // helper method for adding templates to dropdown
5662 var add_template = (template) => {
5663 let content = self.render(template, { input: query });
5664 if (content) {
5665 show_dropdown = true;
5666 dropdown_content.insertBefore(content, dropdown_content.firstChild);
5667 }
5668 return content;
5669 };
5670 // add loading message
5671 if (self.loading) {
5672 add_template('loading');
5673 // invalid query
5674 }
5675 else if (!self.settings.shouldLoad.call(self, query)) {
5676 add_template('not_loading');
5677 // add no_results message
5678 }
5679 else if (results.items.length === 0) {
5680 add_template('no_results');
5681 }
5682 // add create option
5683 has_create_option = self.canCreate(query);
5684 if (has_create_option) {
5685 create = add_template('option_create');
5686 }
5687 // activate
5688 self.hasOptions = results.items.length > 0 || has_create_option;
5689 if (show_dropdown) {
5690 if (results.items.length > 0) {
5691 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
5692 active_option = self.getOption(self.items[0]);
5693 }
5694 if (!dropdown_content.contains(active_option)) {
5695 let active_index = 0;
5696 if (create && !self.settings.addPrecedence) {
5697 active_index = 1;
5698 }
5699 active_option = self.selectable()[active_index];
5700 }
5701 }
5702 else if (create) {
5703 active_option = create;
5704 }
5705 if (triggerDropdown && !self.isOpen) {
5706 self.open();
5707 self.scrollToOption(active_option, 'auto');
5708 }
5709 self.setActiveOption(active_option);
5710 }
5711 else {
5712 self.clearActiveOption();
5713 if (triggerDropdown && self.isOpen) {
5714 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
5715 }
5716 }
5717 }
5718 /**
5719 * Return list of selectable options
5720 *
5721 */
5722 selectable() {
5723 return this.dropdown_content.querySelectorAll('[data-selectable]');
5724 }
5725 /**
5726 * Adds an available option. If it already exists,
5727 * nothing will happen. Note: this does not refresh
5728 * the options list dropdown (use `refreshOptions`
5729 * for that).
5730 *
5731 * Usage:
5732 *
5733 * this.addOption(data)
5734 *
5735 */
5736 addOption(data, user_created = false) {
5737 const self = this;
5738 // @deprecated 1.7.7
5739 // use addOptions( array, user_created ) for adding multiple options
5740 if (Array.isArray(data)) {
5741 self.addOptions(data, user_created);
5742 return false;
5743 }
5744 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
5745 if (key === null || self.options.hasOwnProperty(key)) {
5746 return false;
5747 }
5748 data.$order = data.$order || ++self.order;
5749 data.$id = self.inputId + '-opt-' + data.$order;
5750 self.options[key] = data;
5751 self.lastQuery = null;
5752 if (user_created) {
5753 self.userOptions[key] = user_created;
5754 self.trigger('option_add', key, data);
5755 }
5756 return key;
5757 }
5758 /**
5759 * Add multiple options
5760 *
5761 */
5762 addOptions(data, user_created = false) {
5763 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
5764 this.addOption(dat, user_created);
5765 });
5766 }
5767 /**
5768 * @deprecated 1.7.7
5769 */
5770 registerOption(data) {
5771 return this.addOption(data);
5772 }
5773 /**
5774 * Registers an option group to the pool of option groups.
5775 *
5776 * @return {boolean|string}
5777 */
5778 registerOptionGroup(data) {
5779 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
5780 if (key === null)
5781 return false;
5782 data.$order = data.$order || ++this.order;
5783 this.optgroups[key] = data;
5784 return key;
5785 }
5786 /**
5787 * Registers a new optgroup for options
5788 * to be bucketed into.
5789 *
5790 */
5791 addOptionGroup(id, data) {
5792 var hashed_id;
5793 data[this.settings.optgroupValueField] = id;
5794 if (hashed_id = this.registerOptionGroup(data)) {
5795 this.trigger('optgroup_add', hashed_id, data);
5796 }
5797 }
5798 /**
5799 * Removes an existing option group.
5800 *
5801 */
5802 removeOptionGroup(id) {
5803 if (this.optgroups.hasOwnProperty(id)) {
5804 delete this.optgroups[id];
5805 this.clearCache();
5806 this.trigger('optgroup_remove', id);
5807 }
5808 }
5809 /**
5810 * Clears all existing option groups.
5811 */
5812 clearOptionGroups() {
5813 this.optgroups = {};
5814 this.clearCache();
5815 this.trigger('optgroup_clear');
5816 }
5817 /**
5818 * Updates an option available for selection. If
5819 * it is visible in the selected items or options
5820 * dropdown, it will be re-rendered automatically.
5821 *
5822 */
5823 updateOption(value, data) {
5824 const self = this;
5825 var item_new;
5826 var index_item;
5827 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
5828 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
5829 // sanity checks
5830 if (value_old === null)
5831 return;
5832 const data_old = self.options[value_old];
5833 if (data_old == undefined)
5834 return;
5835 if (typeof value_new !== 'string')
5836 throw new Error('Value must be set in option data');
5837 const option = self.getOption(value_old);
5838 const item = self.getItem(value_old);
5839 data.$order = data.$order || data_old.$order;
5840 delete self.options[value_old];
5841 // invalidate render cache
5842 // don't remove existing node yet, we'll remove it after replacing it
5843 self.uncacheValue(value_new);
5844 self.options[value_new] = data;
5845 // update the option if it's in the dropdown
5846 if (option) {
5847 if (self.dropdown_content.contains(option)) {
5848 const option_new = self._render('option', data);
5849 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
5850 if (self.activeOption === option) {
5851 self.setActiveOption(option_new);
5852 }
5853 }
5854 option.remove();
5855 }
5856 // update the item if we have one
5857 if (item) {
5858 index_item = self.items.indexOf(value_old);
5859 if (index_item !== -1) {
5860 self.items.splice(index_item, 1, value_new);
5861 }
5862 item_new = self._render('item', data);
5863 if (item.classList.contains('active'))
5864 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
5865 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
5866 }
5867 // invalidate last query because we might have updated the sortField
5868 self.lastQuery = null;
5869 }
5870 /**
5871 * Removes a single option.
5872 *
5873 */
5874 removeOption(value, silent) {
5875 const self = this;
5876 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
5877 self.uncacheValue(value);
5878 delete self.userOptions[value];
5879 delete self.options[value];
5880 self.lastQuery = null;
5881 self.trigger('option_remove', value);
5882 self.removeItem(value, silent);
5883 }
5884 /**
5885 * Clears all options.
5886 */
5887 clearOptions(filter) {
5888 const boundFilter = (filter || this.clearFilter).bind(this);
5889 this.loadedSearches = {};
5890 this.userOptions = {};
5891 this.clearCache();
5892 const selected = {};
5893 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
5894 if (boundFilter(option, key)) {
5895 selected[key] = option;
5896 }
5897 });
5898 this.options = this.sifter.items = selected;
5899 this.lastQuery = null;
5900 this.trigger('option_clear');
5901 }
5902 /**
5903 * Used by clearOptions() to decide whether or not an option should be removed
5904 * Return true to keep an option, false to remove
5905 *
5906 */
5907 clearFilter(option, value) {
5908 if (this.items.indexOf(value) >= 0) {
5909 return true;
5910 }
5911 return false;
5912 }
5913 /**
5914 * Returns the dom element of the option
5915 * matching the given value.
5916 *
5917 */
5918 getOption(value, create = false) {
5919 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
5920 if (hashed === null)
5921 return null;
5922 const option = this.options[hashed];
5923 if (option != undefined) {
5924 if (option.$div) {
5925 return option.$div;
5926 }
5927 if (create) {
5928 return this._render('option', option);
5929 }
5930 }
5931 return null;
5932 }
5933 /**
5934 * Returns the dom element of the next or previous dom element of the same type
5935 * Note: adjacent options may not be adjacent DOM elements (optgroups)
5936 *
5937 */
5938 getAdjacent(option, direction, type = 'option') {
5939 var self = this, all;
5940 if (!option) {
5941 return null;
5942 }
5943 if (type == 'item') {
5944 all = self.controlChildren();
5945 }
5946 else {
5947 all = self.dropdown_content.querySelectorAll('[data-selectable]');
5948 }
5949 for (let i = 0; i < all.length; i++) {
5950 if (all[i] != option) {
5951 continue;
5952 }
5953 if (direction > 0) {
5954 return all[i + 1];
5955 }
5956 return all[i - 1];
5957 }
5958 return null;
5959 }
5960 /**
5961 * Returns the dom element of the item
5962 * matching the given value.
5963 *
5964 */
5965 getItem(item) {
5966 if (typeof item == 'object') {
5967 return item;
5968 }
5969 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
5970 return value !== null
5971 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
5972 : null;
5973 }
5974 /**
5975 * "Selects" multiple items at once. Adds them to the list
5976 * at the current caret position.
5977 *
5978 */
5979 addItems(values, silent) {
5980 var self = this;
5981 var items = Array.isArray(values) ? values : [values];
5982 items = items.filter(x => self.items.indexOf(x) === -1);
5983 const last_item = items[items.length - 1];
5984 items.forEach(item => {
5985 self.isPending = (item !== last_item);
5986 self.addItem(item, silent);
5987 });
5988 }
5989 /**
5990 * "Selects" an item. Adds it to the list
5991 * at the current caret position.
5992 *
5993 */
5994 addItem(value, silent) {
5995 var events = silent ? [] : ['change', 'dropdown_close'];
5996 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
5997 var item, wasFull;
5998 const self = this;
5999 const inputMode = self.settings.mode;
6000 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
6001 if (hashed && self.items.indexOf(hashed) !== -1) {
6002 if (inputMode === 'single') {
6003 self.close();
6004 }
6005 if (inputMode === 'single' || !self.settings.duplicates) {
6006 return;
6007 }
6008 }
6009 if (hashed === null || !self.options.hasOwnProperty(hashed))
6010 return;
6011 if (inputMode === 'single')
6012 self.clear(silent);
6013 if (inputMode === 'multi' && self.isFull())
6014 return;
6015 item = self._render('item', self.options[hashed]);
6016 if (self.control.contains(item)) { // duplicates
6017 item = item.cloneNode(true);
6018 }
6019 wasFull = self.isFull();
6020 self.items.splice(self.caretPos, 0, hashed);
6021 self.insertAtCaret(item);
6022 if (self.isSetup) {
6023 // update menu / remove the option (if this is not one item being added as part of series)
6024 if (!self.isPending && self.settings.hideSelected) {
6025 let option = self.getOption(hashed);
6026 let next = self.getAdjacent(option, 1);
6027 if (next) {
6028 self.setActiveOption(next);
6029 }
6030 }
6031 // refreshOptions after setActiveOption(),
6032 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
6033 if (!self.isPending && !self.settings.closeAfterSelect) {
6034 self.refreshOptions(self.isFocused && inputMode !== 'single');
6035 }
6036 // hide the menu if the maximum number of items have been selected or no options are left
6037 if (self.settings.closeAfterSelect != false && self.isFull()) {
6038 self.close();
6039 }
6040 else if (!self.isPending) {
6041 self.positionDropdown();
6042 }
6043 self.trigger('item_add', hashed, item);
6044 if (!self.isPending) {
6045 self.updateOriginalInput({ silent: silent });
6046 }
6047 }
6048 if (!self.isPending || (!wasFull && self.isFull())) {
6049 self.inputState();
6050 self.refreshState();
6051 }
6052 });
6053 }
6054 /**
6055 * Removes the selected item matching
6056 * the provided value.
6057 *
6058 */
6059 removeItem(item = null, silent) {
6060 const self = this;
6061 item = self.getItem(item);
6062 if (!item)
6063 return;
6064 var i, idx;
6065 const value = item.dataset.value;
6066 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
6067 item.remove();
6068 if (item.classList.contains('active')) {
6069 idx = self.activeItems.indexOf(item);
6070 self.activeItems.splice(idx, 1);
6071 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
6072 }
6073 self.items.splice(i, 1);
6074 self.lastQuery = null;
6075 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
6076 self.removeOption(value, silent);
6077 }
6078 if (i < self.caretPos) {
6079 self.setCaret(self.caretPos - 1);
6080 }
6081 self.updateOriginalInput({ silent: silent });
6082 self.refreshState();
6083 self.positionDropdown();
6084 self.trigger('item_remove', value, item);
6085 }
6086 /**
6087 * Invokes the `create` method provided in the
6088 * TomSelect options that should provide the data
6089 * for the new item, given the user input.
6090 *
6091 * Once this completes, it will be added
6092 * to the item list.
6093 *
6094 */
6095 createItem(input = null, callback = () => { }) {
6096 // triggerDropdown parameter @deprecated 2.1.1
6097 if (arguments.length === 3) {
6098 callback = arguments[2];
6099 }
6100 if (typeof callback != 'function') {
6101 callback = () => { };
6102 }
6103 var self = this;
6104 var caret = self.caretPos;
6105 var output;
6106 input = input || self.inputValue();
6107 if (!self.canCreate(input)) {
6108 callback();
6109 return false;
6110 }
6111 self.lock();
6112 var created = false;
6113 var create = (data) => {
6114 self.unlock();
6115 if (!data || typeof data !== 'object')
6116 return callback();
6117 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
6118 if (typeof value !== 'string') {
6119 return callback();
6120 }
6121 self.setTextboxValue();
6122 self.addOption(data, true);
6123 self.setCaret(caret);
6124 self.addItem(value);
6125 callback(data);
6126 created = true;
6127 };
6128 if (typeof self.settings.create === 'function') {
6129 output = self.settings.create.call(this, input, create);
6130 }
6131 else {
6132 output = {
6133 [self.settings.labelField]: input,
6134 [self.settings.valueField]: input,
6135 };
6136 }
6137 if (!created) {
6138 create(output);
6139 }
6140 return true;
6141 }
6142 /**
6143 * Re-renders the selected item lists.
6144 */
6145 refreshItems() {
6146 var self = this;
6147 self.lastQuery = null;
6148 if (self.isSetup) {
6149 self.addItems(self.items);
6150 }
6151 self.updateOriginalInput();
6152 self.refreshState();
6153 }
6154 /**
6155 * Updates all state-dependent attributes
6156 * and CSS classes.
6157 */
6158 refreshState() {
6159 const self = this;
6160 self.refreshValidityState();
6161 const isFull = self.isFull();
6162 const isLocked = self.isLocked;
6163 self.wrapper.classList.toggle('rtl', self.rtl);
6164 const wrap_classList = self.wrapper.classList;
6165 wrap_classList.toggle('focus', self.isFocused);
6166 wrap_classList.toggle('disabled', self.isDisabled);
6167 wrap_classList.toggle('readonly', self.isReadOnly);
6168 wrap_classList.toggle('required', self.isRequired);
6169 wrap_classList.toggle('invalid', !self.isValid);
6170 wrap_classList.toggle('locked', isLocked);
6171 wrap_classList.toggle('full', isFull);
6172 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
6173 wrap_classList.toggle('dropdown-active', self.isOpen);
6174 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
6175 wrap_classList.toggle('has-items', self.items.length > 0);
6176 }
6177 /**
6178 * Update the `required` attribute of both input and control input.
6179 *
6180 * The `required` property needs to be activated on the control input
6181 * for the error to be displayed at the right place. `required` also
6182 * needs to be temporarily deactivated on the input since the input is
6183 * hidden and can't show errors.
6184 */
6185 refreshValidityState() {
6186 var self = this;
6187 if (!self.input.validity) {
6188 return;
6189 }
6190 self.isValid = self.input.validity.valid;
6191 self.isInvalid = !self.isValid;
6192 }
6193 /**
6194 * Determines whether or not more items can be added
6195 * to the control without exceeding the user-defined maximum.
6196 *
6197 * @returns {boolean}
6198 */
6199 isFull() {
6200 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
6201 }
6202 /**
6203 * Refreshes the original <select> or <input>
6204 * element to reflect the current state.
6205 *
6206 */
6207 updateOriginalInput(opts = {}) {
6208 const self = this;
6209 var option, label;
6210 const empty_option = self.input.querySelector('option[value=""]');
6211 if (self.is_select_tag) {
6212 const selected = [];
6213 const has_selected = self.input.querySelectorAll('option:checked').length;
6214 function AddSelected(option_el, value, label) {
6215 if (!option_el) {
6216 option_el = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<option value="' + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html)(value) + '">' + (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html)(label) + '</option>');
6217 }
6218 // don't move empty option from top of list
6219 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
6220 if (option_el != empty_option) {
6221 self.input.append(option_el);
6222 }
6223 selected.push(option_el);
6224 // marking empty option as selected can break validation
6225 // fixes https://github.com/orchidjs/tom-select/issues/303
6226 if (option_el != empty_option || has_selected > 0) {
6227 option_el.selected = true;
6228 }
6229 return option_el;
6230 }
6231 // unselect all selected options
6232 self.input.querySelectorAll('option:checked').forEach((option_el) => {
6233 option_el.selected = false;
6234 });
6235 // nothing selected?
6236 if (self.items.length == 0 && self.settings.mode == 'single') {
6237 AddSelected(empty_option, "", "");
6238 // order selected <option> tags for values in self.items
6239 }
6240 else {
6241 self.items.forEach((value) => {
6242 option = self.options[value];
6243 label = option[self.settings.labelField] || '';
6244 if (selected.includes(option.$option)) {
6245 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
6246 AddSelected(reuse_opt, value, label);
6247 }
6248 else {
6249 option.$option = AddSelected(option.$option, value, label);
6250 }
6251 });
6252 }
6253 }
6254 else {
6255 self.input.value = self.getValue();
6256 }
6257 if (self.isSetup) {
6258 if (!opts.silent) {
6259 self.trigger('change', self.getValue());
6260 }
6261 }
6262 }
6263 /**
6264 * Shows the autocomplete dropdown containing
6265 * the available options.
6266 */
6267 open() {
6268 var self = this;
6269 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
6270 return;
6271 self.isOpen = true;
6272 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
6273 self.refreshState();
6274 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
6275 self.positionDropdown();
6276 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
6277 self.focus();
6278 self.trigger('dropdown_open', self.dropdown);
6279 }
6280 /**
6281 * Closes the autocomplete dropdown menu.
6282 */
6283 close(setTextboxValue = true) {
6284 var self = this;
6285 var trigger = self.isOpen;
6286 if (setTextboxValue) {
6287 // before blur() to prevent form onchange event
6288 self.setTextboxValue();
6289 if (self.settings.mode === 'single' && self.items.length) {
6290 self.inputState();
6291 }
6292 }
6293 self.isOpen = false;
6294 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
6295 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
6296 if (self.settings.hideSelected) {
6297 self.clearActiveOption();
6298 }
6299 self.refreshState();
6300 if (trigger)
6301 self.trigger('dropdown_close', self.dropdown);
6302 }
6303 /**
6304 * Calculates and applies the appropriate
6305 * position of the dropdown if dropdownParent = 'body'.
6306 * Otherwise, position is determined by css
6307 */
6308 positionDropdown() {
6309 if (this.settings.dropdownParent !== 'body') {
6310 return;
6311 }
6312 var context = this.control;
6313 var rect = context.getBoundingClientRect();
6314 var top = context.offsetHeight + rect.top + window.scrollY;
6315 var left = rect.left + window.scrollX;
6316 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
6317 width: rect.width + 'px',
6318 top: top + 'px',
6319 left: left + 'px'
6320 });
6321 }
6322 /**
6323 * Resets / clears all selected items
6324 * from the control.
6325 *
6326 */
6327 clear(silent) {
6328 var self = this;
6329 if (!self.items.length)
6330 return;
6331 var items = self.controlChildren();
6332 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
6333 self.removeItem(item, true);
6334 });
6335 self.inputState();
6336 if (!silent)
6337 self.updateOriginalInput();
6338 self.trigger('clear');
6339 }
6340 /**
6341 * A helper method for inserting an element
6342 * at the current caret position.
6343 *
6344 */
6345 insertAtCaret(el) {
6346 const self = this;
6347 const caret = self.caretPos;
6348 const target = self.control;
6349 target.insertBefore(el, target.children[caret] || null);
6350 self.setCaret(caret + 1);
6351 }
6352 /**
6353 * Removes the current selected item(s).
6354 *
6355 */
6356 deleteSelection(e) {
6357 var direction, selection, caret, tail;
6358 var self = this;
6359 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
6360 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
6361 // determine items that will be removed
6362 const rm_items = [];
6363 if (self.activeItems.length) {
6364 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
6365 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
6366 if (direction > 0) {
6367 caret++;
6368 }
6369 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
6370 }
6371 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
6372 const items = self.controlChildren();
6373 let rm_item;
6374 if (direction < 0 && selection.start === 0 && selection.length === 0) {
6375 rm_item = items[self.caretPos - 1];
6376 }
6377 else if (direction > 0 && selection.start === self.inputValue().length) {
6378 rm_item = items[self.caretPos];
6379 }
6380 if (rm_item !== undefined) {
6381 rm_items.push(rm_item);
6382 }
6383 }
6384 if (!self.shouldDelete(rm_items, e)) {
6385 return false;
6386 }
6387 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
6388 // perform removal
6389 if (typeof caret !== 'undefined') {
6390 self.setCaret(caret);
6391 }
6392 while (rm_items.length) {
6393 self.removeItem(rm_items.pop());
6394 }
6395 self.inputState();
6396 self.positionDropdown();
6397 self.refreshOptions(false);
6398 return true;
6399 }
6400 /**
6401 * Return true if the items should be deleted
6402 */
6403 shouldDelete(items, evt) {
6404 const values = items.map(item => item.dataset.value);
6405 // allow the callback to abort
6406 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
6407 return false;
6408 }
6409 return true;
6410 }
6411 /**
6412 * Selects the previous / next item (depending on the `direction` argument).
6413 *
6414 * > 0 - right
6415 * < 0 - left
6416 *
6417 */
6418 advanceSelection(direction, e) {
6419 var last_active, adjacent, self = this;
6420 if (self.rtl)
6421 direction *= -1;
6422 if (self.inputValue().length)
6423 return;
6424 // add or remove to active items
6425 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e) || (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e)) {
6426 last_active = self.getLastActive(direction);
6427 if (last_active) {
6428 if (!last_active.classList.contains('active')) {
6429 adjacent = last_active;
6430 }
6431 else {
6432 adjacent = self.getAdjacent(last_active, direction, 'item');
6433 }
6434 // if no active item, get items adjacent to the control input
6435 }
6436 else if (direction > 0) {
6437 adjacent = self.control_input.nextElementSibling;
6438 }
6439 else {
6440 adjacent = self.control_input.previousElementSibling;
6441 }
6442 if (adjacent) {
6443 if (adjacent.classList.contains('active')) {
6444 self.removeActiveItem(last_active);
6445 }
6446 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
6447 }
6448 // move caret to the left or right
6449 }
6450 else {
6451 self.moveCaret(direction);
6452 }
6453 }
6454 moveCaret(direction) { }
6455 /**
6456 * Get the last active item
6457 *
6458 */
6459 getLastActive(direction) {
6460 let last_active = this.control.querySelector('.last-active');
6461 if (last_active) {
6462 return last_active;
6463 }
6464 var result = this.control.querySelectorAll('.active');
6465 if (result) {
6466 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
6467 }
6468 }
6469 /**
6470 * Moves the caret to the specified index.
6471 *
6472 * The input must be moved by leaving it in place and moving the
6473 * siblings, due to the fact that focus cannot be restored once lost
6474 * on mobile webkit devices
6475 *
6476 */
6477 setCaret(new_pos) {
6478 this.caretPos = this.items.length;
6479 }
6480 /**
6481 * Return list of item dom elements
6482 *
6483 */
6484 controlChildren() {
6485 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
6486 }
6487 /**
6488 * Disables user input on the control. Used while
6489 * items are being asynchronously created.
6490 */
6491 lock() {
6492 this.setLocked(true);
6493 }
6494 /**
6495 * Re-enables user input on the control.
6496 */
6497 unlock() {
6498 this.setLocked(false);
6499 }
6500 /**
6501 * Disable or enable user input on the control
6502 */
6503 setLocked(lock = this.isReadOnly || this.isDisabled) {
6504 this.isLocked = lock;
6505 this.refreshState();
6506 }
6507 /**
6508 * Disables user input on the control completely.
6509 * While disabled, it cannot receive focus.
6510 */
6511 disable() {
6512 this.setDisabled(true);
6513 this.close();
6514 }
6515 /**
6516 * Enables the control so that it can respond
6517 * to focus and user input.
6518 */
6519 enable() {
6520 this.setDisabled(false);
6521 }
6522 setDisabled(disabled) {
6523 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
6524 this.isDisabled = disabled;
6525 this.input.disabled = disabled;
6526 this.control_input.disabled = disabled;
6527 this.setLocked();
6528 }
6529 setReadOnly(isReadOnly) {
6530 this.isReadOnly = isReadOnly;
6531 this.input.readOnly = isReadOnly;
6532 this.control_input.readOnly = isReadOnly;
6533 this.setLocked();
6534 }
6535 /**
6536 * Completely destroys the control and
6537 * unbinds all event listeners so that it can
6538 * be garbage collected.
6539 */
6540 destroy() {
6541 var self = this;
6542 var revertSettings = self.revertSettings;
6543 self.trigger('destroy');
6544 self.off();
6545 self.wrapper.remove();
6546 self.dropdown.remove();
6547 self.input.innerHTML = revertSettings.innerHTML;
6548 self.input.tabIndex = revertSettings.tabIndex;
6549 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
6550 self._destroy();
6551 delete self.input.tomselect;
6552 }
6553 /**
6554 * A helper method for rendering "item" and
6555 * "option" templates, given the data.
6556 *
6557 */
6558 render(templateName, data) {
6559 var id, html;
6560 const self = this;
6561 if (typeof this.settings.render[templateName] !== 'function') {
6562 return null;
6563 }
6564 // render markup
6565 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
6566 if (!html) {
6567 return null;
6568 }
6569 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
6570 // add mandatory attributes
6571 if (templateName === 'option' || templateName === 'option_create') {
6572 if (data[self.settings.disabledField]) {
6573 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
6574 }
6575 else {
6576 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
6577 }
6578 }
6579 else if (templateName === 'optgroup') {
6580 id = data.group[self.settings.optgroupValueField];
6581 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
6582 if (data.group[self.settings.disabledField]) {
6583 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
6584 }
6585 }
6586 if (templateName === 'option' || templateName === 'item') {
6587 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
6588 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
6589 // make sure we have some classes if a template is overwritten
6590 if (templateName === 'item') {
6591 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
6592 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
6593 }
6594 else {
6595 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
6596 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
6597 role: 'option',
6598 id: data.$id
6599 });
6600 // update cache
6601 data.$div = html;
6602 self.options[value] = data;
6603 }
6604 }
6605 return html;
6606 }
6607 /**
6608 * Type guarded rendering
6609 *
6610 */
6611 _render(templateName, data) {
6612 const html = this.render(templateName, data);
6613 if (html == null) {
6614 throw 'HTMLElement expected';
6615 }
6616 return html;
6617 }
6618 /**
6619 * Clears the render cache for a template. If
6620 * no template is given, clears all render
6621 * caches.
6622 *
6623 */
6624 clearCache() {
6625 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
6626 if (option.$div) {
6627 option.$div.remove();
6628 delete option.$div;
6629 }
6630 });
6631 }
6632 /**
6633 * Removes a value from item and option caches
6634 *
6635 */
6636 uncacheValue(value) {
6637 const option_el = this.getOption(value);
6638 if (option_el)
6639 option_el.remove();
6640 }
6641 /**
6642 * Determines whether or not to display the
6643 * create item prompt, given a user input.
6644 *
6645 */
6646 canCreate(input) {
6647 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
6648 }
6649 /**
6650 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
6651 *
6652 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
6653 *
6654 * });
6655 */
6656 hook(when, method, new_fn) {
6657 var self = this;
6658 var orig_method = self[method];
6659 self[method] = function () {
6660 var result, result_new;
6661 if (when === 'after') {
6662 result = orig_method.apply(self, arguments);
6663 }
6664 result_new = new_fn.apply(self, arguments);
6665 if (when === 'instead') {
6666 return result_new;
6667 }
6668 if (when === 'before') {
6669 result = orig_method.apply(self, arguments);
6670 }
6671 return result;
6672 };
6673 }
6674 }
6675 ;
6676 //# sourceMappingURL=tom-select.js.map
6677
6678 /***/ },
6679
6680 /***/ "./node_modules/tom-select/dist/esm/utils.js"
6681 /*!***************************************************!*\
6682 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
6683 \***************************************************/
6684 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
6685
6686 __webpack_require__.r(__webpack_exports__);
6687 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6688 /* harmony export */ addEvent: () => (/* binding */ addEvent),
6689 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
6690 /* harmony export */ append: () => (/* binding */ append),
6691 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
6692 /* harmony export */ escape_html: () => (/* binding */ escape_html),
6693 /* harmony export */ getId: () => (/* binding */ getId),
6694 /* harmony export */ getSelection: () => (/* binding */ getSelection),
6695 /* harmony export */ get_hash: () => (/* binding */ get_hash),
6696 /* harmony export */ hash_key: () => (/* binding */ hash_key),
6697 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
6698 /* harmony export */ iterate: () => (/* binding */ iterate),
6699 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
6700 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
6701 /* harmony export */ timeout: () => (/* binding */ timeout)
6702 /* harmony export */ });
6703 /**
6704 * Converts a scalar to its best string representation
6705 * for hash keys and HTML attribute values.
6706 *
6707 * Transformations:
6708 * 'str' -> 'str'
6709 * null -> ''
6710 * undefined -> ''
6711 * true -> '1'
6712 * false -> '0'
6713 * 0 -> '0'
6714 * 1 -> '1'
6715 *
6716 */
6717 const hash_key = (value) => {
6718 if (typeof value === 'undefined' || value === null)
6719 return null;
6720 return get_hash(value);
6721 };
6722 const get_hash = (value) => {
6723 if (typeof value === 'boolean')
6724 return value ? '1' : '0';
6725 return value + '';
6726 };
6727 /**
6728 * Escapes a string for use within HTML.
6729 *
6730 */
6731 const escape_html = (str) => {
6732 return (str + '')
6733 .replace(/&/g, '&amp;')
6734 .replace(/</g, '&lt;')
6735 .replace(/>/g, '&gt;')
6736 .replace(/"/g, '&quot;');
6737 };
6738 /**
6739 * use setTimeout if timeout > 0
6740 */
6741 const timeout = (fn, timeout) => {
6742 if (timeout > 0) {
6743 return window.setTimeout(fn, timeout);
6744 }
6745 fn.call(null);
6746 return null;
6747 };
6748 /**
6749 * Debounce the user provided load function
6750 *
6751 */
6752 const loadDebounce = (fn, delay) => {
6753 var timeout;
6754 return function (value, callback) {
6755 var self = this;
6756 if (timeout) {
6757 self.loading = Math.max(self.loading - 1, 0);
6758 clearTimeout(timeout);
6759 }
6760 timeout = setTimeout(function () {
6761 timeout = null;
6762 self.loadedSearches[value] = true;
6763 fn.call(self, value, callback);
6764 }, delay);
6765 };
6766 };
6767 /**
6768 * Debounce all fired events types listed in `types`
6769 * while executing the provided `fn`.
6770 *
6771 */
6772 const debounce_events = (self, types, fn) => {
6773 var type;
6774 var trigger = self.trigger;
6775 var event_args = {};
6776 // override trigger method
6777 self.trigger = function () {
6778 var type = arguments[0];
6779 if (types.indexOf(type) !== -1) {
6780 event_args[type] = arguments;
6781 }
6782 else {
6783 return trigger.apply(self, arguments);
6784 }
6785 };
6786 // invoke provided function
6787 fn.apply(self, []);
6788 self.trigger = trigger;
6789 // trigger queued events
6790 for (type of types) {
6791 if (type in event_args) {
6792 trigger.apply(self, event_args[type]);
6793 }
6794 }
6795 };
6796 /**
6797 * Determines the current selection within a text input control.
6798 * Returns an object containing:
6799 * - start
6800 * - length
6801 *
6802 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
6803 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
6804 */
6805 const getSelection = (input) => {
6806 return {
6807 start: input.selectionStart || 0,
6808 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
6809 };
6810 };
6811 /**
6812 * Prevent default
6813 *
6814 */
6815 const preventDefault = (evt, stop = false) => {
6816 if (evt) {
6817 evt.preventDefault();
6818 if (stop) {
6819 evt.stopPropagation();
6820 }
6821 }
6822 };
6823 /**
6824 * Add event helper
6825 *
6826 */
6827 const addEvent = (target, type, callback, options) => {
6828 target.addEventListener(type, callback, options);
6829 };
6830 /**
6831 * Return true if the requested key is down
6832 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
6833 * The current evt may not always set ( eg calling advanceSelection() )
6834 *
6835 */
6836 const isKeyDown = (key_name, evt) => {
6837 if (!evt) {
6838 return false;
6839 }
6840 if (!evt[key_name]) {
6841 return false;
6842 }
6843 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
6844 if (count === 1) {
6845 return true;
6846 }
6847 return false;
6848 };
6849 /**
6850 * Get the id of an element
6851 * If the id attribute is not set, set the attribute with the given id
6852 *
6853 */
6854 const getId = (el, id) => {
6855 const existing_id = el.getAttribute('id');
6856 if (existing_id) {
6857 return existing_id;
6858 }
6859 el.setAttribute('id', id);
6860 return id;
6861 };
6862 /**
6863 * Returns a string with backslashes added before characters that need to be escaped.
6864 */
6865 const addSlashes = (str) => {
6866 return str.replace(/[\\"']/g, '\\$&');
6867 };
6868 /**
6869 *
6870 */
6871 const append = (parent, node) => {
6872 if (node)
6873 parent.append(node);
6874 };
6875 /**
6876 * Iterates over arrays and hashes.
6877 *
6878 * ```
6879 * iterate(this.items, function(item, id) {
6880 * // invoked for each item
6881 * });
6882 * ```
6883 *
6884 */
6885 const iterate = (object, callback) => {
6886 if (Array.isArray(object)) {
6887 object.forEach(callback);
6888 }
6889 else {
6890 for (var key in object) {
6891 if (object.hasOwnProperty(key)) {
6892 callback(object[key], key);
6893 }
6894 }
6895 }
6896 };
6897 //# sourceMappingURL=utils.js.map
6898
6899 /***/ },
6900
6901 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
6902 /*!*****************************************************!*\
6903 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
6904 \*****************************************************/
6905 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
6906
6907 __webpack_require__.r(__webpack_exports__);
6908 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
6909 /* harmony export */ addClasses: () => (/* binding */ addClasses),
6910 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
6911 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
6912 /* harmony export */ classesArray: () => (/* binding */ classesArray),
6913 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
6914 /* harmony export */ getDom: () => (/* binding */ getDom),
6915 /* harmony export */ getTail: () => (/* binding */ getTail),
6916 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
6917 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
6918 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
6919 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
6920 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
6921 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
6922 /* harmony export */ setAttr: () => (/* binding */ setAttr),
6923 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
6924 /* harmony export */ });
6925 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
6926
6927 /**
6928 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
6929 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
6930 *
6931 * param query should be {}
6932 */
6933 const getDom = (query) => {
6934 if (query.jquery) {
6935 return query[0];
6936 }
6937 if (query instanceof HTMLElement) {
6938 return query;
6939 }
6940 if (isHtmlString(query)) {
6941 var tpl = document.createElement('template');
6942 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
6943 return tpl.content.firstChild;
6944 }
6945 return document.querySelector(query);
6946 };
6947 const isHtmlString = (arg) => {
6948 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
6949 return true;
6950 }
6951 return false;
6952 };
6953 const escapeQuery = (query) => {
6954 return query.replace(/['"\\]/g, '\\$&');
6955 };
6956 /**
6957 * Dispatch an event
6958 *
6959 */
6960 const triggerEvent = (dom_el, event_name) => {
6961 var event = document.createEvent('HTMLEvents');
6962 event.initEvent(event_name, true, false);
6963 dom_el.dispatchEvent(event);
6964 };
6965 /**
6966 * Apply CSS rules to a dom element
6967 *
6968 */
6969 const applyCSS = (dom_el, css) => {
6970 Object.assign(dom_el.style, css);
6971 };
6972 /**
6973 * Add css classes
6974 *
6975 */
6976 const addClasses = (elmts, ...classes) => {
6977 var norm_classes = classesArray(classes);
6978 elmts = castAsArray(elmts);
6979 elmts.map(el => {
6980 norm_classes.map(cls => {
6981 el.classList.add(cls);
6982 });
6983 });
6984 };
6985 /**
6986 * Remove css classes
6987 *
6988 */
6989 const removeClasses = (elmts, ...classes) => {
6990 var norm_classes = classesArray(classes);
6991 elmts = castAsArray(elmts);
6992 elmts.map(el => {
6993 norm_classes.map(cls => {
6994 el.classList.remove(cls);
6995 });
6996 });
6997 };
6998 /**
6999 * Return arguments
7000 *
7001 */
7002 const classesArray = (args) => {
7003 var classes = [];
7004 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
7005 if (typeof _classes === 'string') {
7006 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
7007 }
7008 if (Array.isArray(_classes)) {
7009 classes = classes.concat(_classes);
7010 }
7011 });
7012 return classes.filter(Boolean);
7013 };
7014 /**
7015 * Create an array from arg if it's not already an array
7016 *
7017 */
7018 const castAsArray = (arg) => {
7019 if (!Array.isArray(arg)) {
7020 arg = [arg];
7021 }
7022 return arg;
7023 };
7024 /**
7025 * Get the closest node to the evt.target matching the selector
7026 * Stops at wrapper
7027 *
7028 */
7029 const parentMatch = (target, selector, wrapper) => {
7030 if (wrapper && !wrapper.contains(target)) {
7031 return;
7032 }
7033 while (target && target.matches) {
7034 if (target.matches(selector)) {
7035 return target;
7036 }
7037 target = target.parentNode;
7038 }
7039 };
7040 /**
7041 * Get the first or last item from an array
7042 *
7043 * > 0 - right (last)
7044 * <= 0 - left (first)
7045 *
7046 */
7047 const getTail = (list, direction = 0) => {
7048 if (direction > 0) {
7049 return list[list.length - 1];
7050 }
7051 return list[0];
7052 };
7053 /**
7054 * Return true if an object is empty
7055 *
7056 */
7057 const isEmptyObject = (obj) => {
7058 return (Object.keys(obj).length === 0);
7059 };
7060 /**
7061 * Get the index of an element amongst sibling nodes of the same type
7062 *
7063 */
7064 const nodeIndex = (el, amongst) => {
7065 if (!el)
7066 return -1;
7067 amongst = amongst || el.nodeName;
7068 var i = 0;
7069 while (el = el.previousElementSibling) {
7070 if (el.matches(amongst)) {
7071 i++;
7072 }
7073 }
7074 return i;
7075 };
7076 /**
7077 * Set attributes of an element
7078 *
7079 */
7080 const setAttr = (el, attrs) => {
7081 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
7082 if (val == null) {
7083 el.removeAttribute(attr);
7084 }
7085 else {
7086 el.setAttribute(attr, '' + val);
7087 }
7088 });
7089 };
7090 /**
7091 * Replace a node
7092 */
7093 const replaceNode = (existing, replacement) => {
7094 if (existing.parentNode)
7095 existing.parentNode.replaceChild(replacement, existing);
7096 };
7097 //# sourceMappingURL=vanilla.js.map
7098
7099 /***/ }
7100
7101 /******/ });
7102 /************************************************************************/
7103 /******/ // The module cache
7104 /******/ var __webpack_module_cache__ = {};
7105 /******/
7106 /******/ // The require function
7107 /******/ function __webpack_require__(moduleId) {
7108 /******/ // Check if module is in cache
7109 /******/ var cachedModule = __webpack_module_cache__[moduleId];
7110 /******/ if (cachedModule !== undefined) {
7111 /******/ return cachedModule.exports;
7112 /******/ }
7113 /******/ // Create a new module (and put it into the cache)
7114 /******/ var module = __webpack_module_cache__[moduleId] = {
7115 /******/ // no module.id needed
7116 /******/ // no module.loaded needed
7117 /******/ exports: {}
7118 /******/ };
7119 /******/
7120 /******/ // Execute the module function
7121 /******/ if (!(moduleId in __webpack_modules__)) {
7122 /******/ delete __webpack_module_cache__[moduleId];
7123 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
7124 /******/ e.code = 'MODULE_NOT_FOUND';
7125 /******/ throw e;
7126 /******/ }
7127 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
7128 /******/
7129 /******/ // Return the exports of the module
7130 /******/ return module.exports;
7131 /******/ }
7132 /******/
7133 /************************************************************************/
7134 /******/ /* webpack/runtime/define property getters */
7135 /******/ (() => {
7136 /******/ // define getter functions for harmony exports
7137 /******/ __webpack_require__.d = (exports, definition) => {
7138 /******/ for(var key in definition) {
7139 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
7140 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
7141 /******/ }
7142 /******/ }
7143 /******/ };
7144 /******/ })();
7145 /******/
7146 /******/ /* webpack/runtime/hasOwnProperty shorthand */
7147 /******/ (() => {
7148 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
7149 /******/ })();
7150 /******/
7151 /******/ /* webpack/runtime/make namespace object */
7152 /******/ (() => {
7153 /******/ // define __esModule on exports
7154 /******/ __webpack_require__.r = (exports) => {
7155 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
7156 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
7157 /******/ }
7158 /******/ Object.defineProperty(exports, '__esModule', { value: true });
7159 /******/ };
7160 /******/ })();
7161 /******/
7162 /************************************************************************/
7163 var __webpack_exports__ = {};
7164 // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
7165 (() => {
7166 /*!********************************************!*\
7167 !*** ./assets/src/js/admin/admin-tools.js ***!
7168 \********************************************/
7169 __webpack_require__.r(__webpack_exports__);
7170 /* harmony import */ var _tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/assign-user-course */ "./assets/src/js/admin/tools/assign-user-course.js");
7171
7172 (0,_tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__["default"])();
7173 })();
7174
7175 /******/ })()
7176 ;
7177 //# sourceMappingURL=admin-tools.js.map