PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.9 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 All 140 releases
learnpress / assets / dist / js / admin / admin-tools.js

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

14,171 lines 496.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/admin/tools/assign-user-course.js"
5 /*!*********************************************************!*\
6 !*** ./assets/src/js/admin/tools/assign-user-course.js ***!
7 \*********************************************************/
8 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ "default": () => (/* binding */ assignUserCourse)
14 /* harmony export */ });
15 /* harmony import */ var _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils-admin.js */ "./assets/src/js/admin/utils-admin.js");
16 /**
17 * Assign user to course
18 *
19 * @since 4.2.5.6
20 * @version 1.0.1
21 */
22
23 function assignUserCourse() {
24 let elFormAssignUserCourse;
25 let elFormUnAssignUserCourse;
26 let elUserUnAssign, elCourseUnAssign, elUserAssign, elCourseAssign;
27 const limitHandle = 5;
28 const getAllElements = () => {
29 elFormAssignUserCourse = document.querySelector('#lp-assign-user-course-form');
30 elFormUnAssignUserCourse = document.querySelector('#lp-unassign-user-course-form');
31 if (elFormAssignUserCourse) {
32 elUserUnAssign = elFormUnAssignUserCourse.querySelector('[name=user_ids]');
33 elCourseUnAssign = elFormUnAssignUserCourse.querySelector('[name=course_ids]');
34 }
35 if (elFormUnAssignUserCourse) {
36 elUserAssign = elFormAssignUserCourse.querySelector('[name=user_ids]');
37 elCourseAssign = elFormAssignUserCourse.querySelector('[name=course_ids]');
38 }
39 };
40 const events = () => {
41 const elForm = document.querySelector('form');
42 if (!elForm) {
43 return;
44 }
45 document.addEventListener('submit', e => {
46 const elForm = e.target;
47 const formData = new FormData(e.target); // Create a FormData object from the form
48
49 // get values of form.
50 const obj = Object.fromEntries(Array.from(formData.keys(), key => {
51 const val = formData.getAll(key);
52 return [key, val.length > 1 ? val : val.pop()];
53 }));
54 if (elForm.id === 'lp-assign-user-course-form') {
55 e.preventDefault();
56 if (!confirm('Are you sure you want to Assign?')) {
57 return;
58 }
59 const {
60 packages,
61 data,
62 totalPage
63 } = handleDataBeforeSend(obj);
64 fetchAPIAssignCourse(packages, data, 1, totalPage);
65 } else if (elForm.id === 'lp-unassign-user-course-form') {
66 e.preventDefault();
67 if (!confirm('Are you sure you want to Unassign?')) {
68 return;
69 }
70 const {
71 packages,
72 data,
73 totalPage
74 } = handleDataBeforeSend(obj);
75 fetchAPIUnAssignCourse(packages, data, 1, totalPage);
76 }
77 });
78 };
79 const handleDataBeforeSend = dataRaw => {
80 // Cut to packages to send, 1 packages has 5 items.
81 let arrCourseIds = [];
82 let arrUserIds = [];
83 if (typeof dataRaw.course_ids === 'string') {
84 arrCourseIds.push(dataRaw.course_ids);
85 } else if (typeof dataRaw.course_ids === 'object') {
86 arrCourseIds = dataRaw.course_ids;
87 }
88 if (typeof dataRaw.user_ids === 'string') {
89 arrUserIds.push(dataRaw.user_ids);
90 } else if (typeof dataRaw.user_ids === 'object') {
91 arrUserIds = dataRaw.user_ids;
92 }
93 const packages = [];
94 arrCourseIds.map((courseId, indexCourse) => {
95 const item = {};
96 item.course_id = courseId;
97 arrUserIds.map((userID, indexUser) => {
98 const newItem = {
99 ...item,
100 user_id: userID
101 };
102 packages.push(newItem);
103 });
104 });
105 const data = packages.slice(0, limitHandle);
106 const totalPage = Math.ceil(packages.length / limitHandle);
107 return {
108 packages,
109 data,
110 totalPage
111 };
112 };
113 const fetchAPIAssignCourse = (packages, data, page, totalPage) => {
114 const url = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiAssignUserCourse;
115 const params = {
116 headers: {
117 'Content-Type': 'application/json',
118 'X-WP-Nonce': lpDataAdmin.nonce
119 },
120 method: 'POST',
121 body: JSON.stringify({
122 data,
123 page,
124 totalPage
125 })
126 };
127 const elProgress = elFormAssignUserCourse.querySelector('.percent');
128 const elButtonAssign = elFormAssignUserCourse.querySelector('.lp-button-assign-course');
129 const elMessage = elFormAssignUserCourse.querySelector('.message');
130 elButtonAssign.disabled = true;
131 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, {
132 success: response => {
133 const {
134 status,
135 message
136 } = response;
137 if (status === 'success') {
138 let page = parseInt(response.data.page);
139 const begin = page * limitHandle;
140 const end = begin + limitHandle;
141 data = packages.slice(begin, end);
142 elProgress.innerHTML = response.data.percent;
143 fetchAPIAssignCourse(packages, data, ++page, totalPage);
144 } else if (status === 'finished') {
145 elProgress.innerHTML = '';
146 elMessage.style.color = 'green';
147 elMessage.innerHTML = message;
148 setTimeout(() => {
149 elMessage.innerHTML = '';
150 }, 2000);
151 elButtonAssign.disabled = false;
152 // Clear data selected on Tom Select.
153 if (!elUserAssign.tomselect || !elCourseAssign.tomselect) {
154 return;
155 }
156 elUserAssign.tomselect.clear();
157 elCourseAssign.tomselect.clear();
158 } else if (status === 'error') {
159 elButtonAssign.disabled = false;
160 elMessage.style.color = 'red';
161 elMessage.innerHTML = message;
162 setTimeout(() => {
163 elMessage.innerHTML = '';
164 }, 2000);
165 }
166 },
167 error: err => {
168 elButtonAssign.disabled = false;
169 elMessage.innerHTML = err.message;
170 },
171 completed: () => {}
172 });
173 };
174 const fetchAPIUnAssignCourse = (packages, data, page, totalPage) => {
175 const url = _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Api.admin.apiUnAssignUserCourse;
176 const params = {
177 headers: {
178 'Content-Type': 'application/json',
179 'X-WP-Nonce': lpDataAdmin.nonce
180 },
181 method: 'POST',
182 body: JSON.stringify({
183 data,
184 page,
185 totalPage
186 })
187 };
188 const elProgress = elFormUnAssignUserCourse.querySelector('.percent');
189 const elButtonAssign = elFormUnAssignUserCourse.querySelector('.lp-button-unassign-course');
190 const elMessage = elFormUnAssignUserCourse.querySelector('.message');
191 elButtonAssign.disabled = true;
192 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(url, params, {
193 success: response => {
194 const {
195 status,
196 message
197 } = response;
198 if (status === 'success') {
199 let page = parseInt(response.data.page);
200 const begin = page * limitHandle;
201 const end = begin + limitHandle;
202 data = packages.slice(begin, end);
203 elProgress.innerHTML = response.data.percent;
204 fetchAPIUnAssignCourse(packages, data, ++page, totalPage);
205 } else if (status === 'finished') {
206 elProgress.innerHTML = '';
207 elMessage.style.color = 'green';
208 elMessage.innerHTML = message;
209 setTimeout(() => {
210 elMessage.innerHTML = '';
211 }, 2000);
212 elButtonAssign.disabled = false;
213 // Clear data selected on Tom Select.
214 if (!elUserUnAssign.tomselect || !elCourseUnAssign.tomselect) {
215 return;
216 }
217 elUserUnAssign.tomselect.clear();
218 elCourseUnAssign.tomselect.clear();
219 } else if (status === 'error') {
220 elButtonAssign.disabled = false;
221 elMessage.style.color = 'red';
222 elMessage.innerHTML = message;
223 setTimeout(() => {
224 elMessage.innerHTML = '';
225 }, 2000);
226 }
227 },
228 error: err => {
229 elButtonAssign.disabled = false;
230 elMessage.innerHTML = err.message;
231 },
232 completed: () => {}
233 });
234 };
235
236 // DOMContentLoaded.
237 document.addEventListener('DOMContentLoaded', () => {
238 getAllElements();
239 if (!elFormAssignUserCourse) {
240 return;
241 }
242 events();
243 });
244 }
245
246 /***/ },
247
248 /***/ "./assets/src/js/admin/tools/handle-sample-data.js"
249 /*!*********************************************************!*\
250 !*** ./assets/src/js/admin/tools/handle-sample-data.js ***!
251 \*********************************************************/
252 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
253
254 "use strict";
255 __webpack_require__.r(__webpack_exports__);
256 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
257 /* harmony export */ "default": () => (/* binding */ HandleSampleData)
258 /* harmony export */ });
259 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
260 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
261 /**
262 * Handle install/uninstall sample course data on the Tools page.
263 *
264 * @since 4.4.5
265 * @version 1.0.0
266 */
267
268
269 class HandleSampleData {
270 static selectors = {
271 wrapper: '.lp-install-sample',
272 form: '.lp-form-handle-sample-data',
273 elBtnHandleSampleData: '.lp-btn-install-sample-handle',
274 elTriggerToggle: '.lp-install-sample__toggle-options',
275 elMessage: '.lp-install-sample-message'
276 };
277 constructor() {
278 this.wrapper = null;
279 }
280 init() {
281 this.wrapper = document.querySelector(HandleSampleData.selectors.wrapper);
282 if (!this.wrapper) {
283 return;
284 }
285 this.preventFormSubmit();
286 this.events();
287 }
288 preventFormSubmit() {
289 const form = this.wrapper.querySelector(HandleSampleData.selectors.form);
290 if (form) {
291 form.addEventListener('submit', e => {
292 e.preventDefault();
293 });
294 }
295 }
296 events() {
297 if (HandleSampleData._loadedEvents) {
298 return;
299 }
300 HandleSampleData._loadedEvents = this;
301 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
302 selector: HandleSampleData.selectors.elBtnHandleSampleData,
303 class: this,
304 callBack: this.handleAction.name
305 }, {
306 selector: HandleSampleData.selectors.elTriggerToggle,
307 callBack: args => {
308 const {
309 e,
310 target
311 } = args;
312 const elForm = this.wrapper.querySelector(HandleSampleData.selectors.form);
313 if (elForm) {
314 elForm.classList.toggle('lp-hidden');
315 const textShow = target.dataset.showText;
316 const textHide = target.dataset.hideText;
317 target.textContent = elForm.classList.contains('lp-hidden') ? textShow : textHide;
318 }
319 }
320 }]);
321 }
322 handleAction(args) {
323 const {
324 e,
325 target
326 } = args;
327 const button = target.closest(HandleSampleData.selectors.elBtnHandleSampleData);
328 e.preventDefault();
329 const elMessage = this.wrapper.querySelector(HandleSampleData.selectors.elMessage);
330 const message = button.dataset.message;
331 if (!message || !confirm(message)) {
332 return;
333 }
334 elMessage.innerHTML = '';
335 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(button, true);
336 const wrapper = button.closest(HandleSampleData.selectors.wrapper);
337 const elForm = wrapper.querySelector(HandleSampleData.selectors.form);
338 let dataSend = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.getDataOfForm(elForm);
339 dataSend.action = button.dataset.action;
340 dataSend.id_url = 'handle-sample-data';
341 const callBack = {
342 success: response => {
343 const {
344 status,
345 message,
346 data
347 } = response;
348 if ('success' === status) {
349 this.wrapper.querySelector(HandleSampleData.selectors.elMessage).innerHTML = data.html;
350 } else {
351 throw new Error(message);
352 }
353 },
354 error: error => {
355 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
356 },
357 completed: () => {
358 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(button, false);
359 setTimeout(() => {
360 elMessage.innerHTML = '';
361 }, 3000);
362 }
363 };
364 window.lpAJAXG.fetchAJAX(dataSend, callBack);
365 }
366 }
367
368 /***/ },
369
370 /***/ "./assets/src/js/admin/tools/reset-course-progress.js"
371 /*!************************************************************!*\
372 !*** ./assets/src/js/admin/tools/reset-course-progress.js ***!
373 \************************************************************/
374 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
375
376 "use strict";
377 __webpack_require__.r(__webpack_exports__);
378 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
379 /* harmony export */ "default": () => (/* binding */ ResetCourseProgress)
380 /* harmony export */ });
381 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
382 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
383 /* harmony import */ var lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/lpPopupSelectItemToAdd.js */ "./assets/src/js/lpPopupSelectItemToAdd.js");
384 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
385 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_3__);
386 /**
387 * Reset course user progress handler.
388 *
389 * @since 4.4.6
390 * @version 1.0.0
391 */
392
393
394
395
396 const lpPopupSelectItemToAdd = new lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd();
397 class ResetCourseProgress {
398 static selectors = {
399 elPopupTemplate: '#lp-tmpl-select-courses-to-reset-progress',
400 elFilterField: '.lp-filter-field',
401 elFormFilter: '.lp-form-filter-reset-course-progress',
402 elPopupItemsToSelect: '.lp-popup-select-courses-to-reset-progress',
403 elBtnResetAll: '.lp-btn-reset-all-courses-progress'
404 };
405 constructor() {
406 this.btnChooseCourses = null;
407 this.elFormFilter = null;
408 this.elPopupItemsToSelect = null;
409 this.elBtnResetAll = null;
410 this.elBtnAddItemsSelected = null;
411 this.debouncedSearchUsers = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.debounce(elForm => {
412 this.fetchCourses(elForm);
413 }, 800);
414 }
415 init() {
416 this.events();
417 }
418 events() {
419 // Check and attach events only once.
420 if (ResetCourseProgress._loadedEvents) {
421 return;
422 }
423 ResetCourseProgress._loadedEvents = this;
424
425 // Click events.
426 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
427 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
428 class: this,
429 callBack: this.handleShowPopupItemsToSelect.name
430 }, {
431 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected,
432 class: lpPopupSelectItemToAdd,
433 callBack: lpPopupSelectItemToAdd.addItemsSelectedToSection.name,
434 callBackHandle: this.addItemsSelectedToSection.bind(this),
435 conditionBeforeCallBack: args => {
436 // Only run when the Add button inside this tool's popup is clicked.
437 return !!args.target.closest(ResetCourseProgress.selectors.elPopupItemsToSelect);
438 }
439 }, {
440 selector: ResetCourseProgress.selectors.elBtnResetAll,
441 class: this,
442 callBack: this.resetAllCoursesProgress.name
443 }]);
444
445 // Change events.
446 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
447 selector: ResetCourseProgress.selectors.elFilterField,
448 class: this,
449 callBack: this.filterCourses.name
450 }]);
451 }
452
453 /**
454 * Called when the picker button is clicked.
455 *
456 * @param {Object} args Event arguments.
457 */
458 handleShowPopupItemsToSelect(args) {
459 const {
460 e,
461 target
462 } = args;
463 this.btnChooseCourses = target.closest('.lp-btn-choose-courses-to-reset-progress');
464 if (!this.btnChooseCourses) {
465 return;
466 }
467 this.elPopupItemsToSelect = sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().getPopup().querySelector(ResetCourseProgress.selectors.elPopupItemsToSelect);
468 if (!this.elPopupItemsToSelect) {
469 return;
470 }
471 this.elBtnAddItemsSelected = this.elPopupItemsToSelect.querySelector(lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected);
472 if (!this.elBtnAddItemsSelected) {
473 return;
474 }
475 this.elBtnResetAll = this.elPopupItemsToSelect.querySelector(ResetCourseProgress.selectors.elBtnResetAll);
476 }
477
478 /**
479 * Called after courses are selected in the popup and the action button is clicked.
480 *
481 * @param {Array} itemsSelectedData Selected item data from the popup.
482 */
483 addItemsSelectedToSection(itemsSelectedData) {
484 if (!this.btnChooseCourses) {
485 return;
486 }
487 const messageConfirm = this.elBtnAddItemsSelected.dataset.messageConfirm;
488 if (!messageConfirm || confirm(messageConfirm) === false) {
489 return;
490 }
491 this.btnChooseCourses.textContent = this.btnChooseCourses.dataset.messageResetting;
492 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 1);
493 const userItemIds = itemsSelectedData.map(item => parseInt(item.id, 10)).filter(id => !isNaN(id) && id > 0);
494 const elSearchUser = this.elFormFilter?.querySelector('.lp-search-user');
495 const searchUserValue = elSearchUser?.value || '';
496 window.lpAJAXG.fetchAJAX({
497 id_url: 'course-reset-progress-tool',
498 action: 'reset_progress_courses',
499 user_item_ids: userItemIds,
500 search_user: searchUserValue
501 }, {
502 success: response => {
503 const {
504 status,
505 message
506 } = response;
507 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
508 },
509 error: error => {
510 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
511 },
512 completed: () => {
513 this.btnChooseCourses.textContent = this.btnChooseCourses.dataset.messageChoose;
514 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 0);
515 }
516 });
517 }
518
519 /**
520 * Reset all courses progress.
521 *
522 * @param {Object} args Event arguments.
523 */
524 resetAllCoursesProgress(args) {
525 const {
526 e,
527 target
528 } = args;
529 const elPopupItemsToSelect = target.closest(ResetCourseProgress.selectors.elPopupItemsToSelect);
530 if (!elPopupItemsToSelect) {
531 return;
532 }
533 const elFormFilter = elPopupItemsToSelect.querySelector(ResetCourseProgress.selectors.elFormFilter);
534 if (!elFormFilter) {
535 return;
536 }
537 const messageConfirm = this.elBtnResetAll.dataset.messageConfirm;
538 if (!messageConfirm || confirm(messageConfirm) === false) {
539 return;
540 }
541
542 // Show loading
543 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 1);
544 sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().close();
545 const formData = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.getDataOfForm(elFormFilter);
546 window.lpAJAXG.fetchAJAX({
547 id_url: 'course-reset-progress-tool',
548 action: 'reset_progress_courses',
549 reset_all: 1,
550 ...formData
551 }, {
552 success: response => {
553 const {
554 status,
555 message
556 } = response;
557 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
558 },
559 error: error => {
560 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
561 },
562 completed: () => {
563 this.btnChooseCourses.textContent = this.btnChooseCourses.dataset.messageChoose;
564 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseCourses, 0);
565 }
566 });
567 }
568
569 /**
570 * Fetch courses to reset progress.
571 *
572 * @param {HTMLElement} elForm The form element.
573 */
574 fetchCourses(elForm) {
575 this.elFormFilter = elForm;
576 const elPopup = elForm.closest(ResetCourseProgress.selectors.elPopupItemsToSelect);
577 const elLPTarget = elPopup.querySelector('.lp-target');
578 let dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
579 dataSend.args = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(elForm, dataSend.args);
580 dataSend.args.paged = 1;
581 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
582
583 // Show loading
584 window.lpAJAXG.showHideLoading(elLPTarget, 1);
585 window.lpAJAXG.fetchAJAX(dataSend, {
586 success: response => {
587 const {
588 data
589 } = response;
590 elLPTarget.innerHTML = data.content || '';
591 },
592 error: error => {
593 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
594 },
595 completed: () => {
596 window.lpAJAXG.showHideLoading(elLPTarget, 0);
597 }
598 });
599 }
600
601 /**
602 * Filter courses to reset progress.
603 *
604 * @param {Object} args Event arguments.
605 */
606 filterCourses(args) {
607 const {
608 target
609 } = args;
610 const elFilterField = target.closest(ResetCourseProgress.selectors.elFilterField);
611 if (!elFilterField) {
612 return;
613 }
614 const elForm = elFilterField.closest(ResetCourseProgress.selectors.elFormFilter);
615 if (!elForm) {
616 return;
617 }
618 this.debouncedSearchUsers(elForm);
619 }
620 }
621
622 /***/ },
623
624 /***/ "./assets/src/js/admin/tools/reset-item-progress.js"
625 /*!**********************************************************!*\
626 !*** ./assets/src/js/admin/tools/reset-item-progress.js ***!
627 \**********************************************************/
628 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
629
630 "use strict";
631 __webpack_require__.r(__webpack_exports__);
632 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
633 /* harmony export */ "default": () => (/* binding */ ResetItemProgress)
634 /* harmony export */ });
635 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
636 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
637 /* harmony import */ var lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/lpPopupSelectItemToAdd.js */ "./assets/src/js/lpPopupSelectItemToAdd.js");
638 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
639 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_3__);
640 /**
641 * Reset item user progress handler.
642 *
643 * @since 4.4.6
644 * @version 1.0.0
645 */
646
647
648
649
650 const lpPopupSelectItemToAdd = new lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd({
651 openButtonSelector: '.lp-btn-choose-item-to-reset-progress'
652 });
653 class ResetItemProgress {
654 static selectors = {
655 elPopupTemplate: '#lp-tmpl-select-items-to-reset-progress',
656 elFilterField: '.lp-filter-field',
657 elFormFilter: '.lp-form-filter-reset-item-progress',
658 elPopupItemsToSelect: '.lp-popup-select-items-to-reset-progress',
659 elBtnResetAll: '.lp-btn-reset-all-items-progress'
660 };
661 constructor() {
662 this.btnChooseItems = null;
663 this.elFormFilter = null;
664 this.elPopupItemsToSelect = null;
665 this.elBtnResetAll = null;
666 this.elBtnAddItemsSelected = null;
667 this.debouncedSearchItems = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.debounce(elForm => {
668 this.fetchItems(elForm);
669 }, 800);
670 }
671 init() {
672 this.events();
673 }
674 events() {
675 // Check and attach events only once.
676 if (ResetItemProgress._loadedEvents) {
677 return;
678 }
679 ResetItemProgress._loadedEvents = this;
680
681 // Click events.
682 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
683 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
684 class: this,
685 callBack: this.handleShowPopupItemsToSelect.name
686 }, {
687 selector: lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected,
688 class: lpPopupSelectItemToAdd,
689 callBack: lpPopupSelectItemToAdd.addItemsSelectedToSection.name,
690 callBackHandle: this.addItemsSelectedToSection.bind(this),
691 conditionBeforeCallBack: args => {
692 // Only run when the Add button inside this tool's popup is clicked.
693 return !!args.target.closest(ResetItemProgress.selectors.elPopupItemsToSelect);
694 }
695 }, {
696 selector: ResetItemProgress.selectors.elBtnResetAll,
697 class: this,
698 callBack: this.resetAllItemsProgress.name
699 }]);
700
701 // Change events.
702 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
703 selector: ResetItemProgress.selectors.elFilterField,
704 class: this,
705 callBack: this.filterItems.name
706 }]);
707 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('change', [{
708 selector: ResetItemProgress.selectors.elFilterField,
709 class: this,
710 callBack: this.filterItems.name
711 }]);
712 }
713
714 /**
715 * Called when the picker button is clicked.
716 *
717 * @param {Object} args Event arguments.
718 */
719 handleShowPopupItemsToSelect(args) {
720 const {
721 e,
722 target
723 } = args;
724 this.btnChooseItems = target.closest('.lp-btn-choose-item-to-reset-progress');
725 if (!this.btnChooseItems) {
726 return;
727 }
728 this.elPopupItemsToSelect = sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().getPopup().querySelector(ResetItemProgress.selectors.elPopupItemsToSelect);
729 this.elBtnAddItemsSelected = this.elPopupItemsToSelect.querySelector(lpAssetsJsPath_lpPopupSelectItemToAdd_js__WEBPACK_IMPORTED_MODULE_2__.LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected);
730 this.elBtnResetAll = this.elPopupItemsToSelect.querySelector(ResetItemProgress.selectors.elBtnResetAll);
731 }
732
733 /**
734 * Called after items are selected in the popup and the action button is clicked.
735 *
736 * @param {Array} itemsSelectedData Selected item data from the popup.
737 */
738 addItemsSelectedToSection(itemsSelectedData) {
739 if (!this.btnChooseItems) {
740 return;
741 }
742 const messageConfirm = this.elBtnAddItemsSelected.dataset.messageConfirm;
743 if (!messageConfirm || confirm(messageConfirm) === false) {
744 return;
745 }
746 this.btnChooseItems.textContent = this.btnChooseItems.dataset.messageResetting;
747 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 1);
748 const userItemIds = itemsSelectedData.map(item => parseInt(item.id, 10)).filter(id => !isNaN(id) && id > 0);
749 window.lpAJAXG.fetchAJAX({
750 id_url: 'item-reset-progress-tool',
751 action: 'reset_progress_items_course',
752 user_item_ids: userItemIds
753 }, {
754 success: response => {
755 const {
756 status,
757 message
758 } = response;
759 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
760 },
761 error: error => {
762 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
763 },
764 completed: () => {
765 this.btnChooseItems.textContent = this.btnChooseItems.dataset.messageChoose;
766 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 0);
767 }
768 });
769 }
770
771 /**
772 * Reset all items progress.
773 *
774 * @param {Object} args Event arguments.
775 */
776 resetAllItemsProgress(args) {
777 const {
778 e,
779 target
780 } = args;
781 const elPopupItemsToSelect = target.closest(ResetItemProgress.selectors.elPopupItemsToSelect);
782 if (!elPopupItemsToSelect) {
783 return;
784 }
785 const elFormFilter = elPopupItemsToSelect.querySelector(ResetItemProgress.selectors.elFormFilter);
786 if (!elFormFilter) {
787 return;
788 }
789 const messageConfirm = this.elBtnResetAll.dataset.messageConfirm;
790 if (!messageConfirm || confirm(messageConfirm) === false) {
791 return;
792 }
793
794 // Show loading
795 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 1);
796 sweetalert2__WEBPACK_IMPORTED_MODULE_3___default().close();
797 const formData = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.getDataOfForm(elFormFilter);
798 window.lpAJAXG.fetchAJAX({
799 id_url: 'item-reset-progress-tool',
800 action: 'reset_progress_items_course',
801 reset_all: 1,
802 ...formData
803 }, {
804 success: response => {
805 const {
806 status,
807 message
808 } = response;
809 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(message, status);
810 },
811 error: error => {
812 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error.message, 'error');
813 },
814 completed: () => {
815 this.btnChooseItems.textContent = this.btnChooseItems.dataset.messageChoose;
816 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl(this.btnChooseItems, 0);
817 }
818 });
819 }
820
821 /**
822 * Fetch items to reset progress.
823 *
824 * @param {HTMLElement} elForm The form element.
825 */
826 fetchItems(elForm) {
827 this.elFormFilter = elForm;
828 const elPopup = elForm.closest(ResetItemProgress.selectors.elPopupItemsToSelect);
829 const elLPTarget = elPopup.querySelector('.lp-target');
830 let dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
831 dataSend.args = lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.mergeDataWithDatForm(elForm, dataSend.args);
832 dataSend.args.paged = 1;
833 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
834
835 // Show loading
836 window.lpAJAXG.showHideLoading(elLPTarget, 1);
837 window.lpAJAXG.fetchAJAX(dataSend, {
838 success: response => {
839 const {
840 data
841 } = response;
842 elLPTarget.innerHTML = data.content || '';
843 },
844 error: error => {
845 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
846 },
847 completed: () => {
848 window.lpAJAXG.showHideLoading(elLPTarget, 0);
849 }
850 });
851 }
852
853 /**
854 * Filter items to reset progress.
855 *
856 * @param {Object} args Event arguments.
857 */
858 filterItems(args) {
859 const {
860 target
861 } = args;
862 const elFilterField = target.closest(ResetItemProgress.selectors.elFilterField);
863 if (!elFilterField) {
864 return;
865 }
866 const elForm = elFilterField.closest(ResetItemProgress.selectors.elFormFilter);
867 if (!elForm) {
868 return;
869 }
870 this.debouncedSearchItems(elForm);
871 }
872 }
873
874 /***/ },
875
876 /***/ "./assets/src/js/admin/utils-admin.js"
877 /*!********************************************!*\
878 !*** ./assets/src/js/admin/utils-admin.js ***!
879 \********************************************/
880 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
881
882 "use strict";
883 __webpack_require__.r(__webpack_exports__);
884 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
885 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
886 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
887 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
888 /* harmony export */ });
889 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
890 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
891 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
892 /**
893 * Library run on Admin
894 *
895 * @since 4.2.6.9
896 * @version 1.0.1
897 */
898
899
900
901 const AdminUtilsFunctions = {
902 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
903 if (!elTomSelect) {
904 return;
905 }
906 const optionDefault = {
907 plugins: {
908 remove_button: {
909 title: 'Remove this item'
910 },
911 dropdown_input: {}
912 },
913 onInitialize() {},
914 onItemAdd(e) {
915 // Get list without current item.
916 if (fetchAPI) {
917 const selectedOptions = Array.from(elTomSelect.selectedOptions);
918 const selectedValues = selectedOptions.map(option => option.value);
919 selectedValues.push(e);
920 dataSend.id_not_in = selectedValues.join(',');
921 fetchAPI('', dataSend, callBackHandleData);
922 }
923 }
924 };
925 if (fetchAPI) {
926 optionDefault.load = (keySearch, callbackTom) => {
927 const selectedOptions = Array.from(elTomSelect.selectedOptions);
928 const selectedValues = selectedOptions.map(option => option.value);
929 dataSend.id_not_in = selectedValues.join(',');
930 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
931 };
932 }
933 options = {
934 ...optionDefault,
935 ...options
936 };
937 const items_selected = options.options;
938 /*if ( options?.options?.length > 20 ) {
939 const chunkSize = 20;
940 const length = options.options.length;
941 let i = 0;
942 const chunkedOptions = { ...options };
943 chunkedOptions.options = items_selected.slice( i, chunkSize );
944 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
945 i += chunkSize;
946 const interval = setInterval( () => {
947 if ( i > ( length - 1 ) ) {
948 clearInterval( interval );
949 }
950 const optionsSlice = items_selected.slice( i, i + chunkSize );
951 i += chunkSize;
952 tomSelect.addOptions( optionsSlice );
953 tomSelect.setValue( options.items );
954 }, 200 );
955 return tomSelect;
956 }*/
957
958 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
959 },
960 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
961 return {
962 success: response => {
963 const options = callBackHandleData.success(response);
964 callbackTom(options);
965 }
966 };
967 },
968 fetchCourses(keySearch = '', dataSend = {}, callback) {
969 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
970 dataSend.search = keySearch;
971 const params = {
972 headers: {
973 'Content-Type': 'application/json',
974 'X-WP-Nonce': lpDataAdmin.nonce
975 },
976 method: 'POST',
977 body: JSON.stringify(dataSend)
978 };
979 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
980 },
981 fetchUsers(keySearch = '', dataSend = {}, callback) {
982 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
983 dataSend.search = keySearch;
984 const params = {
985 headers: {
986 'Content-Type': 'application/json',
987 'X-WP-Nonce': lpDataAdmin.nonce
988 },
989 method: 'POST',
990 body: JSON.stringify(dataSend)
991 };
992 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
993 }
994 };
995
996
997 /***/ },
998
999 /***/ "./assets/src/js/api.js"
1000 /*!******************************!*\
1001 !*** ./assets/src/js/api.js ***!
1002 \******************************/
1003 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1004
1005 "use strict";
1006 __webpack_require__.r(__webpack_exports__);
1007 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1008 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1009 /* harmony export */ });
1010 /**
1011 * List API on backend
1012 *
1013 * @since 4.2.6
1014 * @version 1.0.2
1015 */
1016
1017 const lplistAPI = {};
1018 let lp_rest_url;
1019 if ('undefined' !== typeof lpDataAdmin) {
1020 lp_rest_url = lpDataAdmin.lp_rest_url;
1021 lplistAPI.admin = {
1022 // apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
1023 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
1024 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
1025 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
1026 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
1027 };
1028 }
1029 if ('undefined' !== typeof lpData) {
1030 lp_rest_url = lpData.lp_rest_url;
1031 lplistAPI.frontend = {
1032 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
1033 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
1034 // Deprecated API, don't load from v4.3.7
1035 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
1036 // Deprecated since 4.3.0
1037 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
1038 };
1039 }
1040 if (lp_rest_url) {
1041 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
1042 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
1043 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
1044 }
1045 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
1046
1047 /***/ },
1048
1049 /***/ "./assets/src/js/lpPopupSelectItemToAdd.js"
1050 /*!*************************************************!*\
1051 !*** ./assets/src/js/lpPopupSelectItemToAdd.js ***!
1052 \*************************************************/
1053 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1054
1055 "use strict";
1056 __webpack_require__.r(__webpack_exports__);
1057 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1058 /* harmony export */ LpPopupSelectItemToAdd: () => (/* binding */ LpPopupSelectItemToAdd)
1059 /* harmony export */ });
1060 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
1061 /* harmony import */ var lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify.js */ "./assets/src/js/lpToastify.js");
1062 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
1063 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_2__);
1064 /**
1065 * LearnPress Popup Select Item
1066 *
1067 * Handles load(search) item from API, show in popup and select item.
1068 */
1069
1070
1071
1072
1073 let itemsSelectedData = [];
1074 let elPopup;
1075 let timeSearchTitleItem;
1076 class LpPopupSelectItemToAdd {
1077 constructor() {
1078 this.init();
1079 }
1080 static selectors = {
1081 elBtnShowPopupItemsToSelect: '.lp-btn-show-popup-items-to-select',
1082 elBtnAddItemsSelected: '.lp-btn-add-items-selected',
1083 elBtnCountItemsSelected: '.lp-btn-count-items-selected',
1084 elHeaderCountItemSelected: '.header-count-items-selected',
1085 elSelectItem: '.lp-select-item',
1086 elListItems: '.list-items',
1087 elPopupItemsToSelect: '.lp-popup-items-to-select',
1088 elSearchTitleItem: '.lp-search-title-item',
1089 elBtnBackListItems: '.lp-btn-back-to-select-items',
1090 elListItemsWrap: '.list-items-wrap',
1091 elListItemsSelected: '.list-items-selected',
1092 elItemSelectedClone: '.li-item-selected.clone',
1093 elItemSelected: '.li-item-selected',
1094 LPTarget: '.lp-target'
1095 };
1096 init() {
1097 this.events();
1098 }
1099 events = () => {
1100 if (LpPopupSelectItemToAdd._loadedEvents) {
1101 return;
1102 }
1103 LpPopupSelectItemToAdd._loadedEvents = true;
1104 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('click', [{
1105 selector: LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect,
1106 callBack: this.showPopupItemsToSelect.name,
1107 class: this
1108 }, {
1109 selector: LpPopupSelectItemToAdd.selectors.elSelectItem,
1110 callBack: this.selectItemsFromList.name,
1111 class: this
1112 }, {
1113 selector: LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected,
1114 callBack: this.showItemsSelected.name,
1115 class: this
1116 }, {
1117 selector: LpPopupSelectItemToAdd.selectors.elBtnBackListItems,
1118 callBack: this.backToSelectItems.name,
1119 class: this
1120 }, {
1121 selector: LpPopupSelectItemToAdd.selectors.elItemSelected,
1122 callBack: this.removeItemSelected.name,
1123 class: this
1124 }, {
1125 selector: '.tabs .tab',
1126 callBack: this.chooseTabItemsType.name,
1127 class: this
1128 }]);
1129 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.eventHandlers('keyup', [{
1130 selector: LpPopupSelectItemToAdd.selectors.elSearchTitleItem,
1131 callBack: this.searchTitleItemToSelect.name,
1132 class: this
1133 }]);
1134 };
1135
1136 // Show popup items to select
1137 showPopupItemsToSelect = args => {
1138 const {
1139 e,
1140 target = false,
1141 callBack
1142 } = args;
1143 const elBtnShowPopupItemsToSelect = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnShowPopupItemsToSelect}`);
1144 if (!elBtnShowPopupItemsToSelect) {
1145 return;
1146 }
1147
1148 // Reset items selected data when opening popup
1149 itemsSelectedData = [];
1150 const templateId = target.dataset.template || '';
1151 const modalTemplate = document.querySelector(templateId);
1152 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().fire({
1153 html: modalTemplate.innerHTML,
1154 showConfirmButton: false,
1155 showCloseButton: true,
1156 width: 'max(350px, 65vw)',
1157 customClass: {
1158 popup: 'lp-select-items-popup',
1159 htmlContainer: 'lp-select-items-html-container',
1160 container: 'lp-select-items-container'
1161 },
1162 willOpen: () => {
1163 elPopup = sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().getPopup();
1164 const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1165
1166 // Avoid duplicate AJAX: loadAJAX.js handles fresh elements; skip if already loaded. Set timeout to ensure DOM is ready handle.
1167 setTimeout(() => {
1168 const elLoadAjaxElement = elLPTarget.closest('.lp-load-ajax-element:not(.loaded)');
1169 if (!elLoadAjaxElement) {
1170 return;
1171 }
1172 if (elLPTarget) {
1173 const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1174 dataSend.args.paged = 1;
1175 dataSend.args.item_selecting = itemsSelectedData || [];
1176 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
1177 window.lpAJAXG.fetchAJAX(dataSend, {
1178 success: response => {
1179 const {
1180 data
1181 } = response;
1182 const elSkeleton = elPopup.querySelector('.lp-skeleton-animation');
1183 elSkeleton.remove();
1184 elLPTarget.innerHTML = data.content || '';
1185 this.watchItemsSelectedDataChange();
1186 }
1187 });
1188 }
1189 }, 1);
1190 }
1191 }).then(result => {
1192 if (result.isDismissed) {}
1193 });
1194 };
1195
1196 // Choose tab items type
1197 chooseTabItemsType = args => {
1198 const {
1199 e,
1200 target,
1201 callBack
1202 } = args;
1203 const elTabType = target.closest('.tab');
1204 if (!elTabType) {
1205 return;
1206 }
1207 e.preventDefault();
1208 const elTabs = elTabType.closest('.tabs');
1209 if (!elTabs) {
1210 return;
1211 }
1212 const elSelectItemsToAdd = elTabs.closest(`${LpPopupSelectItemToAdd.selectors.elPopupItemsToSelect}`);
1213 const elInputSearch = elSelectItemsToAdd.querySelector(`${LpPopupSelectItemToAdd.selectors.elSearchTitleItem}`);
1214 const itemType = elTabType.dataset.type;
1215 const elTabLis = elTabs.querySelectorAll('.tab');
1216 elTabLis.forEach(elTabLi => {
1217 if (elTabLi.classList.contains('active')) {
1218 elTabLi.classList.remove('active');
1219 }
1220 });
1221 elTabType.classList.add('active');
1222 // Reset search input
1223 elInputSearch.value = '';
1224 const elLPTarget = elSelectItemsToAdd.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1225 const dataSend = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1226 dataSend.args.item_type = itemType;
1227 dataSend.args.paged = 1;
1228 dataSend.args.item_selecting = itemsSelectedData || [];
1229 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSend);
1230 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1231 window.lpAJAXG.fetchAJAX(dataSend, {
1232 success: response => {
1233 const {
1234 data
1235 } = response;
1236 elLPTarget.innerHTML = data.content || '';
1237 },
1238 error: error => {
1239 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
1240 },
1241 completed: () => {
1242 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1243 this.watchItemsSelectedDataChange();
1244 }
1245 });
1246 };
1247
1248 // Choice items to add list items selected before adding to section
1249 selectItemsFromList = args => {
1250 const {
1251 e,
1252 target
1253 } = args;
1254 const elItemAttend = target.closest(`${LpPopupSelectItemToAdd.selectors.elSelectItem}`);
1255 if (!elItemAttend) {
1256 return;
1257 }
1258 const elInput = elItemAttend.querySelector('input[type="checkbox"]');
1259 if (target.tagName !== 'INPUT') {
1260 elInput.click();
1261 return;
1262 }
1263 const elUl = elItemAttend.closest(`${LpPopupSelectItemToAdd.selectors.elListItems}`);
1264 if (!elUl) {
1265 return;
1266 }
1267 const itemSelected = {
1268 ...elInput.dataset
1269 };
1270 //console.log( 'itemSelected', itemSelected );
1271
1272 if (elInput.checked) {
1273 const exists = itemsSelectedData.some(item => item.id === itemSelected.id);
1274 if (!exists) {
1275 itemsSelectedData.push(itemSelected);
1276 }
1277 } else {
1278 const index = itemsSelectedData.findIndex(item => item.id === itemSelected.id);
1279 if (index !== -1) {
1280 itemsSelectedData.splice(index, 1);
1281 }
1282 }
1283 this.watchItemsSelectedDataChange();
1284 };
1285
1286 // Search title item
1287 searchTitleItemToSelect = args => {
1288 const {
1289 e,
1290 target
1291 } = args;
1292 const elInputSearch = target.closest(LpPopupSelectItemToAdd.selectors.elSearchTitleItem);
1293 if (!elInputSearch) {
1294 return;
1295 }
1296 const elLPTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1297 clearTimeout(timeSearchTitleItem);
1298 timeSearchTitleItem = setTimeout(() => {
1299 const dataSet = window.lpAJAXG.getDataSetCurrent(elLPTarget);
1300 dataSet.args.search_title = elInputSearch.value.trim();
1301 dataSet.args.item_selecting = itemsSelectedData;
1302 dataSet.args.paged = 1;
1303 window.lpAJAXG.setDataSetCurrent(elLPTarget, dataSet);
1304
1305 // Show loading
1306 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1307 window.lpAJAXG.fetchAJAX(dataSet, {
1308 success: response => {
1309 const {
1310 data
1311 } = response;
1312 elLPTarget.innerHTML = data.content || '';
1313 },
1314 error: error => {
1315 lpAssetsJsPath_lpToastify_js__WEBPACK_IMPORTED_MODULE_1__.show(error, 'error');
1316 },
1317 completed: () => {
1318 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1319 }
1320 });
1321 }, 800);
1322 };
1323
1324 // Show list of items, to choose items to add to section
1325 showItemsSelected = args => {
1326 const {
1327 e,
1328 target
1329 } = args;
1330 const elBtnCountItemsSelected = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1331 if (!elBtnCountItemsSelected) {
1332 return;
1333 }
1334 const elBtnBack = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnBackListItems}`);
1335 const elTabs = elPopup.querySelector('.tabs');
1336 const elListItemsWrap = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsWrap}`);
1337 const elHeaderItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1338 const elListItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsSelected}`);
1339 const elItemClone = elListItemsSelected.querySelector(`${LpPopupSelectItemToAdd.selectors.elItemSelectedClone}`);
1340 elHeaderItemsSelected.innerHTML = elBtnCountItemsSelected.innerHTML;
1341 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsWrap, 0);
1342 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnCountItemsSelected, 0);
1343 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elTabs, 0);
1344 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnBack, 1);
1345 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elHeaderItemsSelected, 1);
1346 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsSelected, 1);
1347 elListItemsSelected.querySelectorAll(`${LpPopupSelectItemToAdd.selectors.elItemSelected}:not(.clone)`).forEach(elItem => {
1348 elItem.remove();
1349 });
1350 itemsSelectedData.forEach(item => {
1351 const elItemSelected = elItemClone.cloneNode(true);
1352 elItemSelected.classList.remove('clone');
1353 Object.entries(item).forEach(([key, value]) => {
1354 elItemSelected.dataset[key] = value;
1355 });
1356 const elTitleDisplay = elItemSelected.querySelector('.title-display');
1357 elTitleDisplay.innerHTML = item.title;
1358 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elItemSelected, 1);
1359 elItemClone.insertAdjacentElement('beforebegin', elItemSelected);
1360 });
1361 };
1362
1363 // Back to list of items
1364 backToSelectItems = args => {
1365 const {
1366 e,
1367 target
1368 } = args;
1369 const elBtnBack = target.closest(`${LpPopupSelectItemToAdd.selectors.elBtnBackListItems}`);
1370 if (!elBtnBack) {
1371 return;
1372 }
1373 const elBtnCountItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1374 const elTabs = elPopup.querySelector('.tabs');
1375 const elListItemsWrap = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsWrap}`);
1376 const elHeaderCountItemSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1377 const elListItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItemsSelected}`);
1378 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnCountItemsSelected, 1);
1379 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsWrap, 1);
1380 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elTabs, 1);
1381 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elBtnBack, 0);
1382 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elHeaderCountItemSelected, 0);
1383 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpShowHideEl(elListItemsSelected, 0);
1384 };
1385
1386 // Remove item selected from list items selected
1387 removeItemSelected = args => {
1388 const {
1389 e,
1390 target
1391 } = args;
1392 const elRemoveItemSelected = target.closest(`${LpPopupSelectItemToAdd.selectors.elItemSelected}`);
1393 if (!elRemoveItemSelected) {
1394 return;
1395 }
1396 const itemRemove = elRemoveItemSelected.dataset;
1397 const index = itemsSelectedData.findIndex(item => item.id === itemRemove.id);
1398 if (index !== -1) {
1399 itemsSelectedData.splice(index, 1);
1400 }
1401 elRemoveItemSelected.remove();
1402 this.watchItemsSelectedDataChange();
1403 };
1404
1405 // Watch items selected when data change
1406 watchItemsSelectedDataChange = () => {
1407 // Update count items selected, disable/enable buttons
1408 const elBtnAddItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnAddItemsSelected}`);
1409 const elBtnCountItemsSelected = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elBtnCountItemsSelected}`);
1410 const elSpanCount = elBtnCountItemsSelected.querySelector('span');
1411 const elHeaderCount = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elHeaderCountItemSelected}`);
1412 const elTarget = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.LPTarget}`);
1413 if (itemsSelectedData.length !== 0) {
1414 elBtnCountItemsSelected.disabled = false;
1415 elBtnAddItemsSelected.disabled = false;
1416 elBtnAddItemsSelected.classList.add('active');
1417 elSpanCount.textContent = `(${itemsSelectedData.length})`;
1418 elHeaderCount.innerHTML = elBtnCountItemsSelected.innerHTML;
1419 } else {
1420 elBtnCountItemsSelected.disabled = true;
1421 elBtnAddItemsSelected.disabled = true;
1422 elBtnAddItemsSelected.classList.remove('active');
1423 elSpanCount.textContent = '';
1424 elHeaderCount.textContent = '';
1425 }
1426
1427 // Update list input checked, when items removed, or change tab type
1428 const elListItems = elPopup.querySelector(`${LpPopupSelectItemToAdd.selectors.elListItems}`);
1429 const elInputs = elListItems.querySelectorAll('input[type="checkbox"]');
1430 elInputs.forEach(elInputItem => {
1431 const itemSelected = elInputItem.dataset;
1432 const exists = itemsSelectedData.some(item => item.id === itemSelected.id);
1433 elInputItem.checked = exists;
1434 });
1435
1436 // Set item selecting data to dataset for query.
1437 const dataSet = window.lpAJAXG.getDataSetCurrent(elTarget);
1438 dataSet.args.item_selecting = itemsSelectedData;
1439 window.lpAJAXG.setDataSetCurrent(elTarget, dataSet);
1440 };
1441
1442 // Add items selected to section
1443 addItemsSelectedToSection = args => {
1444 const {
1445 e,
1446 target,
1447 callBackHandle
1448 } = args;
1449 if (!elPopup) {
1450 return;
1451 }
1452 sweetalert2__WEBPACK_IMPORTED_MODULE_2___default().close();
1453 if (typeof callBackHandle === 'function') {
1454 callBackHandle(itemsSelectedData);
1455 itemsSelectedData = [];
1456 }
1457 };
1458 }
1459
1460 /***/ },
1461
1462 /***/ "./assets/src/js/lpToastify.js"
1463 /*!*************************************!*\
1464 !*** ./assets/src/js/lpToastify.js ***!
1465 \*************************************/
1466 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1467
1468 "use strict";
1469 __webpack_require__.r(__webpack_exports__);
1470 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1471 /* harmony export */ show: () => (/* binding */ show)
1472 /* harmony export */ });
1473 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
1474 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
1475 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
1476 /**
1477 * Utils functions
1478 *
1479 * @param url
1480 * @param data
1481 * @param functions
1482 * @since 4.3.0
1483 * @version 1.0.0
1484 */
1485
1486
1487 const argsToastify = {
1488 text: '',
1489 gravity: lpData.toast.gravity,
1490 // `top` or `bottom`
1491 position: lpData.toast.position,
1492 // `left`, `center` or `right`
1493 className: `${lpData.toast.classPrefix}`,
1494 close: lpData.toast.close == 1,
1495 stopOnFocus: lpData.toast.stopOnFocus == 1,
1496 duration: lpData.toast.duration
1497 };
1498 const show = (message, status = 'success', argsCustom) => {
1499 let args = argsToastify;
1500 if (argsCustom) {
1501 args = {
1502 ...args,
1503 ...argsCustom
1504 };
1505 }
1506 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
1507 ...args,
1508 text: message,
1509 className: `${lpData.toast.classPrefix} ${status}`
1510 });
1511 toastify.showToast();
1512 };
1513
1514 /***/ },
1515
1516 /***/ "./assets/src/js/utils.js"
1517 /*!********************************!*\
1518 !*** ./assets/src/js/utils.js ***!
1519 \********************************/
1520 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1521
1522 "use strict";
1523 __webpack_require__.r(__webpack_exports__);
1524 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1525 /* harmony export */ debounce: () => (/* binding */ debounce),
1526 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
1527 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
1528 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
1529 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
1530 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
1531 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
1532 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
1533 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
1534 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
1535 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
1536 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
1537 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1538 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1539 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1540 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1541 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
1542 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
1543 /* harmony export */ });
1544 /**
1545 * Utils functions
1546 *
1547 * @param url
1548 * @param data
1549 * @param functions
1550 * @since 4.2.5.1
1551 * @version 1.0.7
1552 */
1553 const lpClassName = {
1554 hidden: 'lp-hidden',
1555 loading: 'loading',
1556 elCollapse: 'lp-collapse',
1557 elSectionToggle: '.lp-section-toggle',
1558 elTriggerToggle: '.lp-trigger-toggle',
1559 elBtnFullScreen: '.lp-btn-full-screen-view',
1560 elFullScreen: 'lp-full-screen-view',
1561 elBtnFullScreenClose: 'lp-full-screen-view__close'
1562 };
1563 const lpFetchAPI = (url, data = {}, functions = {}) => {
1564 if ('function' === typeof functions.before) {
1565 functions.before();
1566 }
1567 fetch(url, {
1568 method: 'GET',
1569 ...data
1570 }).then(response => response.json()).then(response => {
1571 if ('function' === typeof functions.success) {
1572 functions.success(response);
1573 }
1574 }).catch(err => {
1575 if ('function' === typeof functions.error) {
1576 functions.error(err);
1577 }
1578 }).finally(() => {
1579 if ('function' === typeof functions.completed) {
1580 functions.completed();
1581 }
1582 });
1583 };
1584
1585 /**
1586 * Get current URL without params.
1587 *
1588 * @since 4.2.5.1
1589 */
1590 const lpGetCurrentURLNoParam = () => {
1591 let currentUrl = window.location.href;
1592 const hasParams = currentUrl.includes('?');
1593 if (hasParams) {
1594 currentUrl = currentUrl.split('?')[0];
1595 }
1596 return currentUrl;
1597 };
1598 const lpAddQueryArgs = (endpoint, args) => {
1599 const url = new URL(endpoint);
1600 Object.keys(args).forEach(arg => {
1601 url.searchParams.set(arg, args[arg]);
1602 });
1603 return url;
1604 };
1605
1606 /**
1607 * Listen element viewed.
1608 *
1609 * @param el
1610 * @param callback
1611 * @since 4.2.5.8
1612 */
1613 const listenElementViewed = (el, callback) => {
1614 const observerSeeItem = new IntersectionObserver(function (entries) {
1615 for (const entry of entries) {
1616 if (entry.isIntersecting) {
1617 callback(entry);
1618 }
1619 }
1620 });
1621 observerSeeItem.observe(el);
1622 };
1623
1624 /**
1625 * Listen element created.
1626 *
1627 * @param callback
1628 * @since 4.2.5.8
1629 */
1630 const listenElementCreated = callback => {
1631 const observerCreateItem = new MutationObserver(function (mutations) {
1632 mutations.forEach(function (mutation) {
1633 if (mutation.addedNodes) {
1634 mutation.addedNodes.forEach(function (node) {
1635 if (node.nodeType === 1) {
1636 callback(node);
1637 }
1638 });
1639 }
1640 });
1641 });
1642 observerCreateItem.observe(document, {
1643 childList: true,
1644 subtree: true
1645 });
1646 // End.
1647 };
1648
1649 /**
1650 * Listen element created.
1651 *
1652 * @param selector
1653 * @param callback
1654 * @since 4.2.7.1
1655 */
1656 const lpOnElementReady = (selector, callback) => {
1657 const element = document.querySelector(selector);
1658 if (element) {
1659 callback(element);
1660 return;
1661 }
1662 const observer = new MutationObserver((mutations, obs) => {
1663 const element = document.querySelector(selector);
1664 if (element) {
1665 obs.disconnect();
1666 callback(element);
1667 }
1668 });
1669 observer.observe(document.documentElement, {
1670 childList: true,
1671 subtree: true
1672 });
1673 };
1674
1675 // Parse JSON from string with content include LP_AJAX_START.
1676 const lpAjaxParseJsonOld = data => {
1677 if (typeof data !== 'string') {
1678 return data;
1679 }
1680 const m = String.raw({
1681 raw: data
1682 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1683 try {
1684 if (m) {
1685 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1686 } else {
1687 data = JSON.parse(data);
1688 }
1689 } catch (e) {
1690 data = {};
1691 }
1692 return data;
1693 };
1694
1695 // status 0: hide, 1: show
1696 const lpShowHideEl = (el, status = 0) => {
1697 if (!el) {
1698 return;
1699 }
1700 if (!status) {
1701 el.classList.add(lpClassName.hidden);
1702 } else {
1703 el.classList.remove(lpClassName.hidden);
1704 }
1705 };
1706
1707 // status 0: hide, 1: show
1708 const lpSetLoadingEl = (el, status) => {
1709 if (!el) {
1710 return;
1711 }
1712 if (!status) {
1713 el.classList.remove(lpClassName.loading);
1714 } else {
1715 el.classList.add(lpClassName.loading);
1716 }
1717 };
1718
1719 // Toggle collapse section
1720 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1721 if (!elTriggerClassName) {
1722 elTriggerClassName = lpClassName.elTriggerToggle;
1723 }
1724
1725 // Exclude elements, which should not trigger the collapse toggle
1726 if (elsExclude && elsExclude.length > 0) {
1727 for (const elExclude of elsExclude) {
1728 if (target.closest(elExclude)) {
1729 return;
1730 }
1731 }
1732 }
1733 const elTrigger = target.closest(elTriggerClassName);
1734 if (!elTrigger) {
1735 return;
1736 }
1737
1738 //console.log( 'elTrigger', elTrigger );
1739
1740 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1741 if (!elSectionToggle) {
1742 return;
1743 }
1744 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1745 if ('function' === typeof callback) {
1746 callback(elSectionToggle);
1747 }
1748 };
1749
1750 // Get data of form
1751 const getDataOfForm = form => {
1752 const dataSend = {};
1753 const formData = new FormData(form);
1754 for (const pair of formData.entries()) {
1755 const key = pair[0];
1756 const value = formData.getAll(key);
1757 if (!dataSend.hasOwnProperty(key)) {
1758 // Convert value array to string.
1759 dataSend[key] = value.join(',');
1760 }
1761 }
1762 return dataSend;
1763 };
1764
1765 // Get field keys of form
1766 const getFieldKeysOfForm = form => {
1767 const keys = [];
1768 const elements = form.elements;
1769 for (let i = 0; i < elements.length; i++) {
1770 const name = elements[i].name;
1771 if (name && !keys.includes(name)) {
1772 keys.push(name);
1773 }
1774 }
1775 return keys;
1776 };
1777
1778 // Merge data handle with data form.
1779 const mergeDataWithDatForm = (elForm, dataHandle) => {
1780 const dataForm = getDataOfForm(elForm);
1781 const keys = getFieldKeysOfForm(elForm);
1782 keys.forEach(key => {
1783 if (!dataForm.hasOwnProperty(key)) {
1784 delete dataHandle[key];
1785 } else if (dataForm[key][0] === '') {
1786 delete dataForm[key];
1787 delete dataHandle[key];
1788 }
1789 });
1790 dataHandle = {
1791 ...dataHandle,
1792 ...dataForm
1793 };
1794 return dataHandle;
1795 };
1796
1797 /**
1798 * Event trigger
1799 * For each list of event handlers, listen event on document.
1800 *
1801 * eventName: 'click', 'change', ...
1802 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1803 *
1804 * @param eventName
1805 * @param eventHandlers
1806 */
1807 const eventHandlers = (eventName, eventHandlers) => {
1808 document.addEventListener(eventName, e => {
1809 const target = e.target;
1810 let args = {
1811 e,
1812 target
1813 };
1814 eventHandlers.forEach(eventHandler => {
1815 args = {
1816 ...args,
1817 ...eventHandler
1818 };
1819
1820 //console.log( args );
1821
1822 // Check condition before call back
1823 if (eventHandler.conditionBeforeCallBack) {
1824 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1825 return;
1826 }
1827 }
1828
1829 // Special check for keydown event with checkIsEventEnter = true
1830 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1831 if (e.key !== 'Enter') {
1832 return;
1833 }
1834 }
1835 if (target.closest(eventHandler.selector)) {
1836 if (eventHandler.class) {
1837 // Call method of class, function callBack will understand exactly {this} is class object.
1838 eventHandler.class[eventHandler.callBack](args);
1839 } else {
1840 // For send args is objected, {this} is eventHandler object, not class object.
1841 eventHandler.callBack(args);
1842 }
1843 }
1844 });
1845 });
1846 };
1847
1848 /**
1849 * Debounce - delays function execution until after `wait` ms of inactivity.
1850 *
1851 * Each call resets the timer. Only the last call in a burst executes.
1852 *
1853 * USE CASES:
1854 * - Search inputs, form validation, window resize
1855 * - Multiple elements need independent timers
1856 * - When you need to call with different arguments
1857 *
1858 * EXAMPLES:
1859 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1860 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1861 *
1862 * const debouncedResize = debounce( recalculateLayout, 250 );
1863 * window.addEventListener('resize', debouncedResize);
1864 *
1865 * ⚠️ Create ONCE outside event handlers, not inside.
1866 *
1867 * @param {Function} func - Function to debounce (can be anonymous)
1868 * @param {number} wait - Milliseconds to wait (default: 500)
1869 * @return {Function} Debounced wrapper function
1870 * @since 4.3.7
1871 * @version 1.0.0
1872 */
1873 const debounce = (func, wait = 500) => {
1874 let timer;
1875 return args => {
1876 clearTimeout(timer);
1877 timer = setTimeout(() => func(args), wait);
1878 };
1879 };
1880
1881 /**
1882 * Initialize lp-toggle-enable components.
1883 *
1884 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1885 * Reads initial state from `data-enabled` attribute ("true"/"false").
1886 * Calls `data-on-toggle` callback (if provided via options) on state change.
1887 *
1888 * HTML structure:
1889 * <label class="lp-toggle-enable" data-enabled="true">
1890 * <input type="checkbox" class="lp-toggle-enable__input" />
1891 * <span class="lp-toggle-enable__track"></span>
1892 * </label>
1893 *
1894 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1895 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1896 * @since 4.4.5
1897 * @version 1.0.0
1898 */
1899 window.lpToggleEnableInit = 0;
1900 const toggleEnable = (onToggle = null) => {
1901 if (window.lpToggleEnableInit) {
1902 return;
1903 }
1904 window.lpToggleEnableInit = 1;
1905 const selector = '.lp-toggle-enable';
1906 const updateUI = (toggle, isEnabled) => {
1907 toggle.classList.toggle('is-enabled', isEnabled);
1908 const input = toggle.querySelector('.lp-toggle-enable__input');
1909 if (input) {
1910 input.checked = isEnabled;
1911 input.value = isEnabled ? '1' : '0';
1912 }
1913 };
1914
1915 // Delegate click handling via eventHandlers.
1916 eventHandlers('click', [{
1917 selector,
1918 callBack: args => {
1919 const {
1920 e,
1921 target
1922 } = args;
1923 const toggle = target.closest(selector);
1924 if (!toggle || toggle.classList.contains('is-disabled')) {
1925 return;
1926 }
1927 e.preventDefault();
1928 const isEnabled = !toggle.classList.contains('is-enabled');
1929 updateUI(toggle, isEnabled);
1930 if ('function' === typeof onToggle) {
1931 onToggle(toggle, isEnabled);
1932 }
1933 }
1934 }]);
1935 };
1936
1937 /**
1938 * Initialize custom fullscreen view buttons.
1939 *
1940 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1941 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1942 * target element. Falls back to the button's parent element when
1943 * `data-target` is not provided.
1944 *
1945 * @since 4.4.5
1946 * @version 1.0.0
1947 */
1948 window.lpFullScreenViewInit = 0;
1949 const fullScreenView = () => {
1950 if (window.lpFullScreenViewInit) {
1951 return;
1952 }
1953 window.lpFullScreenViewInit = 1;
1954 let lastScrollY = 0;
1955 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1956 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1957 if (isFullscreen) {
1958 elTarget.classList.remove(lpClassName.elFullScreen);
1959 document.documentElement.classList.remove('lp-full-screen-active');
1960 window.scrollTo(0, lastScrollY);
1961 } else {
1962 lastScrollY = window.scrollY;
1963 elTarget.classList.add(lpClassName.elFullScreen);
1964 document.documentElement.classList.add('lp-full-screen-active');
1965 }
1966 if (!isFullscreen) {
1967 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1968 const closeButton = document.createElement('button');
1969 closeButton.type = 'button';
1970 closeButton.className = lpClassName.elBtnFullScreenClose;
1971 closeButton.setAttribute('aria-label', 'Close');
1972 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1973 closeButton.addEventListener('click', e => {
1974 e.preventDefault();
1975 lpToggleFullscreenView(elTarget);
1976 });
1977 elTarget.appendChild(closeButton);
1978 }
1979 } else {
1980 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1981 if (closeButton) {
1982 closeButton.remove();
1983 }
1984 }
1985 };
1986 eventHandlers('click', [{
1987 selector: lpClassName.elBtnFullScreen,
1988 callBack: args => {
1989 const {
1990 e,
1991 target
1992 } = args;
1993 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1994 if (!elBtnFullScreen) {
1995 console.log('No full screen button found');
1996 return;
1997 }
1998 e.preventDefault();
1999 let elTarget = null;
2000 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
2001 console.log(targetSelector);
2002 if (targetSelector) {
2003 elTarget = document.querySelector(targetSelector);
2004 }
2005 if (!elTarget) {
2006 console.log('No target element found');
2007 return;
2008 }
2009 lpToggleFullscreenView(elTarget, elBtnFullScreen);
2010 }
2011 }]);
2012 };
2013
2014 /***/ },
2015
2016 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
2017 /*!*****************************************************************************************!*\
2018 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
2019 \*****************************************************************************************/
2020 (module, __webpack_exports__, __webpack_require__) {
2021
2022 "use strict";
2023 __webpack_require__.r(__webpack_exports__);
2024 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2025 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2026 /* harmony export */ });
2027 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
2028 /* harmony import */ var _css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
2029 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
2030 /* harmony import */ var _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
2031 // Imports
2032
2033
2034 var ___CSS_LOADER_EXPORT___ = _css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
2035 // Module
2036 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
2037 * Toastify js 1.12.0
2038 * https://github.com/apvarun/toastify-js
2039 * @license MIT licensed
2040 *
2041 * Copyright (C) 2018 Varun A P
2042 */
2043
2044 .toastify {
2045 padding: 12px 20px;
2046 color: #ffffff;
2047 display: inline-block;
2048 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
2049 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
2050 background: linear-gradient(135deg, #73a5ff, #5477f5);
2051 position: fixed;
2052 opacity: 0;
2053 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
2054 border-radius: 2px;
2055 cursor: pointer;
2056 text-decoration: none;
2057 max-width: calc(50% - 20px);
2058 z-index: 2147483647;
2059 }
2060
2061 .toastify.on {
2062 opacity: 1;
2063 }
2064
2065 .toast-close {
2066 background: transparent;
2067 border: 0;
2068 color: white;
2069 cursor: pointer;
2070 font-family: inherit;
2071 font-size: 1em;
2072 opacity: 0.4;
2073 padding: 0 5px;
2074 }
2075
2076 .toastify-right {
2077 right: 15px;
2078 }
2079
2080 .toastify-left {
2081 left: 15px;
2082 }
2083
2084 .toastify-top {
2085 top: -150px;
2086 }
2087
2088 .toastify-bottom {
2089 bottom: -150px;
2090 }
2091
2092 .toastify-rounded {
2093 border-radius: 25px;
2094 }
2095
2096 .toastify-avatar {
2097 width: 1.5em;
2098 height: 1.5em;
2099 margin: -7px 5px;
2100 border-radius: 2px;
2101 }
2102
2103 .toastify-center {
2104 margin-left: auto;
2105 margin-right: auto;
2106 left: 0;
2107 right: 0;
2108 max-width: fit-content;
2109 max-width: -moz-fit-content;
2110 }
2111
2112 @media only screen and (max-width: 360px) {
2113 .toastify-right, .toastify-left {
2114 margin-left: auto;
2115 margin-right: auto;
2116 left: 0;
2117 right: 0;
2118 max-width: fit-content;
2119 }
2120 }
2121 `, "",{"version":3,"sources":["webpack://./node_modules/toastify-js/src/toastify.css"],"names":[],"mappings":"AAAA;;;;;;EAME;;AAEF;IACI,kBAAkB;IAClB,cAAc;IACd,qBAAqB;IACrB,uFAAuF;IACvF,6DAA6D;IAC7D,qDAAqD;IACrD,eAAe;IACf,UAAU;IACV,wDAAwD;IACxD,kBAAkB;IAClB,eAAe;IACf,qBAAqB;IACrB,2BAA2B;IAC3B,mBAAmB;AACvB;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,uBAAuB;IACvB,SAAS;IACT,YAAY;IACZ,eAAe;IACf,oBAAoB;IACpB,cAAc;IACd,YAAY;IACZ,cAAc;AAClB;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,UAAU;AACd;;AAEA;IACI,WAAW;AACf;;AAEA;IACI,cAAc;AAClB;;AAEA;IACI,mBAAmB;AACvB;;AAEA;IACI,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,kBAAkB;AACtB;;AAEA;IACI,iBAAiB;IACjB,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,sBAAsB;IACtB,2BAA2B;AAC/B;;AAEA;IACI;QACI,iBAAiB;QACjB,kBAAkB;QAClB,OAAO;QACP,QAAQ;QACR,sBAAsB;IAC1B;AACJ","sourcesContent":["/*!\n * Toastify js 1.12.0\n * https://github.com/apvarun/toastify-js\n * @license MIT licensed\n *\n * Copyright (C) 2018 Varun A P\n */\n\n.toastify {\n padding: 12px 20px;\n color: #ffffff;\n display: inline-block;\n box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);\n background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);\n background: linear-gradient(135deg, #73a5ff, #5477f5);\n position: fixed;\n opacity: 0;\n transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);\n border-radius: 2px;\n cursor: pointer;\n text-decoration: none;\n max-width: calc(50% - 20px);\n z-index: 2147483647;\n}\n\n.toastify.on {\n opacity: 1;\n}\n\n.toast-close {\n background: transparent;\n border: 0;\n color: white;\n cursor: pointer;\n font-family: inherit;\n font-size: 1em;\n opacity: 0.4;\n padding: 0 5px;\n}\n\n.toastify-right {\n right: 15px;\n}\n\n.toastify-left {\n left: 15px;\n}\n\n.toastify-top {\n top: -150px;\n}\n\n.toastify-bottom {\n bottom: -150px;\n}\n\n.toastify-rounded {\n border-radius: 25px;\n}\n\n.toastify-avatar {\n width: 1.5em;\n height: 1.5em;\n margin: -7px 5px;\n border-radius: 2px;\n}\n\n.toastify-center {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n max-width: -moz-fit-content;\n}\n\n@media only screen and (max-width: 360px) {\n .toastify-right, .toastify-left {\n margin-left: auto;\n margin-right: auto;\n left: 0;\n right: 0;\n max-width: fit-content;\n }\n}\n"],"sourceRoot":""}]);
2122 // Exports
2123 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
2124
2125
2126 /***/ },
2127
2128 /***/ "./node_modules/css-loader/dist/runtime/api.js"
2129 /*!*****************************************************!*\
2130 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
2131 \*****************************************************/
2132 (module) {
2133
2134 "use strict";
2135
2136
2137 /*
2138 MIT License http://www.opensource.org/licenses/mit-license.php
2139 Author Tobias Koppers @sokra
2140 */
2141 module.exports = function (cssWithMappingToString) {
2142 var list = [];
2143
2144 // return the list of modules as css string
2145 list.toString = function toString() {
2146 return this.map(function (item) {
2147 var content = "";
2148 var needLayer = typeof item[5] !== "undefined";
2149 if (item[4]) {
2150 content += "@supports (".concat(item[4], ") {");
2151 }
2152 if (item[2]) {
2153 content += "@media ".concat(item[2], " {");
2154 }
2155 if (needLayer) {
2156 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
2157 }
2158 content += cssWithMappingToString(item);
2159 if (needLayer) {
2160 content += "}";
2161 }
2162 if (item[2]) {
2163 content += "}";
2164 }
2165 if (item[4]) {
2166 content += "}";
2167 }
2168 return content;
2169 }).join("");
2170 };
2171
2172 // import a list of modules into the list
2173 list.i = function i(modules, media, dedupe, supports, layer) {
2174 if (typeof modules === "string") {
2175 modules = [[null, modules, undefined]];
2176 }
2177 var alreadyImportedModules = {};
2178 if (dedupe) {
2179 for (var k = 0; k < this.length; k++) {
2180 var id = this[k][0];
2181 if (id != null) {
2182 alreadyImportedModules[id] = true;
2183 }
2184 }
2185 }
2186 for (var _k = 0; _k < modules.length; _k++) {
2187 var item = [].concat(modules[_k]);
2188 if (dedupe && alreadyImportedModules[item[0]]) {
2189 continue;
2190 }
2191 if (typeof layer !== "undefined") {
2192 if (typeof item[5] === "undefined") {
2193 item[5] = layer;
2194 } else {
2195 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
2196 item[5] = layer;
2197 }
2198 }
2199 if (media) {
2200 if (!item[2]) {
2201 item[2] = media;
2202 } else {
2203 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
2204 item[2] = media;
2205 }
2206 }
2207 if (supports) {
2208 if (!item[4]) {
2209 item[4] = "".concat(supports);
2210 } else {
2211 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
2212 item[4] = supports;
2213 }
2214 }
2215 list.push(item);
2216 }
2217 };
2218 return list;
2219 };
2220
2221 /***/ },
2222
2223 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
2224 /*!************************************************************!*\
2225 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
2226 \************************************************************/
2227 (module) {
2228
2229 "use strict";
2230
2231
2232 module.exports = function (item) {
2233 var content = item[1];
2234 var cssMapping = item[3];
2235 if (!cssMapping) {
2236 return content;
2237 }
2238 if (typeof btoa === "function") {
2239 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
2240 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
2241 var sourceMapping = "/*# ".concat(data, " */");
2242 return [content].concat([sourceMapping]).join("\n");
2243 }
2244 return [content].join("\n");
2245 };
2246
2247 /***/ },
2248
2249 /***/ "./node_modules/toastify-js/src/toastify.css"
2250 /*!***************************************************!*\
2251 !*** ./node_modules/toastify-js/src/toastify.css ***!
2252 \***************************************************/
2253 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2254
2255 "use strict";
2256 __webpack_require__.r(__webpack_exports__);
2257 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2258 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
2259 /* harmony export */ });
2260 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! !../../style-loader/dist/runtime/injectStylesIntoStyleTag.js */ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js");
2261 /* harmony import */ var _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0__);
2262 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleDomAPI.js */ "./node_modules/style-loader/dist/runtime/styleDomAPI.js");
2263 /* harmony import */ var _style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1__);
2264 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertBySelector.js */ "./node_modules/style-loader/dist/runtime/insertBySelector.js");
2265 /* harmony import */ var _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2__);
2266 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! !../../style-loader/dist/runtime/setAttributesWithoutAttributes.js */ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js");
2267 /* harmony import */ var _style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3__);
2268 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! !../../style-loader/dist/runtime/insertStyleElement.js */ "./node_modules/style-loader/dist/runtime/insertStyleElement.js");
2269 /* harmony import */ var _style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4__);
2270 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! !../../style-loader/dist/runtime/styleTagTransform.js */ "./node_modules/style-loader/dist/runtime/styleTagTransform.js");
2271 /* harmony import */ var _style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5__);
2272 /* harmony import */ var _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./toastify.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css");
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284 var options = {};
2285
2286 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
2287 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
2288
2289 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
2290
2291 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
2292 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
2293
2294 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
2295
2296
2297
2298
2299 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_toastify_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
2300
2301
2302 /***/ },
2303
2304 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
2305 /*!****************************************************************************!*\
2306 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
2307 \****************************************************************************/
2308 (module) {
2309
2310 "use strict";
2311
2312
2313 var stylesInDOM = [];
2314 function getIndexByIdentifier(identifier) {
2315 var result = -1;
2316 for (var i = 0; i < stylesInDOM.length; i++) {
2317 if (stylesInDOM[i].identifier === identifier) {
2318 result = i;
2319 break;
2320 }
2321 }
2322 return result;
2323 }
2324 function modulesToDom(list, options) {
2325 var idCountMap = {};
2326 var identifiers = [];
2327 for (var i = 0; i < list.length; i++) {
2328 var item = list[i];
2329 var id = options.base ? item[0] + options.base : item[0];
2330 var count = idCountMap[id] || 0;
2331 var identifier = "".concat(id, " ").concat(count);
2332 idCountMap[id] = count + 1;
2333 var indexByIdentifier = getIndexByIdentifier(identifier);
2334 var obj = {
2335 css: item[1],
2336 media: item[2],
2337 sourceMap: item[3],
2338 supports: item[4],
2339 layer: item[5]
2340 };
2341 if (indexByIdentifier !== -1) {
2342 stylesInDOM[indexByIdentifier].references++;
2343 stylesInDOM[indexByIdentifier].updater(obj);
2344 } else {
2345 var updater = addElementStyle(obj, options);
2346 options.byIndex = i;
2347 stylesInDOM.splice(i, 0, {
2348 identifier: identifier,
2349 updater: updater,
2350 references: 1
2351 });
2352 }
2353 identifiers.push(identifier);
2354 }
2355 return identifiers;
2356 }
2357 function addElementStyle(obj, options) {
2358 var api = options.domAPI(options);
2359 api.update(obj);
2360 var updater = function updater(newObj) {
2361 if (newObj) {
2362 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
2363 return;
2364 }
2365 api.update(obj = newObj);
2366 } else {
2367 api.remove();
2368 }
2369 };
2370 return updater;
2371 }
2372 module.exports = function (list, options) {
2373 options = options || {};
2374 list = list || [];
2375 var lastIdentifiers = modulesToDom(list, options);
2376 return function update(newList) {
2377 newList = newList || [];
2378 for (var i = 0; i < lastIdentifiers.length; i++) {
2379 var identifier = lastIdentifiers[i];
2380 var index = getIndexByIdentifier(identifier);
2381 stylesInDOM[index].references--;
2382 }
2383 var newLastIdentifiers = modulesToDom(newList, options);
2384 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
2385 var _identifier = lastIdentifiers[_i];
2386 var _index = getIndexByIdentifier(_identifier);
2387 if (stylesInDOM[_index].references === 0) {
2388 stylesInDOM[_index].updater();
2389 stylesInDOM.splice(_index, 1);
2390 }
2391 }
2392 lastIdentifiers = newLastIdentifiers;
2393 };
2394 };
2395
2396 /***/ },
2397
2398 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
2399 /*!********************************************************************!*\
2400 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
2401 \********************************************************************/
2402 (module) {
2403
2404 "use strict";
2405
2406
2407 var memo = {};
2408
2409 /* istanbul ignore next */
2410 function getTarget(target) {
2411 if (typeof memo[target] === "undefined") {
2412 var styleTarget = document.querySelector(target);
2413
2414 // Special case to return head of iframe instead of iframe itself
2415 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
2416 try {
2417 // This will throw an exception if access to iframe is blocked
2418 // due to cross-origin restrictions
2419 styleTarget = styleTarget.contentDocument.head;
2420 } catch (e) {
2421 // istanbul ignore next
2422 styleTarget = null;
2423 }
2424 }
2425 memo[target] = styleTarget;
2426 }
2427 return memo[target];
2428 }
2429
2430 /* istanbul ignore next */
2431 function insertBySelector(insert, style) {
2432 var target = getTarget(insert);
2433 if (!target) {
2434 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
2435 }
2436 target.appendChild(style);
2437 }
2438 module.exports = insertBySelector;
2439
2440 /***/ },
2441
2442 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
2443 /*!**********************************************************************!*\
2444 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
2445 \**********************************************************************/
2446 (module) {
2447
2448 "use strict";
2449
2450
2451 /* istanbul ignore next */
2452 function insertStyleElement(options) {
2453 var element = document.createElement("style");
2454 options.setAttributes(element, options.attributes);
2455 options.insert(element, options.options);
2456 return element;
2457 }
2458 module.exports = insertStyleElement;
2459
2460 /***/ },
2461
2462 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
2463 /*!**********************************************************************************!*\
2464 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
2465 \**********************************************************************************/
2466 (module, __unused_webpack_exports, __webpack_require__) {
2467
2468 "use strict";
2469
2470
2471 /* istanbul ignore next */
2472 function setAttributesWithoutAttributes(styleElement) {
2473 var nonce = true ? __webpack_require__.nc : 0;
2474 if (nonce) {
2475 styleElement.setAttribute("nonce", nonce);
2476 }
2477 }
2478 module.exports = setAttributesWithoutAttributes;
2479
2480 /***/ },
2481
2482 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
2483 /*!***************************************************************!*\
2484 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
2485 \***************************************************************/
2486 (module) {
2487
2488 "use strict";
2489
2490
2491 /* istanbul ignore next */
2492 function apply(styleElement, options, obj) {
2493 var css = "";
2494 if (obj.supports) {
2495 css += "@supports (".concat(obj.supports, ") {");
2496 }
2497 if (obj.media) {
2498 css += "@media ".concat(obj.media, " {");
2499 }
2500 var needLayer = typeof obj.layer !== "undefined";
2501 if (needLayer) {
2502 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
2503 }
2504 css += obj.css;
2505 if (needLayer) {
2506 css += "}";
2507 }
2508 if (obj.media) {
2509 css += "}";
2510 }
2511 if (obj.supports) {
2512 css += "}";
2513 }
2514 var sourceMap = obj.sourceMap;
2515 if (sourceMap && typeof btoa !== "undefined") {
2516 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
2517 }
2518
2519 // For old IE
2520 /* istanbul ignore if */
2521 options.styleTagTransform(css, styleElement, options.options);
2522 }
2523 function removeStyleElement(styleElement) {
2524 // istanbul ignore if
2525 if (styleElement.parentNode === null) {
2526 return false;
2527 }
2528 styleElement.parentNode.removeChild(styleElement);
2529 }
2530
2531 /* istanbul ignore next */
2532 function domAPI(options) {
2533 if (typeof document === "undefined") {
2534 return {
2535 update: function update() {},
2536 remove: function remove() {}
2537 };
2538 }
2539 var styleElement = options.insertStyleElement(options);
2540 return {
2541 update: function update(obj) {
2542 apply(styleElement, options, obj);
2543 },
2544 remove: function remove() {
2545 removeStyleElement(styleElement);
2546 }
2547 };
2548 }
2549 module.exports = domAPI;
2550
2551 /***/ },
2552
2553 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
2554 /*!*********************************************************************!*\
2555 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
2556 \*********************************************************************/
2557 (module) {
2558
2559 "use strict";
2560
2561
2562 /* istanbul ignore next */
2563 function styleTagTransform(css, styleElement) {
2564 if (styleElement.styleSheet) {
2565 styleElement.styleSheet.cssText = css;
2566 } else {
2567 while (styleElement.firstChild) {
2568 styleElement.removeChild(styleElement.firstChild);
2569 }
2570 styleElement.appendChild(document.createTextNode(css));
2571 }
2572 }
2573 module.exports = styleTagTransform;
2574
2575 /***/ },
2576
2577 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
2578 /*!**********************************************************!*\
2579 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
2580 \**********************************************************/
2581 (module) {
2582
2583 /*!
2584 * sweetalert2 v11.26.17
2585 * Released under the MIT License.
2586 */
2587 (function (global, factory) {
2588 true ? module.exports = factory() :
2589 0;
2590 })(this, (function () { 'use strict';
2591
2592 function _assertClassBrand(e, t, n) {
2593 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2594 throw new TypeError("Private element is not present on this object");
2595 }
2596 function _checkPrivateRedeclaration(e, t) {
2597 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2598 }
2599 function _classPrivateFieldGet2(s, a) {
2600 return s.get(_assertClassBrand(s, a));
2601 }
2602 function _classPrivateFieldInitSpec(e, t, a) {
2603 _checkPrivateRedeclaration(e, t), t.set(e, a);
2604 }
2605 function _classPrivateFieldSet2(s, a, r) {
2606 return s.set(_assertClassBrand(s, a), r), r;
2607 }
2608
2609 const RESTORE_FOCUS_TIMEOUT = 100;
2610
2611 /** @type {GlobalState} */
2612 const globalState = {};
2613 const focusPreviousActiveElement = () => {
2614 if (globalState.previousActiveElement instanceof HTMLElement) {
2615 globalState.previousActiveElement.focus();
2616 globalState.previousActiveElement = null;
2617 } else if (document.body) {
2618 document.body.focus();
2619 }
2620 };
2621
2622 /**
2623 * Restore previous active (focused) element
2624 *
2625 * @param {boolean} returnFocus
2626 * @returns {Promise<void>}
2627 */
2628 const restoreActiveElement = returnFocus => {
2629 return new Promise(resolve => {
2630 if (!returnFocus) {
2631 return resolve();
2632 }
2633 const x = window.scrollX;
2634 const y = window.scrollY;
2635 globalState.restoreFocusTimeout = setTimeout(() => {
2636 focusPreviousActiveElement();
2637 resolve();
2638 }, RESTORE_FOCUS_TIMEOUT); // issues/900
2639
2640 window.scrollTo(x, y);
2641 });
2642 };
2643
2644 const swalPrefix = 'swal2-';
2645
2646 /**
2647 * @typedef {Record<SwalClass, string>} SwalClasses
2648 */
2649
2650 /**
2651 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
2652 * @typedef {Record<SwalIcon, string>} SwalIcons
2653 */
2654
2655 /** @type {SwalClass[]} */
2656 const classNames = ['container', 'shown', 'height-auto', 'iosfix', 'popup', 'modal', 'no-backdrop', 'no-transition', 'toast', 'toast-shown', 'show', 'hide', 'close', 'title', 'html-container', 'actions', 'confirm', 'deny', 'cancel', 'footer', 'icon', 'icon-content', 'image', 'input', 'file', 'range', 'select', 'radio', 'checkbox', 'label', 'textarea', 'inputerror', 'input-label', 'validation-message', 'progress-steps', 'active-progress-step', 'progress-step', 'progress-step-line', 'loader', 'loading', 'styled', 'top', 'top-start', 'top-end', 'top-left', 'top-right', 'center', 'center-start', 'center-end', 'center-left', 'center-right', 'bottom', 'bottom-start', 'bottom-end', 'bottom-left', 'bottom-right', 'grow-row', 'grow-column', 'grow-fullscreen', 'rtl', 'timer-progress-bar', 'timer-progress-bar-container', 'scrollbar-measure', 'icon-success', 'icon-warning', 'icon-info', 'icon-question', 'icon-error', 'draggable', 'dragging'];
2657 const swalClasses = classNames.reduce((acc, className) => {
2658 acc[className] = swalPrefix + className;
2659 return acc;
2660 }, /** @type {SwalClasses} */{});
2661
2662 /** @type {SwalIcon[]} */
2663 const icons = ['success', 'warning', 'info', 'question', 'error'];
2664 const iconTypes = icons.reduce((acc, icon) => {
2665 acc[icon] = swalPrefix + icon;
2666 return acc;
2667 }, /** @type {SwalIcons} */{});
2668
2669 const consolePrefix = 'SweetAlert2:';
2670
2671 /**
2672 * Capitalize the first letter of a string
2673 *
2674 * @param {string} str
2675 * @returns {string}
2676 */
2677 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2678
2679 /**
2680 * Standardize console warnings
2681 *
2682 * @param {string | string[]} message
2683 */
2684 const warn = message => {
2685 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2686 };
2687
2688 /**
2689 * Standardize console errors
2690 *
2691 * @param {string} message
2692 */
2693 const error = message => {
2694 console.error(`${consolePrefix} ${message}`);
2695 };
2696
2697 /**
2698 * Private global state for `warnOnce`
2699 *
2700 * @type {string[]}
2701 * @private
2702 */
2703 const previousWarnOnceMessages = [];
2704
2705 /**
2706 * Show a console warning, but only if it hasn't already been shown
2707 *
2708 * @param {string} message
2709 */
2710 const warnOnce = message => {
2711 if (!previousWarnOnceMessages.includes(message)) {
2712 previousWarnOnceMessages.push(message);
2713 warn(message);
2714 }
2715 };
2716
2717 /**
2718 * Show a one-time console warning about deprecated params/methods
2719 *
2720 * @param {string} deprecatedParam
2721 * @param {string?} useInstead
2722 */
2723 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2724 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2725 };
2726
2727 /**
2728 * If `arg` is a function, call it (with no arguments or context) and return the result.
2729 * Otherwise, just pass the value through
2730 *
2731 * @param {(() => *) | *} arg
2732 * @returns {*}
2733 */
2734 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2735
2736 /**
2737 * @param {*} arg
2738 * @returns {boolean}
2739 */
2740 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2741
2742 /**
2743 * @param {*} arg
2744 * @returns {Promise<*>}
2745 */
2746 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2747
2748 /**
2749 * @param {*} arg
2750 * @returns {boolean}
2751 */
2752 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2753
2754 /**
2755 * Gets the popup container which contains the backdrop and the popup itself.
2756 *
2757 * @returns {HTMLElement | null}
2758 */
2759 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2760
2761 /**
2762 * @param {string} selectorString
2763 * @returns {HTMLElement | null}
2764 */
2765 const elementBySelector = selectorString => {
2766 const container = getContainer();
2767 return container ? container.querySelector(selectorString) : null;
2768 };
2769
2770 /**
2771 * @param {string} className
2772 * @returns {HTMLElement | null}
2773 */
2774 const elementByClass = className => {
2775 return elementBySelector(`.${className}`);
2776 };
2777
2778 /**
2779 * @returns {HTMLElement | null}
2780 */
2781 const getPopup = () => elementByClass(swalClasses.popup);
2782
2783 /**
2784 * @returns {HTMLElement | null}
2785 */
2786 const getIcon = () => elementByClass(swalClasses.icon);
2787
2788 /**
2789 * @returns {HTMLElement | null}
2790 */
2791 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2792
2793 /**
2794 * @returns {HTMLElement | null}
2795 */
2796 const getTitle = () => elementByClass(swalClasses.title);
2797
2798 /**
2799 * @returns {HTMLElement | null}
2800 */
2801 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2802
2803 /**
2804 * @returns {HTMLElement | null}
2805 */
2806 const getImage = () => elementByClass(swalClasses.image);
2807
2808 /**
2809 * @returns {HTMLElement | null}
2810 */
2811 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2812
2813 /**
2814 * @returns {HTMLElement | null}
2815 */
2816 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2817
2818 /**
2819 * @returns {HTMLButtonElement | null}
2820 */
2821 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2822
2823 /**
2824 * @returns {HTMLButtonElement | null}
2825 */
2826 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2827
2828 /**
2829 * @returns {HTMLButtonElement | null}
2830 */
2831 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2832
2833 /**
2834 * @returns {HTMLElement | null}
2835 */
2836 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2837
2838 /**
2839 * @returns {HTMLElement | null}
2840 */
2841 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2842
2843 /**
2844 * @returns {HTMLElement | null}
2845 */
2846 const getActions = () => elementByClass(swalClasses.actions);
2847
2848 /**
2849 * @returns {HTMLElement | null}
2850 */
2851 const getFooter = () => elementByClass(swalClasses.footer);
2852
2853 /**
2854 * @returns {HTMLElement | null}
2855 */
2856 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2857
2858 /**
2859 * @returns {HTMLElement | null}
2860 */
2861 const getCloseButton = () => elementByClass(swalClasses.close);
2862
2863 // https://github.com/jkup/focusable/blob/master/index.js
2864 const focusable = `
2865 a[href],
2866 area[href],
2867 input:not([disabled]),
2868 select:not([disabled]),
2869 textarea:not([disabled]),
2870 button:not([disabled]),
2871 iframe,
2872 object,
2873 embed,
2874 [tabindex="0"],
2875 [contenteditable],
2876 audio[controls],
2877 video[controls],
2878 summary
2879 `;
2880 /**
2881 * @returns {HTMLElement[]}
2882 */
2883 const getFocusableElements = () => {
2884 const popup = getPopup();
2885 if (!popup) {
2886 return [];
2887 }
2888 /** @type {NodeListOf<HTMLElement>} */
2889 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2890 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2891 // sort according to tabindex
2892 .sort((a, b) => {
2893 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2894 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2895 if (tabindexA > tabindexB) {
2896 return 1;
2897 } else if (tabindexA < tabindexB) {
2898 return -1;
2899 }
2900 return 0;
2901 });
2902
2903 /** @type {NodeListOf<HTMLElement>} */
2904 const otherFocusableElements = popup.querySelectorAll(focusable);
2905 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2906 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2907 };
2908
2909 /**
2910 * @returns {boolean}
2911 */
2912 const isModal = () => {
2913 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2914 };
2915
2916 /**
2917 * @returns {boolean}
2918 */
2919 const isToast = () => {
2920 const popup = getPopup();
2921 if (!popup) {
2922 return false;
2923 }
2924 return hasClass(popup, swalClasses.toast);
2925 };
2926
2927 /**
2928 * @returns {boolean}
2929 */
2930 const isLoading = () => {
2931 const popup = getPopup();
2932 if (!popup) {
2933 return false;
2934 }
2935 return popup.hasAttribute('data-loading');
2936 };
2937
2938 /**
2939 * Securely set innerHTML of an element
2940 * https://github.com/sweetalert2/sweetalert2/issues/1926
2941 *
2942 * @param {HTMLElement} elem
2943 * @param {string} html
2944 */
2945 const setInnerHtml = (elem, html) => {
2946 elem.textContent = '';
2947 if (html) {
2948 const parser = new DOMParser();
2949 const parsed = parser.parseFromString(html, `text/html`);
2950 const head = parsed.querySelector('head');
2951 if (head) {
2952 Array.from(head.childNodes).forEach(child => {
2953 elem.appendChild(child);
2954 });
2955 }
2956 const body = parsed.querySelector('body');
2957 if (body) {
2958 Array.from(body.childNodes).forEach(child => {
2959 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2960 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2961 } else {
2962 elem.appendChild(child);
2963 }
2964 });
2965 }
2966 }
2967 };
2968
2969 /**
2970 * @param {HTMLElement} elem
2971 * @param {string} className
2972 * @returns {boolean}
2973 */
2974 const hasClass = (elem, className) => {
2975 if (!className) {
2976 return false;
2977 }
2978 const classList = className.split(/\s+/);
2979 for (let i = 0; i < classList.length; i++) {
2980 if (!elem.classList.contains(classList[i])) {
2981 return false;
2982 }
2983 }
2984 return true;
2985 };
2986
2987 /**
2988 * @param {HTMLElement} elem
2989 * @param {SweetAlertOptions} params
2990 */
2991 const removeCustomClasses = (elem, params) => {
2992 Array.from(elem.classList).forEach(className => {
2993 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2994 elem.classList.remove(className);
2995 }
2996 });
2997 };
2998
2999 /**
3000 * @param {HTMLElement} elem
3001 * @param {SweetAlertOptions} params
3002 * @param {string} className
3003 */
3004 const applyCustomClass = (elem, params, className) => {
3005 removeCustomClasses(elem, params);
3006 if (!params.customClass) {
3007 return;
3008 }
3009 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
3010 if (!customClass) {
3011 return;
3012 }
3013 if (typeof customClass !== 'string' && !customClass.forEach) {
3014 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
3015 return;
3016 }
3017 addClass(elem, customClass);
3018 };
3019
3020 /**
3021 * @param {HTMLElement} popup
3022 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
3023 * @returns {HTMLInputElement | null}
3024 */
3025 const getInput$1 = (popup, inputClass) => {
3026 if (!inputClass) {
3027 return null;
3028 }
3029 switch (inputClass) {
3030 case 'select':
3031 case 'textarea':
3032 case 'file':
3033 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
3034 case 'checkbox':
3035 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
3036 case 'radio':
3037 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
3038 case 'range':
3039 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
3040 default:
3041 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
3042 }
3043 };
3044
3045 /**
3046 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
3047 */
3048 const focusInput = input => {
3049 input.focus();
3050
3051 // place cursor at end of text in text input
3052 if (input.type !== 'file') {
3053 // http://stackoverflow.com/a/2345915
3054 const val = input.value;
3055 input.value = '';
3056 input.value = val;
3057 }
3058 };
3059
3060 /**
3061 * @param {HTMLElement | HTMLElement[] | null} target
3062 * @param {string | string[] | readonly string[] | undefined} classList
3063 * @param {boolean} condition
3064 */
3065 const toggleClass = (target, classList, condition) => {
3066 if (!target || !classList) {
3067 return;
3068 }
3069 if (typeof classList === 'string') {
3070 classList = classList.split(/\s+/).filter(Boolean);
3071 }
3072 classList.forEach(className => {
3073 if (Array.isArray(target)) {
3074 target.forEach(elem => {
3075 if (condition) {
3076 elem.classList.add(className);
3077 } else {
3078 elem.classList.remove(className);
3079 }
3080 });
3081 } else {
3082 if (condition) {
3083 target.classList.add(className);
3084 } else {
3085 target.classList.remove(className);
3086 }
3087 }
3088 });
3089 };
3090
3091 /**
3092 * @param {HTMLElement | HTMLElement[] | null} target
3093 * @param {string | string[] | readonly string[] | undefined} classList
3094 */
3095 const addClass = (target, classList) => {
3096 toggleClass(target, classList, true);
3097 };
3098
3099 /**
3100 * @param {HTMLElement | HTMLElement[] | null} target
3101 * @param {string | string[] | readonly string[] | undefined} classList
3102 */
3103 const removeClass = (target, classList) => {
3104 toggleClass(target, classList, false);
3105 };
3106
3107 /**
3108 * Get direct child of an element by class name
3109 *
3110 * @param {HTMLElement} elem
3111 * @param {string} className
3112 * @returns {HTMLElement | undefined}
3113 */
3114 const getDirectChildByClass = (elem, className) => {
3115 const children = Array.from(elem.children);
3116 for (let i = 0; i < children.length; i++) {
3117 const child = children[i];
3118 if (child instanceof HTMLElement && hasClass(child, className)) {
3119 return child;
3120 }
3121 }
3122 };
3123
3124 /**
3125 * @param {HTMLElement} elem
3126 * @param {string} property
3127 * @param {string | number | null | undefined} value
3128 */
3129 const applyNumericalStyle = (elem, property, value) => {
3130 if (value === `${parseInt(`${value}`)}`) {
3131 value = parseInt(value);
3132 }
3133 if (value || parseInt(`${value}`) === 0) {
3134 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
3135 } else {
3136 elem.style.removeProperty(property);
3137 }
3138 };
3139
3140 /**
3141 * @param {HTMLElement | null} elem
3142 * @param {string} display
3143 */
3144 const show = (elem, display = 'flex') => {
3145 if (!elem) {
3146 return;
3147 }
3148 elem.style.display = display;
3149 };
3150
3151 /**
3152 * @param {HTMLElement | null} elem
3153 */
3154 const hide = elem => {
3155 if (!elem) {
3156 return;
3157 }
3158 elem.style.display = 'none';
3159 };
3160
3161 /**
3162 * @param {HTMLElement | null} elem
3163 * @param {string} display
3164 */
3165 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
3166 if (!elem) {
3167 return;
3168 }
3169 new MutationObserver(() => {
3170 toggle(elem, elem.innerHTML, display);
3171 }).observe(elem, {
3172 childList: true,
3173 subtree: true
3174 });
3175 };
3176
3177 /**
3178 * @param {HTMLElement} parent
3179 * @param {string} selector
3180 * @param {string} property
3181 * @param {string} value
3182 */
3183 const setStyle = (parent, selector, property, value) => {
3184 /** @type {HTMLElement | null} */
3185 const el = parent.querySelector(selector);
3186 if (el) {
3187 el.style.setProperty(property, value);
3188 }
3189 };
3190
3191 /**
3192 * @param {HTMLElement} elem
3193 * @param {boolean | string | null | undefined} condition
3194 * @param {string} display
3195 */
3196 const toggle = (elem, condition, display = 'flex') => {
3197 if (condition) {
3198 show(elem, display);
3199 } else {
3200 hide(elem);
3201 }
3202 };
3203
3204 /**
3205 * borrowed from jquery $(elem).is(':visible') implementation
3206 *
3207 * @param {HTMLElement | null} elem
3208 * @returns {boolean}
3209 */
3210 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
3211
3212 /**
3213 * @returns {boolean}
3214 */
3215 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
3216
3217 /**
3218 * @param {HTMLElement} elem
3219 * @returns {boolean}
3220 */
3221 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
3222
3223 /**
3224 * @param {HTMLElement} element
3225 * @param {HTMLElement} stopElement
3226 * @returns {boolean}
3227 */
3228 const selfOrParentIsScrollable = (element, stopElement) => {
3229 let parent = /** @type {HTMLElement | null} */element;
3230 while (parent && parent !== stopElement) {
3231 if (isScrollable(parent)) {
3232 return true;
3233 }
3234 parent = parent.parentElement;
3235 }
3236 return false;
3237 };
3238
3239 /**
3240 * borrowed from https://stackoverflow.com/a/46352119
3241 *
3242 * @param {HTMLElement} elem
3243 * @returns {boolean}
3244 */
3245 const hasCssAnimation = elem => {
3246 const style = window.getComputedStyle(elem);
3247 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
3248 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
3249 return animDuration > 0 || transDuration > 0;
3250 };
3251
3252 /**
3253 * @param {number} timer
3254 * @param {boolean} reset
3255 */
3256 const animateTimerProgressBar = (timer, reset = false) => {
3257 const timerProgressBar = getTimerProgressBar();
3258 if (!timerProgressBar) {
3259 return;
3260 }
3261 if (isVisible$1(timerProgressBar)) {
3262 if (reset) {
3263 timerProgressBar.style.transition = 'none';
3264 timerProgressBar.style.width = '100%';
3265 }
3266 setTimeout(() => {
3267 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
3268 timerProgressBar.style.width = '0%';
3269 }, 10);
3270 }
3271 };
3272 const stopTimerProgressBar = () => {
3273 const timerProgressBar = getTimerProgressBar();
3274 if (!timerProgressBar) {
3275 return;
3276 }
3277 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
3278 timerProgressBar.style.removeProperty('transition');
3279 timerProgressBar.style.width = '100%';
3280 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
3281 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
3282 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
3283 };
3284
3285 /**
3286 * Detect Node env
3287 *
3288 * @returns {boolean}
3289 */
3290 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
3291
3292 const sweetHTML = `
3293 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
3294 <button type="button" class="${swalClasses.close}"></button>
3295 <ul class="${swalClasses['progress-steps']}"></ul>
3296 <div class="${swalClasses.icon}"></div>
3297 <img class="${swalClasses.image}" />
3298 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
3299 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
3300 <input class="${swalClasses.input}" id="${swalClasses.input}" />
3301 <input type="file" class="${swalClasses.file}" />
3302 <div class="${swalClasses.range}">
3303 <input type="range" />
3304 <output></output>
3305 </div>
3306 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
3307 <div class="${swalClasses.radio}"></div>
3308 <label class="${swalClasses.checkbox}">
3309 <input type="checkbox" id="${swalClasses.checkbox}" />
3310 <span class="${swalClasses.label}"></span>
3311 </label>
3312 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
3313 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
3314 <div class="${swalClasses.actions}">
3315 <div class="${swalClasses.loader}"></div>
3316 <button type="button" class="${swalClasses.confirm}"></button>
3317 <button type="button" class="${swalClasses.deny}"></button>
3318 <button type="button" class="${swalClasses.cancel}"></button>
3319 </div>
3320 <div class="${swalClasses.footer}"></div>
3321 <div class="${swalClasses['timer-progress-bar-container']}">
3322 <div class="${swalClasses['timer-progress-bar']}"></div>
3323 </div>
3324 </div>
3325 `.replace(/(^|\n)\s*/g, '');
3326
3327 /**
3328 * @returns {boolean}
3329 */
3330 const resetOldContainer = () => {
3331 const oldContainer = getContainer();
3332 if (!oldContainer) {
3333 return false;
3334 }
3335 oldContainer.remove();
3336 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
3337 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
3338 swalClasses['has-column']]);
3339 return true;
3340 };
3341 const resetValidationMessage$1 = () => {
3342 if (globalState.currentInstance) {
3343 globalState.currentInstance.resetValidationMessage();
3344 }
3345 };
3346 const addInputChangeListeners = () => {
3347 const popup = getPopup();
3348 if (!popup) {
3349 return;
3350 }
3351 const input = getDirectChildByClass(popup, swalClasses.input);
3352 const file = getDirectChildByClass(popup, swalClasses.file);
3353 /** @type {HTMLInputElement | null} */
3354 const range = popup.querySelector(`.${swalClasses.range} input`);
3355 /** @type {HTMLOutputElement | null} */
3356 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
3357 const select = getDirectChildByClass(popup, swalClasses.select);
3358 /** @type {HTMLInputElement | null} */
3359 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
3360 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
3361 if (input) {
3362 input.oninput = resetValidationMessage$1;
3363 }
3364 if (file) {
3365 file.onchange = resetValidationMessage$1;
3366 }
3367 if (select) {
3368 select.onchange = resetValidationMessage$1;
3369 }
3370 if (checkbox) {
3371 checkbox.onchange = resetValidationMessage$1;
3372 }
3373 if (textarea) {
3374 textarea.oninput = resetValidationMessage$1;
3375 }
3376 if (range && rangeOutput) {
3377 range.oninput = () => {
3378 resetValidationMessage$1();
3379 rangeOutput.value = range.value;
3380 };
3381 range.onchange = () => {
3382 resetValidationMessage$1();
3383 rangeOutput.value = range.value;
3384 };
3385 }
3386 };
3387
3388 /**
3389 * @param {string | HTMLElement} target
3390 * @returns {HTMLElement}
3391 */
3392 const getTarget = target => {
3393 if (typeof target === 'string') {
3394 const element = document.querySelector(target);
3395 if (!element) {
3396 throw new Error(`Target element "${target}" not found`);
3397 }
3398 return /** @type {HTMLElement} */element;
3399 }
3400 return target;
3401 };
3402
3403 /**
3404 * @param {SweetAlertOptions} params
3405 */
3406 const setupAccessibility = params => {
3407 const popup = getPopup();
3408 if (!popup) {
3409 return;
3410 }
3411 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
3412 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
3413 if (!params.toast) {
3414 popup.setAttribute('aria-modal', 'true');
3415 }
3416 };
3417
3418 /**
3419 * @param {HTMLElement} targetElement
3420 */
3421 const setupRTL = targetElement => {
3422 if (window.getComputedStyle(targetElement).direction === 'rtl') {
3423 addClass(getContainer(), swalClasses.rtl);
3424 globalState.isRTL = true;
3425 }
3426 };
3427
3428 /**
3429 * Add modal + backdrop to DOM
3430 *
3431 * @param {SweetAlertOptions} params
3432 */
3433 const init = params => {
3434 // Clean up the old popup container if it exists
3435 const oldContainerExisted = resetOldContainer();
3436 if (isNodeEnv()) {
3437 error('SweetAlert2 requires document to initialize');
3438 return;
3439 }
3440 const container = document.createElement('div');
3441 container.className = swalClasses.container;
3442 if (oldContainerExisted) {
3443 addClass(container, swalClasses['no-transition']);
3444 }
3445 setInnerHtml(container, sweetHTML);
3446 container.dataset['swal2Theme'] = params.theme;
3447 const targetElement = getTarget(params.target || 'body');
3448 targetElement.appendChild(container);
3449 if (params.topLayer) {
3450 container.setAttribute('popover', '');
3451 container.showPopover();
3452 }
3453 setupAccessibility(params);
3454 setupRTL(targetElement);
3455 addInputChangeListeners();
3456 };
3457
3458 /**
3459 * @param {HTMLElement | object | string} param
3460 * @param {HTMLElement} target
3461 */
3462 const parseHtmlToContainer = (param, target) => {
3463 // DOM element
3464 if (param instanceof HTMLElement) {
3465 target.appendChild(param);
3466 }
3467
3468 // Object
3469 else if (typeof param === 'object') {
3470 handleObject(param, target);
3471 }
3472
3473 // Plain string
3474 else if (param) {
3475 setInnerHtml(target, param);
3476 }
3477 };
3478
3479 /**
3480 * @param {object} param
3481 * @param {HTMLElement} target
3482 */
3483 const handleObject = (param, target) => {
3484 // JQuery element(s)
3485 if ('jquery' in param) {
3486 handleJqueryElem(target, param);
3487 }
3488
3489 // For other objects use their string representation
3490 else {
3491 setInnerHtml(target, param.toString());
3492 }
3493 };
3494
3495 /**
3496 * @param {HTMLElement} target
3497 * @param {any} elem
3498 */
3499 const handleJqueryElem = (target, elem) => {
3500 target.textContent = '';
3501 if (0 in elem) {
3502 for (let i = 0; i in elem; i++) {
3503 target.appendChild(elem[i].cloneNode(true));
3504 }
3505 } else {
3506 target.appendChild(elem.cloneNode(true));
3507 }
3508 };
3509
3510 /**
3511 * @param {SweetAlert} instance
3512 * @param {SweetAlertOptions} params
3513 */
3514 const renderActions = (instance, params) => {
3515 const actions = getActions();
3516 const loader = getLoader();
3517 if (!actions || !loader) {
3518 return;
3519 }
3520
3521 // Actions (buttons) wrapper
3522 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
3523 hide(actions);
3524 } else {
3525 show(actions);
3526 }
3527
3528 // Custom class
3529 applyCustomClass(actions, params, 'actions');
3530
3531 // Render all the buttons
3532 renderButtons(actions, loader, params);
3533
3534 // Loader
3535 setInnerHtml(loader, params.loaderHtml || '');
3536 applyCustomClass(loader, params, 'loader');
3537 };
3538
3539 /**
3540 * @param {HTMLElement} actions
3541 * @param {HTMLElement} loader
3542 * @param {SweetAlertOptions} params
3543 */
3544 function renderButtons(actions, loader, params) {
3545 const confirmButton = getConfirmButton();
3546 const denyButton = getDenyButton();
3547 const cancelButton = getCancelButton();
3548 if (!confirmButton || !denyButton || !cancelButton) {
3549 return;
3550 }
3551
3552 // Render buttons
3553 renderButton(confirmButton, 'confirm', params);
3554 renderButton(denyButton, 'deny', params);
3555 renderButton(cancelButton, 'cancel', params);
3556 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3557 if (params.reverseButtons) {
3558 if (params.toast) {
3559 actions.insertBefore(cancelButton, confirmButton);
3560 actions.insertBefore(denyButton, confirmButton);
3561 } else {
3562 actions.insertBefore(cancelButton, loader);
3563 actions.insertBefore(denyButton, loader);
3564 actions.insertBefore(confirmButton, loader);
3565 }
3566 }
3567 }
3568
3569 /**
3570 * @param {HTMLElement} confirmButton
3571 * @param {HTMLElement} denyButton
3572 * @param {HTMLElement} cancelButton
3573 * @param {SweetAlertOptions} params
3574 */
3575 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3576 if (!params.buttonsStyling) {
3577 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3578 return;
3579 }
3580 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3581
3582 // Apply custom background colors to action buttons
3583 if (params.confirmButtonColor) {
3584 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
3585 }
3586 if (params.denyButtonColor) {
3587 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
3588 }
3589 if (params.cancelButtonColor) {
3590 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
3591 }
3592
3593 // Apply the outline color to action buttons
3594 applyOutlineColor(confirmButton);
3595 applyOutlineColor(denyButton);
3596 applyOutlineColor(cancelButton);
3597 }
3598
3599 /**
3600 * @param {HTMLElement} button
3601 */
3602 function applyOutlineColor(button) {
3603 const buttonStyle = window.getComputedStyle(button);
3604 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3605 // If the button already has a custom outline color, no need to change it
3606 return;
3607 }
3608 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3609 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3610 }
3611
3612 /**
3613 * @param {HTMLElement} button
3614 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3615 * @param {SweetAlertOptions} params
3616 */
3617 function renderButton(button, buttonType, params) {
3618 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3619 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3620 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3621 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3622
3623 // Add buttons custom classes
3624 button.className = swalClasses[buttonType];
3625 applyCustomClass(button, params, `${buttonType}Button`);
3626 }
3627
3628 /**
3629 * @param {SweetAlert} instance
3630 * @param {SweetAlertOptions} params
3631 */
3632 const renderCloseButton = (instance, params) => {
3633 const closeButton = getCloseButton();
3634 if (!closeButton) {
3635 return;
3636 }
3637 setInnerHtml(closeButton, params.closeButtonHtml || '');
3638
3639 // Custom class
3640 applyCustomClass(closeButton, params, 'closeButton');
3641 toggle(closeButton, params.showCloseButton);
3642 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3643 };
3644
3645 /**
3646 * @param {SweetAlert} instance
3647 * @param {SweetAlertOptions} params
3648 */
3649 const renderContainer = (instance, params) => {
3650 const container = getContainer();
3651 if (!container) {
3652 return;
3653 }
3654 handleBackdropParam(container, params.backdrop);
3655 handlePositionParam(container, params.position);
3656 handleGrowParam(container, params.grow);
3657
3658 // Custom class
3659 applyCustomClass(container, params, 'container');
3660 };
3661
3662 /**
3663 * @param {HTMLElement} container
3664 * @param {SweetAlertOptions['backdrop']} backdrop
3665 */
3666 function handleBackdropParam(container, backdrop) {
3667 if (typeof backdrop === 'string') {
3668 container.style.background = backdrop;
3669 } else if (!backdrop) {
3670 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3671 }
3672 }
3673
3674 /**
3675 * @param {HTMLElement} container
3676 * @param {SweetAlertOptions['position']} position
3677 */
3678 function handlePositionParam(container, position) {
3679 if (!position) {
3680 return;
3681 }
3682 if (position in swalClasses) {
3683 addClass(container, swalClasses[position]);
3684 } else {
3685 warn('The "position" parameter is not valid, defaulting to "center"');
3686 addClass(container, swalClasses.center);
3687 }
3688 }
3689
3690 /**
3691 * @param {HTMLElement} container
3692 * @param {SweetAlertOptions['grow']} grow
3693 */
3694 function handleGrowParam(container, grow) {
3695 if (!grow) {
3696 return;
3697 }
3698 addClass(container, swalClasses[`grow-${grow}`]);
3699 }
3700
3701 /**
3702 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3703 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3704 * This is the approach that Babel will probably take to implement private methods/fields
3705 * https://github.com/tc39/proposal-private-methods
3706 * https://github.com/babel/babel/pull/7555
3707 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3708 * then we can use that language feature.
3709 */
3710
3711 var privateProps = {
3712 innerParams: new WeakMap(),
3713 domCache: new WeakMap()
3714 };
3715
3716 /// <reference path="../../../../sweetalert2.d.ts"/>
3717
3718
3719 /** @type {InputClass[]} */
3720 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3721
3722 /**
3723 * @param {SweetAlert} instance
3724 * @param {SweetAlertOptions} params
3725 */
3726 const renderInput = (instance, params) => {
3727 const popup = getPopup();
3728 if (!popup) {
3729 return;
3730 }
3731 const innerParams = privateProps.innerParams.get(instance);
3732 const rerender = !innerParams || params.input !== innerParams.input;
3733 inputClasses.forEach(inputClass => {
3734 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3735 if (!inputContainer) {
3736 return;
3737 }
3738
3739 // set attributes
3740 setAttributes(inputClass, params.inputAttributes);
3741
3742 // set class
3743 inputContainer.className = swalClasses[inputClass];
3744 if (rerender) {
3745 hide(inputContainer);
3746 }
3747 });
3748 if (params.input) {
3749 if (rerender) {
3750 showInput(params);
3751 }
3752 // set custom class
3753 setCustomClass(params);
3754 }
3755 };
3756
3757 /**
3758 * @param {SweetAlertOptions} params
3759 */
3760 const showInput = params => {
3761 if (!params.input) {
3762 return;
3763 }
3764 if (!renderInputType[params.input]) {
3765 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3766 return;
3767 }
3768 const inputContainer = getInputContainer(params.input);
3769 if (!inputContainer) {
3770 return;
3771 }
3772 const input = renderInputType[params.input](inputContainer, params);
3773 show(inputContainer);
3774
3775 // input autofocus
3776 if (params.inputAutoFocus) {
3777 setTimeout(() => {
3778 focusInput(input);
3779 });
3780 }
3781 };
3782
3783 /**
3784 * @param {HTMLInputElement} input
3785 */
3786 const removeAttributes = input => {
3787 for (let i = 0; i < input.attributes.length; i++) {
3788 const attrName = input.attributes[i].name;
3789 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
3790 input.removeAttribute(attrName);
3791 }
3792 }
3793 };
3794
3795 /**
3796 * @param {InputClass} inputClass
3797 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3798 */
3799 const setAttributes = (inputClass, inputAttributes) => {
3800 const popup = getPopup();
3801 if (!popup) {
3802 return;
3803 }
3804 const input = getInput$1(popup, inputClass);
3805 if (!input) {
3806 return;
3807 }
3808 removeAttributes(input);
3809 for (const attr in inputAttributes) {
3810 input.setAttribute(attr, inputAttributes[attr]);
3811 }
3812 };
3813
3814 /**
3815 * @param {SweetAlertOptions} params
3816 */
3817 const setCustomClass = params => {
3818 if (!params.input) {
3819 return;
3820 }
3821 const inputContainer = getInputContainer(params.input);
3822 if (inputContainer) {
3823 applyCustomClass(inputContainer, params, 'input');
3824 }
3825 };
3826
3827 /**
3828 * @param {HTMLInputElement | HTMLTextAreaElement} input
3829 * @param {SweetAlertOptions} params
3830 */
3831 const setInputPlaceholder = (input, params) => {
3832 if (!input.placeholder && params.inputPlaceholder) {
3833 input.placeholder = params.inputPlaceholder;
3834 }
3835 };
3836
3837 /**
3838 * @param {Input} input
3839 * @param {Input} prependTo
3840 * @param {SweetAlertOptions} params
3841 */
3842 const setInputLabel = (input, prependTo, params) => {
3843 if (params.inputLabel) {
3844 const label = document.createElement('label');
3845 const labelClass = swalClasses['input-label'];
3846 label.setAttribute('for', input.id);
3847 label.className = labelClass;
3848 if (typeof params.customClass === 'object') {
3849 addClass(label, params.customClass.inputLabel);
3850 }
3851 label.innerText = params.inputLabel;
3852 prependTo.insertAdjacentElement('beforebegin', label);
3853 }
3854 };
3855
3856 /**
3857 * @param {SweetAlertInput} inputType
3858 * @returns {HTMLElement | undefined}
3859 */
3860 const getInputContainer = inputType => {
3861 const popup = getPopup();
3862 if (!popup) {
3863 return;
3864 }
3865 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3866 };
3867
3868 /**
3869 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3870 * @param {SweetAlertOptions['inputValue']} inputValue
3871 */
3872 const checkAndSetInputValue = (input, inputValue) => {
3873 if (['string', 'number'].includes(typeof inputValue)) {
3874 input.value = `${inputValue}`;
3875 } else if (!isPromise(inputValue)) {
3876 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3877 }
3878 };
3879
3880 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3881 const renderInputType = {};
3882
3883 /**
3884 * @param {Input | HTMLElement} input
3885 * @param {SweetAlertOptions} params
3886 * @returns {Input}
3887 */
3888 renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = renderInputType.search = renderInputType.date = renderInputType['datetime-local'] = renderInputType.time = renderInputType.week = renderInputType.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
3889 (input, params) => {
3890 const inputElement = /** @type {HTMLInputElement} */input;
3891 checkAndSetInputValue(inputElement, params.inputValue);
3892 setInputLabel(inputElement, inputElement, params);
3893 setInputPlaceholder(inputElement, params);
3894 inputElement.type = /** @type {string} */params.input;
3895 return inputElement;
3896 };
3897
3898 /**
3899 * @param {Input | HTMLElement} input
3900 * @param {SweetAlertOptions} params
3901 * @returns {Input}
3902 */
3903 renderInputType.file = (input, params) => {
3904 const inputElement = /** @type {HTMLInputElement} */input;
3905 setInputLabel(inputElement, inputElement, params);
3906 setInputPlaceholder(inputElement, params);
3907 return inputElement;
3908 };
3909
3910 /**
3911 * @param {Input | HTMLElement} range
3912 * @param {SweetAlertOptions} params
3913 * @returns {Input}
3914 */
3915 renderInputType.range = (range, params) => {
3916 const rangeContainer = /** @type {HTMLElement} */range;
3917 const rangeInput = rangeContainer.querySelector('input');
3918 const rangeOutput = rangeContainer.querySelector('output');
3919 if (rangeInput) {
3920 checkAndSetInputValue(rangeInput, params.inputValue);
3921 rangeInput.type = /** @type {string} */params.input;
3922 setInputLabel(rangeInput, /** @type {Input} */range, params);
3923 }
3924 if (rangeOutput) {
3925 checkAndSetInputValue(rangeOutput, params.inputValue);
3926 }
3927 return /** @type {Input} */range;
3928 };
3929
3930 /**
3931 * @param {Input | HTMLElement} select
3932 * @param {SweetAlertOptions} params
3933 * @returns {Input}
3934 */
3935 renderInputType.select = (select, params) => {
3936 const selectElement = /** @type {HTMLSelectElement} */select;
3937 selectElement.textContent = '';
3938 if (params.inputPlaceholder) {
3939 const placeholder = document.createElement('option');
3940 setInnerHtml(placeholder, params.inputPlaceholder);
3941 placeholder.value = '';
3942 placeholder.disabled = true;
3943 placeholder.selected = true;
3944 selectElement.appendChild(placeholder);
3945 }
3946 setInputLabel(selectElement, selectElement, params);
3947 return selectElement;
3948 };
3949
3950 /**
3951 * @param {Input | HTMLElement} radio
3952 * @returns {Input}
3953 */
3954 renderInputType.radio = radio => {
3955 const radioElement = /** @type {HTMLElement} */radio;
3956 radioElement.textContent = '';
3957 return /** @type {Input} */radio;
3958 };
3959
3960 /**
3961 * @param {Input | HTMLElement} checkboxContainer
3962 * @param {SweetAlertOptions} params
3963 * @returns {Input}
3964 */
3965 renderInputType.checkbox = (checkboxContainer, params) => {
3966 const popup = getPopup();
3967 if (!popup) {
3968 throw new Error('Popup not found');
3969 }
3970 const checkbox = getInput$1(popup, 'checkbox');
3971 if (!checkbox) {
3972 throw new Error('Checkbox input not found');
3973 }
3974 checkbox.value = '1';
3975 checkbox.checked = Boolean(params.inputValue);
3976 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3977 const label = containerElement.querySelector('span');
3978 if (label) {
3979 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3980 if (placeholderOrLabel) {
3981 setInnerHtml(label, placeholderOrLabel);
3982 }
3983 }
3984 return checkbox;
3985 };
3986
3987 /**
3988 * @param {Input | HTMLElement} textarea
3989 * @param {SweetAlertOptions} params
3990 * @returns {Input}
3991 */
3992 renderInputType.textarea = (textarea, params) => {
3993 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3994 checkAndSetInputValue(textareaElement, params.inputValue);
3995 setInputPlaceholder(textareaElement, params);
3996 setInputLabel(textareaElement, textareaElement, params);
3997
3998 /**
3999 * @param {HTMLElement} el
4000 * @returns {number}
4001 */
4002 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
4003
4004 // https://github.com/sweetalert2/sweetalert2/issues/2291
4005 setTimeout(() => {
4006 // https://github.com/sweetalert2/sweetalert2/issues/1699
4007 if ('MutationObserver' in window) {
4008 const popup = getPopup();
4009 if (!popup) {
4010 return;
4011 }
4012 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
4013 const textareaResizeHandler = () => {
4014 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
4015 if (!document.body.contains(textareaElement)) {
4016 return;
4017 }
4018 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
4019 const popupElement = getPopup();
4020 if (popupElement) {
4021 if (textareaWidth > initialPopupWidth) {
4022 popupElement.style.width = `${textareaWidth}px`;
4023 } else {
4024 applyNumericalStyle(popupElement, 'width', params.width);
4025 }
4026 }
4027 };
4028 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
4029 attributes: true,
4030 attributeFilter: ['style']
4031 });
4032 }
4033 });
4034 return textareaElement;
4035 };
4036
4037 /**
4038 * @param {SweetAlert} instance
4039 * @param {SweetAlertOptions} params
4040 */
4041 const renderContent = (instance, params) => {
4042 const htmlContainer = getHtmlContainer();
4043 if (!htmlContainer) {
4044 return;
4045 }
4046 showWhenInnerHtmlPresent(htmlContainer);
4047 applyCustomClass(htmlContainer, params, 'htmlContainer');
4048
4049 // Content as HTML
4050 if (params.html) {
4051 parseHtmlToContainer(params.html, htmlContainer);
4052 show(htmlContainer, 'block');
4053 }
4054
4055 // Content as plain text
4056 else if (params.text) {
4057 htmlContainer.textContent = params.text;
4058 show(htmlContainer, 'block');
4059 }
4060
4061 // No content
4062 else {
4063 hide(htmlContainer);
4064 }
4065 renderInput(instance, params);
4066 };
4067
4068 /**
4069 * @param {SweetAlert} instance
4070 * @param {SweetAlertOptions} params
4071 */
4072 const renderFooter = (instance, params) => {
4073 const footer = getFooter();
4074 if (!footer) {
4075 return;
4076 }
4077 showWhenInnerHtmlPresent(footer);
4078 toggle(footer, Boolean(params.footer), 'block');
4079 if (params.footer) {
4080 parseHtmlToContainer(params.footer, footer);
4081 }
4082
4083 // Custom class
4084 applyCustomClass(footer, params, 'footer');
4085 };
4086
4087 /**
4088 * @param {SweetAlert} instance
4089 * @param {SweetAlertOptions} params
4090 */
4091 const renderIcon = (instance, params) => {
4092 const innerParams = privateProps.innerParams.get(instance);
4093 const icon = getIcon();
4094 if (!icon) {
4095 return;
4096 }
4097
4098 // if the given icon already rendered, apply the styling without re-rendering the icon
4099 if (innerParams && params.icon === innerParams.icon) {
4100 // Custom or default content
4101 setContent(icon, params);
4102 applyStyles(icon, params);
4103 return;
4104 }
4105 if (!params.icon && !params.iconHtml) {
4106 hide(icon);
4107 return;
4108 }
4109 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
4110 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
4111 hide(icon);
4112 return;
4113 }
4114 show(icon);
4115
4116 // Custom or default content
4117 setContent(icon, params);
4118 applyStyles(icon, params);
4119
4120 // Animate icon
4121 addClass(icon, params.showClass && params.showClass.icon);
4122
4123 // Re-adjust the success icon on system theme change
4124 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
4125 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
4126 };
4127
4128 /**
4129 * @param {HTMLElement} icon
4130 * @param {SweetAlertOptions} params
4131 */
4132 const applyStyles = (icon, params) => {
4133 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
4134 if (params.icon !== iconType) {
4135 removeClass(icon, iconClassName);
4136 }
4137 }
4138 addClass(icon, params.icon && iconTypes[params.icon]);
4139
4140 // Icon color
4141 setColor(icon, params);
4142
4143 // Success icon background color
4144 adjustSuccessIconBackgroundColor();
4145
4146 // Custom class
4147 applyCustomClass(icon, params, 'icon');
4148 };
4149
4150 // Adjust success icon background color to match the popup background color
4151 const adjustSuccessIconBackgroundColor = () => {
4152 const popup = getPopup();
4153 if (!popup) {
4154 return;
4155 }
4156 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
4157 /** @type {NodeListOf<HTMLElement>} */
4158 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
4159 for (let i = 0; i < successIconParts.length; i++) {
4160 successIconParts[i].style.backgroundColor = popupBackgroundColor;
4161 }
4162 };
4163
4164 /**
4165 *
4166 * @param {SweetAlertOptions} params
4167 * @returns {string}
4168 */
4169 const successIconHtml = params => `
4170 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
4171 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
4172 <div class="swal2-success-ring"></div>
4173 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
4174 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
4175 `;
4176 const errorIconHtml = `
4177 <span class="swal2-x-mark">
4178 <span class="swal2-x-mark-line-left"></span>
4179 <span class="swal2-x-mark-line-right"></span>
4180 </span>
4181 `;
4182
4183 /**
4184 * @param {HTMLElement} icon
4185 * @param {SweetAlertOptions} params
4186 */
4187 const setContent = (icon, params) => {
4188 if (!params.icon && !params.iconHtml) {
4189 return;
4190 }
4191 let oldContent = icon.innerHTML;
4192 let newContent = '';
4193 if (params.iconHtml) {
4194 newContent = iconContent(params.iconHtml);
4195 } else if (params.icon === 'success') {
4196 newContent = successIconHtml(params);
4197 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
4198 } else if (params.icon === 'error') {
4199 newContent = errorIconHtml;
4200 } else if (params.icon) {
4201 const defaultIconHtml = {
4202 question: '?',
4203 warning: '!',
4204 info: 'i'
4205 };
4206 newContent = iconContent(defaultIconHtml[params.icon]);
4207 }
4208 if (oldContent.trim() !== newContent.trim()) {
4209 setInnerHtml(icon, newContent);
4210 }
4211 };
4212
4213 /**
4214 * @param {HTMLElement} icon
4215 * @param {SweetAlertOptions} params
4216 */
4217 const setColor = (icon, params) => {
4218 if (!params.iconColor) {
4219 return;
4220 }
4221 icon.style.color = params.iconColor;
4222 icon.style.borderColor = params.iconColor;
4223 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
4224 setStyle(icon, sel, 'background-color', params.iconColor);
4225 }
4226 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
4227 };
4228
4229 /**
4230 * @param {string} content
4231 * @returns {string}
4232 */
4233 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
4234
4235 /**
4236 * @param {SweetAlert} instance
4237 * @param {SweetAlertOptions} params
4238 */
4239 const renderImage = (instance, params) => {
4240 const image = getImage();
4241 if (!image) {
4242 return;
4243 }
4244 if (!params.imageUrl) {
4245 hide(image);
4246 return;
4247 }
4248 show(image, '');
4249
4250 // Src, alt
4251 image.setAttribute('src', params.imageUrl);
4252 image.setAttribute('alt', params.imageAlt || '');
4253
4254 // Width, height
4255 applyNumericalStyle(image, 'width', params.imageWidth);
4256 applyNumericalStyle(image, 'height', params.imageHeight);
4257
4258 // Class
4259 image.className = swalClasses.image;
4260 applyCustomClass(image, params, 'image');
4261 };
4262
4263 let dragging = false;
4264 let mousedownX = 0;
4265 let mousedownY = 0;
4266 let initialX = 0;
4267 let initialY = 0;
4268
4269 /**
4270 * @param {HTMLElement} popup
4271 */
4272 const addDraggableListeners = popup => {
4273 popup.addEventListener('mousedown', down);
4274 document.body.addEventListener('mousemove', move);
4275 popup.addEventListener('mouseup', up);
4276 popup.addEventListener('touchstart', down);
4277 document.body.addEventListener('touchmove', move);
4278 popup.addEventListener('touchend', up);
4279 };
4280
4281 /**
4282 * @param {HTMLElement} popup
4283 */
4284 const removeDraggableListeners = popup => {
4285 popup.removeEventListener('mousedown', down);
4286 document.body.removeEventListener('mousemove', move);
4287 popup.removeEventListener('mouseup', up);
4288 popup.removeEventListener('touchstart', down);
4289 document.body.removeEventListener('touchmove', move);
4290 popup.removeEventListener('touchend', up);
4291 };
4292
4293 /**
4294 * @param {MouseEvent | TouchEvent} event
4295 */
4296 const down = event => {
4297 const popup = getPopup();
4298 if (!popup) {
4299 return;
4300 }
4301 const icon = getIcon();
4302 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
4303 dragging = true;
4304 const clientXY = getClientXY(event);
4305 mousedownX = clientXY.clientX;
4306 mousedownY = clientXY.clientY;
4307 initialX = parseInt(popup.style.insetInlineStart) || 0;
4308 initialY = parseInt(popup.style.insetBlockStart) || 0;
4309 addClass(popup, 'swal2-dragging');
4310 }
4311 };
4312
4313 /**
4314 * @param {MouseEvent | TouchEvent} event
4315 */
4316 const move = event => {
4317 const popup = getPopup();
4318 if (!popup) {
4319 return;
4320 }
4321 if (dragging) {
4322 let {
4323 clientX,
4324 clientY
4325 } = getClientXY(event);
4326 const deltaX = clientX - mousedownX;
4327 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
4328 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
4329 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
4330 }
4331 };
4332 const up = () => {
4333 const popup = getPopup();
4334 dragging = false;
4335 removeClass(popup, 'swal2-dragging');
4336 };
4337
4338 /**
4339 * @param {MouseEvent | TouchEvent} event
4340 * @returns {{ clientX: number, clientY: number }}
4341 */
4342 const getClientXY = event => {
4343 let clientX = 0,
4344 clientY = 0;
4345 if (event.type.startsWith('mouse')) {
4346 clientX = /** @type {MouseEvent} */event.clientX;
4347 clientY = /** @type {MouseEvent} */event.clientY;
4348 } else if (event.type.startsWith('touch')) {
4349 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
4350 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
4351 }
4352 return {
4353 clientX,
4354 clientY
4355 };
4356 };
4357
4358 /**
4359 * @param {SweetAlert} instance
4360 * @param {SweetAlertOptions} params
4361 */
4362 const renderPopup = (instance, params) => {
4363 const container = getContainer();
4364 const popup = getPopup();
4365 if (!container || !popup) {
4366 return;
4367 }
4368
4369 // Width
4370 // https://github.com/sweetalert2/sweetalert2/issues/2170
4371 if (params.toast) {
4372 applyNumericalStyle(container, 'width', params.width);
4373 popup.style.width = '100%';
4374 const loader = getLoader();
4375 if (loader) {
4376 popup.insertBefore(loader, getIcon());
4377 }
4378 } else {
4379 applyNumericalStyle(popup, 'width', params.width);
4380 }
4381
4382 // Padding
4383 applyNumericalStyle(popup, 'padding', params.padding);
4384
4385 // Color
4386 if (params.color) {
4387 popup.style.color = params.color;
4388 }
4389
4390 // Background
4391 if (params.background) {
4392 popup.style.background = params.background;
4393 }
4394 hide(getValidationMessage());
4395
4396 // Classes
4397 addClasses$1(popup, params);
4398 if (params.draggable && !params.toast) {
4399 addClass(popup, swalClasses.draggable);
4400 addDraggableListeners(popup);
4401 } else {
4402 removeClass(popup, swalClasses.draggable);
4403 removeDraggableListeners(popup);
4404 }
4405 };
4406
4407 /**
4408 * @param {HTMLElement} popup
4409 * @param {SweetAlertOptions} params
4410 */
4411 const addClasses$1 = (popup, params) => {
4412 const showClass = params.showClass || {};
4413 // Default Class + showClass when updating Swal.update({})
4414 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
4415 if (params.toast) {
4416 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
4417 addClass(popup, swalClasses.toast);
4418 } else {
4419 addClass(popup, swalClasses.modal);
4420 }
4421
4422 // Custom class
4423 applyCustomClass(popup, params, 'popup');
4424 // TODO: remove in the next major
4425 if (typeof params.customClass === 'string') {
4426 addClass(popup, params.customClass);
4427 }
4428
4429 // Icon class (#1842)
4430 if (params.icon) {
4431 addClass(popup, swalClasses[`icon-${params.icon}`]);
4432 }
4433 };
4434
4435 /**
4436 * @param {SweetAlert} instance
4437 * @param {SweetAlertOptions} params
4438 */
4439 const renderProgressSteps = (instance, params) => {
4440 const progressStepsContainer = getProgressSteps();
4441 if (!progressStepsContainer) {
4442 return;
4443 }
4444 const {
4445 progressSteps,
4446 currentProgressStep
4447 } = params;
4448 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
4449 hide(progressStepsContainer);
4450 return;
4451 }
4452 show(progressStepsContainer);
4453 progressStepsContainer.textContent = '';
4454 if (currentProgressStep >= progressSteps.length) {
4455 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
4456 }
4457 progressSteps.forEach((step, index) => {
4458 const stepEl = createStepElement(step);
4459 progressStepsContainer.appendChild(stepEl);
4460 if (index === currentProgressStep) {
4461 addClass(stepEl, swalClasses['active-progress-step']);
4462 }
4463 if (index !== progressSteps.length - 1) {
4464 const lineEl = createLineElement(params);
4465 progressStepsContainer.appendChild(lineEl);
4466 }
4467 });
4468 };
4469
4470 /**
4471 * @param {string} step
4472 * @returns {HTMLLIElement}
4473 */
4474 const createStepElement = step => {
4475 const stepEl = document.createElement('li');
4476 addClass(stepEl, swalClasses['progress-step']);
4477 setInnerHtml(stepEl, step);
4478 return stepEl;
4479 };
4480
4481 /**
4482 * @param {SweetAlertOptions} params
4483 * @returns {HTMLLIElement}
4484 */
4485 const createLineElement = params => {
4486 const lineEl = document.createElement('li');
4487 addClass(lineEl, swalClasses['progress-step-line']);
4488 if (params.progressStepsDistance) {
4489 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
4490 }
4491 return lineEl;
4492 };
4493
4494 /**
4495 * @param {SweetAlert} instance
4496 * @param {SweetAlertOptions} params
4497 */
4498 const renderTitle = (instance, params) => {
4499 const title = getTitle();
4500 if (!title) {
4501 return;
4502 }
4503 showWhenInnerHtmlPresent(title);
4504 toggle(title, Boolean(params.title || params.titleText), 'block');
4505 if (params.title) {
4506 parseHtmlToContainer(params.title, title);
4507 }
4508 if (params.titleText) {
4509 title.innerText = params.titleText;
4510 }
4511
4512 // Custom class
4513 applyCustomClass(title, params, 'title');
4514 };
4515
4516 /**
4517 * @param {SweetAlert} instance
4518 * @param {SweetAlertOptions} params
4519 */
4520 const render = (instance, params) => {
4521 var _globalState$eventEmi;
4522 renderPopup(instance, params);
4523 renderContainer(instance, params);
4524 renderProgressSteps(instance, params);
4525 renderIcon(instance, params);
4526 renderImage(instance, params);
4527 renderTitle(instance, params);
4528 renderCloseButton(instance, params);
4529 renderContent(instance, params);
4530 renderActions(instance, params);
4531 renderFooter(instance, params);
4532 const popup = getPopup();
4533 if (typeof params.didRender === 'function' && popup) {
4534 params.didRender(popup);
4535 }
4536 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
4537 };
4538
4539 /*
4540 * Global function to determine if SweetAlert2 popup is shown
4541 */
4542 const isVisible = () => {
4543 return isVisible$1(getPopup());
4544 };
4545
4546 /*
4547 * Global function to click 'Confirm' button
4548 */
4549 const clickConfirm = () => {
4550 var _dom$getConfirmButton;
4551 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
4552 };
4553
4554 /*
4555 * Global function to click 'Deny' button
4556 */
4557 const clickDeny = () => {
4558 var _dom$getDenyButton;
4559 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
4560 };
4561
4562 /*
4563 * Global function to click 'Cancel' button
4564 */
4565 const clickCancel = () => {
4566 var _dom$getCancelButton;
4567 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4568 };
4569
4570 /** @type {Record<DismissReason, DismissReason>} */
4571 const DismissReason = Object.freeze({
4572 cancel: 'cancel',
4573 backdrop: 'backdrop',
4574 close: 'close',
4575 esc: 'esc',
4576 timer: 'timer'
4577 });
4578
4579 /**
4580 * @param {GlobalState} globalState
4581 */
4582 const removeKeydownHandler = globalState => {
4583 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4584 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
4585 globalState.keydownTarget.removeEventListener('keydown', handler, {
4586 capture: globalState.keydownListenerCapture
4587 });
4588 globalState.keydownHandlerAdded = false;
4589 }
4590 };
4591
4592 /**
4593 * @param {GlobalState} globalState
4594 * @param {SweetAlertOptions} innerParams
4595 * @param {(dismiss: DismissReason) => void} dismissWith
4596 */
4597 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4598 removeKeydownHandler(globalState);
4599 if (!innerParams.toast) {
4600 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4601 const handler = e => keydownHandler(innerParams, e, dismissWith);
4602 globalState.keydownHandler = handler;
4603 const target = innerParams.keydownListenerCapture ? window : getPopup();
4604 if (target) {
4605 globalState.keydownTarget = target;
4606 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4607 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4608 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4609 capture: globalState.keydownListenerCapture
4610 });
4611 globalState.keydownHandlerAdded = true;
4612 }
4613 }
4614 };
4615
4616 /**
4617 * @param {number} index
4618 * @param {number} increment
4619 */
4620 const setFocus = (index, increment) => {
4621 var _dom$getPopup;
4622 const focusableElements = getFocusableElements();
4623 // search for visible elements and select the next possible match
4624 if (focusableElements.length) {
4625 index = index + increment;
4626
4627 // shift + tab when .swal2-popup is focused
4628 if (index === -2) {
4629 index = focusableElements.length - 1;
4630 }
4631
4632 // rollover to first item
4633 if (index === focusableElements.length) {
4634 index = 0;
4635
4636 // go to last item
4637 } else if (index === -1) {
4638 index = focusableElements.length - 1;
4639 }
4640 focusableElements[index].focus();
4641 return;
4642 }
4643 // no visible focusable elements, focus the popup
4644 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4645 };
4646 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4647 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4648
4649 /**
4650 * @param {SweetAlertOptions} innerParams
4651 * @param {KeyboardEvent} event
4652 * @param {(dismiss: DismissReason) => void} dismissWith
4653 */
4654 const keydownHandler = (innerParams, event, dismissWith) => {
4655 if (!innerParams) {
4656 return; // This instance has already been destroyed
4657 }
4658
4659 // Ignore keydown during IME composition
4660 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4661 // https://github.com/sweetalert2/sweetalert2/issues/720
4662 // https://github.com/sweetalert2/sweetalert2/issues/2406
4663 if (event.isComposing || event.keyCode === 229) {
4664 return;
4665 }
4666 if (innerParams.stopKeydownPropagation) {
4667 event.stopPropagation();
4668 }
4669
4670 // ENTER
4671 if (event.key === 'Enter') {
4672 handleEnter(event, innerParams);
4673 }
4674
4675 // TAB
4676 else if (event.key === 'Tab') {
4677 handleTab(event);
4678 }
4679
4680 // ARROWS - switch focus between buttons
4681 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4682 handleArrows(event.key);
4683 }
4684
4685 // ESC
4686 else if (event.key === 'Escape') {
4687 handleEsc(event, innerParams, dismissWith);
4688 }
4689 };
4690
4691 /**
4692 * @param {KeyboardEvent} event
4693 * @param {SweetAlertOptions} innerParams
4694 */
4695 const handleEnter = (event, innerParams) => {
4696 // https://github.com/sweetalert2/sweetalert2/issues/2386
4697 if (!callIfFunction(innerParams.allowEnterKey)) {
4698 return;
4699 }
4700 const popup = getPopup();
4701 if (!popup || !innerParams.input) {
4702 return;
4703 }
4704 const input = getInput$1(popup, innerParams.input);
4705 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4706 if (['textarea', 'file'].includes(innerParams.input)) {
4707 return; // do not submit
4708 }
4709 clickConfirm();
4710 event.preventDefault();
4711 }
4712 };
4713
4714 /**
4715 * @param {KeyboardEvent} event
4716 */
4717 const handleTab = event => {
4718 const targetElement = event.target;
4719 const focusableElements = getFocusableElements();
4720 let btnIndex = -1;
4721 for (let i = 0; i < focusableElements.length; i++) {
4722 if (targetElement === focusableElements[i]) {
4723 btnIndex = i;
4724 break;
4725 }
4726 }
4727
4728 // Cycle to the next button
4729 if (!event.shiftKey) {
4730 setFocus(btnIndex, 1);
4731 }
4732
4733 // Cycle to the prev button
4734 else {
4735 setFocus(btnIndex, -1);
4736 }
4737 event.stopPropagation();
4738 event.preventDefault();
4739 };
4740
4741 /**
4742 * @param {string} key
4743 */
4744 const handleArrows = key => {
4745 const actions = getActions();
4746 const confirmButton = getConfirmButton();
4747 const denyButton = getDenyButton();
4748 const cancelButton = getCancelButton();
4749 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4750 return;
4751 }
4752 /** @type HTMLElement[] */
4753 const buttons = [confirmButton, denyButton, cancelButton];
4754 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4755 return;
4756 }
4757 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4758 let buttonToFocus = document.activeElement;
4759 if (!buttonToFocus) {
4760 return;
4761 }
4762 for (let i = 0; i < actions.children.length; i++) {
4763 buttonToFocus = buttonToFocus[sibling];
4764 if (!buttonToFocus) {
4765 return;
4766 }
4767 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4768 break;
4769 }
4770 }
4771 if (buttonToFocus instanceof HTMLButtonElement) {
4772 buttonToFocus.focus();
4773 }
4774 };
4775
4776 /**
4777 * @param {KeyboardEvent} event
4778 * @param {SweetAlertOptions} innerParams
4779 * @param {(dismiss: DismissReason) => void} dismissWith
4780 */
4781 const handleEsc = (event, innerParams, dismissWith) => {
4782 event.preventDefault();
4783 if (callIfFunction(innerParams.allowEscapeKey)) {
4784 dismissWith(DismissReason.esc);
4785 }
4786 };
4787
4788 /**
4789 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4790 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4791 * This is the approach that Babel will probably take to implement private methods/fields
4792 * https://github.com/tc39/proposal-private-methods
4793 * https://github.com/babel/babel/pull/7555
4794 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4795 * then we can use that language feature.
4796 */
4797
4798 var privateMethods = {
4799 swalPromiseResolve: new WeakMap(),
4800 swalPromiseReject: new WeakMap()
4801 };
4802
4803 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4804 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4805 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4806 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4807
4808 const setAriaHidden = () => {
4809 const container = getContainer();
4810 const bodyChildren = Array.from(document.body.children);
4811 bodyChildren.forEach(el => {
4812 if (el.contains(container)) {
4813 return;
4814 }
4815 if (el.hasAttribute('aria-hidden')) {
4816 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4817 }
4818 el.setAttribute('aria-hidden', 'true');
4819 });
4820 };
4821 const unsetAriaHidden = () => {
4822 const bodyChildren = Array.from(document.body.children);
4823 bodyChildren.forEach(el => {
4824 if (el.hasAttribute('data-previous-aria-hidden')) {
4825 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4826 el.removeAttribute('data-previous-aria-hidden');
4827 } else {
4828 el.removeAttribute('aria-hidden');
4829 }
4830 });
4831 };
4832
4833 // @ts-ignore
4834 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4835
4836 /**
4837 * Fix iOS scrolling
4838 * http://stackoverflow.com/q/39626302
4839 */
4840 const iOSfix = () => {
4841 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4842 const offset = document.body.scrollTop;
4843 document.body.style.top = `${offset * -1}px`;
4844 addClass(document.body, swalClasses.iosfix);
4845 lockBodyScroll();
4846 }
4847 };
4848
4849 /**
4850 * https://github.com/sweetalert2/sweetalert2/issues/1246
4851 */
4852 const lockBodyScroll = () => {
4853 const container = getContainer();
4854 if (!container) {
4855 return;
4856 }
4857 /** @type {boolean} */
4858 let preventTouchMove;
4859 /**
4860 * @param {TouchEvent} event
4861 */
4862 container.ontouchstart = event => {
4863 preventTouchMove = shouldPreventTouchMove(event);
4864 };
4865 /**
4866 * @param {TouchEvent} event
4867 */
4868 container.ontouchmove = event => {
4869 if (preventTouchMove) {
4870 event.preventDefault();
4871 event.stopPropagation();
4872 }
4873 };
4874 };
4875
4876 /**
4877 * @param {TouchEvent} event
4878 * @returns {boolean}
4879 */
4880 const shouldPreventTouchMove = event => {
4881 const target = event.target;
4882 const container = getContainer();
4883 const htmlContainer = getHtmlContainer();
4884 if (!container || !htmlContainer) {
4885 return false;
4886 }
4887 if (isStylus(event) || isZoom(event)) {
4888 return false;
4889 }
4890 if (target === container) {
4891 return true;
4892 }
4893 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4894 // #2823
4895 target.tagName !== 'INPUT' &&
4896 // #1603
4897 target.tagName !== 'TEXTAREA' &&
4898 // #2266
4899 !(isScrollable(htmlContainer) &&
4900 // #1944
4901 htmlContainer.contains(target))) {
4902 return true;
4903 }
4904 return false;
4905 };
4906
4907 /**
4908 * https://github.com/sweetalert2/sweetalert2/issues/1786
4909 *
4910 * @param {TouchEvent} event
4911 * @returns {boolean}
4912 */
4913 const isStylus = event => {
4914 return Boolean(event.touches && event.touches.length &&
4915 // @ts-ignore - touchType is not a standard property
4916 event.touches[0].touchType === 'stylus');
4917 };
4918
4919 /**
4920 * https://github.com/sweetalert2/sweetalert2/issues/1891
4921 *
4922 * @param {TouchEvent} event
4923 * @returns {boolean}
4924 */
4925 const isZoom = event => {
4926 return event.touches && event.touches.length > 1;
4927 };
4928 const undoIOSfix = () => {
4929 if (hasClass(document.body, swalClasses.iosfix)) {
4930 const offset = parseInt(document.body.style.top, 10);
4931 removeClass(document.body, swalClasses.iosfix);
4932 document.body.style.top = '';
4933 document.body.scrollTop = offset * -1;
4934 }
4935 };
4936
4937 /**
4938 * Measure scrollbar width for padding body during modal show/hide
4939 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4940 *
4941 * @returns {number}
4942 */
4943 const measureScrollbar = () => {
4944 const scrollDiv = document.createElement('div');
4945 scrollDiv.className = swalClasses['scrollbar-measure'];
4946 document.body.appendChild(scrollDiv);
4947 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4948 document.body.removeChild(scrollDiv);
4949 return scrollbarWidth;
4950 };
4951
4952 /**
4953 * Remember state in cases where opening and handling a modal will fiddle with it.
4954 * @type {number | null}
4955 */
4956 let previousBodyPadding = null;
4957
4958 /**
4959 * @param {string} initialBodyOverflow
4960 */
4961 const replaceScrollbarWithPadding = initialBodyOverflow => {
4962 // for queues, do not do this more than once
4963 if (previousBodyPadding !== null) {
4964 return;
4965 }
4966 // if the body has overflow
4967 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4968 ) {
4969 // add padding so the content doesn't shift after removal of scrollbar
4970 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4971 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4972 }
4973 };
4974 const undoReplaceScrollbarWithPadding = () => {
4975 if (previousBodyPadding !== null) {
4976 document.body.style.paddingRight = `${previousBodyPadding}px`;
4977 previousBodyPadding = null;
4978 }
4979 };
4980
4981 /**
4982 * @param {SweetAlert} instance
4983 * @param {HTMLElement} container
4984 * @param {boolean} returnFocus
4985 * @param {(() => void) | undefined} didClose
4986 */
4987 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4988 if (isToast()) {
4989 triggerDidCloseAndDispose(instance, didClose);
4990 } else {
4991 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4992 removeKeydownHandler(globalState);
4993 }
4994
4995 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4996 // for some reason removing the container in Safari will scroll the document to bottom
4997 if (isSafariOrIOS) {
4998 container.setAttribute('style', 'display:none !important');
4999 container.removeAttribute('class');
5000 container.innerHTML = '';
5001 } else {
5002 container.remove();
5003 }
5004 if (isModal()) {
5005 undoReplaceScrollbarWithPadding();
5006 undoIOSfix();
5007 unsetAriaHidden();
5008 }
5009 removeBodyClasses();
5010 }
5011
5012 /**
5013 * Remove SweetAlert2 classes from body
5014 */
5015 function removeBodyClasses() {
5016 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
5017 }
5018
5019 /**
5020 * Instance method to close sweetAlert
5021 *
5022 * @param {SweetAlertResult | undefined} resolveValue
5023 * @this {SweetAlert}
5024 */
5025 function close(resolveValue) {
5026 resolveValue = prepareResolveValue(resolveValue);
5027 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
5028 const didClose = triggerClosePopup(this);
5029 if (this.isAwaitingPromise) {
5030 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
5031 if (!resolveValue.isDismissed) {
5032 handleAwaitingPromise(this);
5033 swalPromiseResolve(resolveValue);
5034 }
5035 } else if (didClose) {
5036 // Resolve Swal promise
5037 swalPromiseResolve(resolveValue);
5038 }
5039 }
5040
5041 /**
5042 * @param {SweetAlert} instance
5043 * @returns {boolean}
5044 */
5045 const triggerClosePopup = instance => {
5046 const popup = getPopup();
5047 if (!popup) {
5048 return false;
5049 }
5050 const innerParams = privateProps.innerParams.get(instance);
5051 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
5052 return false;
5053 }
5054 removeClass(popup, innerParams.showClass.popup);
5055 addClass(popup, innerParams.hideClass.popup);
5056 const backdrop = getContainer();
5057 removeClass(backdrop, innerParams.showClass.backdrop);
5058 addClass(backdrop, innerParams.hideClass.backdrop);
5059 handlePopupAnimation(instance, popup, innerParams);
5060 return true;
5061 };
5062
5063 /**
5064 * @param {Error | string} error
5065 * @this {SweetAlert}
5066 */
5067 function rejectPromise(error) {
5068 const rejectPromise = privateMethods.swalPromiseReject.get(this);
5069 handleAwaitingPromise(this);
5070 if (rejectPromise) {
5071 // Reject Swal promise
5072 rejectPromise(error);
5073 }
5074 }
5075
5076 /**
5077 * @param {SweetAlert} instance
5078 */
5079 const handleAwaitingPromise = instance => {
5080 if (instance.isAwaitingPromise) {
5081 // @ts-ignore
5082 delete instance.isAwaitingPromise;
5083 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
5084 if (!privateProps.innerParams.get(instance)) {
5085 instance._destroy();
5086 }
5087 }
5088 };
5089
5090 /**
5091 * @param {SweetAlertResult | undefined} resolveValue
5092 * @returns {SweetAlertResult}
5093 */
5094 const prepareResolveValue = resolveValue => {
5095 // When user calls Swal.close()
5096 if (typeof resolveValue === 'undefined') {
5097 return {
5098 isConfirmed: false,
5099 isDenied: false,
5100 isDismissed: true
5101 };
5102 }
5103 return Object.assign({
5104 isConfirmed: false,
5105 isDenied: false,
5106 isDismissed: false
5107 }, resolveValue);
5108 };
5109
5110 /**
5111 * @param {SweetAlert} instance
5112 * @param {HTMLElement} popup
5113 * @param {SweetAlertOptions} innerParams
5114 */
5115 const handlePopupAnimation = (instance, popup, innerParams) => {
5116 var _globalState$eventEmi;
5117 const container = getContainer();
5118 // If animation is supported, animate
5119 const animationIsSupported = hasCssAnimation(popup);
5120 if (typeof innerParams.willClose === 'function') {
5121 innerParams.willClose(popup);
5122 }
5123 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
5124 if (animationIsSupported && container) {
5125 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
5126 } else if (container) {
5127 // Otherwise, remove immediately
5128 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
5129 }
5130 };
5131
5132 /**
5133 * @param {SweetAlert} instance
5134 * @param {HTMLElement} popup
5135 * @param {HTMLElement} container
5136 * @param {boolean} returnFocus
5137 * @param {(() => void) | undefined} didClose
5138 */
5139 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
5140 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
5141 /**
5142 * @param {AnimationEvent | TransitionEvent} e
5143 */
5144 const swalCloseAnimationFinished = function (e) {
5145 if (e.target === popup) {
5146 var _globalState$swalClos;
5147 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
5148 delete globalState.swalCloseEventFinishedCallback;
5149 popup.removeEventListener('animationend', swalCloseAnimationFinished);
5150 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
5151 }
5152 };
5153 popup.addEventListener('animationend', swalCloseAnimationFinished);
5154 popup.addEventListener('transitionend', swalCloseAnimationFinished);
5155 };
5156
5157 /**
5158 * @param {SweetAlert} instance
5159 * @param {(() => void) | undefined} didClose
5160 */
5161 const triggerDidCloseAndDispose = (instance, didClose) => {
5162 setTimeout(() => {
5163 var _globalState$eventEmi2;
5164 if (typeof didClose === 'function') {
5165 didClose.bind(instance.params)();
5166 }
5167 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
5168 // instance might have been destroyed already
5169 if (instance._destroy) {
5170 instance._destroy();
5171 }
5172 });
5173 };
5174
5175 /**
5176 * Shows loader (spinner), this is useful with AJAX requests.
5177 * By default the loader be shown instead of the "Confirm" button.
5178 *
5179 * @param {HTMLButtonElement | null} [buttonToReplace]
5180 */
5181 const showLoading = buttonToReplace => {
5182 let popup = getPopup();
5183 if (!popup) {
5184 new Swal();
5185 }
5186 popup = getPopup();
5187 if (!popup) {
5188 return;
5189 }
5190 const loader = getLoader();
5191 if (isToast()) {
5192 hide(getIcon());
5193 } else {
5194 replaceButton(popup, buttonToReplace);
5195 }
5196 show(loader);
5197 popup.setAttribute('data-loading', 'true');
5198 popup.setAttribute('aria-busy', 'true');
5199 popup.focus();
5200 };
5201
5202 /**
5203 * @param {HTMLElement} popup
5204 * @param {HTMLButtonElement | null} [buttonToReplace]
5205 */
5206 const replaceButton = (popup, buttonToReplace) => {
5207 const actions = getActions();
5208 const loader = getLoader();
5209 if (!actions || !loader) {
5210 return;
5211 }
5212 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
5213 buttonToReplace = getConfirmButton();
5214 }
5215 show(actions);
5216 if (buttonToReplace) {
5217 hide(buttonToReplace);
5218 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
5219 actions.insertBefore(loader, buttonToReplace);
5220 }
5221 addClass([popup, actions], swalClasses.loading);
5222 };
5223
5224 /**
5225 * @param {SweetAlert} instance
5226 * @param {SweetAlertOptions} params
5227 */
5228 const handleInputOptionsAndValue = (instance, params) => {
5229 if (params.input === 'select' || params.input === 'radio') {
5230 handleInputOptions(instance, params);
5231 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
5232 showLoading(getConfirmButton());
5233 handleInputValue(instance, params);
5234 }
5235 };
5236
5237 /**
5238 * @param {SweetAlert} instance
5239 * @param {SweetAlertOptions} innerParams
5240 * @returns {SweetAlertInputValue}
5241 */
5242 const getInputValue = (instance, innerParams) => {
5243 const input = instance.getInput();
5244 if (!input) {
5245 return null;
5246 }
5247 switch (innerParams.input) {
5248 case 'checkbox':
5249 return getCheckboxValue(input);
5250 case 'radio':
5251 return getRadioValue(input);
5252 case 'file':
5253 return getFileValue(input);
5254 default:
5255 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
5256 }
5257 };
5258
5259 /**
5260 * @param {HTMLInputElement} input
5261 * @returns {number}
5262 */
5263 const getCheckboxValue = input => input.checked ? 1 : 0;
5264
5265 /**
5266 * @param {HTMLInputElement} input
5267 * @returns {string | null}
5268 */
5269 const getRadioValue = input => input.checked ? input.value : null;
5270
5271 /**
5272 * @param {HTMLInputElement} input
5273 * @returns {FileList | File | null}
5274 */
5275 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
5276
5277 /**
5278 * @param {SweetAlert} instance
5279 * @param {SweetAlertOptions} params
5280 */
5281 const handleInputOptions = (instance, params) => {
5282 const popup = getPopup();
5283 if (!popup) {
5284 return;
5285 }
5286 /**
5287 * @param {*} inputOptions
5288 */
5289 const processInputOptions = inputOptions => {
5290 if (params.input === 'select') {
5291 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
5292 } else if (params.input === 'radio') {
5293 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
5294 }
5295 };
5296 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
5297 showLoading(getConfirmButton());
5298 asPromise(params.inputOptions).then(inputOptions => {
5299 instance.hideLoading();
5300 processInputOptions(inputOptions);
5301 });
5302 } else if (typeof params.inputOptions === 'object') {
5303 processInputOptions(params.inputOptions);
5304 } else {
5305 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
5306 }
5307 };
5308
5309 /**
5310 * @param {SweetAlert} instance
5311 * @param {SweetAlertOptions} params
5312 */
5313 const handleInputValue = (instance, params) => {
5314 const input = instance.getInput();
5315 if (!input) {
5316 return;
5317 }
5318 hide(input);
5319 asPromise(params.inputValue).then(inputValue => {
5320 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
5321 show(input);
5322 input.focus();
5323 instance.hideLoading();
5324 }).catch(err => {
5325 error(`Error in inputValue promise: ${err}`);
5326 input.value = '';
5327 show(input);
5328 input.focus();
5329 instance.hideLoading();
5330 });
5331 };
5332
5333 /**
5334 * @param {HTMLElement} popup
5335 * @param {InputOptionFlattened[]} inputOptions
5336 * @param {SweetAlertOptions} params
5337 */
5338 function populateSelectOptions(popup, inputOptions, params) {
5339 const select = getDirectChildByClass(popup, swalClasses.select);
5340 if (!select) {
5341 return;
5342 }
5343 /**
5344 * @param {HTMLElement} parent
5345 * @param {string} optionLabel
5346 * @param {string} optionValue
5347 */
5348 const renderOption = (parent, optionLabel, optionValue) => {
5349 const option = document.createElement('option');
5350 option.value = optionValue;
5351 setInnerHtml(option, optionLabel);
5352 option.selected = isSelected(optionValue, params.inputValue);
5353 parent.appendChild(option);
5354 };
5355 inputOptions.forEach(inputOption => {
5356 const optionValue = inputOption[0];
5357 const optionLabel = inputOption[1];
5358 // <optgroup> spec:
5359 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
5360 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
5361 // check whether this is a <optgroup>
5362 if (Array.isArray(optionLabel)) {
5363 // if it is an array, then it is an <optgroup>
5364 const optgroup = document.createElement('optgroup');
5365 optgroup.label = optionValue;
5366 optgroup.disabled = false; // not configurable for now
5367 select.appendChild(optgroup);
5368 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
5369 } else {
5370 // case of <option>
5371 renderOption(select, optionLabel, optionValue);
5372 }
5373 });
5374 select.focus();
5375 }
5376
5377 /**
5378 * @param {HTMLElement} popup
5379 * @param {InputOptionFlattened[]} inputOptions
5380 * @param {SweetAlertOptions} params
5381 */
5382 function populateRadioOptions(popup, inputOptions, params) {
5383 const radio = getDirectChildByClass(popup, swalClasses.radio);
5384 if (!radio) {
5385 return;
5386 }
5387 inputOptions.forEach(inputOption => {
5388 const radioValue = inputOption[0];
5389 const radioLabel = inputOption[1];
5390 const radioInput = document.createElement('input');
5391 const radioLabelElement = document.createElement('label');
5392 radioInput.type = 'radio';
5393 radioInput.name = swalClasses.radio;
5394 radioInput.value = radioValue;
5395 if (isSelected(radioValue, params.inputValue)) {
5396 radioInput.checked = true;
5397 }
5398 const label = document.createElement('span');
5399 setInnerHtml(label, radioLabel);
5400 label.className = swalClasses.label;
5401 radioLabelElement.appendChild(radioInput);
5402 radioLabelElement.appendChild(label);
5403 radio.appendChild(radioLabelElement);
5404 });
5405 const radios = radio.querySelectorAll('input');
5406 if (radios.length) {
5407 radios[0].focus();
5408 }
5409 }
5410
5411 /**
5412 * Converts `inputOptions` into an array of `[value, label]`s
5413 *
5414 * @param {*} inputOptions
5415 * @typedef {string[]} InputOptionFlattened
5416 * @returns {InputOptionFlattened[]}
5417 */
5418 const formatInputOptions = inputOptions => {
5419 /** @type {InputOptionFlattened[]} */
5420 const result = [];
5421 if (inputOptions instanceof Map) {
5422 inputOptions.forEach((value, key) => {
5423 let valueFormatted = value;
5424 if (typeof valueFormatted === 'object') {
5425 // case of <optgroup>
5426 valueFormatted = formatInputOptions(valueFormatted);
5427 }
5428 result.push([key, valueFormatted]);
5429 });
5430 } else {
5431 Object.keys(inputOptions).forEach(key => {
5432 let valueFormatted = inputOptions[key];
5433 if (typeof valueFormatted === 'object') {
5434 // case of <optgroup>
5435 valueFormatted = formatInputOptions(valueFormatted);
5436 }
5437 result.push([key, valueFormatted]);
5438 });
5439 }
5440 return result;
5441 };
5442
5443 /**
5444 * @param {string} optionValue
5445 * @param {SweetAlertInputValue} inputValue
5446 * @returns {boolean}
5447 */
5448 const isSelected = (optionValue, inputValue) => {
5449 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
5450 };
5451
5452 /**
5453 * @param {SweetAlert} instance
5454 */
5455 const handleConfirmButtonClick = instance => {
5456 const innerParams = privateProps.innerParams.get(instance);
5457 instance.disableButtons();
5458 if (innerParams.input) {
5459 handleConfirmOrDenyWithInput(instance, 'confirm');
5460 } else {
5461 confirm(instance, true);
5462 }
5463 };
5464
5465 /**
5466 * @param {SweetAlert} instance
5467 */
5468 const handleDenyButtonClick = instance => {
5469 const innerParams = privateProps.innerParams.get(instance);
5470 instance.disableButtons();
5471 if (innerParams.returnInputValueOnDeny) {
5472 handleConfirmOrDenyWithInput(instance, 'deny');
5473 } else {
5474 deny(instance, false);
5475 }
5476 };
5477
5478 /**
5479 * @param {SweetAlert} instance
5480 * @param {(dismiss: DismissReason) => void} dismissWith
5481 */
5482 const handleCancelButtonClick = (instance, dismissWith) => {
5483 instance.disableButtons();
5484 dismissWith(DismissReason.cancel);
5485 };
5486
5487 /**
5488 * @param {SweetAlert} instance
5489 * @param {'confirm' | 'deny'} type
5490 */
5491 const handleConfirmOrDenyWithInput = (instance, type) => {
5492 const innerParams = privateProps.innerParams.get(instance);
5493 if (!innerParams.input) {
5494 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
5495 return;
5496 }
5497 const input = instance.getInput();
5498 const inputValue = getInputValue(instance, innerParams);
5499 if (innerParams.inputValidator) {
5500 handleInputValidator(instance, inputValue, type);
5501 } else if (input && !input.checkValidity()) {
5502 instance.enableButtons();
5503 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
5504 } else if (type === 'deny') {
5505 deny(instance, inputValue);
5506 } else {
5507 confirm(instance, inputValue);
5508 }
5509 };
5510
5511 /**
5512 * @param {SweetAlert} instance
5513 * @param {SweetAlertInputValue} inputValue
5514 * @param {'confirm' | 'deny'} type
5515 */
5516 const handleInputValidator = (instance, inputValue, type) => {
5517 const innerParams = privateProps.innerParams.get(instance);
5518 instance.disableInput();
5519 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
5520 validationPromise.then(validationMessage => {
5521 instance.enableButtons();
5522 instance.enableInput();
5523 if (validationMessage) {
5524 instance.showValidationMessage(validationMessage);
5525 } else if (type === 'deny') {
5526 deny(instance, inputValue);
5527 } else {
5528 confirm(instance, inputValue);
5529 }
5530 });
5531 };
5532
5533 /**
5534 * @param {SweetAlert} instance
5535 * @param {*} value
5536 */
5537 const deny = (instance, value) => {
5538 const innerParams = privateProps.innerParams.get(instance);
5539 if (innerParams.showLoaderOnDeny) {
5540 showLoading(getDenyButton());
5541 }
5542 if (innerParams.preDeny) {
5543 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preDeny's promise is received
5544 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
5545 preDenyPromise.then(preDenyValue => {
5546 if (preDenyValue === false) {
5547 instance.hideLoading();
5548 handleAwaitingPromise(instance);
5549 } else {
5550 instance.close(/** @type SweetAlertResult */{
5551 isDenied: true,
5552 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
5553 });
5554 }
5555 }).catch(error => rejectWith(instance, error));
5556 } else {
5557 instance.close(/** @type SweetAlertResult */{
5558 isDenied: true,
5559 value
5560 });
5561 }
5562 };
5563
5564 /**
5565 * @param {SweetAlert} instance
5566 * @param {*} value
5567 */
5568 const succeedWith = (instance, value) => {
5569 instance.close(/** @type SweetAlertResult */{
5570 isConfirmed: true,
5571 value
5572 });
5573 };
5574
5575 /**
5576 *
5577 * @param {SweetAlert} instance
5578 * @param {string} error
5579 */
5580 const rejectWith = (instance, error) => {
5581 instance.rejectPromise(error);
5582 };
5583
5584 /**
5585 *
5586 * @param {SweetAlert} instance
5587 * @param {*} value
5588 */
5589 const confirm = (instance, value) => {
5590 const innerParams = privateProps.innerParams.get(instance);
5591 if (innerParams.showLoaderOnConfirm) {
5592 showLoading();
5593 }
5594 if (innerParams.preConfirm) {
5595 instance.resetValidationMessage();
5596 instance.isAwaitingPromise = true; // Flagging the instance as awaiting a promise so it's own promise's reject/resolve methods doesn't get destroyed until the result from this preConfirm's promise is received
5597 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5598 preConfirmPromise.then(preConfirmValue => {
5599 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5600 instance.hideLoading();
5601 handleAwaitingPromise(instance);
5602 } else {
5603 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5604 }
5605 }).catch(error => rejectWith(instance, error));
5606 } else {
5607 succeedWith(instance, value);
5608 }
5609 };
5610
5611 /**
5612 * Hides loader and shows back the button which was hidden by .showLoading()
5613 * @this {SweetAlert}
5614 */
5615 function hideLoading() {
5616 // do nothing if popup is closed
5617 const innerParams = privateProps.innerParams.get(this);
5618 if (!innerParams) {
5619 return;
5620 }
5621 const domCache = privateProps.domCache.get(this);
5622 hide(domCache.loader);
5623 if (isToast()) {
5624 if (innerParams.icon) {
5625 show(getIcon());
5626 }
5627 } else {
5628 showRelatedButton(domCache);
5629 }
5630 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5631 domCache.popup.removeAttribute('aria-busy');
5632 domCache.popup.removeAttribute('data-loading');
5633 domCache.confirmButton.disabled = false;
5634 domCache.denyButton.disabled = false;
5635 domCache.cancelButton.disabled = false;
5636 }
5637
5638 /**
5639 * @param {DomCache} domCache
5640 */
5641 const showRelatedButton = domCache => {
5642 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5643 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5644 if (buttonToReplace.length) {
5645 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5646 } else if (allButtonsAreHidden()) {
5647 hide(domCache.actions);
5648 }
5649 };
5650
5651 /**
5652 * Gets the input DOM node, this method works with input parameter.
5653 *
5654 * @returns {HTMLInputElement | null}
5655 * @this {SweetAlert}
5656 */
5657 function getInput() {
5658 const innerParams = privateProps.innerParams.get(this);
5659 const domCache = privateProps.domCache.get(this);
5660 if (!domCache) {
5661 return null;
5662 }
5663 return getInput$1(domCache.popup, innerParams.input);
5664 }
5665
5666 /**
5667 * @param {SweetAlert} instance
5668 * @param {string[]} buttons
5669 * @param {boolean} disabled
5670 */
5671 function setButtonsDisabled(instance, buttons, disabled) {
5672 const domCache = privateProps.domCache.get(instance);
5673 buttons.forEach(button => {
5674 domCache[button].disabled = disabled;
5675 });
5676 }
5677
5678 /**
5679 * @param {HTMLInputElement | null} input
5680 * @param {boolean} disabled
5681 */
5682 function setInputDisabled(input, disabled) {
5683 const popup = getPopup();
5684 if (!popup || !input) {
5685 return;
5686 }
5687 if (input.type === 'radio') {
5688 /** @type {NodeListOf<HTMLInputElement>} */
5689 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5690 for (let i = 0; i < radios.length; i++) {
5691 radios[i].disabled = disabled;
5692 }
5693 } else {
5694 input.disabled = disabled;
5695 }
5696 }
5697
5698 /**
5699 * Enable all the buttons
5700 * @this {SweetAlert}
5701 */
5702 function enableButtons() {
5703 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5704 }
5705
5706 /**
5707 * Disable all the buttons
5708 * @this {SweetAlert}
5709 */
5710 function disableButtons() {
5711 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5712 }
5713
5714 /**
5715 * Enable the input field
5716 * @this {SweetAlert}
5717 */
5718 function enableInput() {
5719 setInputDisabled(this.getInput(), false);
5720 }
5721
5722 /**
5723 * Disable the input field
5724 * @this {SweetAlert}
5725 */
5726 function disableInput() {
5727 setInputDisabled(this.getInput(), true);
5728 }
5729
5730 /**
5731 * Show block with validation message
5732 *
5733 * @param {string} error
5734 * @this {SweetAlert}
5735 */
5736 function showValidationMessage(error) {
5737 const domCache = privateProps.domCache.get(this);
5738 const params = privateProps.innerParams.get(this);
5739 setInnerHtml(domCache.validationMessage, error);
5740 domCache.validationMessage.className = swalClasses['validation-message'];
5741 if (params.customClass && params.customClass.validationMessage) {
5742 addClass(domCache.validationMessage, params.customClass.validationMessage);
5743 }
5744 show(domCache.validationMessage);
5745 const input = this.getInput();
5746 if (input) {
5747 input.setAttribute('aria-invalid', 'true');
5748 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5749 focusInput(input);
5750 addClass(input, swalClasses.inputerror);
5751 }
5752 }
5753
5754 /**
5755 * Hide block with validation message
5756 *
5757 * @this {SweetAlert}
5758 */
5759 function resetValidationMessage() {
5760 const domCache = privateProps.domCache.get(this);
5761 if (domCache.validationMessage) {
5762 hide(domCache.validationMessage);
5763 }
5764 const input = this.getInput();
5765 if (input) {
5766 input.removeAttribute('aria-invalid');
5767 input.removeAttribute('aria-describedby');
5768 removeClass(input, swalClasses.inputerror);
5769 }
5770 }
5771
5772 const defaultParams = {
5773 title: '',
5774 titleText: '',
5775 text: '',
5776 html: '',
5777 footer: '',
5778 icon: undefined,
5779 iconColor: undefined,
5780 iconHtml: undefined,
5781 template: undefined,
5782 toast: false,
5783 draggable: false,
5784 animation: true,
5785 theme: 'light',
5786 showClass: {
5787 popup: 'swal2-show',
5788 backdrop: 'swal2-backdrop-show',
5789 icon: 'swal2-icon-show'
5790 },
5791 hideClass: {
5792 popup: 'swal2-hide',
5793 backdrop: 'swal2-backdrop-hide',
5794 icon: 'swal2-icon-hide'
5795 },
5796 customClass: {},
5797 target: 'body',
5798 color: undefined,
5799 backdrop: true,
5800 heightAuto: true,
5801 allowOutsideClick: true,
5802 allowEscapeKey: true,
5803 allowEnterKey: true,
5804 stopKeydownPropagation: true,
5805 keydownListenerCapture: false,
5806 showConfirmButton: true,
5807 showDenyButton: false,
5808 showCancelButton: false,
5809 preConfirm: undefined,
5810 preDeny: undefined,
5811 confirmButtonText: 'OK',
5812 confirmButtonAriaLabel: '',
5813 confirmButtonColor: undefined,
5814 denyButtonText: 'No',
5815 denyButtonAriaLabel: '',
5816 denyButtonColor: undefined,
5817 cancelButtonText: 'Cancel',
5818 cancelButtonAriaLabel: '',
5819 cancelButtonColor: undefined,
5820 buttonsStyling: true,
5821 reverseButtons: false,
5822 focusConfirm: true,
5823 focusDeny: false,
5824 focusCancel: false,
5825 returnFocus: true,
5826 showCloseButton: false,
5827 closeButtonHtml: '&times;',
5828 closeButtonAriaLabel: 'Close this dialog',
5829 loaderHtml: '',
5830 showLoaderOnConfirm: false,
5831 showLoaderOnDeny: false,
5832 imageUrl: undefined,
5833 imageWidth: undefined,
5834 imageHeight: undefined,
5835 imageAlt: '',
5836 timer: undefined,
5837 timerProgressBar: false,
5838 width: undefined,
5839 padding: undefined,
5840 background: undefined,
5841 input: undefined,
5842 inputPlaceholder: '',
5843 inputLabel: '',
5844 inputValue: '',
5845 inputOptions: {},
5846 inputAutoFocus: true,
5847 inputAutoTrim: true,
5848 inputAttributes: {},
5849 inputValidator: undefined,
5850 returnInputValueOnDeny: false,
5851 validationMessage: undefined,
5852 grow: false,
5853 position: 'center',
5854 progressSteps: [],
5855 currentProgressStep: undefined,
5856 progressStepsDistance: undefined,
5857 willOpen: undefined,
5858 didOpen: undefined,
5859 didRender: undefined,
5860 willClose: undefined,
5861 didClose: undefined,
5862 didDestroy: undefined,
5863 scrollbarPadding: true,
5864 topLayer: false
5865 };
5866 const updatableParams = ['allowEscapeKey', 'allowOutsideClick', 'background', 'buttonsStyling', 'cancelButtonAriaLabel', 'cancelButtonColor', 'cancelButtonText', 'closeButtonAriaLabel', 'closeButtonHtml', 'color', 'confirmButtonAriaLabel', 'confirmButtonColor', 'confirmButtonText', 'currentProgressStep', 'customClass', 'denyButtonAriaLabel', 'denyButtonColor', 'denyButtonText', 'didClose', 'didDestroy', 'draggable', 'footer', 'hideClass', 'html', 'icon', 'iconColor', 'iconHtml', 'imageAlt', 'imageHeight', 'imageUrl', 'imageWidth', 'preConfirm', 'preDeny', 'progressSteps', 'returnFocus', 'reverseButtons', 'showCancelButton', 'showCloseButton', 'showConfirmButton', 'showDenyButton', 'text', 'title', 'titleText', 'theme', 'willClose'];
5867
5868 /** @type {Record<string, string | undefined>} */
5869 const deprecatedParams = {
5870 allowEnterKey: undefined
5871 };
5872 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5873
5874 /**
5875 * Is valid parameter
5876 *
5877 * @param {string} paramName
5878 * @returns {boolean}
5879 */
5880 const isValidParameter = paramName => {
5881 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5882 };
5883
5884 /**
5885 * Is valid parameter for Swal.update() method
5886 *
5887 * @param {string} paramName
5888 * @returns {boolean}
5889 */
5890 const isUpdatableParameter = paramName => {
5891 return updatableParams.indexOf(paramName) !== -1;
5892 };
5893
5894 /**
5895 * Is deprecated parameter
5896 *
5897 * @param {string} paramName
5898 * @returns {string | undefined}
5899 */
5900 const isDeprecatedParameter = paramName => {
5901 return deprecatedParams[paramName];
5902 };
5903
5904 /**
5905 * @param {string} param
5906 */
5907 const checkIfParamIsValid = param => {
5908 if (!isValidParameter(param)) {
5909 warn(`Unknown parameter "${param}"`);
5910 }
5911 };
5912
5913 /**
5914 * @param {string} param
5915 */
5916 const checkIfToastParamIsValid = param => {
5917 if (toastIncompatibleParams.includes(param)) {
5918 warn(`The parameter "${param}" is incompatible with toasts`);
5919 }
5920 };
5921
5922 /**
5923 * @param {string} param
5924 */
5925 const checkIfParamIsDeprecated = param => {
5926 const isDeprecated = isDeprecatedParameter(param);
5927 if (isDeprecated) {
5928 warnAboutDeprecation(param, isDeprecated);
5929 }
5930 };
5931
5932 /**
5933 * Show relevant warnings for given params
5934 *
5935 * @param {SweetAlertOptions} params
5936 */
5937 const showWarningsForParams = params => {
5938 if (params.backdrop === false && params.allowOutsideClick) {
5939 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5940 }
5941 if (params.theme && !['light', 'dark', 'auto', 'minimal', 'borderless', 'bootstrap-4', 'bootstrap-4-light', 'bootstrap-4-dark', 'bootstrap-5', 'bootstrap-5-light', 'bootstrap-5-dark', 'material-ui', 'material-ui-light', 'material-ui-dark', 'embed-iframe', 'bulma', 'bulma-light', 'bulma-dark'].includes(params.theme)) {
5942 warn(`Invalid theme "${params.theme}"`);
5943 }
5944 for (const param in params) {
5945 checkIfParamIsValid(param);
5946 if (params.toast) {
5947 checkIfToastParamIsValid(param);
5948 }
5949 checkIfParamIsDeprecated(param);
5950 }
5951 };
5952
5953 /**
5954 * Updates popup parameters.
5955 *
5956 * @this {any}
5957 * @param {SweetAlertOptions} params
5958 */
5959 function update(params) {
5960 const container = getContainer();
5961 const popup = getPopup();
5962 const innerParams = privateProps.innerParams.get(this);
5963 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5964 warn(`You're trying to update the closed or closing popup, that won't work. Use the update() method in preConfirm parameter or show a new popup.`);
5965 return;
5966 }
5967 const validUpdatableParams = filterValidParams(params);
5968 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5969 showWarningsForParams(updatedParams);
5970 if (container) {
5971 container.dataset['swal2Theme'] = updatedParams.theme;
5972 }
5973 render(this, updatedParams);
5974 privateProps.innerParams.set(this, updatedParams);
5975 Object.defineProperties(this, {
5976 params: {
5977 value: Object.assign({}, this.params, params),
5978 writable: false,
5979 enumerable: true
5980 }
5981 });
5982 }
5983
5984 /**
5985 * @param {SweetAlertOptions} params
5986 * @returns {SweetAlertOptions}
5987 */
5988 const filterValidParams = params => {
5989 /** @type {Record<string, any>} */
5990 const validUpdatableParams = {};
5991 Object.keys(params).forEach(param => {
5992 if (isUpdatableParameter(param)) {
5993 const typedParams = /** @type {Record<string, any>} */params;
5994 validUpdatableParams[param] = typedParams[param];
5995 } else {
5996 warn(`Invalid parameter to update: ${param}`);
5997 }
5998 });
5999 return validUpdatableParams;
6000 };
6001
6002 /**
6003 * Dispose the current SweetAlert2 instance
6004 * @this {SweetAlert}
6005 */
6006 function _destroy() {
6007 var _globalState$eventEmi;
6008 const domCache = privateProps.domCache.get(this);
6009 const innerParams = privateProps.innerParams.get(this);
6010 if (!innerParams) {
6011 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
6012 return; // This instance has already been destroyed
6013 }
6014
6015 // Check if there is another Swal closing
6016 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
6017 globalState.swalCloseEventFinishedCallback();
6018 delete globalState.swalCloseEventFinishedCallback;
6019 }
6020 if (typeof innerParams.didDestroy === 'function') {
6021 innerParams.didDestroy();
6022 }
6023 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
6024 disposeSwal(this);
6025 }
6026
6027 /**
6028 * @param {SweetAlert} instance
6029 */
6030 const disposeSwal = instance => {
6031 disposeWeakMaps(instance);
6032 // Unset this.params so GC will dispose it (#1569)
6033 // @ts-ignore
6034 delete instance.params;
6035 // Unset globalState props so GC will dispose globalState (#1569)
6036 delete globalState.keydownHandler;
6037 delete globalState.keydownTarget;
6038 // Unset currentInstance
6039 delete globalState.currentInstance;
6040 };
6041
6042 /**
6043 * @param {SweetAlert} instance
6044 */
6045 const disposeWeakMaps = instance => {
6046 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
6047 if (instance.isAwaitingPromise) {
6048 unsetWeakMaps(privateProps, instance);
6049 instance.isAwaitingPromise = true;
6050 } else {
6051 unsetWeakMaps(privateMethods, instance);
6052 unsetWeakMaps(privateProps, instance);
6053
6054 // @ts-ignore
6055 delete instance.isAwaitingPromise;
6056 // Unset instance methods
6057 // @ts-ignore
6058 delete instance.disableButtons;
6059 // @ts-ignore
6060 delete instance.enableButtons;
6061 // @ts-ignore
6062 delete instance.getInput;
6063 // @ts-ignore
6064 delete instance.disableInput;
6065 // @ts-ignore
6066 delete instance.enableInput;
6067 // @ts-ignore
6068 delete instance.hideLoading;
6069 // @ts-ignore
6070 delete instance.disableLoading;
6071 // @ts-ignore
6072 delete instance.showValidationMessage;
6073 // @ts-ignore
6074 delete instance.resetValidationMessage;
6075 // @ts-ignore
6076 delete instance.close;
6077 // @ts-ignore
6078 delete instance.closePopup;
6079 // @ts-ignore
6080 delete instance.closeModal;
6081 // @ts-ignore
6082 delete instance.closeToast;
6083 // @ts-ignore
6084 delete instance.rejectPromise;
6085 // @ts-ignore
6086 delete instance.update;
6087 // @ts-ignore
6088 delete instance._destroy;
6089 }
6090 };
6091
6092 /**
6093 * @param {Record<string, WeakMap<any, any>>} obj
6094 * @param {SweetAlert} instance
6095 */
6096 const unsetWeakMaps = (obj, instance) => {
6097 for (const i in obj) {
6098 obj[i].delete(instance);
6099 }
6100 };
6101
6102 var instanceMethods = /*#__PURE__*/Object.freeze({
6103 __proto__: null,
6104 _destroy: _destroy,
6105 close: close,
6106 closeModal: close,
6107 closePopup: close,
6108 closeToast: close,
6109 disableButtons: disableButtons,
6110 disableInput: disableInput,
6111 disableLoading: hideLoading,
6112 enableButtons: enableButtons,
6113 enableInput: enableInput,
6114 getInput: getInput,
6115 handleAwaitingPromise: handleAwaitingPromise,
6116 hideLoading: hideLoading,
6117 rejectPromise: rejectPromise,
6118 resetValidationMessage: resetValidationMessage,
6119 showValidationMessage: showValidationMessage,
6120 update: update
6121 });
6122
6123 /**
6124 * @param {SweetAlertOptions} innerParams
6125 * @param {DomCache} domCache
6126 * @param {(dismiss: DismissReason) => void} dismissWith
6127 */
6128 const handlePopupClick = (innerParams, domCache, dismissWith) => {
6129 if (innerParams.toast) {
6130 handleToastClick(innerParams, domCache, dismissWith);
6131 } else {
6132 // Ignore click events that had mousedown on the popup but mouseup on the container
6133 // This can happen when the user drags a slider
6134 handleModalMousedown(domCache);
6135
6136 // Ignore click events that had mousedown on the container but mouseup on the popup
6137 handleContainerMousedown(domCache);
6138 handleModalClick(innerParams, domCache, dismissWith);
6139 }
6140 };
6141
6142 /**
6143 * @param {SweetAlertOptions} innerParams
6144 * @param {DomCache} domCache
6145 * @param {(dismiss: DismissReason) => void} dismissWith
6146 */
6147 const handleToastClick = (innerParams, domCache, dismissWith) => {
6148 // Closing toast by internal click
6149 domCache.popup.onclick = () => {
6150 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
6151 return;
6152 }
6153 dismissWith(DismissReason.close);
6154 };
6155 };
6156
6157 /**
6158 * @param {SweetAlertOptions} innerParams
6159 * @returns {boolean}
6160 */
6161 const isAnyButtonShown = innerParams => {
6162 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
6163 };
6164 let ignoreOutsideClick = false;
6165
6166 /**
6167 * @param {DomCache} domCache
6168 */
6169 const handleModalMousedown = domCache => {
6170 domCache.popup.onmousedown = () => {
6171 domCache.container.onmouseup = function (e) {
6172 domCache.container.onmouseup = () => {};
6173 // We only check if the mouseup target is the container because usually it doesn't
6174 // have any other direct children aside of the popup
6175 if (e.target === domCache.container) {
6176 ignoreOutsideClick = true;
6177 }
6178 };
6179 };
6180 };
6181
6182 /**
6183 * @param {DomCache} domCache
6184 */
6185 const handleContainerMousedown = domCache => {
6186 domCache.container.onmousedown = e => {
6187 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
6188 if (e.target === domCache.container) {
6189 e.preventDefault();
6190 }
6191 domCache.popup.onmouseup = function (e) {
6192 domCache.popup.onmouseup = () => {};
6193 // We also need to check if the mouseup target is a child of the popup
6194 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
6195 ignoreOutsideClick = true;
6196 }
6197 };
6198 };
6199 };
6200
6201 /**
6202 * @param {SweetAlertOptions} innerParams
6203 * @param {DomCache} domCache
6204 * @param {(dismiss: DismissReason) => void} dismissWith
6205 */
6206 const handleModalClick = (innerParams, domCache, dismissWith) => {
6207 domCache.container.onclick = e => {
6208 if (ignoreOutsideClick) {
6209 ignoreOutsideClick = false;
6210 return;
6211 }
6212 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
6213 dismissWith(DismissReason.backdrop);
6214 }
6215 };
6216 };
6217
6218 /**
6219 * @param {any} elem
6220 * @returns {boolean}
6221 */
6222 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
6223
6224 /**
6225 * @param {any} elem
6226 * @returns {boolean}
6227 */
6228 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
6229
6230 /**
6231 * @param {any[]} args
6232 * @returns {SweetAlertOptions}
6233 */
6234 const argsToParams = args => {
6235 /** @type {Record<string, any>} */
6236 const params = {};
6237 if (typeof args[0] === 'object' && !isElement(args[0])) {
6238 Object.assign(params, args[0]);
6239 } else {
6240 ['title', 'html', 'icon'].forEach((name, index) => {
6241 const arg = args[index];
6242 if (typeof arg === 'string' || isElement(arg)) {
6243 params[name] = arg;
6244 } else if (arg !== undefined) {
6245 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
6246 }
6247 });
6248 }
6249 return params;
6250 };
6251
6252 /**
6253 * Main method to create a new SweetAlert2 popup
6254 *
6255 * @this {new (...args: any[]) => any}
6256 * @param {...SweetAlertOptions} args
6257 * @returns {Promise<SweetAlertResult>}
6258 */
6259 function fire(...args) {
6260 return new this(...args);
6261 }
6262
6263 /**
6264 * Returns an extended version of `Swal` containing `params` as defaults.
6265 * Useful for reusing Swal configuration.
6266 *
6267 * For example:
6268 *
6269 * Before:
6270 * const textPromptOptions = { input: 'text', showCancelButton: true }
6271 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
6272 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
6273 *
6274 * After:
6275 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
6276 * const {value: firstName} = await TextPrompt('What is your first name?')
6277 * const {value: lastName} = await TextPrompt('What is your last name?')
6278 *
6279 * @param {SweetAlertOptions} mixinParams
6280 * @returns {SweetAlert}
6281 * @this {typeof import('../SweetAlert.js').SweetAlert}
6282 */
6283 function mixin(mixinParams) {
6284 // @ts-ignore: 'this' refers to the SweetAlert constructor
6285 class MixinSwal extends this {
6286 /**
6287 * @param {any} params
6288 * @param {any} priorityMixinParams
6289 */
6290 _main(params, priorityMixinParams) {
6291 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
6292 }
6293 }
6294 // @ts-ignore
6295 return MixinSwal;
6296 }
6297
6298 /**
6299 * If `timer` parameter is set, returns number of milliseconds of timer remained.
6300 * Otherwise, returns undefined.
6301 *
6302 * @returns {number | undefined}
6303 */
6304 const getTimerLeft = () => {
6305 return globalState.timeout && globalState.timeout.getTimerLeft();
6306 };
6307
6308 /**
6309 * Stop timer. Returns number of milliseconds of timer remained.
6310 * If `timer` parameter isn't set, returns undefined.
6311 *
6312 * @returns {number | undefined}
6313 */
6314 const stopTimer = () => {
6315 if (globalState.timeout) {
6316 stopTimerProgressBar();
6317 return globalState.timeout.stop();
6318 }
6319 };
6320
6321 /**
6322 * Resume timer. Returns number of milliseconds of timer remained.
6323 * If `timer` parameter isn't set, returns undefined.
6324 *
6325 * @returns {number | undefined}
6326 */
6327 const resumeTimer = () => {
6328 if (globalState.timeout) {
6329 const remaining = globalState.timeout.start();
6330 animateTimerProgressBar(remaining);
6331 return remaining;
6332 }
6333 };
6334
6335 /**
6336 * Resume timer. Returns number of milliseconds of timer remained.
6337 * If `timer` parameter isn't set, returns undefined.
6338 *
6339 * @returns {number | undefined}
6340 */
6341 const toggleTimer = () => {
6342 const timer = globalState.timeout;
6343 return timer && (timer.running ? stopTimer() : resumeTimer());
6344 };
6345
6346 /**
6347 * Increase timer. Returns number of milliseconds of an updated timer.
6348 * If `timer` parameter isn't set, returns undefined.
6349 *
6350 * @param {number} ms
6351 * @returns {number | undefined}
6352 */
6353 const increaseTimer = ms => {
6354 if (globalState.timeout) {
6355 const remaining = globalState.timeout.increase(ms);
6356 animateTimerProgressBar(remaining, true);
6357 return remaining;
6358 }
6359 };
6360
6361 /**
6362 * Check if timer is running. Returns true if timer is running
6363 * or false if timer is paused or stopped.
6364 * If `timer` parameter isn't set, returns undefined
6365 *
6366 * @returns {boolean}
6367 */
6368 const isTimerRunning = () => {
6369 return Boolean(globalState.timeout && globalState.timeout.isRunning());
6370 };
6371
6372 let bodyClickListenerAdded = false;
6373 /** @type {Record<string, any>} */
6374 const clickHandlers = {};
6375
6376 /**
6377 * @this {any}
6378 * @param {string} attr
6379 */
6380 function bindClickHandler(attr = 'data-swal-template') {
6381 clickHandlers[attr] = this;
6382 if (!bodyClickListenerAdded) {
6383 document.body.addEventListener('click', bodyClickListener);
6384 bodyClickListenerAdded = true;
6385 }
6386 }
6387
6388 /**
6389 * @param {MouseEvent} event
6390 */
6391 const bodyClickListener = event => {
6392 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
6393 for (const attr in clickHandlers) {
6394 const template = el.getAttribute && el.getAttribute(attr);
6395 if (template) {
6396 clickHandlers[attr].fire({
6397 template
6398 });
6399 return;
6400 }
6401 }
6402 }
6403 };
6404
6405 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
6406
6407 class EventEmitter {
6408 constructor() {
6409 /** @type {Events} */
6410 this.events = {};
6411 }
6412
6413 /**
6414 * @param {string} eventName
6415 * @returns {EventHandlers}
6416 */
6417 _getHandlersByEventName(eventName) {
6418 if (typeof this.events[eventName] === 'undefined') {
6419 // not Set because we need to keep the FIFO order
6420 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
6421 this.events[eventName] = [];
6422 }
6423 return this.events[eventName];
6424 }
6425
6426 /**
6427 * @param {string} eventName
6428 * @param {EventHandler} eventHandler
6429 */
6430 on(eventName, eventHandler) {
6431 const currentHandlers = this._getHandlersByEventName(eventName);
6432 if (!currentHandlers.includes(eventHandler)) {
6433 currentHandlers.push(eventHandler);
6434 }
6435 }
6436
6437 /**
6438 * @param {string} eventName
6439 * @param {EventHandler} eventHandler
6440 */
6441 once(eventName, eventHandler) {
6442 /**
6443 * @param {...any} args
6444 */
6445 const onceFn = (...args) => {
6446 this.removeListener(eventName, onceFn);
6447 // @ts-ignore
6448 eventHandler.apply(this, args);
6449 };
6450 this.on(eventName, onceFn);
6451 }
6452
6453 /**
6454 * @param {string} eventName
6455 * @param {...any} args
6456 */
6457 emit(eventName, ...args) {
6458 this._getHandlersByEventName(eventName).forEach(
6459 /**
6460 * @param {EventHandler} eventHandler
6461 */
6462 eventHandler => {
6463 try {
6464 // @ts-ignore
6465 eventHandler.apply(this, args);
6466 } catch (error) {
6467 console.error(error);
6468 }
6469 });
6470 }
6471
6472 /**
6473 * @param {string} eventName
6474 * @param {EventHandler} eventHandler
6475 */
6476 removeListener(eventName, eventHandler) {
6477 const currentHandlers = this._getHandlersByEventName(eventName);
6478 const index = currentHandlers.indexOf(eventHandler);
6479 if (index > -1) {
6480 currentHandlers.splice(index, 1);
6481 }
6482 }
6483
6484 /**
6485 * @param {string} eventName
6486 */
6487 removeAllListeners(eventName) {
6488 if (this.events[eventName] !== undefined) {
6489 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
6490 this.events[eventName].length = 0;
6491 }
6492 }
6493 reset() {
6494 this.events = {};
6495 }
6496 }
6497
6498 globalState.eventEmitter = new EventEmitter();
6499
6500 /**
6501 * @param {string} eventName
6502 * @param {EventHandler} eventHandler
6503 */
6504 const on = (eventName, eventHandler) => {
6505 if (globalState.eventEmitter) {
6506 globalState.eventEmitter.on(eventName, eventHandler);
6507 }
6508 };
6509
6510 /**
6511 * @param {string} eventName
6512 * @param {EventHandler} eventHandler
6513 */
6514 const once = (eventName, eventHandler) => {
6515 if (globalState.eventEmitter) {
6516 globalState.eventEmitter.once(eventName, eventHandler);
6517 }
6518 };
6519
6520 /**
6521 * @param {string} [eventName]
6522 * @param {EventHandler} [eventHandler]
6523 */
6524 const off = (eventName, eventHandler) => {
6525 if (!globalState.eventEmitter) {
6526 return;
6527 }
6528
6529 // Remove all handlers for all events
6530 if (!eventName) {
6531 globalState.eventEmitter.reset();
6532 return;
6533 }
6534 if (eventHandler) {
6535 // Remove a specific handler
6536 globalState.eventEmitter.removeListener(eventName, eventHandler);
6537 } else {
6538 // Remove all handlers for a specific event
6539 globalState.eventEmitter.removeAllListeners(eventName);
6540 }
6541 };
6542
6543 var staticMethods = /*#__PURE__*/Object.freeze({
6544 __proto__: null,
6545 argsToParams: argsToParams,
6546 bindClickHandler: bindClickHandler,
6547 clickCancel: clickCancel,
6548 clickConfirm: clickConfirm,
6549 clickDeny: clickDeny,
6550 enableLoading: showLoading,
6551 fire: fire,
6552 getActions: getActions,
6553 getCancelButton: getCancelButton,
6554 getCloseButton: getCloseButton,
6555 getConfirmButton: getConfirmButton,
6556 getContainer: getContainer,
6557 getDenyButton: getDenyButton,
6558 getFocusableElements: getFocusableElements,
6559 getFooter: getFooter,
6560 getHtmlContainer: getHtmlContainer,
6561 getIcon: getIcon,
6562 getIconContent: getIconContent,
6563 getImage: getImage,
6564 getInputLabel: getInputLabel,
6565 getLoader: getLoader,
6566 getPopup: getPopup,
6567 getProgressSteps: getProgressSteps,
6568 getTimerLeft: getTimerLeft,
6569 getTimerProgressBar: getTimerProgressBar,
6570 getTitle: getTitle,
6571 getValidationMessage: getValidationMessage,
6572 increaseTimer: increaseTimer,
6573 isDeprecatedParameter: isDeprecatedParameter,
6574 isLoading: isLoading,
6575 isTimerRunning: isTimerRunning,
6576 isUpdatableParameter: isUpdatableParameter,
6577 isValidParameter: isValidParameter,
6578 isVisible: isVisible,
6579 mixin: mixin,
6580 off: off,
6581 on: on,
6582 once: once,
6583 resumeTimer: resumeTimer,
6584 showLoading: showLoading,
6585 stopTimer: stopTimer,
6586 toggleTimer: toggleTimer
6587 });
6588
6589 class Timer {
6590 /**
6591 * @param {() => void} callback
6592 * @param {number} delay
6593 */
6594 constructor(callback, delay) {
6595 this.callback = callback;
6596 this.remaining = delay;
6597 this.running = false;
6598 this.start();
6599 }
6600
6601 /**
6602 * @returns {number}
6603 */
6604 start() {
6605 if (!this.running) {
6606 this.running = true;
6607 this.started = new Date();
6608 this.id = setTimeout(this.callback, this.remaining);
6609 }
6610 return this.remaining;
6611 }
6612
6613 /**
6614 * @returns {number}
6615 */
6616 stop() {
6617 if (this.started && this.running) {
6618 this.running = false;
6619 clearTimeout(this.id);
6620 this.remaining -= new Date().getTime() - this.started.getTime();
6621 }
6622 return this.remaining;
6623 }
6624
6625 /**
6626 * @param {number} n
6627 * @returns {number}
6628 */
6629 increase(n) {
6630 const running = this.running;
6631 if (running) {
6632 this.stop();
6633 }
6634 this.remaining += n;
6635 if (running) {
6636 this.start();
6637 }
6638 return this.remaining;
6639 }
6640
6641 /**
6642 * @returns {number}
6643 */
6644 getTimerLeft() {
6645 if (this.running) {
6646 this.stop();
6647 this.start();
6648 }
6649 return this.remaining;
6650 }
6651
6652 /**
6653 * @returns {boolean}
6654 */
6655 isRunning() {
6656 return this.running;
6657 }
6658 }
6659
6660 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6661
6662 /**
6663 * @param {SweetAlertOptions} params
6664 * @returns {SweetAlertOptions}
6665 */
6666 const getTemplateParams = params => {
6667 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6668 if (!template) {
6669 return {};
6670 }
6671 /** @type {DocumentFragment} */
6672 const templateContent = template.content;
6673 showWarningsForElements(templateContent);
6674 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6675 return result;
6676 };
6677
6678 /**
6679 * @param {DocumentFragment} templateContent
6680 * @returns {Record<string, string | boolean | number>}
6681 */
6682 const getSwalParams = templateContent => {
6683 /** @type {Record<string, string | boolean | number>} */
6684 const result = {};
6685 /** @type {HTMLElement[]} */
6686 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6687 swalParams.forEach(param => {
6688 showWarningsForAttributes(param, ['name', 'value']);
6689 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6690 const value = param.getAttribute('value');
6691 if (!paramName || !value) {
6692 return;
6693 }
6694 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6695 result[paramName] = value !== 'false';
6696 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6697 result[paramName] = JSON.parse(value);
6698 } else {
6699 result[paramName] = value;
6700 }
6701 });
6702 return result;
6703 };
6704
6705 /**
6706 * @param {DocumentFragment} templateContent
6707 * @returns {Record<string, () => void>}
6708 */
6709 const getSwalFunctionParams = templateContent => {
6710 /** @type {Record<string, () => void>} */
6711 const result = {};
6712 /** @type {HTMLElement[]} */
6713 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6714 swalFunctions.forEach(param => {
6715 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6716 const value = param.getAttribute('value');
6717 if (!paramName || !value) {
6718 return;
6719 }
6720 result[paramName] = new Function(`return ${value}`)();
6721 });
6722 return result;
6723 };
6724
6725 /**
6726 * @param {DocumentFragment} templateContent
6727 * @returns {Record<string, string | boolean>}
6728 */
6729 const getSwalButtons = templateContent => {
6730 /** @type {Record<string, string | boolean>} */
6731 const result = {};
6732 /** @type {HTMLElement[]} */
6733 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6734 swalButtons.forEach(button => {
6735 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6736 const type = button.getAttribute('type');
6737 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6738 return;
6739 }
6740 result[`${type}ButtonText`] = button.innerHTML;
6741 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6742 if (button.hasAttribute('color')) {
6743 const color = button.getAttribute('color');
6744 if (color !== null) {
6745 result[`${type}ButtonColor`] = color;
6746 }
6747 }
6748 if (button.hasAttribute('aria-label')) {
6749 const ariaLabel = button.getAttribute('aria-label');
6750 if (ariaLabel !== null) {
6751 result[`${type}ButtonAriaLabel`] = ariaLabel;
6752 }
6753 }
6754 });
6755 return result;
6756 };
6757
6758 /**
6759 * @param {DocumentFragment} templateContent
6760 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6761 */
6762 const getSwalImage = templateContent => {
6763 const result = {};
6764 /** @type {HTMLElement | null} */
6765 const image = templateContent.querySelector('swal-image');
6766 if (image) {
6767 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6768 if (image.hasAttribute('src')) {
6769 result.imageUrl = image.getAttribute('src') || undefined;
6770 }
6771 if (image.hasAttribute('width')) {
6772 result.imageWidth = image.getAttribute('width') || undefined;
6773 }
6774 if (image.hasAttribute('height')) {
6775 result.imageHeight = image.getAttribute('height') || undefined;
6776 }
6777 if (image.hasAttribute('alt')) {
6778 result.imageAlt = image.getAttribute('alt') || undefined;
6779 }
6780 }
6781 return result;
6782 };
6783
6784 /**
6785 * @param {DocumentFragment} templateContent
6786 * @returns {object}
6787 */
6788 const getSwalIcon = templateContent => {
6789 const result = {};
6790 /** @type {HTMLElement | null} */
6791 const icon = templateContent.querySelector('swal-icon');
6792 if (icon) {
6793 showWarningsForAttributes(icon, ['type', 'color']);
6794 if (icon.hasAttribute('type')) {
6795 result.icon = icon.getAttribute('type');
6796 }
6797 if (icon.hasAttribute('color')) {
6798 result.iconColor = icon.getAttribute('color');
6799 }
6800 result.iconHtml = icon.innerHTML;
6801 }
6802 return result;
6803 };
6804
6805 /**
6806 * @param {DocumentFragment} templateContent
6807 * @returns {object}
6808 */
6809 const getSwalInput = templateContent => {
6810 /** @type {Record<string, any>} */
6811 const result = {};
6812 /** @type {HTMLElement | null} */
6813 const input = templateContent.querySelector('swal-input');
6814 if (input) {
6815 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6816 result.input = input.getAttribute('type') || 'text';
6817 if (input.hasAttribute('label')) {
6818 result.inputLabel = input.getAttribute('label');
6819 }
6820 if (input.hasAttribute('placeholder')) {
6821 result.inputPlaceholder = input.getAttribute('placeholder');
6822 }
6823 if (input.hasAttribute('value')) {
6824 result.inputValue = input.getAttribute('value');
6825 }
6826 }
6827 /** @type {HTMLElement[]} */
6828 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6829 if (inputOptions.length) {
6830 result.inputOptions = {};
6831 inputOptions.forEach(option => {
6832 showWarningsForAttributes(option, ['value']);
6833 const optionValue = option.getAttribute('value');
6834 if (!optionValue) {
6835 return;
6836 }
6837 const optionName = option.innerHTML;
6838 result.inputOptions[optionValue] = optionName;
6839 });
6840 }
6841 return result;
6842 };
6843
6844 /**
6845 * @param {DocumentFragment} templateContent
6846 * @param {string[]} paramNames
6847 * @returns {Record<string, string>}
6848 */
6849 const getSwalStringParams = (templateContent, paramNames) => {
6850 /** @type {Record<string, string>} */
6851 const result = {};
6852 for (const i in paramNames) {
6853 const paramName = paramNames[i];
6854 /** @type {HTMLElement | null} */
6855 const tag = templateContent.querySelector(paramName);
6856 if (tag) {
6857 showWarningsForAttributes(tag, []);
6858 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6859 }
6860 }
6861 return result;
6862 };
6863
6864 /**
6865 * @param {DocumentFragment} templateContent
6866 */
6867 const showWarningsForElements = templateContent => {
6868 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6869 Array.from(templateContent.children).forEach(el => {
6870 const tagName = el.tagName.toLowerCase();
6871 if (!allowedElements.includes(tagName)) {
6872 warn(`Unrecognized element <${tagName}>`);
6873 }
6874 });
6875 };
6876
6877 /**
6878 * @param {HTMLElement} el
6879 * @param {string[]} allowedAttributes
6880 */
6881 const showWarningsForAttributes = (el, allowedAttributes) => {
6882 Array.from(el.attributes).forEach(attribute => {
6883 if (allowedAttributes.indexOf(attribute.name) === -1) {
6884 warn([`Unrecognized attribute "${attribute.name}" on <${el.tagName.toLowerCase()}>.`, `${allowedAttributes.length ? `Allowed attributes are: ${allowedAttributes.join(', ')}` : 'To set the value, use HTML within the element.'}`]);
6885 }
6886 });
6887 };
6888
6889 const SHOW_CLASS_TIMEOUT = 10;
6890
6891 /**
6892 * Open popup, add necessary classes and styles, fix scrollbar
6893 *
6894 * @param {SweetAlertOptions} params
6895 */
6896 const openPopup = params => {
6897 var _globalState$eventEmi, _globalState$eventEmi2;
6898 const container = getContainer();
6899 const popup = getPopup();
6900 if (!container || !popup) {
6901 return;
6902 }
6903 if (typeof params.willOpen === 'function') {
6904 params.willOpen(popup);
6905 }
6906 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6907 const bodyStyles = window.getComputedStyle(document.body);
6908 const initialBodyOverflow = bodyStyles.overflowY;
6909 addClasses(container, popup, params);
6910
6911 // scrolling is 'hidden' until animation is done, after that 'auto'
6912 setTimeout(() => {
6913 setScrollingVisibility(container, popup);
6914 }, SHOW_CLASS_TIMEOUT);
6915 if (isModal()) {
6916 // Using ternary instead of ?? operator for Webpack 4 compatibility
6917 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6918 setAriaHidden();
6919 }
6920 if (!isToast() && !globalState.previousActiveElement) {
6921 globalState.previousActiveElement = document.activeElement;
6922 }
6923 if (typeof params.didOpen === 'function') {
6924 const didOpen = params.didOpen;
6925 setTimeout(() => didOpen(popup));
6926 }
6927 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6928 };
6929
6930 /**
6931 * @param {Event} event
6932 */
6933 const swalOpenAnimationFinished = event => {
6934 const popup = getPopup();
6935 if (!popup || event.target !== popup) {
6936 return;
6937 }
6938 const container = getContainer();
6939 if (!container) {
6940 return;
6941 }
6942 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6943 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6944 container.style.overflowY = 'auto';
6945
6946 // no-transition is added in init() in case one swal is opened right after another
6947 removeClass(container, swalClasses['no-transition']);
6948 };
6949
6950 /**
6951 * @param {HTMLElement} container
6952 * @param {HTMLElement} popup
6953 */
6954 const setScrollingVisibility = (container, popup) => {
6955 if (hasCssAnimation(popup)) {
6956 container.style.overflowY = 'hidden';
6957 popup.addEventListener('animationend', swalOpenAnimationFinished);
6958 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6959 } else {
6960 container.style.overflowY = 'auto';
6961 }
6962 };
6963
6964 /**
6965 * @param {HTMLElement} container
6966 * @param {boolean} scrollbarPadding
6967 * @param {string} initialBodyOverflow
6968 */
6969 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6970 iOSfix();
6971 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6972 replaceScrollbarWithPadding(initialBodyOverflow);
6973 }
6974
6975 // sweetalert2/issues/1247
6976 setTimeout(() => {
6977 container.scrollTop = 0;
6978 });
6979 };
6980
6981 /**
6982 * @param {HTMLElement} container
6983 * @param {HTMLElement} popup
6984 * @param {SweetAlertOptions} params
6985 */
6986 const addClasses = (container, popup, params) => {
6987 var _params$showClass;
6988 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6989 addClass(container, params.showClass.backdrop);
6990 }
6991 if (params.animation) {
6992 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6993 popup.style.setProperty('opacity', '0', 'important');
6994 show(popup, 'grid');
6995 setTimeout(() => {
6996 var _params$showClass2;
6997 // Animate popup right after showing it
6998 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6999 addClass(popup, params.showClass.popup);
7000 }
7001 // and remove the opacity workaround
7002 popup.style.removeProperty('opacity');
7003 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
7004 } else {
7005 show(popup, 'grid');
7006 }
7007 addClass([document.documentElement, document.body], swalClasses.shown);
7008 if (params.heightAuto && params.backdrop && !params.toast) {
7009 addClass([document.documentElement, document.body], swalClasses['height-auto']);
7010 }
7011 };
7012
7013 var defaultInputValidators = {
7014 /**
7015 * @param {string} string
7016 * @param {string} [validationMessage]
7017 * @returns {Promise<string | void>}
7018 */
7019 email: (string, validationMessage) => {
7020 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
7021 },
7022 /**
7023 * @param {string} string
7024 * @param {string} [validationMessage]
7025 * @returns {Promise<string | void>}
7026 */
7027 url: (string, validationMessage) => {
7028 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
7029 return /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-z]{2,63}\b([-a-zA-Z0-9@:%_+.~#?&/=]*)$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid URL');
7030 }
7031 };
7032
7033 /**
7034 * @param {SweetAlertOptions} params
7035 */
7036 function setDefaultInputValidators(params) {
7037 // Use default `inputValidator` for supported input types if not provided
7038 if (params.inputValidator) {
7039 return;
7040 }
7041 if (params.input === 'email') {
7042 params.inputValidator = defaultInputValidators['email'];
7043 }
7044 if (params.input === 'url') {
7045 params.inputValidator = defaultInputValidators['url'];
7046 }
7047 }
7048
7049 /**
7050 * @param {SweetAlertOptions} params
7051 */
7052 function validateCustomTargetElement(params) {
7053 // Determine if the custom target element is valid
7054 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
7055 warn('Target parameter is not valid, defaulting to "body"');
7056 params.target = 'body';
7057 }
7058 }
7059
7060 /**
7061 * Set type, text and actions on popup
7062 *
7063 * @param {SweetAlertOptions} params
7064 */
7065 function setParameters(params) {
7066 setDefaultInputValidators(params);
7067
7068 // showLoaderOnConfirm && preConfirm
7069 if (params.showLoaderOnConfirm && !params.preConfirm) {
7070 warn('showLoaderOnConfirm is set to true, but preConfirm is not defined.\n' + 'showLoaderOnConfirm should be used together with preConfirm, see usage example:\n' + 'https://sweetalert2.github.io/#ajax-request');
7071 }
7072 validateCustomTargetElement(params);
7073
7074 // Replace newlines with <br> in title
7075 if (typeof params.title === 'string') {
7076 params.title = params.title.split('\n').join('<br />');
7077 }
7078 init(params);
7079 }
7080
7081 /** @type {SweetAlert} */
7082 let currentInstance;
7083 var _promise = /*#__PURE__*/new WeakMap();
7084 class SweetAlert {
7085 /**
7086 * @param {...(SweetAlertOptions | string)} args
7087 * @this {SweetAlert}
7088 */
7089 constructor(...args) {
7090 /**
7091 * @type {Promise<SweetAlertResult>}
7092 */
7093 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
7094 isConfirmed: false,
7095 isDenied: false,
7096 isDismissed: true
7097 }));
7098 // Prevent run in Node env
7099 if (typeof window === 'undefined') {
7100 return;
7101 }
7102 currentInstance = this;
7103
7104 // @ts-ignore
7105 const outerParams = Object.freeze(this.constructor.argsToParams(args));
7106
7107 /** @type {Readonly<SweetAlertOptions>} */
7108 this.params = outerParams;
7109
7110 /** @type {boolean} */
7111 this.isAwaitingPromise = false;
7112 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
7113 }
7114
7115 /**
7116 * @param {any} userParams
7117 * @param {any} mixinParams
7118 */
7119 _main(userParams, mixinParams = {}) {
7120 showWarningsForParams(Object.assign({}, mixinParams, userParams));
7121 if (globalState.currentInstance) {
7122 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
7123 const {
7124 isAwaitingPromise
7125 } = globalState.currentInstance;
7126 globalState.currentInstance._destroy();
7127 if (!isAwaitingPromise) {
7128 swalPromiseResolve({
7129 isDismissed: true
7130 });
7131 }
7132 if (isModal()) {
7133 unsetAriaHidden();
7134 }
7135 }
7136 globalState.currentInstance = currentInstance;
7137 const innerParams = prepareParams(userParams, mixinParams);
7138 setParameters(innerParams);
7139 Object.freeze(innerParams);
7140
7141 // clear the previous timer
7142 if (globalState.timeout) {
7143 globalState.timeout.stop();
7144 delete globalState.timeout;
7145 }
7146
7147 // clear the restore focus timeout
7148 clearTimeout(globalState.restoreFocusTimeout);
7149 const domCache = populateDomCache(currentInstance);
7150 render(currentInstance, innerParams);
7151 privateProps.innerParams.set(currentInstance, innerParams);
7152 return swalPromise(currentInstance, domCache, innerParams);
7153 }
7154
7155 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
7156 /**
7157 * @param {any} onFulfilled
7158 */
7159 then(onFulfilled) {
7160 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
7161 }
7162
7163 /**
7164 * @param {any} onFinally
7165 */
7166 finally(onFinally) {
7167 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
7168 }
7169 }
7170
7171 /**
7172 * @param {SweetAlert} instance
7173 * @param {DomCache} domCache
7174 * @param {SweetAlertOptions} innerParams
7175 * @returns {Promise<SweetAlertResult>}
7176 */
7177 const swalPromise = (instance, domCache, innerParams) => {
7178 return new Promise((resolve, reject) => {
7179 // functions to handle all closings/dismissals
7180 /**
7181 * @param {DismissReason} dismiss
7182 */
7183 const dismissWith = dismiss => {
7184 instance.close({
7185 isDismissed: true,
7186 dismiss,
7187 isConfirmed: false,
7188 isDenied: false
7189 });
7190 };
7191 privateMethods.swalPromiseResolve.set(instance, resolve);
7192 privateMethods.swalPromiseReject.set(instance, reject);
7193 domCache.confirmButton.onclick = () => {
7194 handleConfirmButtonClick(instance);
7195 };
7196 domCache.denyButton.onclick = () => {
7197 handleDenyButtonClick(instance);
7198 };
7199 domCache.cancelButton.onclick = () => {
7200 handleCancelButtonClick(instance, dismissWith);
7201 };
7202 domCache.closeButton.onclick = () => {
7203 dismissWith(DismissReason.close);
7204 };
7205 handlePopupClick(innerParams, domCache, dismissWith);
7206 addKeydownHandler(globalState, innerParams, dismissWith);
7207 handleInputOptionsAndValue(instance, innerParams);
7208 openPopup(innerParams);
7209 setupTimer(globalState, innerParams, dismissWith);
7210 initFocus(domCache, innerParams);
7211
7212 // Scroll container to top on open (#1247, #1946)
7213 setTimeout(() => {
7214 domCache.container.scrollTop = 0;
7215 });
7216 });
7217 };
7218
7219 /**
7220 * @param {SweetAlertOptions} userParams
7221 * @param {SweetAlertOptions} mixinParams
7222 * @returns {SweetAlertOptions}
7223 */
7224 const prepareParams = (userParams, mixinParams) => {
7225 const templateParams = getTemplateParams(userParams);
7226 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
7227 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
7228 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
7229 if (params.animation === false) {
7230 params.showClass = {
7231 backdrop: 'swal2-noanimation'
7232 };
7233 params.hideClass = {};
7234 }
7235 return params;
7236 };
7237
7238 /**
7239 * @param {SweetAlert} instance
7240 * @returns {DomCache}
7241 */
7242 const populateDomCache = instance => {
7243 const domCache = /** @type {DomCache} */{
7244 popup: (/** @type {HTMLElement} */getPopup()),
7245 container: (/** @type {HTMLElement} */getContainer()),
7246 actions: (/** @type {HTMLElement} */getActions()),
7247 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
7248 denyButton: (/** @type {HTMLElement} */getDenyButton()),
7249 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
7250 loader: (/** @type {HTMLElement} */getLoader()),
7251 closeButton: (/** @type {HTMLElement} */getCloseButton()),
7252 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
7253 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
7254 };
7255 privateProps.domCache.set(instance, domCache);
7256 return domCache;
7257 };
7258
7259 /**
7260 * @param {GlobalState} globalState
7261 * @param {SweetAlertOptions} innerParams
7262 * @param {(dismiss: DismissReason) => void} dismissWith
7263 */
7264 const setupTimer = (globalState, innerParams, dismissWith) => {
7265 const timerProgressBar = getTimerProgressBar();
7266 hide(timerProgressBar);
7267 if (innerParams.timer) {
7268 globalState.timeout = new Timer(() => {
7269 dismissWith('timer');
7270 delete globalState.timeout;
7271 }, innerParams.timer);
7272 if (innerParams.timerProgressBar && timerProgressBar) {
7273 show(timerProgressBar);
7274 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
7275 setTimeout(() => {
7276 if (globalState.timeout && globalState.timeout.running) {
7277 // timer can be already stopped or unset at this point
7278 animateTimerProgressBar(/** @type {number} */innerParams.timer);
7279 }
7280 });
7281 }
7282 }
7283 };
7284
7285 /**
7286 * Initialize focus in the popup:
7287 *
7288 * 1. If `toast` is `true`, don't steal focus from the document.
7289 * 2. Else if there is an [autofocus] element, focus it.
7290 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
7291 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
7292 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
7293 * 6. Else focus the first focusable element in a popup (if any).
7294 *
7295 * @param {DomCache} domCache
7296 * @param {SweetAlertOptions} innerParams
7297 */
7298 const initFocus = (domCache, innerParams) => {
7299 if (innerParams.toast) {
7300 return;
7301 }
7302 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
7303 if (!callIfFunction(innerParams.allowEnterKey)) {
7304 warnAboutDeprecation('allowEnterKey');
7305 blurActiveElement();
7306 return;
7307 }
7308 if (focusAutofocus(domCache)) {
7309 return;
7310 }
7311 if (focusButton(domCache, innerParams)) {
7312 return;
7313 }
7314 setFocus(-1, 1);
7315 };
7316
7317 /**
7318 * @param {DomCache} domCache
7319 * @returns {boolean}
7320 */
7321 const focusAutofocus = domCache => {
7322 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
7323 for (const autofocusElement of autofocusElements) {
7324 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
7325 autofocusElement.focus();
7326 return true;
7327 }
7328 }
7329 return false;
7330 };
7331
7332 /**
7333 * @param {DomCache} domCache
7334 * @param {SweetAlertOptions} innerParams
7335 * @returns {boolean}
7336 */
7337 const focusButton = (domCache, innerParams) => {
7338 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
7339 domCache.denyButton.focus();
7340 return true;
7341 }
7342 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
7343 domCache.cancelButton.focus();
7344 return true;
7345 }
7346 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
7347 domCache.confirmButton.focus();
7348 return true;
7349 }
7350 return false;
7351 };
7352 const blurActiveElement = () => {
7353 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
7354 document.activeElement.blur();
7355 }
7356 };
7357
7358 // Assign instance methods from src/instanceMethods/*.js to prototype
7359 SweetAlert.prototype.disableButtons = disableButtons;
7360 SweetAlert.prototype.enableButtons = enableButtons;
7361 SweetAlert.prototype.getInput = getInput;
7362 SweetAlert.prototype.disableInput = disableInput;
7363 SweetAlert.prototype.enableInput = enableInput;
7364 SweetAlert.prototype.hideLoading = hideLoading;
7365 SweetAlert.prototype.disableLoading = hideLoading;
7366 SweetAlert.prototype.showValidationMessage = showValidationMessage;
7367 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
7368 SweetAlert.prototype.close = close;
7369 SweetAlert.prototype.closePopup = close;
7370 SweetAlert.prototype.closeModal = close;
7371 SweetAlert.prototype.closeToast = close;
7372 SweetAlert.prototype.rejectPromise = rejectPromise;
7373 SweetAlert.prototype.update = update;
7374 SweetAlert.prototype._destroy = _destroy;
7375
7376 // Assign static methods from src/staticMethods/*.js to constructor
7377 Object.assign(SweetAlert, staticMethods);
7378
7379 // Proxy to instance methods to constructor, for now, for backwards compatibility
7380 Object.keys(instanceMethods).forEach(key => {
7381 /**
7382 * @param {...(SweetAlertOptions | string | undefined)} args
7383 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
7384 */
7385 // @ts-ignore: Dynamic property assignment for backwards compatibility
7386 SweetAlert[key] = function (...args) {
7387 // @ts-ignore
7388 if (currentInstance && currentInstance[key]) {
7389 // @ts-ignore
7390 return currentInstance[key](...args);
7391 }
7392 return undefined;
7393 };
7394 });
7395 SweetAlert.DismissReason = DismissReason;
7396 SweetAlert.version = '11.26.17';
7397
7398 const Swal = SweetAlert;
7399 // @ts-ignore
7400 Swal.default = Swal;
7401
7402 return Swal;
7403
7404 }));
7405 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
7406 "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}");
7407
7408 /***/ },
7409
7410 /***/ "./node_modules/toastify-js/src/toastify.js"
7411 /*!**************************************************!*\
7412 !*** ./node_modules/toastify-js/src/toastify.js ***!
7413 \**************************************************/
7414 (module) {
7415
7416 /*!
7417 * Toastify js 1.12.0
7418 * https://github.com/apvarun/toastify-js
7419 * @license MIT licensed
7420 *
7421 * Copyright (C) 2018 Varun A P
7422 */
7423 (function(root, factory) {
7424 if ( true && module.exports) {
7425 module.exports = factory();
7426 } else {
7427 root.Toastify = factory();
7428 }
7429 })(this, function(global) {
7430 // Object initialization
7431 var Toastify = function(options) {
7432 // Returning a new init object
7433 return new Toastify.lib.init(options);
7434 },
7435 // Library version
7436 version = "1.12.0";
7437
7438 // Set the default global options
7439 Toastify.defaults = {
7440 oldestFirst: true,
7441 text: "Toastify is awesome!",
7442 node: undefined,
7443 duration: 3000,
7444 selector: undefined,
7445 callback: function () {
7446 },
7447 destination: undefined,
7448 newWindow: false,
7449 close: false,
7450 gravity: "toastify-top",
7451 positionLeft: false,
7452 position: '',
7453 backgroundColor: '',
7454 avatar: "",
7455 className: "",
7456 stopOnFocus: true,
7457 onClick: function () {
7458 },
7459 offset: {x: 0, y: 0},
7460 escapeMarkup: true,
7461 ariaLive: 'polite',
7462 style: {background: ''}
7463 };
7464
7465 // Defining the prototype of the object
7466 Toastify.lib = Toastify.prototype = {
7467 toastify: version,
7468
7469 constructor: Toastify,
7470
7471 // Initializing the object with required parameters
7472 init: function(options) {
7473 // Verifying and validating the input object
7474 if (!options) {
7475 options = {};
7476 }
7477
7478 // Creating the options object
7479 this.options = {};
7480
7481 this.toastElement = null;
7482
7483 // Validating the options
7484 this.options.text = options.text || Toastify.defaults.text; // Display message
7485 this.options.node = options.node || Toastify.defaults.node; // Display content as node
7486 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
7487 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
7488 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
7489 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
7490 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
7491 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
7492 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
7493 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
7494 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
7495 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
7496 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
7497 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
7498 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
7499 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
7500 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
7501 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
7502 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
7503 this.options.style = options.style || Toastify.defaults.style;
7504 if(options.backgroundColor) {
7505 this.options.style.background = options.backgroundColor;
7506 }
7507
7508 // Returning the current object for chaining functions
7509 return this;
7510 },
7511
7512 // Building the DOM element
7513 buildToast: function() {
7514 // Validating if the options are defined
7515 if (!this.options) {
7516 throw "Toastify is not initialized";
7517 }
7518
7519 // Creating the DOM object
7520 var divElement = document.createElement("div");
7521 divElement.className = "toastify on " + this.options.className;
7522
7523 // Positioning toast to left or right or center
7524 if (!!this.options.position) {
7525 divElement.className += " toastify-" + this.options.position;
7526 } else {
7527 // To be depreciated in further versions
7528 if (this.options.positionLeft === true) {
7529 divElement.className += " toastify-left";
7530 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
7531 } else {
7532 // Default position
7533 divElement.className += " toastify-right";
7534 }
7535 }
7536
7537 // Assigning gravity of element
7538 divElement.className += " " + this.options.gravity;
7539
7540 if (this.options.backgroundColor) {
7541 // This is being deprecated in favor of using the style HTML DOM property
7542 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
7543 }
7544
7545 // Loop through our style object and apply styles to divElement
7546 for (var property in this.options.style) {
7547 divElement.style[property] = this.options.style[property];
7548 }
7549
7550 // Announce the toast to screen readers
7551 if (this.options.ariaLive) {
7552 divElement.setAttribute('aria-live', this.options.ariaLive)
7553 }
7554
7555 // Adding the toast message/node
7556 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
7557 // If we have a valid node, we insert it
7558 divElement.appendChild(this.options.node)
7559 } else {
7560 if (this.options.escapeMarkup) {
7561 divElement.innerText = this.options.text;
7562 } else {
7563 divElement.innerHTML = this.options.text;
7564 }
7565
7566 if (this.options.avatar !== "") {
7567 var avatarElement = document.createElement("img");
7568 avatarElement.src = this.options.avatar;
7569
7570 avatarElement.className = "toastify-avatar";
7571
7572 if (this.options.position == "left" || this.options.positionLeft === true) {
7573 // Adding close icon on the left of content
7574 divElement.appendChild(avatarElement);
7575 } else {
7576 // Adding close icon on the right of content
7577 divElement.insertAdjacentElement("afterbegin", avatarElement);
7578 }
7579 }
7580 }
7581
7582 // Adding a close icon to the toast
7583 if (this.options.close === true) {
7584 // Create a span for close element
7585 var closeElement = document.createElement("button");
7586 closeElement.type = "button";
7587 closeElement.setAttribute("aria-label", "Close");
7588 closeElement.className = "toast-close";
7589 closeElement.innerHTML = "&#10006;";
7590
7591 // Triggering the removal of toast from DOM on close click
7592 closeElement.addEventListener(
7593 "click",
7594 function(event) {
7595 event.stopPropagation();
7596 this.removeElement(this.toastElement);
7597 window.clearTimeout(this.toastElement.timeOutValue);
7598 }.bind(this)
7599 );
7600
7601 //Calculating screen width
7602 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7603
7604 // Adding the close icon to the toast element
7605 // Display on the right if screen width is less than or equal to 360px
7606 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7607 // Adding close icon on the left of content
7608 divElement.insertAdjacentElement("afterbegin", closeElement);
7609 } else {
7610 // Adding close icon on the right of content
7611 divElement.appendChild(closeElement);
7612 }
7613 }
7614
7615 // Clear timeout while toast is focused
7616 if (this.options.stopOnFocus && this.options.duration > 0) {
7617 var self = this;
7618 // stop countdown
7619 divElement.addEventListener(
7620 "mouseover",
7621 function(event) {
7622 window.clearTimeout(divElement.timeOutValue);
7623 }
7624 )
7625 // add back the timeout
7626 divElement.addEventListener(
7627 "mouseleave",
7628 function() {
7629 divElement.timeOutValue = window.setTimeout(
7630 function() {
7631 // Remove the toast from DOM
7632 self.removeElement(divElement);
7633 },
7634 self.options.duration
7635 )
7636 }
7637 )
7638 }
7639
7640 // Adding an on-click destination path
7641 if (typeof this.options.destination !== "undefined") {
7642 divElement.addEventListener(
7643 "click",
7644 function(event) {
7645 event.stopPropagation();
7646 if (this.options.newWindow === true) {
7647 window.open(this.options.destination, "_blank");
7648 } else {
7649 window.location = this.options.destination;
7650 }
7651 }.bind(this)
7652 );
7653 }
7654
7655 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7656 divElement.addEventListener(
7657 "click",
7658 function(event) {
7659 event.stopPropagation();
7660 this.options.onClick();
7661 }.bind(this)
7662 );
7663 }
7664
7665 // Adding offset
7666 if(typeof this.options.offset === "object") {
7667
7668 var x = getAxisOffsetAValue("x", this.options);
7669 var y = getAxisOffsetAValue("y", this.options);
7670
7671 var xOffset = this.options.position == "left" ? x : "-" + x;
7672 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7673
7674 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7675
7676 }
7677
7678 // Returning the generated element
7679 return divElement;
7680 },
7681
7682 // Displaying the toast
7683 showToast: function() {
7684 // Creating the DOM object for the toast
7685 this.toastElement = this.buildToast();
7686
7687 // Getting the root element to with the toast needs to be added
7688 var rootElement;
7689 if (typeof this.options.selector === "string") {
7690 rootElement = document.getElementById(this.options.selector);
7691 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7692 rootElement = this.options.selector;
7693 } else {
7694 rootElement = document.body;
7695 }
7696
7697 // Validating if root element is present in DOM
7698 if (!rootElement) {
7699 throw "Root element is not defined";
7700 }
7701
7702 // Adding the DOM element
7703 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7704 rootElement.insertBefore(this.toastElement, elementToInsert);
7705
7706 // Repositioning the toasts in case multiple toasts are present
7707 Toastify.reposition();
7708
7709 if (this.options.duration > 0) {
7710 this.toastElement.timeOutValue = window.setTimeout(
7711 function() {
7712 // Remove the toast from DOM
7713 this.removeElement(this.toastElement);
7714 }.bind(this),
7715 this.options.duration
7716 ); // Binding `this` for function invocation
7717 }
7718
7719 // Supporting function chaining
7720 return this;
7721 },
7722
7723 hideToast: function() {
7724 if (this.toastElement.timeOutValue) {
7725 clearTimeout(this.toastElement.timeOutValue);
7726 }
7727 this.removeElement(this.toastElement);
7728 },
7729
7730 // Removing the element from the DOM
7731 removeElement: function(toastElement) {
7732 // Hiding the element
7733 // toastElement.classList.remove("on");
7734 toastElement.className = toastElement.className.replace(" on", "");
7735
7736 // Removing the element from DOM after transition end
7737 window.setTimeout(
7738 function() {
7739 // remove options node if any
7740 if (this.options.node && this.options.node.parentNode) {
7741 this.options.node.parentNode.removeChild(this.options.node);
7742 }
7743
7744 // Remove the element from the DOM, only when the parent node was not removed before.
7745 if (toastElement.parentNode) {
7746 toastElement.parentNode.removeChild(toastElement);
7747 }
7748
7749 // Calling the callback function
7750 this.options.callback.call(toastElement);
7751
7752 // Repositioning the toasts again
7753 Toastify.reposition();
7754 }.bind(this),
7755 400
7756 ); // Binding `this` for function invocation
7757 },
7758 };
7759
7760 // Positioning the toasts on the DOM
7761 Toastify.reposition = function() {
7762
7763 // Top margins with gravity
7764 var topLeftOffsetSize = {
7765 top: 15,
7766 bottom: 15,
7767 };
7768 var topRightOffsetSize = {
7769 top: 15,
7770 bottom: 15,
7771 };
7772 var offsetSize = {
7773 top: 15,
7774 bottom: 15,
7775 };
7776
7777 // Get all toast messages on the DOM
7778 var allToasts = document.getElementsByClassName("toastify");
7779
7780 var classUsed;
7781
7782 // Modifying the position of each toast element
7783 for (var i = 0; i < allToasts.length; i++) {
7784 // Getting the applied gravity
7785 if (containsClass(allToasts[i], "toastify-top") === true) {
7786 classUsed = "toastify-top";
7787 } else {
7788 classUsed = "toastify-bottom";
7789 }
7790
7791 var height = allToasts[i].offsetHeight;
7792 classUsed = classUsed.substr(9, classUsed.length-1)
7793 // Spacing between toasts
7794 var offset = 15;
7795
7796 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7797
7798 // Show toast in center if screen with less than or equal to 360px
7799 if (width <= 360) {
7800 // Setting the position
7801 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7802
7803 offsetSize[classUsed] += height + offset;
7804 } else {
7805 if (containsClass(allToasts[i], "toastify-left") === true) {
7806 // Setting the position
7807 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7808
7809 topLeftOffsetSize[classUsed] += height + offset;
7810 } else {
7811 // Setting the position
7812 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7813
7814 topRightOffsetSize[classUsed] += height + offset;
7815 }
7816 }
7817 }
7818
7819 // Supporting function chaining
7820 return this;
7821 };
7822
7823 // Helper function to get offset.
7824 function getAxisOffsetAValue(axis, options) {
7825
7826 if(options.offset[axis]) {
7827 if(isNaN(options.offset[axis])) {
7828 return options.offset[axis];
7829 }
7830 else {
7831 return options.offset[axis] + 'px';
7832 }
7833 }
7834
7835 return '0px';
7836
7837 }
7838
7839 function containsClass(elem, yourClass) {
7840 if (!elem || typeof yourClass !== "string") {
7841 return false;
7842 } else if (
7843 elem.className &&
7844 elem.className
7845 .trim()
7846 .split(/\s+/gi)
7847 .indexOf(yourClass) > -1
7848 ) {
7849 return true;
7850 } else {
7851 return false;
7852 }
7853 }
7854
7855 // Setting up the prototype for the init object
7856 Toastify.lib.init.prototype = Toastify.lib;
7857
7858 // Returning the Toastify function to be assigned to the window object/module
7859 return Toastify;
7860 });
7861
7862
7863 /***/ },
7864
7865 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7866 /*!**********************************************************!*\
7867 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7868 \**********************************************************/
7869 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7870
7871 "use strict";
7872 __webpack_require__.r(__webpack_exports__);
7873 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7874 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7875 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7876 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7877 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7878 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7879 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7880 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7881 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7882 /* harmony export */ });
7883 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7884 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7885 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7886 /**
7887 * sifter.js
7888 * Copyright (c) 2013–2020 Brian Reavis & contributors
7889 *
7890 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7891 * file except in compliance with the License. You may obtain a copy of the License at:
7892 * http://www.apache.org/licenses/LICENSE-2.0
7893 *
7894 * Unless required by applicable law or agreed to in writing, software distributed under
7895 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7896 * ANY KIND, either express or implied. See the License for the specific language
7897 * governing permissions and limitations under the License.
7898 *
7899 * @author Brian Reavis <[email protected]>
7900 */
7901
7902
7903 class Sifter {
7904 items; // []|{};
7905 settings;
7906 /**
7907 * Textually searches arrays and hashes of objects
7908 * by property (or multiple properties). Designed
7909 * specifically for autocomplete.
7910 *
7911 */
7912 constructor(items, settings) {
7913 this.items = items;
7914 this.settings = settings || { diacritics: true };
7915 }
7916 ;
7917 /**
7918 * Splits a search string into an array of individual
7919 * regexps to be used to match results.
7920 *
7921 */
7922 tokenize(query, respect_word_boundaries, weights) {
7923 if (!query || !query.length)
7924 return [];
7925 const tokens = [];
7926 const words = query.split(/\s+/);
7927 var field_regex;
7928 if (weights) {
7929 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7930 }
7931 words.forEach((word) => {
7932 let field_match;
7933 let field = null;
7934 let regex = null;
7935 // look for "field:query" tokens
7936 if (field_regex && (field_match = word.match(field_regex))) {
7937 field = field_match[1];
7938 word = field_match[2];
7939 }
7940 if (word.length > 0) {
7941 if (this.settings.diacritics) {
7942 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7943 }
7944 else {
7945 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7946 }
7947 if (regex && respect_word_boundaries)
7948 regex = "\\b" + regex;
7949 }
7950 tokens.push({
7951 string: word,
7952 regex: regex ? new RegExp(regex, 'iu') : null,
7953 field: field,
7954 });
7955 });
7956 return tokens;
7957 }
7958 ;
7959 /**
7960 * Returns a function to be used to score individual results.
7961 *
7962 * Good matches will have a higher score than poor matches.
7963 * If an item is not a match, 0 will be returned by the function.
7964 *
7965 * @returns {T.ScoreFn}
7966 */
7967 getScoreFunction(query, options) {
7968 var search = this.prepareSearch(query, options);
7969 return this._getScoreFunction(search);
7970 }
7971 /**
7972 * @returns {T.ScoreFn}
7973 *
7974 */
7975 _getScoreFunction(search) {
7976 const tokens = search.tokens, token_count = tokens.length;
7977 if (!token_count) {
7978 return function () { return 0; };
7979 }
7980 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7981 if (!field_count) {
7982 return function () { return 1; };
7983 }
7984 /**
7985 * Calculates the score of an object
7986 * against the search query.
7987 *
7988 */
7989 const scoreObject = (function () {
7990 if (field_count === 1) {
7991 return function (token, data) {
7992 const field = fields[0].field;
7993 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7994 };
7995 }
7996 return function (token, data) {
7997 var sum = 0;
7998 // is the token specific to a field?
7999 if (token.field) {
8000 const value = getAttrFn(data, token.field);
8001 if (!token.regex && value) {
8002 sum += (1 / field_count);
8003 }
8004 else {
8005 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
8006 }
8007 }
8008 else {
8009 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
8010 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
8011 });
8012 }
8013 return sum / field_count;
8014 };
8015 })();
8016 if (token_count === 1) {
8017 return function (data) {
8018 return scoreObject(tokens[0], data);
8019 };
8020 }
8021 if (search.options.conjunction === 'and') {
8022 return function (data) {
8023 var score, sum = 0;
8024 for (let token of tokens) {
8025 score = scoreObject(token, data);
8026 if (score <= 0)
8027 return 0;
8028 sum += score;
8029 }
8030 return sum / token_count;
8031 };
8032 }
8033 else {
8034 return function (data) {
8035 var sum = 0;
8036 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
8037 sum += scoreObject(token, data);
8038 });
8039 return sum / token_count;
8040 };
8041 }
8042 }
8043 ;
8044 /**
8045 * Returns a function that can be used to compare two
8046 * results, for sorting purposes. If no sorting should
8047 * be performed, `null` will be returned.
8048 *
8049 * @return function(a,b)
8050 */
8051 getSortFunction(query, options) {
8052 var search = this.prepareSearch(query, options);
8053 return this._getSortFunction(search);
8054 }
8055 _getSortFunction(search) {
8056 var implicit_score, sort_flds = [];
8057 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
8058 if (typeof sort == 'function') {
8059 return sort.bind(this);
8060 }
8061 /**
8062 * Fetches the specified sort field value
8063 * from a search result item.
8064 *
8065 */
8066 const get_field = function (name, result) {
8067 if (name === '$score')
8068 return result.score;
8069 return search.getAttrFn(self.items[result.id], name);
8070 };
8071 // parse options
8072 if (sort) {
8073 for (let s of sort) {
8074 if (search.query || s.field !== '$score') {
8075 sort_flds.push(s);
8076 }
8077 }
8078 }
8079 // the "$score" field is implied to be the primary
8080 // sort field, unless it's manually specified
8081 if (search.query) {
8082 implicit_score = true;
8083 for (let fld of sort_flds) {
8084 if (fld.field === '$score') {
8085 implicit_score = false;
8086 break;
8087 }
8088 }
8089 if (implicit_score) {
8090 sort_flds.unshift({ field: '$score', direction: 'desc' });
8091 }
8092 // without a search.query, all items will have the same score
8093 }
8094 else {
8095 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
8096 }
8097 // build function
8098 const sort_flds_count = sort_flds.length;
8099 if (!sort_flds_count) {
8100 return null;
8101 }
8102 return function (a, b) {
8103 var result, field;
8104 for (let sort_fld of sort_flds) {
8105 field = sort_fld.field;
8106 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
8107 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
8108 if (result)
8109 return result;
8110 }
8111 return 0;
8112 };
8113 }
8114 ;
8115 /**
8116 * Parses a search query and returns an object
8117 * with tokens and fields ready to be populated
8118 * with results.
8119 *
8120 */
8121 prepareSearch(query, optsUser) {
8122 const weights = {};
8123 var options = Object.assign({}, optsUser);
8124 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
8125 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
8126 // convert fields to new format
8127 if (options.fields) {
8128 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
8129 const fields = [];
8130 options.fields.forEach((field) => {
8131 if (typeof field == 'string') {
8132 field = { field: field, weight: 1 };
8133 }
8134 fields.push(field);
8135 weights[field.field] = ('weight' in field) ? field.weight : 1;
8136 });
8137 options.fields = fields;
8138 }
8139 return {
8140 options: options,
8141 query: query.toLowerCase().trim(),
8142 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
8143 total: 0,
8144 items: [],
8145 weights: weights,
8146 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
8147 };
8148 }
8149 ;
8150 /**
8151 * Searches through all items and returns a sorted array of matches.
8152 *
8153 */
8154 search(query, options) {
8155 var self = this, score, search;
8156 search = this.prepareSearch(query, options);
8157 options = search.options;
8158 query = search.query;
8159 // generate result scoring function
8160 const fn_score = options.score || self._getScoreFunction(search);
8161 // perform search and sort
8162 if (query.length) {
8163 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
8164 score = fn_score(item);
8165 if (options.filter === false || score > 0) {
8166 search.items.push({ 'score': score, 'id': id });
8167 }
8168 });
8169 }
8170 else {
8171 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
8172 search.items.push({ 'score': 1, 'id': id });
8173 });
8174 }
8175 const fn_sort = self._getSortFunction(search);
8176 if (fn_sort)
8177 search.items.sort(fn_sort);
8178 // apply limits
8179 search.total = search.items.length;
8180 if (typeof options.limit === 'number') {
8181 search.items = search.items.slice(0, options.limit);
8182 }
8183 return search;
8184 }
8185 ;
8186 }
8187
8188
8189 //# sourceMappingURL=sifter.js.map
8190
8191 /***/ },
8192
8193 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
8194 /*!*********************************************************!*\
8195 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
8196 \*********************************************************/
8197 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8198
8199 "use strict";
8200 __webpack_require__.r(__webpack_exports__);
8201
8202 //# sourceMappingURL=types.js.map
8203
8204 /***/ },
8205
8206 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
8207 /*!*********************************************************!*\
8208 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
8209 \*********************************************************/
8210 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8211
8212 "use strict";
8213 __webpack_require__.r(__webpack_exports__);
8214 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8215 /* harmony export */ cmp: () => (/* binding */ cmp),
8216 /* harmony export */ getAttr: () => (/* binding */ getAttr),
8217 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
8218 /* harmony export */ iterate: () => (/* binding */ iterate),
8219 /* harmony export */ propToArray: () => (/* binding */ propToArray),
8220 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
8221 /* harmony export */ });
8222 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
8223
8224 /**
8225 * A property getter resolving dot-notation
8226 * @param {Object} obj The root object to fetch property on
8227 * @param {String} name The optionally dotted property name to fetch
8228 * @return {Object} The resolved property value
8229 */
8230 const getAttr = (obj, name) => {
8231 if (!obj)
8232 return;
8233 return obj[name];
8234 };
8235 /**
8236 * A property getter resolving dot-notation
8237 * @param {Object} obj The root object to fetch property on
8238 * @param {String} name The optionally dotted property name to fetch
8239 * @return {Object} The resolved property value
8240 */
8241 const getAttrNesting = (obj, name) => {
8242 if (!obj)
8243 return;
8244 var part, names = name.split(".");
8245 while ((part = names.shift()) && (obj = obj[part]))
8246 ;
8247 return obj;
8248 };
8249 /**
8250 * Calculates how close of a match the
8251 * given value is against a search token.
8252 *
8253 */
8254 const scoreValue = (value, token, weight) => {
8255 var score, pos;
8256 if (!value)
8257 return 0;
8258 value = value + '';
8259 if (token.regex == null)
8260 return 0;
8261 pos = value.search(token.regex);
8262 if (pos === -1)
8263 return 0;
8264 score = token.string.length / value.length;
8265 if (pos === 0)
8266 score += 0.5;
8267 return score * weight;
8268 };
8269 /**
8270 * Cast object property to an array if it exists and has a value
8271 *
8272 */
8273 const propToArray = (obj, key) => {
8274 var value = obj[key];
8275 if (typeof value == 'function')
8276 return value;
8277 if (value && !Array.isArray(value)) {
8278 obj[key] = [value];
8279 }
8280 };
8281 /**
8282 * Iterates over arrays and hashes.
8283 *
8284 * ```
8285 * iterate(this.items, function(item, id) {
8286 * // invoked for each item
8287 * });
8288 * ```
8289 *
8290 */
8291 const iterate = (object, callback) => {
8292 if (Array.isArray(object)) {
8293 object.forEach(callback);
8294 }
8295 else {
8296 for (var key in object) {
8297 if (object.hasOwnProperty(key)) {
8298 callback(object[key], key);
8299 }
8300 }
8301 }
8302 };
8303 const cmp = (a, b) => {
8304 if (typeof a === 'number' && typeof b === 'number') {
8305 return a > b ? 1 : (a < b ? -1 : 0);
8306 }
8307 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
8308 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
8309 if (a > b)
8310 return 1;
8311 if (b > a)
8312 return -1;
8313 return 0;
8314 };
8315 //# sourceMappingURL=utils.js.map
8316
8317 /***/ },
8318
8319 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
8320 /*!*******************************************************************!*\
8321 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
8322 \*******************************************************************/
8323 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8324
8325 "use strict";
8326 __webpack_require__.r(__webpack_exports__);
8327 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8328 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
8329 /* harmony export */ asciifold: () => (/* binding */ asciifold),
8330 /* harmony export */ code_points: () => (/* binding */ code_points),
8331 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
8332 /* harmony export */ generateMap: () => (/* binding */ generateMap),
8333 /* harmony export */ generateSets: () => (/* binding */ generateSets),
8334 /* harmony export */ generator: () => (/* binding */ generator),
8335 /* harmony export */ getPattern: () => (/* binding */ getPattern),
8336 /* harmony export */ initialize: () => (/* binding */ initialize),
8337 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
8338 /* harmony export */ normalize: () => (/* binding */ normalize),
8339 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
8340 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
8341 /* harmony export */ });
8342 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
8343 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
8344
8345
8346 const code_points = [[0, 65535]];
8347 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
8348 let unicode_map;
8349 let multi_char_reg;
8350 const max_char_length = 3;
8351 const latin_convert = {};
8352 const latin_condensed = {
8353 '/': '⁄∕',
8354 '0': '߀',
8355 "a": "ⱥɐɑ",
8356 "aa": "ꜳ",
8357 "ae": "æǽǣ",
8358 "ao": "ꜵ",
8359 "au": "ꜷ",
8360 "av": "ꜹꜻ",
8361 "ay": "ꜽ",
8362 "b": "ƀɓƃ",
8363 "c": "ꜿƈȼↄ",
8364 "d": "đɗɖᴅƌꮷԁɦ",
8365 "e": "ɛǝᴇɇ",
8366 "f": "ꝼƒ",
8367 "g": "ǥɠꞡᵹꝿɢ",
8368 "h": "ħⱨⱶɥ",
8369 "i": "ɨı",
8370 "j": "ɉȷ",
8371 "k": "ƙⱪꝁꝃꝅꞣ",
8372 "l": "łƚɫⱡꝉꝇꞁɭ",
8373 "m": "ɱɯϻ",
8374 "n": "ꞥƞɲꞑᴎлԉ",
8375 "o": "øǿɔɵꝋꝍᴑ",
8376 "oe": "œ",
8377 "oi": "ƣ",
8378 "oo": "ꝏ",
8379 "ou": "ȣ",
8380 "p": "ƥᵽꝑꝓꝕρ",
8381 "q": "ꝗꝙɋ",
8382 "r": "ɍɽꝛꞧꞃ",
8383 "s": "ßȿꞩꞅʂ",
8384 "t": "ŧƭʈⱦꞇ",
8385 "th": "þ",
8386 "tz": "ꜩ",
8387 "u": "ʉ",
8388 "v": "ʋꝟʌ",
8389 "vy": "ꝡ",
8390 "w": "ⱳ",
8391 "y": "ƴɏỿ",
8392 "z": "ƶȥɀⱬꝣ",
8393 "hv": "ƕ"
8394 };
8395 for (let latin in latin_condensed) {
8396 let unicode = latin_condensed[latin] || '';
8397 for (let i = 0; i < unicode.length; i++) {
8398 let char = unicode.substring(i, i + 1);
8399 latin_convert[char] = latin;
8400 }
8401 }
8402 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
8403 /**
8404 * Initialize the unicode_map from the give code point ranges
8405 */
8406 const initialize = (_code_points) => {
8407 if (unicode_map !== undefined)
8408 return;
8409 unicode_map = generateMap(_code_points || code_points);
8410 };
8411 /**
8412 * Helper method for normalize a string
8413 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
8414 */
8415 const normalize = (str, form = 'NFKD') => str.normalize(form);
8416 /**
8417 * Remove accents without reordering string
8418 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
8419 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
8420 */
8421 const asciifold = (str) => {
8422 return Array.from(str).reduce(
8423 /**
8424 * @param {string} result
8425 * @param {string} char
8426 */
8427 (result, char) => {
8428 return result + _asciifold(char);
8429 }, '');
8430 };
8431 const _asciifold = (str) => {
8432 str = normalize(str)
8433 .toLowerCase()
8434 .replace(convert_pat, (/** @type {string} */ char) => {
8435 return latin_convert[char] || '';
8436 });
8437 //return str;
8438 return normalize(str, 'NFC');
8439 };
8440 /**
8441 * Generate a list of unicode variants from the list of code points
8442 */
8443 function* generator(code_points) {
8444 for (const [code_point_min, code_point_max] of code_points) {
8445 for (let i = code_point_min; i <= code_point_max; i++) {
8446 let composed = String.fromCharCode(i);
8447 let folded = asciifold(composed);
8448 if (folded == composed.toLowerCase()) {
8449 continue;
8450 }
8451 // skip when folded is a string longer than 3 characters long
8452 // bc the resulting regex patterns will be long
8453 // eg:
8454 // folded صلى الله عليه وسلم length 18 code point 65018
8455 // folded جل جلاله length 8 code point 65019
8456 if (folded.length > max_char_length) {
8457 continue;
8458 }
8459 if (folded.length == 0) {
8460 continue;
8461 }
8462 yield { folded: folded, composed: composed, code_point: i };
8463 }
8464 }
8465 }
8466 /**
8467 * Generate a unicode map from the list of code points
8468 */
8469 const generateSets = (code_points) => {
8470 const unicode_sets = {};
8471 const addMatching = (folded, to_add) => {
8472 /** @type {Set<string>} */
8473 const folded_set = unicode_sets[folded] || new Set();
8474 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
8475 if (to_add.match(patt)) {
8476 return;
8477 }
8478 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
8479 unicode_sets[folded] = folded_set;
8480 };
8481 for (let value of generator(code_points)) {
8482 addMatching(value.folded, value.folded);
8483 addMatching(value.folded, value.composed);
8484 }
8485 return unicode_sets;
8486 };
8487 /**
8488 * Generate a unicode map from the list of code points
8489 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
8490 */
8491 const generateMap = (code_points) => {
8492 const unicode_sets = generateSets(code_points);
8493 const unicode_map = {};
8494 let multi_char = [];
8495 for (let folded in unicode_sets) {
8496 let set = unicode_sets[folded];
8497 if (set) {
8498 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
8499 }
8500 if (folded.length > 1) {
8501 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
8502 }
8503 }
8504 multi_char.sort((a, b) => b.length - a.length);
8505 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
8506 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
8507 return unicode_map;
8508 };
8509 /**
8510 * Map each element of an array from its folded value to all possible unicode matches
8511 */
8512 const mapSequence = (strings, min_replacement = 1) => {
8513 let chars_replaced = 0;
8514 strings = strings.map((str) => {
8515 if (unicode_map[str]) {
8516 chars_replaced += str.length;
8517 }
8518 return unicode_map[str] || str;
8519 });
8520 if (chars_replaced >= min_replacement) {
8521 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
8522 }
8523 return '';
8524 };
8525 /**
8526 * Convert a short string and split it into all possible patterns
8527 * Keep a pattern only if min_replacement is met
8528 *
8529 * 'abc'
8530 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
8531 * => ['abc-pattern','ab-c-pattern'...]
8532 */
8533 const substringsToPattern = (str, min_replacement = 1) => {
8534 min_replacement = Math.max(min_replacement, str.length - 1);
8535 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
8536 return mapSequence(sub_pat, min_replacement);
8537 }));
8538 };
8539 /**
8540 * Convert an array of sequences into a pattern
8541 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
8542 */
8543 const sequencesToPattern = (sequences, all = true) => {
8544 let min_replacement = sequences.length > 1 ? 1 : 0;
8545 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
8546 let seq = [];
8547 const len = all ? sequence.length() : sequence.length() - 1;
8548 for (let j = 0; j < len; j++) {
8549 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
8550 }
8551 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
8552 }));
8553 };
8554 /**
8555 * Return true if the sequence is already in the sequences
8556 */
8557 const inSequences = (needle_seq, sequences) => {
8558 for (const seq of sequences) {
8559 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
8560 continue;
8561 }
8562 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
8563 continue;
8564 }
8565 let needle_parts = needle_seq.parts;
8566 const filter = (part) => {
8567 for (const needle_part of needle_parts) {
8568 if (needle_part.start === part.start && needle_part.substr === part.substr) {
8569 return false;
8570 }
8571 if (part.length == 1 || needle_part.length == 1) {
8572 continue;
8573 }
8574 // check for overlapping parts
8575 // a = ['::=','==']
8576 // b = ['::','===']
8577 // a = ['r','sm']
8578 // b = ['rs','m']
8579 if (part.start < needle_part.start && part.end > needle_part.start) {
8580 return true;
8581 }
8582 if (needle_part.start < part.start && needle_part.end > part.start) {
8583 return true;
8584 }
8585 }
8586 return false;
8587 };
8588 let filtered = seq.parts.filter(filter);
8589 if (filtered.length > 0) {
8590 continue;
8591 }
8592 return true;
8593 }
8594 return false;
8595 };
8596 class Sequence {
8597 parts;
8598 substrs;
8599 start;
8600 end;
8601 constructor() {
8602 this.parts = [];
8603 this.substrs = [];
8604 this.start = 0;
8605 this.end = 0;
8606 }
8607 add(part) {
8608 if (part) {
8609 this.parts.push(part);
8610 this.substrs.push(part.substr);
8611 this.start = Math.min(part.start, this.start);
8612 this.end = Math.max(part.end, this.end);
8613 }
8614 }
8615 last() {
8616 return this.parts[this.parts.length - 1];
8617 }
8618 length() {
8619 return this.parts.length;
8620 }
8621 clone(position, last_piece) {
8622 let clone = new Sequence();
8623 let parts = JSON.parse(JSON.stringify(this.parts));
8624 let last_part = parts.pop();
8625 for (const part of parts) {
8626 clone.add(part);
8627 }
8628 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8629 let clone_last_len = last_substr.length;
8630 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8631 return clone;
8632 }
8633 }
8634 /**
8635 * Expand a regular expression pattern to include unicode variants
8636 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8637 *
8638 * Issue:
8639 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8640 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8641 *
8642 * İIJ = IIJ = ⅡJ
8643 *
8644 * 1/2/4
8645 */
8646 const getPattern = (str) => {
8647 initialize();
8648 str = asciifold(str);
8649 let pattern = '';
8650 let sequences = [new Sequence()];
8651 for (let i = 0; i < str.length; i++) {
8652 let substr = str.substring(i);
8653 let match = substr.match(multi_char_reg);
8654 const char = str.substring(i, i + 1);
8655 const match_str = match ? match[0] : null;
8656 // loop through sequences
8657 // add either the char or multi_match
8658 let overlapping = [];
8659 let added_types = new Set();
8660 for (const sequence of sequences) {
8661 const last_piece = sequence.last();
8662 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8663 // if we have a multi match
8664 if (match_str) {
8665 const len = match_str.length;
8666 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8667 added_types.add('1');
8668 }
8669 else {
8670 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8671 added_types.add('2');
8672 }
8673 }
8674 else if (match_str) {
8675 let clone = sequence.clone(i, last_piece);
8676 const len = match_str.length;
8677 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8678 overlapping.push(clone);
8679 }
8680 else {
8681 // don't add char
8682 // adding would create invalid patterns: 234 => [2,34,4]
8683 added_types.add('3');
8684 }
8685 }
8686 // if we have overlapping
8687 if (overlapping.length > 0) {
8688 // ['ii','iii'] before ['i','i','iii']
8689 overlapping = overlapping.sort((a, b) => {
8690 return a.length() - b.length();
8691 });
8692 for (let clone of overlapping) {
8693 // don't add if we already have an equivalent sequence
8694 if (inSequences(clone, sequences)) {
8695 continue;
8696 }
8697 sequences.push(clone);
8698 }
8699 continue;
8700 }
8701 // if we haven't done anything unique
8702 // clean up the patterns
8703 // helps keep patterns smaller
8704 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8705 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8706 pattern += sequencesToPattern(sequences, false);
8707 let new_seq = new Sequence();
8708 const old_seq = sequences[0];
8709 if (old_seq) {
8710 new_seq.add(old_seq.last());
8711 }
8712 sequences = [new_seq];
8713 }
8714 }
8715 pattern += sequencesToPattern(sequences, true);
8716 return pattern;
8717 };
8718
8719 //# sourceMappingURL=index.js.map
8720
8721 /***/ },
8722
8723 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8724 /*!*******************************************************************!*\
8725 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8726 \*******************************************************************/
8727 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8728
8729 "use strict";
8730 __webpack_require__.r(__webpack_exports__);
8731 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8732 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8733 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8734 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8735 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8736 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8737 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8738 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8739 /* harmony export */ });
8740 /**
8741 * Convert array of strings to a regular expression
8742 * ex ['ab','a'] => (?:ab|a)
8743 * ex ['a','b'] => [ab]
8744 */
8745 const arrayToPattern = (chars) => {
8746 chars = chars.filter(Boolean);
8747 if (chars.length < 2) {
8748 return chars[0] || '';
8749 }
8750 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8751 };
8752 const sequencePattern = (array) => {
8753 if (!hasDuplicates(array)) {
8754 return array.join('');
8755 }
8756 let pattern = '';
8757 let prev_char_count = 0;
8758 const prev_pattern = () => {
8759 if (prev_char_count > 1) {
8760 pattern += '{' + prev_char_count + '}';
8761 }
8762 };
8763 array.forEach((char, i) => {
8764 if (char === array[i - 1]) {
8765 prev_char_count++;
8766 return;
8767 }
8768 prev_pattern();
8769 pattern += char;
8770 prev_char_count = 1;
8771 });
8772 prev_pattern();
8773 return pattern;
8774 };
8775 /**
8776 * Convert array of strings to a regular expression
8777 * ex ['ab','a'] => (?:ab|a)
8778 * ex ['a','b'] => [ab]
8779 */
8780 const setToPattern = (chars) => {
8781 let array = Array.from(chars);
8782 return arrayToPattern(array);
8783 };
8784 /**
8785 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8786 */
8787 const hasDuplicates = (array) => {
8788 return (new Set(array)).size !== array.length;
8789 };
8790 /**
8791 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8792 */
8793 const escape_regex = (str) => {
8794 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8795 };
8796 /**
8797 * Return the max length of array values
8798 */
8799 const maxValueLength = (array) => {
8800 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8801 };
8802 const unicodeLength = (str) => {
8803 return Array.from(str).length;
8804 };
8805 //# sourceMappingURL=regex.js.map
8806
8807 /***/ },
8808
8809 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8810 /*!*********************************************************************!*\
8811 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8812 \*********************************************************************/
8813 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8814
8815 "use strict";
8816 __webpack_require__.r(__webpack_exports__);
8817 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8818 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8819 /* harmony export */ });
8820 /**
8821 * Get all possible combinations of substrings that add up to the given string
8822 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8823 */
8824 const allSubstrings = (input) => {
8825 if (input.length === 1)
8826 return [[input]];
8827 let result = [];
8828 const start = input.substring(1);
8829 const suba = allSubstrings(start);
8830 suba.forEach(function (subresult) {
8831 let tmp = subresult.slice(0);
8832 tmp[0] = input.charAt(0) + tmp[0];
8833 result.push(tmp);
8834 tmp = subresult.slice(0);
8835 tmp.unshift(input.charAt(0));
8836 result.push(tmp);
8837 });
8838 return result;
8839 };
8840 //# sourceMappingURL=strings.js.map
8841
8842 /***/ },
8843
8844 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8845 /*!*******************************************************!*\
8846 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8847 \*******************************************************/
8848 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8849
8850 "use strict";
8851 __webpack_require__.r(__webpack_exports__);
8852 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8853 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8854 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8855 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8856 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8857 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8858 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8859 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8860 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8861 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8862 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8863 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8864 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8865 /* harmony export */ });
8866 const KEY_A = 65;
8867 const KEY_RETURN = 13;
8868 const KEY_ESC = 27;
8869 const KEY_LEFT = 37;
8870 const KEY_UP = 38;
8871 const KEY_RIGHT = 39;
8872 const KEY_DOWN = 40;
8873 const KEY_BACKSPACE = 8;
8874 const KEY_DELETE = 46;
8875 const KEY_TAB = 9;
8876 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8877 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8878 //# sourceMappingURL=constants.js.map
8879
8880 /***/ },
8881
8882 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8883 /*!***************************************************************!*\
8884 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8885 \***************************************************************/
8886 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8887
8888 "use strict";
8889 __webpack_require__.r(__webpack_exports__);
8890 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8891 /* harmony export */ highlight: () => (/* binding */ highlight),
8892 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8893 /* harmony export */ });
8894 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8895 /**
8896 * highlight v3 | MIT license | Johann Burkard <[email protected]>
8897 * Highlights arbitrary terms in a node.
8898 *
8899 * - Modified by Marshal <[email protected]> 2011-6-24 (added regex)
8900 * - Modified by Brian Reavis <[email protected]> 2012-8-27 (cleanup)
8901 */
8902
8903 const highlight = (element, regex) => {
8904 if (regex === null)
8905 return;
8906 // convet string to regex
8907 if (typeof regex === 'string') {
8908 if (!regex.length)
8909 return;
8910 regex = new RegExp(regex, 'i');
8911 }
8912 // Wrap matching part of text node with highlighting <span>, e.g.
8913 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8914 const highlightText = (node) => {
8915 var match = node.data.match(regex);
8916 if (match && node.data.length > 0) {
8917 var spannode = document.createElement('span');
8918 spannode.className = 'highlight';
8919 var middlebit = node.splitText(match.index);
8920 middlebit.splitText(match[0].length);
8921 var middleclone = middlebit.cloneNode(true);
8922 spannode.appendChild(middleclone);
8923 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8924 return 1;
8925 }
8926 return 0;
8927 };
8928 // Recurse element node, looking for child text nodes to highlight, unless element
8929 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8930 const highlightChildren = (node) => {
8931 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8932 Array.from(node.childNodes).forEach(element => {
8933 highlightRecursive(element);
8934 });
8935 }
8936 };
8937 const highlightRecursive = (node) => {
8938 if (node.nodeType === 3) {
8939 return highlightText(node);
8940 }
8941 highlightChildren(node);
8942 return 0;
8943 };
8944 highlightRecursive(element);
8945 };
8946 /**
8947 * removeHighlight fn copied from highlight v5 and
8948 * edited to remove with(), pass js strict mode, and use without jquery
8949 */
8950 const removeHighlight = (el) => {
8951 var elements = el.querySelectorAll("span.highlight");
8952 Array.prototype.forEach.call(elements, function (el) {
8953 var parent = el.parentNode;
8954 parent.replaceChild(el.firstChild, el);
8955 parent.normalize();
8956 });
8957 };
8958 //# sourceMappingURL=highlight.js.map
8959
8960 /***/ },
8961
8962 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8963 /*!****************************************************************!*\
8964 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8965 \****************************************************************/
8966 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8967
8968 "use strict";
8969 __webpack_require__.r(__webpack_exports__);
8970 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8971 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8972 /* harmony export */ });
8973 /**
8974 * MicroEvent - to make any js object an event emitter
8975 *
8976 * - pure javascript - server compatible, browser compatible
8977 * - dont rely on the browser doms
8978 * - super simple - you get it immediatly, no mistery, no magic involved
8979 *
8980 * @author Jerome Etienne (https://github.com/jeromeetienne)
8981 */
8982 /**
8983 * Execute callback for each event in space separated list of event names
8984 *
8985 */
8986 function forEvents(events, callback) {
8987 events.split(/\s+/).forEach((event) => {
8988 callback(event);
8989 });
8990 }
8991 class MicroEvent {
8992 constructor() {
8993 this._events = {};
8994 }
8995 on(events, fct) {
8996 forEvents(events, (event) => {
8997 const event_array = this._events[event] || [];
8998 event_array.push(fct);
8999 this._events[event] = event_array;
9000 });
9001 }
9002 off(events, fct) {
9003 var n = arguments.length;
9004 if (n === 0) {
9005 this._events = {};
9006 return;
9007 }
9008 forEvents(events, (event) => {
9009 if (n === 1) {
9010 delete this._events[event];
9011 return;
9012 }
9013 const event_array = this._events[event];
9014 if (event_array === undefined)
9015 return;
9016 event_array.splice(event_array.indexOf(fct), 1);
9017 this._events[event] = event_array;
9018 });
9019 }
9020 trigger(events, ...args) {
9021 var self = this;
9022 forEvents(events, (event) => {
9023 const event_array = self._events[event];
9024 if (event_array === undefined)
9025 return;
9026 event_array.forEach(fct => {
9027 fct.apply(self, args);
9028 });
9029 });
9030 }
9031 }
9032 ;
9033 //# sourceMappingURL=microevent.js.map
9034
9035 /***/ },
9036
9037 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
9038 /*!*****************************************************************!*\
9039 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
9040 \*****************************************************************/
9041 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9042
9043 "use strict";
9044 __webpack_require__.r(__webpack_exports__);
9045 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9046 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
9047 /* harmony export */ });
9048 /**
9049 * microplugin.js
9050 * Copyright (c) 2013 Brian Reavis & contributors
9051 *
9052 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9053 * file except in compliance with the License. You may obtain a copy of the License at:
9054 * http://www.apache.org/licenses/LICENSE-2.0
9055 *
9056 * Unless required by applicable law or agreed to in writing, software distributed under
9057 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9058 * ANY KIND, either express or implied. See the License for the specific language
9059 * governing permissions and limitations under the License.
9060 *
9061 * @author Brian Reavis <[email protected]>
9062 */
9063 function MicroPlugin(Interface) {
9064 Interface.plugins = {};
9065 return class extends Interface {
9066 constructor() {
9067 super(...arguments);
9068 this.plugins = {
9069 names: [],
9070 settings: {},
9071 requested: {},
9072 loaded: {}
9073 };
9074 }
9075 /**
9076 * Registers a plugin.
9077 *
9078 * @param {function} fn
9079 */
9080 static define(name, fn) {
9081 Interface.plugins[name] = {
9082 'name': name,
9083 'fn': fn
9084 };
9085 }
9086 /**
9087 * Initializes the listed plugins (with options).
9088 * Acceptable formats:
9089 *
9090 * List (without options):
9091 * ['a', 'b', 'c']
9092 *
9093 * List (with options):
9094 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
9095 *
9096 * Hash (with options):
9097 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
9098 *
9099 * @param {array|object} plugins
9100 */
9101 initializePlugins(plugins) {
9102 var key, name;
9103 const self = this;
9104 const queue = [];
9105 if (Array.isArray(plugins)) {
9106 plugins.forEach((plugin) => {
9107 if (typeof plugin === 'string') {
9108 queue.push(plugin);
9109 }
9110 else {
9111 self.plugins.settings[plugin.name] = plugin.options;
9112 queue.push(plugin.name);
9113 }
9114 });
9115 }
9116 else if (plugins) {
9117 for (key in plugins) {
9118 if (plugins.hasOwnProperty(key)) {
9119 self.plugins.settings[key] = plugins[key];
9120 queue.push(key);
9121 }
9122 }
9123 }
9124 while (name = queue.shift()) {
9125 self.require(name);
9126 }
9127 }
9128 loadPlugin(name) {
9129 var self = this;
9130 var plugins = self.plugins;
9131 var plugin = Interface.plugins[name];
9132 if (!Interface.plugins.hasOwnProperty(name)) {
9133 throw new Error('Unable to find "' + name + '" plugin');
9134 }
9135 plugins.requested[name] = true;
9136 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
9137 plugins.names.push(name);
9138 }
9139 /**
9140 * Initializes a plugin.
9141 *
9142 */
9143 require(name) {
9144 var self = this;
9145 var plugins = self.plugins;
9146 if (!self.plugins.loaded.hasOwnProperty(name)) {
9147 if (plugins.requested[name]) {
9148 throw new Error('Plugin has circular dependency ("' + name + '")');
9149 }
9150 self.loadPlugin(name);
9151 }
9152 return plugins.loaded[name];
9153 }
9154 };
9155 }
9156 //# sourceMappingURL=microplugin.js.map
9157
9158 /***/ },
9159
9160 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
9161 /*!******************************************************!*\
9162 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
9163 \******************************************************/
9164 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9165
9166 "use strict";
9167 __webpack_require__.r(__webpack_exports__);
9168 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9169 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
9170 /* harmony export */ });
9171 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
9172 options: [],
9173 optgroups: [],
9174 plugins: [],
9175 delimiter: ',',
9176 splitOn: null, // regexp or string for splitting up values from a paste command
9177 persist: true,
9178 diacritics: true,
9179 create: null,
9180 createOnBlur: false,
9181 createFilter: null,
9182 highlight: true,
9183 openOnFocus: true,
9184 shouldOpen: null,
9185 maxOptions: 50,
9186 maxItems: null,
9187 hideSelected: null,
9188 duplicates: false,
9189 addPrecedence: false,
9190 selectOnTab: false,
9191 preload: null,
9192 allowEmptyOption: false,
9193 //closeAfterSelect: false,
9194 refreshThrottle: 300,
9195 loadThrottle: 300,
9196 loadingClass: 'loading',
9197 dataAttr: null, //'data-data',
9198 optgroupField: 'optgroup',
9199 valueField: 'value',
9200 labelField: 'text',
9201 disabledField: 'disabled',
9202 optgroupLabelField: 'label',
9203 optgroupValueField: 'value',
9204 lockOptgroupOrder: false,
9205 sortField: '$order',
9206 searchField: ['text'],
9207 searchConjunction: 'and',
9208 mode: null,
9209 wrapperClass: 'ts-wrapper',
9210 controlClass: 'ts-control',
9211 dropdownClass: 'ts-dropdown',
9212 dropdownContentClass: 'ts-dropdown-content',
9213 itemClass: 'item',
9214 optionClass: 'option',
9215 dropdownParent: null,
9216 controlInput: '<input type="text" autocomplete="off" size="1" />',
9217 copyClassesToDropdown: false,
9218 placeholder: null,
9219 hidePlaceholder: null,
9220 shouldLoad: function (query) {
9221 return query.length > 0;
9222 },
9223 /*
9224 load : null, // function(query, callback) { ... }
9225 score : null, // function(search) { ... }
9226 onInitialize : null, // function() { ... }
9227 onChange : null, // function(value) { ... }
9228 onItemAdd : null, // function(value, $item) { ... }
9229 onItemRemove : null, // function(value) { ... }
9230 onClear : null, // function() { ... }
9231 onOptionAdd : null, // function(value, data) { ... }
9232 onOptionRemove : null, // function(value) { ... }
9233 onOptionClear : null, // function() { ... }
9234 onOptionGroupAdd : null, // function(id, data) { ... }
9235 onOptionGroupRemove : null, // function(id) { ... }
9236 onOptionGroupClear : null, // function() { ... }
9237 onDropdownOpen : null, // function(dropdown) { ... }
9238 onDropdownClose : null, // function(dropdown) { ... }
9239 onType : null, // function(str) { ... }
9240 onDelete : null, // function(values) { ... }
9241 */
9242 render: {
9243 /*
9244 item: null,
9245 optgroup: null,
9246 optgroup_header: null,
9247 option: null,
9248 option_create: null
9249 */
9250 }
9251 });
9252 //# sourceMappingURL=defaults.js.map
9253
9254 /***/ },
9255
9256 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
9257 /*!*********************************************************!*\
9258 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
9259 \*********************************************************/
9260 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9261
9262 "use strict";
9263 __webpack_require__.r(__webpack_exports__);
9264 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9265 /* harmony export */ "default": () => (/* binding */ getSettings)
9266 /* harmony export */ });
9267 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
9268 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
9269
9270
9271 function getSettings(input, settings_user) {
9272 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
9273 var attr_data = settings.dataAttr;
9274 var field_label = settings.labelField;
9275 var field_value = settings.valueField;
9276 var field_disabled = settings.disabledField;
9277 var field_optgroup = settings.optgroupField;
9278 var field_optgroup_label = settings.optgroupLabelField;
9279 var field_optgroup_value = settings.optgroupValueField;
9280 var tag_name = input.tagName.toLowerCase();
9281 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
9282 if (!placeholder && !settings.allowEmptyOption) {
9283 let option = input.querySelector('option[value=""]');
9284 if (option) {
9285 placeholder = option.textContent;
9286 }
9287 }
9288 var settings_element = {
9289 placeholder: placeholder,
9290 options: [],
9291 optgroups: [],
9292 items: [],
9293 maxItems: null,
9294 };
9295 /**
9296 * Initialize from a <select> element.
9297 *
9298 */
9299 var init_select = () => {
9300 var tagName;
9301 var options = settings_element.options;
9302 var optionsMap = {};
9303 var group_count = 1;
9304 let $order = 0;
9305 var readData = (el) => {
9306 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
9307 var json = attr_data && data[attr_data];
9308 if (typeof json === 'string' && json.length) {
9309 data = Object.assign(data, JSON.parse(json));
9310 }
9311 return data;
9312 };
9313 var addOption = (option, group) => {
9314 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
9315 if (value == null)
9316 return;
9317 if (!value && !settings.allowEmptyOption)
9318 return;
9319 // if the option already exists, it's probably been
9320 // duplicated in another optgroup. in this case, push
9321 // the current group to the "optgroup" property on the
9322 // existing option so that it's rendered in both places.
9323 if (optionsMap.hasOwnProperty(value)) {
9324 if (group) {
9325 var arr = optionsMap[value][field_optgroup];
9326 if (!arr) {
9327 optionsMap[value][field_optgroup] = group;
9328 }
9329 else if (!Array.isArray(arr)) {
9330 optionsMap[value][field_optgroup] = [arr, group];
9331 }
9332 else {
9333 arr.push(group);
9334 }
9335 }
9336 }
9337 else {
9338 var option_data = readData(option);
9339 option_data[field_label] = option_data[field_label] || option.textContent;
9340 option_data[field_value] = option_data[field_value] || value;
9341 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
9342 option_data[field_optgroup] = option_data[field_optgroup] || group;
9343 option_data.$option = option;
9344 option_data.$order = option_data.$order || ++$order;
9345 optionsMap[value] = option_data;
9346 options.push(option_data);
9347 }
9348 if (option.selected) {
9349 settings_element.items.push(value);
9350 }
9351 };
9352 var addGroup = (optgroup) => {
9353 var id, optgroup_data;
9354 optgroup_data = readData(optgroup);
9355 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
9356 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
9357 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
9358 optgroup_data.$order = optgroup_data.$order || ++$order;
9359 settings_element.optgroups.push(optgroup_data);
9360 id = optgroup_data[field_optgroup_value];
9361 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
9362 addOption(option, id);
9363 });
9364 };
9365 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
9366 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
9367 tagName = child.tagName.toLowerCase();
9368 if (tagName === 'optgroup') {
9369 addGroup(child);
9370 }
9371 else if (tagName === 'option') {
9372 addOption(child);
9373 }
9374 });
9375 };
9376 /**
9377 * Initialize from a <input type="text"> element.
9378 *
9379 */
9380 var init_textbox = () => {
9381 const data_raw = input.getAttribute(attr_data);
9382 if (!data_raw) {
9383 var value = input.value.trim() || '';
9384 if (!settings.allowEmptyOption && !value.length)
9385 return;
9386 const values = value.split(settings.delimiter);
9387 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
9388 const option = {};
9389 option[field_label] = value;
9390 option[field_value] = value;
9391 settings_element.options.push(option);
9392 });
9393 settings_element.items = values;
9394 }
9395 else {
9396 settings_element.options = JSON.parse(data_raw);
9397 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
9398 settings_element.items.push(opt[field_value]);
9399 });
9400 }
9401 };
9402 if (tag_name === 'select') {
9403 init_select();
9404 }
9405 else {
9406 init_textbox();
9407 }
9408 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
9409 }
9410 ;
9411 //# sourceMappingURL=getSettings.js.map
9412
9413 /***/ },
9414
9415 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
9416 /*!***************************************************************************!*\
9417 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
9418 \***************************************************************************/
9419 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9420
9421 "use strict";
9422 __webpack_require__.r(__webpack_exports__);
9423 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9424 /* harmony export */ "default": () => (/* binding */ plugin)
9425 /* harmony export */ });
9426 /**
9427 * Tom Select v2.4.3
9428 * Licensed under the Apache License, Version 2.0 (the "License");
9429 */
9430
9431 /**
9432 * Converts a scalar to its best string representation
9433 * for hash keys and HTML attribute values.
9434 *
9435 * Transformations:
9436 * 'str' -> 'str'
9437 * null -> ''
9438 * undefined -> ''
9439 * true -> '1'
9440 * false -> '0'
9441 * 0 -> '0'
9442 * 1 -> '1'
9443 *
9444 */
9445
9446 /**
9447 * Iterates over arrays and hashes.
9448 *
9449 * ```
9450 * iterate(this.items, function(item, id) {
9451 * // invoked for each item
9452 * });
9453 * ```
9454 *
9455 */
9456 const iterate = (object, callback) => {
9457 if (Array.isArray(object)) {
9458 object.forEach(callback);
9459 } else {
9460 for (var key in object) {
9461 if (object.hasOwnProperty(key)) {
9462 callback(object[key], key);
9463 }
9464 }
9465 }
9466 };
9467
9468 /**
9469 * Remove css classes
9470 *
9471 */
9472 const removeClasses = (elmts, ...classes) => {
9473 var norm_classes = classesArray(classes);
9474 elmts = castAsArray(elmts);
9475 elmts.map(el => {
9476 norm_classes.map(cls => {
9477 el.classList.remove(cls);
9478 });
9479 });
9480 };
9481
9482 /**
9483 * Return arguments
9484 *
9485 */
9486 const classesArray = args => {
9487 var classes = [];
9488 iterate(args, _classes => {
9489 if (typeof _classes === 'string') {
9490 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9491 }
9492 if (Array.isArray(_classes)) {
9493 classes = classes.concat(_classes);
9494 }
9495 });
9496 return classes.filter(Boolean);
9497 };
9498
9499 /**
9500 * Create an array from arg if it's not already an array
9501 *
9502 */
9503 const castAsArray = arg => {
9504 if (!Array.isArray(arg)) {
9505 arg = [arg];
9506 }
9507 return arg;
9508 };
9509
9510 /**
9511 * Get the index of an element amongst sibling nodes of the same type
9512 *
9513 */
9514 const nodeIndex = (el, amongst) => {
9515 if (!el) return -1;
9516 amongst = amongst || el.nodeName;
9517 var i = 0;
9518 while (el = el.previousElementSibling) {
9519 if (el.matches(amongst)) {
9520 i++;
9521 }
9522 }
9523 return i;
9524 };
9525
9526 /**
9527 * Plugin: "dropdown_input" (Tom Select)
9528 * Copyright (c) contributors
9529 *
9530 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9531 * file except in compliance with the License. You may obtain a copy of the License at:
9532 * http://www.apache.org/licenses/LICENSE-2.0
9533 *
9534 * Unless required by applicable law or agreed to in writing, software distributed under
9535 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9536 * ANY KIND, either express or implied. See the License for the specific language
9537 * governing permissions and limitations under the License.
9538 *
9539 */
9540
9541 function plugin () {
9542 var self = this;
9543
9544 /**
9545 * Moves the caret to the specified index.
9546 *
9547 * The input must be moved by leaving it in place and moving the
9548 * siblings, due to the fact that focus cannot be restored once lost
9549 * on mobile webkit devices
9550 *
9551 */
9552 self.hook('instead', 'setCaret', new_pos => {
9553 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
9554 new_pos = self.items.length;
9555 } else {
9556 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
9557 if (new_pos != self.caretPos && !self.isPending) {
9558 self.controlChildren().forEach((child, j) => {
9559 if (j < new_pos) {
9560 self.control_input.insertAdjacentElement('beforebegin', child);
9561 } else {
9562 self.control.appendChild(child);
9563 }
9564 });
9565 }
9566 }
9567 self.caretPos = new_pos;
9568 });
9569 self.hook('instead', 'moveCaret', direction => {
9570 if (!self.isFocused) return;
9571
9572 // move caret before or after selected items
9573 const last_active = self.getLastActive(direction);
9574 if (last_active) {
9575 const idx = nodeIndex(last_active);
9576 self.setCaret(direction > 0 ? idx + 1 : idx);
9577 self.setActiveItem();
9578 removeClasses(last_active, 'last-active');
9579
9580 // move caret left or right of current position
9581 } else {
9582 self.setCaret(self.caretPos + direction);
9583 }
9584 });
9585 }
9586
9587
9588 //# sourceMappingURL=plugin.js.map
9589
9590
9591 /***/ },
9592
9593 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9594 /*!****************************************************************************!*\
9595 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9596 \****************************************************************************/
9597 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9598
9599 "use strict";
9600 __webpack_require__.r(__webpack_exports__);
9601 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9602 /* harmony export */ "default": () => (/* binding */ plugin)
9603 /* harmony export */ });
9604 /**
9605 * Tom Select v2.4.3
9606 * Licensed under the Apache License, Version 2.0 (the "License");
9607 */
9608
9609 /**
9610 * Converts a scalar to its best string representation
9611 * for hash keys and HTML attribute values.
9612 *
9613 * Transformations:
9614 * 'str' -> 'str'
9615 * null -> ''
9616 * undefined -> ''
9617 * true -> '1'
9618 * false -> '0'
9619 * 0 -> '0'
9620 * 1 -> '1'
9621 *
9622 */
9623
9624 /**
9625 * Add event helper
9626 *
9627 */
9628 const addEvent = (target, type, callback, options) => {
9629 target.addEventListener(type, callback, options);
9630 };
9631
9632 /**
9633 * Plugin: "change_listener" (Tom Select)
9634 * Copyright (c) contributors
9635 *
9636 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9637 * file except in compliance with the License. You may obtain a copy of the License at:
9638 * http://www.apache.org/licenses/LICENSE-2.0
9639 *
9640 * Unless required by applicable law or agreed to in writing, software distributed under
9641 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9642 * ANY KIND, either express or implied. See the License for the specific language
9643 * governing permissions and limitations under the License.
9644 *
9645 */
9646
9647 function plugin () {
9648 addEvent(this.input, 'change', () => {
9649 this.sync();
9650 });
9651 }
9652
9653
9654 //# sourceMappingURL=plugin.js.map
9655
9656
9657 /***/ },
9658
9659 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9660 /*!*****************************************************************************!*\
9661 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9662 \*****************************************************************************/
9663 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9664
9665 "use strict";
9666 __webpack_require__.r(__webpack_exports__);
9667 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9668 /* harmony export */ "default": () => (/* binding */ plugin)
9669 /* harmony export */ });
9670 /**
9671 * Tom Select v2.4.3
9672 * Licensed under the Apache License, Version 2.0 (the "License");
9673 */
9674
9675 /**
9676 * Converts a scalar to its best string representation
9677 * for hash keys and HTML attribute values.
9678 *
9679 * Transformations:
9680 * 'str' -> 'str'
9681 * null -> ''
9682 * undefined -> ''
9683 * true -> '1'
9684 * false -> '0'
9685 * 0 -> '0'
9686 * 1 -> '1'
9687 *
9688 */
9689 const hash_key = value => {
9690 if (typeof value === 'undefined' || value === null) return null;
9691 return get_hash(value);
9692 };
9693 const get_hash = value => {
9694 if (typeof value === 'boolean') return value ? '1' : '0';
9695 return value + '';
9696 };
9697
9698 /**
9699 * Prevent default
9700 *
9701 */
9702 const preventDefault = (evt, stop = false) => {
9703 if (evt) {
9704 evt.preventDefault();
9705 if (stop) {
9706 evt.stopPropagation();
9707 }
9708 }
9709 };
9710
9711 /**
9712 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9713 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9714 *
9715 * param query should be {}
9716 */
9717 const getDom = query => {
9718 if (query.jquery) {
9719 return query[0];
9720 }
9721 if (query instanceof HTMLElement) {
9722 return query;
9723 }
9724 if (isHtmlString(query)) {
9725 var tpl = document.createElement('template');
9726 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9727 return tpl.content.firstChild;
9728 }
9729 return document.querySelector(query);
9730 };
9731 const isHtmlString = arg => {
9732 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9733 return true;
9734 }
9735 return false;
9736 };
9737
9738 /**
9739 * Plugin: "checkbox_options" (Tom Select)
9740 * Copyright (c) contributors
9741 *
9742 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9743 * file except in compliance with the License. You may obtain a copy of the License at:
9744 * http://www.apache.org/licenses/LICENSE-2.0
9745 *
9746 * Unless required by applicable law or agreed to in writing, software distributed under
9747 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9748 * ANY KIND, either express or implied. See the License for the specific language
9749 * governing permissions and limitations under the License.
9750 *
9751 */
9752
9753 function plugin (userOptions) {
9754 var self = this;
9755 var orig_onOptionSelect = self.onOptionSelect;
9756 self.settings.hideSelected = false;
9757 const cbOptions = Object.assign({
9758 // so that the user may add different ones as well
9759 className: "tomselect-checkbox",
9760 // the following default to the historic plugin's values
9761 checkedClassNames: undefined,
9762 uncheckedClassNames: undefined
9763 }, userOptions);
9764 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9765 if (toCheck) {
9766 checkbox.checked = true;
9767 if (cbOptions.uncheckedClassNames) {
9768 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9769 }
9770 if (cbOptions.checkedClassNames) {
9771 checkbox.classList.add(...cbOptions.checkedClassNames);
9772 }
9773 } else {
9774 checkbox.checked = false;
9775 if (cbOptions.checkedClassNames) {
9776 checkbox.classList.remove(...cbOptions.checkedClassNames);
9777 }
9778 if (cbOptions.uncheckedClassNames) {
9779 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9780 }
9781 }
9782 };
9783
9784 // update the checkbox for an option
9785 var UpdateCheckbox = function UpdateCheckbox(option) {
9786 setTimeout(() => {
9787 var checkbox = option.querySelector('input.' + cbOptions.className);
9788 if (checkbox instanceof HTMLInputElement) {
9789 UpdateChecked(checkbox, option.classList.contains('selected'));
9790 }
9791 }, 1);
9792 };
9793
9794 // add checkbox to option template
9795 self.hook('after', 'setupTemplates', () => {
9796 var orig_render_option = self.settings.render.option;
9797 self.settings.render.option = (data, escape_html) => {
9798 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9799 var checkbox = document.createElement('input');
9800 if (cbOptions.className) {
9801 checkbox.classList.add(cbOptions.className);
9802 }
9803 checkbox.addEventListener('click', function (evt) {
9804 preventDefault(evt);
9805 });
9806 checkbox.type = 'checkbox';
9807 const hashed = hash_key(data[self.settings.valueField]);
9808 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9809 rendered.prepend(checkbox);
9810 return rendered;
9811 };
9812 });
9813
9814 // uncheck when item removed
9815 self.on('item_remove', value => {
9816 var option = self.getOption(value);
9817 if (option) {
9818 // if dropdown hasn't been opened yet, the option won't exist
9819 option.classList.remove('selected'); // selected class won't be removed yet
9820 UpdateCheckbox(option);
9821 }
9822 });
9823
9824 // check when item added
9825 self.on('item_add', value => {
9826 var option = self.getOption(value);
9827 if (option) {
9828 // if dropdown hasn't been opened yet, the option won't exist
9829 UpdateCheckbox(option);
9830 }
9831 });
9832
9833 // remove items when selected option is clicked
9834 self.hook('instead', 'onOptionSelect', (evt, option) => {
9835 if (option.classList.contains('selected')) {
9836 option.classList.remove('selected');
9837 self.removeItem(option.dataset.value);
9838 self.refreshOptions();
9839 preventDefault(evt, true);
9840 return;
9841 }
9842 orig_onOptionSelect.call(self, evt, option);
9843 UpdateCheckbox(option);
9844 });
9845 }
9846
9847
9848 //# sourceMappingURL=plugin.js.map
9849
9850
9851 /***/ },
9852
9853 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9854 /*!*************************************************************************!*\
9855 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9856 \*************************************************************************/
9857 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9858
9859 "use strict";
9860 __webpack_require__.r(__webpack_exports__);
9861 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9862 /* harmony export */ "default": () => (/* binding */ plugin)
9863 /* harmony export */ });
9864 /**
9865 * Tom Select v2.4.3
9866 * Licensed under the Apache License, Version 2.0 (the "License");
9867 */
9868
9869 /**
9870 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9871 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9872 *
9873 * param query should be {}
9874 */
9875 const getDom = query => {
9876 if (query.jquery) {
9877 return query[0];
9878 }
9879 if (query instanceof HTMLElement) {
9880 return query;
9881 }
9882 if (isHtmlString(query)) {
9883 var tpl = document.createElement('template');
9884 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9885 return tpl.content.firstChild;
9886 }
9887 return document.querySelector(query);
9888 };
9889 const isHtmlString = arg => {
9890 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9891 return true;
9892 }
9893 return false;
9894 };
9895
9896 /**
9897 * Plugin: "dropdown_header" (Tom Select)
9898 * Copyright (c) contributors
9899 *
9900 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9901 * file except in compliance with the License. You may obtain a copy of the License at:
9902 * http://www.apache.org/licenses/LICENSE-2.0
9903 *
9904 * Unless required by applicable law or agreed to in writing, software distributed under
9905 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9906 * ANY KIND, either express or implied. See the License for the specific language
9907 * governing permissions and limitations under the License.
9908 *
9909 */
9910
9911 function plugin (userOptions) {
9912 const self = this;
9913 const options = Object.assign({
9914 className: 'clear-button',
9915 title: 'Clear All',
9916 html: data => {
9917 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
9918 }
9919 }, userOptions);
9920 self.on('initialize', () => {
9921 var button = getDom(options.html(options));
9922 button.addEventListener('click', evt => {
9923 if (self.isLocked) return;
9924 self.clear();
9925 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9926 self.addItem('');
9927 }
9928 evt.preventDefault();
9929 evt.stopPropagation();
9930 });
9931 self.control.appendChild(button);
9932 });
9933 }
9934
9935
9936 //# sourceMappingURL=plugin.js.map
9937
9938
9939 /***/ },
9940
9941 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9942 /*!**********************************************************************!*\
9943 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9944 \**********************************************************************/
9945 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9946
9947 "use strict";
9948 __webpack_require__.r(__webpack_exports__);
9949 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9950 /* harmony export */ "default": () => (/* binding */ plugin)
9951 /* harmony export */ });
9952 /**
9953 * Tom Select v2.4.3
9954 * Licensed under the Apache License, Version 2.0 (the "License");
9955 */
9956
9957 /**
9958 * Converts a scalar to its best string representation
9959 * for hash keys and HTML attribute values.
9960 *
9961 * Transformations:
9962 * 'str' -> 'str'
9963 * null -> ''
9964 * undefined -> ''
9965 * true -> '1'
9966 * false -> '0'
9967 * 0 -> '0'
9968 * 1 -> '1'
9969 *
9970 */
9971
9972 /**
9973 * Prevent default
9974 *
9975 */
9976 const preventDefault = (evt, stop = false) => {
9977 if (evt) {
9978 evt.preventDefault();
9979 if (stop) {
9980 evt.stopPropagation();
9981 }
9982 }
9983 };
9984
9985 /**
9986 * Add event helper
9987 *
9988 */
9989 const addEvent = (target, type, callback, options) => {
9990 target.addEventListener(type, callback, options);
9991 };
9992
9993 /**
9994 * Iterates over arrays and hashes.
9995 *
9996 * ```
9997 * iterate(this.items, function(item, id) {
9998 * // invoked for each item
9999 * });
10000 * ```
10001 *
10002 */
10003 const iterate = (object, callback) => {
10004 if (Array.isArray(object)) {
10005 object.forEach(callback);
10006 } else {
10007 for (var key in object) {
10008 if (object.hasOwnProperty(key)) {
10009 callback(object[key], key);
10010 }
10011 }
10012 }
10013 };
10014
10015 /**
10016 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10017 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10018 *
10019 * param query should be {}
10020 */
10021 const getDom = query => {
10022 if (query.jquery) {
10023 return query[0];
10024 }
10025 if (query instanceof HTMLElement) {
10026 return query;
10027 }
10028 if (isHtmlString(query)) {
10029 var tpl = document.createElement('template');
10030 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10031 return tpl.content.firstChild;
10032 }
10033 return document.querySelector(query);
10034 };
10035 const isHtmlString = arg => {
10036 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10037 return true;
10038 }
10039 return false;
10040 };
10041
10042 /**
10043 * Set attributes of an element
10044 *
10045 */
10046 const setAttr = (el, attrs) => {
10047 iterate(attrs, (val, attr) => {
10048 if (val == null) {
10049 el.removeAttribute(attr);
10050 } else {
10051 el.setAttribute(attr, '' + val);
10052 }
10053 });
10054 };
10055
10056 /**
10057 * Plugin: "drag_drop" (Tom Select)
10058 * Copyright (c) contributors
10059 *
10060 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10061 * file except in compliance with the License. You may obtain a copy of the License at:
10062 * http://www.apache.org/licenses/LICENSE-2.0
10063 *
10064 * Unless required by applicable law or agreed to in writing, software distributed under
10065 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10066 * ANY KIND, either express or implied. See the License for the specific language
10067 * governing permissions and limitations under the License.
10068 *
10069 */
10070
10071 const insertAfter = (referenceNode, newNode) => {
10072 var _referenceNode$parent;
10073 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
10074 };
10075 const insertBefore = (referenceNode, newNode) => {
10076 var _referenceNode$parent2;
10077 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
10078 };
10079 const isBefore = (referenceNode, newNode) => {
10080 do {
10081 var _newNode;
10082 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
10083 if (referenceNode == newNode) {
10084 return true;
10085 }
10086 } while (newNode && newNode.previousElementSibling);
10087 return false;
10088 };
10089 function plugin () {
10090 var self = this;
10091 if (self.settings.mode !== 'multi') return;
10092 var orig_lock = self.lock;
10093 var orig_unlock = self.unlock;
10094 let sortable = true;
10095 let drag_item;
10096
10097 /**
10098 * Add draggable attribute to item
10099 */
10100 self.hook('after', 'setupTemplates', () => {
10101 var orig_render_item = self.settings.render.item;
10102 self.settings.render.item = (data, escape) => {
10103 const item = getDom(orig_render_item.call(self, data, escape));
10104 setAttr(item, {
10105 'draggable': 'true'
10106 });
10107
10108 // prevent doc_mousedown (see tom-select.ts)
10109 const mousedown = evt => {
10110 if (!sortable) preventDefault(evt);
10111 evt.stopPropagation();
10112 };
10113 const dragStart = evt => {
10114 drag_item = item;
10115 setTimeout(() => {
10116 item.classList.add('ts-dragging');
10117 }, 0);
10118 };
10119 const dragOver = evt => {
10120 evt.preventDefault();
10121 item.classList.add('ts-drag-over');
10122 moveitem(item, drag_item);
10123 };
10124 const dragLeave = () => {
10125 item.classList.remove('ts-drag-over');
10126 };
10127 const moveitem = (targetitem, dragitem) => {
10128 if (dragitem === undefined) return;
10129 if (isBefore(dragitem, item)) {
10130 insertAfter(targetitem, dragitem);
10131 } else {
10132 insertBefore(targetitem, dragitem);
10133 }
10134 };
10135 const dragend = () => {
10136 var _drag_item;
10137 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
10138 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
10139 drag_item = undefined;
10140 var values = [];
10141 self.control.querySelectorAll(`[data-value]`).forEach(el => {
10142 if (el.dataset.value) {
10143 let value = el.dataset.value;
10144 if (value) {
10145 values.push(value);
10146 }
10147 }
10148 });
10149 self.setValue(values);
10150 };
10151 addEvent(item, 'mousedown', mousedown);
10152 addEvent(item, 'dragstart', dragStart);
10153 addEvent(item, 'dragenter', dragOver);
10154 addEvent(item, 'dragover', dragOver);
10155 addEvent(item, 'dragleave', dragLeave);
10156 addEvent(item, 'dragend', dragend);
10157 return item;
10158 };
10159 });
10160 self.hook('instead', 'lock', () => {
10161 sortable = false;
10162 return orig_lock.call(self);
10163 });
10164 self.hook('instead', 'unlock', () => {
10165 sortable = true;
10166 return orig_unlock.call(self);
10167 });
10168 }
10169
10170
10171 //# sourceMappingURL=plugin.js.map
10172
10173
10174 /***/ },
10175
10176 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
10177 /*!****************************************************************************!*\
10178 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
10179 \****************************************************************************/
10180 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10181
10182 "use strict";
10183 __webpack_require__.r(__webpack_exports__);
10184 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10185 /* harmony export */ "default": () => (/* binding */ plugin)
10186 /* harmony export */ });
10187 /**
10188 * Tom Select v2.4.3
10189 * Licensed under the Apache License, Version 2.0 (the "License");
10190 */
10191
10192 /**
10193 * Converts a scalar to its best string representation
10194 * for hash keys and HTML attribute values.
10195 *
10196 * Transformations:
10197 * 'str' -> 'str'
10198 * null -> ''
10199 * undefined -> ''
10200 * true -> '1'
10201 * false -> '0'
10202 * 0 -> '0'
10203 * 1 -> '1'
10204 *
10205 */
10206
10207 /**
10208 * Prevent default
10209 *
10210 */
10211 const preventDefault = (evt, stop = false) => {
10212 if (evt) {
10213 evt.preventDefault();
10214 if (stop) {
10215 evt.stopPropagation();
10216 }
10217 }
10218 };
10219
10220 /**
10221 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10222 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10223 *
10224 * param query should be {}
10225 */
10226 const getDom = query => {
10227 if (query.jquery) {
10228 return query[0];
10229 }
10230 if (query instanceof HTMLElement) {
10231 return query;
10232 }
10233 if (isHtmlString(query)) {
10234 var tpl = document.createElement('template');
10235 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10236 return tpl.content.firstChild;
10237 }
10238 return document.querySelector(query);
10239 };
10240 const isHtmlString = arg => {
10241 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10242 return true;
10243 }
10244 return false;
10245 };
10246
10247 /**
10248 * Plugin: "dropdown_header" (Tom Select)
10249 * Copyright (c) contributors
10250 *
10251 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10252 * file except in compliance with the License. You may obtain a copy of the License at:
10253 * http://www.apache.org/licenses/LICENSE-2.0
10254 *
10255 * Unless required by applicable law or agreed to in writing, software distributed under
10256 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10257 * ANY KIND, either express or implied. See the License for the specific language
10258 * governing permissions and limitations under the License.
10259 *
10260 */
10261
10262 function plugin (userOptions) {
10263 const self = this;
10264 const options = Object.assign({
10265 title: 'Untitled',
10266 headerClass: 'dropdown-header',
10267 titleRowClass: 'dropdown-header-title',
10268 labelClass: 'dropdown-header-label',
10269 closeClass: 'dropdown-header-close',
10270 html: data => {
10271 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
10272 }
10273 }, userOptions);
10274 self.on('initialize', () => {
10275 var header = getDom(options.html(options));
10276 var close_link = header.querySelector('.' + options.closeClass);
10277 if (close_link) {
10278 close_link.addEventListener('click', evt => {
10279 preventDefault(evt, true);
10280 self.close();
10281 });
10282 }
10283 self.dropdown.insertBefore(header, self.dropdown.firstChild);
10284 });
10285 }
10286
10287
10288 //# sourceMappingURL=plugin.js.map
10289
10290
10291 /***/ },
10292
10293 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
10294 /*!***************************************************************************!*\
10295 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
10296 \***************************************************************************/
10297 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10298
10299 "use strict";
10300 __webpack_require__.r(__webpack_exports__);
10301 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10302 /* harmony export */ "default": () => (/* binding */ plugin)
10303 /* harmony export */ });
10304 /**
10305 * Tom Select v2.4.3
10306 * Licensed under the Apache License, Version 2.0 (the "License");
10307 */
10308
10309 const KEY_ESC = 27;
10310 const KEY_TAB = 9;
10311 // ctrl key or apple key for ma
10312
10313 /**
10314 * Converts a scalar to its best string representation
10315 * for hash keys and HTML attribute values.
10316 *
10317 * Transformations:
10318 * 'str' -> 'str'
10319 * null -> ''
10320 * undefined -> ''
10321 * true -> '1'
10322 * false -> '0'
10323 * 0 -> '0'
10324 * 1 -> '1'
10325 *
10326 */
10327
10328 /**
10329 * Prevent default
10330 *
10331 */
10332 const preventDefault = (evt, stop = false) => {
10333 if (evt) {
10334 evt.preventDefault();
10335 if (stop) {
10336 evt.stopPropagation();
10337 }
10338 }
10339 };
10340
10341 /**
10342 * Add event helper
10343 *
10344 */
10345 const addEvent = (target, type, callback, options) => {
10346 target.addEventListener(type, callback, options);
10347 };
10348
10349 /**
10350 * Iterates over arrays and hashes.
10351 *
10352 * ```
10353 * iterate(this.items, function(item, id) {
10354 * // invoked for each item
10355 * });
10356 * ```
10357 *
10358 */
10359 const iterate = (object, callback) => {
10360 if (Array.isArray(object)) {
10361 object.forEach(callback);
10362 } else {
10363 for (var key in object) {
10364 if (object.hasOwnProperty(key)) {
10365 callback(object[key], key);
10366 }
10367 }
10368 }
10369 };
10370
10371 /**
10372 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10373 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10374 *
10375 * param query should be {}
10376 */
10377 const getDom = query => {
10378 if (query.jquery) {
10379 return query[0];
10380 }
10381 if (query instanceof HTMLElement) {
10382 return query;
10383 }
10384 if (isHtmlString(query)) {
10385 var tpl = document.createElement('template');
10386 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10387 return tpl.content.firstChild;
10388 }
10389 return document.querySelector(query);
10390 };
10391 const isHtmlString = arg => {
10392 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10393 return true;
10394 }
10395 return false;
10396 };
10397
10398 /**
10399 * Add css classes
10400 *
10401 */
10402 const addClasses = (elmts, ...classes) => {
10403 var norm_classes = classesArray(classes);
10404 elmts = castAsArray(elmts);
10405 elmts.map(el => {
10406 norm_classes.map(cls => {
10407 el.classList.add(cls);
10408 });
10409 });
10410 };
10411
10412 /**
10413 * Return arguments
10414 *
10415 */
10416 const classesArray = args => {
10417 var classes = [];
10418 iterate(args, _classes => {
10419 if (typeof _classes === 'string') {
10420 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10421 }
10422 if (Array.isArray(_classes)) {
10423 classes = classes.concat(_classes);
10424 }
10425 });
10426 return classes.filter(Boolean);
10427 };
10428
10429 /**
10430 * Create an array from arg if it's not already an array
10431 *
10432 */
10433 const castAsArray = arg => {
10434 if (!Array.isArray(arg)) {
10435 arg = [arg];
10436 }
10437 return arg;
10438 };
10439
10440 /**
10441 * Plugin: "dropdown_input" (Tom Select)
10442 * Copyright (c) contributors
10443 *
10444 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10445 * file except in compliance with the License. You may obtain a copy of the License at:
10446 * http://www.apache.org/licenses/LICENSE-2.0
10447 *
10448 * Unless required by applicable law or agreed to in writing, software distributed under
10449 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10450 * ANY KIND, either express or implied. See the License for the specific language
10451 * governing permissions and limitations under the License.
10452 *
10453 */
10454
10455 function plugin () {
10456 const self = this;
10457 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
10458
10459 self.hook('before', 'setup', () => {
10460 self.focus_node = self.control;
10461 addClasses(self.control_input, 'dropdown-input');
10462 const div = getDom('<div class="dropdown-input-wrap">');
10463 div.append(self.control_input);
10464 self.dropdown.insertBefore(div, self.dropdown.firstChild);
10465
10466 // set a placeholder in the select control
10467 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
10468 placeholder.placeholder = self.settings.placeholder || '';
10469 self.control.append(placeholder);
10470 });
10471 self.on('initialize', () => {
10472 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
10473 self.control_input.addEventListener('keydown', evt => {
10474 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
10475 switch (evt.keyCode) {
10476 case KEY_ESC:
10477 if (self.isOpen) {
10478 preventDefault(evt, true);
10479 self.close();
10480 }
10481 self.clearActiveItems();
10482 return;
10483 case KEY_TAB:
10484 self.focus_node.tabIndex = -1;
10485 break;
10486 }
10487 return self.onKeyDown.call(self, evt);
10488 });
10489 self.on('blur', () => {
10490 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
10491 });
10492
10493 // give the control_input focus when the dropdown is open
10494 self.on('dropdown_open', () => {
10495 self.control_input.focus();
10496 });
10497
10498 // prevent onBlur from closing when focus is on the control_input
10499 const orig_onBlur = self.onBlur;
10500 self.hook('instead', 'onBlur', evt => {
10501 if (evt && evt.relatedTarget == self.control_input) return;
10502 return orig_onBlur.call(self);
10503 });
10504 addEvent(self.control_input, 'blur', () => self.onBlur());
10505
10506 // return focus to control to allow further keyboard input
10507 self.hook('before', 'close', () => {
10508 if (!self.isOpen) return;
10509 self.focus_node.focus({
10510 preventScroll: true
10511 });
10512 });
10513 });
10514 }
10515
10516
10517 //# sourceMappingURL=plugin.js.map
10518
10519
10520 /***/ },
10521
10522 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
10523 /*!***************************************************************************!*\
10524 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
10525 \***************************************************************************/
10526 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10527
10528 "use strict";
10529 __webpack_require__.r(__webpack_exports__);
10530 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10531 /* harmony export */ "default": () => (/* binding */ plugin)
10532 /* harmony export */ });
10533 /**
10534 * Tom Select v2.4.3
10535 * Licensed under the Apache License, Version 2.0 (the "License");
10536 */
10537
10538 /**
10539 * Converts a scalar to its best string representation
10540 * for hash keys and HTML attribute values.
10541 *
10542 * Transformations:
10543 * 'str' -> 'str'
10544 * null -> ''
10545 * undefined -> ''
10546 * true -> '1'
10547 * false -> '0'
10548 * 0 -> '0'
10549 * 1 -> '1'
10550 *
10551 */
10552
10553 /**
10554 * Add event helper
10555 *
10556 */
10557 const addEvent = (target, type, callback, options) => {
10558 target.addEventListener(type, callback, options);
10559 };
10560
10561 /**
10562 * Plugin: "input_autogrow" (Tom Select)
10563 *
10564 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10565 * file except in compliance with the License. You may obtain a copy of the License at:
10566 * http://www.apache.org/licenses/LICENSE-2.0
10567 *
10568 * Unless required by applicable law or agreed to in writing, software distributed under
10569 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10570 * ANY KIND, either express or implied. See the License for the specific language
10571 * governing permissions and limitations under the License.
10572 *
10573 */
10574
10575 function plugin () {
10576 var self = this;
10577 self.on('initialize', () => {
10578 var test_input = document.createElement('span');
10579 var control = self.control_input;
10580 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10581 self.wrapper.appendChild(test_input);
10582 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10583 for (const style_name of transfer_styles) {
10584 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10585 test_input.style[style_name] = control.style[style_name];
10586 }
10587
10588 /**
10589 * Set the control width
10590 *
10591 */
10592 var resize = () => {
10593 test_input.textContent = control.value;
10594 control.style.width = test_input.clientWidth + 'px';
10595 };
10596 resize();
10597 self.on('update item_add item_remove', resize);
10598 addEvent(control, 'input', resize);
10599 addEvent(control, 'keyup', resize);
10600 addEvent(control, 'blur', resize);
10601 addEvent(control, 'update', resize);
10602 });
10603 }
10604
10605
10606 //# sourceMappingURL=plugin.js.map
10607
10608
10609 /***/ },
10610
10611 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10612 /*!****************************************************************************!*\
10613 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10614 \****************************************************************************/
10615 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10616
10617 "use strict";
10618 __webpack_require__.r(__webpack_exports__);
10619 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10620 /* harmony export */ "default": () => (/* binding */ plugin)
10621 /* harmony export */ });
10622 /**
10623 * Tom Select v2.4.3
10624 * Licensed under the Apache License, Version 2.0 (the "License");
10625 */
10626
10627 /**
10628 * Plugin: "no_active_items" (Tom Select)
10629 *
10630 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10631 * file except in compliance with the License. You may obtain a copy of the License at:
10632 * http://www.apache.org/licenses/LICENSE-2.0
10633 *
10634 * Unless required by applicable law or agreed to in writing, software distributed under
10635 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10636 * ANY KIND, either express or implied. See the License for the specific language
10637 * governing permissions and limitations under the License.
10638 *
10639 */
10640
10641 function plugin () {
10642 this.hook('instead', 'setActiveItem', () => {});
10643 this.hook('instead', 'selectAll', () => {});
10644 }
10645
10646
10647 //# sourceMappingURL=plugin.js.map
10648
10649
10650 /***/ },
10651
10652 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10653 /*!********************************************************************************!*\
10654 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10655 \********************************************************************************/
10656 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10657
10658 "use strict";
10659 __webpack_require__.r(__webpack_exports__);
10660 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10661 /* harmony export */ "default": () => (/* binding */ plugin)
10662 /* harmony export */ });
10663 /**
10664 * Tom Select v2.4.3
10665 * Licensed under the Apache License, Version 2.0 (the "License");
10666 */
10667
10668 /**
10669 * Plugin: "input_autogrow" (Tom Select)
10670 *
10671 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10672 * file except in compliance with the License. You may obtain a copy of the License at:
10673 * http://www.apache.org/licenses/LICENSE-2.0
10674 *
10675 * Unless required by applicable law or agreed to in writing, software distributed under
10676 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10677 * ANY KIND, either express or implied. See the License for the specific language
10678 * governing permissions and limitations under the License.
10679 *
10680 */
10681
10682 function plugin () {
10683 var self = this;
10684 var orig_deleteSelection = self.deleteSelection;
10685 this.hook('instead', 'deleteSelection', evt => {
10686 if (self.activeItems.length) {
10687 return orig_deleteSelection.call(self, evt);
10688 }
10689 return false;
10690 });
10691 }
10692
10693
10694 //# sourceMappingURL=plugin.js.map
10695
10696
10697 /***/ },
10698
10699 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10700 /*!*****************************************************************************!*\
10701 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10702 \*****************************************************************************/
10703 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10704
10705 "use strict";
10706 __webpack_require__.r(__webpack_exports__);
10707 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10708 /* harmony export */ "default": () => (/* binding */ plugin)
10709 /* harmony export */ });
10710 /**
10711 * Tom Select v2.4.3
10712 * Licensed under the Apache License, Version 2.0 (the "License");
10713 */
10714
10715 const KEY_LEFT = 37;
10716 const KEY_RIGHT = 39;
10717 // ctrl key or apple key for ma
10718
10719 /**
10720 * Get the closest node to the evt.target matching the selector
10721 * Stops at wrapper
10722 *
10723 */
10724 const parentMatch = (target, selector, wrapper) => {
10725 while (target && target.matches) {
10726 if (target.matches(selector)) {
10727 return target;
10728 }
10729 target = target.parentNode;
10730 }
10731 };
10732
10733 /**
10734 * Get the index of an element amongst sibling nodes of the same type
10735 *
10736 */
10737 const nodeIndex = (el, amongst) => {
10738 if (!el) return -1;
10739 amongst = amongst || el.nodeName;
10740 var i = 0;
10741 while (el = el.previousElementSibling) {
10742 if (el.matches(amongst)) {
10743 i++;
10744 }
10745 }
10746 return i;
10747 };
10748
10749 /**
10750 * Plugin: "optgroup_columns" (Tom Select.js)
10751 * Copyright (c) contributors
10752 *
10753 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10754 * file except in compliance with the License. You may obtain a copy of the License at:
10755 * http://www.apache.org/licenses/LICENSE-2.0
10756 *
10757 * Unless required by applicable law or agreed to in writing, software distributed under
10758 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10759 * ANY KIND, either express or implied. See the License for the specific language
10760 * governing permissions and limitations under the License.
10761 *
10762 */
10763
10764 function plugin () {
10765 var self = this;
10766 var orig_keydown = self.onKeyDown;
10767 self.hook('instead', 'onKeyDown', evt => {
10768 var index, option, options, optgroup;
10769 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10770 return orig_keydown.call(self, evt);
10771 }
10772 self.ignoreHover = true;
10773 optgroup = parentMatch(self.activeOption, '[data-group]');
10774 index = nodeIndex(self.activeOption, '[data-selectable]');
10775 if (!optgroup) {
10776 return;
10777 }
10778 if (evt.keyCode === KEY_LEFT) {
10779 optgroup = optgroup.previousSibling;
10780 } else {
10781 optgroup = optgroup.nextSibling;
10782 }
10783 if (!optgroup) {
10784 return;
10785 }
10786 options = optgroup.querySelectorAll('[data-selectable]');
10787 option = options[Math.min(options.length - 1, index)];
10788 if (option) {
10789 self.setActiveOption(option);
10790 }
10791 });
10792 }
10793
10794
10795 //# sourceMappingURL=plugin.js.map
10796
10797
10798 /***/ },
10799
10800 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10801 /*!**************************************************************************!*\
10802 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10803 \**************************************************************************/
10804 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10805
10806 "use strict";
10807 __webpack_require__.r(__webpack_exports__);
10808 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10809 /* harmony export */ "default": () => (/* binding */ plugin)
10810 /* harmony export */ });
10811 /**
10812 * Tom Select v2.4.3
10813 * Licensed under the Apache License, Version 2.0 (the "License");
10814 */
10815
10816 /**
10817 * Converts a scalar to its best string representation
10818 * for hash keys and HTML attribute values.
10819 *
10820 * Transformations:
10821 * 'str' -> 'str'
10822 * null -> ''
10823 * undefined -> ''
10824 * true -> '1'
10825 * false -> '0'
10826 * 0 -> '0'
10827 * 1 -> '1'
10828 *
10829 */
10830
10831 /**
10832 * Escapes a string for use within HTML.
10833 *
10834 */
10835 const escape_html = str => {
10836 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
10837 };
10838
10839 /**
10840 * Prevent default
10841 *
10842 */
10843 const preventDefault = (evt, stop = false) => {
10844 if (evt) {
10845 evt.preventDefault();
10846 if (stop) {
10847 evt.stopPropagation();
10848 }
10849 }
10850 };
10851
10852 /**
10853 * Add event helper
10854 *
10855 */
10856 const addEvent = (target, type, callback, options) => {
10857 target.addEventListener(type, callback, options);
10858 };
10859
10860 /**
10861 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10862 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10863 *
10864 * param query should be {}
10865 */
10866 const getDom = query => {
10867 if (query.jquery) {
10868 return query[0];
10869 }
10870 if (query instanceof HTMLElement) {
10871 return query;
10872 }
10873 if (isHtmlString(query)) {
10874 var tpl = document.createElement('template');
10875 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10876 return tpl.content.firstChild;
10877 }
10878 return document.querySelector(query);
10879 };
10880 const isHtmlString = arg => {
10881 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10882 return true;
10883 }
10884 return false;
10885 };
10886
10887 /**
10888 * Plugin: "remove_button" (Tom Select)
10889 * Copyright (c) contributors
10890 *
10891 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10892 * file except in compliance with the License. You may obtain a copy of the License at:
10893 * http://www.apache.org/licenses/LICENSE-2.0
10894 *
10895 * Unless required by applicable law or agreed to in writing, software distributed under
10896 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10897 * ANY KIND, either express or implied. See the License for the specific language
10898 * governing permissions and limitations under the License.
10899 *
10900 */
10901
10902 function plugin (userOptions) {
10903 const options = Object.assign({
10904 label: '&times;',
10905 title: 'Remove',
10906 className: 'remove',
10907 append: true
10908 }, userOptions);
10909
10910 //options.className = 'remove-single';
10911 var self = this;
10912
10913 // override the render method to add remove button to each item
10914 if (!options.append) {
10915 return;
10916 }
10917 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
10918 self.hook('after', 'setupTemplates', () => {
10919 var orig_render_item = self.settings.render.item;
10920 self.settings.render.item = (data, escape) => {
10921 var item = getDom(orig_render_item.call(self, data, escape));
10922 var close_button = getDom(html);
10923 item.appendChild(close_button);
10924 addEvent(close_button, 'mousedown', evt => {
10925 preventDefault(evt, true);
10926 });
10927 addEvent(close_button, 'click', evt => {
10928 if (self.isLocked) return;
10929
10930 // propagating will trigger the dropdown to show for single mode
10931 preventDefault(evt, true);
10932 if (self.isLocked) return;
10933 if (!self.shouldDelete([item], evt)) return;
10934 self.removeItem(item);
10935 self.refreshOptions(false);
10936 self.inputState();
10937 });
10938 return item;
10939 };
10940 });
10941 }
10942
10943
10944 //# sourceMappingURL=plugin.js.map
10945
10946
10947 /***/ },
10948
10949 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10950 /*!*********************************************************************************!*\
10951 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10952 \*********************************************************************************/
10953 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10954
10955 "use strict";
10956 __webpack_require__.r(__webpack_exports__);
10957 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10958 /* harmony export */ "default": () => (/* binding */ plugin)
10959 /* harmony export */ });
10960 /**
10961 * Tom Select v2.4.3
10962 * Licensed under the Apache License, Version 2.0 (the "License");
10963 */
10964
10965 /**
10966 * Plugin: "restore_on_backspace" (Tom Select)
10967 * Copyright (c) contributors
10968 *
10969 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10970 * file except in compliance with the License. You may obtain a copy of the License at:
10971 * http://www.apache.org/licenses/LICENSE-2.0
10972 *
10973 * Unless required by applicable law or agreed to in writing, software distributed under
10974 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10975 * ANY KIND, either express or implied. See the License for the specific language
10976 * governing permissions and limitations under the License.
10977 *
10978 */
10979
10980 function plugin (userOptions) {
10981 const self = this;
10982 const options = Object.assign({
10983 text: option => {
10984 return option[self.settings.labelField];
10985 }
10986 }, userOptions);
10987 self.on('item_remove', function (value) {
10988 if (!self.isFocused) {
10989 return;
10990 }
10991 if (self.control_input.value.trim() === '') {
10992 var option = self.options[value];
10993 if (option) {
10994 self.setTextboxValue(options.text.call(self, option));
10995 }
10996 }
10997 });
10998 }
10999
11000
11001 //# sourceMappingURL=plugin.js.map
11002
11003
11004 /***/ },
11005
11006 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
11007 /*!***************************************************************************!*\
11008 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
11009 \***************************************************************************/
11010 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11011
11012 "use strict";
11013 __webpack_require__.r(__webpack_exports__);
11014 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11015 /* harmony export */ "default": () => (/* binding */ plugin)
11016 /* harmony export */ });
11017 /**
11018 * Tom Select v2.4.3
11019 * Licensed under the Apache License, Version 2.0 (the "License");
11020 */
11021
11022 /**
11023 * Converts a scalar to its best string representation
11024 * for hash keys and HTML attribute values.
11025 *
11026 * Transformations:
11027 * 'str' -> 'str'
11028 * null -> ''
11029 * undefined -> ''
11030 * true -> '1'
11031 * false -> '0'
11032 * 0 -> '0'
11033 * 1 -> '1'
11034 *
11035 */
11036
11037 /**
11038 * Iterates over arrays and hashes.
11039 *
11040 * ```
11041 * iterate(this.items, function(item, id) {
11042 * // invoked for each item
11043 * });
11044 * ```
11045 *
11046 */
11047 const iterate = (object, callback) => {
11048 if (Array.isArray(object)) {
11049 object.forEach(callback);
11050 } else {
11051 for (var key in object) {
11052 if (object.hasOwnProperty(key)) {
11053 callback(object[key], key);
11054 }
11055 }
11056 }
11057 };
11058
11059 /**
11060 * Add css classes
11061 *
11062 */
11063 const addClasses = (elmts, ...classes) => {
11064 var norm_classes = classesArray(classes);
11065 elmts = castAsArray(elmts);
11066 elmts.map(el => {
11067 norm_classes.map(cls => {
11068 el.classList.add(cls);
11069 });
11070 });
11071 };
11072
11073 /**
11074 * Return arguments
11075 *
11076 */
11077 const classesArray = args => {
11078 var classes = [];
11079 iterate(args, _classes => {
11080 if (typeof _classes === 'string') {
11081 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
11082 }
11083 if (Array.isArray(_classes)) {
11084 classes = classes.concat(_classes);
11085 }
11086 });
11087 return classes.filter(Boolean);
11088 };
11089
11090 /**
11091 * Create an array from arg if it's not already an array
11092 *
11093 */
11094 const castAsArray = arg => {
11095 if (!Array.isArray(arg)) {
11096 arg = [arg];
11097 }
11098 return arg;
11099 };
11100
11101 /**
11102 * Plugin: "restore_on_backspace" (Tom Select)
11103 * Copyright (c) contributors
11104 *
11105 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
11106 * file except in compliance with the License. You may obtain a copy of the License at:
11107 * http://www.apache.org/licenses/LICENSE-2.0
11108 *
11109 * Unless required by applicable law or agreed to in writing, software distributed under
11110 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11111 * ANY KIND, either express or implied. See the License for the specific language
11112 * governing permissions and limitations under the License.
11113 *
11114 */
11115
11116 function plugin () {
11117 const self = this;
11118 const orig_canLoad = self.canLoad;
11119 const orig_clearActiveOption = self.clearActiveOption;
11120 const orig_loadCallback = self.loadCallback;
11121 var pagination = {};
11122 var dropdown_content;
11123 var loading_more = false;
11124 var load_more_opt;
11125 var default_values = [];
11126 if (!self.settings.shouldLoadMore) {
11127 // return true if additional results should be loaded
11128 self.settings.shouldLoadMore = () => {
11129 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
11130 if (scroll_percent > 0.9) {
11131 return true;
11132 }
11133 if (self.activeOption) {
11134 var selectable = self.selectable();
11135 var index = Array.from(selectable).indexOf(self.activeOption);
11136 if (index >= selectable.length - 2) {
11137 return true;
11138 }
11139 }
11140 return false;
11141 };
11142 }
11143 if (!self.settings.firstUrl) {
11144 throw 'virtual_scroll plugin requires a firstUrl() method';
11145 }
11146
11147 // in order for virtual scrolling to work,
11148 // options need to be ordered the same way they're returned from the remote data source
11149 self.settings.sortField = [{
11150 field: '$order'
11151 }, {
11152 field: '$score'
11153 }];
11154
11155 // can we load more results for given query?
11156 const canLoadMore = query => {
11157 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
11158 return false;
11159 }
11160 if (query in pagination && pagination[query]) {
11161 return true;
11162 }
11163 return false;
11164 };
11165 const clearFilter = (option, value) => {
11166 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
11167 return true;
11168 }
11169 return false;
11170 };
11171
11172 // set the next url that will be
11173 self.setNextUrl = (value, next_url) => {
11174 pagination[value] = next_url;
11175 };
11176
11177 // getUrl() to be used in settings.load()
11178 self.getUrl = query => {
11179 if (query in pagination) {
11180 const next_url = pagination[query];
11181 pagination[query] = false;
11182 return next_url;
11183 }
11184
11185 // if the user goes back to a previous query
11186 // we need to load the first page again
11187 self.clearPagination();
11188 return self.settings.firstUrl.call(self, query);
11189 };
11190
11191 // clear pagination
11192 self.clearPagination = () => {
11193 pagination = {};
11194 };
11195
11196 // don't clear the active option (and cause unwanted dropdown scroll)
11197 // while loading more results
11198 self.hook('instead', 'clearActiveOption', () => {
11199 if (loading_more) {
11200 return;
11201 }
11202 return orig_clearActiveOption.call(self);
11203 });
11204
11205 // override the canLoad method
11206 self.hook('instead', 'canLoad', query => {
11207 // first time the query has been seen
11208 if (!(query in pagination)) {
11209 return orig_canLoad.call(self, query);
11210 }
11211 return canLoadMore(query);
11212 });
11213
11214 // wrap the load
11215 self.hook('instead', 'loadCallback', (options, optgroups) => {
11216 if (!loading_more) {
11217 self.clearOptions(clearFilter);
11218 } else if (load_more_opt) {
11219 const first_option = options[0];
11220 if (first_option !== undefined) {
11221 load_more_opt.dataset.value = first_option[self.settings.valueField];
11222 }
11223 }
11224 orig_loadCallback.call(self, options, optgroups);
11225 loading_more = false;
11226 });
11227
11228 // add templates to dropdown
11229 // loading_more if we have another url in the queue
11230 // no_more_results if we don't have another url in the queue
11231 self.hook('after', 'refreshOptions', () => {
11232 const query = self.lastValue;
11233 var option;
11234 if (canLoadMore(query)) {
11235 option = self.render('loading_more', {
11236 query: query
11237 });
11238 if (option) {
11239 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
11240 load_more_opt = option;
11241 }
11242 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
11243 option = self.render('no_more_results', {
11244 query: query
11245 });
11246 }
11247 if (option) {
11248 addClasses(option, self.settings.optionClass);
11249 dropdown_content.append(option);
11250 }
11251 });
11252
11253 // add scroll listener and default templates
11254 self.on('initialize', () => {
11255 default_values = Object.keys(self.options);
11256 dropdown_content = self.dropdown_content;
11257
11258 // default templates
11259 self.settings.render = Object.assign({}, {
11260 loading_more: () => {
11261 return `<div class="loading-more-results">Loading more results ... </div>`;
11262 },
11263 no_more_results: () => {
11264 return `<div class="no-more-results">No more results</div>`;
11265 }
11266 }, self.settings.render);
11267
11268 // watch dropdown content scroll position
11269 dropdown_content.addEventListener('scroll', () => {
11270 if (!self.settings.shouldLoadMore.call(self)) {
11271 return;
11272 }
11273
11274 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
11275 if (!canLoadMore(self.lastValue)) {
11276 return;
11277 }
11278
11279 // don't call load() too much
11280 if (loading_more) return;
11281 loading_more = true;
11282 self.load.call(self, self.lastValue);
11283 });
11284 });
11285 }
11286
11287
11288 //# sourceMappingURL=plugin.js.map
11289
11290
11291 /***/ },
11292
11293 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
11294 /*!*****************************************************************!*\
11295 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
11296 \*****************************************************************/
11297 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11298
11299 "use strict";
11300 __webpack_require__.r(__webpack_exports__);
11301 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11302 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
11303 /* harmony export */ });
11304 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
11305 /* 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");
11306 /* 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");
11307 /* 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");
11308 /* 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");
11309 /* 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");
11310 /* 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");
11311 /* 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");
11312 /* 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");
11313 /* 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");
11314 /* 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");
11315 /* 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");
11316 /* 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");
11317 /* 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");
11318 /* 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");
11319
11320
11321
11322
11323
11324
11325
11326
11327
11328
11329
11330
11331
11332
11333
11334 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
11335 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
11336 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
11337 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
11338 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
11339 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
11340 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
11341 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
11342 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
11343 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
11344 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
11345 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
11346 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
11347 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
11348 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
11349 //# sourceMappingURL=tom-select.complete.js.map
11350
11351 /***/ },
11352
11353 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
11354 /*!********************************************************!*\
11355 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
11356 \********************************************************/
11357 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11358
11359 "use strict";
11360 __webpack_require__.r(__webpack_exports__);
11361 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
11362 /* harmony export */ "default": () => (/* binding */ TomSelect)
11363 /* harmony export */ });
11364 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
11365 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
11366 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
11367 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
11368 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
11369 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
11370 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
11371 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
11372 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
11373
11374
11375
11376
11377
11378
11379
11380
11381
11382 var instance_i = 0;
11383 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
11384 constructor(input_arg, user_settings) {
11385 super();
11386 this.order = 0;
11387 this.isOpen = false;
11388 this.isDisabled = false;
11389 this.isReadOnly = false;
11390 this.isInvalid = false; // @deprecated 1.8
11391 this.isValid = true;
11392 this.isLocked = false;
11393 this.isFocused = false;
11394 this.isInputHidden = false;
11395 this.isSetup = false;
11396 this.ignoreFocus = false;
11397 this.ignoreHover = false;
11398 this.hasOptions = false;
11399 this.lastValue = '';
11400 this.caretPos = 0;
11401 this.loading = 0;
11402 this.loadedSearches = {};
11403 this.activeOption = null;
11404 this.activeItems = [];
11405 this.optgroups = {};
11406 this.options = {};
11407 this.userOptions = {};
11408 this.items = [];
11409 this.refreshTimeout = null;
11410 instance_i++;
11411 var dir;
11412 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
11413 if (input.tomselect) {
11414 throw new Error('Tom Select already initialized on this element');
11415 }
11416 input.tomselect = this;
11417 // detect rtl environment
11418 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
11419 dir = computedStyle.getPropertyValue('direction');
11420 // setup default state
11421 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
11422 this.settings = settings;
11423 this.input = input;
11424 this.tabIndex = input.tabIndex || 0;
11425 this.is_select_tag = input.tagName.toLowerCase() === 'select';
11426 this.rtl = /rtl/i.test(dir);
11427 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
11428 this.isRequired = input.required;
11429 // search system
11430 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
11431 // option-dependent defaults
11432 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
11433 if (typeof settings.hideSelected !== 'boolean') {
11434 settings.hideSelected = settings.mode === 'multi';
11435 }
11436 if (typeof settings.hidePlaceholder !== 'boolean') {
11437 settings.hidePlaceholder = settings.mode !== 'multi';
11438 }
11439 // set up createFilter callback
11440 var filter = settings.createFilter;
11441 if (typeof filter !== 'function') {
11442 if (typeof filter === 'string') {
11443 filter = new RegExp(filter);
11444 }
11445 if (filter instanceof RegExp) {
11446 settings.createFilter = (input) => filter.test(input);
11447 }
11448 else {
11449 settings.createFilter = (value) => {
11450 return this.settings.duplicates || !this.options[value];
11451 };
11452 }
11453 }
11454 this.initializePlugins(settings.plugins);
11455 this.setupCallbacks();
11456 this.setupTemplates();
11457 // Create all elements
11458 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
11459 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
11460 const dropdown = this._render('dropdown');
11461 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
11462 const classes = this.input.getAttribute('class') || '';
11463 const inputMode = settings.mode;
11464 var control_input;
11465 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
11466 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
11467 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
11468 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
11469 if (settings.copyClassesToDropdown) {
11470 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
11471 }
11472 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
11473 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
11474 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
11475 // default controlInput
11476 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
11477 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
11478 // set attributes
11479 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
11480 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
11481 if (input.getAttribute(attr)) {
11482 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
11483 }
11484 });
11485 control_input.tabIndex = -1;
11486 control.appendChild(control_input);
11487 this.focus_node = control_input;
11488 // dom element
11489 }
11490 else if (settings.controlInput) {
11491 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
11492 this.focus_node = control_input;
11493 }
11494 else {
11495 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
11496 this.focus_node = control;
11497 }
11498 this.wrapper = wrapper;
11499 this.dropdown = dropdown;
11500 this.dropdown_content = dropdown_content;
11501 this.control = control;
11502 this.control_input = control_input;
11503 this.setup();
11504 }
11505 /**
11506 * set up event bindings.
11507 *
11508 */
11509 setup() {
11510 const self = this;
11511 const settings = self.settings;
11512 const control_input = self.control_input;
11513 const dropdown = self.dropdown;
11514 const dropdown_content = self.dropdown_content;
11515 const wrapper = self.wrapper;
11516 const control = self.control;
11517 const input = self.input;
11518 const focus_node = self.focus_node;
11519 const passive_event = { passive: true };
11520 const listboxId = self.inputId + '-ts-dropdown';
11521 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
11522 id: listboxId
11523 });
11524 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
11525 role: 'combobox',
11526 'aria-haspopup': 'listbox',
11527 'aria-expanded': 'false',
11528 'aria-controls': listboxId
11529 });
11530 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
11531 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
11532 const label = document.querySelector(query);
11533 const label_click = self.focus.bind(self);
11534 if (label) {
11535 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
11536 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
11537 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
11538 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
11539 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11540 }
11541 wrapper.style.width = input.style.width;
11542 if (self.plugins.names.length) {
11543 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11544 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11545 }
11546 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11547 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11548 }
11549 if (settings.placeholder) {
11550 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11551 }
11552 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11553 if (!settings.splitOn && settings.delimiter) {
11554 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11555 }
11556 // debounce user defined load() if loadThrottle > 0
11557 // after initializePlugins() so plugins can create/modify user defined loaders
11558 if (settings.load && settings.loadThrottle) {
11559 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11560 }
11561 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11562 self.ignoreHover = false;
11563 });
11564 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11565 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11566 if (target_match)
11567 self.onOptionHover(e, target_match);
11568 }, { capture: true });
11569 // clicking on an option should select it
11570 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11571 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11572 if (option) {
11573 self.onOptionSelect(evt, option);
11574 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11575 }
11576 });
11577 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11578 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11579 if (target_match && self.onItemSelect(evt, target_match)) {
11580 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11581 return;
11582 }
11583 // retain focus (see control_input mousedown)
11584 if (control_input.value != '') {
11585 return;
11586 }
11587 self.onClick();
11588 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11589 });
11590 // keydown on focus_node for arrow_down/arrow_up
11591 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11592 // keypress and input/keyup
11593 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11594 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11595 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11596 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11597 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11598 const doc_mousedown = (evt) => {
11599 // blur if target is outside of this instance
11600 // dropdown is not always inside wrapper
11601 const target = evt.composedPath()[0];
11602 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11603 if (self.isFocused) {
11604 self.blur();
11605 }
11606 self.inputState();
11607 return;
11608 }
11609 // retain focus by preventing native handling. if the
11610 // event target is the input it should not be modified.
11611 // otherwise, text selection within the input won't work.
11612 // Fixes bug #212 which is no covered by tests
11613 if (target == control_input && self.isOpen) {
11614 evt.stopPropagation();
11615 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11616 }
11617 else {
11618 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11619 }
11620 };
11621 const win_scroll = () => {
11622 if (self.isOpen) {
11623 self.positionDropdown();
11624 }
11625 };
11626 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11627 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11628 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11629 this._destroy = () => {
11630 document.removeEventListener('mousedown', doc_mousedown);
11631 window.removeEventListener('scroll', win_scroll);
11632 window.removeEventListener('resize', win_scroll);
11633 if (label)
11634 label.removeEventListener('click', label_click);
11635 };
11636 // store original html and tab index so that they can be
11637 // restored when the destroy() method is called.
11638 this.revertSettings = {
11639 innerHTML: input.innerHTML,
11640 tabIndex: input.tabIndex
11641 };
11642 input.tabIndex = -1;
11643 input.insertAdjacentElement('afterend', self.wrapper);
11644 self.sync(false);
11645 settings.items = [];
11646 delete settings.optgroups;
11647 delete settings.options;
11648 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
11649 if (self.isValid) {
11650 self.isValid = false;
11651 self.isInvalid = true;
11652 self.refreshState();
11653 }
11654 });
11655 self.updateOriginalInput();
11656 self.refreshItems();
11657 self.close(false);
11658 self.inputState();
11659 self.isSetup = true;
11660 if (input.disabled) {
11661 self.disable();
11662 }
11663 else if (input.readOnly) {
11664 self.setReadOnly(true);
11665 }
11666 else {
11667 self.enable(); //sets tabIndex
11668 }
11669 self.on('change', this.onChange);
11670 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11671 self.trigger('initialize');
11672 // preload options
11673 if (settings.preload === true) {
11674 self.preload();
11675 }
11676 }
11677 /**
11678 * Register options and optgroups
11679 *
11680 */
11681 setupOptions(options = [], optgroups = []) {
11682 // build options table
11683 this.addOptions(options);
11684 // build optgroup table
11685 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11686 this.registerOptionGroup(optgroup);
11687 });
11688 }
11689 /**
11690 * Sets up default rendering functions.
11691 */
11692 setupTemplates() {
11693 var self = this;
11694 var field_label = self.settings.labelField;
11695 var field_optgroup = self.settings.optgroupLabelField;
11696 var templates = {
11697 'optgroup': (data) => {
11698 let optgroup = document.createElement('div');
11699 optgroup.className = 'optgroup';
11700 optgroup.appendChild(data.options);
11701 return optgroup;
11702 },
11703 'optgroup_header': (data, escape) => {
11704 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11705 },
11706 'option': (data, escape) => {
11707 return '<div>' + escape(data[field_label]) + '</div>';
11708 },
11709 'item': (data, escape) => {
11710 return '<div>' + escape(data[field_label]) + '</div>';
11711 },
11712 'option_create': (data, escape) => {
11713 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11714 },
11715 'no_results': () => {
11716 return '<div class="no-results">No results found</div>';
11717 },
11718 'loading': () => {
11719 return '<div class="spinner"></div>';
11720 },
11721 'not_loading': () => { },
11722 'dropdown': () => {
11723 return '<div></div>';
11724 }
11725 };
11726 self.settings.render = Object.assign({}, templates, self.settings.render);
11727 }
11728 /**
11729 * Maps fired events to callbacks provided
11730 * in the settings used when creating the control.
11731 */
11732 setupCallbacks() {
11733 var key, fn;
11734 var callbacks = {
11735 'initialize': 'onInitialize',
11736 'change': 'onChange',
11737 'item_add': 'onItemAdd',
11738 'item_remove': 'onItemRemove',
11739 'item_select': 'onItemSelect',
11740 'clear': 'onClear',
11741 'option_add': 'onOptionAdd',
11742 'option_remove': 'onOptionRemove',
11743 'option_clear': 'onOptionClear',
11744 'optgroup_add': 'onOptionGroupAdd',
11745 'optgroup_remove': 'onOptionGroupRemove',
11746 'optgroup_clear': 'onOptionGroupClear',
11747 'dropdown_open': 'onDropdownOpen',
11748 'dropdown_close': 'onDropdownClose',
11749 'type': 'onType',
11750 'load': 'onLoad',
11751 'focus': 'onFocus',
11752 'blur': 'onBlur'
11753 };
11754 for (key in callbacks) {
11755 fn = this.settings[callbacks[key]];
11756 if (fn)
11757 this.on(key, fn);
11758 }
11759 }
11760 /**
11761 * Sync the Tom Select instance with the original input or select
11762 *
11763 */
11764 sync(get_settings = true) {
11765 const self = this;
11766 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
11767 self.setupOptions(settings.options, settings.optgroups);
11768 self.setValue(settings.items || [], true); // silent prevents recursion
11769 self.lastQuery = null; // so updated options will be displayed in dropdown
11770 }
11771 /**
11772 * Triggered when the main control element
11773 * has a click event.
11774 *
11775 */
11776 onClick() {
11777 var self = this;
11778 if (self.activeItems.length > 0) {
11779 self.clearActiveItems();
11780 self.focus();
11781 return;
11782 }
11783 if (self.isFocused && self.isOpen) {
11784 self.blur();
11785 }
11786 else {
11787 self.focus();
11788 }
11789 }
11790 /**
11791 * @deprecated v1.7
11792 *
11793 */
11794 onMouseDown() { }
11795 /**
11796 * Triggered when the value of the control has been changed.
11797 * This should propagate the event to the original DOM
11798 * input / select element.
11799 */
11800 onChange() {
11801 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11802 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11803 }
11804 /**
11805 * Triggered on <input> paste.
11806 *
11807 */
11808 onPaste(e) {
11809 var self = this;
11810 if (self.isInputHidden || self.isLocked) {
11811 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11812 return;
11813 }
11814 // If a regex or string is included, this will split the pasted
11815 // input and create Items for each separate value
11816 if (!self.settings.splitOn) {
11817 return;
11818 }
11819 // Wait for pasted text to be recognized in value
11820 setTimeout(() => {
11821 var pastedText = self.inputValue();
11822 if (!pastedText.match(self.settings.splitOn)) {
11823 return;
11824 }
11825 var splitInput = pastedText.trim().split(self.settings.splitOn);
11826 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11827 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11828 if (hash) {
11829 if (this.options[piece]) {
11830 self.addItem(piece);
11831 }
11832 else {
11833 self.createItem(piece);
11834 }
11835 }
11836 });
11837 }, 0);
11838 }
11839 /**
11840 * Triggered on <input> keypress.
11841 *
11842 */
11843 onKeyPress(e) {
11844 var self = this;
11845 if (self.isLocked) {
11846 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11847 return;
11848 }
11849 var character = String.fromCharCode(e.keyCode || e.which);
11850 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11851 self.createItem();
11852 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11853 return;
11854 }
11855 }
11856 /**
11857 * Triggered on <input> keydown.
11858 *
11859 */
11860 onKeyDown(e) {
11861 var self = this;
11862 self.ignoreHover = true;
11863 if (self.isLocked) {
11864 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11865 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11866 }
11867 return;
11868 }
11869 switch (e.keyCode) {
11870 // ctrl+A: select all
11871 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11872 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11873 if (self.control_input.value == '') {
11874 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11875 self.selectAll();
11876 return;
11877 }
11878 }
11879 break;
11880 // esc: close dropdown
11881 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11882 if (self.isOpen) {
11883 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11884 self.close();
11885 }
11886 self.clearActiveItems();
11887 return;
11888 // down: open dropdown or move selection down
11889 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11890 if (!self.isOpen && self.hasOptions) {
11891 self.open();
11892 }
11893 else if (self.activeOption) {
11894 let next = self.getAdjacent(self.activeOption, 1);
11895 if (next)
11896 self.setActiveOption(next);
11897 }
11898 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11899 return;
11900 // up: move selection up
11901 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11902 if (self.activeOption) {
11903 let prev = self.getAdjacent(self.activeOption, -1);
11904 if (prev)
11905 self.setActiveOption(prev);
11906 }
11907 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11908 return;
11909 // return: select active option
11910 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11911 if (self.canSelect(self.activeOption)) {
11912 self.onOptionSelect(e, self.activeOption);
11913 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11914 // if the option_create=null, the dropdown might be closed
11915 }
11916 else if (self.settings.create && self.createItem()) {
11917 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11918 // don't submit form when searching for a value
11919 }
11920 else if (document.activeElement == self.control_input && self.isOpen) {
11921 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11922 }
11923 return;
11924 // left: modifiy item selection to the left
11925 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11926 self.advanceSelection(-1, e);
11927 return;
11928 // right: modifiy item selection to the right
11929 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11930 self.advanceSelection(1, e);
11931 return;
11932 // tab: select active option and/or create item
11933 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11934 if (self.settings.selectOnTab) {
11935 if (self.canSelect(self.activeOption)) {
11936 self.onOptionSelect(e, self.activeOption);
11937 // prevent default [tab] behaviour of jump to the next field
11938 // if select isFull, then the dropdown won't be open and [tab] will work normally
11939 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11940 }
11941 if (self.settings.create && self.createItem()) {
11942 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11943 }
11944 }
11945 return;
11946 // delete|backspace: delete items
11947 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11948 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11949 self.deleteSelection(e);
11950 return;
11951 }
11952 // don't enter text in the control_input when active items are selected
11953 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11954 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11955 }
11956 }
11957 /**
11958 * Triggered on <input> keyup.
11959 *
11960 */
11961 onInput(e) {
11962 if (this.isLocked) {
11963 return;
11964 }
11965 const value = this.inputValue();
11966 if (this.lastValue === value)
11967 return;
11968 this.lastValue = value;
11969 if (value == '') {
11970 this._onInput();
11971 return;
11972 }
11973 if (this.refreshTimeout) {
11974 window.clearTimeout(this.refreshTimeout);
11975 }
11976 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11977 this.refreshTimeout = null;
11978 this._onInput();
11979 }, this.settings.refreshThrottle);
11980 }
11981 _onInput() {
11982 const value = this.lastValue;
11983 if (this.settings.shouldLoad.call(this, value)) {
11984 this.load(value);
11985 }
11986 this.refreshOptions();
11987 this.trigger('type', value);
11988 }
11989 /**
11990 * Triggered when the user rolls over
11991 * an option in the autocomplete dropdown menu.
11992 *
11993 */
11994 onOptionHover(evt, option) {
11995 if (this.ignoreHover)
11996 return;
11997 this.setActiveOption(option, false);
11998 }
11999 /**
12000 * Triggered on <input> focus.
12001 *
12002 */
12003 onFocus(e) {
12004 var self = this;
12005 var wasFocused = self.isFocused;
12006 if (self.isDisabled || self.isReadOnly) {
12007 self.blur();
12008 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
12009 return;
12010 }
12011 if (self.ignoreFocus)
12012 return;
12013 self.isFocused = true;
12014 if (self.settings.preload === 'focus')
12015 self.preload();
12016 if (!wasFocused)
12017 self.trigger('focus');
12018 if (!self.activeItems.length) {
12019 self.inputState();
12020 self.refreshOptions(!!self.settings.openOnFocus);
12021 }
12022 self.refreshState();
12023 }
12024 /**
12025 * Triggered on <input> blur.
12026 *
12027 */
12028 onBlur(e) {
12029 if (document.hasFocus() === false)
12030 return;
12031 var self = this;
12032 if (!self.isFocused)
12033 return;
12034 self.isFocused = false;
12035 self.ignoreFocus = false;
12036 var deactivate = () => {
12037 self.close();
12038 self.setActiveItem();
12039 self.setCaret(self.items.length);
12040 self.trigger('blur');
12041 };
12042 if (self.settings.create && self.settings.createOnBlur) {
12043 self.createItem(null, deactivate);
12044 }
12045 else {
12046 deactivate();
12047 }
12048 }
12049 /**
12050 * Triggered when the user clicks on an option
12051 * in the autocomplete dropdown menu.
12052 *
12053 */
12054 onOptionSelect(evt, option) {
12055 var value, self = this;
12056 // should not be possible to trigger a option under a disabled optgroup
12057 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
12058 return;
12059 }
12060 if (option.classList.contains('create')) {
12061 self.createItem(null, () => {
12062 if (self.settings.closeAfterSelect) {
12063 self.close();
12064 }
12065 });
12066 }
12067 else {
12068 value = option.dataset.value;
12069 if (typeof value !== 'undefined') {
12070 self.lastQuery = null;
12071 self.addItem(value);
12072 if (self.settings.closeAfterSelect) {
12073 self.close();
12074 }
12075 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
12076 self.setActiveOption(option);
12077 }
12078 }
12079 }
12080 }
12081 /**
12082 * Return true if the given option can be selected
12083 *
12084 */
12085 canSelect(option) {
12086 if (this.isOpen && option && this.dropdown_content.contains(option)) {
12087 return true;
12088 }
12089 return false;
12090 }
12091 /**
12092 * Triggered when the user clicks on an item
12093 * that has been selected.
12094 *
12095 */
12096 onItemSelect(evt, item) {
12097 var self = this;
12098 if (!self.isLocked && self.settings.mode === 'multi') {
12099 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
12100 self.setActiveItem(item, evt);
12101 return true;
12102 }
12103 return false;
12104 }
12105 /**
12106 * Determines whether or not to invoke
12107 * the user-provided option provider / loader
12108 *
12109 * Note, there is a subtle difference between
12110 * this.canLoad() and this.settings.shouldLoad();
12111 *
12112 * - settings.shouldLoad() is a user-input validator.
12113 * When false is returned, the not_loading template
12114 * will be added to the dropdown
12115 *
12116 * - canLoad() is lower level validator that checks
12117 * the Tom Select instance. There is no inherent user
12118 * feedback when canLoad returns false
12119 *
12120 */
12121 canLoad(value) {
12122 if (!this.settings.load)
12123 return false;
12124 if (this.loadedSearches.hasOwnProperty(value))
12125 return false;
12126 return true;
12127 }
12128 /**
12129 * Invokes the user-provided option provider / loader.
12130 *
12131 */
12132 load(value) {
12133 const self = this;
12134 if (!self.canLoad(value))
12135 return;
12136 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
12137 self.loading++;
12138 const callback = self.loadCallback.bind(self);
12139 self.settings.load.call(self, value, callback);
12140 }
12141 /**
12142 * Invoked by the user-provided option provider
12143 *
12144 */
12145 loadCallback(options, optgroups) {
12146 const self = this;
12147 self.loading = Math.max(self.loading - 1, 0);
12148 self.lastQuery = null;
12149 self.clearActiveOption(); // when new results load, focus should be on first option
12150 self.setupOptions(options, optgroups);
12151 self.refreshOptions(self.isFocused && !self.isInputHidden);
12152 if (!self.loading) {
12153 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
12154 }
12155 self.trigger('load', options, optgroups);
12156 }
12157 preload() {
12158 var classList = this.wrapper.classList;
12159 if (classList.contains('preloaded'))
12160 return;
12161 classList.add('preloaded');
12162 this.load('');
12163 }
12164 /**
12165 * Sets the input field of the control to the specified value.
12166 *
12167 */
12168 setTextboxValue(value = '') {
12169 var input = this.control_input;
12170 var changed = input.value !== value;
12171 if (changed) {
12172 input.value = value;
12173 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
12174 this.lastValue = value;
12175 }
12176 }
12177 /**
12178 * Returns the value of the control. If multiple items
12179 * can be selected (e.g. <select multiple>), this returns
12180 * an array. If only one item can be selected, this
12181 * returns a string.
12182 *
12183 */
12184 getValue() {
12185 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
12186 return this.items;
12187 }
12188 return this.items.join(this.settings.delimiter);
12189 }
12190 /**
12191 * Resets the selected items to the given value.
12192 *
12193 */
12194 setValue(value, silent) {
12195 var events = silent ? [] : ['change'];
12196 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12197 this.clear(silent);
12198 this.addItems(value, silent);
12199 });
12200 }
12201 /**
12202 * Resets the number of max items to the given value
12203 *
12204 */
12205 setMaxItems(value) {
12206 if (value === 0)
12207 value = null; //reset to unlimited items.
12208 this.settings.maxItems = value;
12209 this.refreshState();
12210 }
12211 /**
12212 * Sets the selected item.
12213 *
12214 */
12215 setActiveItem(item, e) {
12216 var self = this;
12217 var eventName;
12218 var i, begin, end, swap;
12219 var last;
12220 if (self.settings.mode === 'single')
12221 return;
12222 // clear the active selection
12223 if (!item) {
12224 self.clearActiveItems();
12225 if (self.isFocused) {
12226 self.inputState();
12227 }
12228 return;
12229 }
12230 // modify selection
12231 eventName = e && e.type.toLowerCase();
12232 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
12233 last = self.getLastActive();
12234 begin = Array.prototype.indexOf.call(self.control.children, last);
12235 end = Array.prototype.indexOf.call(self.control.children, item);
12236 if (begin > end) {
12237 swap = begin;
12238 begin = end;
12239 end = swap;
12240 }
12241 for (i = begin; i <= end; i++) {
12242 item = self.control.children[i];
12243 if (self.activeItems.indexOf(item) === -1) {
12244 self.setActiveItemClass(item);
12245 }
12246 }
12247 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
12248 }
12249 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))) {
12250 if (item.classList.contains('active')) {
12251 self.removeActiveItem(item);
12252 }
12253 else {
12254 self.setActiveItemClass(item);
12255 }
12256 }
12257 else {
12258 self.clearActiveItems();
12259 self.setActiveItemClass(item);
12260 }
12261 // ensure control has focus
12262 self.inputState();
12263 if (!self.isFocused) {
12264 self.focus();
12265 }
12266 }
12267 /**
12268 * Set the active and last-active classes
12269 *
12270 */
12271 setActiveItemClass(item) {
12272 const self = this;
12273 const last_active = self.control.querySelector('.last-active');
12274 if (last_active)
12275 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
12276 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
12277 self.trigger('item_select', item);
12278 if (self.activeItems.indexOf(item) == -1) {
12279 self.activeItems.push(item);
12280 }
12281 }
12282 /**
12283 * Remove active item
12284 *
12285 */
12286 removeActiveItem(item) {
12287 var idx = this.activeItems.indexOf(item);
12288 this.activeItems.splice(idx, 1);
12289 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12290 }
12291 /**
12292 * Clears all the active items
12293 *
12294 */
12295 clearActiveItems() {
12296 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
12297 this.activeItems = [];
12298 }
12299 /**
12300 * Sets the selected item in the dropdown menu
12301 * of available options.
12302 *
12303 */
12304 setActiveOption(option, scroll = true) {
12305 if (option === this.activeOption) {
12306 return;
12307 }
12308 this.clearActiveOption();
12309 if (!option)
12310 return;
12311 this.activeOption = option;
12312 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
12313 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
12314 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
12315 if (scroll)
12316 this.scrollToOption(option);
12317 }
12318 /**
12319 * Sets the dropdown_content scrollTop to display the option
12320 *
12321 */
12322 scrollToOption(option, behavior) {
12323 if (!option)
12324 return;
12325 const content = this.dropdown_content;
12326 const height_menu = content.clientHeight;
12327 const scrollTop = content.scrollTop || 0;
12328 const height_item = option.offsetHeight;
12329 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
12330 if (y + height_item > height_menu + scrollTop) {
12331 this.scroll(y - height_menu + height_item, behavior);
12332 }
12333 else if (y < scrollTop) {
12334 this.scroll(y, behavior);
12335 }
12336 }
12337 /**
12338 * Scroll the dropdown to the given position
12339 *
12340 */
12341 scroll(scrollTop, behavior) {
12342 const content = this.dropdown_content;
12343 if (behavior) {
12344 content.style.scrollBehavior = behavior;
12345 }
12346 content.scrollTop = scrollTop;
12347 content.style.scrollBehavior = '';
12348 }
12349 /**
12350 * Clears the active option
12351 *
12352 */
12353 clearActiveOption() {
12354 if (this.activeOption) {
12355 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
12356 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
12357 }
12358 this.activeOption = null;
12359 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
12360 }
12361 /**
12362 * Selects all items (CTRL + A).
12363 */
12364 selectAll() {
12365 const self = this;
12366 if (self.settings.mode === 'single')
12367 return;
12368 const activeItems = self.controlChildren();
12369 if (!activeItems.length)
12370 return;
12371 self.inputState();
12372 self.close();
12373 self.activeItems = activeItems;
12374 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
12375 self.setActiveItemClass(item);
12376 });
12377 }
12378 /**
12379 * Determines if the control_input should be in a hidden or visible state
12380 *
12381 */
12382 inputState() {
12383 var self = this;
12384 if (!self.control.contains(self.control_input))
12385 return;
12386 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
12387 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
12388 self.setTextboxValue();
12389 self.isInputHidden = true;
12390 }
12391 else {
12392 if (self.settings.hidePlaceholder && self.items.length > 0) {
12393 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
12394 }
12395 self.isInputHidden = false;
12396 }
12397 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
12398 }
12399 /**
12400 * Get the input value
12401 */
12402 inputValue() {
12403 return this.control_input.value.trim();
12404 }
12405 /**
12406 * Gives the control focus.
12407 */
12408 focus() {
12409 var self = this;
12410 if (self.isDisabled || self.isReadOnly)
12411 return;
12412 self.ignoreFocus = true;
12413 if (self.control_input.offsetWidth) {
12414 self.control_input.focus();
12415 }
12416 else {
12417 self.focus_node.focus();
12418 }
12419 setTimeout(() => {
12420 self.ignoreFocus = false;
12421 self.onFocus();
12422 }, 0);
12423 }
12424 /**
12425 * Forces the control out of focus.
12426 *
12427 */
12428 blur() {
12429 this.focus_node.blur();
12430 this.onBlur();
12431 }
12432 /**
12433 * Returns a function that scores an object
12434 * to show how good of a match it is to the
12435 * provided query.
12436 *
12437 * @return {function}
12438 */
12439 getScoreFunction(query) {
12440 return this.sifter.getScoreFunction(query, this.getSearchOptions());
12441 }
12442 /**
12443 * Returns search options for sifter (the system
12444 * for scoring and sorting results).
12445 *
12446 * @see https://github.com/orchidjs/sifter.js
12447 * @return {object}
12448 */
12449 getSearchOptions() {
12450 var settings = this.settings;
12451 var sort = settings.sortField;
12452 if (typeof settings.sortField === 'string') {
12453 sort = [{ field: settings.sortField }];
12454 }
12455 return {
12456 fields: settings.searchField,
12457 conjunction: settings.searchConjunction,
12458 sort: sort,
12459 nesting: settings.nesting
12460 };
12461 }
12462 /**
12463 * Searches through available options and returns
12464 * a sorted array of matches.
12465 *
12466 */
12467 search(query) {
12468 var result, calculateScore;
12469 var self = this;
12470 var options = this.getSearchOptions();
12471 // validate user-provided result scoring function
12472 if (self.settings.score) {
12473 calculateScore = self.settings.score.call(self, query);
12474 if (typeof calculateScore !== 'function') {
12475 throw new Error('Tom Select "score" setting must be a function that returns a function');
12476 }
12477 }
12478 // perform search
12479 if (query !== self.lastQuery) {
12480 self.lastQuery = query;
12481 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
12482 self.currentResults = result;
12483 }
12484 else {
12485 result = Object.assign({}, self.currentResults);
12486 }
12487 // filter out selected items
12488 if (self.settings.hideSelected) {
12489 result.items = result.items.filter((item) => {
12490 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
12491 return !(hashed && self.items.indexOf(hashed) !== -1);
12492 });
12493 }
12494 return result;
12495 }
12496 /**
12497 * Refreshes the list of available options shown
12498 * in the autocomplete dropdown menu.
12499 *
12500 */
12501 refreshOptions(triggerDropdown = true) {
12502 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
12503 var create;
12504 const groups = {};
12505 const groups_order = [];
12506 var self = this;
12507 var query = self.inputValue();
12508 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
12509 var results = self.search(query);
12510 var active_option = null;
12511 var show_dropdown = self.settings.shouldOpen || false;
12512 var dropdown_content = self.dropdown_content;
12513 if (same_query) {
12514 active_option = self.activeOption;
12515 if (active_option) {
12516 active_group = active_option.closest('[data-group]');
12517 }
12518 }
12519 // build markup
12520 n = results.items.length;
12521 if (typeof self.settings.maxOptions === 'number') {
12522 n = Math.min(n, self.settings.maxOptions);
12523 }
12524 if (n > 0) {
12525 show_dropdown = true;
12526 }
12527 // get fragment for group and the position of the group in group_order
12528 const getGroupFragment = (optgroup, order) => {
12529 let group_order_i = groups[optgroup];
12530 if (group_order_i !== undefined) {
12531 let order_group = groups_order[group_order_i];
12532 if (order_group !== undefined) {
12533 return [group_order_i, order_group.fragment];
12534 }
12535 }
12536 let group_fragment = document.createDocumentFragment();
12537 group_order_i = groups_order.length;
12538 groups_order.push({ fragment: group_fragment, order, optgroup });
12539 return [group_order_i, group_fragment];
12540 };
12541 // render and group available options individually
12542 for (i = 0; i < n; i++) {
12543 // get option dom element
12544 let item = results.items[i];
12545 if (!item)
12546 continue;
12547 let opt_value = item.id;
12548 let option = self.options[opt_value];
12549 if (option === undefined)
12550 continue;
12551 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12552 let option_el = self.getOption(opt_hash, true);
12553 // toggle 'selected' class
12554 if (!self.settings.hideSelected) {
12555 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12556 }
12557 optgroup = option[self.settings.optgroupField] || '';
12558 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12559 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12560 optgroup = optgroups[j];
12561 let order = option.$order;
12562 let self_optgroup = self.optgroups[optgroup];
12563 if (self_optgroup === undefined) {
12564 optgroup = '';
12565 }
12566 else {
12567 order = self_optgroup.$order;
12568 }
12569 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12570 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12571 if (j > 0) {
12572 option_el = option_el.cloneNode(true);
12573 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12574 option_el.classList.add('ts-cloned');
12575 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12576 // make sure we keep the activeOption in the same group
12577 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12578 if (active_group && active_group.dataset.group === optgroup.toString()) {
12579 active_option = option_el;
12580 }
12581 }
12582 }
12583 group_fragment.appendChild(option_el);
12584 if (optgroup != '') {
12585 groups[optgroup] = group_order_i;
12586 }
12587 }
12588 }
12589 // sort optgroups
12590 if (self.settings.lockOptgroupOrder) {
12591 groups_order.sort((a, b) => {
12592 return a.order - b.order;
12593 });
12594 }
12595 // render optgroup headers & join groups
12596 html = document.createDocumentFragment();
12597 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12598 let group_fragment = group_order.fragment;
12599 let optgroup = group_order.optgroup;
12600 if (!group_fragment || !group_fragment.children.length)
12601 return;
12602 let group_heading = self.optgroups[optgroup];
12603 if (group_heading !== undefined) {
12604 let group_options = document.createDocumentFragment();
12605 let header = self.render('optgroup_header', group_heading);
12606 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12607 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12608 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12609 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12610 }
12611 else {
12612 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12613 }
12614 });
12615 dropdown_content.innerHTML = '';
12616 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12617 // highlight matching terms inline
12618 if (self.settings.highlight) {
12619 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12620 if (results.query.length && results.tokens.length) {
12621 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12622 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12623 });
12624 }
12625 }
12626 // helper method for adding templates to dropdown
12627 var add_template = (template) => {
12628 let content = self.render(template, { input: query });
12629 if (content) {
12630 show_dropdown = true;
12631 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12632 }
12633 return content;
12634 };
12635 // add loading message
12636 if (self.loading) {
12637 add_template('loading');
12638 // invalid query
12639 }
12640 else if (!self.settings.shouldLoad.call(self, query)) {
12641 add_template('not_loading');
12642 // add no_results message
12643 }
12644 else if (results.items.length === 0) {
12645 add_template('no_results');
12646 }
12647 // add create option
12648 has_create_option = self.canCreate(query);
12649 if (has_create_option) {
12650 create = add_template('option_create');
12651 }
12652 // activate
12653 self.hasOptions = results.items.length > 0 || has_create_option;
12654 if (show_dropdown) {
12655 if (results.items.length > 0) {
12656 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12657 active_option = self.getOption(self.items[0]);
12658 }
12659 if (!dropdown_content.contains(active_option)) {
12660 let active_index = 0;
12661 if (create && !self.settings.addPrecedence) {
12662 active_index = 1;
12663 }
12664 active_option = self.selectable()[active_index];
12665 }
12666 }
12667 else if (create) {
12668 active_option = create;
12669 }
12670 if (triggerDropdown && !self.isOpen) {
12671 self.open();
12672 self.scrollToOption(active_option, 'auto');
12673 }
12674 self.setActiveOption(active_option);
12675 }
12676 else {
12677 self.clearActiveOption();
12678 if (triggerDropdown && self.isOpen) {
12679 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12680 }
12681 }
12682 }
12683 /**
12684 * Return list of selectable options
12685 *
12686 */
12687 selectable() {
12688 return this.dropdown_content.querySelectorAll('[data-selectable]');
12689 }
12690 /**
12691 * Adds an available option. If it already exists,
12692 * nothing will happen. Note: this does not refresh
12693 * the options list dropdown (use `refreshOptions`
12694 * for that).
12695 *
12696 * Usage:
12697 *
12698 * this.addOption(data)
12699 *
12700 */
12701 addOption(data, user_created = false) {
12702 const self = this;
12703 // @deprecated 1.7.7
12704 // use addOptions( array, user_created ) for adding multiple options
12705 if (Array.isArray(data)) {
12706 self.addOptions(data, user_created);
12707 return false;
12708 }
12709 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12710 if (key === null || self.options.hasOwnProperty(key)) {
12711 return false;
12712 }
12713 data.$order = data.$order || ++self.order;
12714 data.$id = self.inputId + '-opt-' + data.$order;
12715 self.options[key] = data;
12716 self.lastQuery = null;
12717 if (user_created) {
12718 self.userOptions[key] = user_created;
12719 self.trigger('option_add', key, data);
12720 }
12721 return key;
12722 }
12723 /**
12724 * Add multiple options
12725 *
12726 */
12727 addOptions(data, user_created = false) {
12728 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12729 this.addOption(dat, user_created);
12730 });
12731 }
12732 /**
12733 * @deprecated 1.7.7
12734 */
12735 registerOption(data) {
12736 return this.addOption(data);
12737 }
12738 /**
12739 * Registers an option group to the pool of option groups.
12740 *
12741 * @return {boolean|string}
12742 */
12743 registerOptionGroup(data) {
12744 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12745 if (key === null)
12746 return false;
12747 data.$order = data.$order || ++this.order;
12748 this.optgroups[key] = data;
12749 return key;
12750 }
12751 /**
12752 * Registers a new optgroup for options
12753 * to be bucketed into.
12754 *
12755 */
12756 addOptionGroup(id, data) {
12757 var hashed_id;
12758 data[this.settings.optgroupValueField] = id;
12759 if (hashed_id = this.registerOptionGroup(data)) {
12760 this.trigger('optgroup_add', hashed_id, data);
12761 }
12762 }
12763 /**
12764 * Removes an existing option group.
12765 *
12766 */
12767 removeOptionGroup(id) {
12768 if (this.optgroups.hasOwnProperty(id)) {
12769 delete this.optgroups[id];
12770 this.clearCache();
12771 this.trigger('optgroup_remove', id);
12772 }
12773 }
12774 /**
12775 * Clears all existing option groups.
12776 */
12777 clearOptionGroups() {
12778 this.optgroups = {};
12779 this.clearCache();
12780 this.trigger('optgroup_clear');
12781 }
12782 /**
12783 * Updates an option available for selection. If
12784 * it is visible in the selected items or options
12785 * dropdown, it will be re-rendered automatically.
12786 *
12787 */
12788 updateOption(value, data) {
12789 const self = this;
12790 var item_new;
12791 var index_item;
12792 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12793 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12794 // sanity checks
12795 if (value_old === null)
12796 return;
12797 const data_old = self.options[value_old];
12798 if (data_old == undefined)
12799 return;
12800 if (typeof value_new !== 'string')
12801 throw new Error('Value must be set in option data');
12802 const option = self.getOption(value_old);
12803 const item = self.getItem(value_old);
12804 data.$order = data.$order || data_old.$order;
12805 delete self.options[value_old];
12806 // invalidate render cache
12807 // don't remove existing node yet, we'll remove it after replacing it
12808 self.uncacheValue(value_new);
12809 self.options[value_new] = data;
12810 // update the option if it's in the dropdown
12811 if (option) {
12812 if (self.dropdown_content.contains(option)) {
12813 const option_new = self._render('option', data);
12814 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12815 if (self.activeOption === option) {
12816 self.setActiveOption(option_new);
12817 }
12818 }
12819 option.remove();
12820 }
12821 // update the item if we have one
12822 if (item) {
12823 index_item = self.items.indexOf(value_old);
12824 if (index_item !== -1) {
12825 self.items.splice(index_item, 1, value_new);
12826 }
12827 item_new = self._render('item', data);
12828 if (item.classList.contains('active'))
12829 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12830 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12831 }
12832 // invalidate last query because we might have updated the sortField
12833 self.lastQuery = null;
12834 }
12835 /**
12836 * Removes a single option.
12837 *
12838 */
12839 removeOption(value, silent) {
12840 const self = this;
12841 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12842 self.uncacheValue(value);
12843 delete self.userOptions[value];
12844 delete self.options[value];
12845 self.lastQuery = null;
12846 self.trigger('option_remove', value);
12847 self.removeItem(value, silent);
12848 }
12849 /**
12850 * Clears all options.
12851 */
12852 clearOptions(filter) {
12853 const boundFilter = (filter || this.clearFilter).bind(this);
12854 this.loadedSearches = {};
12855 this.userOptions = {};
12856 this.clearCache();
12857 const selected = {};
12858 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12859 if (boundFilter(option, key)) {
12860 selected[key] = option;
12861 }
12862 });
12863 this.options = this.sifter.items = selected;
12864 this.lastQuery = null;
12865 this.trigger('option_clear');
12866 }
12867 /**
12868 * Used by clearOptions() to decide whether or not an option should be removed
12869 * Return true to keep an option, false to remove
12870 *
12871 */
12872 clearFilter(option, value) {
12873 if (this.items.indexOf(value) >= 0) {
12874 return true;
12875 }
12876 return false;
12877 }
12878 /**
12879 * Returns the dom element of the option
12880 * matching the given value.
12881 *
12882 */
12883 getOption(value, create = false) {
12884 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12885 if (hashed === null)
12886 return null;
12887 const option = this.options[hashed];
12888 if (option != undefined) {
12889 if (option.$div) {
12890 return option.$div;
12891 }
12892 if (create) {
12893 return this._render('option', option);
12894 }
12895 }
12896 return null;
12897 }
12898 /**
12899 * Returns the dom element of the next or previous dom element of the same type
12900 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12901 *
12902 */
12903 getAdjacent(option, direction, type = 'option') {
12904 var self = this, all;
12905 if (!option) {
12906 return null;
12907 }
12908 if (type == 'item') {
12909 all = self.controlChildren();
12910 }
12911 else {
12912 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12913 }
12914 for (let i = 0; i < all.length; i++) {
12915 if (all[i] != option) {
12916 continue;
12917 }
12918 if (direction > 0) {
12919 return all[i + 1];
12920 }
12921 return all[i - 1];
12922 }
12923 return null;
12924 }
12925 /**
12926 * Returns the dom element of the item
12927 * matching the given value.
12928 *
12929 */
12930 getItem(item) {
12931 if (typeof item == 'object') {
12932 return item;
12933 }
12934 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12935 return value !== null
12936 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12937 : null;
12938 }
12939 /**
12940 * "Selects" multiple items at once. Adds them to the list
12941 * at the current caret position.
12942 *
12943 */
12944 addItems(values, silent) {
12945 var self = this;
12946 var items = Array.isArray(values) ? values : [values];
12947 items = items.filter(x => self.items.indexOf(x) === -1);
12948 const last_item = items[items.length - 1];
12949 items.forEach(item => {
12950 self.isPending = (item !== last_item);
12951 self.addItem(item, silent);
12952 });
12953 }
12954 /**
12955 * "Selects" an item. Adds it to the list
12956 * at the current caret position.
12957 *
12958 */
12959 addItem(value, silent) {
12960 var events = silent ? [] : ['change', 'dropdown_close'];
12961 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12962 var item, wasFull;
12963 const self = this;
12964 const inputMode = self.settings.mode;
12965 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12966 if (hashed && self.items.indexOf(hashed) !== -1) {
12967 if (inputMode === 'single') {
12968 self.close();
12969 }
12970 if (inputMode === 'single' || !self.settings.duplicates) {
12971 return;
12972 }
12973 }
12974 if (hashed === null || !self.options.hasOwnProperty(hashed))
12975 return;
12976 if (inputMode === 'single')
12977 self.clear(silent);
12978 if (inputMode === 'multi' && self.isFull())
12979 return;
12980 item = self._render('item', self.options[hashed]);
12981 if (self.control.contains(item)) { // duplicates
12982 item = item.cloneNode(true);
12983 }
12984 wasFull = self.isFull();
12985 self.items.splice(self.caretPos, 0, hashed);
12986 self.insertAtCaret(item);
12987 if (self.isSetup) {
12988 // update menu / remove the option (if this is not one item being added as part of series)
12989 if (!self.isPending && self.settings.hideSelected) {
12990 let option = self.getOption(hashed);
12991 let next = self.getAdjacent(option, 1);
12992 if (next) {
12993 self.setActiveOption(next);
12994 }
12995 }
12996 // refreshOptions after setActiveOption(),
12997 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12998 if (!self.isPending && !self.settings.closeAfterSelect) {
12999 self.refreshOptions(self.isFocused && inputMode !== 'single');
13000 }
13001 // hide the menu if the maximum number of items have been selected or no options are left
13002 if (self.settings.closeAfterSelect != false && self.isFull()) {
13003 self.close();
13004 }
13005 else if (!self.isPending) {
13006 self.positionDropdown();
13007 }
13008 self.trigger('item_add', hashed, item);
13009 if (!self.isPending) {
13010 self.updateOriginalInput({ silent: silent });
13011 }
13012 }
13013 if (!self.isPending || (!wasFull && self.isFull())) {
13014 self.inputState();
13015 self.refreshState();
13016 }
13017 });
13018 }
13019 /**
13020 * Removes the selected item matching
13021 * the provided value.
13022 *
13023 */
13024 removeItem(item = null, silent) {
13025 const self = this;
13026 item = self.getItem(item);
13027 if (!item)
13028 return;
13029 var i, idx;
13030 const value = item.dataset.value;
13031 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
13032 item.remove();
13033 if (item.classList.contains('active')) {
13034 idx = self.activeItems.indexOf(item);
13035 self.activeItems.splice(idx, 1);
13036 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
13037 }
13038 self.items.splice(i, 1);
13039 self.lastQuery = null;
13040 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
13041 self.removeOption(value, silent);
13042 }
13043 if (i < self.caretPos) {
13044 self.setCaret(self.caretPos - 1);
13045 }
13046 self.updateOriginalInput({ silent: silent });
13047 self.refreshState();
13048 self.positionDropdown();
13049 self.trigger('item_remove', value, item);
13050 }
13051 /**
13052 * Invokes the `create` method provided in the
13053 * TomSelect options that should provide the data
13054 * for the new item, given the user input.
13055 *
13056 * Once this completes, it will be added
13057 * to the item list.
13058 *
13059 */
13060 createItem(input = null, callback = () => { }) {
13061 // triggerDropdown parameter @deprecated 2.1.1
13062 if (arguments.length === 3) {
13063 callback = arguments[2];
13064 }
13065 if (typeof callback != 'function') {
13066 callback = () => { };
13067 }
13068 var self = this;
13069 var caret = self.caretPos;
13070 var output;
13071 input = input || self.inputValue();
13072 if (!self.canCreate(input)) {
13073 callback();
13074 return false;
13075 }
13076 self.lock();
13077 var created = false;
13078 var create = (data) => {
13079 self.unlock();
13080 if (!data || typeof data !== 'object')
13081 return callback();
13082 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
13083 if (typeof value !== 'string') {
13084 return callback();
13085 }
13086 self.setTextboxValue();
13087 self.addOption(data, true);
13088 self.setCaret(caret);
13089 self.addItem(value);
13090 callback(data);
13091 created = true;
13092 };
13093 if (typeof self.settings.create === 'function') {
13094 output = self.settings.create.call(this, input, create);
13095 }
13096 else {
13097 output = {
13098 [self.settings.labelField]: input,
13099 [self.settings.valueField]: input,
13100 };
13101 }
13102 if (!created) {
13103 create(output);
13104 }
13105 return true;
13106 }
13107 /**
13108 * Re-renders the selected item lists.
13109 */
13110 refreshItems() {
13111 var self = this;
13112 self.lastQuery = null;
13113 if (self.isSetup) {
13114 self.addItems(self.items);
13115 }
13116 self.updateOriginalInput();
13117 self.refreshState();
13118 }
13119 /**
13120 * Updates all state-dependent attributes
13121 * and CSS classes.
13122 */
13123 refreshState() {
13124 const self = this;
13125 self.refreshValidityState();
13126 const isFull = self.isFull();
13127 const isLocked = self.isLocked;
13128 self.wrapper.classList.toggle('rtl', self.rtl);
13129 const wrap_classList = self.wrapper.classList;
13130 wrap_classList.toggle('focus', self.isFocused);
13131 wrap_classList.toggle('disabled', self.isDisabled);
13132 wrap_classList.toggle('readonly', self.isReadOnly);
13133 wrap_classList.toggle('required', self.isRequired);
13134 wrap_classList.toggle('invalid', !self.isValid);
13135 wrap_classList.toggle('locked', isLocked);
13136 wrap_classList.toggle('full', isFull);
13137 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
13138 wrap_classList.toggle('dropdown-active', self.isOpen);
13139 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
13140 wrap_classList.toggle('has-items', self.items.length > 0);
13141 }
13142 /**
13143 * Update the `required` attribute of both input and control input.
13144 *
13145 * The `required` property needs to be activated on the control input
13146 * for the error to be displayed at the right place. `required` also
13147 * needs to be temporarily deactivated on the input since the input is
13148 * hidden and can't show errors.
13149 */
13150 refreshValidityState() {
13151 var self = this;
13152 if (!self.input.validity) {
13153 return;
13154 }
13155 self.isValid = self.input.validity.valid;
13156 self.isInvalid = !self.isValid;
13157 }
13158 /**
13159 * Determines whether or not more items can be added
13160 * to the control without exceeding the user-defined maximum.
13161 *
13162 * @returns {boolean}
13163 */
13164 isFull() {
13165 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
13166 }
13167 /**
13168 * Refreshes the original <select> or <input>
13169 * element to reflect the current state.
13170 *
13171 */
13172 updateOriginalInput(opts = {}) {
13173 const self = this;
13174 var option, label;
13175 const empty_option = self.input.querySelector('option[value=""]');
13176 if (self.is_select_tag) {
13177 const selected = [];
13178 const has_selected = self.input.querySelectorAll('option:checked').length;
13179 function AddSelected(option_el, value, label) {
13180 if (!option_el) {
13181 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>');
13182 }
13183 // don't move empty option from top of list
13184 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
13185 if (option_el != empty_option) {
13186 self.input.append(option_el);
13187 }
13188 selected.push(option_el);
13189 // marking empty option as selected can break validation
13190 // fixes https://github.com/orchidjs/tom-select/issues/303
13191 if (option_el != empty_option || has_selected > 0) {
13192 option_el.selected = true;
13193 }
13194 return option_el;
13195 }
13196 // unselect all selected options
13197 self.input.querySelectorAll('option:checked').forEach((option_el) => {
13198 option_el.selected = false;
13199 });
13200 // nothing selected?
13201 if (self.items.length == 0 && self.settings.mode == 'single') {
13202 AddSelected(empty_option, "", "");
13203 // order selected <option> tags for values in self.items
13204 }
13205 else {
13206 self.items.forEach((value) => {
13207 option = self.options[value];
13208 label = option[self.settings.labelField] || '';
13209 if (selected.includes(option.$option)) {
13210 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
13211 AddSelected(reuse_opt, value, label);
13212 }
13213 else {
13214 option.$option = AddSelected(option.$option, value, label);
13215 }
13216 });
13217 }
13218 }
13219 else {
13220 self.input.value = self.getValue();
13221 }
13222 if (self.isSetup) {
13223 if (!opts.silent) {
13224 self.trigger('change', self.getValue());
13225 }
13226 }
13227 }
13228 /**
13229 * Shows the autocomplete dropdown containing
13230 * the available options.
13231 */
13232 open() {
13233 var self = this;
13234 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
13235 return;
13236 self.isOpen = true;
13237 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
13238 self.refreshState();
13239 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
13240 self.positionDropdown();
13241 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
13242 self.focus();
13243 self.trigger('dropdown_open', self.dropdown);
13244 }
13245 /**
13246 * Closes the autocomplete dropdown menu.
13247 */
13248 close(setTextboxValue = true) {
13249 var self = this;
13250 var trigger = self.isOpen;
13251 if (setTextboxValue) {
13252 // before blur() to prevent form onchange event
13253 self.setTextboxValue();
13254 if (self.settings.mode === 'single' && self.items.length) {
13255 self.inputState();
13256 }
13257 }
13258 self.isOpen = false;
13259 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
13260 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
13261 if (self.settings.hideSelected) {
13262 self.clearActiveOption();
13263 }
13264 self.refreshState();
13265 if (trigger)
13266 self.trigger('dropdown_close', self.dropdown);
13267 }
13268 /**
13269 * Calculates and applies the appropriate
13270 * position of the dropdown if dropdownParent = 'body'.
13271 * Otherwise, position is determined by css
13272 */
13273 positionDropdown() {
13274 if (this.settings.dropdownParent !== 'body') {
13275 return;
13276 }
13277 var context = this.control;
13278 var rect = context.getBoundingClientRect();
13279 var top = context.offsetHeight + rect.top + window.scrollY;
13280 var left = rect.left + window.scrollX;
13281 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
13282 width: rect.width + 'px',
13283 top: top + 'px',
13284 left: left + 'px'
13285 });
13286 }
13287 /**
13288 * Resets / clears all selected items
13289 * from the control.
13290 *
13291 */
13292 clear(silent) {
13293 var self = this;
13294 if (!self.items.length)
13295 return;
13296 var items = self.controlChildren();
13297 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
13298 self.removeItem(item, true);
13299 });
13300 self.inputState();
13301 if (!silent)
13302 self.updateOriginalInput();
13303 self.trigger('clear');
13304 }
13305 /**
13306 * A helper method for inserting an element
13307 * at the current caret position.
13308 *
13309 */
13310 insertAtCaret(el) {
13311 const self = this;
13312 const caret = self.caretPos;
13313 const target = self.control;
13314 target.insertBefore(el, target.children[caret] || null);
13315 self.setCaret(caret + 1);
13316 }
13317 /**
13318 * Removes the current selected item(s).
13319 *
13320 */
13321 deleteSelection(e) {
13322 var direction, selection, caret, tail;
13323 var self = this;
13324 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
13325 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
13326 // determine items that will be removed
13327 const rm_items = [];
13328 if (self.activeItems.length) {
13329 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
13330 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
13331 if (direction > 0) {
13332 caret++;
13333 }
13334 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
13335 }
13336 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
13337 const items = self.controlChildren();
13338 let rm_item;
13339 if (direction < 0 && selection.start === 0 && selection.length === 0) {
13340 rm_item = items[self.caretPos - 1];
13341 }
13342 else if (direction > 0 && selection.start === self.inputValue().length) {
13343 rm_item = items[self.caretPos];
13344 }
13345 if (rm_item !== undefined) {
13346 rm_items.push(rm_item);
13347 }
13348 }
13349 if (!self.shouldDelete(rm_items, e)) {
13350 return false;
13351 }
13352 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
13353 // perform removal
13354 if (typeof caret !== 'undefined') {
13355 self.setCaret(caret);
13356 }
13357 while (rm_items.length) {
13358 self.removeItem(rm_items.pop());
13359 }
13360 self.inputState();
13361 self.positionDropdown();
13362 self.refreshOptions(false);
13363 return true;
13364 }
13365 /**
13366 * Return true if the items should be deleted
13367 */
13368 shouldDelete(items, evt) {
13369 const values = items.map(item => item.dataset.value);
13370 // allow the callback to abort
13371 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
13372 return false;
13373 }
13374 return true;
13375 }
13376 /**
13377 * Selects the previous / next item (depending on the `direction` argument).
13378 *
13379 * > 0 - right
13380 * < 0 - left
13381 *
13382 */
13383 advanceSelection(direction, e) {
13384 var last_active, adjacent, self = this;
13385 if (self.rtl)
13386 direction *= -1;
13387 if (self.inputValue().length)
13388 return;
13389 // add or remove to active items
13390 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)) {
13391 last_active = self.getLastActive(direction);
13392 if (last_active) {
13393 if (!last_active.classList.contains('active')) {
13394 adjacent = last_active;
13395 }
13396 else {
13397 adjacent = self.getAdjacent(last_active, direction, 'item');
13398 }
13399 // if no active item, get items adjacent to the control input
13400 }
13401 else if (direction > 0) {
13402 adjacent = self.control_input.nextElementSibling;
13403 }
13404 else {
13405 adjacent = self.control_input.previousElementSibling;
13406 }
13407 if (adjacent) {
13408 if (adjacent.classList.contains('active')) {
13409 self.removeActiveItem(last_active);
13410 }
13411 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
13412 }
13413 // move caret to the left or right
13414 }
13415 else {
13416 self.moveCaret(direction);
13417 }
13418 }
13419 moveCaret(direction) { }
13420 /**
13421 * Get the last active item
13422 *
13423 */
13424 getLastActive(direction) {
13425 let last_active = this.control.querySelector('.last-active');
13426 if (last_active) {
13427 return last_active;
13428 }
13429 var result = this.control.querySelectorAll('.active');
13430 if (result) {
13431 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
13432 }
13433 }
13434 /**
13435 * Moves the caret to the specified index.
13436 *
13437 * The input must be moved by leaving it in place and moving the
13438 * siblings, due to the fact that focus cannot be restored once lost
13439 * on mobile webkit devices
13440 *
13441 */
13442 setCaret(new_pos) {
13443 this.caretPos = this.items.length;
13444 }
13445 /**
13446 * Return list of item dom elements
13447 *
13448 */
13449 controlChildren() {
13450 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
13451 }
13452 /**
13453 * Disables user input on the control. Used while
13454 * items are being asynchronously created.
13455 */
13456 lock() {
13457 this.setLocked(true);
13458 }
13459 /**
13460 * Re-enables user input on the control.
13461 */
13462 unlock() {
13463 this.setLocked(false);
13464 }
13465 /**
13466 * Disable or enable user input on the control
13467 */
13468 setLocked(lock = this.isReadOnly || this.isDisabled) {
13469 this.isLocked = lock;
13470 this.refreshState();
13471 }
13472 /**
13473 * Disables user input on the control completely.
13474 * While disabled, it cannot receive focus.
13475 */
13476 disable() {
13477 this.setDisabled(true);
13478 this.close();
13479 }
13480 /**
13481 * Enables the control so that it can respond
13482 * to focus and user input.
13483 */
13484 enable() {
13485 this.setDisabled(false);
13486 }
13487 setDisabled(disabled) {
13488 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
13489 this.isDisabled = disabled;
13490 this.input.disabled = disabled;
13491 this.control_input.disabled = disabled;
13492 this.setLocked();
13493 }
13494 setReadOnly(isReadOnly) {
13495 this.isReadOnly = isReadOnly;
13496 this.input.readOnly = isReadOnly;
13497 this.control_input.readOnly = isReadOnly;
13498 this.setLocked();
13499 }
13500 /**
13501 * Completely destroys the control and
13502 * unbinds all event listeners so that it can
13503 * be garbage collected.
13504 */
13505 destroy() {
13506 var self = this;
13507 var revertSettings = self.revertSettings;
13508 self.trigger('destroy');
13509 self.off();
13510 self.wrapper.remove();
13511 self.dropdown.remove();
13512 self.input.innerHTML = revertSettings.innerHTML;
13513 self.input.tabIndex = revertSettings.tabIndex;
13514 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
13515 self._destroy();
13516 delete self.input.tomselect;
13517 }
13518 /**
13519 * A helper method for rendering "item" and
13520 * "option" templates, given the data.
13521 *
13522 */
13523 render(templateName, data) {
13524 var id, html;
13525 const self = this;
13526 if (typeof this.settings.render[templateName] !== 'function') {
13527 return null;
13528 }
13529 // render markup
13530 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
13531 if (!html) {
13532 return null;
13533 }
13534 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
13535 // add mandatory attributes
13536 if (templateName === 'option' || templateName === 'option_create') {
13537 if (data[self.settings.disabledField]) {
13538 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
13539 }
13540 else {
13541 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13542 }
13543 }
13544 else if (templateName === 'optgroup') {
13545 id = data.group[self.settings.optgroupValueField];
13546 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13547 if (data.group[self.settings.disabledField]) {
13548 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13549 }
13550 }
13551 if (templateName === 'option' || templateName === 'item') {
13552 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13553 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13554 // make sure we have some classes if a template is overwritten
13555 if (templateName === 'item') {
13556 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13557 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13558 }
13559 else {
13560 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13561 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13562 role: 'option',
13563 id: data.$id
13564 });
13565 // update cache
13566 data.$div = html;
13567 self.options[value] = data;
13568 }
13569 }
13570 return html;
13571 }
13572 /**
13573 * Type guarded rendering
13574 *
13575 */
13576 _render(templateName, data) {
13577 const html = this.render(templateName, data);
13578 if (html == null) {
13579 throw 'HTMLElement expected';
13580 }
13581 return html;
13582 }
13583 /**
13584 * Clears the render cache for a template. If
13585 * no template is given, clears all render
13586 * caches.
13587 *
13588 */
13589 clearCache() {
13590 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13591 if (option.$div) {
13592 option.$div.remove();
13593 delete option.$div;
13594 }
13595 });
13596 }
13597 /**
13598 * Removes a value from item and option caches
13599 *
13600 */
13601 uncacheValue(value) {
13602 const option_el = this.getOption(value);
13603 if (option_el)
13604 option_el.remove();
13605 }
13606 /**
13607 * Determines whether or not to display the
13608 * create item prompt, given a user input.
13609 *
13610 */
13611 canCreate(input) {
13612 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13613 }
13614 /**
13615 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13616 *
13617 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13618 *
13619 * });
13620 */
13621 hook(when, method, new_fn) {
13622 var self = this;
13623 var orig_method = self[method];
13624 self[method] = function () {
13625 var result, result_new;
13626 if (when === 'after') {
13627 result = orig_method.apply(self, arguments);
13628 }
13629 result_new = new_fn.apply(self, arguments);
13630 if (when === 'instead') {
13631 return result_new;
13632 }
13633 if (when === 'before') {
13634 result = orig_method.apply(self, arguments);
13635 }
13636 return result;
13637 };
13638 }
13639 }
13640 ;
13641 //# sourceMappingURL=tom-select.js.map
13642
13643 /***/ },
13644
13645 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13646 /*!***************************************************!*\
13647 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13648 \***************************************************/
13649 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13650
13651 "use strict";
13652 __webpack_require__.r(__webpack_exports__);
13653 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13654 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13655 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13656 /* harmony export */ append: () => (/* binding */ append),
13657 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13658 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13659 /* harmony export */ getId: () => (/* binding */ getId),
13660 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13661 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13662 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13663 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13664 /* harmony export */ iterate: () => (/* binding */ iterate),
13665 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13666 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13667 /* harmony export */ timeout: () => (/* binding */ timeout)
13668 /* harmony export */ });
13669 /**
13670 * Converts a scalar to its best string representation
13671 * for hash keys and HTML attribute values.
13672 *
13673 * Transformations:
13674 * 'str' -> 'str'
13675 * null -> ''
13676 * undefined -> ''
13677 * true -> '1'
13678 * false -> '0'
13679 * 0 -> '0'
13680 * 1 -> '1'
13681 *
13682 */
13683 const hash_key = (value) => {
13684 if (typeof value === 'undefined' || value === null)
13685 return null;
13686 return get_hash(value);
13687 };
13688 const get_hash = (value) => {
13689 if (typeof value === 'boolean')
13690 return value ? '1' : '0';
13691 return value + '';
13692 };
13693 /**
13694 * Escapes a string for use within HTML.
13695 *
13696 */
13697 const escape_html = (str) => {
13698 return (str + '')
13699 .replace(/&/g, '&amp;')
13700 .replace(/</g, '&lt;')
13701 .replace(/>/g, '&gt;')
13702 .replace(/"/g, '&quot;');
13703 };
13704 /**
13705 * use setTimeout if timeout > 0
13706 */
13707 const timeout = (fn, timeout) => {
13708 if (timeout > 0) {
13709 return window.setTimeout(fn, timeout);
13710 }
13711 fn.call(null);
13712 return null;
13713 };
13714 /**
13715 * Debounce the user provided load function
13716 *
13717 */
13718 const loadDebounce = (fn, delay) => {
13719 var timeout;
13720 return function (value, callback) {
13721 var self = this;
13722 if (timeout) {
13723 self.loading = Math.max(self.loading - 1, 0);
13724 clearTimeout(timeout);
13725 }
13726 timeout = setTimeout(function () {
13727 timeout = null;
13728 self.loadedSearches[value] = true;
13729 fn.call(self, value, callback);
13730 }, delay);
13731 };
13732 };
13733 /**
13734 * Debounce all fired events types listed in `types`
13735 * while executing the provided `fn`.
13736 *
13737 */
13738 const debounce_events = (self, types, fn) => {
13739 var type;
13740 var trigger = self.trigger;
13741 var event_args = {};
13742 // override trigger method
13743 self.trigger = function () {
13744 var type = arguments[0];
13745 if (types.indexOf(type) !== -1) {
13746 event_args[type] = arguments;
13747 }
13748 else {
13749 return trigger.apply(self, arguments);
13750 }
13751 };
13752 // invoke provided function
13753 fn.apply(self, []);
13754 self.trigger = trigger;
13755 // trigger queued events
13756 for (type of types) {
13757 if (type in event_args) {
13758 trigger.apply(self, event_args[type]);
13759 }
13760 }
13761 };
13762 /**
13763 * Determines the current selection within a text input control.
13764 * Returns an object containing:
13765 * - start
13766 * - length
13767 *
13768 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13769 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13770 */
13771 const getSelection = (input) => {
13772 return {
13773 start: input.selectionStart || 0,
13774 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13775 };
13776 };
13777 /**
13778 * Prevent default
13779 *
13780 */
13781 const preventDefault = (evt, stop = false) => {
13782 if (evt) {
13783 evt.preventDefault();
13784 if (stop) {
13785 evt.stopPropagation();
13786 }
13787 }
13788 };
13789 /**
13790 * Add event helper
13791 *
13792 */
13793 const addEvent = (target, type, callback, options) => {
13794 target.addEventListener(type, callback, options);
13795 };
13796 /**
13797 * Return true if the requested key is down
13798 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13799 * The current evt may not always set ( eg calling advanceSelection() )
13800 *
13801 */
13802 const isKeyDown = (key_name, evt) => {
13803 if (!evt) {
13804 return false;
13805 }
13806 if (!evt[key_name]) {
13807 return false;
13808 }
13809 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13810 if (count === 1) {
13811 return true;
13812 }
13813 return false;
13814 };
13815 /**
13816 * Get the id of an element
13817 * If the id attribute is not set, set the attribute with the given id
13818 *
13819 */
13820 const getId = (el, id) => {
13821 const existing_id = el.getAttribute('id');
13822 if (existing_id) {
13823 return existing_id;
13824 }
13825 el.setAttribute('id', id);
13826 return id;
13827 };
13828 /**
13829 * Returns a string with backslashes added before characters that need to be escaped.
13830 */
13831 const addSlashes = (str) => {
13832 return str.replace(/[\\"']/g, '\\$&');
13833 };
13834 /**
13835 *
13836 */
13837 const append = (parent, node) => {
13838 if (node)
13839 parent.append(node);
13840 };
13841 /**
13842 * Iterates over arrays and hashes.
13843 *
13844 * ```
13845 * iterate(this.items, function(item, id) {
13846 * // invoked for each item
13847 * });
13848 * ```
13849 *
13850 */
13851 const iterate = (object, callback) => {
13852 if (Array.isArray(object)) {
13853 object.forEach(callback);
13854 }
13855 else {
13856 for (var key in object) {
13857 if (object.hasOwnProperty(key)) {
13858 callback(object[key], key);
13859 }
13860 }
13861 }
13862 };
13863 //# sourceMappingURL=utils.js.map
13864
13865 /***/ },
13866
13867 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13868 /*!*****************************************************!*\
13869 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13870 \*****************************************************/
13871 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13872
13873 "use strict";
13874 __webpack_require__.r(__webpack_exports__);
13875 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13876 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13877 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13878 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13879 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13880 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13881 /* harmony export */ getDom: () => (/* binding */ getDom),
13882 /* harmony export */ getTail: () => (/* binding */ getTail),
13883 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13884 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13885 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13886 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13887 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13888 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13889 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13890 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13891 /* harmony export */ });
13892 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13893
13894 /**
13895 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13896 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13897 *
13898 * param query should be {}
13899 */
13900 const getDom = (query) => {
13901 if (query.jquery) {
13902 return query[0];
13903 }
13904 if (query instanceof HTMLElement) {
13905 return query;
13906 }
13907 if (isHtmlString(query)) {
13908 var tpl = document.createElement('template');
13909 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13910 return tpl.content.firstChild;
13911 }
13912 return document.querySelector(query);
13913 };
13914 const isHtmlString = (arg) => {
13915 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13916 return true;
13917 }
13918 return false;
13919 };
13920 const escapeQuery = (query) => {
13921 return query.replace(/['"\\]/g, '\\$&');
13922 };
13923 /**
13924 * Dispatch an event
13925 *
13926 */
13927 const triggerEvent = (dom_el, event_name) => {
13928 var event = document.createEvent('HTMLEvents');
13929 event.initEvent(event_name, true, false);
13930 dom_el.dispatchEvent(event);
13931 };
13932 /**
13933 * Apply CSS rules to a dom element
13934 *
13935 */
13936 const applyCSS = (dom_el, css) => {
13937 Object.assign(dom_el.style, css);
13938 };
13939 /**
13940 * Add css classes
13941 *
13942 */
13943 const addClasses = (elmts, ...classes) => {
13944 var norm_classes = classesArray(classes);
13945 elmts = castAsArray(elmts);
13946 elmts.map(el => {
13947 norm_classes.map(cls => {
13948 el.classList.add(cls);
13949 });
13950 });
13951 };
13952 /**
13953 * Remove css classes
13954 *
13955 */
13956 const removeClasses = (elmts, ...classes) => {
13957 var norm_classes = classesArray(classes);
13958 elmts = castAsArray(elmts);
13959 elmts.map(el => {
13960 norm_classes.map(cls => {
13961 el.classList.remove(cls);
13962 });
13963 });
13964 };
13965 /**
13966 * Return arguments
13967 *
13968 */
13969 const classesArray = (args) => {
13970 var classes = [];
13971 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13972 if (typeof _classes === 'string') {
13973 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13974 }
13975 if (Array.isArray(_classes)) {
13976 classes = classes.concat(_classes);
13977 }
13978 });
13979 return classes.filter(Boolean);
13980 };
13981 /**
13982 * Create an array from arg if it's not already an array
13983 *
13984 */
13985 const castAsArray = (arg) => {
13986 if (!Array.isArray(arg)) {
13987 arg = [arg];
13988 }
13989 return arg;
13990 };
13991 /**
13992 * Get the closest node to the evt.target matching the selector
13993 * Stops at wrapper
13994 *
13995 */
13996 const parentMatch = (target, selector, wrapper) => {
13997 if (wrapper && !wrapper.contains(target)) {
13998 return;
13999 }
14000 while (target && target.matches) {
14001 if (target.matches(selector)) {
14002 return target;
14003 }
14004 target = target.parentNode;
14005 }
14006 };
14007 /**
14008 * Get the first or last item from an array
14009 *
14010 * > 0 - right (last)
14011 * <= 0 - left (first)
14012 *
14013 */
14014 const getTail = (list, direction = 0) => {
14015 if (direction > 0) {
14016 return list[list.length - 1];
14017 }
14018 return list[0];
14019 };
14020 /**
14021 * Return true if an object is empty
14022 *
14023 */
14024 const isEmptyObject = (obj) => {
14025 return (Object.keys(obj).length === 0);
14026 };
14027 /**
14028 * Get the index of an element amongst sibling nodes of the same type
14029 *
14030 */
14031 const nodeIndex = (el, amongst) => {
14032 if (!el)
14033 return -1;
14034 amongst = amongst || el.nodeName;
14035 var i = 0;
14036 while (el = el.previousElementSibling) {
14037 if (el.matches(amongst)) {
14038 i++;
14039 }
14040 }
14041 return i;
14042 };
14043 /**
14044 * Set attributes of an element
14045 *
14046 */
14047 const setAttr = (el, attrs) => {
14048 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
14049 if (val == null) {
14050 el.removeAttribute(attr);
14051 }
14052 else {
14053 el.setAttribute(attr, '' + val);
14054 }
14055 });
14056 };
14057 /**
14058 * Replace a node
14059 */
14060 const replaceNode = (existing, replacement) => {
14061 if (existing.parentNode)
14062 existing.parentNode.replaceChild(replacement, existing);
14063 };
14064 //# sourceMappingURL=vanilla.js.map
14065
14066 /***/ }
14067
14068 /******/ });
14069 /************************************************************************/
14070 /******/ // The module cache
14071 /******/ var __webpack_module_cache__ = {};
14072 /******/
14073 /******/ // The require function
14074 /******/ function __webpack_require__(moduleId) {
14075 /******/ // Check if module is in cache
14076 /******/ var cachedModule = __webpack_module_cache__[moduleId];
14077 /******/ if (cachedModule !== undefined) {
14078 /******/ return cachedModule.exports;
14079 /******/ }
14080 /******/ // Create a new module (and put it into the cache)
14081 /******/ var module = __webpack_module_cache__[moduleId] = {
14082 /******/ id: moduleId,
14083 /******/ // no module.loaded needed
14084 /******/ exports: {}
14085 /******/ };
14086 /******/
14087 /******/ // Execute the module function
14088 /******/ if (!(moduleId in __webpack_modules__)) {
14089 /******/ delete __webpack_module_cache__[moduleId];
14090 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
14091 /******/ e.code = 'MODULE_NOT_FOUND';
14092 /******/ throw e;
14093 /******/ }
14094 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
14095 /******/
14096 /******/ // Return the exports of the module
14097 /******/ return module.exports;
14098 /******/ }
14099 /******/
14100 /************************************************************************/
14101 /******/ /* webpack/runtime/compat get default export */
14102 /******/ (() => {
14103 /******/ // getDefaultExport function for compatibility with non-harmony modules
14104 /******/ __webpack_require__.n = (module) => {
14105 /******/ var getter = module && module.__esModule ?
14106 /******/ () => (module['default']) :
14107 /******/ () => (module);
14108 /******/ __webpack_require__.d(getter, { a: getter });
14109 /******/ return getter;
14110 /******/ };
14111 /******/ })();
14112 /******/
14113 /******/ /* webpack/runtime/define property getters */
14114 /******/ (() => {
14115 /******/ // define getter functions for harmony exports
14116 /******/ __webpack_require__.d = (exports, definition) => {
14117 /******/ for(var key in definition) {
14118 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
14119 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14120 /******/ }
14121 /******/ }
14122 /******/ };
14123 /******/ })();
14124 /******/
14125 /******/ /* webpack/runtime/hasOwnProperty shorthand */
14126 /******/ (() => {
14127 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
14128 /******/ })();
14129 /******/
14130 /******/ /* webpack/runtime/make namespace object */
14131 /******/ (() => {
14132 /******/ // define __esModule on exports
14133 /******/ __webpack_require__.r = (exports) => {
14134 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
14135 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
14136 /******/ }
14137 /******/ Object.defineProperty(exports, '__esModule', { value: true });
14138 /******/ };
14139 /******/ })();
14140 /******/
14141 /******/ /* webpack/runtime/nonce */
14142 /******/ (() => {
14143 /******/ __webpack_require__.nc = undefined;
14144 /******/ })();
14145 /******/
14146 /************************************************************************/
14147 var __webpack_exports__ = {};
14148 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
14149 (() => {
14150 "use strict";
14151 /*!********************************************!*\
14152 !*** ./assets/src/js/admin/admin-tools.js ***!
14153 \********************************************/
14154 __webpack_require__.r(__webpack_exports__);
14155 /* harmony import */ var _tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools/assign-user-course */ "./assets/src/js/admin/tools/assign-user-course.js");
14156 /* harmony import */ var _tools_handle_sample_data__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools/handle-sample-data */ "./assets/src/js/admin/tools/handle-sample-data.js");
14157 /* harmony import */ var _tools_reset_course_progress__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools/reset-course-progress */ "./assets/src/js/admin/tools/reset-course-progress.js");
14158 /* harmony import */ var _tools_reset_item_progress__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tools/reset-item-progress */ "./assets/src/js/admin/tools/reset-item-progress.js");
14159
14160
14161
14162
14163 (0,_tools_assign_user_course__WEBPACK_IMPORTED_MODULE_0__["default"])();
14164 new _tools_handle_sample_data__WEBPACK_IMPORTED_MODULE_1__["default"]().init();
14165 new _tools_reset_course_progress__WEBPACK_IMPORTED_MODULE_2__["default"]().init();
14166 new _tools_reset_item_progress__WEBPACK_IMPORTED_MODULE_3__["default"]().init();
14167 })();
14168
14169 /******/ })()
14170 ;
14171 //# sourceMappingURL=admin-tools.js.map