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

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

13,708 lines 480.4 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/order/add-courses-to-order.js"
5 /*!***********************************************************!*\
6 !*** ./assets/src/js/admin/order/add-courses-to-order.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": () => (__WEBPACK_DEFAULT_EXPORT__)
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 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
17
18
19 const addCoursesToOrder = () => {
20 let elModalSearchCourses;
21 let elSearchCoursesResult;
22 let elOrderDetails, modalSearchItemsTemplate, modalContainer;
23 let elOrderModalFooter, elOrderModalBtnAdd;
24 let elListOrderItems;
25 let timeOutSearch;
26 const idModalSearchItems = '#modal-search-items';
27 const idOrderDetails = '#learn-press-order';
28 let dataSend = {
29 search: '',
30 id_not_in: '',
31 paged: 1
32 };
33 const courseIdsNewSelected = [];
34 let courseIdsAdded = [];
35 const getAllElements = () => {
36 elOrderDetails = document.querySelector('#learn-press-order');
37 modalSearchItemsTemplate = document.querySelector('#learn-press-modal-search-items');
38 modalContainer = document.querySelector('#container-modal-search-items');
39 };
40
41 /**
42 * Fetch courses from API.
43 *
44 * @param keySearch
45 * @param course_ids_exclude
46 * @param paged
47 */
48 const fetchCoursesAPI = (keySearch = '', course_ids_exclude = [], paged = 1) => {
49 let id_not_in = '';
50 if (course_ids_exclude.length > 0) {
51 id_not_in = course_ids_exclude.join(',');
52 }
53 dataSend = {
54 search: keySearch,
55 id_not_in,
56 paged
57 };
58 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.AdminUtilsFunctions.fetchCourses(keySearch, dataSend, {
59 before() {
60 elModalSearchCourses.classList.add('loading');
61 },
62 success(response) {
63 const {
64 data,
65 status,
66 message
67 } = response;
68 const {
69 courses,
70 total_pages
71 } = data;
72 if ('success' !== status) {
73 console.error(message);
74 } else {
75 if (!courses.length) {
76 elSearchCoursesResult.innerHTML = '<li class="lp-result-item">No courses found</li>';
77 return;
78 }
79 elSearchCoursesResult.innerHTML = renderSearchResult(courses);
80 const paginationHtml = renderPagination(paged, total_pages);
81 const searchNav = elModalSearchCourses.querySelector('.search-nav');
82 searchNav.innerHTML = paginationHtml;
83 }
84 },
85 error(err) {
86 console.error(err);
87 },
88 completed() {
89 elModalSearchCourses.classList.remove('loading');
90 }
91 });
92 };
93
94 /**
95 * Get list course ids added.
96 */
97 const getCoursesAdded = () => {
98 courseIdsAdded = [];
99 const orderItems = document.querySelectorAll('#learn-press-order .list-order-items tbody .order-item-row');
100 orderItems.forEach(orderItem => {
101 const orderItemId = parseInt(orderItem.getAttribute('data-id'));
102 courseIdsAdded.push(orderItemId);
103 });
104 };
105
106 /**
107 * Add courses to order.
108 * @param e
109 * @param target
110 */
111 const addCourses = (e, target) => {
112 if (!target.classList.contains('add')) {
113 return;
114 }
115 if (!target.closest(idModalSearchItems)) {
116 return;
117 }
118 elListOrderItems = elOrderDetails.querySelector('.list-order-items');
119 e.preventDefault();
120 target.disabled = true;
121 const dataSend = {
122 'lp-ajax': 'add_items_to_order',
123 order_id: document.querySelector('#post_ID').value,
124 items: courseIdsNewSelected,
125 nonce: lpDataAdmin.nonce
126 };
127 const callBack = {
128 success(response) {
129 const {
130 data,
131 messages,
132 status
133 } = response;
134 if ('error' === status) {
135 console.error(messages);
136 return;
137 }
138 const {
139 item_html,
140 order_data
141 } = data;
142 const elNoItem = elListOrderItems.querySelector('.no-order-items');
143 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpShowHideEl(elNoItem, 0);
144 elNoItem.insertAdjacentHTML('beforebegin', item_html);
145 elOrderDetails.querySelector('.order-subtotal').innerHTML = order_data.subtotal_html;
146 elOrderDetails.querySelector('.order-total').innerHTML = order_data.total_html;
147 //courseIdsAdded.push( ...courseIdsNewSelected );
148 courseIdsNewSelected.splice(0, courseIdsNewSelected.length);
149 },
150 error(err) {
151 console.error(err);
152 },
153 completed() {
154 target.disabled = false;
155 modalContainer.style.display = 'none';
156 }
157 };
158 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpAddQueryArgs(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpGetCurrentURLNoParam(), dataSend), {}, callBack);
159 };
160
161 /**
162 * Remove course from order.
163 *
164 * @param e
165 * @param target
166 */
167 const removeCourse = (e, target) => {
168 if (target.tagName !== 'SPAN') {
169 return;
170 }
171 if (!target.closest('.remove-order-item')) {
172 return;
173 }
174 e.preventDefault();
175 if (!confirm('Are you sure you want to remove this item?')) {
176 return;
177 }
178 target.disabled = true;
179 target.classList.add('dashicons-update');
180 const elItemRow = target.closest('.order-item-row');
181 const elListOrderItems = target.closest('.list-order-items');
182 const orderItemId = parseInt(elItemRow.getAttribute('data-item_id'));
183 const courseId = parseInt(elItemRow.getAttribute('data-id'));
184 const dataSend = {
185 'lp-ajax': 'remove_items_from_order',
186 order_id: document.querySelector('#post_ID').value,
187 items: orderItemId,
188 nonce: lpDataAdmin.nonce
189 };
190 const callBack = {
191 success(response) {
192 const {
193 data,
194 messages,
195 status
196 } = response;
197 if ('error' === status) {
198 console.error(messages);
199 return;
200 }
201 const {
202 item_html,
203 order_data
204 } = data;
205 const elNoItem = elListOrderItems.querySelector('.no-order-items');
206 const orderItems = elListOrderItems.querySelectorAll('.order-item-row');
207 orderItems.forEach(orderItem => {
208 orderItem.remove();
209 });
210 if (item_html.length) {
211 elNoItem.insertAdjacentHTML('beforebegin', item_html);
212 } else {
213 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpShowHideEl(elNoItem, 1);
214 }
215 courseIdsNewSelected.splice(courseIdsNewSelected.indexOf(courseId), 1);
216 //courseIdsAdded.splice( courseIdsNewSelected.indexOf( courseId ), 1 );
217 elOrderDetails.querySelector('.order-subtotal').innerHTML = order_data.subtotal_html;
218 elOrderDetails.querySelector('.order-total').innerHTML = order_data.total_html;
219 },
220 error(err) {
221 console.error(err);
222 },
223 completed() {}
224 };
225 _utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpFetchAPI(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpAddQueryArgs(_utils_admin_js__WEBPACK_IMPORTED_MODULE_0__.Utils.lpGetCurrentURLNoParam(), dataSend), {}, callBack);
226 };
227
228 /**
229 * Search courses before add Order.
230 *
231 * @param e
232 * @param target
233 */
234 const searchCourse = (e, target) => {
235 if ('search' !== target.name) {
236 return;
237 }
238 const elLPTarget = target.closest(idModalSearchItems);
239 if (!elLPTarget) {
240 return;
241 }
242 e.preventDefault();
243 const keyword = target.value;
244 if (!keyword || keyword && keyword.length > 2) {
245 if (undefined !== timeOutSearch) {
246 clearTimeout(timeOutSearch);
247 }
248 timeOutSearch = setTimeout(function () {
249 fetchCoursesAPI(keyword, courseIdsAdded, 1);
250 }, 800);
251 }
252 };
253
254 /**
255 * Display list courses when search done.
256 *
257 * @param courses
258 */
259 const renderSearchResult = courses => {
260 let html = '';
261 courses.forEach(course => {
262 const courseId = parseInt(course.ID);
263 const checked = courseIdsNewSelected.includes(courseId) ? 'checked' : '';
264 html += `
265 <li class="lp-result-item" data-id="${courseId}" data-type="lp_course" data-text="${course.post_title}">
266 <label>
267 <input type="checkbox" value="${courseId}" name="selectedItems[]" ${checked}>
268 <span class="lp-item-text">${course.post_title} (#${courseId})</span>
269 </label>
270 </li>`;
271 });
272 return html;
273 };
274
275 /**
276 * Render pagination.
277 *
278 * @param currentPage
279 * @param maxPage
280 */
281 const renderPagination = (currentPage, maxPage) => {
282 currentPage = parseInt(currentPage);
283 maxPage = parseInt(maxPage);
284 let html = '';
285 if (maxPage <= 1) {
286 return html;
287 }
288 const nextPage = currentPage + 1;
289 const prevPage = currentPage - 1;
290 let pages = [];
291 if (maxPage <= 9) {
292 for (let i = 1; i <= maxPage; i++) {
293 pages.push(i);
294 }
295 } else if (currentPage <= 3) {
296 // x is ...
297 pages = [1, 2, 3, 4, 5, 'x', maxPage];
298 } else if (currentPage <= 5) {
299 for (let i = 1; i <= currentPage; i++) {
300 pages.push(i);
301 }
302 for (let j = 1; j <= 2; j++) {
303 const tempPage = currentPage + j;
304 pages.push(tempPage);
305 }
306 pages.push('x');
307 pages.push(maxPage);
308 } else {
309 pages = [1, 'x'];
310 for (let k = 2; k >= 0; k--) {
311 const tempPage = currentPage - k;
312 pages.push(tempPage);
313 }
314 const currentToLast = maxPage - currentPage;
315 if (currentToLast <= 5) {
316 for (let m = currentPage + 1; m <= maxPage; m++) {
317 pages.push(m);
318 }
319 } else {
320 for (let n = 1; n <= 2; n++) {
321 const tempPage = currentPage + n;
322 pages.push(tempPage);
323 }
324 pages.push('x');
325 pages.push(maxPage);
326 }
327 }
328 const maximum = pages.length;
329 if (currentPage !== 1) {
330 html += `<a class="prev page-numbers button" href="#" data-page="${prevPage}"><</a>`;
331 }
332 for (let i = 0; i < maximum; i++) {
333 if (currentPage === parseInt(pages[i])) {
334 html += `<a aria-current="page" class="page-numbers current button disabled" data-page="${pages[i]}">
335 ${pages[i]}
336 </a>`;
337 } else if (pages[i] === 'x') {
338 html += `<span class="page-numbers dots button disabled">...</span>`;
339 } else {
340 html += `<a class="page-numbers button" href="#" data-page="${pages[i]}">${pages[i]} </a>`;
341 }
342 }
343 if (currentPage !== maxPage) {
344 html += `<a class="next page-numbers button" href="#" data-page="${nextPage}">></a>`;
345 }
346 return html;
347 };
348 const showPopupSearchCourses = () => {
349 getCoursesAdded();
350 modalContainer.style.display = 'block';
351 elOrderModalBtnAdd.style.display = 'none';
352 elSearchCoursesResult.innerHTML = '';
353 fetchCoursesAPI(dataSend.search, courseIdsAdded, dataSend.paged);
354 };
355
356 // Events.
357 document.addEventListener('click', e => {
358 const target = e.target;
359 //console.dir( target );
360 if (target.id === 'learn-press-add-order-item') {
361 e.preventDefault();
362 showPopupSearchCourses();
363 }
364 if (target.classList.contains('close') && target.closest(idModalSearchItems)) {
365 e.preventDefault();
366 elModalSearchCourses.querySelector('input[name="search"]').value = '';
367 dataSend.search = '';
368 dataSend.paged = 1;
369 modalContainer.style.display = 'none';
370 }
371 if (target.classList.contains('page-numbers')) {
372 if (target.closest(idModalSearchItems)) {
373 e.preventDefault();
374 const paged = target.getAttribute('data-page');
375 fetchCoursesAPI(dataSend.search, dataSend.id_not_in, paged);
376 }
377 }
378 if (target.name === 'selectedItems[]') {
379 if (target.closest(idModalSearchItems)) {
380 const courseId = parseInt(target.value);
381 if (target.checked) {
382 courseIdsNewSelected.push(courseId);
383 } else {
384 const index = courseIdsNewSelected.indexOf(courseId);
385 if (index > -1) {
386 courseIdsNewSelected.splice(index, 1);
387 }
388 }
389 elOrderModalBtnAdd.style.display = courseIdsNewSelected.length > 0 ? 'block' : 'none';
390 }
391 }
392 addCourses(e, target);
393 removeCourse(e, target);
394 });
395 document.addEventListener('keyup', function (e) {
396 const target = e.target;
397 searchCourse(e, target);
398 });
399 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpOnElementReady('.lp-order-detail-items', el => {
400 getAllElements();
401 if (!elOrderDetails) {
402 return;
403 }
404 modalContainer.innerHTML = modalSearchItemsTemplate.innerHTML;
405 elModalSearchCourses = modalContainer.querySelector(idModalSearchItems);
406 elSearchCoursesResult = elModalSearchCourses.querySelector('.search-results');
407 elOrderModalFooter = elModalSearchCourses.querySelector('footer');
408 elOrderModalBtnAdd = elOrderModalFooter.querySelector('.add');
409 modalContainer.style.display = 'none';
410 });
411 };
412 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (addCoursesToOrder);
413
414 /***/ },
415
416 /***/ "./assets/src/js/admin/order/export_invoice.js"
417 /*!*****************************************************!*\
418 !*** ./assets/src/js/admin/order/export_invoice.js ***!
419 \*****************************************************/
420 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
421
422 "use strict";
423 __webpack_require__.r(__webpack_exports__);
424 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
425 /* harmony export */ "default": () => (/* binding */ export_invoice)
426 /* harmony export */ });
427 /**
428 * Export invoice to PDF
429 */
430 function export_invoice() {
431 let html2pdf_obj, modal;
432 document.addEventListener('click', e => {
433 const target = e.target;
434 if (target.id === 'lp-invoice__export') {
435 html2pdf_obj.save();
436 } else if (target.id === 'lp-invoice__update') {
437 const elOption = document.querySelector('.export-options__content');
438 const fields = elOption.querySelectorAll('input');
439 const fieldNameUnChecked = [];
440 fields.forEach(field => {
441 if (!field.checked) {
442 fieldNameUnChecked.push(field.name);
443 }
444 });
445 window.localStorage.setItem('lp_invoice_un_fields', JSON.stringify(fieldNameUnChecked));
446 window.localStorage.setItem('lp_invoice_show', 1);
447 window.location.reload();
448 }
449 });
450 const exportPDF = () => {
451 const pdfOptions = {
452 margin: [0, 0, 0, 5],
453 filename: document.title,
454 image: {
455 type: 'webp'
456 },
457 html2canvas: {
458 scale: 2.5
459 },
460 jsPDF: {
461 format: 'a4',
462 orientation: 'p'
463 }
464 };
465 const html = document.querySelector('#lp-invoice__content');
466 html2pdf_obj = html2pdf().set(pdfOptions).from(html);
467 };
468 const showInfoFields = () => {
469 // Get fields name checked
470 const fieldsChecked = window.localStorage.getItem('lp_invoice_un_fields');
471 const elOptions = document.querySelector('.export-options__content');
472 const elInvoiceFields = document.querySelectorAll('.invoice-field');
473 elInvoiceFields.forEach(field => {
474 const nameClass = field.classList[1];
475 if (fieldsChecked && fieldsChecked.includes(nameClass)) {
476 field.remove();
477 const elOption = elOptions.querySelector(`[name=${nameClass}]`);
478 if (elOption) {
479 elOption.checked = false;
480 }
481 }
482 });
483 const showInvoice = parseInt(window.localStorage.getItem('lp_invoice_show'));
484 if (showInvoice === 1) {
485 modal.style.display = 'block';
486 }
487 };
488 document.addEventListener('DOMContentLoaded', () => {
489 const elExportSection = document.querySelector('#order-export__section');
490 if (!elExportSection.length) {
491 const tabs = document.querySelectorAll('.tabs');
492 const tab = document.querySelectorAll('.tab');
493 const panel = document.querySelectorAll('.panel');
494 function onTabClick(event) {
495 // deactivate existing active tabs and panel
496
497 for (let i = 0; i < tab.length; i++) {
498 tab[i].classList.remove('active');
499 }
500 for (let i = 0; i < panel.length; i++) {
501 panel[i].classList.remove('active');
502 }
503
504 // activate new tabs and panel
505 event.target.classList.add('active');
506 const classString = event.target.getAttribute('data-target');
507 document.getElementById('panels').getElementsByClassName(classString)[0].classList.add('active');
508 }
509 for (let i = 0; i < tab.length; i++) {
510 tab[i].addEventListener('click', onTabClick, false);
511 }
512
513 // Get the modal
514 modal = document.getElementById('myModal');
515 // Get the button that opens the modal
516 const btn = document.getElementById('order-export__button');
517 // Get the <span> element that closes the modal
518 const span = document.getElementsByClassName('close')[0];
519 // When the user clicks on the button, open the modal
520 btn.onclick = function () {
521 modal.style.display = 'block';
522 };
523
524 // When the user clicks on <span> (x), close the modal
525 span.onclick = function () {
526 modal.style.display = 'none';
527 window.localStorage.setItem('lp_invoice_show', 0);
528 };
529
530 // When the user clicks anywhere outside the modal, close it
531 window.onclick = function (event) {
532 if (event.target === modal) {
533 modal.style.display = 'none';
534 window.localStorage.setItem('lp_invoice_show', 0);
535 }
536 };
537 showInfoFields();
538 exportPDF();
539 }
540 });
541 }
542
543 /***/ },
544
545 /***/ "./assets/src/js/admin/order/refund-order.js"
546 /*!***************************************************!*\
547 !*** ./assets/src/js/admin/order/refund-order.js ***!
548 \***************************************************/
549 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
550
551 "use strict";
552 __webpack_require__.r(__webpack_exports__);
553 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
554 /* harmony export */ RefundOrder: () => (/* binding */ RefundOrder),
555 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
556 /* harmony export */ });
557 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
558 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_0__);
559 /* harmony import */ var lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/lpToastify */ "./assets/src/js/lpToastify.js");
560 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
561
562
563
564
565 /**
566 * Handle admin approve/deny refund actions.
567 *
568 * @since 4.3.9
569 * @version 1.0.0
570 */
571 class RefundOrder {
572 constructor() {
573 this.isRequesting = false;
574 this.isReloading = false;
575 }
576 static selectors = {
577 panel: '.order-data-refund-request',
578 action: '.lp-admin-refund-order-action'
579 };
580 init() {
581 this.events();
582 }
583 events() {
584 if (RefundOrder._loadedEvents) {
585 return;
586 }
587 RefundOrder._loadedEvents = this;
588 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.eventHandlers('click', [{
589 selector: RefundOrder.selectors.action,
590 class: this,
591 callBack: this.handleAction.name
592 }]);
593 }
594 getPanelData(panel) {
595 const orderTotal = parseFloat(panel.dataset.orderTotal || '0');
596 return {
597 orderId: parseInt(panel.dataset.orderId || '0', 10),
598 orderTotal: Number.isNaN(orderTotal) ? 0 : orderTotal,
599 orderTotalFormatted: panel.dataset.orderTotalFormatted || '',
600 confirmTitle: panel.dataset.confirmTitle || 'Approve refund?',
601 confirmText: panel.dataset.confirmText || '',
602 messageLabel: panel.dataset.messageLabel || 'Message to payer',
603 messagePlaceholder: panel.dataset.messagePlaceholder || '',
604 amountLabel: panel.dataset.amountLabel || 'Refund amount',
605 amountInvalid: panel.dataset.amountInvalid || 'Invalid refund amount.',
606 confirmButton: panel.dataset.confirmButton || 'Approve Refund',
607 cancelButton: panel.dataset.cancelButton || 'Cancel'
608 };
609 }
610 setLoadingState(panel, isLoading) {
611 panel.querySelectorAll(RefundOrder.selectors.action).forEach(button => {
612 button.disabled = isLoading;
613 });
614 }
615 openApproveModal(data) {
616 const content = document.createElement('div');
617 const messageLabel = document.createElement('label');
618 const message = document.createElement('textarea');
619 const amountLabel = document.createElement('label');
620 const amount = document.createElement('input');
621 content.className = 'lp-admin-refund-modal__form';
622 if (data.confirmText) {
623 const confirmText = document.createElement('p');
624 confirmText.className = 'lp-admin-refund-modal__description';
625 confirmText.textContent = data.confirmText;
626 content.append(confirmText);
627 }
628 messageLabel.textContent = data.messageLabel;
629 messageLabel.htmlFor = 'lp-admin-refund-message';
630 messageLabel.className = 'swal2-input-label';
631 message.id = 'lp-admin-refund-message';
632 message.className = 'swal2-textarea';
633 message.placeholder = data.messagePlaceholder;
634 amountLabel.textContent = `${data.amountLabel} (${data.orderTotalFormatted})`;
635 amountLabel.htmlFor = 'lp-admin-refund-amount';
636 amountLabel.className = 'swal2-input-label';
637 amount.id = 'lp-admin-refund-amount';
638 amount.className = 'swal2-input';
639 amount.type = 'number';
640 amount.min = '0.01';
641 amount.max = data.orderTotal.toString();
642 amount.step = '0.01';
643 amount.value = data.orderTotal.toFixed(2);
644 content.append(messageLabel, message, amountLabel, amount);
645 return sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().fire({
646 icon: 'warning',
647 title: data.confirmTitle,
648 html: content,
649 showCancelButton: true,
650 confirmButtonText: data.confirmButton,
651 cancelButtonText: data.cancelButton,
652 focusConfirm: false,
653 customClass: {
654 popup: 'lp-admin-refund-modal',
655 htmlContainer: 'lp-admin-refund-modal__content',
656 actions: 'lp-admin-refund-modal__actions'
657 },
658 preConfirm: () => {
659 const refundAmount = parseFloat(amount.value);
660 if (Number.isNaN(refundAmount) || refundAmount <= 0 || refundAmount > data.orderTotal) {
661 sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().showValidationMessage(data.amountInvalid);
662 return false;
663 }
664 return {
665 note: message.value.trim(),
666 refundAmount
667 };
668 }
669 });
670 }
671 sendAction(actionButton, panel, refundAction, refundAmount = 0, note = '') {
672 const data = this.getPanelData(panel);
673 if (!data.orderId) {
674 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show('Invalid order.', 'error');
675 return;
676 }
677 this.isRequesting = true;
678 this.setLoadingState(panel, true);
679 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(actionButton, 1);
680 window.lpAJAXG.fetchAJAX({
681 action: 'admin_handle_request_refund',
682 order_id: data.orderId,
683 refund_action: refundAction,
684 refund_amount: refundAmount,
685 note
686 }, {
687 success: response => {
688 const {
689 status,
690 message,
691 data
692 } = response;
693 if (status !== 'success') {
694 throw new Error(message);
695 }
696 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(message, 'success');
697 this.isReloading = true;
698 window.setTimeout(() => window.location.reload(), 1200);
699 },
700 error: error => {
701 const messageResponse = error?.message || error || 'Refund action failed.';
702 lpAssetsJsPath_lpToastify__WEBPACK_IMPORTED_MODULE_1__.show(messageResponse, 'error');
703 },
704 completed: () => {
705 if (this.isReloading) {
706 return;
707 }
708 this.isRequesting = false;
709 this.setLoadingState(panel, false);
710 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(actionButton, 0);
711 }
712 });
713 }
714 async handleAction(args) {
715 const {
716 e,
717 target
718 } = args;
719 e.preventDefault();
720 const actionButton = target.closest(RefundOrder.selectors.action);
721 const panel = actionButton?.closest(RefundOrder.selectors.panel);
722 if (!actionButton || !panel || this.isRequesting) {
723 return;
724 }
725 const refundAction = actionButton.dataset.refundAction || '';
726 let amount = '';
727 let note = '';
728 if ('reject' === refundAction) {
729 return this.sendAction(actionButton, panel, refundAction);
730 }
731 const result = await this.openApproveModal(this.getPanelData(panel));
732 if (result.isConfirmed && result.value) {
733 amount = result.value.refundAmount;
734 note = result.value.note;
735 this.sendAction(actionButton, panel, refundAction, amount, note);
736 }
737 }
738 }
739 const refundOrder = () => {
740 const refundOrderHandle = new RefundOrder();
741 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_2__.lpOnElementReady(RefundOrder.selectors.action, () => {
742 refundOrderHandle.init();
743 });
744 };
745 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (refundOrder);
746
747 /***/ },
748
749 /***/ "./assets/src/js/admin/utils-admin.js"
750 /*!********************************************!*\
751 !*** ./assets/src/js/admin/utils-admin.js ***!
752 \********************************************/
753 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
754
755 "use strict";
756 __webpack_require__.r(__webpack_exports__);
757 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
758 /* harmony export */ AdminUtilsFunctions: () => (/* binding */ AdminUtilsFunctions),
759 /* harmony export */ Api: () => (/* reexport safe */ _api_js__WEBPACK_IMPORTED_MODULE_2__["default"]),
760 /* harmony export */ Utils: () => (/* reexport module object */ _utils_js__WEBPACK_IMPORTED_MODULE_0__)
761 /* harmony export */ });
762 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils.js */ "./assets/src/js/utils.js");
763 /* harmony import */ var tom_select__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tom-select */ "./node_modules/tom-select/dist/esm/tom-select.complete.js");
764 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../api.js */ "./assets/src/js/api.js");
765 /**
766 * Library run on Admin
767 *
768 * @since 4.2.6.9
769 * @version 1.0.1
770 */
771
772
773
774 const AdminUtilsFunctions = {
775 buildTomSelect(elTomSelect, options, fetchAPI, dataSend, callBackHandleData) {
776 if (!elTomSelect) {
777 return;
778 }
779 const optionDefault = {
780 plugins: {
781 remove_button: {
782 title: 'Remove this item'
783 },
784 dropdown_input: {}
785 },
786 onInitialize() {},
787 onItemAdd(e) {
788 // Get list without current item.
789 if (fetchAPI) {
790 const selectedOptions = Array.from(elTomSelect.selectedOptions);
791 const selectedValues = selectedOptions.map(option => option.value);
792 selectedValues.push(e);
793 dataSend.id_not_in = selectedValues.join(',');
794 fetchAPI('', dataSend, callBackHandleData);
795 }
796 }
797 };
798 if (fetchAPI) {
799 optionDefault.load = (keySearch, callbackTom) => {
800 const selectedOptions = Array.from(elTomSelect.selectedOptions);
801 const selectedValues = selectedOptions.map(option => option.value);
802 dataSend.id_not_in = selectedValues.join(',');
803 fetchAPI(keySearch, dataSend, AdminUtilsFunctions.callBackTomSelectSearchAPI(callbackTom, callBackHandleData));
804 };
805 }
806 options = {
807 ...optionDefault,
808 ...options
809 };
810 const items_selected = options.options;
811 /*if ( options?.options?.length > 20 ) {
812 const chunkSize = 20;
813 const length = options.options.length;
814 let i = 0;
815 const chunkedOptions = { ...options };
816 chunkedOptions.options = items_selected.slice( i, chunkSize );
817 const tomSelect = new TomSelect( elTomSelect, chunkedOptions );
818 i += chunkSize;
819 const interval = setInterval( () => {
820 if ( i > ( length - 1 ) ) {
821 clearInterval( interval );
822 }
823 const optionsSlice = items_selected.slice( i, i + chunkSize );
824 i += chunkSize;
825 tomSelect.addOptions( optionsSlice );
826 tomSelect.setValue( options.items );
827 }, 200 );
828 return tomSelect;
829 }*/
830
831 return new tom_select__WEBPACK_IMPORTED_MODULE_1__["default"](elTomSelect, options);
832 },
833 callBackTomSelectSearchAPI(callbackTom, callBackHandleData) {
834 return {
835 success: response => {
836 const options = callBackHandleData.success(response);
837 callbackTom(options);
838 }
839 };
840 },
841 fetchCourses(keySearch = '', dataSend = {}, callback) {
842 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchCourses;
843 dataSend.search = keySearch;
844 const params = {
845 headers: {
846 'Content-Type': 'application/json',
847 'X-WP-Nonce': lpDataAdmin.nonce
848 },
849 method: 'POST',
850 body: JSON.stringify(dataSend)
851 };
852 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
853 },
854 fetchUsers(keySearch = '', dataSend = {}, callback) {
855 const url = _api_js__WEBPACK_IMPORTED_MODULE_2__["default"].admin.apiSearchUsers;
856 dataSend.search = keySearch;
857 const params = {
858 headers: {
859 'Content-Type': 'application/json',
860 'X-WP-Nonce': lpDataAdmin.nonce
861 },
862 method: 'POST',
863 body: JSON.stringify(dataSend)
864 };
865 _utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI(url, params, callback);
866 }
867 };
868
869
870 /***/ },
871
872 /***/ "./assets/src/js/api.js"
873 /*!******************************!*\
874 !*** ./assets/src/js/api.js ***!
875 \******************************/
876 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
877
878 "use strict";
879 __webpack_require__.r(__webpack_exports__);
880 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
881 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
882 /* harmony export */ });
883 /**
884 * List API on backend
885 *
886 * @since 4.2.6
887 * @version 1.0.2
888 */
889
890 const lplistAPI = {};
891 let lp_rest_url;
892 if ('undefined' !== typeof lpDataAdmin) {
893 lp_rest_url = lpDataAdmin.lp_rest_url;
894 lplistAPI.admin = {
895 apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
896 apiAddons: lp_rest_url + 'lp/v1/addon/all',
897 apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
898 apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
899 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
900 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
901 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
902 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
903 };
904 }
905 if ('undefined' !== typeof lpData) {
906 lp_rest_url = lpData.lp_rest_url;
907 lplistAPI.frontend = {
908 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
909 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
910 // Deprecated API, don't load from v4.3.7
911 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
912 // Deprecated since 4.3.0
913 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
914 };
915 }
916 if (lp_rest_url) {
917 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
918 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
919 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
920 }
921 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
922
923 /***/ },
924
925 /***/ "./assets/src/js/lpToastify.js"
926 /*!*************************************!*\
927 !*** ./assets/src/js/lpToastify.js ***!
928 \*************************************/
929 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
930
931 "use strict";
932 __webpack_require__.r(__webpack_exports__);
933 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
934 /* harmony export */ show: () => (/* binding */ show)
935 /* harmony export */ });
936 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
937 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
938 /* 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");
939 /**
940 * Utils functions
941 *
942 * @param url
943 * @param data
944 * @param functions
945 * @since 4.3.0
946 * @version 1.0.0
947 */
948
949
950 const argsToastify = {
951 text: '',
952 gravity: lpData.toast.gravity,
953 // `top` or `bottom`
954 position: lpData.toast.position,
955 // `left`, `center` or `right`
956 className: `${lpData.toast.classPrefix}`,
957 close: lpData.toast.close == 1,
958 stopOnFocus: lpData.toast.stopOnFocus == 1,
959 duration: lpData.toast.duration
960 };
961 const show = (message, status = 'success', argsCustom) => {
962 let args = argsToastify;
963 if (argsCustom) {
964 args = {
965 ...args,
966 ...argsCustom
967 };
968 }
969 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
970 ...args,
971 text: message,
972 className: `${lpData.toast.classPrefix} ${status}`
973 });
974 toastify.showToast();
975 };
976
977 /***/ },
978
979 /***/ "./assets/src/js/utils.js"
980 /*!********************************!*\
981 !*** ./assets/src/js/utils.js ***!
982 \********************************/
983 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
984
985 "use strict";
986 __webpack_require__.r(__webpack_exports__);
987 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
988 /* harmony export */ debounce: () => (/* binding */ debounce),
989 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
990 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
991 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
992 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
993 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
994 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
995 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
996 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
997 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
998 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
999 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
1000 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1001 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1002 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1003 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1004 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
1005 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
1006 /* harmony export */ });
1007 /**
1008 * Utils functions
1009 *
1010 * @param url
1011 * @param data
1012 * @param functions
1013 * @since 4.2.5.1
1014 * @version 1.0.7
1015 */
1016 const lpClassName = {
1017 hidden: 'lp-hidden',
1018 loading: 'loading',
1019 elCollapse: 'lp-collapse',
1020 elSectionToggle: '.lp-section-toggle',
1021 elTriggerToggle: '.lp-trigger-toggle',
1022 elBtnFullScreen: '.lp-btn-full-screen-view',
1023 elFullScreen: 'lp-full-screen-view',
1024 elBtnFullScreenClose: 'lp-full-screen-view__close'
1025 };
1026 const lpFetchAPI = (url, data = {}, functions = {}) => {
1027 if ('function' === typeof functions.before) {
1028 functions.before();
1029 }
1030 fetch(url, {
1031 method: 'GET',
1032 ...data
1033 }).then(response => response.json()).then(response => {
1034 if ('function' === typeof functions.success) {
1035 functions.success(response);
1036 }
1037 }).catch(err => {
1038 if ('function' === typeof functions.error) {
1039 functions.error(err);
1040 }
1041 }).finally(() => {
1042 if ('function' === typeof functions.completed) {
1043 functions.completed();
1044 }
1045 });
1046 };
1047
1048 /**
1049 * Get current URL without params.
1050 *
1051 * @since 4.2.5.1
1052 */
1053 const lpGetCurrentURLNoParam = () => {
1054 let currentUrl = window.location.href;
1055 const hasParams = currentUrl.includes('?');
1056 if (hasParams) {
1057 currentUrl = currentUrl.split('?')[0];
1058 }
1059 return currentUrl;
1060 };
1061 const lpAddQueryArgs = (endpoint, args) => {
1062 const url = new URL(endpoint);
1063 Object.keys(args).forEach(arg => {
1064 url.searchParams.set(arg, args[arg]);
1065 });
1066 return url;
1067 };
1068
1069 /**
1070 * Listen element viewed.
1071 *
1072 * @param el
1073 * @param callback
1074 * @since 4.2.5.8
1075 */
1076 const listenElementViewed = (el, callback) => {
1077 const observerSeeItem = new IntersectionObserver(function (entries) {
1078 for (const entry of entries) {
1079 if (entry.isIntersecting) {
1080 callback(entry);
1081 }
1082 }
1083 });
1084 observerSeeItem.observe(el);
1085 };
1086
1087 /**
1088 * Listen element created.
1089 *
1090 * @param callback
1091 * @since 4.2.5.8
1092 */
1093 const listenElementCreated = callback => {
1094 const observerCreateItem = new MutationObserver(function (mutations) {
1095 mutations.forEach(function (mutation) {
1096 if (mutation.addedNodes) {
1097 mutation.addedNodes.forEach(function (node) {
1098 if (node.nodeType === 1) {
1099 callback(node);
1100 }
1101 });
1102 }
1103 });
1104 });
1105 observerCreateItem.observe(document, {
1106 childList: true,
1107 subtree: true
1108 });
1109 // End.
1110 };
1111
1112 /**
1113 * Listen element created.
1114 *
1115 * @param selector
1116 * @param callback
1117 * @since 4.2.7.1
1118 */
1119 const lpOnElementReady = (selector, callback) => {
1120 const element = document.querySelector(selector);
1121 if (element) {
1122 callback(element);
1123 return;
1124 }
1125 const observer = new MutationObserver((mutations, obs) => {
1126 const element = document.querySelector(selector);
1127 if (element) {
1128 obs.disconnect();
1129 callback(element);
1130 }
1131 });
1132 observer.observe(document.documentElement, {
1133 childList: true,
1134 subtree: true
1135 });
1136 };
1137
1138 // Parse JSON from string with content include LP_AJAX_START.
1139 const lpAjaxParseJsonOld = data => {
1140 if (typeof data !== 'string') {
1141 return data;
1142 }
1143 const m = String.raw({
1144 raw: data
1145 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1146 try {
1147 if (m) {
1148 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1149 } else {
1150 data = JSON.parse(data);
1151 }
1152 } catch (e) {
1153 data = {};
1154 }
1155 return data;
1156 };
1157
1158 // status 0: hide, 1: show
1159 const lpShowHideEl = (el, status = 0) => {
1160 if (!el) {
1161 return;
1162 }
1163 if (!status) {
1164 el.classList.add(lpClassName.hidden);
1165 } else {
1166 el.classList.remove(lpClassName.hidden);
1167 }
1168 };
1169
1170 // status 0: hide, 1: show
1171 const lpSetLoadingEl = (el, status) => {
1172 if (!el) {
1173 return;
1174 }
1175 if (!status) {
1176 el.classList.remove(lpClassName.loading);
1177 } else {
1178 el.classList.add(lpClassName.loading);
1179 }
1180 };
1181
1182 // Toggle collapse section
1183 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1184 if (!elTriggerClassName) {
1185 elTriggerClassName = lpClassName.elTriggerToggle;
1186 }
1187
1188 // Exclude elements, which should not trigger the collapse toggle
1189 if (elsExclude && elsExclude.length > 0) {
1190 for (const elExclude of elsExclude) {
1191 if (target.closest(elExclude)) {
1192 return;
1193 }
1194 }
1195 }
1196 const elTrigger = target.closest(elTriggerClassName);
1197 if (!elTrigger) {
1198 return;
1199 }
1200
1201 //console.log( 'elTrigger', elTrigger );
1202
1203 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1204 if (!elSectionToggle) {
1205 return;
1206 }
1207 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1208 if ('function' === typeof callback) {
1209 callback(elSectionToggle);
1210 }
1211 };
1212
1213 // Get data of form
1214 const getDataOfForm = form => {
1215 const dataSend = {};
1216 const formData = new FormData(form);
1217 for (const pair of formData.entries()) {
1218 const key = pair[0];
1219 const value = formData.getAll(key);
1220 if (!dataSend.hasOwnProperty(key)) {
1221 // Convert value array to string.
1222 dataSend[key] = value.join(',');
1223 }
1224 }
1225 return dataSend;
1226 };
1227
1228 // Get field keys of form
1229 const getFieldKeysOfForm = form => {
1230 const keys = [];
1231 const elements = form.elements;
1232 for (let i = 0; i < elements.length; i++) {
1233 const name = elements[i].name;
1234 if (name && !keys.includes(name)) {
1235 keys.push(name);
1236 }
1237 }
1238 return keys;
1239 };
1240
1241 // Merge data handle with data form.
1242 const mergeDataWithDatForm = (elForm, dataHandle) => {
1243 const dataForm = getDataOfForm(elForm);
1244 const keys = getFieldKeysOfForm(elForm);
1245 keys.forEach(key => {
1246 if (!dataForm.hasOwnProperty(key)) {
1247 delete dataHandle[key];
1248 } else if (dataForm[key][0] === '') {
1249 delete dataForm[key];
1250 delete dataHandle[key];
1251 }
1252 });
1253 dataHandle = {
1254 ...dataHandle,
1255 ...dataForm
1256 };
1257 return dataHandle;
1258 };
1259
1260 /**
1261 * Event trigger
1262 * For each list of event handlers, listen event on document.
1263 *
1264 * eventName: 'click', 'change', ...
1265 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1266 *
1267 * @param eventName
1268 * @param eventHandlers
1269 */
1270 const eventHandlers = (eventName, eventHandlers) => {
1271 document.addEventListener(eventName, e => {
1272 const target = e.target;
1273 let args = {
1274 e,
1275 target
1276 };
1277 eventHandlers.forEach(eventHandler => {
1278 args = {
1279 ...args,
1280 ...eventHandler
1281 };
1282
1283 //console.log( args );
1284
1285 // Check condition before call back
1286 if (eventHandler.conditionBeforeCallBack) {
1287 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1288 return;
1289 }
1290 }
1291
1292 // Special check for keydown event with checkIsEventEnter = true
1293 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1294 if (e.key !== 'Enter') {
1295 return;
1296 }
1297 }
1298 if (target.closest(eventHandler.selector)) {
1299 if (eventHandler.class) {
1300 // Call method of class, function callBack will understand exactly {this} is class object.
1301 eventHandler.class[eventHandler.callBack](args);
1302 } else {
1303 // For send args is objected, {this} is eventHandler object, not class object.
1304 eventHandler.callBack(args);
1305 }
1306 }
1307 });
1308 });
1309 };
1310
1311 /**
1312 * Debounce - delays function execution until after `wait` ms of inactivity.
1313 *
1314 * Each call resets the timer. Only the last call in a burst executes.
1315 *
1316 * USE CASES:
1317 * - Search inputs, form validation, window resize
1318 * - Multiple elements need independent timers
1319 * - When you need to call with different arguments
1320 *
1321 * EXAMPLES:
1322 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1323 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1324 *
1325 * const debouncedResize = debounce( recalculateLayout, 250 );
1326 * window.addEventListener('resize', debouncedResize);
1327 *
1328 * ⚠️ Create ONCE outside event handlers, not inside.
1329 *
1330 * @param {Function} func - Function to debounce (can be anonymous)
1331 * @param {number} wait - Milliseconds to wait (default: 500)
1332 * @return {Function} Debounced wrapper function
1333 * @since 4.3.7
1334 * @version 1.0.0
1335 */
1336 const debounce = (func, wait = 500) => {
1337 let timer;
1338 return args => {
1339 clearTimeout(timer);
1340 timer = setTimeout(() => func(args), wait);
1341 };
1342 };
1343
1344 /**
1345 * Initialize lp-toggle-enable components.
1346 *
1347 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1348 * Reads initial state from `data-enabled` attribute ("true"/"false").
1349 * Calls `data-on-toggle` callback (if provided via options) on state change.
1350 *
1351 * HTML structure:
1352 * <label class="lp-toggle-enable" data-enabled="true">
1353 * <input type="checkbox" class="lp-toggle-enable__input" />
1354 * <span class="lp-toggle-enable__track"></span>
1355 * </label>
1356 *
1357 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1358 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1359 * @since 4.4.5
1360 * @version 1.0.0
1361 */
1362 window.lpToggleEnableInit = 0;
1363 const toggleEnable = (onToggle = null) => {
1364 if (window.lpToggleEnableInit) {
1365 return;
1366 }
1367 window.lpToggleEnableInit = 1;
1368 const selector = '.lp-toggle-enable';
1369 const updateUI = (toggle, isEnabled) => {
1370 toggle.classList.toggle('is-enabled', isEnabled);
1371 const input = toggle.querySelector('.lp-toggle-enable__input');
1372 if (input) {
1373 input.checked = isEnabled;
1374 input.value = isEnabled ? '1' : '0';
1375 }
1376 };
1377
1378 // Delegate click handling via eventHandlers.
1379 eventHandlers('click', [{
1380 selector,
1381 callBack: args => {
1382 const {
1383 e,
1384 target
1385 } = args;
1386 const toggle = target.closest(selector);
1387 if (!toggle || toggle.classList.contains('is-disabled')) {
1388 return;
1389 }
1390 e.preventDefault();
1391 const isEnabled = !toggle.classList.contains('is-enabled');
1392 updateUI(toggle, isEnabled);
1393 if ('function' === typeof onToggle) {
1394 onToggle(toggle, isEnabled);
1395 }
1396 }
1397 }]);
1398 };
1399
1400 /**
1401 * Initialize custom fullscreen view buttons.
1402 *
1403 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1404 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1405 * target element. Falls back to the button's parent element when
1406 * `data-target` is not provided.
1407 *
1408 * @since 4.4.5
1409 * @version 1.0.0
1410 */
1411 window.lpFullScreenViewInit = 0;
1412 const fullScreenView = () => {
1413 if (window.lpFullScreenViewInit) {
1414 return;
1415 }
1416 window.lpFullScreenViewInit = 1;
1417 let lastScrollY = 0;
1418 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1419 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1420 if (isFullscreen) {
1421 elTarget.classList.remove(lpClassName.elFullScreen);
1422 document.documentElement.classList.remove('lp-full-screen-active');
1423 window.scrollTo(0, lastScrollY);
1424 } else {
1425 lastScrollY = window.scrollY;
1426 elTarget.classList.add(lpClassName.elFullScreen);
1427 document.documentElement.classList.add('lp-full-screen-active');
1428 }
1429 if (!isFullscreen) {
1430 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1431 const closeButton = document.createElement('button');
1432 closeButton.type = 'button';
1433 closeButton.className = lpClassName.elBtnFullScreenClose;
1434 closeButton.setAttribute('aria-label', 'Close');
1435 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1436 closeButton.addEventListener('click', e => {
1437 e.preventDefault();
1438 lpToggleFullscreenView(elTarget);
1439 });
1440 elTarget.appendChild(closeButton);
1441 }
1442 } else {
1443 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1444 if (closeButton) {
1445 closeButton.remove();
1446 }
1447 }
1448 };
1449 eventHandlers('click', [{
1450 selector: lpClassName.elBtnFullScreen,
1451 callBack: args => {
1452 const {
1453 e,
1454 target
1455 } = args;
1456 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1457 if (!elBtnFullScreen) {
1458 console.log('No full screen button found');
1459 return;
1460 }
1461 e.preventDefault();
1462 let elTarget = null;
1463 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
1464 console.log(targetSelector);
1465 if (targetSelector) {
1466 elTarget = document.querySelector(targetSelector);
1467 }
1468 if (!elTarget) {
1469 console.log('No target element found');
1470 return;
1471 }
1472 lpToggleFullscreenView(elTarget, elBtnFullScreen);
1473 }
1474 }]);
1475 };
1476
1477 /***/ },
1478
1479 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1480 /*!*****************************************************************************************!*\
1481 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1482 \*****************************************************************************************/
1483 (module, __webpack_exports__, __webpack_require__) {
1484
1485 "use strict";
1486 __webpack_require__.r(__webpack_exports__);
1487 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1488 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1489 /* harmony export */ });
1490 /* 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");
1491 /* 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__);
1492 /* 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");
1493 /* 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__);
1494 // Imports
1495
1496
1497 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()));
1498 // Module
1499 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1500 * Toastify js 1.12.0
1501 * https://github.com/apvarun/toastify-js
1502 * @license MIT licensed
1503 *
1504 * Copyright (C) 2018 Varun A P
1505 */
1506
1507 .toastify {
1508 padding: 12px 20px;
1509 color: #ffffff;
1510 display: inline-block;
1511 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1512 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1513 background: linear-gradient(135deg, #73a5ff, #5477f5);
1514 position: fixed;
1515 opacity: 0;
1516 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1517 border-radius: 2px;
1518 cursor: pointer;
1519 text-decoration: none;
1520 max-width: calc(50% - 20px);
1521 z-index: 2147483647;
1522 }
1523
1524 .toastify.on {
1525 opacity: 1;
1526 }
1527
1528 .toast-close {
1529 background: transparent;
1530 border: 0;
1531 color: white;
1532 cursor: pointer;
1533 font-family: inherit;
1534 font-size: 1em;
1535 opacity: 0.4;
1536 padding: 0 5px;
1537 }
1538
1539 .toastify-right {
1540 right: 15px;
1541 }
1542
1543 .toastify-left {
1544 left: 15px;
1545 }
1546
1547 .toastify-top {
1548 top: -150px;
1549 }
1550
1551 .toastify-bottom {
1552 bottom: -150px;
1553 }
1554
1555 .toastify-rounded {
1556 border-radius: 25px;
1557 }
1558
1559 .toastify-avatar {
1560 width: 1.5em;
1561 height: 1.5em;
1562 margin: -7px 5px;
1563 border-radius: 2px;
1564 }
1565
1566 .toastify-center {
1567 margin-left: auto;
1568 margin-right: auto;
1569 left: 0;
1570 right: 0;
1571 max-width: fit-content;
1572 max-width: -moz-fit-content;
1573 }
1574
1575 @media only screen and (max-width: 360px) {
1576 .toastify-right, .toastify-left {
1577 margin-left: auto;
1578 margin-right: auto;
1579 left: 0;
1580 right: 0;
1581 max-width: fit-content;
1582 }
1583 }
1584 `, "",{"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":""}]);
1585 // Exports
1586 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1587
1588
1589 /***/ },
1590
1591 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1592 /*!*****************************************************!*\
1593 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1594 \*****************************************************/
1595 (module) {
1596
1597 "use strict";
1598
1599
1600 /*
1601 MIT License http://www.opensource.org/licenses/mit-license.php
1602 Author Tobias Koppers @sokra
1603 */
1604 module.exports = function (cssWithMappingToString) {
1605 var list = [];
1606
1607 // return the list of modules as css string
1608 list.toString = function toString() {
1609 return this.map(function (item) {
1610 var content = "";
1611 var needLayer = typeof item[5] !== "undefined";
1612 if (item[4]) {
1613 content += "@supports (".concat(item[4], ") {");
1614 }
1615 if (item[2]) {
1616 content += "@media ".concat(item[2], " {");
1617 }
1618 if (needLayer) {
1619 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1620 }
1621 content += cssWithMappingToString(item);
1622 if (needLayer) {
1623 content += "}";
1624 }
1625 if (item[2]) {
1626 content += "}";
1627 }
1628 if (item[4]) {
1629 content += "}";
1630 }
1631 return content;
1632 }).join("");
1633 };
1634
1635 // import a list of modules into the list
1636 list.i = function i(modules, media, dedupe, supports, layer) {
1637 if (typeof modules === "string") {
1638 modules = [[null, modules, undefined]];
1639 }
1640 var alreadyImportedModules = {};
1641 if (dedupe) {
1642 for (var k = 0; k < this.length; k++) {
1643 var id = this[k][0];
1644 if (id != null) {
1645 alreadyImportedModules[id] = true;
1646 }
1647 }
1648 }
1649 for (var _k = 0; _k < modules.length; _k++) {
1650 var item = [].concat(modules[_k]);
1651 if (dedupe && alreadyImportedModules[item[0]]) {
1652 continue;
1653 }
1654 if (typeof layer !== "undefined") {
1655 if (typeof item[5] === "undefined") {
1656 item[5] = layer;
1657 } else {
1658 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1659 item[5] = layer;
1660 }
1661 }
1662 if (media) {
1663 if (!item[2]) {
1664 item[2] = media;
1665 } else {
1666 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1667 item[2] = media;
1668 }
1669 }
1670 if (supports) {
1671 if (!item[4]) {
1672 item[4] = "".concat(supports);
1673 } else {
1674 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1675 item[4] = supports;
1676 }
1677 }
1678 list.push(item);
1679 }
1680 };
1681 return list;
1682 };
1683
1684 /***/ },
1685
1686 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1687 /*!************************************************************!*\
1688 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1689 \************************************************************/
1690 (module) {
1691
1692 "use strict";
1693
1694
1695 module.exports = function (item) {
1696 var content = item[1];
1697 var cssMapping = item[3];
1698 if (!cssMapping) {
1699 return content;
1700 }
1701 if (typeof btoa === "function") {
1702 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1703 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1704 var sourceMapping = "/*# ".concat(data, " */");
1705 return [content].concat([sourceMapping]).join("\n");
1706 }
1707 return [content].join("\n");
1708 };
1709
1710 /***/ },
1711
1712 /***/ "./node_modules/toastify-js/src/toastify.css"
1713 /*!***************************************************!*\
1714 !*** ./node_modules/toastify-js/src/toastify.css ***!
1715 \***************************************************/
1716 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1717
1718 "use strict";
1719 __webpack_require__.r(__webpack_exports__);
1720 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1721 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1722 /* harmony export */ });
1723 /* 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");
1724 /* 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__);
1725 /* 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");
1726 /* 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__);
1727 /* 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");
1728 /* 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__);
1729 /* 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");
1730 /* 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__);
1731 /* 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");
1732 /* 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__);
1733 /* 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");
1734 /* 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__);
1735 /* 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");
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747 var options = {};
1748
1749 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1750 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1751
1752 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1753
1754 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1755 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1756
1757 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);
1758
1759
1760
1761
1762 /* 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);
1763
1764
1765 /***/ },
1766
1767 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1768 /*!****************************************************************************!*\
1769 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1770 \****************************************************************************/
1771 (module) {
1772
1773 "use strict";
1774
1775
1776 var stylesInDOM = [];
1777 function getIndexByIdentifier(identifier) {
1778 var result = -1;
1779 for (var i = 0; i < stylesInDOM.length; i++) {
1780 if (stylesInDOM[i].identifier === identifier) {
1781 result = i;
1782 break;
1783 }
1784 }
1785 return result;
1786 }
1787 function modulesToDom(list, options) {
1788 var idCountMap = {};
1789 var identifiers = [];
1790 for (var i = 0; i < list.length; i++) {
1791 var item = list[i];
1792 var id = options.base ? item[0] + options.base : item[0];
1793 var count = idCountMap[id] || 0;
1794 var identifier = "".concat(id, " ").concat(count);
1795 idCountMap[id] = count + 1;
1796 var indexByIdentifier = getIndexByIdentifier(identifier);
1797 var obj = {
1798 css: item[1],
1799 media: item[2],
1800 sourceMap: item[3],
1801 supports: item[4],
1802 layer: item[5]
1803 };
1804 if (indexByIdentifier !== -1) {
1805 stylesInDOM[indexByIdentifier].references++;
1806 stylesInDOM[indexByIdentifier].updater(obj);
1807 } else {
1808 var updater = addElementStyle(obj, options);
1809 options.byIndex = i;
1810 stylesInDOM.splice(i, 0, {
1811 identifier: identifier,
1812 updater: updater,
1813 references: 1
1814 });
1815 }
1816 identifiers.push(identifier);
1817 }
1818 return identifiers;
1819 }
1820 function addElementStyle(obj, options) {
1821 var api = options.domAPI(options);
1822 api.update(obj);
1823 var updater = function updater(newObj) {
1824 if (newObj) {
1825 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1826 return;
1827 }
1828 api.update(obj = newObj);
1829 } else {
1830 api.remove();
1831 }
1832 };
1833 return updater;
1834 }
1835 module.exports = function (list, options) {
1836 options = options || {};
1837 list = list || [];
1838 var lastIdentifiers = modulesToDom(list, options);
1839 return function update(newList) {
1840 newList = newList || [];
1841 for (var i = 0; i < lastIdentifiers.length; i++) {
1842 var identifier = lastIdentifiers[i];
1843 var index = getIndexByIdentifier(identifier);
1844 stylesInDOM[index].references--;
1845 }
1846 var newLastIdentifiers = modulesToDom(newList, options);
1847 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1848 var _identifier = lastIdentifiers[_i];
1849 var _index = getIndexByIdentifier(_identifier);
1850 if (stylesInDOM[_index].references === 0) {
1851 stylesInDOM[_index].updater();
1852 stylesInDOM.splice(_index, 1);
1853 }
1854 }
1855 lastIdentifiers = newLastIdentifiers;
1856 };
1857 };
1858
1859 /***/ },
1860
1861 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1862 /*!********************************************************************!*\
1863 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1864 \********************************************************************/
1865 (module) {
1866
1867 "use strict";
1868
1869
1870 var memo = {};
1871
1872 /* istanbul ignore next */
1873 function getTarget(target) {
1874 if (typeof memo[target] === "undefined") {
1875 var styleTarget = document.querySelector(target);
1876
1877 // Special case to return head of iframe instead of iframe itself
1878 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1879 try {
1880 // This will throw an exception if access to iframe is blocked
1881 // due to cross-origin restrictions
1882 styleTarget = styleTarget.contentDocument.head;
1883 } catch (e) {
1884 // istanbul ignore next
1885 styleTarget = null;
1886 }
1887 }
1888 memo[target] = styleTarget;
1889 }
1890 return memo[target];
1891 }
1892
1893 /* istanbul ignore next */
1894 function insertBySelector(insert, style) {
1895 var target = getTarget(insert);
1896 if (!target) {
1897 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1898 }
1899 target.appendChild(style);
1900 }
1901 module.exports = insertBySelector;
1902
1903 /***/ },
1904
1905 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1906 /*!**********************************************************************!*\
1907 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1908 \**********************************************************************/
1909 (module) {
1910
1911 "use strict";
1912
1913
1914 /* istanbul ignore next */
1915 function insertStyleElement(options) {
1916 var element = document.createElement("style");
1917 options.setAttributes(element, options.attributes);
1918 options.insert(element, options.options);
1919 return element;
1920 }
1921 module.exports = insertStyleElement;
1922
1923 /***/ },
1924
1925 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1926 /*!**********************************************************************************!*\
1927 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1928 \**********************************************************************************/
1929 (module, __unused_webpack_exports, __webpack_require__) {
1930
1931 "use strict";
1932
1933
1934 /* istanbul ignore next */
1935 function setAttributesWithoutAttributes(styleElement) {
1936 var nonce = true ? __webpack_require__.nc : 0;
1937 if (nonce) {
1938 styleElement.setAttribute("nonce", nonce);
1939 }
1940 }
1941 module.exports = setAttributesWithoutAttributes;
1942
1943 /***/ },
1944
1945 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1946 /*!***************************************************************!*\
1947 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1948 \***************************************************************/
1949 (module) {
1950
1951 "use strict";
1952
1953
1954 /* istanbul ignore next */
1955 function apply(styleElement, options, obj) {
1956 var css = "";
1957 if (obj.supports) {
1958 css += "@supports (".concat(obj.supports, ") {");
1959 }
1960 if (obj.media) {
1961 css += "@media ".concat(obj.media, " {");
1962 }
1963 var needLayer = typeof obj.layer !== "undefined";
1964 if (needLayer) {
1965 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1966 }
1967 css += obj.css;
1968 if (needLayer) {
1969 css += "}";
1970 }
1971 if (obj.media) {
1972 css += "}";
1973 }
1974 if (obj.supports) {
1975 css += "}";
1976 }
1977 var sourceMap = obj.sourceMap;
1978 if (sourceMap && typeof btoa !== "undefined") {
1979 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1980 }
1981
1982 // For old IE
1983 /* istanbul ignore if */
1984 options.styleTagTransform(css, styleElement, options.options);
1985 }
1986 function removeStyleElement(styleElement) {
1987 // istanbul ignore if
1988 if (styleElement.parentNode === null) {
1989 return false;
1990 }
1991 styleElement.parentNode.removeChild(styleElement);
1992 }
1993
1994 /* istanbul ignore next */
1995 function domAPI(options) {
1996 if (typeof document === "undefined") {
1997 return {
1998 update: function update() {},
1999 remove: function remove() {}
2000 };
2001 }
2002 var styleElement = options.insertStyleElement(options);
2003 return {
2004 update: function update(obj) {
2005 apply(styleElement, options, obj);
2006 },
2007 remove: function remove() {
2008 removeStyleElement(styleElement);
2009 }
2010 };
2011 }
2012 module.exports = domAPI;
2013
2014 /***/ },
2015
2016 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
2017 /*!*********************************************************************!*\
2018 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
2019 \*********************************************************************/
2020 (module) {
2021
2022 "use strict";
2023
2024
2025 /* istanbul ignore next */
2026 function styleTagTransform(css, styleElement) {
2027 if (styleElement.styleSheet) {
2028 styleElement.styleSheet.cssText = css;
2029 } else {
2030 while (styleElement.firstChild) {
2031 styleElement.removeChild(styleElement.firstChild);
2032 }
2033 styleElement.appendChild(document.createTextNode(css));
2034 }
2035 }
2036 module.exports = styleTagTransform;
2037
2038 /***/ },
2039
2040 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
2041 /*!**********************************************************!*\
2042 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
2043 \**********************************************************/
2044 (module) {
2045
2046 /*!
2047 * sweetalert2 v11.26.25
2048 * Released under the MIT License.
2049 */
2050 (function (global, factory) {
2051 true ? module.exports = factory() :
2052 0;
2053 })(this, (function () { 'use strict';
2054
2055 function _assertClassBrand(e, t, n) {
2056 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2057 throw new TypeError("Private element is not present on this object");
2058 }
2059 function _checkPrivateRedeclaration(e, t) {
2060 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2061 }
2062 function _classPrivateFieldGet2(s, a) {
2063 return s.get(_assertClassBrand(s, a));
2064 }
2065 function _classPrivateFieldInitSpec(e, t, a) {
2066 _checkPrivateRedeclaration(e, t), t.set(e, a);
2067 }
2068 function _classPrivateFieldSet2(s, a, r) {
2069 return s.set(_assertClassBrand(s, a), r), r;
2070 }
2071
2072 const RESTORE_FOCUS_TIMEOUT = 100;
2073
2074 /** @type {GlobalState} */
2075 const globalState = {};
2076 const focusPreviousActiveElement = () => {
2077 if (globalState.previousActiveElement instanceof HTMLElement) {
2078 globalState.previousActiveElement.focus();
2079 globalState.previousActiveElement = null;
2080 } else if (document.body) {
2081 document.body.focus();
2082 }
2083 };
2084
2085 /**
2086 * Restore previous active (focused) element
2087 *
2088 * @param {boolean} returnFocus
2089 * @returns {Promise<void>}
2090 */
2091 const restoreActiveElement = returnFocus => {
2092 return new Promise(resolve => {
2093 if (!returnFocus) {
2094 return resolve();
2095 }
2096 const x = window.scrollX;
2097 const y = window.scrollY;
2098 globalState.restoreFocusTimeout = setTimeout(() => {
2099 focusPreviousActiveElement();
2100 resolve();
2101 }, RESTORE_FOCUS_TIMEOUT); // issues/900
2102
2103 window.scrollTo(x, y);
2104 });
2105 };
2106
2107 const swalPrefix = 'swal2-';
2108
2109 /**
2110 * @typedef {Record<SwalClass, string>} SwalClasses
2111 */
2112
2113 /**
2114 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
2115 * @typedef {Record<SwalIcon, string>} SwalIcons
2116 */
2117
2118 /** @type {SwalClass[]} */
2119 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'];
2120 const swalClasses = classNames.reduce((acc, className) => {
2121 acc[className] = swalPrefix + className;
2122 return acc;
2123 }, /** @type {SwalClasses} */{});
2124
2125 /** @type {SwalIcon[]} */
2126 const icons = ['success', 'warning', 'info', 'question', 'error'];
2127 const iconTypes = icons.reduce((acc, icon) => {
2128 acc[icon] = swalPrefix + icon;
2129 return acc;
2130 }, /** @type {SwalIcons} */{});
2131
2132 const consolePrefix = 'SweetAlert2:';
2133
2134 /**
2135 * Capitalize the first letter of a string
2136 *
2137 * @param {string} str
2138 * @returns {string}
2139 */
2140 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2141
2142 /**
2143 * Standardize console warnings
2144 *
2145 * @param {string | string[]} message
2146 */
2147 const warn = message => {
2148 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2149 };
2150
2151 /**
2152 * Standardize console errors
2153 *
2154 * @param {string} message
2155 */
2156 const error = message => {
2157 console.error(`${consolePrefix} ${message}`);
2158 };
2159
2160 /**
2161 * Private global state for `warnOnce`
2162 *
2163 * @type {string[]}
2164 * @private
2165 */
2166 const previousWarnOnceMessages = [];
2167
2168 /**
2169 * Show a console warning, but only if it hasn't already been shown
2170 *
2171 * @param {string} message
2172 */
2173 const warnOnce = message => {
2174 if (!previousWarnOnceMessages.includes(message)) {
2175 previousWarnOnceMessages.push(message);
2176 warn(message);
2177 }
2178 };
2179
2180 /**
2181 * Show a one-time console warning about deprecated params/methods
2182 *
2183 * @param {string} deprecatedParam
2184 * @param {string?} useInstead
2185 */
2186 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2187 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2188 };
2189
2190 /**
2191 * If `arg` is a function, call it (with no arguments or context) and return the result.
2192 * Otherwise, just pass the value through
2193 *
2194 * @param {(() => *) | *} arg
2195 * @returns {*}
2196 */
2197 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2198
2199 /**
2200 * @param {*} arg
2201 * @returns {boolean}
2202 */
2203 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2204
2205 /**
2206 * @param {*} arg
2207 * @returns {Promise<*>}
2208 */
2209 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2210
2211 /**
2212 * @param {*} arg
2213 * @returns {boolean}
2214 */
2215 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2216
2217 /**
2218 * @returns {boolean}
2219 */
2220 const isFirefox = () => navigator.userAgent.includes('Firefox');
2221
2222 /**
2223 * Gets the popup container which contains the backdrop and the popup itself.
2224 *
2225 * @returns {HTMLElement | null}
2226 */
2227 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2228
2229 /**
2230 * @param {string} selectorString
2231 * @returns {HTMLElement | null}
2232 */
2233 const elementBySelector = selectorString => {
2234 const container = getContainer();
2235 return container ? container.querySelector(selectorString) : null;
2236 };
2237
2238 /**
2239 * @param {string} className
2240 * @returns {HTMLElement | null}
2241 */
2242 const elementByClass = className => {
2243 return elementBySelector(`.${className}`);
2244 };
2245
2246 /**
2247 * @returns {HTMLElement | null}
2248 */
2249 const getPopup = () => elementByClass(swalClasses.popup);
2250
2251 /**
2252 * @returns {HTMLElement | null}
2253 */
2254 const getIcon = () => elementByClass(swalClasses.icon);
2255
2256 /**
2257 * @returns {HTMLElement | null}
2258 */
2259 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2260
2261 /**
2262 * @returns {HTMLElement | null}
2263 */
2264 const getTitle = () => elementByClass(swalClasses.title);
2265
2266 /**
2267 * @returns {HTMLElement | null}
2268 */
2269 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2270
2271 /**
2272 * @returns {HTMLElement | null}
2273 */
2274 const getImage = () => elementByClass(swalClasses.image);
2275
2276 /**
2277 * @returns {HTMLElement | null}
2278 */
2279 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2280
2281 /**
2282 * @returns {HTMLElement | null}
2283 */
2284 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2285
2286 /**
2287 * @returns {HTMLButtonElement | null}
2288 */
2289 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2290
2291 /**
2292 * @returns {HTMLButtonElement | null}
2293 */
2294 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2295
2296 /**
2297 * @returns {HTMLButtonElement | null}
2298 */
2299 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2300
2301 /**
2302 * @returns {HTMLElement | null}
2303 */
2304 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2305
2306 /**
2307 * @returns {HTMLElement | null}
2308 */
2309 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2310
2311 /**
2312 * @returns {HTMLElement | null}
2313 */
2314 const getActions = () => elementByClass(swalClasses.actions);
2315
2316 /**
2317 * @returns {HTMLElement | null}
2318 */
2319 const getFooter = () => elementByClass(swalClasses.footer);
2320
2321 /**
2322 * @returns {HTMLElement | null}
2323 */
2324 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2325
2326 /**
2327 * @returns {HTMLElement | null}
2328 */
2329 const getCloseButton = () => elementByClass(swalClasses.close);
2330
2331 // https://github.com/jkup/focusable/blob/master/index.js
2332 const focusable = `
2333 a[href],
2334 area[href],
2335 input:not([disabled]),
2336 select:not([disabled]),
2337 textarea:not([disabled]),
2338 button:not([disabled]),
2339 iframe,
2340 object,
2341 embed,
2342 [tabindex="0"],
2343 [contenteditable],
2344 audio[controls],
2345 video[controls],
2346 summary
2347 `;
2348 /**
2349 * @returns {HTMLElement[]}
2350 */
2351 const getFocusableElements = () => {
2352 const popup = getPopup();
2353 if (!popup) {
2354 return [];
2355 }
2356 /** @type {NodeListOf<HTMLElement>} */
2357 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2358 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2359 // sort according to tabindex
2360 .sort((a, b) => {
2361 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2362 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2363 if (tabindexA > tabindexB) {
2364 return 1;
2365 } else if (tabindexA < tabindexB) {
2366 return -1;
2367 }
2368 return 0;
2369 });
2370
2371 /** @type {NodeListOf<HTMLElement>} */
2372 const otherFocusableElements = popup.querySelectorAll(focusable);
2373 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2374 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2375 };
2376
2377 /**
2378 * @returns {boolean}
2379 */
2380 const isModal = () => {
2381 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2382 };
2383
2384 /**
2385 * @returns {boolean}
2386 */
2387 const isToast = () => {
2388 const popup = getPopup();
2389 if (!popup) {
2390 return false;
2391 }
2392 return hasClass(popup, swalClasses.toast);
2393 };
2394
2395 /**
2396 * @returns {boolean}
2397 */
2398 const isLoading = () => {
2399 const popup = getPopup();
2400 if (!popup) {
2401 return false;
2402 }
2403 return popup.hasAttribute('data-loading');
2404 };
2405
2406 /**
2407 * Securely set innerHTML of an element
2408 * https://github.com/sweetalert2/sweetalert2/issues/1926
2409 *
2410 * @param {HTMLElement} elem
2411 * @param {string} html
2412 */
2413 const setInnerHtml = (elem, html) => {
2414 elem.textContent = '';
2415 if (html) {
2416 const parser = new DOMParser();
2417 const parsed = parser.parseFromString(html, `text/html`);
2418 const head = parsed.querySelector('head');
2419 if (head) {
2420 Array.from(head.childNodes).forEach(child => {
2421 elem.appendChild(child);
2422 });
2423 }
2424 const body = parsed.querySelector('body');
2425 if (body) {
2426 Array.from(body.childNodes).forEach(child => {
2427 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2428 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2429 } else {
2430 elem.appendChild(child);
2431 }
2432 });
2433 }
2434 }
2435 };
2436
2437 /**
2438 * @param {HTMLElement} elem
2439 * @param {string} className
2440 * @returns {boolean}
2441 */
2442 const hasClass = (elem, className) => {
2443 if (!className) {
2444 return false;
2445 }
2446 return className.split(/\s+/).every(cls => elem.classList.contains(cls));
2447 };
2448
2449 /**
2450 * @param {HTMLElement} elem
2451 * @param {SweetAlertOptions} params
2452 */
2453 const removeCustomClasses = (elem, params) => {
2454 Array.from(elem.classList).forEach(className => {
2455 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2456 elem.classList.remove(className);
2457 }
2458 });
2459 };
2460
2461 /**
2462 * @param {HTMLElement} elem
2463 * @param {SweetAlertOptions} params
2464 * @param {string} className
2465 */
2466 const applyCustomClass = (elem, params, className) => {
2467 removeCustomClasses(elem, params);
2468 if (!params.customClass) {
2469 return;
2470 }
2471 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2472 if (!customClass) {
2473 return;
2474 }
2475 if (typeof customClass !== 'string' && !customClass.forEach) {
2476 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2477 return;
2478 }
2479 addClass(elem, customClass);
2480 };
2481
2482 /**
2483 * @param {HTMLElement} popup
2484 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2485 * @returns {HTMLInputElement | null}
2486 */
2487 const getInput$1 = (popup, inputClass) => {
2488 if (!inputClass) {
2489 return null;
2490 }
2491 switch (inputClass) {
2492 case 'select':
2493 case 'textarea':
2494 case 'file':
2495 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2496 case 'checkbox':
2497 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2498 case 'radio':
2499 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2500 case 'range':
2501 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2502 default:
2503 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2504 }
2505 };
2506
2507 /**
2508 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2509 */
2510 const focusInput = input => {
2511 input.focus();
2512
2513 // place cursor at end of text in text input
2514 if (input.type !== 'file') {
2515 // http://stackoverflow.com/a/2345915
2516 const val = input.value;
2517 input.value = '';
2518 input.value = val;
2519 }
2520 };
2521
2522 /**
2523 * @param {HTMLElement | HTMLElement[] | null} target
2524 * @param {string | string[] | readonly string[] | undefined} classList
2525 * @param {boolean} condition
2526 */
2527 const toggleClass = (target, classList, condition) => {
2528 if (!target || !classList) {
2529 return;
2530 }
2531 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
2532 const targets = Array.isArray(target) ? target : [target];
2533 targets.forEach(elem => {
2534 classes.forEach(className => {
2535 if (condition) {
2536 elem.classList.add(className);
2537 } else {
2538 elem.classList.remove(className);
2539 }
2540 });
2541 });
2542 };
2543
2544 /**
2545 * @param {HTMLElement | HTMLElement[] | null} target
2546 * @param {string | string[] | readonly string[] | undefined} classList
2547 */
2548 const addClass = (target, classList) => {
2549 toggleClass(target, classList, true);
2550 };
2551
2552 /**
2553 * @param {HTMLElement | HTMLElement[] | null} target
2554 * @param {string | string[] | readonly string[] | undefined} classList
2555 */
2556 const removeClass = (target, classList) => {
2557 toggleClass(target, classList, false);
2558 };
2559
2560 /**
2561 * Get direct child of an element by class name
2562 *
2563 * @param {HTMLElement} elem
2564 * @param {string} className
2565 * @returns {HTMLElement | undefined}
2566 */
2567 const getDirectChildByClass = (elem, className) => (/** @type {HTMLElement | undefined} */
2568 Array.from(elem.children).find(child => child instanceof HTMLElement && hasClass(child, className)));
2569
2570 /**
2571 * @param {HTMLElement} elem
2572 * @param {string} property
2573 * @param {string | number | null | undefined} value
2574 */
2575 const applyNumericalStyle = (elem, property, value) => {
2576 if (value === `${parseInt(`${value}`)}`) {
2577 value = parseInt(value);
2578 }
2579 if (value || value === 0) {
2580 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2581 } else {
2582 elem.style.removeProperty(property);
2583 }
2584 };
2585
2586 /**
2587 * @param {HTMLElement | null} elem
2588 * @param {string} display
2589 */
2590 const show = (elem, display = 'flex') => {
2591 if (!elem) {
2592 return;
2593 }
2594 elem.style.display = display;
2595 };
2596
2597 /**
2598 * @param {HTMLElement | null} elem
2599 */
2600 const hide = elem => {
2601 if (!elem) {
2602 return;
2603 }
2604 elem.style.display = 'none';
2605 };
2606
2607 /**
2608 * @param {HTMLElement | null} elem
2609 * @param {string} display
2610 */
2611 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2612 if (!elem) {
2613 return;
2614 }
2615 new MutationObserver(() => {
2616 toggle(elem, elem.innerHTML, display);
2617 }).observe(elem, {
2618 childList: true,
2619 subtree: true
2620 });
2621 };
2622
2623 /**
2624 * @param {HTMLElement} parent
2625 * @param {string} selector
2626 * @param {string} property
2627 * @param {string} value
2628 */
2629 const setStyle = (parent, selector, property, value) => {
2630 /** @type {HTMLElement | null} */
2631 const el = parent.querySelector(selector);
2632 if (el) {
2633 el.style.setProperty(property, value);
2634 }
2635 };
2636
2637 /**
2638 * @param {HTMLElement} elem
2639 * @param {boolean | string | null | undefined} condition
2640 * @param {string} display
2641 */
2642 const toggle = (elem, condition, display = 'flex') => {
2643 if (condition) {
2644 show(elem, display);
2645 } else {
2646 hide(elem);
2647 }
2648 };
2649
2650 /**
2651 * borrowed from jquery $(elem).is(':visible') implementation
2652 *
2653 * @param {HTMLElement | null} elem
2654 * @returns {boolean}
2655 */
2656 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2657
2658 /**
2659 * @returns {boolean}
2660 */
2661 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2662
2663 /**
2664 * @param {HTMLElement} elem
2665 * @returns {boolean}
2666 */
2667 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2668
2669 /**
2670 * @param {HTMLElement} element
2671 * @param {HTMLElement} stopElement
2672 * @returns {boolean}
2673 */
2674 const selfOrParentIsScrollable = (element, stopElement) => {
2675 let parent = /** @type {HTMLElement | null} */element;
2676 while (parent && parent !== stopElement) {
2677 if (isScrollable(parent)) {
2678 return true;
2679 }
2680 parent = parent.parentElement;
2681 }
2682 return false;
2683 };
2684
2685 /**
2686 * borrowed from https://stackoverflow.com/a/46352119
2687 *
2688 * @param {HTMLElement} elem
2689 * @returns {boolean}
2690 */
2691 const hasCssAnimation = elem => {
2692 const style = window.getComputedStyle(elem);
2693 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2694 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2695 return animDuration > 0 || transDuration > 0;
2696 };
2697
2698 /**
2699 * @param {number} timer
2700 * @param {boolean} reset
2701 */
2702 const animateTimerProgressBar = (timer, reset = false) => {
2703 const timerProgressBar = getTimerProgressBar();
2704 if (!timerProgressBar) {
2705 return;
2706 }
2707 if (isVisible$1(timerProgressBar)) {
2708 if (reset) {
2709 timerProgressBar.style.transition = 'none';
2710 timerProgressBar.style.width = '100%';
2711 }
2712 setTimeout(() => {
2713 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2714 timerProgressBar.style.width = '0%';
2715 }, 10);
2716 }
2717 };
2718 const stopTimerProgressBar = () => {
2719 const timerProgressBar = getTimerProgressBar();
2720 if (!timerProgressBar) {
2721 return;
2722 }
2723 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2724 timerProgressBar.style.removeProperty('transition');
2725 timerProgressBar.style.width = '100%';
2726 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2727 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2728 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2729 };
2730
2731 /**
2732 * Detect Node env
2733 *
2734 * @returns {boolean}
2735 */
2736 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2737
2738 const sweetHTML = `
2739 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2740 <button type="button" class="${swalClasses.close}"></button>
2741 <ul class="${swalClasses['progress-steps']}"></ul>
2742 <div class="${swalClasses.icon}"></div>
2743 <img class="${swalClasses.image}" />
2744 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2745 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2746 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2747 <input type="file" class="${swalClasses.file}" />
2748 <div class="${swalClasses.range}">
2749 <input type="range" />
2750 <output></output>
2751 </div>
2752 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2753 <div class="${swalClasses.radio}"></div>
2754 <label class="${swalClasses.checkbox}">
2755 <input type="checkbox" id="${swalClasses.checkbox}" />
2756 <span class="${swalClasses.label}"></span>
2757 </label>
2758 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2759 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2760 <div class="${swalClasses.actions}">
2761 <div class="${swalClasses.loader}"></div>
2762 <button type="button" class="${swalClasses.confirm}"></button>
2763 <button type="button" class="${swalClasses.deny}"></button>
2764 <button type="button" class="${swalClasses.cancel}"></button>
2765 </div>
2766 <div class="${swalClasses.footer}"></div>
2767 <div class="${swalClasses['timer-progress-bar-container']}">
2768 <div class="${swalClasses['timer-progress-bar']}"></div>
2769 </div>
2770 </div>
2771 `.replace(/(^|\n)\s*/g, '');
2772
2773 /**
2774 * @returns {boolean}
2775 */
2776 const resetOldContainer = () => {
2777 const oldContainer = getContainer();
2778 if (!oldContainer) {
2779 return false;
2780 }
2781 oldContainer.remove();
2782 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2783 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2784 swalClasses['has-column']]);
2785 return true;
2786 };
2787 const resetValidationMessage$1 = () => {
2788 if (globalState.currentInstance) {
2789 globalState.currentInstance.resetValidationMessage();
2790 }
2791 };
2792 const addInputChangeListeners = () => {
2793 const popup = getPopup();
2794 if (!popup) {
2795 return;
2796 }
2797 const input = getDirectChildByClass(popup, swalClasses.input);
2798 const file = getDirectChildByClass(popup, swalClasses.file);
2799 /** @type {HTMLInputElement | null} */
2800 const range = popup.querySelector(`.${swalClasses.range} input`);
2801 /** @type {HTMLOutputElement | null} */
2802 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2803 const select = getDirectChildByClass(popup, swalClasses.select);
2804 /** @type {HTMLInputElement | null} */
2805 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2806 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2807 if (input) {
2808 input.oninput = resetValidationMessage$1;
2809 }
2810 if (file) {
2811 file.onchange = resetValidationMessage$1;
2812 }
2813 if (select) {
2814 select.onchange = resetValidationMessage$1;
2815 }
2816 if (checkbox) {
2817 checkbox.onchange = resetValidationMessage$1;
2818 }
2819 if (textarea) {
2820 textarea.oninput = resetValidationMessage$1;
2821 }
2822 if (range && rangeOutput) {
2823 range.oninput = () => {
2824 resetValidationMessage$1();
2825 rangeOutput.value = range.value;
2826 };
2827 range.onchange = () => {
2828 resetValidationMessage$1();
2829 rangeOutput.value = range.value;
2830 };
2831 }
2832 };
2833
2834 /**
2835 * @param {string | HTMLElement} target
2836 * @returns {HTMLElement}
2837 */
2838 const getTarget = target => {
2839 if (typeof target === 'string') {
2840 const element = document.querySelector(target);
2841 if (!element) {
2842 throw new Error(`Target element "${target}" not found`);
2843 }
2844 return /** @type {HTMLElement} */element;
2845 }
2846 return target;
2847 };
2848
2849 /**
2850 * @param {SweetAlertOptions} params
2851 */
2852 const setupAccessibility = params => {
2853 const popup = getPopup();
2854 if (!popup) {
2855 return;
2856 }
2857 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2858 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2859 if (!params.toast) {
2860 popup.setAttribute('aria-modal', 'true');
2861 }
2862 };
2863
2864 /**
2865 * @param {HTMLElement} targetElement
2866 */
2867 const setupRTL = targetElement => {
2868 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2869 addClass(getContainer(), swalClasses.rtl);
2870 globalState.isRTL = true;
2871 }
2872 };
2873
2874 /**
2875 * Add modal + backdrop to DOM
2876 *
2877 * @param {SweetAlertOptions} params
2878 */
2879 const init = params => {
2880 // Clean up the old popup container if it exists
2881 const oldContainerExisted = resetOldContainer();
2882 if (isNodeEnv()) {
2883 error('SweetAlert2 requires document to initialize');
2884 return;
2885 }
2886 const container = document.createElement('div');
2887 container.className = swalClasses.container;
2888 if (oldContainerExisted) {
2889 addClass(container, swalClasses['no-transition']);
2890 }
2891 setInnerHtml(container, sweetHTML);
2892 container.dataset['swal2Theme'] = params.theme;
2893 const targetElement = getTarget(params.target || 'body');
2894 targetElement.appendChild(container);
2895 if (params.topLayer) {
2896 container.setAttribute('popover', '');
2897 container.showPopover();
2898 }
2899 setupAccessibility(params);
2900 setupRTL(targetElement);
2901 addInputChangeListeners();
2902 };
2903
2904 /**
2905 * @param {HTMLElement | object | string} param
2906 * @param {HTMLElement} target
2907 */
2908 const parseHtmlToContainer = (param, target) => {
2909 // DOM element
2910 if (param instanceof HTMLElement) {
2911 target.appendChild(param);
2912 }
2913
2914 // Object
2915 else if (typeof param === 'object') {
2916 handleObject(param, target);
2917 }
2918
2919 // Plain string
2920 else if (param) {
2921 setInnerHtml(target, param);
2922 }
2923 };
2924
2925 /**
2926 * @param {object} param
2927 * @param {HTMLElement} target
2928 */
2929 const handleObject = (param, target) => {
2930 // JQuery element(s)
2931 if ('jquery' in param) {
2932 handleJqueryElem(target, param);
2933 }
2934
2935 // For other objects use their string representation
2936 else {
2937 setInnerHtml(target, param.toString());
2938 }
2939 };
2940
2941 /**
2942 * @param {HTMLElement} target
2943 * @param {any} elem
2944 */
2945 const handleJqueryElem = (target, elem) => {
2946 target.textContent = '';
2947 if (0 in elem) {
2948 for (let i = 0; i in elem; i++) {
2949 target.appendChild(elem[i].cloneNode(true));
2950 }
2951 } else {
2952 target.appendChild(elem.cloneNode(true));
2953 }
2954 };
2955
2956 /**
2957 * @param {SweetAlert} instance
2958 * @param {SweetAlertOptions} params
2959 */
2960 const renderActions = (instance, params) => {
2961 const actions = getActions();
2962 const loader = getLoader();
2963 if (!actions || !loader) {
2964 return;
2965 }
2966
2967 // Actions (buttons) wrapper
2968 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2969 hide(actions);
2970 } else {
2971 show(actions);
2972 }
2973
2974 // Custom class
2975 applyCustomClass(actions, params, 'actions');
2976
2977 // Render all the buttons
2978 renderButtons(actions, loader, params);
2979
2980 // Loader
2981 setInnerHtml(loader, params.loaderHtml || '');
2982 applyCustomClass(loader, params, 'loader');
2983 };
2984
2985 /**
2986 * @param {HTMLElement} actions
2987 * @param {HTMLElement} loader
2988 * @param {SweetAlertOptions} params
2989 */
2990 function renderButtons(actions, loader, params) {
2991 const confirmButton = getConfirmButton();
2992 const denyButton = getDenyButton();
2993 const cancelButton = getCancelButton();
2994 if (!confirmButton || !denyButton || !cancelButton) {
2995 return;
2996 }
2997
2998 // Render buttons
2999 renderButton(confirmButton, 'confirm', params);
3000 renderButton(denyButton, 'deny', params);
3001 renderButton(cancelButton, 'cancel', params);
3002 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3003 if (params.reverseButtons) {
3004 if (params.toast) {
3005 actions.insertBefore(cancelButton, confirmButton);
3006 actions.insertBefore(denyButton, confirmButton);
3007 } else {
3008 actions.insertBefore(cancelButton, loader);
3009 actions.insertBefore(denyButton, loader);
3010 actions.insertBefore(confirmButton, loader);
3011 }
3012 }
3013 }
3014
3015 /**
3016 * @param {HTMLElement} confirmButton
3017 * @param {HTMLElement} denyButton
3018 * @param {HTMLElement} cancelButton
3019 * @param {SweetAlertOptions} params
3020 */
3021 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3022 if (!params.buttonsStyling) {
3023 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3024 return;
3025 }
3026 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3027
3028 // Apply custom background colors and outline colors to action buttons
3029 /** @type {[HTMLElement, string, string | undefined][]} */
3030 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
3031 buttons.forEach(([button, type, color]) => {
3032 if (color) {
3033 button.style.setProperty(`--swal2-${type}-button-background-color`, color);
3034 }
3035 applyOutlineColor(button);
3036 });
3037 }
3038
3039 /**
3040 * @param {HTMLElement} button
3041 */
3042 function applyOutlineColor(button) {
3043 const buttonStyle = window.getComputedStyle(button);
3044 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3045 // If the button already has a custom outline color, no need to change it
3046 return;
3047 }
3048 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3049 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3050 }
3051
3052 /**
3053 * @param {HTMLElement} button
3054 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3055 * @param {SweetAlertOptions} params
3056 */
3057 function renderButton(button, buttonType, params) {
3058 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3059 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3060 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3061 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3062
3063 // Add buttons custom classes
3064 button.className = swalClasses[buttonType];
3065 applyCustomClass(button, params, `${buttonType}Button`);
3066 }
3067
3068 /**
3069 * @param {SweetAlert} instance
3070 * @param {SweetAlertOptions} params
3071 */
3072 const renderCloseButton = (instance, params) => {
3073 const closeButton = getCloseButton();
3074 if (!closeButton) {
3075 return;
3076 }
3077 setInnerHtml(closeButton, params.closeButtonHtml || '');
3078
3079 // Custom class
3080 applyCustomClass(closeButton, params, 'closeButton');
3081 toggle(closeButton, params.showCloseButton);
3082 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3083 };
3084
3085 /**
3086 * @param {SweetAlert} instance
3087 * @param {SweetAlertOptions} params
3088 */
3089 const renderContainer = (instance, params) => {
3090 const container = getContainer();
3091 if (!container) {
3092 return;
3093 }
3094 handleBackdropParam(container, params.backdrop);
3095 handlePositionParam(container, params.position);
3096 handleGrowParam(container, params.grow);
3097
3098 // Custom class
3099 applyCustomClass(container, params, 'container');
3100 };
3101
3102 /**
3103 * @param {HTMLElement} container
3104 * @param {SweetAlertOptions['backdrop']} backdrop
3105 */
3106 function handleBackdropParam(container, backdrop) {
3107 if (typeof backdrop === 'string') {
3108 container.style.background = backdrop;
3109 } else if (!backdrop) {
3110 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3111 }
3112 }
3113
3114 /**
3115 * @param {HTMLElement} container
3116 * @param {SweetAlertOptions['position']} position
3117 */
3118 function handlePositionParam(container, position) {
3119 if (!position) {
3120 return;
3121 }
3122 if (position in swalClasses) {
3123 addClass(container, swalClasses[position]);
3124 } else {
3125 warn('The "position" parameter is not valid, defaulting to "center"');
3126 addClass(container, swalClasses.center);
3127 }
3128 }
3129
3130 /**
3131 * @param {HTMLElement} container
3132 * @param {SweetAlertOptions['grow']} grow
3133 */
3134 function handleGrowParam(container, grow) {
3135 if (!grow) {
3136 return;
3137 }
3138 addClass(container, swalClasses[`grow-${grow}`]);
3139 }
3140
3141 /**
3142 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3143 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3144 * This is the approach that Babel will probably take to implement private methods/fields
3145 * https://github.com/tc39/proposal-private-methods
3146 * https://github.com/babel/babel/pull/7555
3147 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3148 * then we can use that language feature.
3149 */
3150
3151 var privateProps = {
3152 innerParams: new WeakMap(),
3153 domCache: new WeakMap(),
3154 focusedElement: new WeakMap()
3155 };
3156
3157 /// <reference path="../../../../sweetalert2.d.ts"/>
3158
3159
3160 /** @type {InputClass[]} */
3161 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3162
3163 /**
3164 * @param {SweetAlert} instance
3165 * @param {SweetAlertOptions} params
3166 */
3167 const renderInput = (instance, params) => {
3168 const popup = getPopup();
3169 if (!popup) {
3170 return;
3171 }
3172 const innerParams = privateProps.innerParams.get(instance);
3173 const rerender = !innerParams || params.input !== innerParams.input;
3174 inputClasses.forEach(inputClass => {
3175 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3176 if (!inputContainer) {
3177 return;
3178 }
3179
3180 // set attributes
3181 setAttributes(inputClass, params.inputAttributes);
3182
3183 // set class
3184 inputContainer.className = swalClasses[inputClass];
3185 if (rerender) {
3186 hide(inputContainer);
3187 }
3188 });
3189 if (params.input) {
3190 if (rerender) {
3191 showInput(params);
3192 }
3193 // set custom class
3194 setCustomClass(params);
3195 }
3196 };
3197
3198 /**
3199 * @param {SweetAlertOptions} params
3200 */
3201 const showInput = params => {
3202 if (!params.input) {
3203 return;
3204 }
3205 if (!renderInputType[params.input]) {
3206 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3207 return;
3208 }
3209 const inputContainer = getInputContainer(params.input);
3210 if (!inputContainer) {
3211 return;
3212 }
3213 const input = renderInputType[params.input](inputContainer, params);
3214 show(inputContainer);
3215
3216 // input autofocus
3217 if (params.inputAutoFocus) {
3218 setTimeout(() => {
3219 focusInput(input);
3220 });
3221 }
3222 };
3223
3224 /**
3225 * @param {HTMLInputElement} input
3226 */
3227 const removeAttributes = input => {
3228 for (const {
3229 name
3230 } of Array.from(input.attributes)) {
3231 if (!['id', 'type', 'value', 'style'].includes(name)) {
3232 input.removeAttribute(name);
3233 }
3234 }
3235 };
3236
3237 /**
3238 * @param {InputClass} inputClass
3239 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3240 */
3241 const setAttributes = (inputClass, inputAttributes) => {
3242 const popup = getPopup();
3243 if (!popup) {
3244 return;
3245 }
3246 const input = getInput$1(popup, inputClass);
3247 if (!input) {
3248 return;
3249 }
3250 removeAttributes(input);
3251 for (const attr in inputAttributes) {
3252 input.setAttribute(attr, inputAttributes[attr]);
3253 }
3254 };
3255
3256 /**
3257 * @param {SweetAlertOptions} params
3258 */
3259 const setCustomClass = params => {
3260 if (!params.input) {
3261 return;
3262 }
3263 const inputContainer = getInputContainer(params.input);
3264 if (inputContainer) {
3265 applyCustomClass(inputContainer, params, 'input');
3266 }
3267 };
3268
3269 /**
3270 * @param {HTMLInputElement | HTMLTextAreaElement} input
3271 * @param {SweetAlertOptions} params
3272 */
3273 const setInputPlaceholder = (input, params) => {
3274 if (!input.placeholder && params.inputPlaceholder) {
3275 input.placeholder = params.inputPlaceholder;
3276 }
3277 };
3278
3279 /**
3280 * @param {Input} input
3281 * @param {Input} prependTo
3282 * @param {SweetAlertOptions} params
3283 */
3284 const setInputLabel = (input, prependTo, params) => {
3285 if (params.inputLabel) {
3286 const label = document.createElement('label');
3287 const labelClass = swalClasses['input-label'];
3288 label.setAttribute('for', input.id);
3289 label.className = labelClass;
3290 if (typeof params.customClass === 'object') {
3291 addClass(label, params.customClass.inputLabel);
3292 }
3293 label.innerText = params.inputLabel;
3294 prependTo.insertAdjacentElement('beforebegin', label);
3295 }
3296 };
3297
3298 /**
3299 * @param {SweetAlertInput} inputType
3300 * @returns {HTMLElement | undefined}
3301 */
3302 const getInputContainer = inputType => {
3303 const popup = getPopup();
3304 if (!popup) {
3305 return;
3306 }
3307 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3308 };
3309
3310 /**
3311 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3312 * @param {SweetAlertOptions['inputValue']} inputValue
3313 */
3314 const checkAndSetInputValue = (input, inputValue) => {
3315 if (['string', 'number'].includes(typeof inputValue)) {
3316 input.value = `${inputValue}`;
3317 } else if (!isPromise(inputValue)) {
3318 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3319 }
3320 };
3321
3322 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3323 const renderInputType = {};
3324
3325 /**
3326 * @param {Input | HTMLElement} input
3327 * @param {SweetAlertOptions} params
3328 * @returns {Input}
3329 */
3330 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} */
3331 (input, params) => {
3332 // oxfmt-ignore
3333 const inputElement = /** @type {HTMLInputElement} */input;
3334 checkAndSetInputValue(inputElement, params.inputValue);
3335 setInputLabel(inputElement, inputElement, params);
3336 setInputPlaceholder(inputElement, params);
3337 // oxfmt-ignore
3338 inputElement.type = /** @type {string} */params.input;
3339 return inputElement;
3340 };
3341
3342 /**
3343 * @param {Input | HTMLElement} input
3344 * @param {SweetAlertOptions} params
3345 * @returns {Input}
3346 */
3347 renderInputType.file = (input, params) => {
3348 const inputElement = /** @type {HTMLInputElement} */input;
3349 setInputLabel(inputElement, inputElement, params);
3350 setInputPlaceholder(inputElement, params);
3351 return inputElement;
3352 };
3353
3354 /**
3355 * @param {Input | HTMLElement} range
3356 * @param {SweetAlertOptions} params
3357 * @returns {Input}
3358 */
3359 renderInputType.range = (range, params) => {
3360 const rangeContainer = /** @type {HTMLElement} */range;
3361 const rangeInput = rangeContainer.querySelector('input');
3362 const rangeOutput = rangeContainer.querySelector('output');
3363 if (rangeInput) {
3364 checkAndSetInputValue(rangeInput, params.inputValue);
3365 rangeInput.type = /** @type {string} */params.input;
3366 setInputLabel(rangeInput, /** @type {Input} */range, params);
3367 }
3368 if (rangeOutput) {
3369 checkAndSetInputValue(rangeOutput, params.inputValue);
3370 }
3371 return /** @type {Input} */range;
3372 };
3373
3374 /**
3375 * @param {Input | HTMLElement} select
3376 * @param {SweetAlertOptions} params
3377 * @returns {Input}
3378 */
3379 renderInputType.select = (select, params) => {
3380 const selectElement = /** @type {HTMLSelectElement} */select;
3381 selectElement.textContent = '';
3382 if (params.inputPlaceholder) {
3383 const placeholder = document.createElement('option');
3384 setInnerHtml(placeholder, params.inputPlaceholder);
3385 placeholder.value = '';
3386 placeholder.disabled = true;
3387 placeholder.selected = true;
3388 selectElement.appendChild(placeholder);
3389 }
3390 setInputLabel(selectElement, selectElement, params);
3391 return selectElement;
3392 };
3393
3394 /**
3395 * @param {Input | HTMLElement} radio
3396 * @returns {Input}
3397 */
3398 renderInputType.radio = radio => {
3399 const radioElement = /** @type {HTMLElement} */radio;
3400 radioElement.textContent = '';
3401 return /** @type {Input} */radio;
3402 };
3403
3404 /**
3405 * @param {Input | HTMLElement} checkboxContainer
3406 * @param {SweetAlertOptions} params
3407 * @returns {Input}
3408 */
3409 renderInputType.checkbox = (checkboxContainer, params) => {
3410 const popup = getPopup();
3411 if (!popup) {
3412 throw new Error('Popup not found');
3413 }
3414 const checkbox = getInput$1(popup, 'checkbox');
3415 if (!checkbox) {
3416 throw new Error('Checkbox input not found');
3417 }
3418 checkbox.value = '1';
3419 checkbox.checked = Boolean(params.inputValue);
3420 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3421 const label = containerElement.querySelector('span');
3422 if (label) {
3423 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3424 if (placeholderOrLabel) {
3425 setInnerHtml(label, placeholderOrLabel);
3426 }
3427 }
3428 return checkbox;
3429 };
3430
3431 /**
3432 * @param {Input | HTMLElement} textarea
3433 * @param {SweetAlertOptions} params
3434 * @returns {Input}
3435 */
3436 renderInputType.textarea = (textarea, params) => {
3437 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3438 checkAndSetInputValue(textareaElement, params.inputValue);
3439 setInputPlaceholder(textareaElement, params);
3440 setInputLabel(textareaElement, textareaElement, params);
3441
3442 /**
3443 * @param {HTMLElement} el
3444 * @returns {number}
3445 */
3446 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3447
3448 // https://github.com/sweetalert2/sweetalert2/issues/2291
3449 setTimeout(() => {
3450 // https://github.com/sweetalert2/sweetalert2/issues/1699
3451 if ('MutationObserver' in window) {
3452 const popup = getPopup();
3453 if (!popup) {
3454 return;
3455 }
3456 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3457 const textareaResizeHandler = () => {
3458 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3459 if (!document.body.contains(textareaElement)) {
3460 return;
3461 }
3462 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3463 const popupElement = getPopup();
3464 if (popupElement) {
3465 if (textareaWidth > initialPopupWidth) {
3466 popupElement.style.width = `${textareaWidth}px`;
3467 } else {
3468 applyNumericalStyle(popupElement, 'width', params.width);
3469 }
3470 }
3471 };
3472 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3473 attributes: true,
3474 attributeFilter: ['style']
3475 });
3476 }
3477 });
3478 return textareaElement;
3479 };
3480
3481 /**
3482 * @param {SweetAlert} instance
3483 * @param {SweetAlertOptions} params
3484 */
3485 const renderContent = (instance, params) => {
3486 const htmlContainer = getHtmlContainer();
3487 if (!htmlContainer) {
3488 return;
3489 }
3490 showWhenInnerHtmlPresent(htmlContainer);
3491 applyCustomClass(htmlContainer, params, 'htmlContainer');
3492
3493 // Content as HTML
3494 if (params.html) {
3495 parseHtmlToContainer(params.html, htmlContainer);
3496 show(htmlContainer, 'block');
3497 }
3498
3499 // Content as plain text
3500 else if (params.text) {
3501 htmlContainer.textContent = params.text;
3502 show(htmlContainer, 'block');
3503 }
3504
3505 // No content
3506 else {
3507 hide(htmlContainer);
3508 }
3509 renderInput(instance, params);
3510 };
3511
3512 /**
3513 * @param {SweetAlert} instance
3514 * @param {SweetAlertOptions} params
3515 */
3516 const renderFooter = (instance, params) => {
3517 const footer = getFooter();
3518 if (!footer) {
3519 return;
3520 }
3521 showWhenInnerHtmlPresent(footer);
3522 toggle(footer, Boolean(params.footer), 'block');
3523 if (params.footer) {
3524 parseHtmlToContainer(params.footer, footer);
3525 }
3526
3527 // Custom class
3528 applyCustomClass(footer, params, 'footer');
3529 };
3530
3531 /**
3532 * @param {SweetAlert} instance
3533 * @param {SweetAlertOptions} params
3534 */
3535 const renderIcon = (instance, params) => {
3536 const innerParams = privateProps.innerParams.get(instance);
3537 const icon = getIcon();
3538 if (!icon) {
3539 return;
3540 }
3541
3542 // if the given icon already rendered, apply the styling without re-rendering the icon
3543 if (innerParams && params.icon === innerParams.icon) {
3544 // Custom or default content
3545 setContent(icon, params);
3546 applyStyles(icon, params);
3547 return;
3548 }
3549 if (!params.icon && !params.iconHtml) {
3550 hide(icon);
3551 return;
3552 }
3553 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3554 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3555 hide(icon);
3556 return;
3557 }
3558 show(icon);
3559
3560 // Custom or default content
3561 setContent(icon, params);
3562 applyStyles(icon, params);
3563
3564 // Animate icon
3565 addClass(icon, params.showClass && params.showClass.icon);
3566
3567 // Re-adjust the success icon on system theme change
3568 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3569 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3570 };
3571
3572 /**
3573 * @param {HTMLElement} icon
3574 * @param {SweetAlertOptions} params
3575 */
3576 const applyStyles = (icon, params) => {
3577 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3578 if (params.icon !== iconType) {
3579 removeClass(icon, iconClassName);
3580 }
3581 }
3582 addClass(icon, params.icon && iconTypes[params.icon]);
3583
3584 // Icon color
3585 setColor(icon, params);
3586
3587 // Success icon background color
3588 adjustSuccessIconBackgroundColor();
3589
3590 // Custom class
3591 applyCustomClass(icon, params, 'icon');
3592 };
3593
3594 // Adjust success icon background color to match the popup background color
3595 const adjustSuccessIconBackgroundColor = () => {
3596 const popup = getPopup();
3597 if (!popup) {
3598 return;
3599 }
3600 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3601 /** @type {NodeListOf<HTMLElement>} */
3602 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3603 successIconParts.forEach(part => {
3604 part.style.backgroundColor = popupBackgroundColor;
3605 });
3606 };
3607
3608 /**
3609 *
3610 * @param {SweetAlertOptions} params
3611 * @returns {string}
3612 */
3613 const successIconHtml = params => `
3614 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3615 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3616 <div class="swal2-success-ring"></div>
3617 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3618 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3619 `;
3620 const errorIconHtml = `
3621 <span class="swal2-x-mark">
3622 <span class="swal2-x-mark-line-left"></span>
3623 <span class="swal2-x-mark-line-right"></span>
3624 </span>
3625 `;
3626
3627 /**
3628 * @param {HTMLElement} icon
3629 * @param {SweetAlertOptions} params
3630 */
3631 const setContent = (icon, params) => {
3632 if (!params.icon && !params.iconHtml) {
3633 return;
3634 }
3635 let oldContent = icon.innerHTML;
3636 let newContent = '';
3637 if (params.iconHtml) {
3638 newContent = iconContent(params.iconHtml);
3639 } else if (params.icon === 'success') {
3640 newContent = successIconHtml(params);
3641 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3642 } else if (params.icon === 'error') {
3643 newContent = errorIconHtml;
3644 } else if (params.icon) {
3645 const defaultIconHtml = {
3646 question: '?',
3647 warning: '!',
3648 info: 'i'
3649 };
3650 newContent = iconContent(defaultIconHtml[params.icon]);
3651 }
3652 if (oldContent.trim() !== newContent.trim()) {
3653 setInnerHtml(icon, newContent);
3654 }
3655 };
3656
3657 /**
3658 * @param {HTMLElement} icon
3659 * @param {SweetAlertOptions} params
3660 */
3661 const setColor = (icon, params) => {
3662 if (!params.iconColor) {
3663 return;
3664 }
3665 icon.style.color = params.iconColor;
3666 icon.style.borderColor = params.iconColor;
3667 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3668 setStyle(icon, sel, 'background-color', params.iconColor);
3669 }
3670 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3671 };
3672
3673 /**
3674 * @param {string} content
3675 * @returns {string}
3676 */
3677 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3678
3679 /**
3680 * @param {SweetAlert} instance
3681 * @param {SweetAlertOptions} params
3682 */
3683 const renderImage = (instance, params) => {
3684 const image = getImage();
3685 if (!image) {
3686 return;
3687 }
3688 if (!params.imageUrl) {
3689 hide(image);
3690 return;
3691 }
3692 show(image, '');
3693
3694 // Src, alt
3695 image.setAttribute('src', params.imageUrl);
3696 image.setAttribute('alt', params.imageAlt || '');
3697
3698 // Width, height
3699 applyNumericalStyle(image, 'width', params.imageWidth);
3700 applyNumericalStyle(image, 'height', params.imageHeight);
3701
3702 // Class
3703 image.className = swalClasses.image;
3704 applyCustomClass(image, params, 'image');
3705 };
3706
3707 let dragging = false;
3708 let mousedownX = 0;
3709 let mousedownY = 0;
3710 let initialX = 0;
3711 let initialY = 0;
3712
3713 /**
3714 * @param {HTMLElement} popup
3715 */
3716 const addDraggableListeners = popup => {
3717 popup.addEventListener('mousedown', down);
3718 document.body.addEventListener('mousemove', move);
3719 popup.addEventListener('mouseup', up);
3720 popup.addEventListener('touchstart', down);
3721 document.body.addEventListener('touchmove', move);
3722 popup.addEventListener('touchend', up);
3723 };
3724
3725 /**
3726 * @param {HTMLElement} popup
3727 */
3728 const removeDraggableListeners = popup => {
3729 popup.removeEventListener('mousedown', down);
3730 document.body.removeEventListener('mousemove', move);
3731 popup.removeEventListener('mouseup', up);
3732 popup.removeEventListener('touchstart', down);
3733 document.body.removeEventListener('touchmove', move);
3734 popup.removeEventListener('touchend', up);
3735 };
3736
3737 /**
3738 * @param {MouseEvent | TouchEvent} event
3739 */
3740 const down = event => {
3741 const popup = getPopup();
3742 if (!popup) {
3743 return;
3744 }
3745 const icon = getIcon();
3746 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3747 dragging = true;
3748 const clientXY = getClientXY(event);
3749 mousedownX = clientXY.clientX;
3750 mousedownY = clientXY.clientY;
3751 initialX = parseInt(popup.style.insetInlineStart) || 0;
3752 initialY = parseInt(popup.style.insetBlockStart) || 0;
3753 addClass(popup, 'swal2-dragging');
3754 }
3755 };
3756
3757 /**
3758 * @param {MouseEvent | TouchEvent} event
3759 */
3760 const move = event => {
3761 const popup = getPopup();
3762 if (!popup) {
3763 return;
3764 }
3765 if (dragging) {
3766 let {
3767 clientX,
3768 clientY
3769 } = getClientXY(event);
3770 const deltaX = clientX - mousedownX;
3771 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3772 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3773 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3774 }
3775 };
3776 const up = () => {
3777 const popup = getPopup();
3778 dragging = false;
3779 removeClass(popup, 'swal2-dragging');
3780 };
3781
3782 /**
3783 * @param {MouseEvent | TouchEvent} event
3784 * @returns {{ clientX: number, clientY: number }}
3785 */
3786 const getClientXY = event => {
3787 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
3788 return {
3789 clientX: source.clientX,
3790 clientY: source.clientY
3791 };
3792 };
3793
3794 /**
3795 * @param {SweetAlert} instance
3796 * @param {SweetAlertOptions} params
3797 */
3798 const renderPopup = (instance, params) => {
3799 const container = getContainer();
3800 const popup = getPopup();
3801 if (!container || !popup) {
3802 return;
3803 }
3804
3805 // Width
3806 // https://github.com/sweetalert2/sweetalert2/issues/2170
3807 if (params.toast) {
3808 applyNumericalStyle(container, 'width', params.width);
3809 popup.style.width = '100%';
3810 const loader = getLoader();
3811 if (loader) {
3812 popup.insertBefore(loader, getIcon());
3813 }
3814 } else {
3815 applyNumericalStyle(popup, 'width', params.width);
3816 }
3817
3818 // Padding
3819 applyNumericalStyle(popup, 'padding', params.padding);
3820
3821 // Color
3822 if (params.color) {
3823 popup.style.color = params.color;
3824 }
3825
3826 // Background
3827 if (params.background) {
3828 popup.style.background = params.background;
3829 }
3830 hide(getValidationMessage());
3831
3832 // Classes
3833 addClasses$1(popup, params);
3834 if (params.draggable && !params.toast) {
3835 addClass(popup, swalClasses.draggable);
3836 addDraggableListeners(popup);
3837 } else {
3838 removeClass(popup, swalClasses.draggable);
3839 removeDraggableListeners(popup);
3840 }
3841 };
3842
3843 /**
3844 * @param {HTMLElement} popup
3845 * @param {SweetAlertOptions} params
3846 */
3847 const addClasses$1 = (popup, params) => {
3848 const showClass = params.showClass || {};
3849 // Default Class + showClass when updating Swal.update({})
3850 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3851 if (params.toast) {
3852 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3853 addClass(popup, swalClasses.toast);
3854 } else {
3855 addClass(popup, swalClasses.modal);
3856 }
3857
3858 // Custom class
3859 applyCustomClass(popup, params, 'popup');
3860 // TODO: remove in the next major
3861 if (typeof params.customClass === 'string') {
3862 addClass(popup, params.customClass);
3863 }
3864
3865 // Icon class (#1842)
3866 if (params.icon) {
3867 addClass(popup, swalClasses[`icon-${params.icon}`]);
3868 }
3869 };
3870
3871 /**
3872 * @param {SweetAlert} instance
3873 * @param {SweetAlertOptions} params
3874 */
3875 const renderProgressSteps = (instance, params) => {
3876 const progressStepsContainer = getProgressSteps();
3877 if (!progressStepsContainer) {
3878 return;
3879 }
3880 const {
3881 progressSteps,
3882 currentProgressStep
3883 } = params;
3884 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3885 hide(progressStepsContainer);
3886 return;
3887 }
3888 show(progressStepsContainer);
3889 progressStepsContainer.textContent = '';
3890 if (currentProgressStep >= progressSteps.length) {
3891 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3892 }
3893 progressSteps.forEach((step, index) => {
3894 const stepEl = createStepElement(step);
3895 progressStepsContainer.appendChild(stepEl);
3896 if (index === currentProgressStep) {
3897 addClass(stepEl, swalClasses['active-progress-step']);
3898 }
3899 if (index !== progressSteps.length - 1) {
3900 const lineEl = createLineElement(params);
3901 progressStepsContainer.appendChild(lineEl);
3902 }
3903 });
3904 };
3905
3906 /**
3907 * @param {string} step
3908 * @returns {HTMLLIElement}
3909 */
3910 const createStepElement = step => {
3911 const stepEl = document.createElement('li');
3912 addClass(stepEl, swalClasses['progress-step']);
3913 setInnerHtml(stepEl, step);
3914 return stepEl;
3915 };
3916
3917 /**
3918 * @param {SweetAlertOptions} params
3919 * @returns {HTMLLIElement}
3920 */
3921 const createLineElement = params => {
3922 const lineEl = document.createElement('li');
3923 addClass(lineEl, swalClasses['progress-step-line']);
3924 if (params.progressStepsDistance) {
3925 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3926 }
3927 return lineEl;
3928 };
3929
3930 /**
3931 * @param {SweetAlert} instance
3932 * @param {SweetAlertOptions} params
3933 */
3934 const renderTitle = (instance, params) => {
3935 const title = getTitle();
3936 if (!title) {
3937 return;
3938 }
3939 showWhenInnerHtmlPresent(title);
3940 toggle(title, Boolean(params.title || params.titleText), 'block');
3941 if (params.title) {
3942 parseHtmlToContainer(params.title, title);
3943 }
3944 if (params.titleText) {
3945 title.innerText = params.titleText;
3946 }
3947
3948 // Custom class
3949 applyCustomClass(title, params, 'title');
3950 };
3951
3952 /**
3953 * @param {SweetAlert} instance
3954 * @param {SweetAlertOptions} params
3955 */
3956 const render = (instance, params) => {
3957 var _globalState$eventEmi;
3958 renderPopup(instance, params);
3959 renderContainer(instance, params);
3960 renderProgressSteps(instance, params);
3961 renderIcon(instance, params);
3962 renderImage(instance, params);
3963 renderTitle(instance, params);
3964 renderCloseButton(instance, params);
3965 renderContent(instance, params);
3966 renderActions(instance, params);
3967 renderFooter(instance, params);
3968 const popup = getPopup();
3969 if (typeof params.didRender === 'function' && popup) {
3970 params.didRender(popup);
3971 }
3972 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3973 };
3974
3975 /*
3976 * Global function to determine if SweetAlert2 popup is shown
3977 */
3978 const isVisible = () => {
3979 return isVisible$1(getPopup());
3980 };
3981
3982 /*
3983 * Global function to click 'Confirm' button
3984 */
3985 const clickConfirm = () => {
3986 var _dom$getConfirmButton;
3987 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
3988 };
3989
3990 /*
3991 * Global function to click 'Deny' button
3992 */
3993 const clickDeny = () => {
3994 var _dom$getDenyButton;
3995 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
3996 };
3997
3998 /*
3999 * Global function to click 'Cancel' button
4000 */
4001 const clickCancel = () => {
4002 var _dom$getCancelButton;
4003 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4004 };
4005
4006 /** @type {Record<DismissReason, DismissReason>} */
4007 const DismissReason = Object.freeze({
4008 cancel: 'cancel',
4009 backdrop: 'backdrop',
4010 close: 'close',
4011 esc: 'esc',
4012 timer: 'timer'
4013 });
4014
4015 /**
4016 * @param {GlobalState} globalState
4017 */
4018 const removeKeydownHandler = globalState => {
4019 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4020 const handler = /** @type {EventListenerOrEventListenerObject} */
4021 /** @type {unknown} */globalState.keydownHandler;
4022 globalState.keydownTarget.removeEventListener('keydown', handler, {
4023 capture: globalState.keydownListenerCapture
4024 });
4025 globalState.keydownHandlerAdded = false;
4026 }
4027 };
4028
4029 /**
4030 * @param {GlobalState} globalState
4031 * @param {SweetAlertOptions} innerParams
4032 * @param {(dismiss: DismissReason) => void} dismissWith
4033 */
4034 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4035 removeKeydownHandler(globalState);
4036 if (!innerParams.toast) {
4037 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4038 const handler = e => keydownHandler(innerParams, e, dismissWith);
4039 globalState.keydownHandler = handler;
4040 const target = innerParams.keydownListenerCapture ? window : getPopup();
4041 if (target) {
4042 globalState.keydownTarget = target;
4043 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4044 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4045 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4046 capture: globalState.keydownListenerCapture
4047 });
4048 globalState.keydownHandlerAdded = true;
4049 }
4050 }
4051 };
4052
4053 /**
4054 * @param {number} index
4055 * @param {number} increment
4056 * @returns {boolean} shouldPreventDefault
4057 */
4058 const setFocus = (index, increment) => {
4059 var _dom$getPopup;
4060 const focusableElements = getFocusableElements();
4061 // search for visible elements and select the next possible match
4062 if (focusableElements.length) {
4063 index = index + increment;
4064
4065 // shift + tab when .swal2-popup is focused
4066 if (index === -2) {
4067 index = focusableElements.length - 1;
4068 }
4069
4070 // rollover to first item
4071 if (index === focusableElements.length) {
4072 index = 0;
4073
4074 // go to last item
4075 } else if (index === -1) {
4076 index = focusableElements.length - 1;
4077 }
4078 focusableElements[index].focus();
4079
4080 // don't prevent default for iframes (Firefox fix)
4081 // https://github.com/sweetalert2/sweetalert2/issues/2931
4082 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
4083 return false;
4084 }
4085 return true;
4086 }
4087 // no visible focusable elements, focus the popup
4088 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4089 return true;
4090 };
4091 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4092 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4093
4094 /**
4095 * @param {SweetAlertOptions} innerParams
4096 * @param {KeyboardEvent} event
4097 * @param {(dismiss: DismissReason) => void} dismissWith
4098 */
4099 const keydownHandler = (innerParams, event, dismissWith) => {
4100 if (!innerParams) {
4101 return; // This instance has already been destroyed
4102 }
4103
4104 // Ignore keydown during IME composition
4105 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4106 // https://github.com/sweetalert2/sweetalert2/issues/720
4107 // https://github.com/sweetalert2/sweetalert2/issues/2406
4108 if (event.isComposing || event.keyCode === 229) {
4109 return;
4110 }
4111 if (innerParams.stopKeydownPropagation) {
4112 event.stopPropagation();
4113 }
4114
4115 // ENTER
4116 if (event.key === 'Enter') {
4117 handleEnter(event, innerParams);
4118 }
4119
4120 // TAB
4121 else if (event.key === 'Tab') {
4122 handleTab(event);
4123 }
4124
4125 // ARROWS - switch focus between buttons
4126 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4127 handleArrows(event.key);
4128 }
4129
4130 // ESC
4131 else if (event.key === 'Escape') {
4132 handleEsc(event, innerParams, dismissWith);
4133 }
4134 };
4135
4136 /**
4137 * @param {KeyboardEvent} event
4138 * @param {SweetAlertOptions} innerParams
4139 */
4140 const handleEnter = (event, innerParams) => {
4141 // https://github.com/sweetalert2/sweetalert2/issues/2386
4142 if (!callIfFunction(innerParams.allowEnterKey)) {
4143 return;
4144 }
4145 const popup = getPopup();
4146 if (!popup || !innerParams.input) {
4147 return;
4148 }
4149 const input = getInput$1(popup, innerParams.input);
4150 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4151 if (['textarea', 'file'].includes(innerParams.input)) {
4152 return; // do not submit
4153 }
4154 clickConfirm();
4155 event.preventDefault();
4156 }
4157 };
4158
4159 /**
4160 * @param {KeyboardEvent} event
4161 */
4162 const handleTab = event => {
4163 const targetElement = event.target;
4164 const focusableElements = getFocusableElements();
4165 const btnIndex = focusableElements.findIndex(el => el === targetElement);
4166
4167 // don't prevent default for iframes (Firefox fix)
4168 // https://github.com/sweetalert2/sweetalert2/issues/2931
4169 let shouldPreventDefault = true;
4170
4171 // Cycle to the next button
4172 if (!event.shiftKey) {
4173 shouldPreventDefault = setFocus(btnIndex, 1);
4174 }
4175
4176 // Cycle to the prev button
4177 else {
4178 shouldPreventDefault = setFocus(btnIndex, -1);
4179 }
4180 event.stopPropagation();
4181 if (shouldPreventDefault) {
4182 event.preventDefault();
4183 }
4184 };
4185
4186 /**
4187 * @param {string} key
4188 */
4189 const handleArrows = key => {
4190 const actions = getActions();
4191 const confirmButton = getConfirmButton();
4192 const denyButton = getDenyButton();
4193 const cancelButton = getCancelButton();
4194 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4195 return;
4196 }
4197 /** @type HTMLElement[] */
4198 const buttons = [confirmButton, denyButton, cancelButton];
4199 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4200 return;
4201 }
4202 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4203 let buttonToFocus = document.activeElement;
4204 if (!buttonToFocus) {
4205 return;
4206 }
4207 for (let i = 0; i < actions.children.length; i++) {
4208 buttonToFocus = buttonToFocus[sibling];
4209 if (!buttonToFocus) {
4210 return;
4211 }
4212 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4213 break;
4214 }
4215 }
4216 if (buttonToFocus instanceof HTMLButtonElement) {
4217 buttonToFocus.focus();
4218 }
4219 };
4220
4221 /**
4222 * @param {KeyboardEvent} event
4223 * @param {SweetAlertOptions} innerParams
4224 * @param {(dismiss: DismissReason) => void} dismissWith
4225 */
4226 const handleEsc = (event, innerParams, dismissWith) => {
4227 event.preventDefault();
4228 if (callIfFunction(innerParams.allowEscapeKey)) {
4229 dismissWith(DismissReason.esc);
4230 }
4231 };
4232
4233 /**
4234 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4235 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4236 * This is the approach that Babel will probably take to implement private methods/fields
4237 * https://github.com/tc39/proposal-private-methods
4238 * https://github.com/babel/babel/pull/7555
4239 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4240 * then we can use that language feature.
4241 */
4242
4243 var privateMethods = {
4244 swalPromiseResolve: new WeakMap(),
4245 swalPromiseReject: new WeakMap()
4246 };
4247
4248 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4249 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4250 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4251 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4252
4253 const setAriaHidden = () => {
4254 const container = getContainer();
4255 const bodyChildren = Array.from(document.body.children);
4256 bodyChildren.forEach(el => {
4257 if (el.contains(container)) {
4258 return;
4259 }
4260 if (el.hasAttribute('aria-hidden')) {
4261 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4262 }
4263 el.setAttribute('aria-hidden', 'true');
4264 });
4265 };
4266 const unsetAriaHidden = () => {
4267 const bodyChildren = Array.from(document.body.children);
4268 bodyChildren.forEach(el => {
4269 if (el.hasAttribute('data-previous-aria-hidden')) {
4270 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4271 el.removeAttribute('data-previous-aria-hidden');
4272 } else {
4273 el.removeAttribute('aria-hidden');
4274 }
4275 });
4276 };
4277
4278 // @ts-ignore
4279 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4280
4281 // @ts-ignore
4282 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
4283
4284 /**
4285 * Fix iOS scrolling
4286 * http://stackoverflow.com/q/39626302
4287 */
4288 const iOSfix = () => {
4289 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4290 const offset = document.body.scrollTop;
4291 document.body.style.top = `${offset * -1}px`;
4292 addClass(document.body, swalClasses.iosfix);
4293 lockBodyScroll();
4294 }
4295 };
4296
4297 /**
4298 * https://github.com/sweetalert2/sweetalert2/issues/1246
4299 */
4300 const lockBodyScroll = () => {
4301 const container = getContainer();
4302 if (!container) {
4303 return;
4304 }
4305 /** @type {boolean} */
4306 let preventTouchMove;
4307 /**
4308 * @param {TouchEvent} event
4309 */
4310 container.ontouchstart = event => {
4311 preventTouchMove = shouldPreventTouchMove(event);
4312 };
4313 /**
4314 * @param {TouchEvent} event
4315 */
4316 container.ontouchmove = event => {
4317 if (preventTouchMove) {
4318 event.preventDefault();
4319 event.stopPropagation();
4320 }
4321 };
4322 };
4323
4324 /**
4325 * @param {TouchEvent} event
4326 * @returns {boolean}
4327 */
4328 const shouldPreventTouchMove = event => {
4329 const target = event.target;
4330 const container = getContainer();
4331 const htmlContainer = getHtmlContainer();
4332 if (!container || !htmlContainer) {
4333 return false;
4334 }
4335 if (isStylus(event) || isZoom(event)) {
4336 return false;
4337 }
4338 if (target === container) {
4339 return true;
4340 }
4341 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4342 // #2823
4343 target.tagName !== 'INPUT' &&
4344 // #1603
4345 target.tagName !== 'TEXTAREA' &&
4346 // #2266
4347 !(isScrollable(htmlContainer) &&
4348 // #1944
4349 htmlContainer.contains(target))) {
4350 return true;
4351 }
4352 return false;
4353 };
4354
4355 /**
4356 * https://github.com/sweetalert2/sweetalert2/issues/1786
4357 *
4358 * @param {TouchEvent} event
4359 * @returns {boolean}
4360 */
4361 const isStylus = event => {
4362 return Boolean(event.touches && event.touches.length &&
4363 // @ts-ignore - touchType is not a standard property
4364 event.touches[0].touchType === 'stylus');
4365 };
4366
4367 /**
4368 * https://github.com/sweetalert2/sweetalert2/issues/1891
4369 *
4370 * @param {TouchEvent} event
4371 * @returns {boolean}
4372 */
4373 const isZoom = event => {
4374 return event.touches && event.touches.length > 1;
4375 };
4376 const undoIOSfix = () => {
4377 if (hasClass(document.body, swalClasses.iosfix)) {
4378 const offset = parseInt(document.body.style.top, 10);
4379 removeClass(document.body, swalClasses.iosfix);
4380 document.body.style.top = '';
4381 document.body.scrollTop = offset * -1;
4382 }
4383 };
4384
4385 /**
4386 * Measure scrollbar width for padding body during modal show/hide
4387 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4388 *
4389 * @returns {number}
4390 */
4391 const measureScrollbar = () => {
4392 const scrollDiv = document.createElement('div');
4393 scrollDiv.className = swalClasses['scrollbar-measure'];
4394 document.body.appendChild(scrollDiv);
4395 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4396 document.body.removeChild(scrollDiv);
4397 return scrollbarWidth;
4398 };
4399
4400 /**
4401 * Remember state in cases where opening and handling a modal will fiddle with it.
4402 * @type {number | null}
4403 */
4404 let previousBodyPadding = null;
4405
4406 /**
4407 * @param {string} initialBodyOverflow
4408 */
4409 const replaceScrollbarWithPadding = initialBodyOverflow => {
4410 // for queues, do not do this more than once
4411 if (previousBodyPadding !== null) {
4412 return;
4413 }
4414 // if the body has overflow
4415 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4416 ) {
4417 // add padding so the content doesn't shift after removal of scrollbar
4418 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4419 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4420 }
4421 };
4422 const undoReplaceScrollbarWithPadding = () => {
4423 if (previousBodyPadding !== null) {
4424 document.body.style.paddingRight = `${previousBodyPadding}px`;
4425 previousBodyPadding = null;
4426 }
4427 };
4428
4429 /**
4430 * @param {SweetAlert} instance
4431 * @param {HTMLElement} container
4432 * @param {boolean} returnFocus
4433 * @param {(() => void) | undefined} didClose
4434 */
4435 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4436 if (isToast()) {
4437 triggerDidCloseAndDispose(instance, didClose);
4438 } else {
4439 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4440 removeKeydownHandler(globalState);
4441 }
4442
4443 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4444 // for some reason removing the container in Safari will scroll the document to bottom
4445 if (isSafariOrIOS) {
4446 container.setAttribute('style', 'display:none !important');
4447 container.removeAttribute('class');
4448 container.innerHTML = '';
4449 } else {
4450 container.remove();
4451 }
4452 if (isModal()) {
4453 undoReplaceScrollbarWithPadding();
4454 undoIOSfix();
4455 unsetAriaHidden();
4456 }
4457 removeBodyClasses();
4458 }
4459
4460 /**
4461 * Remove SweetAlert2 classes from body
4462 */
4463 function removeBodyClasses() {
4464 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4465 }
4466
4467 /**
4468 * Instance method to close sweetAlert
4469 *
4470 * @param {SweetAlertResult | undefined} resolveValue
4471 * @this {SweetAlert}
4472 */
4473 function close(resolveValue) {
4474 resolveValue = prepareResolveValue(resolveValue);
4475 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4476 const didClose = triggerClosePopup(this);
4477 if (this.isAwaitingPromise) {
4478 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4479 if (!resolveValue.isDismissed) {
4480 handleAwaitingPromise(this);
4481 swalPromiseResolve(resolveValue);
4482 }
4483 } else if (didClose) {
4484 // Resolve Swal promise
4485 swalPromiseResolve(resolveValue);
4486 }
4487 }
4488
4489 /**
4490 * @param {SweetAlert} instance
4491 * @returns {boolean}
4492 */
4493 const triggerClosePopup = instance => {
4494 const popup = getPopup();
4495 if (!popup) {
4496 return false;
4497 }
4498 const innerParams = privateProps.innerParams.get(instance);
4499 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4500 return false;
4501 }
4502 removeClass(popup, innerParams.showClass.popup);
4503 addClass(popup, innerParams.hideClass.popup);
4504 const backdrop = getContainer();
4505 removeClass(backdrop, innerParams.showClass.backdrop);
4506 addClass(backdrop, innerParams.hideClass.backdrop);
4507 handlePopupAnimation(instance, popup, innerParams);
4508 return true;
4509 };
4510
4511 /**
4512 * @param {Error | string} error
4513 * @this {SweetAlert}
4514 */
4515 function rejectPromise(error) {
4516 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4517 handleAwaitingPromise(this);
4518 if (rejectPromise) {
4519 // Reject Swal promise
4520 rejectPromise(error);
4521 }
4522 }
4523
4524 /**
4525 * @param {SweetAlert} instance
4526 */
4527 const handleAwaitingPromise = instance => {
4528 if (instance.isAwaitingPromise) {
4529 // @ts-ignore
4530 delete instance.isAwaitingPromise;
4531 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4532 if (!privateProps.innerParams.get(instance)) {
4533 instance._destroy();
4534 }
4535 }
4536 };
4537
4538 /**
4539 * @param {SweetAlertResult | undefined} resolveValue
4540 * @returns {SweetAlertResult}
4541 */
4542 const prepareResolveValue = resolveValue => {
4543 // When user calls Swal.close()
4544 if (typeof resolveValue === 'undefined') {
4545 return {
4546 isConfirmed: false,
4547 isDenied: false,
4548 isDismissed: true
4549 };
4550 }
4551 return Object.assign({
4552 isConfirmed: false,
4553 isDenied: false,
4554 isDismissed: false
4555 }, resolveValue);
4556 };
4557
4558 /**
4559 * @param {SweetAlert} instance
4560 * @param {HTMLElement} popup
4561 * @param {SweetAlertOptions} innerParams
4562 */
4563 const handlePopupAnimation = (instance, popup, innerParams) => {
4564 var _globalState$eventEmi;
4565 const container = getContainer();
4566 // If animation is supported, animate
4567 const animationIsSupported = hasCssAnimation(popup);
4568 if (typeof innerParams.willClose === 'function') {
4569 innerParams.willClose(popup);
4570 }
4571 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4572 if (animationIsSupported && container) {
4573 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4574 } else if (container) {
4575 // Otherwise, remove immediately
4576 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4577 }
4578 };
4579
4580 /**
4581 * @param {SweetAlert} instance
4582 * @param {HTMLElement} popup
4583 * @param {HTMLElement} container
4584 * @param {boolean} returnFocus
4585 * @param {(() => void) | undefined} didClose
4586 */
4587 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4588 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4589 /**
4590 * @param {AnimationEvent | TransitionEvent} e
4591 */
4592 const swalCloseAnimationFinished = function (e) {
4593 if (e.target === popup) {
4594 var _globalState$swalClos;
4595 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4596 delete globalState.swalCloseEventFinishedCallback;
4597 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4598 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4599 }
4600 };
4601 popup.addEventListener('animationend', swalCloseAnimationFinished);
4602 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4603 };
4604
4605 /**
4606 * @param {SweetAlert} instance
4607 * @param {(() => void) | undefined} didClose
4608 */
4609 const triggerDidCloseAndDispose = (instance, didClose) => {
4610 setTimeout(() => {
4611 var _globalState$eventEmi2;
4612 if (typeof didClose === 'function') {
4613 didClose.bind(instance.params)();
4614 }
4615 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4616 // instance might have been destroyed already
4617 if (instance._destroy) {
4618 instance._destroy();
4619 }
4620 });
4621 };
4622
4623 /**
4624 * Shows loader (spinner), this is useful with AJAX requests.
4625 * By default the loader be shown instead of the "Confirm" button.
4626 *
4627 * @param {HTMLButtonElement | null} [buttonToReplace]
4628 */
4629 const showLoading = buttonToReplace => {
4630 let popup = getPopup();
4631 if (!popup) {
4632 new Swal();
4633 }
4634 popup = getPopup();
4635 if (!popup) {
4636 return;
4637 }
4638 const loader = getLoader();
4639 if (isToast()) {
4640 hide(getIcon());
4641 } else {
4642 replaceButton(popup, buttonToReplace);
4643 }
4644 show(loader);
4645 popup.setAttribute('data-loading', 'true');
4646 popup.setAttribute('aria-busy', 'true');
4647 popup.focus();
4648 };
4649
4650 /**
4651 * @param {HTMLElement} popup
4652 * @param {HTMLButtonElement | null} [buttonToReplace]
4653 */
4654 const replaceButton = (popup, buttonToReplace) => {
4655 const actions = getActions();
4656 const loader = getLoader();
4657 if (!actions || !loader) {
4658 return;
4659 }
4660 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4661 buttonToReplace = getConfirmButton();
4662 }
4663 show(actions);
4664 if (buttonToReplace) {
4665 hide(buttonToReplace);
4666 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4667 actions.insertBefore(loader, buttonToReplace);
4668 }
4669 addClass([popup, actions], swalClasses.loading);
4670 };
4671
4672 /**
4673 * @param {SweetAlert} instance
4674 * @param {SweetAlertOptions} params
4675 */
4676 const handleInputOptionsAndValue = (instance, params) => {
4677 if (params.input === 'select' || params.input === 'radio') {
4678 handleInputOptions(instance, params);
4679 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4680 showLoading(getConfirmButton());
4681 handleInputValue(instance, params);
4682 }
4683 };
4684
4685 /**
4686 * @param {SweetAlert} instance
4687 * @param {SweetAlertOptions} innerParams
4688 * @returns {SweetAlertInputValue}
4689 */
4690 const getInputValue = (instance, innerParams) => {
4691 const input = instance.getInput();
4692 if (!input) {
4693 return null;
4694 }
4695 switch (innerParams.input) {
4696 case 'checkbox':
4697 return getCheckboxValue(input);
4698 case 'radio':
4699 return getRadioValue(input);
4700 case 'file':
4701 return getFileValue(input);
4702 default:
4703 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4704 }
4705 };
4706
4707 /**
4708 * @param {HTMLInputElement} input
4709 * @returns {number}
4710 */
4711 const getCheckboxValue = input => input.checked ? 1 : 0;
4712
4713 /**
4714 * @param {HTMLInputElement} input
4715 * @returns {string | null}
4716 */
4717 const getRadioValue = input => input.checked ? input.value : null;
4718
4719 /**
4720 * @param {HTMLInputElement} input
4721 * @returns {FileList | File | null}
4722 */
4723 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4724
4725 /**
4726 * @param {SweetAlert} instance
4727 * @param {SweetAlertOptions} params
4728 */
4729 const handleInputOptions = (instance, params) => {
4730 const popup = getPopup();
4731 if (!popup) {
4732 return;
4733 }
4734 /**
4735 * @param {*} inputOptions
4736 */
4737 const processInputOptions = inputOptions => {
4738 if (params.input === 'select') {
4739 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4740 } else if (params.input === 'radio') {
4741 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4742 }
4743 };
4744 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4745 showLoading(getConfirmButton());
4746 asPromise(params.inputOptions).then(inputOptions => {
4747 instance.hideLoading();
4748 processInputOptions(inputOptions);
4749 });
4750 } else if (typeof params.inputOptions === 'object') {
4751 processInputOptions(params.inputOptions);
4752 } else {
4753 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4754 }
4755 };
4756
4757 /**
4758 * @param {SweetAlert} instance
4759 * @param {SweetAlertOptions} params
4760 */
4761 const handleInputValue = (instance, params) => {
4762 const input = instance.getInput();
4763 if (!input) {
4764 return;
4765 }
4766 hide(input);
4767 asPromise(params.inputValue).then(inputValue => {
4768 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4769 show(input);
4770 input.focus();
4771 instance.hideLoading();
4772 }).catch(err => {
4773 error(`Error in inputValue promise: ${err}`);
4774 input.value = '';
4775 show(input);
4776 input.focus();
4777 instance.hideLoading();
4778 });
4779 };
4780
4781 /**
4782 * @param {HTMLElement} popup
4783 * @param {InputOptionFlattened[]} inputOptions
4784 * @param {SweetAlertOptions} params
4785 */
4786 function populateSelectOptions(popup, inputOptions, params) {
4787 const select = getDirectChildByClass(popup, swalClasses.select);
4788 if (!select) {
4789 return;
4790 }
4791 /**
4792 * @param {HTMLElement} parent
4793 * @param {string} optionLabel
4794 * @param {string} optionValue
4795 */
4796 const renderOption = (parent, optionLabel, optionValue) => {
4797 const option = document.createElement('option');
4798 option.value = optionValue;
4799 setInnerHtml(option, optionLabel);
4800 option.selected = isSelected(optionValue, params.inputValue);
4801 parent.appendChild(option);
4802 };
4803 inputOptions.forEach(inputOption => {
4804 const optionValue = inputOption[0];
4805 const optionLabel = inputOption[1];
4806 // <optgroup> spec:
4807 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4808 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4809 // check whether this is a <optgroup>
4810 if (Array.isArray(optionLabel)) {
4811 // if it is an array, then it is an <optgroup>
4812 const optgroup = document.createElement('optgroup');
4813 optgroup.label = optionValue;
4814 optgroup.disabled = false; // not configurable for now
4815 select.appendChild(optgroup);
4816 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4817 } else {
4818 // case of <option>
4819 renderOption(select, optionLabel, optionValue);
4820 }
4821 });
4822 select.focus();
4823 }
4824
4825 /**
4826 * @param {HTMLElement} popup
4827 * @param {InputOptionFlattened[]} inputOptions
4828 * @param {SweetAlertOptions} params
4829 */
4830 function populateRadioOptions(popup, inputOptions, params) {
4831 const radio = getDirectChildByClass(popup, swalClasses.radio);
4832 if (!radio) {
4833 return;
4834 }
4835 inputOptions.forEach(inputOption => {
4836 const radioValue = inputOption[0];
4837 const radioLabel = inputOption[1];
4838 const radioInput = document.createElement('input');
4839 const radioLabelElement = document.createElement('label');
4840 radioInput.type = 'radio';
4841 radioInput.name = swalClasses.radio;
4842 radioInput.value = radioValue;
4843 if (isSelected(radioValue, params.inputValue)) {
4844 radioInput.checked = true;
4845 }
4846 const label = document.createElement('span');
4847 setInnerHtml(label, radioLabel);
4848 label.className = swalClasses.label;
4849 radioLabelElement.appendChild(radioInput);
4850 radioLabelElement.appendChild(label);
4851 radio.appendChild(radioLabelElement);
4852 });
4853 const radios = radio.querySelectorAll('input');
4854 if (radios.length) {
4855 radios[0].focus();
4856 }
4857 }
4858
4859 /**
4860 * Converts `inputOptions` into an array of `[value, label]`s
4861 *
4862 * @param {*} inputOptions
4863 * @typedef {string[]} InputOptionFlattened
4864 * @returns {InputOptionFlattened[]}
4865 */
4866 const formatInputOptions = inputOptions => {
4867 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
4868 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
4869 };
4870
4871 /**
4872 * @param {string} optionValue
4873 * @param {SweetAlertInputValue} inputValue
4874 * @returns {boolean}
4875 */
4876 const isSelected = (optionValue, inputValue) => Boolean(inputValue) && inputValue != null && inputValue.toString() === optionValue.toString();
4877
4878 /**
4879 * @param {SweetAlert} instance
4880 */
4881 const handleConfirmButtonClick = instance => {
4882 const innerParams = privateProps.innerParams.get(instance);
4883 instance.disableButtons();
4884 if (innerParams.input) {
4885 handleConfirmOrDenyWithInput(instance, 'confirm');
4886 } else {
4887 confirm(instance, true);
4888 }
4889 };
4890
4891 /**
4892 * @param {SweetAlert} instance
4893 */
4894 const handleDenyButtonClick = instance => {
4895 const innerParams = privateProps.innerParams.get(instance);
4896 instance.disableButtons();
4897 if (innerParams.returnInputValueOnDeny) {
4898 handleConfirmOrDenyWithInput(instance, 'deny');
4899 } else {
4900 deny(instance, false);
4901 }
4902 };
4903
4904 /**
4905 * @param {SweetAlert} instance
4906 * @param {(dismiss: DismissReason) => void} dismissWith
4907 */
4908 const handleCancelButtonClick = (instance, dismissWith) => {
4909 instance.disableButtons();
4910 dismissWith(DismissReason.cancel);
4911 };
4912
4913 /**
4914 * @param {SweetAlert} instance
4915 * @param {'confirm' | 'deny'} type
4916 */
4917 const handleConfirmOrDenyWithInput = (instance, type) => {
4918 const innerParams = privateProps.innerParams.get(instance);
4919 if (!innerParams.input) {
4920 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4921 return;
4922 }
4923 const input = instance.getInput();
4924 const inputValue = getInputValue(instance, innerParams);
4925 if (innerParams.inputValidator) {
4926 handleInputValidator(instance, inputValue, type);
4927 } else if (input && !input.checkValidity()) {
4928 instance.enableButtons();
4929 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4930 } else if (type === 'deny') {
4931 deny(instance, inputValue);
4932 } else {
4933 confirm(instance, inputValue);
4934 }
4935 };
4936
4937 /**
4938 * @param {SweetAlert} instance
4939 * @param {SweetAlertInputValue} inputValue
4940 * @param {'confirm' | 'deny'} type
4941 */
4942 const handleInputValidator = (instance, inputValue, type) => {
4943 const innerParams = privateProps.innerParams.get(instance);
4944 instance.disableInput();
4945 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4946 validationPromise.then(validationMessage => {
4947 instance.enableButtons();
4948 instance.enableInput();
4949 if (validationMessage) {
4950 instance.showValidationMessage(validationMessage);
4951 } else if (type === 'deny') {
4952 deny(instance, inputValue);
4953 } else {
4954 confirm(instance, inputValue);
4955 }
4956 });
4957 };
4958
4959 /**
4960 * @param {SweetAlert} instance
4961 * @param {*} value
4962 */
4963 const deny = (instance, value) => {
4964 const innerParams = privateProps.innerParams.get(instance);
4965 if (innerParams.showLoaderOnDeny) {
4966 showLoading(getDenyButton());
4967 }
4968 if (innerParams.preDeny) {
4969 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
4970 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
4971 preDenyPromise.then(preDenyValue => {
4972 if (preDenyValue === false) {
4973 instance.hideLoading();
4974 handleAwaitingPromise(instance);
4975 } else {
4976 instance.close(/** @type SweetAlertResult */{
4977 isDenied: true,
4978 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
4979 });
4980 }
4981 }).catch(error => rejectWith(instance, error));
4982 } else {
4983 instance.close(/** @type SweetAlertResult */{
4984 isDenied: true,
4985 value
4986 });
4987 }
4988 };
4989
4990 /**
4991 * @param {SweetAlert} instance
4992 * @param {*} value
4993 */
4994 const succeedWith = (instance, value) => {
4995 instance.close(/** @type SweetAlertResult */{
4996 isConfirmed: true,
4997 value
4998 });
4999 };
5000
5001 /**
5002 *
5003 * @param {SweetAlert} instance
5004 * @param {string} error
5005 */
5006 const rejectWith = (instance, error) => {
5007 instance.rejectPromise(error);
5008 };
5009
5010 /**
5011 *
5012 * @param {SweetAlert} instance
5013 * @param {*} value
5014 */
5015 const confirm = (instance, value) => {
5016 const innerParams = privateProps.innerParams.get(instance);
5017 if (innerParams.showLoaderOnConfirm) {
5018 showLoading();
5019 }
5020 if (innerParams.preConfirm) {
5021 instance.resetValidationMessage();
5022 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
5023 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5024 preConfirmPromise.then(preConfirmValue => {
5025 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5026 instance.hideLoading();
5027 handleAwaitingPromise(instance);
5028 } else {
5029 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5030 }
5031 }).catch(error => rejectWith(instance, error));
5032 } else {
5033 succeedWith(instance, value);
5034 }
5035 };
5036
5037 /**
5038 * Hides loader and shows back the button which was hidden by .showLoading()
5039 * @this {SweetAlert}
5040 */
5041 function hideLoading() {
5042 // do nothing if popup is closed
5043 const innerParams = privateProps.innerParams.get(this);
5044 if (!innerParams) {
5045 return;
5046 }
5047 const domCache = privateProps.domCache.get(this);
5048 hide(domCache.loader);
5049 if (isToast()) {
5050 if (innerParams.icon) {
5051 show(getIcon());
5052 }
5053 } else {
5054 showRelatedButton(domCache);
5055 }
5056 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5057 domCache.popup.removeAttribute('aria-busy');
5058 domCache.popup.removeAttribute('data-loading');
5059 this.enableButtons();
5060 }
5061
5062 /**
5063 * @param {DomCache} domCache
5064 */
5065 const showRelatedButton = domCache => {
5066 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5067 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5068 if (buttonToReplace.length) {
5069 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5070 } else if (allButtonsAreHidden()) {
5071 hide(domCache.actions);
5072 }
5073 };
5074
5075 /**
5076 * Gets the input DOM node, this method works with input parameter.
5077 *
5078 * @returns {HTMLInputElement | null}
5079 * @this {SweetAlert}
5080 */
5081 function getInput() {
5082 const innerParams = privateProps.innerParams.get(this);
5083 const domCache = privateProps.domCache.get(this);
5084 if (!domCache) {
5085 return null;
5086 }
5087 return getInput$1(domCache.popup, innerParams.input);
5088 }
5089
5090 /**
5091 * @param {SweetAlert} instance
5092 * @param {string[]} buttons
5093 * @param {boolean} disabled
5094 */
5095 function setButtonsDisabled(instance, buttons, disabled) {
5096 const domCache = privateProps.domCache.get(instance);
5097 buttons.forEach(button => {
5098 domCache[button].disabled = disabled;
5099 });
5100 }
5101
5102 /**
5103 * @param {HTMLInputElement | null} input
5104 * @param {boolean} disabled
5105 */
5106 function setInputDisabled(input, disabled) {
5107 const popup = getPopup();
5108 if (!popup || !input) {
5109 return;
5110 }
5111 if (input.type === 'radio') {
5112 /** @type {NodeListOf<HTMLInputElement>} */
5113 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5114 radios.forEach(radio => {
5115 radio.disabled = disabled;
5116 });
5117 } else {
5118 input.disabled = disabled;
5119 }
5120 }
5121
5122 /**
5123 * Enable all the buttons
5124 * @this {SweetAlert}
5125 */
5126 function enableButtons() {
5127 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5128 const focusedElement = privateProps.focusedElement.get(this);
5129 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
5130 focusedElement.focus();
5131 }
5132 privateProps.focusedElement.delete(this);
5133 }
5134
5135 /**
5136 * Disable all the buttons
5137 * @this {SweetAlert}
5138 */
5139 function disableButtons() {
5140 privateProps.focusedElement.set(this, document.activeElement);
5141 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5142 }
5143
5144 /**
5145 * Enable the input field
5146 * @this {SweetAlert}
5147 */
5148 function enableInput() {
5149 setInputDisabled(this.getInput(), false);
5150 }
5151
5152 /**
5153 * Disable the input field
5154 * @this {SweetAlert}
5155 */
5156 function disableInput() {
5157 setInputDisabled(this.getInput(), true);
5158 }
5159
5160 /**
5161 * Show block with validation message
5162 *
5163 * @param {string} error
5164 * @this {SweetAlert}
5165 */
5166 function showValidationMessage(error) {
5167 const domCache = privateProps.domCache.get(this);
5168 const params = privateProps.innerParams.get(this);
5169 setInnerHtml(domCache.validationMessage, error);
5170 domCache.validationMessage.className = swalClasses['validation-message'];
5171 if (params.customClass && params.customClass.validationMessage) {
5172 addClass(domCache.validationMessage, params.customClass.validationMessage);
5173 }
5174 show(domCache.validationMessage);
5175 const input = this.getInput();
5176 if (input) {
5177 input.setAttribute('aria-invalid', 'true');
5178 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5179 focusInput(input);
5180 addClass(input, swalClasses.inputerror);
5181 }
5182 }
5183
5184 /**
5185 * Hide block with validation message
5186 *
5187 * @this {SweetAlert}
5188 */
5189 function resetValidationMessage() {
5190 const domCache = privateProps.domCache.get(this);
5191 if (domCache.validationMessage) {
5192 hide(domCache.validationMessage);
5193 }
5194 const input = this.getInput();
5195 if (input) {
5196 input.removeAttribute('aria-invalid');
5197 input.removeAttribute('aria-describedby');
5198 removeClass(input, swalClasses.inputerror);
5199 }
5200 }
5201
5202 const defaultParams = {
5203 title: '',
5204 titleText: '',
5205 text: '',
5206 html: '',
5207 footer: '',
5208 icon: undefined,
5209 iconColor: undefined,
5210 iconHtml: undefined,
5211 template: undefined,
5212 toast: false,
5213 draggable: false,
5214 animation: true,
5215 theme: 'light',
5216 showClass: {
5217 popup: 'swal2-show',
5218 backdrop: 'swal2-backdrop-show',
5219 icon: 'swal2-icon-show'
5220 },
5221 hideClass: {
5222 popup: 'swal2-hide',
5223 backdrop: 'swal2-backdrop-hide',
5224 icon: 'swal2-icon-hide'
5225 },
5226 customClass: {},
5227 target: 'body',
5228 color: undefined,
5229 backdrop: true,
5230 heightAuto: true,
5231 allowOutsideClick: true,
5232 allowEscapeKey: true,
5233 allowEnterKey: true,
5234 stopKeydownPropagation: true,
5235 keydownListenerCapture: false,
5236 showConfirmButton: true,
5237 showDenyButton: false,
5238 showCancelButton: false,
5239 preConfirm: undefined,
5240 preDeny: undefined,
5241 confirmButtonText: 'OK',
5242 confirmButtonAriaLabel: '',
5243 confirmButtonColor: undefined,
5244 denyButtonText: 'No',
5245 denyButtonAriaLabel: '',
5246 denyButtonColor: undefined,
5247 cancelButtonText: 'Cancel',
5248 cancelButtonAriaLabel: '',
5249 cancelButtonColor: undefined,
5250 buttonsStyling: true,
5251 reverseButtons: false,
5252 focusConfirm: true,
5253 focusDeny: false,
5254 focusCancel: false,
5255 returnFocus: true,
5256 showCloseButton: false,
5257 closeButtonHtml: '&times;',
5258 closeButtonAriaLabel: 'Close this dialog',
5259 loaderHtml: '',
5260 showLoaderOnConfirm: false,
5261 showLoaderOnDeny: false,
5262 imageUrl: undefined,
5263 imageWidth: undefined,
5264 imageHeight: undefined,
5265 imageAlt: '',
5266 timer: undefined,
5267 timerProgressBar: false,
5268 width: undefined,
5269 padding: undefined,
5270 background: undefined,
5271 input: undefined,
5272 inputPlaceholder: '',
5273 inputLabel: '',
5274 inputValue: '',
5275 inputOptions: {},
5276 inputAutoFocus: true,
5277 inputAutoTrim: true,
5278 inputAttributes: {},
5279 inputValidator: undefined,
5280 returnInputValueOnDeny: false,
5281 validationMessage: undefined,
5282 grow: false,
5283 position: 'center',
5284 progressSteps: [],
5285 currentProgressStep: undefined,
5286 progressStepsDistance: undefined,
5287 willOpen: undefined,
5288 didOpen: undefined,
5289 didRender: undefined,
5290 willClose: undefined,
5291 didClose: undefined,
5292 didDestroy: undefined,
5293 scrollbarPadding: true,
5294 topLayer: false
5295 };
5296 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'];
5297
5298 /** @type {Record<string, string | undefined>} */
5299 const deprecatedParams = {
5300 allowEnterKey: undefined
5301 };
5302 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5303
5304 /**
5305 * Is valid parameter
5306 *
5307 * @param {string} paramName
5308 * @returns {boolean}
5309 */
5310 const isValidParameter = paramName => {
5311 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5312 };
5313
5314 /**
5315 * Is valid parameter for Swal.update() method
5316 *
5317 * @param {string} paramName
5318 * @returns {boolean}
5319 */
5320 const isUpdatableParameter = paramName => {
5321 return updatableParams.indexOf(paramName) !== -1;
5322 };
5323
5324 /**
5325 * Is deprecated parameter
5326 *
5327 * @param {string} paramName
5328 * @returns {string | undefined}
5329 */
5330 const isDeprecatedParameter = paramName => {
5331 return deprecatedParams[paramName];
5332 };
5333
5334 /**
5335 * @param {string} param
5336 */
5337 const checkIfParamIsValid = param => {
5338 if (!isValidParameter(param)) {
5339 warn(`Unknown parameter "${param}"`);
5340 }
5341 };
5342
5343 /**
5344 * @param {string} param
5345 */
5346 const checkIfToastParamIsValid = param => {
5347 if (toastIncompatibleParams.includes(param)) {
5348 warn(`The parameter "${param}" is incompatible with toasts`);
5349 }
5350 };
5351
5352 /**
5353 * @param {string} param
5354 */
5355 const checkIfParamIsDeprecated = param => {
5356 const isDeprecated = isDeprecatedParameter(param);
5357 if (isDeprecated) {
5358 warnAboutDeprecation(param, isDeprecated);
5359 }
5360 };
5361
5362 /**
5363 * Show relevant warnings for given params
5364 *
5365 * @param {SweetAlertOptions} params
5366 */
5367 const showWarningsForParams = params => {
5368 if (params.backdrop === false && params.allowOutsideClick) {
5369 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5370 }
5371 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)) {
5372 warn(`Invalid theme "${params.theme}"`);
5373 }
5374 for (const param in params) {
5375 checkIfParamIsValid(param);
5376 if (params.toast) {
5377 checkIfToastParamIsValid(param);
5378 }
5379 checkIfParamIsDeprecated(param);
5380 }
5381 };
5382
5383 /**
5384 * Updates popup parameters.
5385 *
5386 * @this {any}
5387 * @param {SweetAlertOptions} params
5388 */
5389 function update(params) {
5390 const container = getContainer();
5391 const popup = getPopup();
5392 const innerParams = privateProps.innerParams.get(this);
5393 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5394 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.`);
5395 return;
5396 }
5397 const validUpdatableParams = filterValidParams(params);
5398 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5399 showWarningsForParams(updatedParams);
5400 if (container) {
5401 container.dataset['swal2Theme'] = updatedParams.theme;
5402 }
5403 render(this, updatedParams);
5404 privateProps.innerParams.set(this, updatedParams);
5405 Object.defineProperties(this, {
5406 params: {
5407 value: Object.assign({}, this.params, params),
5408 writable: false,
5409 enumerable: true
5410 }
5411 });
5412 }
5413
5414 /**
5415 * @param {SweetAlertOptions} params
5416 * @returns {SweetAlertOptions}
5417 */
5418 const filterValidParams = params => {
5419 /** @type {Record<string, any>} */
5420 const validUpdatableParams = {};
5421 Object.keys(params).forEach(param => {
5422 if (isUpdatableParameter(param)) {
5423 const typedParams = /** @type {Record<string, any>} */params;
5424 validUpdatableParams[param] = typedParams[param];
5425 } else {
5426 warn(`Invalid parameter to update: ${param}`);
5427 }
5428 });
5429 return validUpdatableParams;
5430 };
5431
5432 /**
5433 * Dispose the current SweetAlert2 instance
5434 * @this {SweetAlert}
5435 */
5436 function _destroy() {
5437 var _globalState$eventEmi;
5438 const domCache = privateProps.domCache.get(this);
5439 const innerParams = privateProps.innerParams.get(this);
5440 if (!innerParams) {
5441 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5442 return; // This instance has already been destroyed
5443 }
5444
5445 // Check if there is another Swal closing
5446 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5447 globalState.swalCloseEventFinishedCallback();
5448 delete globalState.swalCloseEventFinishedCallback;
5449 }
5450 if (typeof innerParams.didDestroy === 'function') {
5451 innerParams.didDestroy();
5452 }
5453 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5454 disposeSwal(this);
5455 }
5456
5457 /**
5458 * @param {SweetAlert} instance
5459 */
5460 const disposeSwal = instance => {
5461 disposeWeakMaps(instance);
5462 // Unset this.params so GC will dispose it (#1569)
5463 // @ts-ignore
5464 delete instance.params;
5465 // Unset globalState props so GC will dispose globalState (#1569)
5466 delete globalState.keydownHandler;
5467 delete globalState.keydownTarget;
5468 // Unset currentInstance
5469 delete globalState.currentInstance;
5470 };
5471
5472 /**
5473 * @param {SweetAlert} instance
5474 */
5475 const disposeWeakMaps = instance => {
5476 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5477 if (instance.isAwaitingPromise) {
5478 unsetWeakMaps(privateProps, instance);
5479 instance.isAwaitingPromise = true;
5480 } else {
5481 unsetWeakMaps(privateMethods, instance);
5482 unsetWeakMaps(privateProps, instance);
5483
5484 // @ts-ignore
5485 delete instance.isAwaitingPromise;
5486 // Unset instance methods
5487 // @ts-ignore
5488 delete instance.disableButtons;
5489 // @ts-ignore
5490 delete instance.enableButtons;
5491 // @ts-ignore
5492 delete instance.getInput;
5493 // @ts-ignore
5494 delete instance.disableInput;
5495 // @ts-ignore
5496 delete instance.enableInput;
5497 // @ts-ignore
5498 delete instance.hideLoading;
5499 // @ts-ignore
5500 delete instance.disableLoading;
5501 // @ts-ignore
5502 delete instance.showValidationMessage;
5503 // @ts-ignore
5504 delete instance.resetValidationMessage;
5505 // @ts-ignore
5506 delete instance.close;
5507 // @ts-ignore
5508 delete instance.closePopup;
5509 // @ts-ignore
5510 delete instance.closeModal;
5511 // @ts-ignore
5512 delete instance.closeToast;
5513 // @ts-ignore
5514 delete instance.rejectPromise;
5515 // @ts-ignore
5516 delete instance.update;
5517 // @ts-ignore
5518 delete instance._destroy;
5519 }
5520 };
5521
5522 /**
5523 * @param {Record<string, WeakMap<any, any>>} obj
5524 * @param {SweetAlert} instance
5525 */
5526 const unsetWeakMaps = (obj, instance) => {
5527 for (const i in obj) {
5528 obj[i].delete(instance);
5529 }
5530 };
5531
5532 var instanceMethods = /*#__PURE__*/Object.freeze({
5533 __proto__: null,
5534 _destroy: _destroy,
5535 close: close,
5536 closeModal: close,
5537 closePopup: close,
5538 closeToast: close,
5539 disableButtons: disableButtons,
5540 disableInput: disableInput,
5541 disableLoading: hideLoading,
5542 enableButtons: enableButtons,
5543 enableInput: enableInput,
5544 getInput: getInput,
5545 handleAwaitingPromise: handleAwaitingPromise,
5546 hideLoading: hideLoading,
5547 rejectPromise: rejectPromise,
5548 resetValidationMessage: resetValidationMessage,
5549 showValidationMessage: showValidationMessage,
5550 update: update
5551 });
5552
5553 /**
5554 * @param {SweetAlertOptions} innerParams
5555 * @param {DomCache} domCache
5556 * @param {(dismiss: DismissReason) => void} dismissWith
5557 */
5558 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5559 if (innerParams.toast) {
5560 handleToastClick(innerParams, domCache, dismissWith);
5561 } else {
5562 // Ignore click events that had mousedown on the popup but mouseup on the container
5563 // This can happen when the user drags a slider
5564 handleModalMousedown(domCache);
5565
5566 // Ignore click events that had mousedown on the container but mouseup on the popup
5567 handleContainerMousedown(domCache);
5568 handleModalClick(innerParams, domCache, dismissWith);
5569 }
5570 };
5571
5572 /**
5573 * @param {SweetAlertOptions} innerParams
5574 * @param {DomCache} domCache
5575 * @param {(dismiss: DismissReason) => void} dismissWith
5576 */
5577 const handleToastClick = (innerParams, domCache, dismissWith) => {
5578 // Closing toast by internal click
5579 domCache.popup.onclick = () => {
5580 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5581 return;
5582 }
5583 dismissWith(DismissReason.close);
5584 };
5585 };
5586
5587 /**
5588 * @param {SweetAlertOptions} innerParams
5589 * @returns {boolean}
5590 */
5591 const isAnyButtonShown = innerParams => {
5592 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5593 };
5594 let ignoreOutsideClick = false;
5595
5596 /**
5597 * @param {DomCache} domCache
5598 */
5599 const handleModalMousedown = domCache => {
5600 domCache.popup.onmousedown = () => {
5601 domCache.container.onmouseup = function (e) {
5602 domCache.container.onmouseup = () => {};
5603 // We only check if the mouseup target is the container because usually it doesn't
5604 // have any other direct children aside of the popup
5605 if (e.target === domCache.container) {
5606 ignoreOutsideClick = true;
5607 }
5608 };
5609 };
5610 };
5611
5612 /**
5613 * @param {DomCache} domCache
5614 */
5615 const handleContainerMousedown = domCache => {
5616 domCache.container.onmousedown = e => {
5617 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5618 if (e.target === domCache.container) {
5619 e.preventDefault();
5620 }
5621 domCache.popup.onmouseup = function (e) {
5622 domCache.popup.onmouseup = () => {};
5623 // We also need to check if the mouseup target is a child of the popup
5624 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5625 ignoreOutsideClick = true;
5626 }
5627 };
5628 };
5629 };
5630
5631 /**
5632 * @param {SweetAlertOptions} innerParams
5633 * @param {DomCache} domCache
5634 * @param {(dismiss: DismissReason) => void} dismissWith
5635 */
5636 const handleModalClick = (innerParams, domCache, dismissWith) => {
5637 domCache.container.onclick = e => {
5638 if (ignoreOutsideClick) {
5639 ignoreOutsideClick = false;
5640 return;
5641 }
5642 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5643 dismissWith(DismissReason.backdrop);
5644 }
5645 };
5646 };
5647
5648 /**
5649 * @param {unknown} elem
5650 * @returns {boolean}
5651 */
5652 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
5653
5654 /**
5655 * @param {unknown} elem
5656 * @returns {boolean}
5657 */
5658 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5659
5660 /**
5661 * @param {ReadonlyArray<unknown>} args
5662 * @returns {SweetAlertOptions}
5663 */
5664 const argsToParams = args => {
5665 /** @type {Record<string, unknown>} */
5666 const params = {};
5667 if (typeof args[0] === 'object' && !isElement(args[0])) {
5668 Object.assign(params, args[0]);
5669 } else {
5670 ['title', 'html', 'icon'].forEach((name, index) => {
5671 const arg = args[index];
5672 if (typeof arg === 'string' || isElement(arg)) {
5673 params[name] = arg;
5674 } else if (arg !== undefined) {
5675 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5676 }
5677 });
5678 }
5679 return /** @type {SweetAlertOptions} */params;
5680 };
5681
5682 /**
5683 * Main method to create a new SweetAlert2 popup
5684 *
5685 * @this {new (...args: any[]) => any}
5686 * @param {...SweetAlertOptions} args
5687 * @returns {Promise<SweetAlertResult>}
5688 */
5689 function fire(...args) {
5690 return new this(...args);
5691 }
5692
5693 /**
5694 * Returns an extended version of `Swal` containing `params` as defaults.
5695 * Useful for reusing Swal configuration.
5696 *
5697 * For example:
5698 *
5699 * Before:
5700 * const textPromptOptions = { input: 'text', showCancelButton: true }
5701 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5702 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5703 *
5704 * After:
5705 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5706 * const {value: firstName} = await TextPrompt('What is your first name?')
5707 * const {value: lastName} = await TextPrompt('What is your last name?')
5708 *
5709 * @param {SweetAlertOptions} mixinParams
5710 * @returns {SweetAlert}
5711 * @this {typeof import('../SweetAlert.js').SweetAlert}
5712 */
5713 function mixin(mixinParams) {
5714 // @ts-ignore: 'this' refers to the SweetAlert constructor
5715 class MixinSwal extends this {
5716 /**
5717 * @param {any} params
5718 * @param {any} priorityMixinParams
5719 */
5720 _main(params, priorityMixinParams) {
5721 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5722 }
5723 }
5724 // @ts-ignore
5725 return MixinSwal;
5726 }
5727
5728 /**
5729 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5730 * Otherwise, returns undefined.
5731 *
5732 * @returns {number | undefined}
5733 */
5734 const getTimerLeft = () => {
5735 return globalState.timeout && globalState.timeout.getTimerLeft();
5736 };
5737
5738 /**
5739 * Stop timer. Returns number of milliseconds of timer remained.
5740 * If `timer` parameter isn't set, returns undefined.
5741 *
5742 * @returns {number | undefined}
5743 */
5744 const stopTimer = () => {
5745 if (globalState.timeout) {
5746 stopTimerProgressBar();
5747 return globalState.timeout.stop();
5748 }
5749 };
5750
5751 /**
5752 * Resume timer. Returns number of milliseconds of timer remained.
5753 * If `timer` parameter isn't set, returns undefined.
5754 *
5755 * @returns {number | undefined}
5756 */
5757 const resumeTimer = () => {
5758 if (globalState.timeout) {
5759 const remaining = globalState.timeout.start();
5760 animateTimerProgressBar(remaining);
5761 return remaining;
5762 }
5763 };
5764
5765 /**
5766 * Resume timer. Returns number of milliseconds of timer remained.
5767 * If `timer` parameter isn't set, returns undefined.
5768 *
5769 * @returns {number | undefined}
5770 */
5771 const toggleTimer = () => {
5772 const timer = globalState.timeout;
5773 return timer && (timer.running ? stopTimer() : resumeTimer());
5774 };
5775
5776 /**
5777 * Increase timer. Returns number of milliseconds of an updated timer.
5778 * If `timer` parameter isn't set, returns undefined.
5779 *
5780 * @param {number} ms
5781 * @returns {number | undefined}
5782 */
5783 const increaseTimer = ms => {
5784 if (globalState.timeout) {
5785 const remaining = globalState.timeout.increase(ms);
5786 animateTimerProgressBar(remaining, true);
5787 return remaining;
5788 }
5789 };
5790
5791 /**
5792 * Check if timer is running. Returns true if timer is running
5793 * or false if timer is paused or stopped.
5794 * If `timer` parameter isn't set, returns undefined
5795 *
5796 * @returns {boolean}
5797 */
5798 const isTimerRunning = () => {
5799 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5800 };
5801
5802 let bodyClickListenerAdded = false;
5803 /** @type {Record<string, any>} */
5804 const clickHandlers = {};
5805
5806 /**
5807 * @this {any}
5808 * @param {string} attr
5809 */
5810 function bindClickHandler(attr = 'data-swal-template') {
5811 clickHandlers[attr] = this;
5812 if (!bodyClickListenerAdded) {
5813 document.body.addEventListener('click', bodyClickListener);
5814 bodyClickListenerAdded = true;
5815 }
5816 }
5817
5818 /**
5819 * @param {MouseEvent} event
5820 */
5821 const bodyClickListener = event => {
5822 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5823 for (const attr in clickHandlers) {
5824 const template = el.getAttribute && el.getAttribute(attr);
5825 if (template) {
5826 clickHandlers[attr].fire({
5827 template
5828 });
5829 return;
5830 }
5831 }
5832 }
5833 };
5834
5835 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5836
5837 class EventEmitter {
5838 constructor() {
5839 /** @type {Events} */
5840 this.events = {};
5841 }
5842
5843 /**
5844 * @param {string} eventName
5845 * @returns {EventHandlers}
5846 */
5847 _getHandlersByEventName(eventName) {
5848 if (typeof this.events[eventName] === 'undefined') {
5849 // not Set because we need to keep the FIFO order
5850 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5851 this.events[eventName] = [];
5852 }
5853 return this.events[eventName];
5854 }
5855
5856 /**
5857 * @param {string} eventName
5858 * @param {EventHandler} eventHandler
5859 */
5860 on(eventName, eventHandler) {
5861 const currentHandlers = this._getHandlersByEventName(eventName);
5862 if (!currentHandlers.includes(eventHandler)) {
5863 currentHandlers.push(eventHandler);
5864 }
5865 }
5866
5867 /**
5868 * @param {string} eventName
5869 * @param {EventHandler} eventHandler
5870 */
5871 once(eventName, eventHandler) {
5872 /**
5873 * @param {...any} args
5874 */
5875 const onceFn = (...args) => {
5876 this.removeListener(eventName, onceFn);
5877 // @ts-ignore
5878 eventHandler.apply(this, args);
5879 };
5880 this.on(eventName, onceFn);
5881 }
5882
5883 /**
5884 * @param {string} eventName
5885 * @param {...any} args
5886 */
5887 emit(eventName, ...args) {
5888 this._getHandlersByEventName(eventName).forEach(
5889 /**
5890 * @param {EventHandler} eventHandler
5891 */
5892 eventHandler => {
5893 try {
5894 // @ts-ignore
5895 eventHandler.apply(this, args);
5896 } catch (error) {
5897 console.error(error);
5898 }
5899 });
5900 }
5901
5902 /**
5903 * @param {string} eventName
5904 * @param {EventHandler} eventHandler
5905 */
5906 removeListener(eventName, eventHandler) {
5907 const currentHandlers = this._getHandlersByEventName(eventName);
5908 const index = currentHandlers.indexOf(eventHandler);
5909 if (index > -1) {
5910 currentHandlers.splice(index, 1);
5911 }
5912 }
5913
5914 /**
5915 * @param {string} eventName
5916 */
5917 removeAllListeners(eventName) {
5918 if (this.events[eventName] !== undefined) {
5919 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5920 this.events[eventName].length = 0;
5921 }
5922 }
5923 reset() {
5924 this.events = {};
5925 }
5926 }
5927
5928 globalState.eventEmitter = new EventEmitter();
5929
5930 /**
5931 * @param {string} eventName
5932 * @param {EventHandler} eventHandler
5933 */
5934 const on = (eventName, eventHandler) => {
5935 if (globalState.eventEmitter) {
5936 globalState.eventEmitter.on(eventName, eventHandler);
5937 }
5938 };
5939
5940 /**
5941 * @param {string} eventName
5942 * @param {EventHandler} eventHandler
5943 */
5944 const once = (eventName, eventHandler) => {
5945 if (globalState.eventEmitter) {
5946 globalState.eventEmitter.once(eventName, eventHandler);
5947 }
5948 };
5949
5950 /**
5951 * @param {string} [eventName]
5952 * @param {EventHandler} [eventHandler]
5953 */
5954 const off = (eventName, eventHandler) => {
5955 if (!globalState.eventEmitter) {
5956 return;
5957 }
5958
5959 // Remove all handlers for all events
5960 if (!eventName) {
5961 globalState.eventEmitter.reset();
5962 return;
5963 }
5964 if (eventHandler) {
5965 // Remove a specific handler
5966 globalState.eventEmitter.removeListener(eventName, eventHandler);
5967 } else {
5968 // Remove all handlers for a specific event
5969 globalState.eventEmitter.removeAllListeners(eventName);
5970 }
5971 };
5972
5973 var staticMethods = /*#__PURE__*/Object.freeze({
5974 __proto__: null,
5975 argsToParams: argsToParams,
5976 bindClickHandler: bindClickHandler,
5977 clickCancel: clickCancel,
5978 clickConfirm: clickConfirm,
5979 clickDeny: clickDeny,
5980 enableLoading: showLoading,
5981 fire: fire,
5982 getActions: getActions,
5983 getCancelButton: getCancelButton,
5984 getCloseButton: getCloseButton,
5985 getConfirmButton: getConfirmButton,
5986 getContainer: getContainer,
5987 getDenyButton: getDenyButton,
5988 getFocusableElements: getFocusableElements,
5989 getFooter: getFooter,
5990 getHtmlContainer: getHtmlContainer,
5991 getIcon: getIcon,
5992 getIconContent: getIconContent,
5993 getImage: getImage,
5994 getInputLabel: getInputLabel,
5995 getLoader: getLoader,
5996 getPopup: getPopup,
5997 getProgressSteps: getProgressSteps,
5998 getTimerLeft: getTimerLeft,
5999 getTimerProgressBar: getTimerProgressBar,
6000 getTitle: getTitle,
6001 getValidationMessage: getValidationMessage,
6002 increaseTimer: increaseTimer,
6003 isDeprecatedParameter: isDeprecatedParameter,
6004 isLoading: isLoading,
6005 isTimerRunning: isTimerRunning,
6006 isUpdatableParameter: isUpdatableParameter,
6007 isValidParameter: isValidParameter,
6008 isVisible: isVisible,
6009 mixin: mixin,
6010 off: off,
6011 on: on,
6012 once: once,
6013 resumeTimer: resumeTimer,
6014 showLoading: showLoading,
6015 stopTimer: stopTimer,
6016 toggleTimer: toggleTimer
6017 });
6018
6019 class Timer {
6020 /**
6021 * @param {() => void} callback
6022 * @param {number} delay
6023 */
6024 constructor(callback, delay) {
6025 this.callback = callback;
6026 this.remaining = delay;
6027 this.running = false;
6028 this.start();
6029 }
6030
6031 /**
6032 * @returns {number}
6033 */
6034 start() {
6035 if (!this.running) {
6036 this.running = true;
6037 this.started = new Date();
6038 this.id = setTimeout(this.callback, this.remaining);
6039 }
6040 return this.remaining;
6041 }
6042
6043 /**
6044 * @returns {number}
6045 */
6046 stop() {
6047 if (this.started && this.running) {
6048 this.running = false;
6049 clearTimeout(this.id);
6050 this.remaining -= new Date().getTime() - this.started.getTime();
6051 }
6052 return this.remaining;
6053 }
6054
6055 /**
6056 * @param {number} n
6057 * @returns {number}
6058 */
6059 increase(n) {
6060 const running = this.running;
6061 if (running) {
6062 this.stop();
6063 }
6064 this.remaining += n;
6065 if (running) {
6066 this.start();
6067 }
6068 return this.remaining;
6069 }
6070
6071 /**
6072 * @returns {number}
6073 */
6074 getTimerLeft() {
6075 if (this.running) {
6076 this.stop();
6077 this.start();
6078 }
6079 return this.remaining;
6080 }
6081
6082 /**
6083 * @returns {boolean}
6084 */
6085 isRunning() {
6086 return this.running;
6087 }
6088 }
6089
6090 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6091
6092 /**
6093 * @param {SweetAlertOptions} params
6094 * @returns {SweetAlertOptions}
6095 */
6096 const getTemplateParams = params => {
6097 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6098 if (!template) {
6099 return {};
6100 }
6101 /** @type {DocumentFragment} */
6102 const templateContent = template.content;
6103 showWarningsForElements(templateContent);
6104 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6105 return result;
6106 };
6107
6108 /**
6109 * @param {DocumentFragment} templateContent
6110 * @returns {Record<string, string | boolean | number>}
6111 */
6112 const getSwalParams = templateContent => {
6113 /** @type {Record<string, string | boolean | number>} */
6114 const result = {};
6115 /** @type {HTMLElement[]} */
6116 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6117 swalParams.forEach(param => {
6118 showWarningsForAttributes(param, ['name', 'value']);
6119 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6120 const value = param.getAttribute('value');
6121 if (!paramName || !value) {
6122 return;
6123 }
6124 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6125 result[paramName] = value !== 'false';
6126 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6127 result[paramName] = JSON.parse(value);
6128 } else {
6129 result[paramName] = value;
6130 }
6131 });
6132 return result;
6133 };
6134
6135 /**
6136 * @param {DocumentFragment} templateContent
6137 * @returns {Record<string, () => void>}
6138 */
6139 const getSwalFunctionParams = templateContent => {
6140 /** @type {Record<string, () => void>} */
6141 const result = {};
6142 /** @type {HTMLElement[]} */
6143 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6144 swalFunctions.forEach(param => {
6145 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6146 const value = param.getAttribute('value');
6147 if (!paramName || !value) {
6148 return;
6149 }
6150 result[paramName] = new Function(`return ${value}`)();
6151 });
6152 return result;
6153 };
6154
6155 /**
6156 * @param {DocumentFragment} templateContent
6157 * @returns {Record<string, string | boolean>}
6158 */
6159 const getSwalButtons = templateContent => {
6160 /** @type {Record<string, string | boolean>} */
6161 const result = {};
6162 /** @type {HTMLElement[]} */
6163 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6164 swalButtons.forEach(button => {
6165 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6166 const type = button.getAttribute('type');
6167 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6168 return;
6169 }
6170 result[`${type}ButtonText`] = button.innerHTML;
6171 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6172 const color = button.getAttribute('color');
6173 if (color !== null) {
6174 result[`${type}ButtonColor`] = color;
6175 }
6176 const ariaLabel = button.getAttribute('aria-label');
6177 if (ariaLabel !== null) {
6178 result[`${type}ButtonAriaLabel`] = ariaLabel;
6179 }
6180 });
6181 return result;
6182 };
6183
6184 /**
6185 * @param {DocumentFragment} templateContent
6186 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6187 */
6188 const getSwalImage = templateContent => {
6189 const result = {};
6190 /** @type {HTMLElement | null} */
6191 const image = templateContent.querySelector('swal-image');
6192 if (image) {
6193 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6194 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
6195 const src = image.getAttribute('src');
6196 if (src !== null) result.imageUrl = src || undefined;
6197 const width = image.getAttribute('width');
6198 if (width !== null) result.imageWidth = width || undefined;
6199 const height = image.getAttribute('height');
6200 if (height !== null) result.imageHeight = height || undefined;
6201 const alt = image.getAttribute('alt');
6202 if (alt !== null) result.imageAlt = alt || undefined;
6203 }
6204 return result;
6205 };
6206
6207 /**
6208 * @param {DocumentFragment} templateContent
6209 * @returns {object}
6210 */
6211 const getSwalIcon = templateContent => {
6212 const result = {};
6213 /** @type {HTMLElement | null} */
6214 const icon = templateContent.querySelector('swal-icon');
6215 if (icon) {
6216 showWarningsForAttributes(icon, ['type', 'color']);
6217 if (icon.hasAttribute('type')) {
6218 result.icon = icon.getAttribute('type');
6219 }
6220 if (icon.hasAttribute('color')) {
6221 result.iconColor = icon.getAttribute('color');
6222 }
6223 result.iconHtml = icon.innerHTML;
6224 }
6225 return result;
6226 };
6227
6228 /**
6229 * @param {DocumentFragment} templateContent
6230 * @returns {object}
6231 */
6232 const getSwalInput = templateContent => {
6233 /** @type {Record<string, any>} */
6234 const result = {};
6235 /** @type {HTMLElement | null} */
6236 const input = templateContent.querySelector('swal-input');
6237 if (input) {
6238 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6239 result.input = input.getAttribute('type') || 'text';
6240 if (input.hasAttribute('label')) {
6241 result.inputLabel = input.getAttribute('label');
6242 }
6243 if (input.hasAttribute('placeholder')) {
6244 result.inputPlaceholder = input.getAttribute('placeholder');
6245 }
6246 if (input.hasAttribute('value')) {
6247 result.inputValue = input.getAttribute('value');
6248 }
6249 }
6250 /** @type {HTMLElement[]} */
6251 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6252 if (inputOptions.length) {
6253 result.inputOptions = {};
6254 inputOptions.forEach(option => {
6255 showWarningsForAttributes(option, ['value']);
6256 const optionValue = option.getAttribute('value');
6257 if (!optionValue) {
6258 return;
6259 }
6260 const optionName = option.innerHTML;
6261 result.inputOptions[optionValue] = optionName;
6262 });
6263 }
6264 return result;
6265 };
6266
6267 /**
6268 * @param {DocumentFragment} templateContent
6269 * @param {string[]} paramNames
6270 * @returns {Record<string, string>}
6271 */
6272 const getSwalStringParams = (templateContent, paramNames) => {
6273 /** @type {Record<string, string>} */
6274 const result = {};
6275 for (const i in paramNames) {
6276 const paramName = paramNames[i];
6277 /** @type {HTMLElement | null} */
6278 const tag = templateContent.querySelector(paramName);
6279 if (tag) {
6280 showWarningsForAttributes(tag, []);
6281 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6282 }
6283 }
6284 return result;
6285 };
6286
6287 /**
6288 * @param {DocumentFragment} templateContent
6289 */
6290 const showWarningsForElements = templateContent => {
6291 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6292 Array.from(templateContent.children).forEach(el => {
6293 const tagName = el.tagName.toLowerCase();
6294 if (!allowedElements.includes(tagName)) {
6295 warn(`Unrecognized element <${tagName}>`);
6296 }
6297 });
6298 };
6299
6300 /**
6301 * @param {HTMLElement} el
6302 * @param {string[]} allowedAttributes
6303 */
6304 const showWarningsForAttributes = (el, allowedAttributes) => {
6305 Array.from(el.attributes).forEach(attribute => {
6306 if (allowedAttributes.indexOf(attribute.name) === -1) {
6307 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.'}`]);
6308 }
6309 });
6310 };
6311
6312 const SHOW_CLASS_TIMEOUT = 10;
6313
6314 /**
6315 * Open popup, add necessary classes and styles, fix scrollbar
6316 *
6317 * @param {SweetAlertOptions} params
6318 */
6319 const openPopup = params => {
6320 var _globalState$eventEmi, _globalState$eventEmi2;
6321 const container = getContainer();
6322 const popup = getPopup();
6323 if (!container || !popup) {
6324 return;
6325 }
6326 if (typeof params.willOpen === 'function') {
6327 params.willOpen(popup);
6328 }
6329 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6330 const bodyStyles = window.getComputedStyle(document.body);
6331 const initialBodyOverflow = bodyStyles.overflowY;
6332 addClasses(container, popup, params);
6333
6334 // scrolling is 'hidden' until animation is done, after that 'auto'
6335 setTimeout(() => {
6336 setScrollingVisibility(container, popup);
6337 }, SHOW_CLASS_TIMEOUT);
6338 if (isModal()) {
6339 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6340 setAriaHidden();
6341 }
6342
6343 // https://github.com/sweetalert2/sweetalert2/issues/2923
6344 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
6345 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
6346 container.style.pointerEvents = 'auto';
6347 }
6348 if (!isToast() && !globalState.previousActiveElement) {
6349 globalState.previousActiveElement = document.activeElement;
6350 }
6351 if (typeof params.didOpen === 'function') {
6352 const didOpen = params.didOpen;
6353 setTimeout(() => didOpen(popup));
6354 }
6355 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6356 };
6357
6358 /**
6359 * @param {Event} event
6360 */
6361 const swalOpenAnimationFinished = event => {
6362 const popup = getPopup();
6363 if (!popup || event.target !== popup) {
6364 return;
6365 }
6366 const container = getContainer();
6367 if (!container) {
6368 return;
6369 }
6370 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6371 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6372 container.style.overflowY = 'auto';
6373
6374 // no-transition is added in init() in case one swal is opened right after another
6375 removeClass(container, swalClasses['no-transition']);
6376 };
6377
6378 /**
6379 * @param {HTMLElement} container
6380 * @param {HTMLElement} popup
6381 */
6382 const setScrollingVisibility = (container, popup) => {
6383 if (hasCssAnimation(popup)) {
6384 container.style.overflowY = 'hidden';
6385 popup.addEventListener('animationend', swalOpenAnimationFinished);
6386 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6387 } else {
6388 container.style.overflowY = 'auto';
6389 }
6390 };
6391
6392 /**
6393 * @param {HTMLElement} container
6394 * @param {boolean} scrollbarPadding
6395 * @param {string} initialBodyOverflow
6396 */
6397 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6398 iOSfix();
6399 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6400 replaceScrollbarWithPadding(initialBodyOverflow);
6401 }
6402
6403 // sweetalert2/issues/1247
6404 setTimeout(() => {
6405 container.scrollTop = 0;
6406 });
6407 };
6408
6409 /**
6410 * @param {HTMLElement} container
6411 * @param {HTMLElement} popup
6412 * @param {SweetAlertOptions} params
6413 */
6414 const addClasses = (container, popup, params) => {
6415 var _params$showClass;
6416 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6417 addClass(container, params.showClass.backdrop);
6418 }
6419 if (params.animation) {
6420 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6421 popup.style.setProperty('opacity', '0', 'important');
6422 show(popup, 'grid');
6423 setTimeout(() => {
6424 var _params$showClass2;
6425 // Animate popup right after showing it
6426 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6427 addClass(popup, params.showClass.popup);
6428 }
6429 // and remove the opacity workaround
6430 popup.style.removeProperty('opacity');
6431 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6432 } else {
6433 show(popup, 'grid');
6434 }
6435 addClass([document.documentElement, document.body], swalClasses.shown);
6436 if (params.heightAuto && params.backdrop && !params.toast) {
6437 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6438 }
6439 };
6440
6441 var defaultInputValidators = {
6442 /**
6443 * @param {string} string
6444 * @param {string} [validationMessage]
6445 * @returns {Promise<string | void>}
6446 */
6447 email: (string, validationMessage) => {
6448 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6449 },
6450 /**
6451 * @param {string} string
6452 * @param {string} [validationMessage]
6453 * @returns {Promise<string | void>}
6454 */
6455 url: (string, validationMessage) => {
6456 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6457 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');
6458 }
6459 };
6460
6461 /**
6462 * @param {SweetAlertOptions} params
6463 */
6464 function setDefaultInputValidators(params) {
6465 // Use default `inputValidator` for supported input types if not provided
6466 if (params.inputValidator) {
6467 return;
6468 }
6469 if (params.input === 'email') {
6470 params.inputValidator = defaultInputValidators['email'];
6471 }
6472 if (params.input === 'url') {
6473 params.inputValidator = defaultInputValidators['url'];
6474 }
6475 }
6476
6477 /**
6478 * @param {SweetAlertOptions} params
6479 */
6480 function validateCustomTargetElement(params) {
6481 // Determine if the custom target element is valid
6482 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6483 warn('Target parameter is not valid, defaulting to "body"');
6484 params.target = 'body';
6485 }
6486 }
6487
6488 /**
6489 * Set type, text and actions on popup
6490 *
6491 * @param {SweetAlertOptions} params
6492 */
6493 function setParameters(params) {
6494 setDefaultInputValidators(params);
6495
6496 // showLoaderOnConfirm && preConfirm
6497 if (params.showLoaderOnConfirm && !params.preConfirm) {
6498 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');
6499 }
6500 validateCustomTargetElement(params);
6501
6502 // Replace newlines with <br> in title
6503 if (typeof params.title === 'string') {
6504 params.title = params.title.split('\n').join('<br />');
6505 }
6506 init(params);
6507 }
6508
6509 /** @type {SweetAlert} */
6510 let currentInstance;
6511 var _promise = /*#__PURE__*/new WeakMap();
6512 class SweetAlert {
6513 /**
6514 * @param {...(SweetAlertOptions | string)} args
6515 * @this {SweetAlert}
6516 */
6517 constructor(...args) {
6518 /**
6519 * @type {Promise<SweetAlertResult>}
6520 */
6521 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
6522 Promise.resolve({
6523 isConfirmed: false,
6524 isDenied: false,
6525 isDismissed: true
6526 }));
6527 // Prevent run in Node env
6528 if (typeof window === 'undefined') {
6529 return;
6530 }
6531 currentInstance = this;
6532
6533 // @ts-ignore
6534 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6535
6536 /** @type {Readonly<SweetAlertOptions>} */
6537 this.params = outerParams;
6538
6539 /** @type {boolean} */
6540 this.isAwaitingPromise = false;
6541 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6542 }
6543
6544 /**
6545 * @param {any} userParams
6546 * @param {any} mixinParams
6547 */
6548 _main(userParams, mixinParams = {}) {
6549 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6550 if (globalState.currentInstance) {
6551 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6552 const {
6553 isAwaitingPromise
6554 } = globalState.currentInstance;
6555 globalState.currentInstance._destroy();
6556 if (!isAwaitingPromise) {
6557 swalPromiseResolve({
6558 isDismissed: true
6559 });
6560 }
6561 if (isModal()) {
6562 unsetAriaHidden();
6563 }
6564 }
6565 globalState.currentInstance = currentInstance;
6566 const innerParams = prepareParams(userParams, mixinParams);
6567 setParameters(innerParams);
6568 Object.freeze(innerParams);
6569
6570 // clear the previous timer
6571 if (globalState.timeout) {
6572 globalState.timeout.stop();
6573 delete globalState.timeout;
6574 }
6575
6576 // clear the restore focus timeout
6577 clearTimeout(globalState.restoreFocusTimeout);
6578 const domCache = populateDomCache(currentInstance);
6579 render(currentInstance, innerParams);
6580 privateProps.innerParams.set(currentInstance, innerParams);
6581 return swalPromise(currentInstance, domCache, innerParams);
6582 }
6583
6584 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6585 /**
6586 * @param {any} onFulfilled
6587 */
6588 // oxlint-disable-next-line unicorn/no-thenable
6589 then(onFulfilled) {
6590 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6591 }
6592
6593 /**
6594 * @param {any} onFinally
6595 */
6596 finally(onFinally) {
6597 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6598 }
6599 }
6600
6601 /**
6602 * @param {SweetAlert} instance
6603 * @param {DomCache} domCache
6604 * @param {SweetAlertOptions} innerParams
6605 * @returns {Promise<SweetAlertResult>}
6606 */
6607 const swalPromise = (instance, domCache, innerParams) => {
6608 return new Promise((resolve, reject) => {
6609 // functions to handle all closings/dismissals
6610 /**
6611 * @param {DismissReason} dismiss
6612 */
6613 const dismissWith = dismiss => {
6614 instance.close({
6615 isDismissed: true,
6616 dismiss,
6617 isConfirmed: false,
6618 isDenied: false
6619 });
6620 };
6621 privateMethods.swalPromiseResolve.set(instance, resolve);
6622 privateMethods.swalPromiseReject.set(instance, reject);
6623 domCache.confirmButton.onclick = () => {
6624 handleConfirmButtonClick(instance);
6625 };
6626 domCache.denyButton.onclick = () => {
6627 handleDenyButtonClick(instance);
6628 };
6629 domCache.cancelButton.onclick = () => {
6630 handleCancelButtonClick(instance, dismissWith);
6631 };
6632 domCache.closeButton.onclick = () => {
6633 dismissWith(DismissReason.close);
6634 };
6635 handlePopupClick(innerParams, domCache, dismissWith);
6636 addKeydownHandler(globalState, innerParams, dismissWith);
6637 handleInputOptionsAndValue(instance, innerParams);
6638 openPopup(innerParams);
6639 setupTimer(globalState, innerParams, dismissWith);
6640 initFocus(domCache, innerParams);
6641
6642 // Scroll container to top on open (#1247, #1946)
6643 setTimeout(() => {
6644 domCache.container.scrollTop = 0;
6645 });
6646 });
6647 };
6648
6649 /**
6650 * @param {SweetAlertOptions} userParams
6651 * @param {SweetAlertOptions} mixinParams
6652 * @returns {SweetAlertOptions}
6653 */
6654 const prepareParams = (userParams, mixinParams) => {
6655 const templateParams = getTemplateParams(userParams);
6656 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6657 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6658 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6659 if (params.animation === false) {
6660 params.showClass = {
6661 backdrop: 'swal2-noanimation'
6662 };
6663 params.hideClass = {};
6664 }
6665 return params;
6666 };
6667
6668 /**
6669 * @param {SweetAlert} instance
6670 * @returns {DomCache}
6671 */
6672 const populateDomCache = instance => {
6673 const domCache = /** @type {DomCache} */{
6674 popup: (/** @type {HTMLElement} */getPopup()),
6675 container: (/** @type {HTMLElement} */getContainer()),
6676 actions: (/** @type {HTMLElement} */getActions()),
6677 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6678 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6679 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6680 loader: (/** @type {HTMLElement} */getLoader()),
6681 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6682 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6683 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6684 };
6685 privateProps.domCache.set(instance, domCache);
6686 return domCache;
6687 };
6688
6689 /**
6690 * @param {GlobalState} globalState
6691 * @param {SweetAlertOptions} innerParams
6692 * @param {(dismiss: DismissReason) => void} dismissWith
6693 */
6694 const setupTimer = (globalState, innerParams, dismissWith) => {
6695 const timerProgressBar = getTimerProgressBar();
6696 hide(timerProgressBar);
6697 if (innerParams.timer) {
6698 globalState.timeout = new Timer(() => {
6699 dismissWith('timer');
6700 delete globalState.timeout;
6701 }, innerParams.timer);
6702 if (innerParams.timerProgressBar && timerProgressBar) {
6703 show(timerProgressBar);
6704 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6705 setTimeout(() => {
6706 if (globalState.timeout && globalState.timeout.running) {
6707 // timer can be already stopped or unset at this point
6708 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6709 }
6710 });
6711 }
6712 }
6713 };
6714
6715 /**
6716 * Initialize focus in the popup:
6717 *
6718 * 1. If `toast` is `true`, don't steal focus from the document.
6719 * 2. Else if there is an [autofocus] element, focus it.
6720 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6721 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6722 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6723 * 6. Else focus the first focusable element in a popup (if any).
6724 *
6725 * @param {DomCache} domCache
6726 * @param {SweetAlertOptions} innerParams
6727 */
6728 const initFocus = (domCache, innerParams) => {
6729 if (innerParams.toast) {
6730 return;
6731 }
6732 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6733 if (!callIfFunction(innerParams.allowEnterKey)) {
6734 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
6735 domCache.popup.focus();
6736 return;
6737 }
6738 if (focusAutofocus(domCache)) {
6739 return;
6740 }
6741 if (focusButton(domCache, innerParams)) {
6742 return;
6743 }
6744 setFocus(-1, 1);
6745 };
6746
6747 /**
6748 * @param {DomCache} domCache
6749 * @returns {boolean}
6750 */
6751 const focusAutofocus = domCache => {
6752 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6753 for (const autofocusElement of autofocusElements) {
6754 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6755 autofocusElement.focus();
6756 return true;
6757 }
6758 }
6759 return false;
6760 };
6761
6762 /**
6763 * @param {DomCache} domCache
6764 * @param {SweetAlertOptions} innerParams
6765 * @returns {boolean}
6766 */
6767 const focusButton = (domCache, innerParams) => {
6768 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6769 domCache.denyButton.focus();
6770 return true;
6771 }
6772 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6773 domCache.cancelButton.focus();
6774 return true;
6775 }
6776 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6777 domCache.confirmButton.focus();
6778 return true;
6779 }
6780 return false;
6781 };
6782
6783 // Assign instance methods from src/instanceMethods/*.js to prototype
6784 SweetAlert.prototype.disableButtons = disableButtons;
6785 SweetAlert.prototype.enableButtons = enableButtons;
6786 SweetAlert.prototype.getInput = getInput;
6787 SweetAlert.prototype.disableInput = disableInput;
6788 SweetAlert.prototype.enableInput = enableInput;
6789 SweetAlert.prototype.hideLoading = hideLoading;
6790 SweetAlert.prototype.disableLoading = hideLoading;
6791 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6792 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6793 SweetAlert.prototype.close = close;
6794 SweetAlert.prototype.closePopup = close;
6795 SweetAlert.prototype.closeModal = close;
6796 SweetAlert.prototype.closeToast = close;
6797 SweetAlert.prototype.rejectPromise = rejectPromise;
6798 SweetAlert.prototype.update = update;
6799 SweetAlert.prototype._destroy = _destroy;
6800
6801 // Assign static methods from src/staticMethods/*.js to constructor
6802 Object.assign(SweetAlert, staticMethods);
6803
6804 // Proxy to instance methods to constructor, for now, for backwards compatibility
6805 Object.keys(instanceMethods).forEach(key => {
6806 /**
6807 * @param {...(SweetAlertOptions | string | undefined)} args
6808 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6809 */
6810 // @ts-ignore: Dynamic property assignment for backwards compatibility
6811 SweetAlert[key] = function (...args) {
6812 // @ts-ignore
6813 if (currentInstance && currentInstance[key]) {
6814 // @ts-ignore
6815 return currentInstance[key](...args);
6816 }
6817 return undefined;
6818 };
6819 });
6820 SweetAlert.DismissReason = DismissReason;
6821 SweetAlert.version = '11.26.25';
6822
6823 const Swal = SweetAlert;
6824 // @ts-ignore
6825 Swal.default = Swal;
6826
6827 return Swal;
6828
6829 }));
6830 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6831 "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-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:auto}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}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)}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}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}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}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)}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:auto}.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}.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}}");
6832
6833 /***/ },
6834
6835 /***/ "./node_modules/toastify-js/src/toastify.js"
6836 /*!**************************************************!*\
6837 !*** ./node_modules/toastify-js/src/toastify.js ***!
6838 \**************************************************/
6839 (module) {
6840
6841 /*!
6842 * Toastify js 1.12.0
6843 * https://github.com/apvarun/toastify-js
6844 * @license MIT licensed
6845 *
6846 * Copyright (C) 2018 Varun A P
6847 */
6848 (function(root, factory) {
6849 if ( true && module.exports) {
6850 module.exports = factory();
6851 } else {
6852 root.Toastify = factory();
6853 }
6854 })(this, function(global) {
6855 // Object initialization
6856 var Toastify = function(options) {
6857 // Returning a new init object
6858 return new Toastify.lib.init(options);
6859 },
6860 // Library version
6861 version = "1.12.0";
6862
6863 // Set the default global options
6864 Toastify.defaults = {
6865 oldestFirst: true,
6866 text: "Toastify is awesome!",
6867 node: undefined,
6868 duration: 3000,
6869 selector: undefined,
6870 callback: function () {
6871 },
6872 destination: undefined,
6873 newWindow: false,
6874 close: false,
6875 gravity: "toastify-top",
6876 positionLeft: false,
6877 position: '',
6878 backgroundColor: '',
6879 avatar: "",
6880 className: "",
6881 stopOnFocus: true,
6882 onClick: function () {
6883 },
6884 offset: {x: 0, y: 0},
6885 escapeMarkup: true,
6886 ariaLive: 'polite',
6887 style: {background: ''}
6888 };
6889
6890 // Defining the prototype of the object
6891 Toastify.lib = Toastify.prototype = {
6892 toastify: version,
6893
6894 constructor: Toastify,
6895
6896 // Initializing the object with required parameters
6897 init: function(options) {
6898 // Verifying and validating the input object
6899 if (!options) {
6900 options = {};
6901 }
6902
6903 // Creating the options object
6904 this.options = {};
6905
6906 this.toastElement = null;
6907
6908 // Validating the options
6909 this.options.text = options.text || Toastify.defaults.text; // Display message
6910 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6911 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6912 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6913 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6914 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6915 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6916 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6917 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6918 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6919 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6920 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6921 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6922 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6923 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6924 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6925 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6926 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6927 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6928 this.options.style = options.style || Toastify.defaults.style;
6929 if(options.backgroundColor) {
6930 this.options.style.background = options.backgroundColor;
6931 }
6932
6933 // Returning the current object for chaining functions
6934 return this;
6935 },
6936
6937 // Building the DOM element
6938 buildToast: function() {
6939 // Validating if the options are defined
6940 if (!this.options) {
6941 throw "Toastify is not initialized";
6942 }
6943
6944 // Creating the DOM object
6945 var divElement = document.createElement("div");
6946 divElement.className = "toastify on " + this.options.className;
6947
6948 // Positioning toast to left or right or center
6949 if (!!this.options.position) {
6950 divElement.className += " toastify-" + this.options.position;
6951 } else {
6952 // To be depreciated in further versions
6953 if (this.options.positionLeft === true) {
6954 divElement.className += " toastify-left";
6955 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6956 } else {
6957 // Default position
6958 divElement.className += " toastify-right";
6959 }
6960 }
6961
6962 // Assigning gravity of element
6963 divElement.className += " " + this.options.gravity;
6964
6965 if (this.options.backgroundColor) {
6966 // This is being deprecated in favor of using the style HTML DOM property
6967 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
6968 }
6969
6970 // Loop through our style object and apply styles to divElement
6971 for (var property in this.options.style) {
6972 divElement.style[property] = this.options.style[property];
6973 }
6974
6975 // Announce the toast to screen readers
6976 if (this.options.ariaLive) {
6977 divElement.setAttribute('aria-live', this.options.ariaLive)
6978 }
6979
6980 // Adding the toast message/node
6981 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
6982 // If we have a valid node, we insert it
6983 divElement.appendChild(this.options.node)
6984 } else {
6985 if (this.options.escapeMarkup) {
6986 divElement.innerText = this.options.text;
6987 } else {
6988 divElement.innerHTML = this.options.text;
6989 }
6990
6991 if (this.options.avatar !== "") {
6992 var avatarElement = document.createElement("img");
6993 avatarElement.src = this.options.avatar;
6994
6995 avatarElement.className = "toastify-avatar";
6996
6997 if (this.options.position == "left" || this.options.positionLeft === true) {
6998 // Adding close icon on the left of content
6999 divElement.appendChild(avatarElement);
7000 } else {
7001 // Adding close icon on the right of content
7002 divElement.insertAdjacentElement("afterbegin", avatarElement);
7003 }
7004 }
7005 }
7006
7007 // Adding a close icon to the toast
7008 if (this.options.close === true) {
7009 // Create a span for close element
7010 var closeElement = document.createElement("button");
7011 closeElement.type = "button";
7012 closeElement.setAttribute("aria-label", "Close");
7013 closeElement.className = "toast-close";
7014 closeElement.innerHTML = "&#10006;";
7015
7016 // Triggering the removal of toast from DOM on close click
7017 closeElement.addEventListener(
7018 "click",
7019 function(event) {
7020 event.stopPropagation();
7021 this.removeElement(this.toastElement);
7022 window.clearTimeout(this.toastElement.timeOutValue);
7023 }.bind(this)
7024 );
7025
7026 //Calculating screen width
7027 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7028
7029 // Adding the close icon to the toast element
7030 // Display on the right if screen width is less than or equal to 360px
7031 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7032 // Adding close icon on the left of content
7033 divElement.insertAdjacentElement("afterbegin", closeElement);
7034 } else {
7035 // Adding close icon on the right of content
7036 divElement.appendChild(closeElement);
7037 }
7038 }
7039
7040 // Clear timeout while toast is focused
7041 if (this.options.stopOnFocus && this.options.duration > 0) {
7042 var self = this;
7043 // stop countdown
7044 divElement.addEventListener(
7045 "mouseover",
7046 function(event) {
7047 window.clearTimeout(divElement.timeOutValue);
7048 }
7049 )
7050 // add back the timeout
7051 divElement.addEventListener(
7052 "mouseleave",
7053 function() {
7054 divElement.timeOutValue = window.setTimeout(
7055 function() {
7056 // Remove the toast from DOM
7057 self.removeElement(divElement);
7058 },
7059 self.options.duration
7060 )
7061 }
7062 )
7063 }
7064
7065 // Adding an on-click destination path
7066 if (typeof this.options.destination !== "undefined") {
7067 divElement.addEventListener(
7068 "click",
7069 function(event) {
7070 event.stopPropagation();
7071 if (this.options.newWindow === true) {
7072 window.open(this.options.destination, "_blank");
7073 } else {
7074 window.location = this.options.destination;
7075 }
7076 }.bind(this)
7077 );
7078 }
7079
7080 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7081 divElement.addEventListener(
7082 "click",
7083 function(event) {
7084 event.stopPropagation();
7085 this.options.onClick();
7086 }.bind(this)
7087 );
7088 }
7089
7090 // Adding offset
7091 if(typeof this.options.offset === "object") {
7092
7093 var x = getAxisOffsetAValue("x", this.options);
7094 var y = getAxisOffsetAValue("y", this.options);
7095
7096 var xOffset = this.options.position == "left" ? x : "-" + x;
7097 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7098
7099 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7100
7101 }
7102
7103 // Returning the generated element
7104 return divElement;
7105 },
7106
7107 // Displaying the toast
7108 showToast: function() {
7109 // Creating the DOM object for the toast
7110 this.toastElement = this.buildToast();
7111
7112 // Getting the root element to with the toast needs to be added
7113 var rootElement;
7114 if (typeof this.options.selector === "string") {
7115 rootElement = document.getElementById(this.options.selector);
7116 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7117 rootElement = this.options.selector;
7118 } else {
7119 rootElement = document.body;
7120 }
7121
7122 // Validating if root element is present in DOM
7123 if (!rootElement) {
7124 throw "Root element is not defined";
7125 }
7126
7127 // Adding the DOM element
7128 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7129 rootElement.insertBefore(this.toastElement, elementToInsert);
7130
7131 // Repositioning the toasts in case multiple toasts are present
7132 Toastify.reposition();
7133
7134 if (this.options.duration > 0) {
7135 this.toastElement.timeOutValue = window.setTimeout(
7136 function() {
7137 // Remove the toast from DOM
7138 this.removeElement(this.toastElement);
7139 }.bind(this),
7140 this.options.duration
7141 ); // Binding `this` for function invocation
7142 }
7143
7144 // Supporting function chaining
7145 return this;
7146 },
7147
7148 hideToast: function() {
7149 if (this.toastElement.timeOutValue) {
7150 clearTimeout(this.toastElement.timeOutValue);
7151 }
7152 this.removeElement(this.toastElement);
7153 },
7154
7155 // Removing the element from the DOM
7156 removeElement: function(toastElement) {
7157 // Hiding the element
7158 // toastElement.classList.remove("on");
7159 toastElement.className = toastElement.className.replace(" on", "");
7160
7161 // Removing the element from DOM after transition end
7162 window.setTimeout(
7163 function() {
7164 // remove options node if any
7165 if (this.options.node && this.options.node.parentNode) {
7166 this.options.node.parentNode.removeChild(this.options.node);
7167 }
7168
7169 // Remove the element from the DOM, only when the parent node was not removed before.
7170 if (toastElement.parentNode) {
7171 toastElement.parentNode.removeChild(toastElement);
7172 }
7173
7174 // Calling the callback function
7175 this.options.callback.call(toastElement);
7176
7177 // Repositioning the toasts again
7178 Toastify.reposition();
7179 }.bind(this),
7180 400
7181 ); // Binding `this` for function invocation
7182 },
7183 };
7184
7185 // Positioning the toasts on the DOM
7186 Toastify.reposition = function() {
7187
7188 // Top margins with gravity
7189 var topLeftOffsetSize = {
7190 top: 15,
7191 bottom: 15,
7192 };
7193 var topRightOffsetSize = {
7194 top: 15,
7195 bottom: 15,
7196 };
7197 var offsetSize = {
7198 top: 15,
7199 bottom: 15,
7200 };
7201
7202 // Get all toast messages on the DOM
7203 var allToasts = document.getElementsByClassName("toastify");
7204
7205 var classUsed;
7206
7207 // Modifying the position of each toast element
7208 for (var i = 0; i < allToasts.length; i++) {
7209 // Getting the applied gravity
7210 if (containsClass(allToasts[i], "toastify-top") === true) {
7211 classUsed = "toastify-top";
7212 } else {
7213 classUsed = "toastify-bottom";
7214 }
7215
7216 var height = allToasts[i].offsetHeight;
7217 classUsed = classUsed.substr(9, classUsed.length-1)
7218 // Spacing between toasts
7219 var offset = 15;
7220
7221 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7222
7223 // Show toast in center if screen with less than or equal to 360px
7224 if (width <= 360) {
7225 // Setting the position
7226 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7227
7228 offsetSize[classUsed] += height + offset;
7229 } else {
7230 if (containsClass(allToasts[i], "toastify-left") === true) {
7231 // Setting the position
7232 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7233
7234 topLeftOffsetSize[classUsed] += height + offset;
7235 } else {
7236 // Setting the position
7237 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7238
7239 topRightOffsetSize[classUsed] += height + offset;
7240 }
7241 }
7242 }
7243
7244 // Supporting function chaining
7245 return this;
7246 };
7247
7248 // Helper function to get offset.
7249 function getAxisOffsetAValue(axis, options) {
7250
7251 if(options.offset[axis]) {
7252 if(isNaN(options.offset[axis])) {
7253 return options.offset[axis];
7254 }
7255 else {
7256 return options.offset[axis] + 'px';
7257 }
7258 }
7259
7260 return '0px';
7261
7262 }
7263
7264 function containsClass(elem, yourClass) {
7265 if (!elem || typeof yourClass !== "string") {
7266 return false;
7267 } else if (
7268 elem.className &&
7269 elem.className
7270 .trim()
7271 .split(/\s+/gi)
7272 .indexOf(yourClass) > -1
7273 ) {
7274 return true;
7275 } else {
7276 return false;
7277 }
7278 }
7279
7280 // Setting up the prototype for the init object
7281 Toastify.lib.init.prototype = Toastify.lib;
7282
7283 // Returning the Toastify function to be assigned to the window object/module
7284 return Toastify;
7285 });
7286
7287
7288 /***/ },
7289
7290 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7291 /*!**********************************************************!*\
7292 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7293 \**********************************************************/
7294 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7295
7296 "use strict";
7297 __webpack_require__.r(__webpack_exports__);
7298 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7299 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7300 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7301 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7302 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7303 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7304 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7305 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7306 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7307 /* harmony export */ });
7308 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7309 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7310 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7311 /**
7312 * sifter.js
7313 * Copyright (c) 2013–2020 Brian Reavis & contributors
7314 *
7315 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7316 * file except in compliance with the License. You may obtain a copy of the License at:
7317 * http://www.apache.org/licenses/LICENSE-2.0
7318 *
7319 * Unless required by applicable law or agreed to in writing, software distributed under
7320 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7321 * ANY KIND, either express or implied. See the License for the specific language
7322 * governing permissions and limitations under the License.
7323 *
7324 * @author Brian Reavis <brian@thirdroute.com>
7325 */
7326
7327
7328 class Sifter {
7329 items; // []|{};
7330 settings;
7331 /**
7332 * Textually searches arrays and hashes of objects
7333 * by property (or multiple properties). Designed
7334 * specifically for autocomplete.
7335 *
7336 */
7337 constructor(items, settings) {
7338 this.items = items;
7339 this.settings = settings || { diacritics: true };
7340 }
7341 ;
7342 /**
7343 * Splits a search string into an array of individual
7344 * regexps to be used to match results.
7345 *
7346 */
7347 tokenize(query, respect_word_boundaries, weights) {
7348 if (!query || !query.length)
7349 return [];
7350 const tokens = [];
7351 const words = query.split(/\s+/);
7352 var field_regex;
7353 if (weights) {
7354 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7355 }
7356 words.forEach((word) => {
7357 let field_match;
7358 let field = null;
7359 let regex = null;
7360 // look for "field:query" tokens
7361 if (field_regex && (field_match = word.match(field_regex))) {
7362 field = field_match[1];
7363 word = field_match[2];
7364 }
7365 if (word.length > 0) {
7366 if (this.settings.diacritics) {
7367 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7368 }
7369 else {
7370 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7371 }
7372 if (regex && respect_word_boundaries)
7373 regex = "\\b" + regex;
7374 }
7375 tokens.push({
7376 string: word,
7377 regex: regex ? new RegExp(regex, 'iu') : null,
7378 field: field,
7379 });
7380 });
7381 return tokens;
7382 }
7383 ;
7384 /**
7385 * Returns a function to be used to score individual results.
7386 *
7387 * Good matches will have a higher score than poor matches.
7388 * If an item is not a match, 0 will be returned by the function.
7389 *
7390 * @returns {T.ScoreFn}
7391 */
7392 getScoreFunction(query, options) {
7393 var search = this.prepareSearch(query, options);
7394 return this._getScoreFunction(search);
7395 }
7396 /**
7397 * @returns {T.ScoreFn}
7398 *
7399 */
7400 _getScoreFunction(search) {
7401 const tokens = search.tokens, token_count = tokens.length;
7402 if (!token_count) {
7403 return function () { return 0; };
7404 }
7405 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7406 if (!field_count) {
7407 return function () { return 1; };
7408 }
7409 /**
7410 * Calculates the score of an object
7411 * against the search query.
7412 *
7413 */
7414 const scoreObject = (function () {
7415 if (field_count === 1) {
7416 return function (token, data) {
7417 const field = fields[0].field;
7418 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7419 };
7420 }
7421 return function (token, data) {
7422 var sum = 0;
7423 // is the token specific to a field?
7424 if (token.field) {
7425 const value = getAttrFn(data, token.field);
7426 if (!token.regex && value) {
7427 sum += (1 / field_count);
7428 }
7429 else {
7430 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7431 }
7432 }
7433 else {
7434 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7435 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7436 });
7437 }
7438 return sum / field_count;
7439 };
7440 })();
7441 if (token_count === 1) {
7442 return function (data) {
7443 return scoreObject(tokens[0], data);
7444 };
7445 }
7446 if (search.options.conjunction === 'and') {
7447 return function (data) {
7448 var score, sum = 0;
7449 for (let token of tokens) {
7450 score = scoreObject(token, data);
7451 if (score <= 0)
7452 return 0;
7453 sum += score;
7454 }
7455 return sum / token_count;
7456 };
7457 }
7458 else {
7459 return function (data) {
7460 var sum = 0;
7461 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7462 sum += scoreObject(token, data);
7463 });
7464 return sum / token_count;
7465 };
7466 }
7467 }
7468 ;
7469 /**
7470 * Returns a function that can be used to compare two
7471 * results, for sorting purposes. If no sorting should
7472 * be performed, `null` will be returned.
7473 *
7474 * @return function(a,b)
7475 */
7476 getSortFunction(query, options) {
7477 var search = this.prepareSearch(query, options);
7478 return this._getSortFunction(search);
7479 }
7480 _getSortFunction(search) {
7481 var implicit_score, sort_flds = [];
7482 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
7483 if (typeof sort == 'function') {
7484 return sort.bind(this);
7485 }
7486 /**
7487 * Fetches the specified sort field value
7488 * from a search result item.
7489 *
7490 */
7491 const get_field = function (name, result) {
7492 if (name === '$score')
7493 return result.score;
7494 return search.getAttrFn(self.items[result.id], name);
7495 };
7496 // parse options
7497 if (sort) {
7498 for (let s of sort) {
7499 if (search.query || s.field !== '$score') {
7500 sort_flds.push(s);
7501 }
7502 }
7503 }
7504 // the "$score" field is implied to be the primary
7505 // sort field, unless it's manually specified
7506 if (search.query) {
7507 implicit_score = true;
7508 for (let fld of sort_flds) {
7509 if (fld.field === '$score') {
7510 implicit_score = false;
7511 break;
7512 }
7513 }
7514 if (implicit_score) {
7515 sort_flds.unshift({ field: '$score', direction: 'desc' });
7516 }
7517 // without a search.query, all items will have the same score
7518 }
7519 else {
7520 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
7521 }
7522 // build function
7523 const sort_flds_count = sort_flds.length;
7524 if (!sort_flds_count) {
7525 return null;
7526 }
7527 return function (a, b) {
7528 var result, field;
7529 for (let sort_fld of sort_flds) {
7530 field = sort_fld.field;
7531 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
7532 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
7533 if (result)
7534 return result;
7535 }
7536 return 0;
7537 };
7538 }
7539 ;
7540 /**
7541 * Parses a search query and returns an object
7542 * with tokens and fields ready to be populated
7543 * with results.
7544 *
7545 */
7546 prepareSearch(query, optsUser) {
7547 const weights = {};
7548 var options = Object.assign({}, optsUser);
7549 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
7550 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
7551 // convert fields to new format
7552 if (options.fields) {
7553 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
7554 const fields = [];
7555 options.fields.forEach((field) => {
7556 if (typeof field == 'string') {
7557 field = { field: field, weight: 1 };
7558 }
7559 fields.push(field);
7560 weights[field.field] = ('weight' in field) ? field.weight : 1;
7561 });
7562 options.fields = fields;
7563 }
7564 return {
7565 options: options,
7566 query: query.toLowerCase().trim(),
7567 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
7568 total: 0,
7569 items: [],
7570 weights: weights,
7571 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
7572 };
7573 }
7574 ;
7575 /**
7576 * Searches through all items and returns a sorted array of matches.
7577 *
7578 */
7579 search(query, options) {
7580 var self = this, score, search;
7581 search = this.prepareSearch(query, options);
7582 options = search.options;
7583 query = search.query;
7584 // generate result scoring function
7585 const fn_score = options.score || self._getScoreFunction(search);
7586 // perform search and sort
7587 if (query.length) {
7588 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
7589 score = fn_score(item);
7590 if (options.filter === false || score > 0) {
7591 search.items.push({ 'score': score, 'id': id });
7592 }
7593 });
7594 }
7595 else {
7596 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
7597 search.items.push({ 'score': 1, 'id': id });
7598 });
7599 }
7600 const fn_sort = self._getSortFunction(search);
7601 if (fn_sort)
7602 search.items.sort(fn_sort);
7603 // apply limits
7604 search.total = search.items.length;
7605 if (typeof options.limit === 'number') {
7606 search.items = search.items.slice(0, options.limit);
7607 }
7608 return search;
7609 }
7610 ;
7611 }
7612
7613
7614 //# sourceMappingURL=sifter.js.map
7615
7616 /***/ },
7617
7618 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
7619 /*!*********************************************************!*\
7620 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
7621 \*********************************************************/
7622 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7623
7624 "use strict";
7625 __webpack_require__.r(__webpack_exports__);
7626
7627 //# sourceMappingURL=types.js.map
7628
7629 /***/ },
7630
7631 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
7632 /*!*********************************************************!*\
7633 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
7634 \*********************************************************/
7635 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7636
7637 "use strict";
7638 __webpack_require__.r(__webpack_exports__);
7639 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7640 /* harmony export */ cmp: () => (/* binding */ cmp),
7641 /* harmony export */ getAttr: () => (/* binding */ getAttr),
7642 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
7643 /* harmony export */ iterate: () => (/* binding */ iterate),
7644 /* harmony export */ propToArray: () => (/* binding */ propToArray),
7645 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
7646 /* harmony export */ });
7647 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7648
7649 /**
7650 * A property getter resolving dot-notation
7651 * @param {Object} obj The root object to fetch property on
7652 * @param {String} name The optionally dotted property name to fetch
7653 * @return {Object} The resolved property value
7654 */
7655 const getAttr = (obj, name) => {
7656 if (!obj)
7657 return;
7658 return obj[name];
7659 };
7660 /**
7661 * A property getter resolving dot-notation
7662 * @param {Object} obj The root object to fetch property on
7663 * @param {String} name The optionally dotted property name to fetch
7664 * @return {Object} The resolved property value
7665 */
7666 const getAttrNesting = (obj, name) => {
7667 if (!obj)
7668 return;
7669 var part, names = name.split(".");
7670 while ((part = names.shift()) && (obj = obj[part]))
7671 ;
7672 return obj;
7673 };
7674 /**
7675 * Calculates how close of a match the
7676 * given value is against a search token.
7677 *
7678 */
7679 const scoreValue = (value, token, weight) => {
7680 var score, pos;
7681 if (!value)
7682 return 0;
7683 value = value + '';
7684 if (token.regex == null)
7685 return 0;
7686 pos = value.search(token.regex);
7687 if (pos === -1)
7688 return 0;
7689 score = token.string.length / value.length;
7690 if (pos === 0)
7691 score += 0.5;
7692 return score * weight;
7693 };
7694 /**
7695 * Cast object property to an array if it exists and has a value
7696 *
7697 */
7698 const propToArray = (obj, key) => {
7699 var value = obj[key];
7700 if (typeof value == 'function')
7701 return value;
7702 if (value && !Array.isArray(value)) {
7703 obj[key] = [value];
7704 }
7705 };
7706 /**
7707 * Iterates over arrays and hashes.
7708 *
7709 * ```
7710 * iterate(this.items, function(item, id) {
7711 * // invoked for each item
7712 * });
7713 * ```
7714 *
7715 */
7716 const iterate = (object, callback) => {
7717 if (Array.isArray(object)) {
7718 object.forEach(callback);
7719 }
7720 else {
7721 for (var key in object) {
7722 if (object.hasOwnProperty(key)) {
7723 callback(object[key], key);
7724 }
7725 }
7726 }
7727 };
7728 const cmp = (a, b) => {
7729 if (typeof a === 'number' && typeof b === 'number') {
7730 return a > b ? 1 : (a < b ? -1 : 0);
7731 }
7732 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
7733 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
7734 if (a > b)
7735 return 1;
7736 if (b > a)
7737 return -1;
7738 return 0;
7739 };
7740 //# sourceMappingURL=utils.js.map
7741
7742 /***/ },
7743
7744 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
7745 /*!*******************************************************************!*\
7746 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
7747 \*******************************************************************/
7748 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7749
7750 "use strict";
7751 __webpack_require__.r(__webpack_exports__);
7752 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7753 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
7754 /* harmony export */ asciifold: () => (/* binding */ asciifold),
7755 /* harmony export */ code_points: () => (/* binding */ code_points),
7756 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
7757 /* harmony export */ generateMap: () => (/* binding */ generateMap),
7758 /* harmony export */ generateSets: () => (/* binding */ generateSets),
7759 /* harmony export */ generator: () => (/* binding */ generator),
7760 /* harmony export */ getPattern: () => (/* binding */ getPattern),
7761 /* harmony export */ initialize: () => (/* binding */ initialize),
7762 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
7763 /* harmony export */ normalize: () => (/* binding */ normalize),
7764 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
7765 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
7766 /* harmony export */ });
7767 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
7768 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
7769
7770
7771 const code_points = [[0, 65535]];
7772 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
7773 let unicode_map;
7774 let multi_char_reg;
7775 const max_char_length = 3;
7776 const latin_convert = {};
7777 const latin_condensed = {
7778 '/': '⁄∕',
7779 '0': '߀',
7780 "a": "ⱥɐɑ",
7781 "aa": "ꜳ",
7782 "ae": "æǽǣ",
7783 "ao": "ꜵ",
7784 "au": "ꜷ",
7785 "av": "ꜹꜻ",
7786 "ay": "ꜽ",
7787 "b": "ƀɓƃ",
7788 "c": "ꜿƈȼↄ",
7789 "d": "đɗɖᴅƌꮷԁɦ",
7790 "e": "ɛǝᴇɇ",
7791 "f": "ꝼƒ",
7792 "g": "ǥɠꞡᵹꝿɢ",
7793 "h": "ħⱨⱶɥ",
7794 "i": "ɨı",
7795 "j": "ɉȷ",
7796 "k": "ƙⱪꝁꝃꝅꞣ",
7797 "l": "łƚɫⱡꝉꝇꞁɭ",
7798 "m": "ɱɯϻ",
7799 "n": "ꞥƞɲꞑᴎлԉ",
7800 "o": "øǿɔɵꝋꝍᴑ",
7801 "oe": "œ",
7802 "oi": "ƣ",
7803 "oo": "ꝏ",
7804 "ou": "ȣ",
7805 "p": "ƥᵽꝑꝓꝕρ",
7806 "q": "ꝗꝙɋ",
7807 "r": "ɍɽꝛꞧꞃ",
7808 "s": "ßȿꞩꞅʂ",
7809 "t": "ŧƭʈⱦꞇ",
7810 "th": "þ",
7811 "tz": "ꜩ",
7812 "u": "ʉ",
7813 "v": "ʋꝟʌ",
7814 "vy": "ꝡ",
7815 "w": "ⱳ",
7816 "y": "ƴɏỿ",
7817 "z": "ƶȥɀⱬꝣ",
7818 "hv": "ƕ"
7819 };
7820 for (let latin in latin_condensed) {
7821 let unicode = latin_condensed[latin] || '';
7822 for (let i = 0; i < unicode.length; i++) {
7823 let char = unicode.substring(i, i + 1);
7824 latin_convert[char] = latin;
7825 }
7826 }
7827 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
7828 /**
7829 * Initialize the unicode_map from the give code point ranges
7830 */
7831 const initialize = (_code_points) => {
7832 if (unicode_map !== undefined)
7833 return;
7834 unicode_map = generateMap(_code_points || code_points);
7835 };
7836 /**
7837 * Helper method for normalize a string
7838 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
7839 */
7840 const normalize = (str, form = 'NFKD') => str.normalize(form);
7841 /**
7842 * Remove accents without reordering string
7843 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
7844 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
7845 */
7846 const asciifold = (str) => {
7847 return Array.from(str).reduce(
7848 /**
7849 * @param {string} result
7850 * @param {string} char
7851 */
7852 (result, char) => {
7853 return result + _asciifold(char);
7854 }, '');
7855 };
7856 const _asciifold = (str) => {
7857 str = normalize(str)
7858 .toLowerCase()
7859 .replace(convert_pat, (/** @type {string} */ char) => {
7860 return latin_convert[char] || '';
7861 });
7862 //return str;
7863 return normalize(str, 'NFC');
7864 };
7865 /**
7866 * Generate a list of unicode variants from the list of code points
7867 */
7868 function* generator(code_points) {
7869 for (const [code_point_min, code_point_max] of code_points) {
7870 for (let i = code_point_min; i <= code_point_max; i++) {
7871 let composed = String.fromCharCode(i);
7872 let folded = asciifold(composed);
7873 if (folded == composed.toLowerCase()) {
7874 continue;
7875 }
7876 // skip when folded is a string longer than 3 characters long
7877 // bc the resulting regex patterns will be long
7878 // eg:
7879 // folded صلى الله عليه وسلم length 18 code point 65018
7880 // folded جل جلاله length 8 code point 65019
7881 if (folded.length > max_char_length) {
7882 continue;
7883 }
7884 if (folded.length == 0) {
7885 continue;
7886 }
7887 yield { folded: folded, composed: composed, code_point: i };
7888 }
7889 }
7890 }
7891 /**
7892 * Generate a unicode map from the list of code points
7893 */
7894 const generateSets = (code_points) => {
7895 const unicode_sets = {};
7896 const addMatching = (folded, to_add) => {
7897 /** @type {Set<string>} */
7898 const folded_set = unicode_sets[folded] || new Set();
7899 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
7900 if (to_add.match(patt)) {
7901 return;
7902 }
7903 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
7904 unicode_sets[folded] = folded_set;
7905 };
7906 for (let value of generator(code_points)) {
7907 addMatching(value.folded, value.folded);
7908 addMatching(value.folded, value.composed);
7909 }
7910 return unicode_sets;
7911 };
7912 /**
7913 * Generate a unicode map from the list of code points
7914 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
7915 */
7916 const generateMap = (code_points) => {
7917 const unicode_sets = generateSets(code_points);
7918 const unicode_map = {};
7919 let multi_char = [];
7920 for (let folded in unicode_sets) {
7921 let set = unicode_sets[folded];
7922 if (set) {
7923 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
7924 }
7925 if (folded.length > 1) {
7926 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
7927 }
7928 }
7929 multi_char.sort((a, b) => b.length - a.length);
7930 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
7931 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
7932 return unicode_map;
7933 };
7934 /**
7935 * Map each element of an array from its folded value to all possible unicode matches
7936 */
7937 const mapSequence = (strings, min_replacement = 1) => {
7938 let chars_replaced = 0;
7939 strings = strings.map((str) => {
7940 if (unicode_map[str]) {
7941 chars_replaced += str.length;
7942 }
7943 return unicode_map[str] || str;
7944 });
7945 if (chars_replaced >= min_replacement) {
7946 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
7947 }
7948 return '';
7949 };
7950 /**
7951 * Convert a short string and split it into all possible patterns
7952 * Keep a pattern only if min_replacement is met
7953 *
7954 * 'abc'
7955 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
7956 * => ['abc-pattern','ab-c-pattern'...]
7957 */
7958 const substringsToPattern = (str, min_replacement = 1) => {
7959 min_replacement = Math.max(min_replacement, str.length - 1);
7960 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
7961 return mapSequence(sub_pat, min_replacement);
7962 }));
7963 };
7964 /**
7965 * Convert an array of sequences into a pattern
7966 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
7967 */
7968 const sequencesToPattern = (sequences, all = true) => {
7969 let min_replacement = sequences.length > 1 ? 1 : 0;
7970 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
7971 let seq = [];
7972 const len = all ? sequence.length() : sequence.length() - 1;
7973 for (let j = 0; j < len; j++) {
7974 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
7975 }
7976 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
7977 }));
7978 };
7979 /**
7980 * Return true if the sequence is already in the sequences
7981 */
7982 const inSequences = (needle_seq, sequences) => {
7983 for (const seq of sequences) {
7984 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
7985 continue;
7986 }
7987 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
7988 continue;
7989 }
7990 let needle_parts = needle_seq.parts;
7991 const filter = (part) => {
7992 for (const needle_part of needle_parts) {
7993 if (needle_part.start === part.start && needle_part.substr === part.substr) {
7994 return false;
7995 }
7996 if (part.length == 1 || needle_part.length == 1) {
7997 continue;
7998 }
7999 // check for overlapping parts
8000 // a = ['::=','==']
8001 // b = ['::','===']
8002 // a = ['r','sm']
8003 // b = ['rs','m']
8004 if (part.start < needle_part.start && part.end > needle_part.start) {
8005 return true;
8006 }
8007 if (needle_part.start < part.start && needle_part.end > part.start) {
8008 return true;
8009 }
8010 }
8011 return false;
8012 };
8013 let filtered = seq.parts.filter(filter);
8014 if (filtered.length > 0) {
8015 continue;
8016 }
8017 return true;
8018 }
8019 return false;
8020 };
8021 class Sequence {
8022 parts;
8023 substrs;
8024 start;
8025 end;
8026 constructor() {
8027 this.parts = [];
8028 this.substrs = [];
8029 this.start = 0;
8030 this.end = 0;
8031 }
8032 add(part) {
8033 if (part) {
8034 this.parts.push(part);
8035 this.substrs.push(part.substr);
8036 this.start = Math.min(part.start, this.start);
8037 this.end = Math.max(part.end, this.end);
8038 }
8039 }
8040 last() {
8041 return this.parts[this.parts.length - 1];
8042 }
8043 length() {
8044 return this.parts.length;
8045 }
8046 clone(position, last_piece) {
8047 let clone = new Sequence();
8048 let parts = JSON.parse(JSON.stringify(this.parts));
8049 let last_part = parts.pop();
8050 for (const part of parts) {
8051 clone.add(part);
8052 }
8053 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8054 let clone_last_len = last_substr.length;
8055 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8056 return clone;
8057 }
8058 }
8059 /**
8060 * Expand a regular expression pattern to include unicode variants
8061 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8062 *
8063 * Issue:
8064 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8065 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8066 *
8067 * İIJ = IIJ = ⅡJ
8068 *
8069 * 1/2/4
8070 */
8071 const getPattern = (str) => {
8072 initialize();
8073 str = asciifold(str);
8074 let pattern = '';
8075 let sequences = [new Sequence()];
8076 for (let i = 0; i < str.length; i++) {
8077 let substr = str.substring(i);
8078 let match = substr.match(multi_char_reg);
8079 const char = str.substring(i, i + 1);
8080 const match_str = match ? match[0] : null;
8081 // loop through sequences
8082 // add either the char or multi_match
8083 let overlapping = [];
8084 let added_types = new Set();
8085 for (const sequence of sequences) {
8086 const last_piece = sequence.last();
8087 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8088 // if we have a multi match
8089 if (match_str) {
8090 const len = match_str.length;
8091 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8092 added_types.add('1');
8093 }
8094 else {
8095 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8096 added_types.add('2');
8097 }
8098 }
8099 else if (match_str) {
8100 let clone = sequence.clone(i, last_piece);
8101 const len = match_str.length;
8102 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8103 overlapping.push(clone);
8104 }
8105 else {
8106 // don't add char
8107 // adding would create invalid patterns: 234 => [2,34,4]
8108 added_types.add('3');
8109 }
8110 }
8111 // if we have overlapping
8112 if (overlapping.length > 0) {
8113 // ['ii','iii'] before ['i','i','iii']
8114 overlapping = overlapping.sort((a, b) => {
8115 return a.length() - b.length();
8116 });
8117 for (let clone of overlapping) {
8118 // don't add if we already have an equivalent sequence
8119 if (inSequences(clone, sequences)) {
8120 continue;
8121 }
8122 sequences.push(clone);
8123 }
8124 continue;
8125 }
8126 // if we haven't done anything unique
8127 // clean up the patterns
8128 // helps keep patterns smaller
8129 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8130 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8131 pattern += sequencesToPattern(sequences, false);
8132 let new_seq = new Sequence();
8133 const old_seq = sequences[0];
8134 if (old_seq) {
8135 new_seq.add(old_seq.last());
8136 }
8137 sequences = [new_seq];
8138 }
8139 }
8140 pattern += sequencesToPattern(sequences, true);
8141 return pattern;
8142 };
8143
8144 //# sourceMappingURL=index.js.map
8145
8146 /***/ },
8147
8148 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8149 /*!*******************************************************************!*\
8150 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8151 \*******************************************************************/
8152 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8153
8154 "use strict";
8155 __webpack_require__.r(__webpack_exports__);
8156 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8157 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8158 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8159 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8160 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8161 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8162 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8163 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8164 /* harmony export */ });
8165 /**
8166 * Convert array of strings to a regular expression
8167 * ex ['ab','a'] => (?:ab|a)
8168 * ex ['a','b'] => [ab]
8169 */
8170 const arrayToPattern = (chars) => {
8171 chars = chars.filter(Boolean);
8172 if (chars.length < 2) {
8173 return chars[0] || '';
8174 }
8175 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8176 };
8177 const sequencePattern = (array) => {
8178 if (!hasDuplicates(array)) {
8179 return array.join('');
8180 }
8181 let pattern = '';
8182 let prev_char_count = 0;
8183 const prev_pattern = () => {
8184 if (prev_char_count > 1) {
8185 pattern += '{' + prev_char_count + '}';
8186 }
8187 };
8188 array.forEach((char, i) => {
8189 if (char === array[i - 1]) {
8190 prev_char_count++;
8191 return;
8192 }
8193 prev_pattern();
8194 pattern += char;
8195 prev_char_count = 1;
8196 });
8197 prev_pattern();
8198 return pattern;
8199 };
8200 /**
8201 * Convert array of strings to a regular expression
8202 * ex ['ab','a'] => (?:ab|a)
8203 * ex ['a','b'] => [ab]
8204 */
8205 const setToPattern = (chars) => {
8206 let array = Array.from(chars);
8207 return arrayToPattern(array);
8208 };
8209 /**
8210 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8211 */
8212 const hasDuplicates = (array) => {
8213 return (new Set(array)).size !== array.length;
8214 };
8215 /**
8216 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8217 */
8218 const escape_regex = (str) => {
8219 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8220 };
8221 /**
8222 * Return the max length of array values
8223 */
8224 const maxValueLength = (array) => {
8225 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8226 };
8227 const unicodeLength = (str) => {
8228 return Array.from(str).length;
8229 };
8230 //# sourceMappingURL=regex.js.map
8231
8232 /***/ },
8233
8234 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8235 /*!*********************************************************************!*\
8236 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8237 \*********************************************************************/
8238 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8239
8240 "use strict";
8241 __webpack_require__.r(__webpack_exports__);
8242 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8243 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8244 /* harmony export */ });
8245 /**
8246 * Get all possible combinations of substrings that add up to the given string
8247 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8248 */
8249 const allSubstrings = (input) => {
8250 if (input.length === 1)
8251 return [[input]];
8252 let result = [];
8253 const start = input.substring(1);
8254 const suba = allSubstrings(start);
8255 suba.forEach(function (subresult) {
8256 let tmp = subresult.slice(0);
8257 tmp[0] = input.charAt(0) + tmp[0];
8258 result.push(tmp);
8259 tmp = subresult.slice(0);
8260 tmp.unshift(input.charAt(0));
8261 result.push(tmp);
8262 });
8263 return result;
8264 };
8265 //# sourceMappingURL=strings.js.map
8266
8267 /***/ },
8268
8269 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8270 /*!*******************************************************!*\
8271 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8272 \*******************************************************/
8273 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8274
8275 "use strict";
8276 __webpack_require__.r(__webpack_exports__);
8277 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8278 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8279 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8280 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8281 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8282 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8283 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8284 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8285 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8286 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8287 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8288 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8289 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8290 /* harmony export */ });
8291 const KEY_A = 65;
8292 const KEY_RETURN = 13;
8293 const KEY_ESC = 27;
8294 const KEY_LEFT = 37;
8295 const KEY_UP = 38;
8296 const KEY_RIGHT = 39;
8297 const KEY_DOWN = 40;
8298 const KEY_BACKSPACE = 8;
8299 const KEY_DELETE = 46;
8300 const KEY_TAB = 9;
8301 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8302 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8303 //# sourceMappingURL=constants.js.map
8304
8305 /***/ },
8306
8307 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8308 /*!***************************************************************!*\
8309 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8310 \***************************************************************/
8311 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8312
8313 "use strict";
8314 __webpack_require__.r(__webpack_exports__);
8315 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8316 /* harmony export */ highlight: () => (/* binding */ highlight),
8317 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8318 /* harmony export */ });
8319 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8320 /**
8321 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
8322 * Highlights arbitrary terms in a node.
8323 *
8324 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
8325 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
8326 */
8327
8328 const highlight = (element, regex) => {
8329 if (regex === null)
8330 return;
8331 // convet string to regex
8332 if (typeof regex === 'string') {
8333 if (!regex.length)
8334 return;
8335 regex = new RegExp(regex, 'i');
8336 }
8337 // Wrap matching part of text node with highlighting <span>, e.g.
8338 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8339 const highlightText = (node) => {
8340 var match = node.data.match(regex);
8341 if (match && node.data.length > 0) {
8342 var spannode = document.createElement('span');
8343 spannode.className = 'highlight';
8344 var middlebit = node.splitText(match.index);
8345 middlebit.splitText(match[0].length);
8346 var middleclone = middlebit.cloneNode(true);
8347 spannode.appendChild(middleclone);
8348 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8349 return 1;
8350 }
8351 return 0;
8352 };
8353 // Recurse element node, looking for child text nodes to highlight, unless element
8354 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8355 const highlightChildren = (node) => {
8356 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8357 Array.from(node.childNodes).forEach(element => {
8358 highlightRecursive(element);
8359 });
8360 }
8361 };
8362 const highlightRecursive = (node) => {
8363 if (node.nodeType === 3) {
8364 return highlightText(node);
8365 }
8366 highlightChildren(node);
8367 return 0;
8368 };
8369 highlightRecursive(element);
8370 };
8371 /**
8372 * removeHighlight fn copied from highlight v5 and
8373 * edited to remove with(), pass js strict mode, and use without jquery
8374 */
8375 const removeHighlight = (el) => {
8376 var elements = el.querySelectorAll("span.highlight");
8377 Array.prototype.forEach.call(elements, function (el) {
8378 var parent = el.parentNode;
8379 parent.replaceChild(el.firstChild, el);
8380 parent.normalize();
8381 });
8382 };
8383 //# sourceMappingURL=highlight.js.map
8384
8385 /***/ },
8386
8387 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8388 /*!****************************************************************!*\
8389 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8390 \****************************************************************/
8391 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8392
8393 "use strict";
8394 __webpack_require__.r(__webpack_exports__);
8395 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8396 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8397 /* harmony export */ });
8398 /**
8399 * MicroEvent - to make any js object an event emitter
8400 *
8401 * - pure javascript - server compatible, browser compatible
8402 * - dont rely on the browser doms
8403 * - super simple - you get it immediatly, no mistery, no magic involved
8404 *
8405 * @author Jerome Etienne (https://github.com/jeromeetienne)
8406 */
8407 /**
8408 * Execute callback for each event in space separated list of event names
8409 *
8410 */
8411 function forEvents(events, callback) {
8412 events.split(/\s+/).forEach((event) => {
8413 callback(event);
8414 });
8415 }
8416 class MicroEvent {
8417 constructor() {
8418 this._events = {};
8419 }
8420 on(events, fct) {
8421 forEvents(events, (event) => {
8422 const event_array = this._events[event] || [];
8423 event_array.push(fct);
8424 this._events[event] = event_array;
8425 });
8426 }
8427 off(events, fct) {
8428 var n = arguments.length;
8429 if (n === 0) {
8430 this._events = {};
8431 return;
8432 }
8433 forEvents(events, (event) => {
8434 if (n === 1) {
8435 delete this._events[event];
8436 return;
8437 }
8438 const event_array = this._events[event];
8439 if (event_array === undefined)
8440 return;
8441 event_array.splice(event_array.indexOf(fct), 1);
8442 this._events[event] = event_array;
8443 });
8444 }
8445 trigger(events, ...args) {
8446 var self = this;
8447 forEvents(events, (event) => {
8448 const event_array = self._events[event];
8449 if (event_array === undefined)
8450 return;
8451 event_array.forEach(fct => {
8452 fct.apply(self, args);
8453 });
8454 });
8455 }
8456 }
8457 ;
8458 //# sourceMappingURL=microevent.js.map
8459
8460 /***/ },
8461
8462 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
8463 /*!*****************************************************************!*\
8464 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
8465 \*****************************************************************/
8466 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8467
8468 "use strict";
8469 __webpack_require__.r(__webpack_exports__);
8470 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8471 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
8472 /* harmony export */ });
8473 /**
8474 * microplugin.js
8475 * Copyright (c) 2013 Brian Reavis & contributors
8476 *
8477 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8478 * file except in compliance with the License. You may obtain a copy of the License at:
8479 * http://www.apache.org/licenses/LICENSE-2.0
8480 *
8481 * Unless required by applicable law or agreed to in writing, software distributed under
8482 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8483 * ANY KIND, either express or implied. See the License for the specific language
8484 * governing permissions and limitations under the License.
8485 *
8486 * @author Brian Reavis <brian@thirdroute.com>
8487 */
8488 function MicroPlugin(Interface) {
8489 Interface.plugins = {};
8490 return class extends Interface {
8491 constructor() {
8492 super(...arguments);
8493 this.plugins = {
8494 names: [],
8495 settings: {},
8496 requested: {},
8497 loaded: {}
8498 };
8499 }
8500 /**
8501 * Registers a plugin.
8502 *
8503 * @param {function} fn
8504 */
8505 static define(name, fn) {
8506 Interface.plugins[name] = {
8507 'name': name,
8508 'fn': fn
8509 };
8510 }
8511 /**
8512 * Initializes the listed plugins (with options).
8513 * Acceptable formats:
8514 *
8515 * List (without options):
8516 * ['a', 'b', 'c']
8517 *
8518 * List (with options):
8519 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
8520 *
8521 * Hash (with options):
8522 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
8523 *
8524 * @param {array|object} plugins
8525 */
8526 initializePlugins(plugins) {
8527 var key, name;
8528 const self = this;
8529 const queue = [];
8530 if (Array.isArray(plugins)) {
8531 plugins.forEach((plugin) => {
8532 if (typeof plugin === 'string') {
8533 queue.push(plugin);
8534 }
8535 else {
8536 self.plugins.settings[plugin.name] = plugin.options;
8537 queue.push(plugin.name);
8538 }
8539 });
8540 }
8541 else if (plugins) {
8542 for (key in plugins) {
8543 if (plugins.hasOwnProperty(key)) {
8544 self.plugins.settings[key] = plugins[key];
8545 queue.push(key);
8546 }
8547 }
8548 }
8549 while (name = queue.shift()) {
8550 self.require(name);
8551 }
8552 }
8553 loadPlugin(name) {
8554 var self = this;
8555 var plugins = self.plugins;
8556 var plugin = Interface.plugins[name];
8557 if (!Interface.plugins.hasOwnProperty(name)) {
8558 throw new Error('Unable to find "' + name + '" plugin');
8559 }
8560 plugins.requested[name] = true;
8561 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
8562 plugins.names.push(name);
8563 }
8564 /**
8565 * Initializes a plugin.
8566 *
8567 */
8568 require(name) {
8569 var self = this;
8570 var plugins = self.plugins;
8571 if (!self.plugins.loaded.hasOwnProperty(name)) {
8572 if (plugins.requested[name]) {
8573 throw new Error('Plugin has circular dependency ("' + name + '")');
8574 }
8575 self.loadPlugin(name);
8576 }
8577 return plugins.loaded[name];
8578 }
8579 };
8580 }
8581 //# sourceMappingURL=microplugin.js.map
8582
8583 /***/ },
8584
8585 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
8586 /*!******************************************************!*\
8587 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
8588 \******************************************************/
8589 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8590
8591 "use strict";
8592 __webpack_require__.r(__webpack_exports__);
8593 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8594 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8595 /* harmony export */ });
8596 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
8597 options: [],
8598 optgroups: [],
8599 plugins: [],
8600 delimiter: ',',
8601 splitOn: null, // regexp or string for splitting up values from a paste command
8602 persist: true,
8603 diacritics: true,
8604 create: null,
8605 createOnBlur: false,
8606 createFilter: null,
8607 clearAfterSelect: false,
8608 highlight: true,
8609 openOnFocus: true,
8610 shouldOpen: null,
8611 maxOptions: 50,
8612 maxItems: null,
8613 hideSelected: null,
8614 duplicates: false,
8615 addPrecedence: false,
8616 selectOnTab: false,
8617 preload: null,
8618 allowEmptyOption: false,
8619 //closeAfterSelect: false,
8620 refreshThrottle: 300,
8621 loadThrottle: 300,
8622 loadingClass: 'loading',
8623 dataAttr: null, //'data-data',
8624 optgroupField: 'optgroup',
8625 valueField: 'value',
8626 labelField: 'text',
8627 disabledField: 'disabled',
8628 optgroupLabelField: 'label',
8629 optgroupValueField: 'value',
8630 lockOptgroupOrder: false,
8631 sortField: '$order',
8632 searchField: ['text'],
8633 searchConjunction: 'and',
8634 mode: null,
8635 wrapperClass: 'ts-wrapper',
8636 controlClass: 'ts-control',
8637 dropdownClass: 'ts-dropdown',
8638 dropdownContentClass: 'ts-dropdown-content',
8639 itemClass: 'item',
8640 optionClass: 'option',
8641 dropdownParent: null,
8642 controlInput: '<input type="text" autocomplete="off" size="1" />',
8643 copyClassesToDropdown: false,
8644 placeholder: null,
8645 hidePlaceholder: null,
8646 shouldLoad: function (query) {
8647 return query.length > 0;
8648 },
8649 /*
8650 load : null, // function(query, callback) { ... }
8651 score : null, // function(search) { ... }
8652 onInitialize : null, // function() { ... }
8653 onChange : null, // function(value) { ... }
8654 onItemAdd : null, // function(value, $item) { ... }
8655 onItemRemove : null, // function(value) { ... }
8656 onClear : null, // function() { ... }
8657 onOptionAdd : null, // function(value, data) { ... }
8658 onOptionRemove : null, // function(value) { ... }
8659 onOptionClear : null, // function() { ... }
8660 onOptionGroupAdd : null, // function(id, data) { ... }
8661 onOptionGroupRemove : null, // function(id) { ... }
8662 onOptionGroupClear : null, // function() { ... }
8663 onDropdownOpen : null, // function(dropdown) { ... }
8664 onDropdownClose : null, // function(dropdown) { ... }
8665 onType : null, // function(str) { ... }
8666 onDelete : null, // function(values) { ... }
8667 */
8668 render: {
8669 /*
8670 item: null,
8671 optgroup: null,
8672 optgroup_header: null,
8673 option: null,
8674 option_create: null
8675 */
8676 }
8677 });
8678 //# sourceMappingURL=defaults.js.map
8679
8680 /***/ },
8681
8682 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
8683 /*!*********************************************************!*\
8684 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
8685 \*********************************************************/
8686 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8687
8688 "use strict";
8689 __webpack_require__.r(__webpack_exports__);
8690 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8691 /* harmony export */ "default": () => (/* binding */ getSettings)
8692 /* harmony export */ });
8693 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
8694 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8695
8696
8697 function getSettings(input, settings_user) {
8698 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
8699 var attr_data = settings.dataAttr;
8700 var field_label = settings.labelField;
8701 var field_value = settings.valueField;
8702 var field_disabled = settings.disabledField;
8703 var field_optgroup = settings.optgroupField;
8704 var field_optgroup_label = settings.optgroupLabelField;
8705 var field_optgroup_value = settings.optgroupValueField;
8706 var tag_name = input.tagName.toLowerCase();
8707 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
8708 if (!placeholder && !settings.allowEmptyOption) {
8709 let option = input.querySelector('option[value=""]');
8710 if (option) {
8711 placeholder = option.textContent;
8712 }
8713 }
8714 var settings_element = {
8715 placeholder: placeholder,
8716 options: [],
8717 optgroups: [],
8718 items: [],
8719 maxItems: null,
8720 };
8721 /**
8722 * Initialize from a <select> element.
8723 *
8724 */
8725 var init_select = () => {
8726 var tagName;
8727 var options = settings_element.options;
8728 var optionsMap = {};
8729 var group_count = 1;
8730 let $order = 0;
8731 var readData = (el) => {
8732 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
8733 var json = attr_data && data[attr_data];
8734 if (typeof json === 'string' && json.length) {
8735 data = Object.assign(data, JSON.parse(json));
8736 }
8737 return data;
8738 };
8739 var addOption = (option, group) => {
8740 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
8741 if (value == null)
8742 return;
8743 if (!value && !settings.allowEmptyOption)
8744 return;
8745 // if the option already exists, it's probably been
8746 // duplicated in another optgroup. in this case, push
8747 // the current group to the "optgroup" property on the
8748 // existing option so that it's rendered in both places.
8749 if (optionsMap.hasOwnProperty(value)) {
8750 if (group) {
8751 var arr = optionsMap[value][field_optgroup];
8752 if (!arr) {
8753 optionsMap[value][field_optgroup] = group;
8754 }
8755 else if (!Array.isArray(arr)) {
8756 optionsMap[value][field_optgroup] = [arr, group];
8757 }
8758 else {
8759 arr.push(group);
8760 }
8761 }
8762 }
8763 else {
8764 var option_data = readData(option);
8765 option_data[field_label] = option_data[field_label] || option.textContent;
8766 option_data[field_value] = option_data[field_value] || value;
8767 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
8768 option_data[field_optgroup] = option_data[field_optgroup] || group;
8769 option_data.$option = option;
8770 option_data.$order = option_data.$order || ++$order;
8771 optionsMap[value] = option_data;
8772 options.push(option_data);
8773 }
8774 if (option.selected) {
8775 settings_element.items.push(value);
8776 }
8777 };
8778 var addGroup = (optgroup) => {
8779 var id, optgroup_data;
8780 optgroup_data = readData(optgroup);
8781 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
8782 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
8783 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
8784 optgroup_data.$order = optgroup_data.$order || ++$order;
8785 settings_element.optgroups.push(optgroup_data);
8786 id = optgroup_data[field_optgroup_value];
8787 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
8788 addOption(option, id);
8789 });
8790 };
8791 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
8792 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
8793 tagName = child.tagName.toLowerCase();
8794 if (tagName === 'optgroup') {
8795 addGroup(child);
8796 }
8797 else if (tagName === 'option') {
8798 addOption(child);
8799 }
8800 });
8801 };
8802 /**
8803 * Initialize from a <input type="text"> element.
8804 *
8805 */
8806 var init_textbox = () => {
8807 var _a, _b;
8808 const data_raw = input.getAttribute(attr_data);
8809 if (!data_raw) {
8810 var value = (_b = (_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
8811 if (!settings.allowEmptyOption && !value.length)
8812 return;
8813 const values = value.split(settings.delimiter);
8814 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
8815 const option = {};
8816 option[field_label] = value;
8817 option[field_value] = value;
8818 settings_element.options.push(option);
8819 });
8820 settings_element.items = values;
8821 }
8822 else {
8823 settings_element.options = JSON.parse(data_raw);
8824 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
8825 settings_element.items.push(opt[field_value]);
8826 });
8827 }
8828 };
8829 if (tag_name === 'select') {
8830 init_select();
8831 }
8832 else {
8833 init_textbox();
8834 }
8835 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
8836 }
8837 ;
8838 //# sourceMappingURL=getSettings.js.map
8839
8840 /***/ },
8841
8842 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
8843 /*!***************************************************************************!*\
8844 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
8845 \***************************************************************************/
8846 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8847
8848 "use strict";
8849 __webpack_require__.r(__webpack_exports__);
8850 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8851 /* harmony export */ "default": () => (/* binding */ plugin)
8852 /* harmony export */ });
8853 /**
8854 * Tom Select v2.6.2
8855 * Licensed under the Apache License, Version 2.0 (the "License");
8856 */
8857
8858 /**
8859 * Converts a scalar to its best string representation
8860 * for hash keys and HTML attribute values.
8861 *
8862 * Transformations:
8863 * 'str' -> 'str'
8864 * null -> ''
8865 * undefined -> ''
8866 * true -> '1'
8867 * false -> '0'
8868 * 0 -> '0'
8869 * 1 -> '1'
8870 *
8871 */
8872
8873 /**
8874 * Iterates over arrays and hashes.
8875 *
8876 * ```
8877 * iterate(this.items, function(item, id) {
8878 * // invoked for each item
8879 * });
8880 * ```
8881 *
8882 */
8883 const iterate = (object, callback) => {
8884 if (Array.isArray(object)) {
8885 object.forEach(callback);
8886 } else {
8887 for (var key in object) {
8888 if (object.hasOwnProperty(key)) {
8889 callback(object[key], key);
8890 }
8891 }
8892 }
8893 };
8894
8895 /**
8896 * Remove css classes
8897 *
8898 */
8899 const removeClasses = (elmts, ...classes) => {
8900 var norm_classes = classesArray(classes);
8901 elmts = castAsArray(elmts);
8902 elmts.map(el => {
8903 norm_classes.map(cls => {
8904 el.classList.remove(cls);
8905 });
8906 });
8907 };
8908
8909 /**
8910 * Return arguments
8911 *
8912 */
8913 const classesArray = args => {
8914 var classes = [];
8915 iterate(args, _classes => {
8916 if (typeof _classes === 'string') {
8917 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8918 }
8919 if (Array.isArray(_classes)) {
8920 classes = classes.concat(_classes);
8921 }
8922 });
8923 return classes.filter(Boolean);
8924 };
8925
8926 /**
8927 * Create an array from arg if it's not already an array
8928 *
8929 */
8930 const castAsArray = arg => {
8931 if (!Array.isArray(arg)) {
8932 arg = [arg];
8933 }
8934 return arg;
8935 };
8936
8937 /**
8938 * Get the index of an element amongst sibling nodes of the same type
8939 *
8940 */
8941 const nodeIndex = (el, amongst) => {
8942 if (!el) return -1;
8943 amongst = amongst || el.nodeName;
8944 var i = 0;
8945 while (el = el.previousElementSibling) {
8946 if (el.matches(amongst)) {
8947 i++;
8948 }
8949 }
8950 return i;
8951 };
8952
8953 /**
8954 * Plugin: "dropdown_input" (Tom Select)
8955 * Copyright (c) contributors
8956 *
8957 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8958 * file except in compliance with the License. You may obtain a copy of the License at:
8959 * http://www.apache.org/licenses/LICENSE-2.0
8960 *
8961 * Unless required by applicable law or agreed to in writing, software distributed under
8962 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8963 * ANY KIND, either express or implied. See the License for the specific language
8964 * governing permissions and limitations under the License.
8965 *
8966 */
8967
8968 function plugin () {
8969 var self = this;
8970
8971 /**
8972 * Moves the caret to the specified index.
8973 *
8974 * The input must be moved by leaving it in place and moving the
8975 * siblings, due to the fact that focus cannot be restored once lost
8976 * on mobile webkit devices
8977 *
8978 */
8979 self.hook('instead', 'setCaret', new_pos => {
8980 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
8981 new_pos = self.items.length;
8982 } else {
8983 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
8984 if (new_pos != self.caretPos && !self.isPending) {
8985 self.controlChildren().forEach((child, j) => {
8986 if (j < new_pos) {
8987 self.control_input.insertAdjacentElement('beforebegin', child);
8988 } else {
8989 self.control.appendChild(child);
8990 }
8991 });
8992 }
8993 }
8994 self.caretPos = new_pos;
8995 });
8996 self.hook('instead', 'moveCaret', direction => {
8997 if (!self.isFocused) return;
8998
8999 // move caret before or after selected items
9000 const last_active = self.getLastActive(direction);
9001 if (last_active) {
9002 const idx = nodeIndex(last_active);
9003 self.setCaret(direction > 0 ? idx + 1 : idx);
9004 self.setActiveItem();
9005 removeClasses(last_active, 'last-active');
9006
9007 // move caret left or right of current position
9008 } else {
9009 self.setCaret(self.caretPos + direction);
9010 }
9011 });
9012 }
9013
9014
9015 //# sourceMappingURL=plugin.js.map
9016
9017
9018 /***/ },
9019
9020 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9021 /*!****************************************************************************!*\
9022 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9023 \****************************************************************************/
9024 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9025
9026 "use strict";
9027 __webpack_require__.r(__webpack_exports__);
9028 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9029 /* harmony export */ "default": () => (/* binding */ plugin)
9030 /* harmony export */ });
9031 /**
9032 * Tom Select v2.6.2
9033 * Licensed under the Apache License, Version 2.0 (the "License");
9034 */
9035
9036 /**
9037 * Converts a scalar to its best string representation
9038 * for hash keys and HTML attribute values.
9039 *
9040 * Transformations:
9041 * 'str' -> 'str'
9042 * null -> ''
9043 * undefined -> ''
9044 * true -> '1'
9045 * false -> '0'
9046 * 0 -> '0'
9047 * 1 -> '1'
9048 *
9049 */
9050
9051 /**
9052 * Add event helper
9053 *
9054 */
9055 const addEvent = (target, type, callback, options) => {
9056 target.addEventListener(type, callback, options);
9057 };
9058
9059 /**
9060 * Plugin: "change_listener" (Tom Select)
9061 * Copyright (c) contributors
9062 *
9063 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9064 * file except in compliance with the License. You may obtain a copy of the License at:
9065 * http://www.apache.org/licenses/LICENSE-2.0
9066 *
9067 * Unless required by applicable law or agreed to in writing, software distributed under
9068 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9069 * ANY KIND, either express or implied. See the License for the specific language
9070 * governing permissions and limitations under the License.
9071 *
9072 */
9073
9074 function plugin () {
9075 addEvent(this.input, 'change', () => {
9076 this.sync();
9077 });
9078 }
9079
9080
9081 //# sourceMappingURL=plugin.js.map
9082
9083
9084 /***/ },
9085
9086 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9087 /*!*****************************************************************************!*\
9088 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9089 \*****************************************************************************/
9090 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9091
9092 "use strict";
9093 __webpack_require__.r(__webpack_exports__);
9094 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9095 /* harmony export */ "default": () => (/* binding */ plugin)
9096 /* harmony export */ });
9097 /**
9098 * Tom Select v2.6.2
9099 * Licensed under the Apache License, Version 2.0 (the "License");
9100 */
9101
9102 /**
9103 * Converts a scalar to its best string representation
9104 * for hash keys and HTML attribute values.
9105 *
9106 * Transformations:
9107 * 'str' -> 'str'
9108 * null -> ''
9109 * undefined -> ''
9110 * true -> '1'
9111 * false -> '0'
9112 * 0 -> '0'
9113 * 1 -> '1'
9114 *
9115 */
9116 const hash_key = value => {
9117 if (typeof value === 'undefined' || value === null) return null;
9118 return get_hash(value);
9119 };
9120 const get_hash = value => {
9121 if (typeof value === 'boolean') return value ? '1' : '0';
9122 return value + '';
9123 };
9124
9125 /**
9126 * Prevent default
9127 *
9128 */
9129 const preventDefault = (evt, stop = false) => {
9130 if (evt) {
9131 evt.preventDefault();
9132 if (stop) {
9133 evt.stopPropagation();
9134 }
9135 }
9136 };
9137
9138 /**
9139 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9140 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9141 *
9142 * param query should be {}
9143 */
9144 const getDom = query => {
9145 if (query.jquery) {
9146 return query[0];
9147 }
9148 if (query instanceof HTMLElement) {
9149 return query;
9150 }
9151 if (isHtmlString(query)) {
9152 var tpl = document.createElement('template');
9153 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9154 return tpl.content.firstChild;
9155 }
9156 return document.querySelector(query);
9157 };
9158 const isHtmlString = arg => {
9159 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9160 return true;
9161 }
9162 return false;
9163 };
9164
9165 /**
9166 * Plugin: "checkbox_options" (Tom Select)
9167 * Copyright (c) contributors
9168 *
9169 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9170 * file except in compliance with the License. You may obtain a copy of the License at:
9171 * http://www.apache.org/licenses/LICENSE-2.0
9172 *
9173 * Unless required by applicable law or agreed to in writing, software distributed under
9174 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9175 * ANY KIND, either express or implied. See the License for the specific language
9176 * governing permissions and limitations under the License.
9177 *
9178 */
9179
9180 function plugin (userOptions) {
9181 var self = this;
9182 var orig_onOptionSelect = self.onOptionSelect;
9183 self.settings.hideSelected = false;
9184 const cbOptions = Object.assign({
9185 // so that the user may add different ones as well
9186 className: "tomselect-checkbox",
9187 // the following default to the historic plugin's values
9188 checkedClassNames: undefined,
9189 uncheckedClassNames: undefined
9190 }, userOptions);
9191 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9192 if (toCheck) {
9193 checkbox.checked = true;
9194 if (cbOptions.uncheckedClassNames) {
9195 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9196 }
9197 if (cbOptions.checkedClassNames) {
9198 checkbox.classList.add(...cbOptions.checkedClassNames);
9199 }
9200 } else {
9201 checkbox.checked = false;
9202 if (cbOptions.checkedClassNames) {
9203 checkbox.classList.remove(...cbOptions.checkedClassNames);
9204 }
9205 if (cbOptions.uncheckedClassNames) {
9206 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9207 }
9208 }
9209 };
9210
9211 // update the checkbox for an option
9212 var UpdateCheckbox = function UpdateCheckbox(option) {
9213 setTimeout(() => {
9214 var checkbox = option.querySelector('input.' + cbOptions.className);
9215 if (checkbox instanceof HTMLInputElement) {
9216 UpdateChecked(checkbox, option.classList.contains('selected'));
9217 }
9218 }, 1);
9219 };
9220
9221 // add checkbox to option template
9222 self.hook('after', 'setupTemplates', () => {
9223 var orig_render_option = self.settings.render.option;
9224 self.settings.render.option = (data, escape_html) => {
9225 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9226 var checkbox = document.createElement('input');
9227 if (cbOptions.className) {
9228 checkbox.classList.add(cbOptions.className);
9229 }
9230 checkbox.addEventListener('click', function (evt) {
9231 preventDefault(evt);
9232 });
9233 checkbox.type = 'checkbox';
9234 const hashed = hash_key(data[self.settings.valueField]);
9235 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9236 rendered.prepend(checkbox);
9237 return rendered;
9238 };
9239 });
9240
9241 // uncheck when item removed
9242 self.on('item_remove', value => {
9243 var option = self.getOption(value);
9244 if (option) {
9245 // if dropdown hasn't been opened yet, the option won't exist
9246 option.classList.remove('selected'); // selected class won't be removed yet
9247 UpdateCheckbox(option);
9248 }
9249 });
9250
9251 // check when item added
9252 self.on('item_add', value => {
9253 var option = self.getOption(value);
9254 if (option) {
9255 // if dropdown hasn't been opened yet, the option won't exist
9256 UpdateCheckbox(option);
9257 }
9258 });
9259
9260 // remove items when selected option is clicked
9261 self.hook('instead', 'onOptionSelect', (evt, option) => {
9262 if (option.classList.contains('selected')) {
9263 option.classList.remove('selected');
9264 self.removeItem(option.dataset.value);
9265 self.refreshOptions();
9266 preventDefault(evt, true);
9267 return;
9268 }
9269 orig_onOptionSelect.call(self, evt, option);
9270 UpdateCheckbox(option);
9271 });
9272 }
9273
9274
9275 //# sourceMappingURL=plugin.js.map
9276
9277
9278 /***/ },
9279
9280 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9281 /*!*************************************************************************!*\
9282 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9283 \*************************************************************************/
9284 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9285
9286 "use strict";
9287 __webpack_require__.r(__webpack_exports__);
9288 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9289 /* harmony export */ "default": () => (/* binding */ plugin)
9290 /* harmony export */ });
9291 /**
9292 * Tom Select v2.6.2
9293 * Licensed under the Apache License, Version 2.0 (the "License");
9294 */
9295
9296 /**
9297 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9298 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9299 *
9300 * param query should be {}
9301 */
9302 const getDom = query => {
9303 if (query.jquery) {
9304 return query[0];
9305 }
9306 if (query instanceof HTMLElement) {
9307 return query;
9308 }
9309 if (isHtmlString(query)) {
9310 var tpl = document.createElement('template');
9311 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9312 return tpl.content.firstChild;
9313 }
9314 return document.querySelector(query);
9315 };
9316 const isHtmlString = arg => {
9317 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9318 return true;
9319 }
9320 return false;
9321 };
9322
9323 /**
9324 * Plugin: "dropdown_header" (Tom Select)
9325 * Copyright (c) contributors
9326 *
9327 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9328 * file except in compliance with the License. You may obtain a copy of the License at:
9329 * http://www.apache.org/licenses/LICENSE-2.0
9330 *
9331 * Unless required by applicable law or agreed to in writing, software distributed under
9332 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9333 * ANY KIND, either express or implied. See the License for the specific language
9334 * governing permissions and limitations under the License.
9335 *
9336 */
9337
9338 function plugin (userOptions) {
9339 const self = this;
9340 const options = Object.assign({
9341 className: 'clear-button',
9342 title: 'Clear All',
9343 role: 'button',
9344 tabindex: 0,
9345 html: data => {
9346 return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">&times;</div>`;
9347 }
9348 }, userOptions);
9349 self.on('initialize', () => {
9350 var button = getDom(options.html(options));
9351 button.addEventListener('click', evt => {
9352 if (self.isLocked) return;
9353 self.clear();
9354 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9355 self.addItem('');
9356 }
9357 self.refreshOptions(false);
9358 evt.preventDefault();
9359 evt.stopPropagation();
9360 });
9361 self.control.appendChild(button);
9362 });
9363 }
9364
9365
9366 //# sourceMappingURL=plugin.js.map
9367
9368
9369 /***/ },
9370
9371 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9372 /*!**********************************************************************!*\
9373 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9374 \**********************************************************************/
9375 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9376
9377 "use strict";
9378 __webpack_require__.r(__webpack_exports__);
9379 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9380 /* harmony export */ "default": () => (/* binding */ plugin)
9381 /* harmony export */ });
9382 /**
9383 * Tom Select v2.6.2
9384 * Licensed under the Apache License, Version 2.0 (the "License");
9385 */
9386
9387 /**
9388 * Converts a scalar to its best string representation
9389 * for hash keys and HTML attribute values.
9390 *
9391 * Transformations:
9392 * 'str' -> 'str'
9393 * null -> ''
9394 * undefined -> ''
9395 * true -> '1'
9396 * false -> '0'
9397 * 0 -> '0'
9398 * 1 -> '1'
9399 *
9400 */
9401
9402 /**
9403 * Prevent default
9404 *
9405 */
9406 const preventDefault = (evt, stop = false) => {
9407 if (evt) {
9408 evt.preventDefault();
9409 if (stop) {
9410 evt.stopPropagation();
9411 }
9412 }
9413 };
9414
9415 /**
9416 * Add event helper
9417 *
9418 */
9419 const addEvent = (target, type, callback, options) => {
9420 target.addEventListener(type, callback, options);
9421 };
9422
9423 /**
9424 * Iterates over arrays and hashes.
9425 *
9426 * ```
9427 * iterate(this.items, function(item, id) {
9428 * // invoked for each item
9429 * });
9430 * ```
9431 *
9432 */
9433 const iterate = (object, callback) => {
9434 if (Array.isArray(object)) {
9435 object.forEach(callback);
9436 } else {
9437 for (var key in object) {
9438 if (object.hasOwnProperty(key)) {
9439 callback(object[key], key);
9440 }
9441 }
9442 }
9443 };
9444
9445 /**
9446 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9447 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9448 *
9449 * param query should be {}
9450 */
9451 const getDom = query => {
9452 if (query.jquery) {
9453 return query[0];
9454 }
9455 if (query instanceof HTMLElement) {
9456 return query;
9457 }
9458 if (isHtmlString(query)) {
9459 var tpl = document.createElement('template');
9460 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9461 return tpl.content.firstChild;
9462 }
9463 return document.querySelector(query);
9464 };
9465 const isHtmlString = arg => {
9466 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9467 return true;
9468 }
9469 return false;
9470 };
9471
9472 /**
9473 * Set attributes of an element
9474 *
9475 */
9476 const setAttr = (el, attrs) => {
9477 iterate(attrs, (val, attr) => {
9478 if (val == null) {
9479 el.removeAttribute(attr);
9480 } else {
9481 el.setAttribute(attr, '' + val);
9482 }
9483 });
9484 };
9485
9486 /**
9487 * Plugin: "drag_drop" (Tom Select)
9488 * Copyright (c) contributors
9489 *
9490 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9491 * file except in compliance with the License. You may obtain a copy of the License at:
9492 * http://www.apache.org/licenses/LICENSE-2.0
9493 *
9494 * Unless required by applicable law or agreed to in writing, software distributed under
9495 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9496 * ANY KIND, either express or implied. See the License for the specific language
9497 * governing permissions and limitations under the License.
9498 *
9499 */
9500
9501 const insertAfter = (referenceNode, newNode) => {
9502 var _referenceNode$parent;
9503 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
9504 };
9505 const insertBefore = (referenceNode, newNode) => {
9506 var _referenceNode$parent2;
9507 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
9508 };
9509 const isBefore = (referenceNode, newNode) => {
9510 do {
9511 var _newNode;
9512 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
9513 if (referenceNode == newNode) {
9514 return true;
9515 }
9516 } while (newNode && newNode.previousElementSibling);
9517 return false;
9518 };
9519 function plugin () {
9520 var self = this;
9521 if (self.settings.mode !== 'multi') return;
9522 var orig_lock = self.lock;
9523 var orig_unlock = self.unlock;
9524 let sortable = true;
9525 let drag_item;
9526
9527 /**
9528 * Add draggable attribute to item
9529 */
9530 self.hook('after', 'setupTemplates', () => {
9531 var orig_render_item = self.settings.render.item;
9532 self.settings.render.item = (data, escape) => {
9533 const item = getDom(orig_render_item.call(self, data, escape));
9534 setAttr(item, {
9535 'draggable': 'true'
9536 });
9537
9538 // prevent doc_mousedown (see tom-select.ts)
9539 const mousedown = evt => {
9540 if (!sortable) preventDefault(evt);
9541 evt.stopPropagation();
9542 };
9543 const dragStart = evt => {
9544 drag_item = item;
9545 setTimeout(() => {
9546 item.classList.add('ts-dragging');
9547 }, 0);
9548 };
9549 const dragOver = evt => {
9550 evt.preventDefault();
9551 item.classList.add('ts-drag-over');
9552 moveitem(item, drag_item);
9553 };
9554 const dragLeave = () => {
9555 item.classList.remove('ts-drag-over');
9556 };
9557 const moveitem = (targetitem, dragitem) => {
9558 if (dragitem === undefined) return;
9559 if (isBefore(dragitem, item)) {
9560 insertAfter(targetitem, dragitem);
9561 } else {
9562 insertBefore(targetitem, dragitem);
9563 }
9564 };
9565 const dragend = () => {
9566 var _drag_item;
9567 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
9568 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
9569 drag_item = undefined;
9570 var values = [];
9571 self.control.querySelectorAll(`[data-value]`).forEach(el => {
9572 if (el.dataset.value) {
9573 let value = el.dataset.value;
9574 if (value) {
9575 values.push(value);
9576 }
9577 }
9578 });
9579 self.setValue(values);
9580 };
9581 addEvent(item, 'mousedown', mousedown);
9582 addEvent(item, 'dragstart', dragStart);
9583 addEvent(item, 'dragenter', dragOver);
9584 addEvent(item, 'dragover', dragOver);
9585 addEvent(item, 'dragleave', dragLeave);
9586 addEvent(item, 'dragend', dragend);
9587 return item;
9588 };
9589 });
9590 self.hook('instead', 'lock', () => {
9591 sortable = false;
9592 return orig_lock.call(self);
9593 });
9594 self.hook('instead', 'unlock', () => {
9595 sortable = true;
9596 return orig_unlock.call(self);
9597 });
9598 }
9599
9600
9601 //# sourceMappingURL=plugin.js.map
9602
9603
9604 /***/ },
9605
9606 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
9607 /*!****************************************************************************!*\
9608 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
9609 \****************************************************************************/
9610 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9611
9612 "use strict";
9613 __webpack_require__.r(__webpack_exports__);
9614 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9615 /* harmony export */ "default": () => (/* binding */ plugin)
9616 /* harmony export */ });
9617 /**
9618 * Tom Select v2.6.2
9619 * Licensed under the Apache License, Version 2.0 (the "License");
9620 */
9621
9622 /**
9623 * Converts a scalar to its best string representation
9624 * for hash keys and HTML attribute values.
9625 *
9626 * Transformations:
9627 * 'str' -> 'str'
9628 * null -> ''
9629 * undefined -> ''
9630 * true -> '1'
9631 * false -> '0'
9632 * 0 -> '0'
9633 * 1 -> '1'
9634 *
9635 */
9636
9637 /**
9638 * Prevent default
9639 *
9640 */
9641 const preventDefault = (evt, stop = false) => {
9642 if (evt) {
9643 evt.preventDefault();
9644 if (stop) {
9645 evt.stopPropagation();
9646 }
9647 }
9648 };
9649
9650 /**
9651 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9652 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9653 *
9654 * param query should be {}
9655 */
9656 const getDom = query => {
9657 if (query.jquery) {
9658 return query[0];
9659 }
9660 if (query instanceof HTMLElement) {
9661 return query;
9662 }
9663 if (isHtmlString(query)) {
9664 var tpl = document.createElement('template');
9665 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9666 return tpl.content.firstChild;
9667 }
9668 return document.querySelector(query);
9669 };
9670 const isHtmlString = arg => {
9671 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9672 return true;
9673 }
9674 return false;
9675 };
9676
9677 /**
9678 * Plugin: "dropdown_header" (Tom Select)
9679 * Copyright (c) contributors
9680 *
9681 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9682 * file except in compliance with the License. You may obtain a copy of the License at:
9683 * http://www.apache.org/licenses/LICENSE-2.0
9684 *
9685 * Unless required by applicable law or agreed to in writing, software distributed under
9686 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9687 * ANY KIND, either express or implied. See the License for the specific language
9688 * governing permissions and limitations under the License.
9689 *
9690 */
9691
9692 function plugin (userOptions) {
9693 const self = this;
9694 const options = Object.assign({
9695 title: 'Untitled',
9696 headerClass: 'dropdown-header',
9697 titleRowClass: 'dropdown-header-title',
9698 labelClass: 'dropdown-header-label',
9699 closeClass: 'dropdown-header-close',
9700 html: data => {
9701 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
9702 }
9703 }, userOptions);
9704 self.on('initialize', () => {
9705 var header = getDom(options.html(options));
9706 var close_link = header.querySelector('.' + options.closeClass);
9707 if (close_link) {
9708 close_link.addEventListener('click', evt => {
9709 preventDefault(evt, true);
9710 self.close();
9711 });
9712 }
9713 self.dropdown.insertBefore(header, self.dropdown.firstChild);
9714 });
9715 }
9716
9717
9718 //# sourceMappingURL=plugin.js.map
9719
9720
9721 /***/ },
9722
9723 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
9724 /*!***************************************************************************!*\
9725 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
9726 \***************************************************************************/
9727 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9728
9729 "use strict";
9730 __webpack_require__.r(__webpack_exports__);
9731 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9732 /* harmony export */ "default": () => (/* binding */ plugin)
9733 /* harmony export */ });
9734 /**
9735 * Tom Select v2.6.2
9736 * Licensed under the Apache License, Version 2.0 (the "License");
9737 */
9738
9739 const KEY_ESC = 27;
9740 const KEY_TAB = 9;
9741 // ctrl key or apple key for ma
9742
9743 /**
9744 * Converts a scalar to its best string representation
9745 * for hash keys and HTML attribute values.
9746 *
9747 * Transformations:
9748 * 'str' -> 'str'
9749 * null -> ''
9750 * undefined -> ''
9751 * true -> '1'
9752 * false -> '0'
9753 * 0 -> '0'
9754 * 1 -> '1'
9755 *
9756 */
9757
9758 /**
9759 * Prevent default
9760 *
9761 */
9762 const preventDefault = (evt, stop = false) => {
9763 if (evt) {
9764 evt.preventDefault();
9765 if (stop) {
9766 evt.stopPropagation();
9767 }
9768 }
9769 };
9770
9771 /**
9772 * Add event helper
9773 *
9774 */
9775 const addEvent = (target, type, callback, options) => {
9776 target.addEventListener(type, callback, options);
9777 };
9778
9779 /**
9780 * Iterates over arrays and hashes.
9781 *
9782 * ```
9783 * iterate(this.items, function(item, id) {
9784 * // invoked for each item
9785 * });
9786 * ```
9787 *
9788 */
9789 const iterate = (object, callback) => {
9790 if (Array.isArray(object)) {
9791 object.forEach(callback);
9792 } else {
9793 for (var key in object) {
9794 if (object.hasOwnProperty(key)) {
9795 callback(object[key], key);
9796 }
9797 }
9798 }
9799 };
9800
9801 /**
9802 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9803 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9804 *
9805 * param query should be {}
9806 */
9807 const getDom = query => {
9808 if (query.jquery) {
9809 return query[0];
9810 }
9811 if (query instanceof HTMLElement) {
9812 return query;
9813 }
9814 if (isHtmlString(query)) {
9815 var tpl = document.createElement('template');
9816 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9817 return tpl.content.firstChild;
9818 }
9819 return document.querySelector(query);
9820 };
9821 const isHtmlString = arg => {
9822 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9823 return true;
9824 }
9825 return false;
9826 };
9827
9828 /**
9829 * Add css classes
9830 *
9831 */
9832 const addClasses = (elmts, ...classes) => {
9833 var norm_classes = classesArray(classes);
9834 elmts = castAsArray(elmts);
9835 elmts.map(el => {
9836 norm_classes.map(cls => {
9837 el.classList.add(cls);
9838 });
9839 });
9840 };
9841
9842 /**
9843 * Return arguments
9844 *
9845 */
9846 const classesArray = args => {
9847 var classes = [];
9848 iterate(args, _classes => {
9849 if (typeof _classes === 'string') {
9850 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9851 }
9852 if (Array.isArray(_classes)) {
9853 classes = classes.concat(_classes);
9854 }
9855 });
9856 return classes.filter(Boolean);
9857 };
9858
9859 /**
9860 * Create an array from arg if it's not already an array
9861 *
9862 */
9863 const castAsArray = arg => {
9864 if (!Array.isArray(arg)) {
9865 arg = [arg];
9866 }
9867 return arg;
9868 };
9869
9870 /**
9871 * Plugin: "dropdown_input" (Tom Select)
9872 * Copyright (c) contributors
9873 *
9874 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9875 * file except in compliance with the License. You may obtain a copy of the License at:
9876 * http://www.apache.org/licenses/LICENSE-2.0
9877 *
9878 * Unless required by applicable law or agreed to in writing, software distributed under
9879 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9880 * ANY KIND, either express or implied. See the License for the specific language
9881 * governing permissions and limitations under the License.
9882 *
9883 */
9884
9885 function plugin () {
9886 const self = this;
9887 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
9888
9889 self.hook('before', 'setup', () => {
9890 var _self$input;
9891 self.focus_node = self.control;
9892 addClasses(self.control_input, 'dropdown-input');
9893 const div = getDom('<div class="dropdown-input-wrap">');
9894 div.append(self.control_input);
9895 self.dropdown.insertBefore(div, self.dropdown.firstChild);
9896
9897 // set a placeholder in the select control
9898 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
9899 placeholder.placeholder = self.settings.placeholder || '';
9900 self.control.append(placeholder);
9901 /**
9902 * TomSelect renders a custom control with a focusable <input class="items-placeholder">.
9903 * The source <select>'s aria-label is not automatically propagated to that input,
9904 * which triggers "Missing form label" accessibility warnings.
9905 * This helper copies the label from the <select> onto the generated input.
9906 */
9907 const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label');
9908 if (!label) return;
9909 placeholder.setAttribute('aria-label', label);
9910 });
9911 self.on('initialize', () => {
9912 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
9913 self.control_input.addEventListener('keydown', evt => {
9914 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
9915 switch (evt.keyCode) {
9916 case KEY_ESC:
9917 if (self.isOpen) {
9918 preventDefault(evt, true);
9919 self.close();
9920 }
9921 self.clearActiveItems();
9922 return;
9923 case KEY_TAB:
9924 self.focus_node.tabIndex = -1;
9925 break;
9926 }
9927 return self.onKeyDown.call(self, evt);
9928 });
9929 self.on('blur', () => {
9930 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
9931 });
9932
9933 // give the control_input focus when the dropdown is open
9934 self.on('dropdown_open', () => {
9935 self.control_input.focus();
9936 });
9937
9938 // prevent onBlur from closing when focus is on the control_input
9939 const orig_onBlur = self.onBlur;
9940 self.hook('instead', 'onBlur', evt => {
9941 if (evt && evt.relatedTarget == self.control_input) return;
9942 return orig_onBlur.call(self);
9943 });
9944 addEvent(self.control_input, 'blur', () => self.onBlur());
9945
9946 // return focus to control to allow further keyboard input
9947 self.hook('before', 'close', () => {
9948 if (!self.isOpen) return;
9949 self.focus_node.focus({
9950 preventScroll: true
9951 });
9952 });
9953 });
9954 }
9955
9956
9957 //# sourceMappingURL=plugin.js.map
9958
9959
9960 /***/ },
9961
9962 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
9963 /*!***************************************************************************!*\
9964 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
9965 \***************************************************************************/
9966 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9967
9968 "use strict";
9969 __webpack_require__.r(__webpack_exports__);
9970 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9971 /* harmony export */ "default": () => (/* binding */ plugin)
9972 /* harmony export */ });
9973 /**
9974 * Tom Select v2.6.2
9975 * Licensed under the Apache License, Version 2.0 (the "License");
9976 */
9977
9978 /**
9979 * Converts a scalar to its best string representation
9980 * for hash keys and HTML attribute values.
9981 *
9982 * Transformations:
9983 * 'str' -> 'str'
9984 * null -> ''
9985 * undefined -> ''
9986 * true -> '1'
9987 * false -> '0'
9988 * 0 -> '0'
9989 * 1 -> '1'
9990 *
9991 */
9992
9993 /**
9994 * Add event helper
9995 *
9996 */
9997 const addEvent = (target, type, callback, options) => {
9998 target.addEventListener(type, callback, options);
9999 };
10000
10001 /**
10002 * Plugin: "input_autogrow" (Tom Select)
10003 *
10004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10005 * file except in compliance with the License. You may obtain a copy of the License at:
10006 * http://www.apache.org/licenses/LICENSE-2.0
10007 *
10008 * Unless required by applicable law or agreed to in writing, software distributed under
10009 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10010 * ANY KIND, either express or implied. See the License for the specific language
10011 * governing permissions and limitations under the License.
10012 *
10013 */
10014
10015 function plugin () {
10016 var self = this;
10017 self.on('initialize', () => {
10018 var test_input = document.createElement('span');
10019 var control = self.control_input;
10020 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10021 self.wrapper.appendChild(test_input);
10022 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10023 for (const style_name of transfer_styles) {
10024 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10025 test_input.style[style_name] = control.style[style_name];
10026 }
10027
10028 /**
10029 * Set the control width
10030 *
10031 */
10032 var resize = () => {
10033 test_input.textContent = control.value;
10034 control.style.width = test_input.clientWidth + 'px';
10035 };
10036 resize();
10037 self.on('update item_add item_remove', resize);
10038 addEvent(control, 'input', resize);
10039 addEvent(control, 'keyup', resize);
10040 addEvent(control, 'blur', resize);
10041 addEvent(control, 'update', resize);
10042 });
10043 }
10044
10045
10046 //# sourceMappingURL=plugin.js.map
10047
10048
10049 /***/ },
10050
10051 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10052 /*!****************************************************************************!*\
10053 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10054 \****************************************************************************/
10055 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10056
10057 "use strict";
10058 __webpack_require__.r(__webpack_exports__);
10059 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10060 /* harmony export */ "default": () => (/* binding */ plugin)
10061 /* harmony export */ });
10062 /**
10063 * Tom Select v2.6.2
10064 * Licensed under the Apache License, Version 2.0 (the "License");
10065 */
10066
10067 /**
10068 * Plugin: "no_active_items" (Tom Select)
10069 *
10070 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10071 * file except in compliance with the License. You may obtain a copy of the License at:
10072 * http://www.apache.org/licenses/LICENSE-2.0
10073 *
10074 * Unless required by applicable law or agreed to in writing, software distributed under
10075 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10076 * ANY KIND, either express or implied. See the License for the specific language
10077 * governing permissions and limitations under the License.
10078 *
10079 */
10080
10081 function plugin () {
10082 this.hook('instead', 'setActiveItem', () => {});
10083 this.hook('instead', 'selectAll', () => {});
10084 }
10085
10086
10087 //# sourceMappingURL=plugin.js.map
10088
10089
10090 /***/ },
10091
10092 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10093 /*!********************************************************************************!*\
10094 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10095 \********************************************************************************/
10096 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10097
10098 "use strict";
10099 __webpack_require__.r(__webpack_exports__);
10100 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10101 /* harmony export */ "default": () => (/* binding */ plugin)
10102 /* harmony export */ });
10103 /**
10104 * Tom Select v2.6.2
10105 * Licensed under the Apache License, Version 2.0 (the "License");
10106 */
10107
10108 /**
10109 * Plugin: "input_autogrow" (Tom Select)
10110 *
10111 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10112 * file except in compliance with the License. You may obtain a copy of the License at:
10113 * http://www.apache.org/licenses/LICENSE-2.0
10114 *
10115 * Unless required by applicable law or agreed to in writing, software distributed under
10116 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10117 * ANY KIND, either express or implied. See the License for the specific language
10118 * governing permissions and limitations under the License.
10119 *
10120 */
10121
10122 function plugin () {
10123 var self = this;
10124 var orig_deleteSelection = self.deleteSelection;
10125 this.hook('instead', 'deleteSelection', evt => {
10126 if (self.activeItems.length) {
10127 return orig_deleteSelection.call(self, evt);
10128 }
10129 return false;
10130 });
10131 }
10132
10133
10134 //# sourceMappingURL=plugin.js.map
10135
10136
10137 /***/ },
10138
10139 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10140 /*!*****************************************************************************!*\
10141 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10142 \*****************************************************************************/
10143 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10144
10145 "use strict";
10146 __webpack_require__.r(__webpack_exports__);
10147 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10148 /* harmony export */ "default": () => (/* binding */ plugin)
10149 /* harmony export */ });
10150 /**
10151 * Tom Select v2.6.2
10152 * Licensed under the Apache License, Version 2.0 (the "License");
10153 */
10154
10155 const KEY_LEFT = 37;
10156 const KEY_RIGHT = 39;
10157 // ctrl key or apple key for ma
10158
10159 /**
10160 * Get the closest node to the evt.target matching the selector
10161 * Stops at wrapper
10162 *
10163 */
10164 const parentMatch = (target, selector, wrapper) => {
10165 while (target && target.matches) {
10166 if (target.matches(selector)) {
10167 return target;
10168 }
10169 target = target.parentNode;
10170 }
10171 };
10172
10173 /**
10174 * Get the index of an element amongst sibling nodes of the same type
10175 *
10176 */
10177 const nodeIndex = (el, amongst) => {
10178 if (!el) return -1;
10179 amongst = amongst || el.nodeName;
10180 var i = 0;
10181 while (el = el.previousElementSibling) {
10182 if (el.matches(amongst)) {
10183 i++;
10184 }
10185 }
10186 return i;
10187 };
10188
10189 /**
10190 * Plugin: "optgroup_columns" (Tom Select.js)
10191 * Copyright (c) contributors
10192 *
10193 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10194 * file except in compliance with the License. You may obtain a copy of the License at:
10195 * http://www.apache.org/licenses/LICENSE-2.0
10196 *
10197 * Unless required by applicable law or agreed to in writing, software distributed under
10198 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10199 * ANY KIND, either express or implied. See the License for the specific language
10200 * governing permissions and limitations under the License.
10201 *
10202 */
10203
10204 function plugin () {
10205 var self = this;
10206 var orig_keydown = self.onKeyDown;
10207 self.hook('instead', 'onKeyDown', evt => {
10208 var index, option, options, optgroup;
10209 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10210 return orig_keydown.call(self, evt);
10211 }
10212 self.ignoreHover = true;
10213 optgroup = parentMatch(self.activeOption, '[data-group]');
10214 index = nodeIndex(self.activeOption, '[data-selectable]');
10215 if (!optgroup) {
10216 return;
10217 }
10218 if (evt.keyCode === KEY_LEFT) {
10219 optgroup = optgroup.previousSibling;
10220 } else {
10221 optgroup = optgroup.nextSibling;
10222 }
10223 if (!optgroup) {
10224 return;
10225 }
10226 options = optgroup.querySelectorAll('[data-selectable]');
10227 option = options[Math.min(options.length - 1, index)];
10228 if (option) {
10229 self.setActiveOption(option);
10230 }
10231 });
10232 }
10233
10234
10235 //# sourceMappingURL=plugin.js.map
10236
10237
10238 /***/ },
10239
10240 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10241 /*!**************************************************************************!*\
10242 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10243 \**************************************************************************/
10244 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10245
10246 "use strict";
10247 __webpack_require__.r(__webpack_exports__);
10248 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10249 /* harmony export */ "default": () => (/* binding */ plugin)
10250 /* harmony export */ });
10251 /**
10252 * Tom Select v2.6.2
10253 * Licensed under the Apache License, Version 2.0 (the "License");
10254 */
10255
10256 /**
10257 * Converts a scalar to its best string representation
10258 * for hash keys and HTML attribute values.
10259 *
10260 * Transformations:
10261 * 'str' -> 'str'
10262 * null -> ''
10263 * undefined -> ''
10264 * true -> '1'
10265 * false -> '0'
10266 * 0 -> '0'
10267 * 1 -> '1'
10268 *
10269 */
10270
10271 /**
10272 * Prevent default
10273 *
10274 */
10275 const preventDefault = (evt, stop = false) => {
10276 if (evt) {
10277 evt.preventDefault();
10278 if (stop) {
10279 evt.stopPropagation();
10280 }
10281 }
10282 };
10283
10284 /**
10285 * Add event helper
10286 *
10287 */
10288 const addEvent = (target, type, callback, options) => {
10289 target.addEventListener(type, callback, options);
10290 };
10291
10292 /**
10293 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10294 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10295 *
10296 * param query should be {}
10297 */
10298 const getDom = query => {
10299 if (query.jquery) {
10300 return query[0];
10301 }
10302 if (query instanceof HTMLElement) {
10303 return query;
10304 }
10305 if (isHtmlString(query)) {
10306 var tpl = document.createElement('template');
10307 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10308 return tpl.content.firstChild;
10309 }
10310 return document.querySelector(query);
10311 };
10312 const isHtmlString = arg => {
10313 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10314 return true;
10315 }
10316 return false;
10317 };
10318
10319 /**
10320 * Plugin: "remove_button" (Tom Select)
10321 * Copyright (c) contributors
10322 *
10323 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10324 * file except in compliance with the License. You may obtain a copy of the License at:
10325 * http://www.apache.org/licenses/LICENSE-2.0
10326 *
10327 * Unless required by applicable law or agreed to in writing, software distributed under
10328 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10329 * ANY KIND, either express or implied. See the License for the specific language
10330 * governing permissions and limitations under the License.
10331 *
10332 */
10333
10334 function plugin (userOptions) {
10335 const self = this;
10336 const options = Object.assign({
10337 label: '×',
10338 title: 'Remove',
10339 className: 'remove',
10340 tabindex: -1,
10341 role: 'button',
10342 html: data => {
10343 var _data$tabindex;
10344 const el = document.createElement('div');
10345 el.className = data.className || '';
10346 el.title = data.title || '';
10347 el.setAttribute('role', data.role || 'button');
10348 el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1;
10349 el.textContent = data.label || '';
10350 return el;
10351 }
10352 }, userOptions);
10353 self.hook('after', 'setupTemplates', () => {
10354 var orig_render_item = self.settings.render.item;
10355 self.settings.render.item = (data, escape) => {
10356 var item = getDom(orig_render_item.call(self, data, escape));
10357 var close_button = getDom(options.html(options));
10358 item.appendChild(close_button);
10359 addEvent(close_button, 'mousedown', evt => {
10360 preventDefault(evt, true);
10361 });
10362 addEvent(close_button, 'click', evt => {
10363 if (self.isLocked) return;
10364
10365 // propagating will trigger the dropdown to show for single mode
10366 preventDefault(evt, true);
10367 if (self.isLocked) return;
10368 if (!self.shouldDelete([item], evt)) return;
10369 self.removeItem(item);
10370 self.refreshOptions(false);
10371 self.inputState();
10372 });
10373 return item;
10374 };
10375 });
10376 }
10377
10378
10379 //# sourceMappingURL=plugin.js.map
10380
10381
10382 /***/ },
10383
10384 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10385 /*!*********************************************************************************!*\
10386 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10387 \*********************************************************************************/
10388 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10389
10390 "use strict";
10391 __webpack_require__.r(__webpack_exports__);
10392 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10393 /* harmony export */ "default": () => (/* binding */ plugin)
10394 /* harmony export */ });
10395 /**
10396 * Tom Select v2.6.2
10397 * Licensed under the Apache License, Version 2.0 (the "License");
10398 */
10399
10400 /**
10401 * Plugin: "restore_on_backspace" (Tom Select)
10402 * Copyright (c) contributors
10403 *
10404 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10405 * file except in compliance with the License. You may obtain a copy of the License at:
10406 * http://www.apache.org/licenses/LICENSE-2.0
10407 *
10408 * Unless required by applicable law or agreed to in writing, software distributed under
10409 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10410 * ANY KIND, either express or implied. See the License for the specific language
10411 * governing permissions and limitations under the License.
10412 *
10413 */
10414
10415 function plugin (userOptions) {
10416 const self = this;
10417 const options = Object.assign({
10418 text: option => {
10419 return option[self.settings.labelField];
10420 }
10421 }, userOptions);
10422 self.on('item_remove', function (value) {
10423 if (!self.isFocused) {
10424 return;
10425 }
10426 if (self.control_input.value.trim() === '') {
10427 var option = self.options[value];
10428 if (option) {
10429 self.setTextboxValue(options.text.call(self, option));
10430 }
10431 }
10432 });
10433 }
10434
10435
10436 //# sourceMappingURL=plugin.js.map
10437
10438
10439 /***/ },
10440
10441 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10442 /*!***************************************************************************!*\
10443 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10444 \***************************************************************************/
10445 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10446
10447 "use strict";
10448 __webpack_require__.r(__webpack_exports__);
10449 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10450 /* harmony export */ "default": () => (/* binding */ plugin)
10451 /* harmony export */ });
10452 /**
10453 * Tom Select v2.6.2
10454 * Licensed under the Apache License, Version 2.0 (the "License");
10455 */
10456
10457 /**
10458 * Converts a scalar to its best string representation
10459 * for hash keys and HTML attribute values.
10460 *
10461 * Transformations:
10462 * 'str' -> 'str'
10463 * null -> ''
10464 * undefined -> ''
10465 * true -> '1'
10466 * false -> '0'
10467 * 0 -> '0'
10468 * 1 -> '1'
10469 *
10470 */
10471
10472 /**
10473 * Iterates over arrays and hashes.
10474 *
10475 * ```
10476 * iterate(this.items, function(item, id) {
10477 * // invoked for each item
10478 * });
10479 * ```
10480 *
10481 */
10482 const iterate = (object, callback) => {
10483 if (Array.isArray(object)) {
10484 object.forEach(callback);
10485 } else {
10486 for (var key in object) {
10487 if (object.hasOwnProperty(key)) {
10488 callback(object[key], key);
10489 }
10490 }
10491 }
10492 };
10493
10494 /**
10495 * Add css classes
10496 *
10497 */
10498 const addClasses = (elmts, ...classes) => {
10499 var norm_classes = classesArray(classes);
10500 elmts = castAsArray(elmts);
10501 elmts.map(el => {
10502 norm_classes.map(cls => {
10503 el.classList.add(cls);
10504 });
10505 });
10506 };
10507
10508 /**
10509 * Return arguments
10510 *
10511 */
10512 const classesArray = args => {
10513 var classes = [];
10514 iterate(args, _classes => {
10515 if (typeof _classes === 'string') {
10516 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10517 }
10518 if (Array.isArray(_classes)) {
10519 classes = classes.concat(_classes);
10520 }
10521 });
10522 return classes.filter(Boolean);
10523 };
10524
10525 /**
10526 * Create an array from arg if it's not already an array
10527 *
10528 */
10529 const castAsArray = arg => {
10530 if (!Array.isArray(arg)) {
10531 arg = [arg];
10532 }
10533 return arg;
10534 };
10535
10536 /**
10537 * Plugin: "virtual_scroll" (Tom Select)
10538 * Copyright (c) contributors
10539 *
10540 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10541 * file except in compliance with the License. You may obtain a copy of the License at:
10542 * http://www.apache.org/licenses/LICENSE-2.0
10543 *
10544 * Unless required by applicable law or agreed to in writing, software distributed under
10545 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10546 * ANY KIND, either express or implied. See the License for the specific language
10547 * governing permissions and limitations under the License.
10548 *
10549 */
10550
10551 function plugin () {
10552 const self = this;
10553 const orig_canLoad = self.canLoad;
10554 const orig_clearActiveOption = self.clearActiveOption;
10555 const orig_loadCallback = self.loadCallback;
10556 var pagination = {};
10557 var dropdown_content;
10558 var loading_more = false;
10559 var load_more_opt;
10560 var default_values = [];
10561 var default_values_loaded = false;
10562 var default_pagination;
10563 var default_options = [];
10564 var html_values = [];
10565 if (!self.settings.shouldLoadMore) {
10566 // return true if additional results should be loaded
10567 self.settings.shouldLoadMore = () => {
10568 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
10569 if (scroll_percent > 0.9) {
10570 return true;
10571 }
10572 if (self.activeOption) {
10573 var selectable = self.selectable();
10574 var index = Array.from(selectable).indexOf(self.activeOption);
10575 if (index >= selectable.length - 2) {
10576 return true;
10577 }
10578 }
10579 return false;
10580 };
10581 }
10582 if (!self.settings.firstUrl) {
10583 throw 'virtual_scroll plugin requires a firstUrl() method';
10584 }
10585
10586 // in order for virtual scrolling to work,
10587 // options need to be ordered the same way they're returned from the remote data source
10588 self.settings.sortField = [{
10589 field: '$order'
10590 }, {
10591 field: '$score'
10592 }];
10593
10594 // can we load more results for given query?
10595 const canLoadMore = query => {
10596 if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
10597 return false;
10598 }
10599 if (query in pagination && pagination[query]) {
10600 return true;
10601 }
10602 return false;
10603 };
10604 const clearFilter = (option, value) => {
10605 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
10606 return true;
10607 }
10608 return false;
10609 };
10610
10611 // set the next url that will be
10612 self.setNextUrl = (value, next_url) => {
10613 pagination[value] = next_url;
10614 };
10615
10616 // getUrl() to be used in settings.load()
10617 self.getUrl = query => {
10618 if (query in pagination) {
10619 const next_url = pagination[query];
10620 pagination[query] = false;
10621 return next_url;
10622 }
10623
10624 // if the user goes back to a previous query
10625 // we need to load the first page again
10626 self.clearPagination();
10627 return self.settings.firstUrl.call(self, query);
10628 };
10629
10630 // clear pagination
10631 self.clearPagination = () => {
10632 pagination = {};
10633 };
10634
10635 // don't clear the active option (and cause unwanted dropdown scroll)
10636 // while loading more results
10637 self.hook('instead', 'clearActiveOption', () => {
10638 if (loading_more) {
10639 return;
10640 }
10641 return orig_clearActiveOption.call(self);
10642 });
10643
10644 // override the canLoad method
10645 self.hook('instead', 'canLoad', query => {
10646 // first time the query has been seen
10647 if (!(query in pagination)) {
10648 return orig_canLoad.call(self, query);
10649 }
10650 return canLoadMore(query);
10651 });
10652
10653 // wrap the load
10654 self.hook('instead', 'loadCallback', (options, optgroups) => {
10655 if (!loading_more) {
10656 // When searching (non-empty query), keep selected items and HTML default options,
10657 // but remove preloaded remote options so they don't bleed into search results.
10658 // For empty query, use clearFilter (keeps default_values + items).
10659 const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter;
10660 self.clearOptions(activeFilter);
10661 } else if (load_more_opt) {
10662 const first_option = options[0];
10663 if (first_option !== undefined) {
10664 load_more_opt.dataset.value = first_option[self.settings.valueField];
10665 }
10666 }
10667 orig_loadCallback.call(self, options, optgroups);
10668
10669 // After the initial preload (empty query), snapshot default_values and option objects
10670 // so they can be restored when the user clears their search.
10671 if (!loading_more && !default_values_loaded) {
10672 default_values_loaded = true;
10673 if (self.lastValue === '') {
10674 default_values = Object.keys(self.options);
10675 default_pagination = pagination[''];
10676 default_options = Object.values(self.options);
10677 }
10678 }
10679 loading_more = false;
10680 });
10681
10682 // as the “loading_more” element will be removed from the dropdown,
10683 // we activate the previous option if needed
10684 // to avoid the dropdown being scrolled back to the first one
10685 self.hook('before', 'refreshOptions', () => {
10686 if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) {
10687 self.setActiveOption(self.activeOption.previousElementSibling);
10688 }
10689 });
10690
10691 // add templates to dropdown
10692 // loading_more if we have another url in the queue
10693 // no_more_results if we don't have another url in the queue
10694 self.hook('after', 'refreshOptions', () => {
10695 const query = self.lastValue;
10696 var option;
10697 if (canLoadMore(query)) {
10698 option = self.render('loading_more', {
10699 query: query
10700 });
10701 if (option) {
10702 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
10703 load_more_opt = option;
10704 }
10705 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
10706 option = self.render('no_more_results', {
10707 query: query
10708 });
10709 }
10710 if (option) {
10711 addClasses(option, self.settings.optionClass);
10712 dropdown_content.append(option);
10713 }
10714 });
10715
10716 // Restore preloaded options and pagination when clearing search
10717 const restoreDefaults = () => {
10718 if (!default_values_loaded) {
10719 return;
10720 }
10721 // Re-add preloaded option objects (clearOptions can only remove, not restore)
10722 self.addOptions(default_options);
10723 // Remove any search results that are not part of the preloaded defaults
10724 self.clearOptions(clearFilter);
10725 if (default_pagination) {
10726 pagination[''] = default_pagination;
10727 }
10728 };
10729 self.on('type', query => {
10730 if (query === '') {
10731 restoreDefaults();
10732 self.refreshOptions(false);
10733 }
10734 });
10735 self.on('dropdown_close', restoreDefaults);
10736
10737 // add scroll listener and default templates
10738 self.on('initialize', () => {
10739 html_values = Object.keys(self.options);
10740 default_values = Object.keys(self.options);
10741 dropdown_content = self.dropdown_content;
10742
10743 // default templates
10744 self.settings.render = Object.assign({}, {
10745 loading_more: () => {
10746 return `<div class="loading-more-results">Loading more results ... </div>`;
10747 },
10748 no_more_results: () => {
10749 return `<div class="no-more-results">No more results</div>`;
10750 }
10751 }, self.settings.render);
10752
10753 // watch dropdown content scroll position
10754 dropdown_content.addEventListener('scroll', () => {
10755 if (!self.settings.shouldLoadMore.call(self)) {
10756 return;
10757 }
10758
10759 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
10760 if (!canLoadMore(self.lastValue)) {
10761 return;
10762 }
10763
10764 // don't call load() too much
10765 if (loading_more) return;
10766 loading_more = true;
10767 self.load.call(self, self.lastValue);
10768 });
10769 });
10770 }
10771
10772
10773 //# sourceMappingURL=plugin.js.map
10774
10775
10776 /***/ },
10777
10778 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
10779 /*!*****************************************************************!*\
10780 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
10781 \*****************************************************************/
10782 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10783
10784 "use strict";
10785 __webpack_require__.r(__webpack_exports__);
10786 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10787 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10788 /* harmony export */ });
10789 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
10790 /* 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");
10791 /* 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");
10792 /* 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");
10793 /* 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");
10794 /* 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");
10795 /* 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");
10796 /* 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");
10797 /* 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");
10798 /* 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");
10799 /* 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");
10800 /* 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");
10801 /* 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");
10802 /* 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");
10803 /* 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");
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816
10817
10818
10819 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
10820 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
10821 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
10822 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
10823 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
10824 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
10825 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
10826 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
10827 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
10828 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
10829 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
10830 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
10831 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
10832 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
10833 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
10834 //# sourceMappingURL=tom-select.complete.js.map
10835
10836 /***/ },
10837
10838 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
10839 /*!********************************************************!*\
10840 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
10841 \********************************************************/
10842 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10843
10844 "use strict";
10845 __webpack_require__.r(__webpack_exports__);
10846 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10847 /* harmony export */ "default": () => (/* binding */ TomSelect)
10848 /* harmony export */ });
10849 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
10850 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
10851 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
10852 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10853 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
10854 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
10855 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
10856 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
10857 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867 var instance_i = 0;
10868 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
10869 constructor(input_arg, user_settings) {
10870 super();
10871 this.order = 0;
10872 this.isOpen = false;
10873 this.isDisabled = false;
10874 this.isReadOnly = false;
10875 this.isInvalid = false; // @deprecated 1.8
10876 this.isValid = true;
10877 this.isLocked = false;
10878 this.isFocused = false;
10879 this.isInputHidden = false;
10880 this.isSetup = false;
10881 this.isDropdownContentStale = true;
10882 this.ignoreFocus = false;
10883 this.ignoreHover = false;
10884 this.hasOptions = false;
10885 this.lastValue = '';
10886 this.caretPos = 0;
10887 this.loading = 0;
10888 this.loadedSearches = {};
10889 this.activeOption = null;
10890 this.activeItems = [];
10891 this.optgroups = {};
10892 this.options = {};
10893 this.userOptions = {};
10894 this.items = [];
10895 this.refreshTimeout = null;
10896 instance_i++;
10897 var dir;
10898 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
10899 if (input.tomselect) {
10900 throw new Error('Tom Select already initialized on this element');
10901 }
10902 input.tomselect = this;
10903 // detect rtl environment
10904 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
10905 dir = computedStyle.getPropertyValue('direction');
10906 // setup default state
10907 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
10908 this.settings = settings;
10909 this.input = input;
10910 this.tabIndex = input.tabIndex || 0;
10911 this.is_select_tag = input.tagName.toLowerCase() === 'select';
10912 this.rtl = /rtl/i.test(dir);
10913 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
10914 this.isRequired = input.required;
10915 // search system
10916 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
10917 // option-dependent defaults
10918 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
10919 if (typeof settings.hideSelected !== 'boolean') {
10920 settings.hideSelected = settings.mode === 'multi';
10921 }
10922 if (typeof settings.hidePlaceholder !== 'boolean') {
10923 settings.hidePlaceholder = settings.mode !== 'multi';
10924 }
10925 // set up createFilter callback
10926 var filter = settings.createFilter;
10927 if (typeof filter !== 'function') {
10928 if (typeof filter === 'string') {
10929 filter = new RegExp(filter);
10930 }
10931 if (filter instanceof RegExp) {
10932 settings.createFilter = (input) => filter.test(input);
10933 }
10934 else {
10935 settings.createFilter = (value) => {
10936 return this.settings.duplicates || !this.options[value];
10937 };
10938 }
10939 }
10940 this.initializePlugins(settings.plugins);
10941 this.setupCallbacks();
10942 this.setupTemplates();
10943 // Create all elements
10944 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10945 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10946 const dropdown = this._render('dropdown');
10947 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
10948 const classes = this.input.getAttribute('class') || '';
10949 const inputMode = settings.mode;
10950 var control_input;
10951 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
10952 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
10953 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
10954 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
10955 if (settings.copyClassesToDropdown) {
10956 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
10957 }
10958 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
10959 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
10960 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
10961 // default controlInput
10962 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
10963 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10964 // set attributes
10965 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
10966 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
10967 if (input.getAttribute(attr)) {
10968 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
10969 }
10970 });
10971 control_input.tabIndex = -1;
10972 control.appendChild(control_input);
10973 this.focus_node = control_input;
10974 // dom element
10975 }
10976 else if (settings.controlInput) {
10977 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10978 this.focus_node = control_input;
10979 }
10980 else {
10981 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
10982 this.focus_node = control;
10983 }
10984 this.wrapper = wrapper;
10985 this.dropdown = dropdown;
10986 this.dropdown_content = dropdown_content;
10987 this.control = control;
10988 this.control_input = control_input;
10989 this.setup();
10990 }
10991 /**
10992 * set up event bindings.
10993 *
10994 */
10995 setup() {
10996 const self = this;
10997 const settings = self.settings;
10998 const control_input = self.control_input;
10999 const dropdown = self.dropdown;
11000 const dropdown_content = self.dropdown_content;
11001 const wrapper = self.wrapper;
11002 const control = self.control;
11003 const input = self.input;
11004 const focus_node = self.focus_node;
11005 const passive_event = { passive: true };
11006 const listboxId = self.inputId + '-ts-dropdown';
11007 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
11008 id: listboxId
11009 });
11010 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
11011 role: 'combobox',
11012 'aria-haspopup': 'listbox',
11013 'aria-expanded': 'false',
11014 'aria-controls': listboxId
11015 });
11016 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
11017 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
11018 const label = document.querySelector(query);
11019 const label_click = self.focus.bind(self);
11020 if (label) {
11021 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
11022 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
11023 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
11024 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
11025 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11026 }
11027 wrapper.style.width = input.style.width;
11028 wrapper.style.minWidth = input.style.minWidth;
11029 wrapper.style.maxWidth = input.style.maxWidth;
11030 if (self.plugins.names.length) {
11031 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11032 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11033 }
11034 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11035 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11036 }
11037 if (settings.placeholder) {
11038 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11039 }
11040 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11041 if (!settings.splitOn && settings.delimiter) {
11042 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11043 }
11044 // debounce user defined load() if loadThrottle > 0
11045 // after initializePlugins() so plugins can create/modify user defined loaders
11046 if (settings.load && settings.loadThrottle) {
11047 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11048 }
11049 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11050 self.ignoreHover = false;
11051 });
11052 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11053 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11054 if (target_match)
11055 self.onOptionHover(e, target_match);
11056 }, { capture: true });
11057 // clicking on an option should select it
11058 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11059 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11060 if (option) {
11061 self.onOptionSelect(evt, option);
11062 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11063 }
11064 });
11065 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11066 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11067 if (target_match && self.onItemSelect(evt, target_match)) {
11068 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11069 return;
11070 }
11071 // retain focus (see control_input mousedown)
11072 if (control_input.value != '') {
11073 return;
11074 }
11075 self.onClick();
11076 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11077 });
11078 // keydown on focus_node for arrow_down/arrow_up
11079 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11080 // keypress and input/keyup
11081 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11082 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11083 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11084 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11085 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11086 const doc_mousedown = (evt) => {
11087 // blur if target is outside of this instance
11088 // dropdown is not always inside wrapper
11089 const target = evt.composedPath()[0];
11090 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11091 if (self.isFocused) {
11092 self.blur();
11093 }
11094 self.inputState();
11095 return;
11096 }
11097 // retain focus by preventing native handling. if the
11098 // event target is the input it should not be modified.
11099 // otherwise, text selection within the input won't work.
11100 // Fixes bug #212 which is no covered by tests
11101 if (target == control_input && self.isOpen) {
11102 evt.stopPropagation();
11103 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11104 }
11105 else {
11106 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11107 }
11108 };
11109 const win_scroll = () => {
11110 if (self.isOpen) {
11111 self.positionDropdown();
11112 }
11113 };
11114 const input_invalid = () => {
11115 if (self.isValid) {
11116 self.isValid = false;
11117 self.isInvalid = true;
11118 self.refreshState();
11119 }
11120 };
11121 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid);
11122 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11123 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11124 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11125 this._destroy = () => {
11126 input.removeEventListener('invalid', input_invalid);
11127 document.removeEventListener('mousedown', doc_mousedown);
11128 window.removeEventListener('scroll', win_scroll);
11129 window.removeEventListener('resize', win_scroll);
11130 if (label)
11131 label.removeEventListener('click', label_click);
11132 };
11133 // store original html and tab index so that they can be
11134 // restored when the destroy() method is called.
11135 this.revertSettings = {
11136 innerHTML: input.innerHTML,
11137 tabIndex: input.tabIndex
11138 };
11139 input.tabIndex = -1;
11140 input.insertAdjacentElement('afterend', self.wrapper);
11141 self.sync(false);
11142 settings.items = [];
11143 delete settings.optgroups;
11144 delete settings.options;
11145 self.refreshItems();
11146 self.close(false);
11147 self.inputState();
11148 self.isSetup = true;
11149 self.on('change', this.onChange);
11150 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11151 self.trigger('initialize');
11152 // preload options
11153 if (settings.preload === true) {
11154 self.preload();
11155 }
11156 }
11157 /**
11158 * Register options and optgroups
11159 *
11160 */
11161 setupOptions(options = [], optgroups = []) {
11162 // build options table
11163 this.addOptions(options);
11164 // build optgroup table
11165 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11166 this.registerOptionGroup(optgroup);
11167 });
11168 }
11169 /**
11170 * Sets up default rendering functions.
11171 */
11172 setupTemplates() {
11173 var self = this;
11174 var field_label = self.settings.labelField;
11175 var field_optgroup = self.settings.optgroupLabelField;
11176 var templates = {
11177 'optgroup': (data) => {
11178 let optgroup = document.createElement('div');
11179 optgroup.className = 'optgroup';
11180 optgroup.appendChild(data.options);
11181 return optgroup;
11182 },
11183 'optgroup_header': (data, escape) => {
11184 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11185 },
11186 'option': (data, escape) => {
11187 return '<div>' + escape(data[field_label]) + '</div>';
11188 },
11189 'item': (data, escape) => {
11190 return '<div>' + escape(data[field_label]) + '</div>';
11191 },
11192 'option_create': (data, escape) => {
11193 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11194 },
11195 'no_results': () => {
11196 return '<div class="no-results">No results found</div>';
11197 },
11198 'loading': () => {
11199 return '<div class="spinner"></div>';
11200 },
11201 'not_loading': () => { },
11202 'dropdown': () => {
11203 return '<div></div>';
11204 }
11205 };
11206 self.settings.render = Object.assign({}, templates, self.settings.render);
11207 }
11208 /**
11209 * Maps fired events to callbacks provided
11210 * in the settings used when creating the control.
11211 */
11212 setupCallbacks() {
11213 var key, fn;
11214 var callbacks = {
11215 'initialize': 'onInitialize',
11216 'change': 'onChange',
11217 'item_add': 'onItemAdd',
11218 'item_remove': 'onItemRemove',
11219 'item_select': 'onItemSelect',
11220 'clear': 'onClear',
11221 'option_add': 'onOptionAdd',
11222 'option_remove': 'onOptionRemove',
11223 'option_clear': 'onOptionClear',
11224 'optgroup_add': 'onOptionGroupAdd',
11225 'optgroup_remove': 'onOptionGroupRemove',
11226 'optgroup_clear': 'onOptionGroupClear',
11227 'dropdown_open': 'onDropdownOpen',
11228 'dropdown_close': 'onDropdownClose',
11229 'type': 'onType',
11230 'load': 'onLoad',
11231 'focus': 'onFocus',
11232 'blur': 'onBlur'
11233 };
11234 for (key in callbacks) {
11235 fn = this.settings[callbacks[key]];
11236 if (fn)
11237 this.on(key, fn);
11238 }
11239 }
11240 /**
11241 * Sync the Tom Select instance with the original input or select
11242 *
11243 */
11244 sync(get_settings = true) {
11245 const self = this;
11246 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings;
11247 self.setupOptions(settings.options, settings.optgroups);
11248 self.setValue(settings.items || [], true); // silent prevents recursion
11249 if (self.input.disabled) {
11250 self.disable();
11251 }
11252 else if (self.input.readOnly) {
11253 self.setReadOnly(true);
11254 }
11255 else {
11256 self.enable(); //sets tabIndex
11257 }
11258 self.lastQuery = null; // so updated options will be displayed in dropdown
11259 }
11260 /**
11261 * Triggered when the main control element
11262 * has a click event.
11263 *
11264 */
11265 onClick() {
11266 var self = this;
11267 if (self.activeItems.length > 0) {
11268 self.clearActiveItems();
11269 self.focus();
11270 return;
11271 }
11272 if (self.isFocused && self.isOpen) {
11273 self.blur();
11274 }
11275 else {
11276 self.focus();
11277 }
11278 }
11279 /**
11280 * @deprecated v1.7
11281 *
11282 */
11283 onMouseDown() { }
11284 /**
11285 * Triggered when the value of the control has been changed.
11286 * This should propagate the event to the original DOM
11287 * input / select element.
11288 */
11289 onChange() {
11290 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11291 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11292 }
11293 /**
11294 * Triggered on <input> paste.
11295 *
11296 */
11297 onPaste(e) {
11298 var self = this;
11299 if (self.isInputHidden || self.isLocked) {
11300 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11301 return;
11302 }
11303 // If a regex or string is included, this will split the pasted
11304 // input and create Items for each separate value
11305 if (!self.settings.splitOn) {
11306 return;
11307 }
11308 // Wait for pasted text to be recognized in value
11309 setTimeout(() => {
11310 var pastedText = self.inputValue();
11311 if (!pastedText.match(self.settings.splitOn)) {
11312 return;
11313 }
11314 var splitInput = pastedText.trim().split(self.settings.splitOn);
11315 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11316 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11317 if (hash) {
11318 if (this.options[piece]) {
11319 self.addItem(piece);
11320 }
11321 else {
11322 self.createItem(piece);
11323 }
11324 }
11325 });
11326 }, 0);
11327 }
11328 /**
11329 * Triggered on <input> keypress.
11330 *
11331 */
11332 onKeyPress(e) {
11333 var self = this;
11334 if (self.isLocked) {
11335 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11336 return;
11337 }
11338 var character = String.fromCharCode(e.keyCode || e.which);
11339 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11340 self.createItem();
11341 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11342 return;
11343 }
11344 }
11345 /**
11346 * Triggered on <input> keydown.
11347 *
11348 */
11349 onKeyDown(e) {
11350 var self = this;
11351 self.ignoreHover = true;
11352 if (self.isLocked) {
11353 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11354 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11355 }
11356 return;
11357 }
11358 switch (e.keyCode) {
11359 // ctrl+A: select all
11360 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11361 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11362 if (self.control_input.value == '') {
11363 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11364 self.selectAll();
11365 return;
11366 }
11367 }
11368 break;
11369 // esc: close dropdown
11370 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11371 if (self.isOpen) {
11372 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11373 self.close();
11374 }
11375 self.clearActiveItems();
11376 return;
11377 // down: open dropdown or move selection down
11378 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11379 if (!self.isOpen && self.hasOptions) {
11380 self.open();
11381 }
11382 else if (self.activeOption) {
11383 let next = self.getAdjacent(self.activeOption, 1);
11384 if (next)
11385 self.setActiveOption(next);
11386 }
11387 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11388 return;
11389 // up: move selection up
11390 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11391 if (self.activeOption) {
11392 let prev = self.getAdjacent(self.activeOption, -1);
11393 if (prev)
11394 self.setActiveOption(prev);
11395 }
11396 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11397 return;
11398 // return: select active option
11399 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11400 if (self.canSelect(self.activeOption)) {
11401 self.onOptionSelect(e, self.activeOption);
11402 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11403 // if the option_create=null, the dropdown might be closed
11404 }
11405 else if (self.settings.create && self.createItem()) {
11406 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11407 // don't submit form when searching for a value
11408 }
11409 else if (document.activeElement == self.control_input && self.isOpen) {
11410 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11411 }
11412 return;
11413 // left: modifiy item selection to the left
11414 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11415 self.advanceSelection(-1, e);
11416 return;
11417 // right: modifiy item selection to the right
11418 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11419 self.advanceSelection(1, e);
11420 return;
11421 // tab: select active option and/or create item
11422 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11423 if (self.settings.selectOnTab) {
11424 if (self.canSelect(self.activeOption)) {
11425 self.onOptionSelect(e, self.activeOption);
11426 // prevent default [tab] behaviour of jump to the next field
11427 // if select isFull, then the dropdown won't be open and [tab] will work normally
11428 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11429 }
11430 else if (self.settings.create && self.createItem()) {
11431 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11432 }
11433 }
11434 return;
11435 // delete|backspace: delete items
11436 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11437 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11438 self.deleteSelection(e);
11439 return;
11440 }
11441 // don't enter text in the control_input when active items are selected
11442 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11443 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11444 }
11445 }
11446 /**
11447 * Triggered on <input> keyup.
11448 *
11449 */
11450 onInput(e) {
11451 if (this.isLocked) {
11452 return;
11453 }
11454 const value = this.inputValue();
11455 if (this.lastValue === value)
11456 return;
11457 this.lastValue = value;
11458 if (value == '') {
11459 this._onInput();
11460 return;
11461 }
11462 if (this.refreshTimeout) {
11463 window.clearTimeout(this.refreshTimeout);
11464 }
11465 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11466 this.refreshTimeout = null;
11467 this._onInput();
11468 }, this.settings.refreshThrottle);
11469 }
11470 _onInput() {
11471 const value = this.lastValue;
11472 if (this.settings.shouldLoad.call(this, value)) {
11473 this.load(value);
11474 }
11475 this.refreshOptions();
11476 this.trigger('type', value);
11477 }
11478 /**
11479 * Triggered when the user rolls over
11480 * an option in the autocomplete dropdown menu.
11481 *
11482 */
11483 onOptionHover(evt, option) {
11484 if (this.ignoreHover)
11485 return;
11486 this.setActiveOption(option, false);
11487 }
11488 /**
11489 * Triggered on <input> focus.
11490 *
11491 */
11492 onFocus(e) {
11493 var self = this;
11494 var wasFocused = self.isFocused;
11495 if (self.isDisabled || self.isReadOnly) {
11496 self.blur();
11497 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11498 return;
11499 }
11500 if (self.ignoreFocus)
11501 return;
11502 self.isFocused = true;
11503 if (self.settings.preload === 'focus')
11504 self.preload();
11505 if (!wasFocused)
11506 self.trigger('focus');
11507 if (!self.activeItems.length) {
11508 self.inputState();
11509 self.refreshOptions(!!self.settings.openOnFocus);
11510 }
11511 self.refreshState();
11512 }
11513 /**
11514 * Triggered on <input> blur.
11515 *
11516 */
11517 onBlur(e) {
11518 if (document.hasFocus() === false)
11519 return;
11520 var self = this;
11521 if (!self.isFocused)
11522 return;
11523 self.isFocused = false;
11524 self.ignoreFocus = false;
11525 var deactivate = () => {
11526 self.close();
11527 self.setActiveItem();
11528 self.setCaret(self.items.length);
11529 self.trigger('blur');
11530 };
11531 if (self.settings.create && self.settings.createOnBlur) {
11532 self.createItem(null, deactivate);
11533 }
11534 else {
11535 deactivate();
11536 }
11537 }
11538 /**
11539 * Triggered when the user clicks on an option
11540 * in the autocomplete dropdown menu.
11541 *
11542 */
11543 onOptionSelect(evt, option) {
11544 var value, self = this;
11545 // should not be possible to trigger a option under a disabled optgroup
11546 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
11547 return;
11548 }
11549 if (option.classList.contains('create')) {
11550 self.createItem(null, () => {
11551 if (self.settings.closeAfterSelect) {
11552 self.close();
11553 }
11554 else if (self.settings.clearAfterSelect) {
11555 self.setTextboxValue();
11556 }
11557 });
11558 }
11559 else {
11560 value = option.dataset.value;
11561 if (typeof value !== 'undefined') {
11562 self.isDropdownContentStale = self.settings.hideSelected;
11563 self.addItem(value);
11564 if (self.settings.closeAfterSelect) {
11565 self.close();
11566 }
11567 else if (self.settings.clearAfterSelect) {
11568 self.setTextboxValue();
11569 }
11570 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
11571 self.setActiveOption(option);
11572 }
11573 }
11574 }
11575 }
11576 /**
11577 * Return true if the given option can be selected
11578 *
11579 */
11580 canSelect(option) {
11581 if (this.isOpen && option && this.dropdown_content.contains(option)) {
11582 return true;
11583 }
11584 return false;
11585 }
11586 /**
11587 * Triggered when the user clicks on an item
11588 * that has been selected.
11589 *
11590 */
11591 onItemSelect(evt, item) {
11592 var self = this;
11593 if (!self.isLocked && self.settings.mode === 'multi') {
11594 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
11595 self.setActiveItem(item, evt);
11596 return true;
11597 }
11598 return false;
11599 }
11600 /**
11601 * Determines whether or not to invoke
11602 * the user-provided option provider / loader
11603 *
11604 * Note, there is a subtle difference between
11605 * this.canLoad() and this.settings.shouldLoad();
11606 *
11607 * - settings.shouldLoad() is a user-input validator.
11608 * When false is returned, the not_loading template
11609 * will be added to the dropdown
11610 *
11611 * - canLoad() is lower level validator that checks
11612 * the Tom Select instance. There is no inherent user
11613 * feedback when canLoad returns false
11614 *
11615 */
11616 canLoad(value) {
11617 if (!this.settings.load)
11618 return false;
11619 if (this.loadedSearches.hasOwnProperty(value))
11620 return false;
11621 return true;
11622 }
11623 /**
11624 * Invokes the user-provided option provider / loader.
11625 *
11626 */
11627 load(value) {
11628 const self = this;
11629 if (!self.canLoad(value))
11630 return;
11631 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
11632 self.loading++;
11633 const callback = self.loadCallback.bind(self);
11634 self.settings.load.call(self, value, callback);
11635 }
11636 /**
11637 * Invoked by the user-provided option provider
11638 *
11639 */
11640 loadCallback(options, optgroups) {
11641 const self = this;
11642 self.loading = Math.max(self.loading - 1, 0);
11643 self.isDropdownContentStale = true;
11644 self.clearActiveOption(); // when new results load, focus should be on first option
11645 self.setupOptions(options, optgroups);
11646 self.refreshOptions(self.isFocused && !self.isInputHidden);
11647 if (!self.loading) {
11648 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
11649 }
11650 self.trigger('load', options, optgroups);
11651 }
11652 preload() {
11653 var classList = this.wrapper.classList;
11654 if (classList.contains('preloaded'))
11655 return;
11656 classList.add('preloaded');
11657 this.load('');
11658 }
11659 /**
11660 * Sets the input field of the control to the specified value.
11661 *
11662 */
11663 setTextboxValue(value = '') {
11664 var input = this.control_input;
11665 var changed = input.value !== value;
11666 if (changed) {
11667 input.value = value;
11668 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
11669 this.lastValue = value;
11670 }
11671 }
11672 /**
11673 * Returns the value of the control. If multiple items
11674 * can be selected (e.g. <select multiple>), this returns
11675 * an array. If only one item can be selected, this
11676 * returns a string.
11677 *
11678 */
11679 getValue() {
11680 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
11681 return this.items;
11682 }
11683 return this.items.join(this.settings.delimiter);
11684 }
11685 /**
11686 * Resets the selected items to the given value.
11687 *
11688 */
11689 setValue(value, silent) {
11690 var events = silent ? [] : ['change'];
11691 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
11692 this.clear(silent);
11693 this.addItems(value, silent);
11694 });
11695 }
11696 /**
11697 * Resets the number of max items to the given value
11698 *
11699 */
11700 setMaxItems(value) {
11701 if (value === 0)
11702 value = null; //reset to unlimited items.
11703 this.settings.maxItems = value;
11704 this.refreshState();
11705 }
11706 /**
11707 * Sets the selected item.
11708 *
11709 */
11710 setActiveItem(item, e) {
11711 var self = this;
11712 var eventName;
11713 var i, begin, end, swap;
11714 var last;
11715 if (self.settings.mode === 'single')
11716 return;
11717 // clear the active selection
11718 if (!item) {
11719 self.clearActiveItems();
11720 if (self.isFocused) {
11721 self.inputState();
11722 }
11723 return;
11724 }
11725 // modify selection
11726 eventName = e && e.type.toLowerCase();
11727 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
11728 last = self.getLastActive();
11729 begin = Array.prototype.indexOf.call(self.control.children, last);
11730 end = Array.prototype.indexOf.call(self.control.children, item);
11731 if (begin > end) {
11732 swap = begin;
11733 begin = end;
11734 end = swap;
11735 }
11736 for (i = begin; i <= end; i++) {
11737 item = self.control.children[i];
11738 if (self.activeItems.indexOf(item) === -1) {
11739 self.setActiveItemClass(item);
11740 }
11741 }
11742 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11743 }
11744 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))) {
11745 if (item.classList.contains('active')) {
11746 self.removeActiveItem(item);
11747 }
11748 else {
11749 self.setActiveItemClass(item);
11750 }
11751 }
11752 else {
11753 self.clearActiveItems();
11754 self.setActiveItemClass(item);
11755 }
11756 // ensure control has focus
11757 self.inputState();
11758 if (!self.isFocused) {
11759 self.focus();
11760 }
11761 }
11762 /**
11763 * Set the active and last-active classes
11764 *
11765 */
11766 setActiveItemClass(item) {
11767 const self = this;
11768 const last_active = self.control.querySelector('.last-active');
11769 if (last_active)
11770 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
11771 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
11772 self.trigger('item_select', item);
11773 if (self.activeItems.indexOf(item) == -1) {
11774 self.activeItems.push(item);
11775 }
11776 }
11777 /**
11778 * Remove active item
11779 *
11780 */
11781 removeActiveItem(item) {
11782 var idx = this.activeItems.indexOf(item);
11783 this.activeItems.splice(idx, 1);
11784 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
11785 }
11786 /**
11787 * Clears all the active items
11788 *
11789 */
11790 clearActiveItems() {
11791 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
11792 this.activeItems = [];
11793 }
11794 /**
11795 * Sets the selected item in the dropdown menu
11796 * of available options.
11797 *
11798 */
11799 setActiveOption(option, scroll = true) {
11800 if (option === this.activeOption) {
11801 return;
11802 }
11803 this.clearActiveOption();
11804 if (!option)
11805 return;
11806 this.activeOption = option;
11807 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
11808 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
11809 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
11810 if (scroll)
11811 this.scrollToOption(option);
11812 }
11813 /**
11814 * Sets the dropdown_content scrollTop to display the option
11815 *
11816 */
11817 scrollToOption(option, behavior) {
11818 if (!option)
11819 return;
11820 const content = this.dropdown_content;
11821 const height_menu = content.clientHeight;
11822 const scrollTop = content.scrollTop || 0;
11823 const height_item = option.offsetHeight;
11824 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
11825 if (y + height_item > height_menu + scrollTop) {
11826 this.scroll(y - height_menu + height_item, behavior);
11827 }
11828 else if (y < scrollTop) {
11829 this.scroll(y, behavior);
11830 }
11831 }
11832 /**
11833 * Scroll the dropdown to the given position
11834 *
11835 */
11836 scroll(scrollTop, behavior) {
11837 const content = this.dropdown_content;
11838 if (behavior) {
11839 content.style.scrollBehavior = behavior;
11840 }
11841 content.scrollTop = scrollTop;
11842 content.style.scrollBehavior = '';
11843 }
11844 /**
11845 * Clears the active option
11846 *
11847 */
11848 clearActiveOption() {
11849 if (this.activeOption) {
11850 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
11851 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
11852 }
11853 this.activeOption = null;
11854 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
11855 }
11856 /**
11857 * Selects all items (CTRL + A).
11858 */
11859 selectAll() {
11860 const self = this;
11861 if (self.settings.mode === 'single')
11862 return;
11863 const activeItems = self.controlChildren();
11864 if (!activeItems.length)
11865 return;
11866 self.inputState();
11867 self.close();
11868 self.activeItems = activeItems;
11869 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
11870 self.setActiveItemClass(item);
11871 });
11872 }
11873 /**
11874 * Determines if the control_input should be in a hidden or visible state
11875 *
11876 */
11877 inputState() {
11878 var self = this;
11879 if (!self.control.contains(self.control_input))
11880 return;
11881 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
11882 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
11883 self.setTextboxValue();
11884 self.isInputHidden = true;
11885 }
11886 else {
11887 if (self.settings.hidePlaceholder && self.items.length > 0) {
11888 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
11889 }
11890 self.isInputHidden = false;
11891 }
11892 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
11893 }
11894 /**
11895 * Get the input value
11896 */
11897 inputValue() {
11898 return this.control_input.value.trim();
11899 }
11900 /**
11901 * Gives the control focus.
11902 */
11903 focus() {
11904 var self = this;
11905 if (self.isDisabled || self.isReadOnly)
11906 return;
11907 self.ignoreFocus = true;
11908 const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node;
11909 focusTarget.focus();
11910 setTimeout(() => {
11911 self.ignoreFocus = false;
11912 // Fix https://github.com/orchidjs/tom-select/issues/806
11913 // Only proceed if this instance's element is still the active element. If Edge autofill
11914 // (or anything else) has moved focus to a different element in the interim, calling
11915 // onFocus() here would steal focus back and restart the cascade loop.
11916 const root = focusTarget.getRootNode();
11917 if (root.activeElement !== focusTarget) {
11918 return;
11919 }
11920 this.onFocus();
11921 }, 0);
11922 }
11923 /**
11924 * Forces the control out of focus.
11925 *
11926 */
11927 blur() {
11928 this.focus_node.blur();
11929 this.onBlur();
11930 }
11931 /**
11932 * Returns a function that scores an object
11933 * to show how good of a match it is to the
11934 * provided query.
11935 *
11936 * @return {function}
11937 */
11938 getScoreFunction(query) {
11939 return this.sifter.getScoreFunction(query, this.getSearchOptions());
11940 }
11941 /**
11942 * Returns search options for sifter (the system
11943 * for scoring and sorting results).
11944 *
11945 * @see https://github.com/orchidjs/sifter.js
11946 * @return {object}
11947 */
11948 getSearchOptions() {
11949 var settings = this.settings;
11950 var sort = settings.sortField;
11951 if (typeof settings.sortField === 'string') {
11952 sort = [{ field: settings.sortField }];
11953 }
11954 return {
11955 fields: settings.searchField,
11956 conjunction: settings.searchConjunction,
11957 sort: sort,
11958 nesting: settings.nesting
11959 };
11960 }
11961 /**
11962 * Searches through available options and returns
11963 * a sorted array of matches.
11964 *
11965 */
11966 search(query) {
11967 var result, calculateScore;
11968 var self = this;
11969 var options = this.getSearchOptions();
11970 // validate user-provided result scoring function
11971 if (self.settings.score) {
11972 calculateScore = self.settings.score.call(self, query);
11973 if (typeof calculateScore !== 'function') {
11974 throw new Error('Tom Select "score" setting must be a function that returns a function');
11975 }
11976 }
11977 // perform search
11978 if (self.isDropdownContentStale || query !== self.lastQuery) {
11979 self.lastQuery = query;
11980 // temp fix for https://github.com/orchidjs/tom-select/issues/987
11981 // UI crashed when more than 30 same chars in a row, prevent search and return empt result
11982 if (/(.)\1{15,}/.test(query)) {
11983 query = '';
11984 }
11985 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
11986 self.currentResults = result;
11987 }
11988 else {
11989 result = Object.assign({}, self.currentResults);
11990 }
11991 // filter out selected items
11992 if (self.settings.hideSelected) {
11993 result.items = result.items.filter((item) => {
11994 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
11995 return !(hashed !== null && self.items.indexOf(hashed) !== -1);
11996 });
11997 }
11998 return result;
11999 }
12000 /**
12001 * Refreshes the list of available options shown
12002 * in the autocomplete dropdown menu.
12003 *
12004 */
12005 refreshOptions(triggerDropdown = true) {
12006 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
12007 var create;
12008 const groups = {};
12009 const groups_order = [];
12010 var self = this;
12011 var query = self.inputValue();
12012 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
12013 var results = self.search(query);
12014 var active_option = null;
12015 var show_dropdown = self.settings.shouldOpen || false;
12016 var dropdown_content = self.dropdown_content;
12017 if (same_query) {
12018 active_option = self.activeOption;
12019 if (active_option) {
12020 active_group = active_option.closest('[data-group]');
12021 }
12022 }
12023 // build markup
12024 n = results.items.length;
12025 if (typeof self.settings.maxOptions === 'number') {
12026 n = Math.min(n, self.settings.maxOptions);
12027 }
12028 if (n > 0) {
12029 show_dropdown = true;
12030 }
12031 // get fragment for group and the position of the group in group_order
12032 const getGroupFragment = (optgroup, order) => {
12033 let group_order_i = groups[optgroup];
12034 if (group_order_i !== undefined) {
12035 let order_group = groups_order[group_order_i];
12036 if (order_group !== undefined) {
12037 return [group_order_i, order_group.fragment];
12038 }
12039 }
12040 let group_fragment = document.createDocumentFragment();
12041 group_order_i = groups_order.length;
12042 groups_order.push({ fragment: group_fragment, order, optgroup });
12043 return [group_order_i, group_fragment];
12044 };
12045 // render and group available options individually
12046 for (i = 0; i < n; i++) {
12047 // get option dom element
12048 let item = results.items[i];
12049 if (!item)
12050 continue;
12051 let opt_value = item.id;
12052 let option = self.options[opt_value];
12053 if (option === undefined)
12054 continue;
12055 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12056 let option_el = self.getOption(opt_hash, true);
12057 // toggle 'selected' class
12058 if (!self.settings.hideSelected) {
12059 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12060 }
12061 optgroup = option[self.settings.optgroupField] || '';
12062 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12063 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12064 optgroup = optgroups[j];
12065 let order = option.$order;
12066 let self_optgroup = self.optgroups[optgroup];
12067 if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') {
12068 var regGroup;
12069 if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) {
12070 self.registerOptionGroup(regGroup);
12071 }
12072 }
12073 self_optgroup = self.optgroups[optgroup];
12074 if (self_optgroup === undefined) {
12075 optgroup = '';
12076 }
12077 else {
12078 order = self_optgroup.$order;
12079 }
12080 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12081 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12082 if (j > 0) {
12083 option_el = option_el.cloneNode(true);
12084 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12085 option_el.classList.add('ts-cloned');
12086 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12087 // make sure we keep the activeOption in the same group
12088 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12089 if (active_group && active_group.dataset.group === optgroup.toString()) {
12090 active_option = option_el;
12091 }
12092 }
12093 }
12094 group_fragment.appendChild(option_el);
12095 if (optgroup != '') {
12096 groups[optgroup] = group_order_i;
12097 }
12098 }
12099 }
12100 // sort optgroups
12101 if (self.settings.lockOptgroupOrder) {
12102 groups_order.sort((a, b) => {
12103 return a.order - b.order;
12104 });
12105 }
12106 // render optgroup headers & join groups
12107 html = document.createDocumentFragment();
12108 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12109 let group_fragment = group_order.fragment;
12110 let optgroup = group_order.optgroup;
12111 if (!group_fragment || !group_fragment.children.length)
12112 return;
12113 let group_heading = self.optgroups[optgroup];
12114 if (group_heading !== undefined) {
12115 let group_options = document.createDocumentFragment();
12116 let header = self.render('optgroup_header', group_heading);
12117 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12118 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12119 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12120 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12121 }
12122 else {
12123 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12124 }
12125 });
12126 dropdown_content.innerHTML = '';
12127 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12128 self.isDropdownContentStale = false;
12129 // highlight matching terms inline
12130 if (self.settings.highlight) {
12131 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12132 if (results.query.length && results.tokens.length) {
12133 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12134 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12135 });
12136 }
12137 }
12138 // helper method for adding templates to dropdown
12139 var add_template = (template) => {
12140 let content = self.render(template, { input: query });
12141 if (content) {
12142 show_dropdown = true;
12143 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12144 }
12145 return content;
12146 };
12147 // add loading message
12148 if (self.loading) {
12149 add_template('loading');
12150 // invalid query
12151 }
12152 else if (!self.settings.shouldLoad.call(self, query)) {
12153 add_template('not_loading');
12154 // add no_results message
12155 }
12156 else if (results.items.length === 0) {
12157 add_template('no_results');
12158 }
12159 // add create option
12160 has_create_option = self.canCreate(query);
12161 if (has_create_option) {
12162 create = add_template('option_create');
12163 }
12164 // activate
12165 self.hasOptions = results.items.length > 0 || has_create_option;
12166 if (show_dropdown) {
12167 if (results.items.length > 0) {
12168 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12169 active_option = self.getOption(self.items[0]);
12170 }
12171 if (!dropdown_content.contains(active_option)) {
12172 let active_index = 0;
12173 if (create && !self.settings.addPrecedence) {
12174 active_index = 1;
12175 }
12176 active_option = self.selectable()[active_index];
12177 }
12178 }
12179 else if (create) {
12180 active_option = create;
12181 }
12182 if (triggerDropdown && !self.isOpen) {
12183 self.open();
12184 self.scrollToOption(active_option, 'auto');
12185 }
12186 self.setActiveOption(active_option);
12187 }
12188 else {
12189 self.clearActiveOption();
12190 if (triggerDropdown && self.isOpen) {
12191 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12192 }
12193 }
12194 }
12195 /**
12196 * Return list of selectable options
12197 *
12198 */
12199 selectable() {
12200 return this.dropdown_content.querySelectorAll('[data-selectable]');
12201 }
12202 /**
12203 * Adds an available option. If it already exists,
12204 * nothing will happen. Note: this does not refresh
12205 * the options list dropdown (use `refreshOptions`
12206 * for that).
12207 *
12208 * Usage:
12209 *
12210 * this.addOption(data)
12211 *
12212 */
12213 addOption(data, user_created = false) {
12214 const self = this;
12215 // @deprecated 1.7.7
12216 // use addOptions( array, user_created ) for adding multiple options
12217 if (Array.isArray(data)) {
12218 self.addOptions(data, user_created);
12219 return false;
12220 }
12221 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12222 if (key === null || self.options.hasOwnProperty(key)) {
12223 self.updateOption(data[self.settings.valueField], data);
12224 return false;
12225 }
12226 data.$order = data.$order || ++self.order;
12227 data.$id = self.inputId + '-opt-' + data.$order;
12228 self.options[key] = data;
12229 self.isDropdownContentStale = true;
12230 if (user_created) {
12231 self.userOptions[key] = user_created;
12232 self.trigger('option_add', key, data);
12233 }
12234 return key;
12235 }
12236 /**
12237 * Add multiple options
12238 *
12239 */
12240 addOptions(data, user_created = false) {
12241 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12242 this.addOption(dat, user_created);
12243 });
12244 }
12245 /**
12246 * @deprecated 1.7.7
12247 */
12248 registerOption(data) {
12249 return this.addOption(data);
12250 }
12251 /**
12252 * Registers an option group to the pool of option groups.
12253 *
12254 * @return {boolean|string}
12255 */
12256 registerOptionGroup(data) {
12257 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12258 if (key === null)
12259 return false;
12260 data.$order = data.$order || ++this.order;
12261 this.optgroups[key] = data;
12262 return key;
12263 }
12264 /**
12265 * Registers a new optgroup for options
12266 * to be bucketed into.
12267 *
12268 */
12269 addOptionGroup(id, data) {
12270 var hashed_id;
12271 data[this.settings.optgroupValueField] = id;
12272 if (hashed_id = this.registerOptionGroup(data)) {
12273 this.trigger('optgroup_add', hashed_id, data);
12274 }
12275 }
12276 /**
12277 * Removes an existing option group.
12278 *
12279 */
12280 removeOptionGroup(id) {
12281 if (this.optgroups.hasOwnProperty(id)) {
12282 delete this.optgroups[id];
12283 this.clearCache();
12284 this.trigger('optgroup_remove', id);
12285 }
12286 }
12287 /**
12288 * Clears all existing option groups.
12289 */
12290 clearOptionGroups() {
12291 this.optgroups = {};
12292 this.clearCache();
12293 this.trigger('optgroup_clear');
12294 }
12295 /**
12296 * Updates an option available for selection. If
12297 * it is visible in the selected items or options
12298 * dropdown, it will be re-rendered automatically.
12299 *
12300 */
12301 updateOption(value, data) {
12302 const self = this;
12303 var item_new;
12304 var index_item;
12305 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12306 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12307 // sanity checks
12308 if (value_old === null)
12309 return;
12310 const data_old = self.options[value_old];
12311 if (data_old == undefined)
12312 return;
12313 if (typeof value_new !== 'string')
12314 throw new Error('Value must be set in option data');
12315 const option = self.getOption(value_old);
12316 const item = self.getItem(value_old);
12317 data.$order = data.$order || data_old.$order;
12318 delete self.options[value_old];
12319 // invalidate render cache
12320 // don't remove existing node yet, we'll remove it after replacing it
12321 self.uncacheValue(value_new);
12322 self.options[value_new] = data;
12323 // update the option if it's in the dropdown
12324 if (option) {
12325 if (self.dropdown_content.contains(option)) {
12326 const option_new = self._render('option', data);
12327 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12328 if (self.activeOption === option) {
12329 self.setActiveOption(option_new);
12330 }
12331 }
12332 option.remove();
12333 }
12334 // update the item if we have one
12335 if (item) {
12336 index_item = self.items.indexOf(value_old);
12337 if (index_item !== -1) {
12338 self.items.splice(index_item, 1, value_new);
12339 }
12340 item_new = self._render('item', data);
12341 if (item.classList.contains('active'))
12342 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12343 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12344 }
12345 // we might have updated the sortField
12346 self.isDropdownContentStale = true;
12347 }
12348 /**
12349 * Removes a single option.
12350 *
12351 */
12352 removeOption(value, silent) {
12353 const self = this;
12354 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12355 self.uncacheValue(value);
12356 delete self.userOptions[value];
12357 delete self.options[value];
12358 self.isDropdownContentStale = true;
12359 self.trigger('option_remove', value);
12360 self.removeItem(value, silent);
12361 }
12362 /**
12363 * Clears all options.
12364 */
12365 clearOptions(filter) {
12366 const boundFilter = (filter || this.clearFilter).bind(this);
12367 this.loadedSearches = {};
12368 this.userOptions = {};
12369 this.clearCache();
12370 const selected = {};
12371 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12372 if (boundFilter(option, key)) {
12373 selected[key] = option;
12374 }
12375 });
12376 this.options = this.sifter.items = selected;
12377 this.isDropdownContentStale = true;
12378 this.trigger('option_clear');
12379 }
12380 /**
12381 * Used by clearOptions() to decide whether or not an option should be removed
12382 * Return true to keep an option, false to remove
12383 *
12384 */
12385 clearFilter(option, value) {
12386 if (this.items.indexOf(value) >= 0) {
12387 return true;
12388 }
12389 return false;
12390 }
12391 /**
12392 * Returns the dom element of the option
12393 * matching the given value.
12394 *
12395 */
12396 getOption(value, create = false) {
12397 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12398 if (hashed === null)
12399 return null;
12400 const option = this.options[hashed];
12401 if (option != undefined) {
12402 if (option.$div) {
12403 return option.$div;
12404 }
12405 if (create) {
12406 return this._render('option', option);
12407 }
12408 }
12409 return null;
12410 }
12411 /**
12412 * Returns the dom element of the next or previous dom element of the same type
12413 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12414 *
12415 */
12416 getAdjacent(option, direction, type = 'option') {
12417 var self = this, all;
12418 if (!option) {
12419 return null;
12420 }
12421 if (type == 'item') {
12422 all = self.controlChildren();
12423 }
12424 else {
12425 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12426 }
12427 for (let i = 0; i < all.length; i++) {
12428 if (all[i] != option) {
12429 continue;
12430 }
12431 if (direction > 0) {
12432 return all[i + 1];
12433 }
12434 return all[i - 1];
12435 }
12436 return null;
12437 }
12438 /**
12439 * Returns the dom element of the item
12440 * matching the given value.
12441 *
12442 */
12443 getItem(item) {
12444 if (typeof item == 'object') {
12445 return item;
12446 }
12447 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12448 return value !== null
12449 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12450 : null;
12451 }
12452 /**
12453 * "Selects" multiple items at once. Adds them to the list
12454 * at the current caret position.
12455 *
12456 */
12457 addItems(values, silent) {
12458 var self = this;
12459 var items = Array.isArray(values) ? values : [values];
12460 items = items.filter(x => self.items.indexOf(x) === -1);
12461 const last_item = items[items.length - 1];
12462 items.forEach(item => {
12463 self.isPending = (item !== last_item);
12464 self.addItem(item, silent);
12465 });
12466 }
12467 /**
12468 * "Selects" an item. Adds it to the list
12469 * at the current caret position.
12470 *
12471 */
12472 addItem(value, silent) {
12473 var events = silent ? [] : ['change', 'dropdown_close'];
12474 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12475 var item, wasFull;
12476 const self = this;
12477 const inputMode = self.settings.mode;
12478 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12479 if (hashed && self.items.indexOf(hashed) !== -1) {
12480 if (inputMode === 'single') {
12481 self.close();
12482 }
12483 if (inputMode === 'single' || !self.settings.duplicates) {
12484 return;
12485 }
12486 }
12487 if (hashed === null || !self.options.hasOwnProperty(hashed))
12488 return;
12489 if (inputMode === 'single')
12490 self.clear(silent);
12491 if (inputMode === 'multi' && self.isFull())
12492 return;
12493 item = self._render('item', self.options[hashed]);
12494 if (self.control.contains(item)) { // duplicates
12495 item = item.cloneNode(true);
12496 }
12497 wasFull = self.isFull();
12498 self.items.splice(self.caretPos, 0, hashed);
12499 self.insertAtCaret(item);
12500 if (self.isSetup) {
12501 // update menu / remove the option (if this is not one item being added as part of series)
12502 if (!self.isPending && self.settings.hideSelected) {
12503 let option = self.getOption(hashed);
12504 let next = self.getAdjacent(option, 1);
12505 if (next) {
12506 self.setActiveOption(next);
12507 }
12508 }
12509 //remove input value when enabled
12510 if (self.settings.clearAfterSelect) {
12511 self.setTextboxValue();
12512 }
12513 // refreshOptions after setActiveOption(),
12514 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12515 if (!self.isPending && !self.settings.closeAfterSelect) {
12516 self.refreshOptions(self.isFocused && inputMode !== 'single');
12517 }
12518 // hide the menu if the maximum number of items have been selected or no options are left
12519 if (self.settings.closeAfterSelect != false && self.isFull()) {
12520 self.close();
12521 }
12522 else if (!self.isPending) {
12523 self.positionDropdown();
12524 }
12525 self.trigger('item_add', hashed, item);
12526 if (!self.isPending) {
12527 self.updateOriginalInput({ silent: silent });
12528 }
12529 }
12530 if (!self.isPending || (!wasFull && self.isFull())) {
12531 self.inputState();
12532 self.refreshState();
12533 }
12534 });
12535 }
12536 /**
12537 * Removes the selected item matching
12538 * the provided value.
12539 *
12540 */
12541 removeItem(item = null, silent) {
12542 const self = this;
12543 item = self.getItem(item);
12544 if (!item)
12545 return;
12546 var i, idx;
12547 const value = item.dataset.value;
12548 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
12549 item.remove();
12550 if (item.classList.contains('active')) {
12551 idx = self.activeItems.indexOf(item);
12552 self.activeItems.splice(idx, 1);
12553 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12554 }
12555 self.items.splice(i, 1);
12556 self.isDropdownContentStale = true;
12557 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
12558 self.removeOption(value, silent);
12559 }
12560 if (i < self.caretPos) {
12561 self.setCaret(self.caretPos - 1);
12562 }
12563 self.updateOriginalInput({ silent: silent });
12564 self.refreshState();
12565 self.positionDropdown();
12566 self.trigger('item_remove', value, item);
12567 }
12568 /**
12569 * Invokes the `create` method provided in the
12570 * TomSelect options that should provide the data
12571 * for the new item, given the user input.
12572 *
12573 * Once this completes, it will be added
12574 * to the item list.
12575 *
12576 */
12577 createItem(input = null, callback = () => { }) {
12578 // triggerDropdown parameter @deprecated 2.1.1
12579 if (arguments.length === 3) {
12580 callback = arguments[2];
12581 }
12582 if (typeof callback != 'function') {
12583 callback = () => { };
12584 }
12585 var self = this;
12586 var caret = self.caretPos;
12587 var output;
12588 input = input || self.inputValue();
12589 if (!self.canCreate(input)) {
12590 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input);
12591 if (hash) {
12592 if (this.options[input]) {
12593 self.addItem(input);
12594 }
12595 }
12596 callback();
12597 return false;
12598 }
12599 self.lock();
12600 var created = false;
12601 var create = (data) => {
12602 self.unlock();
12603 if (!data || typeof data !== 'object')
12604 return callback();
12605 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12606 if (typeof value !== 'string') {
12607 return callback();
12608 }
12609 self.setTextboxValue();
12610 self.addOption(data, true);
12611 self.setCaret(caret);
12612 self.addItem(value);
12613 callback(data);
12614 created = true;
12615 };
12616 if (typeof self.settings.create === 'function') {
12617 output = self.settings.create.call(this, input, create);
12618 }
12619 else {
12620 output = {
12621 [self.settings.labelField]: input,
12622 [self.settings.valueField]: input,
12623 };
12624 }
12625 if (!created) {
12626 create(output);
12627 }
12628 return true;
12629 }
12630 /**
12631 * Re-renders the selected item lists.
12632 */
12633 refreshItems() {
12634 var self = this;
12635 self.isDropdownContentStale = true;
12636 if (self.isSetup) {
12637 self.addItems(self.items);
12638 }
12639 self.updateOriginalInput();
12640 self.refreshState();
12641 }
12642 /**
12643 * Updates all state-dependent attributes
12644 * and CSS classes.
12645 */
12646 refreshState() {
12647 const self = this;
12648 self.refreshValidityState();
12649 const isFull = self.isFull();
12650 const isLocked = self.isLocked;
12651 self.wrapper.classList.toggle('rtl', self.rtl);
12652 const wrap_classList = self.wrapper.classList;
12653 wrap_classList.toggle('focus', self.isFocused);
12654 wrap_classList.toggle('disabled', self.isDisabled);
12655 wrap_classList.toggle('readonly', self.isReadOnly);
12656 wrap_classList.toggle('required', self.isRequired);
12657 wrap_classList.toggle('invalid', !self.isValid);
12658 wrap_classList.toggle('locked', isLocked);
12659 wrap_classList.toggle('full', isFull);
12660 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
12661 wrap_classList.toggle('dropdown-active', self.isOpen);
12662 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
12663 wrap_classList.toggle('has-items', self.items.length > 0);
12664 }
12665 /**
12666 * Update the `required` attribute of both input and control input.
12667 *
12668 * The `required` property needs to be activated on the control input
12669 * for the error to be displayed at the right place. `required` also
12670 * needs to be temporarily deactivated on the input since the input is
12671 * hidden and can't show errors.
12672 */
12673 refreshValidityState() {
12674 var self = this;
12675 if (!self.input.validity) {
12676 return;
12677 }
12678 self.isValid = self.input.validity.valid;
12679 self.isInvalid = !self.isValid;
12680 }
12681 /**
12682 * Determines whether or not more items can be added
12683 * to the control without exceeding the user-defined maximum.
12684 *
12685 * @returns {boolean}
12686 */
12687 isFull() {
12688 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
12689 }
12690 /**
12691 * Refreshes the original <select> or <input>
12692 * element to reflect the current state.
12693 *
12694 */
12695 updateOriginalInput(opts = {}) {
12696 const self = this;
12697 var option, label;
12698 const empty_option = self.input.querySelector('option[value=""]');
12699 if (self.is_select_tag) {
12700 const selected = [];
12701 const has_selected = self.input.querySelectorAll('option:checked').length;
12702 function AddSelected(option_el, value, label) {
12703 if (!option_el) {
12704 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>');
12705 }
12706 // don't move empty option from top of list
12707 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
12708 if (option_el != empty_option) {
12709 self.input.append(option_el);
12710 }
12711 selected.push(option_el);
12712 // marking empty option as selected can break validation
12713 // fixes https://github.com/orchidjs/tom-select/issues/303
12714 if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') {
12715 option_el.selected = true;
12716 }
12717 return option_el;
12718 }
12719 // unselect all selected options
12720 self.input.querySelectorAll('option:checked').forEach((option_el) => {
12721 option_el.selected = false;
12722 });
12723 // nothing selected?
12724 if (self.items.length == 0 && self.settings.mode == 'single') {
12725 AddSelected(empty_option, "", "");
12726 // order selected <option> tags for values in self.items
12727 }
12728 else {
12729 self.items.forEach((value) => {
12730 option = self.options[value];
12731 label = option[self.settings.labelField] || '';
12732 if (selected.includes(option.$option)) {
12733 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
12734 AddSelected(reuse_opt, value, label);
12735 }
12736 else {
12737 option.$option = AddSelected(option.$option, value, label);
12738 }
12739 });
12740 }
12741 }
12742 else {
12743 self.input.value = self.getValue();
12744 }
12745 if (self.isSetup) {
12746 if (!opts.silent) {
12747 self.trigger('change', self.getValue());
12748 }
12749 }
12750 }
12751 /**
12752 * Shows the autocomplete dropdown containing
12753 * the available options.
12754 */
12755 open() {
12756 var self = this;
12757 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
12758 return;
12759 self.isOpen = true;
12760 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
12761 self.refreshState();
12762 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
12763 self.positionDropdown();
12764 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
12765 self.focus();
12766 self.trigger('dropdown_open', self.dropdown);
12767 }
12768 /**
12769 * Closes the autocomplete dropdown menu.
12770 */
12771 close(setTextboxValue = true) {
12772 var self = this;
12773 var trigger = self.isOpen;
12774 if (setTextboxValue) {
12775 // before blur() to prevent form onchange event
12776 self.setTextboxValue();
12777 if (self.settings.mode === 'single' && self.items.length) {
12778 self.inputState();
12779 }
12780 }
12781 self.isOpen = false;
12782 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
12783 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
12784 if (self.settings.hideSelected) {
12785 self.clearActiveOption();
12786 }
12787 self.refreshState();
12788 if (trigger)
12789 self.trigger('dropdown_close', self.dropdown);
12790 }
12791 /**
12792 * Calculates and applies the appropriate
12793 * position of the dropdown if dropdownParent = 'body'.
12794 * Otherwise, position is determined by css
12795 */
12796 positionDropdown() {
12797 if (this.settings.dropdownParent !== 'body') {
12798 return;
12799 }
12800 var context = this.control;
12801 var rect = context.getBoundingClientRect();
12802 var top = context.offsetHeight + rect.top + window.scrollY;
12803 var left = rect.left + window.scrollX;
12804 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
12805 width: rect.width + 'px',
12806 top: top + 'px',
12807 left: left + 'px'
12808 });
12809 }
12810 /**
12811 * Resets / clears all selected items
12812 * from the control.
12813 *
12814 */
12815 clear(silent) {
12816 var self = this;
12817 if (!self.items.length)
12818 return;
12819 var items = self.controlChildren();
12820 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
12821 self.removeItem(item, true);
12822 });
12823 self.inputState();
12824 if (!silent)
12825 self.updateOriginalInput();
12826 self.trigger('clear');
12827 }
12828 /**
12829 * A helper method for inserting an element
12830 * at the current caret position.
12831 *
12832 */
12833 insertAtCaret(el) {
12834 const self = this;
12835 const caret = self.caretPos;
12836 const target = self.control;
12837 target.insertBefore(el, target.children[caret] || null);
12838 self.setCaret(caret + 1);
12839 }
12840 /**
12841 * Removes the current selected item(s).
12842 *
12843 */
12844 deleteSelection(e) {
12845 var direction, selection, caret, tail;
12846 var self = this;
12847 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
12848 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
12849 // determine items that will be removed
12850 const rm_items = [];
12851 if (self.activeItems.length) {
12852 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
12853 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
12854 if (direction > 0) {
12855 caret++;
12856 }
12857 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
12858 }
12859 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
12860 const items = self.controlChildren();
12861 let rm_item;
12862 if (direction < 0 && selection.start === 0 && selection.length === 0) {
12863 rm_item = items[self.caretPos - 1];
12864 }
12865 else if (direction > 0 && selection.start === self.inputValue().length) {
12866 rm_item = items[self.caretPos];
12867 }
12868 if (rm_item !== undefined) {
12869 rm_items.push(rm_item);
12870 }
12871 }
12872 if (!self.shouldDelete(rm_items, e)) {
12873 return false;
12874 }
12875 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
12876 // perform removal
12877 if (typeof caret !== 'undefined') {
12878 self.setCaret(caret);
12879 }
12880 while (rm_items.length) {
12881 self.removeItem(rm_items.pop());
12882 }
12883 self.inputState();
12884 self.positionDropdown();
12885 self.refreshOptions(false);
12886 return true;
12887 }
12888 /**
12889 * Return true if the items should be deleted
12890 */
12891 shouldDelete(items, evt) {
12892 const values = items.map(item => item.dataset.value);
12893 // allow the callback to abort
12894 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) {
12895 return false;
12896 }
12897 return true;
12898 }
12899 /**
12900 * Selects the previous / next item (depending on the `direction` argument).
12901 *
12902 * > 0 - right
12903 * < 0 - left
12904 *
12905 */
12906 advanceSelection(direction, e) {
12907 var last_active, adjacent, self = this;
12908 if (self.rtl)
12909 direction *= -1;
12910 if (self.inputValue().length)
12911 return;
12912 // add or remove to active items
12913 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)) {
12914 last_active = self.getLastActive(direction);
12915 if (last_active) {
12916 if (!last_active.classList.contains('active')) {
12917 adjacent = last_active;
12918 }
12919 else {
12920 adjacent = self.getAdjacent(last_active, direction, 'item');
12921 }
12922 // if no active item, get items adjacent to the control input
12923 }
12924 else if (direction > 0) {
12925 adjacent = self.control_input.nextElementSibling;
12926 }
12927 else {
12928 adjacent = self.control_input.previousElementSibling;
12929 }
12930 if (adjacent) {
12931 if (adjacent.classList.contains('active')) {
12932 self.removeActiveItem(last_active);
12933 }
12934 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
12935 }
12936 // move caret to the left or right
12937 }
12938 else {
12939 self.moveCaret(direction);
12940 }
12941 }
12942 moveCaret(direction) { }
12943 /**
12944 * Get the last active item
12945 *
12946 */
12947 getLastActive(direction) {
12948 let last_active = this.control.querySelector('.last-active');
12949 if (last_active) {
12950 return last_active;
12951 }
12952 var result = this.control.querySelectorAll('.active');
12953 if (result) {
12954 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
12955 }
12956 }
12957 /**
12958 * Moves the caret to the specified index.
12959 *
12960 * The input must be moved by leaving it in place and moving the
12961 * siblings, due to the fact that focus cannot be restored once lost
12962 * on mobile webkit devices
12963 *
12964 */
12965 setCaret(new_pos) {
12966 this.caretPos = this.items.length;
12967 }
12968 /**
12969 * Return list of item dom elements
12970 *
12971 */
12972 controlChildren() {
12973 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
12974 }
12975 /**
12976 * Disables user input on the control. Used while
12977 * items are being asynchronously created.
12978 */
12979 lock() {
12980 this.setLocked(true);
12981 }
12982 /**
12983 * Re-enables user input on the control.
12984 */
12985 unlock() {
12986 this.setLocked(false);
12987 }
12988 /**
12989 * Disable or enable user input on the control
12990 */
12991 setLocked(lock = this.isReadOnly || this.isDisabled) {
12992 this.isLocked = lock;
12993 this.refreshState();
12994 }
12995 /**
12996 * Disables user input on the control completely.
12997 * While disabled, it cannot receive focus.
12998 */
12999 disable() {
13000 this.setDisabled(true);
13001 this.close();
13002 }
13003 /**
13004 * Enables the control so that it can respond
13005 * to focus and user input.
13006 */
13007 enable() {
13008 this.setDisabled(false);
13009 }
13010 setDisabled(disabled) {
13011 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
13012 this.isDisabled = disabled;
13013 this.input.disabled = disabled;
13014 this.control_input.disabled = disabled;
13015 this.setLocked();
13016 }
13017 setReadOnly(isReadOnly) {
13018 this.isReadOnly = isReadOnly;
13019 this.input.readOnly = isReadOnly;
13020 this.control_input.readOnly = isReadOnly;
13021 this.setLocked();
13022 }
13023 /**
13024 * Completely destroys the control and
13025 * unbinds all event listeners so that it can
13026 * be garbage collected.
13027 */
13028 destroy() {
13029 var self = this;
13030 var revertSettings = self.revertSettings;
13031 self.trigger('destroy');
13032 self.off();
13033 self.wrapper.remove();
13034 self.dropdown.remove();
13035 self.input.innerHTML = revertSettings.innerHTML;
13036 self.input.tabIndex = revertSettings.tabIndex;
13037 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
13038 self._destroy();
13039 delete self.input.tomselect;
13040 }
13041 /**
13042 * A helper method for rendering "item" and
13043 * "option" templates, given the data.
13044 *
13045 */
13046 render(templateName, data) {
13047 var id, html;
13048 const self = this;
13049 if (typeof this.settings.render[templateName] !== 'function') {
13050 return null;
13051 }
13052 // render markup
13053 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
13054 if (!html) {
13055 return null;
13056 }
13057 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
13058 // add mandatory attributes
13059 if (templateName === 'option' || templateName === 'option_create') {
13060 if (data[self.settings.disabledField]) {
13061 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
13062 }
13063 else {
13064 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13065 }
13066 }
13067 else if (templateName === 'optgroup') {
13068 id = data.group[self.settings.optgroupValueField];
13069 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13070 if (data.group[self.settings.disabledField]) {
13071 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13072 }
13073 }
13074 if (templateName === 'option' || templateName === 'item') {
13075 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13076 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13077 // make sure we have some classes if a template is overwritten
13078 if (templateName === 'item') {
13079 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13080 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13081 }
13082 else {
13083 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13084 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13085 role: 'option',
13086 id: data.$id
13087 });
13088 // update cache
13089 data.$div = html;
13090 self.options[value] = data;
13091 }
13092 }
13093 return html;
13094 }
13095 /**
13096 * Type guarded rendering
13097 *
13098 */
13099 _render(templateName, data) {
13100 const html = this.render(templateName, data);
13101 if (html == null) {
13102 throw 'HTMLElement expected';
13103 }
13104 return html;
13105 }
13106 /**
13107 * Clears the render cache for a template. If
13108 * no template is given, clears all render
13109 * caches.
13110 *
13111 */
13112 clearCache() {
13113 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13114 if (option.$div) {
13115 option.$div.remove();
13116 delete option.$div;
13117 }
13118 });
13119 }
13120 /**
13121 * Removes a value from item and option caches
13122 *
13123 */
13124 uncacheValue(value) {
13125 const option_el = this.getOption(value);
13126 if (option_el)
13127 option_el.remove();
13128 }
13129 /**
13130 * Determines whether or not to display the
13131 * create item prompt, given a user input.
13132 *
13133 */
13134 canCreate(input) {
13135 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13136 }
13137 /**
13138 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13139 *
13140 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13141 *
13142 * });
13143 */
13144 hook(when, method, new_fn) {
13145 var self = this;
13146 var orig_method = self[method];
13147 self[method] = function () {
13148 var result, result_new;
13149 if (when === 'after') {
13150 result = orig_method.apply(self, arguments);
13151 }
13152 result_new = new_fn.apply(self, arguments);
13153 if (when === 'instead') {
13154 return result_new;
13155 }
13156 if (when === 'before') {
13157 result = orig_method.apply(self, arguments);
13158 }
13159 return result;
13160 };
13161 }
13162 }
13163 ;
13164 //# sourceMappingURL=tom-select.js.map
13165
13166 /***/ },
13167
13168 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13169 /*!***************************************************!*\
13170 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13171 \***************************************************/
13172 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13173
13174 "use strict";
13175 __webpack_require__.r(__webpack_exports__);
13176 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13177 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13178 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13179 /* harmony export */ append: () => (/* binding */ append),
13180 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13181 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13182 /* harmony export */ getId: () => (/* binding */ getId),
13183 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13184 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13185 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13186 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13187 /* harmony export */ iterate: () => (/* binding */ iterate),
13188 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13189 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13190 /* harmony export */ timeout: () => (/* binding */ timeout)
13191 /* harmony export */ });
13192 /**
13193 * Converts a scalar to its best string representation
13194 * for hash keys and HTML attribute values.
13195 *
13196 * Transformations:
13197 * 'str' -> 'str'
13198 * null -> ''
13199 * undefined -> ''
13200 * true -> '1'
13201 * false -> '0'
13202 * 0 -> '0'
13203 * 1 -> '1'
13204 *
13205 */
13206 const hash_key = (value) => {
13207 if (typeof value === 'undefined' || value === null)
13208 return null;
13209 return get_hash(value);
13210 };
13211 const get_hash = (value) => {
13212 if (typeof value === 'boolean')
13213 return value ? '1' : '0';
13214 return value + '';
13215 };
13216 /**
13217 * Escapes a string for use within HTML.
13218 *
13219 */
13220 const escape_html = (str) => {
13221 return (str + '')
13222 .replace(/&/g, '&amp;')
13223 .replace(/</g, '&lt;')
13224 .replace(/>/g, '&gt;')
13225 .replace(/"/g, '&quot;');
13226 };
13227 /**
13228 * use setTimeout if timeout > 0
13229 */
13230 const timeout = (fn, timeout) => {
13231 if (timeout > 0) {
13232 return window.setTimeout(fn, timeout);
13233 }
13234 fn.call(null);
13235 return null;
13236 };
13237 /**
13238 * Debounce the user provided load function
13239 *
13240 */
13241 const loadDebounce = (fn, delay) => {
13242 var timeout;
13243 return function (value, callback) {
13244 var self = this;
13245 if (timeout) {
13246 self.loading = Math.max(self.loading - 1, 0);
13247 clearTimeout(timeout);
13248 }
13249 timeout = setTimeout(function () {
13250 timeout = null;
13251 self.loadedSearches[value] = true;
13252 fn.call(self, value, callback);
13253 }, delay);
13254 };
13255 };
13256 /**
13257 * Debounce all fired events types listed in `types`
13258 * while executing the provided `fn`.
13259 *
13260 */
13261 const debounce_events = (self, types, fn) => {
13262 var type;
13263 var trigger = self.trigger;
13264 var event_args = {};
13265 // override trigger method
13266 self.trigger = function () {
13267 var type = arguments[0];
13268 if (types.indexOf(type) !== -1) {
13269 event_args[type] = arguments;
13270 }
13271 else {
13272 return trigger.apply(self, arguments);
13273 }
13274 };
13275 // invoke provided function
13276 fn.apply(self, []);
13277 self.trigger = trigger;
13278 // trigger queued events
13279 for (type of types) {
13280 if (type in event_args) {
13281 trigger.apply(self, event_args[type]);
13282 }
13283 }
13284 };
13285 /**
13286 * Determines the current selection within a text input control.
13287 * Returns an object containing:
13288 * - start
13289 * - length
13290 *
13291 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13292 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13293 */
13294 const getSelection = (input) => {
13295 return {
13296 start: input.selectionStart || 0,
13297 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13298 };
13299 };
13300 /**
13301 * Prevent default
13302 *
13303 */
13304 const preventDefault = (evt, stop = false) => {
13305 if (evt) {
13306 evt.preventDefault();
13307 if (stop) {
13308 evt.stopPropagation();
13309 }
13310 }
13311 };
13312 /**
13313 * Add event helper
13314 *
13315 */
13316 const addEvent = (target, type, callback, options) => {
13317 target.addEventListener(type, callback, options);
13318 };
13319 /**
13320 * Return true if the requested key is down
13321 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13322 * The current evt may not always set ( eg calling advanceSelection() )
13323 *
13324 */
13325 const isKeyDown = (key_name, evt) => {
13326 if (!evt) {
13327 return false;
13328 }
13329 if (!evt[key_name]) {
13330 return false;
13331 }
13332 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13333 if (count === 1) {
13334 return true;
13335 }
13336 return false;
13337 };
13338 /**
13339 * Get the id of an element
13340 * If the id attribute is not set, set the attribute with the given id
13341 *
13342 */
13343 const getId = (el, id) => {
13344 const existing_id = el.getAttribute('id');
13345 if (existing_id) {
13346 return existing_id;
13347 }
13348 el.setAttribute('id', id);
13349 return id;
13350 };
13351 /**
13352 * Returns a string with backslashes added before characters that need to be escaped.
13353 */
13354 const addSlashes = (str) => {
13355 return str.replace(/[\\"']/g, '\\$&');
13356 };
13357 /**
13358 *
13359 */
13360 const append = (parent, node) => {
13361 if (node)
13362 parent.append(node);
13363 };
13364 /**
13365 * Iterates over arrays and hashes.
13366 *
13367 * ```
13368 * iterate(this.items, function(item, id) {
13369 * // invoked for each item
13370 * });
13371 * ```
13372 *
13373 */
13374 const iterate = (object, callback) => {
13375 if (Array.isArray(object)) {
13376 object.forEach(callback);
13377 }
13378 else {
13379 for (var key in object) {
13380 if (object.hasOwnProperty(key)) {
13381 callback(object[key], key);
13382 }
13383 }
13384 }
13385 };
13386 //# sourceMappingURL=utils.js.map
13387
13388 /***/ },
13389
13390 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13391 /*!*****************************************************!*\
13392 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13393 \*****************************************************/
13394 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13395
13396 "use strict";
13397 __webpack_require__.r(__webpack_exports__);
13398 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13399 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13400 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13401 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13402 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13403 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13404 /* harmony export */ getDom: () => (/* binding */ getDom),
13405 /* harmony export */ getTail: () => (/* binding */ getTail),
13406 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13407 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13408 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13409 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13410 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13411 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13412 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13413 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13414 /* harmony export */ });
13415 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13416
13417 /**
13418 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13419 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13420 *
13421 * param query should be {}
13422 */
13423 const getDom = (query) => {
13424 if (query.jquery) {
13425 return query[0];
13426 }
13427 if (query instanceof HTMLElement) {
13428 return query;
13429 }
13430 if (isHtmlString(query)) {
13431 var tpl = document.createElement('template');
13432 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13433 return tpl.content.firstChild;
13434 }
13435 return document.querySelector(query);
13436 };
13437 const isHtmlString = (arg) => {
13438 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13439 return true;
13440 }
13441 return false;
13442 };
13443 const escapeQuery = (query) => {
13444 return query.replace(/['"\\]/g, '\\$&');
13445 };
13446 /**
13447 * Dispatch an event
13448 *
13449 */
13450 const triggerEvent = (dom_el, event_name) => {
13451 var event = document.createEvent('HTMLEvents');
13452 event.initEvent(event_name, true, false);
13453 dom_el.dispatchEvent(event);
13454 };
13455 /**
13456 * Apply CSS rules to a dom element
13457 *
13458 */
13459 const applyCSS = (dom_el, css) => {
13460 Object.assign(dom_el.style, css);
13461 };
13462 /**
13463 * Add css classes
13464 *
13465 */
13466 const addClasses = (elmts, ...classes) => {
13467 var norm_classes = classesArray(classes);
13468 elmts = castAsArray(elmts);
13469 elmts.map(el => {
13470 norm_classes.map(cls => {
13471 el.classList.add(cls);
13472 });
13473 });
13474 };
13475 /**
13476 * Remove css classes
13477 *
13478 */
13479 const removeClasses = (elmts, ...classes) => {
13480 var norm_classes = classesArray(classes);
13481 elmts = castAsArray(elmts);
13482 elmts.map(el => {
13483 norm_classes.map(cls => {
13484 el.classList.remove(cls);
13485 });
13486 });
13487 };
13488 /**
13489 * Return arguments
13490 *
13491 */
13492 const classesArray = (args) => {
13493 var classes = [];
13494 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13495 if (typeof _classes === 'string') {
13496 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13497 }
13498 if (Array.isArray(_classes)) {
13499 classes = classes.concat(_classes);
13500 }
13501 });
13502 return classes.filter(Boolean);
13503 };
13504 /**
13505 * Create an array from arg if it's not already an array
13506 *
13507 */
13508 const castAsArray = (arg) => {
13509 if (!Array.isArray(arg)) {
13510 arg = [arg];
13511 }
13512 return arg;
13513 };
13514 /**
13515 * Get the closest node to the evt.target matching the selector
13516 * Stops at wrapper
13517 *
13518 */
13519 const parentMatch = (target, selector, wrapper) => {
13520 if (wrapper && !wrapper.contains(target)) {
13521 return;
13522 }
13523 while (target && target.matches) {
13524 if (target.matches(selector)) {
13525 return target;
13526 }
13527 target = target.parentNode;
13528 }
13529 };
13530 /**
13531 * Get the first or last item from an array
13532 *
13533 * > 0 - right (last)
13534 * <= 0 - left (first)
13535 *
13536 */
13537 const getTail = (list, direction = 0) => {
13538 if (direction > 0) {
13539 return list[list.length - 1];
13540 }
13541 return list[0];
13542 };
13543 /**
13544 * Return true if an object is empty
13545 *
13546 */
13547 const isEmptyObject = (obj) => {
13548 return (Object.keys(obj).length === 0);
13549 };
13550 /**
13551 * Get the index of an element amongst sibling nodes of the same type
13552 *
13553 */
13554 const nodeIndex = (el, amongst) => {
13555 if (!el)
13556 return -1;
13557 amongst = amongst || el.nodeName;
13558 var i = 0;
13559 while (el = el.previousElementSibling) {
13560 if (el.matches(amongst)) {
13561 i++;
13562 }
13563 }
13564 return i;
13565 };
13566 /**
13567 * Set attributes of an element
13568 *
13569 */
13570 const setAttr = (el, attrs) => {
13571 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
13572 if (val == null) {
13573 el.removeAttribute(attr);
13574 }
13575 else {
13576 el.setAttribute(attr, '' + val);
13577 }
13578 });
13579 };
13580 /**
13581 * Replace a node
13582 */
13583 const replaceNode = (existing, replacement) => {
13584 if (existing.parentNode)
13585 existing.parentNode.replaceChild(replacement, existing);
13586 };
13587 //# sourceMappingURL=vanilla.js.map
13588
13589 /***/ }
13590
13591 /******/ });
13592 /************************************************************************/
13593 /******/ // The module cache
13594 /******/ const __webpack_module_cache__ = {};
13595 /******/
13596 /******/ // The require function
13597 /******/ function __webpack_require__(moduleId) {
13598 /******/ // Check if module is in cache
13599 /******/ const cachedModule = __webpack_module_cache__[moduleId];
13600 /******/ if (cachedModule !== undefined) {
13601 /******/ return cachedModule.exports;
13602 /******/ }
13603 /******/ // Create a new module (and put it into the cache)
13604 /******/ const module = __webpack_module_cache__[moduleId] = {
13605 /******/ id: moduleId,
13606 /******/ // no module.loaded needed
13607 /******/ exports: {}
13608 /******/ };
13609 /******/
13610 /******/ // Execute the module function
13611 /******/ if (!(moduleId in __webpack_modules__)) {
13612 /******/ delete __webpack_module_cache__[moduleId];
13613 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
13614 /******/ e.code = 'MODULE_NOT_FOUND';
13615 /******/ throw e;
13616 /******/ }
13617 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
13618 /******/
13619 /******/ // Return the exports of the module
13620 /******/ return module.exports;
13621 /******/ }
13622 /******/
13623 /************************************************************************/
13624 /******/ /* webpack/runtime/compat get default export */
13625 /******/ (() => {
13626 /******/ // getDefaultExport function for compatibility with non-harmony modules
13627 /******/ __webpack_require__.n = (module) => {
13628 /******/ const getter = module && module.__esModule ?
13629 /******/ () => (module['default']) :
13630 /******/ () => (module);
13631 /******/ __webpack_require__.d(getter, { a: getter });
13632 /******/ return getter;
13633 /******/ };
13634 /******/ })();
13635 /******/
13636 /******/ /* webpack/runtime/define property getters */
13637 /******/ (() => {
13638 /******/ // define getter/value functions for harmony exports
13639 /******/ __webpack_require__.d = (exports, definition) => {
13640 /******/ if(Array.isArray(definition)) {
13641 /******/ var i = 0;
13642 /******/ while(i < definition.length) {
13643 /******/ var key = definition[i++];
13644 /******/ var binding = definition[i++];
13645 /******/ if(!__webpack_require__.o(exports, key)) {
13646 /******/ if(binding === 0) {
13647 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
13648 /******/ } else {
13649 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
13650 /******/ }
13651 /******/ } else if(binding === 0) { i++; }
13652 /******/ }
13653 /******/ } else {
13654 /******/ for(var key in definition) {
13655 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13656 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
13657 /******/ }
13658 /******/ }
13659 /******/ }
13660 /******/ };
13661 /******/ })();
13662 /******/
13663 /******/ /* webpack/runtime/hasOwnProperty shorthand */
13664 /******/ (() => {
13665 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
13666 /******/ })();
13667 /******/
13668 /******/ /* webpack/runtime/make namespace object */
13669 /******/ (() => {
13670 /******/ // define __esModule on exports
13671 /******/ __webpack_require__.r = (exports) => {
13672 /******/ if(Symbol.toStringTag) {
13673 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13674 /******/ }
13675 /******/ Object.defineProperty(exports, '__esModule', { value: true });
13676 /******/ };
13677 /******/ })();
13678 /******/
13679 /******/ /* webpack/runtime/nonce */
13680 /******/ (() => {
13681 /******/ __webpack_require__.nc = undefined;
13682 /******/ })();
13683 /******/
13684 /************************************************************************/
13685 let __webpack_exports__ = {};
13686 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
13687 (() => {
13688 "use strict";
13689 /*!********************************************!*\
13690 !*** ./assets/src/js/admin/admin-order.js ***!
13691 \********************************************/
13692 __webpack_require__.r(__webpack_exports__);
13693 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
13694 /* harmony import */ var _order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./order/add-courses-to-order */ "./assets/src/js/admin/order/add-courses-to-order.js");
13695 /* harmony import */ var _order_refund_order__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./order/refund-order */ "./assets/src/js/admin/order/refund-order.js");
13696
13697
13698 //import modalSearchCourses from './order/modal-search-courses';
13699
13700
13701 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
13702 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
13703 (0,_order_refund_order__WEBPACK_IMPORTED_MODULE_2__["default"])();
13704 })();
13705
13706 /******/ })()
13707 ;
13708 //# sourceMappingURL=admin-order.js.map