PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.4
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.4
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.js

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

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