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

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

13,570 lines 475.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/js/admin/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 */ getDataOfForm: () => (/* binding */ getDataOfForm),
991 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
992 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
993 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
994 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
995 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
996 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
997 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
998 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
999 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1000 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1001 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1002 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1003 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
1004 /* harmony export */ });
1005 /**
1006 * Utils functions
1007 *
1008 * @param url
1009 * @param data
1010 * @param functions
1011 * @since 4.2.5.1
1012 * @version 1.0.6
1013 */
1014 const lpClassName = {
1015 hidden: 'lp-hidden',
1016 loading: 'loading',
1017 elCollapse: 'lp-collapse',
1018 elSectionToggle: '.lp-section-toggle',
1019 elTriggerToggle: '.lp-trigger-toggle'
1020 };
1021 const lpFetchAPI = (url, data = {}, functions = {}) => {
1022 if ('function' === typeof functions.before) {
1023 functions.before();
1024 }
1025 fetch(url, {
1026 method: 'GET',
1027 ...data
1028 }).then(response => response.json()).then(response => {
1029 if ('function' === typeof functions.success) {
1030 functions.success(response);
1031 }
1032 }).catch(err => {
1033 if ('function' === typeof functions.error) {
1034 functions.error(err);
1035 }
1036 }).finally(() => {
1037 if ('function' === typeof functions.completed) {
1038 functions.completed();
1039 }
1040 });
1041 };
1042
1043 /**
1044 * Get current URL without params.
1045 *
1046 * @since 4.2.5.1
1047 */
1048 const lpGetCurrentURLNoParam = () => {
1049 let currentUrl = window.location.href;
1050 const hasParams = currentUrl.includes('?');
1051 if (hasParams) {
1052 currentUrl = currentUrl.split('?')[0];
1053 }
1054 return currentUrl;
1055 };
1056 const lpAddQueryArgs = (endpoint, args) => {
1057 const url = new URL(endpoint);
1058 Object.keys(args).forEach(arg => {
1059 url.searchParams.set(arg, args[arg]);
1060 });
1061 return url;
1062 };
1063
1064 /**
1065 * Listen element viewed.
1066 *
1067 * @param el
1068 * @param callback
1069 * @since 4.2.5.8
1070 */
1071 const listenElementViewed = (el, callback) => {
1072 const observerSeeItem = new IntersectionObserver(function (entries) {
1073 for (const entry of entries) {
1074 if (entry.isIntersecting) {
1075 callback(entry);
1076 }
1077 }
1078 });
1079 observerSeeItem.observe(el);
1080 };
1081
1082 /**
1083 * Listen element created.
1084 *
1085 * @param callback
1086 * @since 4.2.5.8
1087 */
1088 const listenElementCreated = callback => {
1089 const observerCreateItem = new MutationObserver(function (mutations) {
1090 mutations.forEach(function (mutation) {
1091 if (mutation.addedNodes) {
1092 mutation.addedNodes.forEach(function (node) {
1093 if (node.nodeType === 1) {
1094 callback(node);
1095 }
1096 });
1097 }
1098 });
1099 });
1100 observerCreateItem.observe(document, {
1101 childList: true,
1102 subtree: true
1103 });
1104 // End.
1105 };
1106
1107 /**
1108 * Listen element created.
1109 *
1110 * @param selector
1111 * @param callback
1112 * @since 4.2.7.1
1113 */
1114 const lpOnElementReady = (selector, callback) => {
1115 const element = document.querySelector(selector);
1116 if (element) {
1117 callback(element);
1118 return;
1119 }
1120 const observer = new MutationObserver((mutations, obs) => {
1121 const element = document.querySelector(selector);
1122 if (element) {
1123 obs.disconnect();
1124 callback(element);
1125 }
1126 });
1127 observer.observe(document.documentElement, {
1128 childList: true,
1129 subtree: true
1130 });
1131 };
1132
1133 // Parse JSON from string with content include LP_AJAX_START.
1134 const lpAjaxParseJsonOld = data => {
1135 if (typeof data !== 'string') {
1136 return data;
1137 }
1138 const m = String.raw({
1139 raw: data
1140 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1141 try {
1142 if (m) {
1143 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1144 } else {
1145 data = JSON.parse(data);
1146 }
1147 } catch (e) {
1148 data = {};
1149 }
1150 return data;
1151 };
1152
1153 // status 0: hide, 1: show
1154 const lpShowHideEl = (el, status = 0) => {
1155 if (!el) {
1156 return;
1157 }
1158 if (!status) {
1159 el.classList.add(lpClassName.hidden);
1160 } else {
1161 el.classList.remove(lpClassName.hidden);
1162 }
1163 };
1164
1165 // status 0: hide, 1: show
1166 const lpSetLoadingEl = (el, status) => {
1167 if (!el) {
1168 return;
1169 }
1170 if (!status) {
1171 el.classList.remove(lpClassName.loading);
1172 } else {
1173 el.classList.add(lpClassName.loading);
1174 }
1175 };
1176
1177 // Toggle collapse section
1178 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1179 if (!elTriggerClassName) {
1180 elTriggerClassName = lpClassName.elTriggerToggle;
1181 }
1182
1183 // Exclude elements, which should not trigger the collapse toggle
1184 if (elsExclude && elsExclude.length > 0) {
1185 for (const elExclude of elsExclude) {
1186 if (target.closest(elExclude)) {
1187 return;
1188 }
1189 }
1190 }
1191 const elTrigger = target.closest(elTriggerClassName);
1192 if (!elTrigger) {
1193 return;
1194 }
1195
1196 //console.log( 'elTrigger', elTrigger );
1197
1198 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1199 if (!elSectionToggle) {
1200 return;
1201 }
1202 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1203 if ('function' === typeof callback) {
1204 callback(elSectionToggle);
1205 }
1206 };
1207
1208 // Get data of form
1209 const getDataOfForm = form => {
1210 const dataSend = {};
1211 const formData = new FormData(form);
1212 for (const pair of formData.entries()) {
1213 const key = pair[0];
1214 const value = formData.getAll(key);
1215 if (!dataSend.hasOwnProperty(key)) {
1216 // Convert value array to string.
1217 dataSend[key] = value.join(',');
1218 }
1219 }
1220 return dataSend;
1221 };
1222
1223 // Get field keys of form
1224 const getFieldKeysOfForm = form => {
1225 const keys = [];
1226 const elements = form.elements;
1227 for (let i = 0; i < elements.length; i++) {
1228 const name = elements[i].name;
1229 if (name && !keys.includes(name)) {
1230 keys.push(name);
1231 }
1232 }
1233 return keys;
1234 };
1235
1236 // Merge data handle with data form.
1237 const mergeDataWithDatForm = (elForm, dataHandle) => {
1238 const dataForm = getDataOfForm(elForm);
1239 const keys = getFieldKeysOfForm(elForm);
1240 keys.forEach(key => {
1241 if (!dataForm.hasOwnProperty(key)) {
1242 delete dataHandle[key];
1243 } else if (dataForm[key][0] === '') {
1244 delete dataForm[key];
1245 delete dataHandle[key];
1246 }
1247 });
1248 dataHandle = {
1249 ...dataHandle,
1250 ...dataForm
1251 };
1252 return dataHandle;
1253 };
1254
1255 /**
1256 * Event trigger
1257 * For each list of event handlers, listen event on document.
1258 *
1259 * eventName: 'click', 'change', ...
1260 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1261 *
1262 * @param eventName
1263 * @param eventHandlers
1264 */
1265 const eventHandlers = (eventName, eventHandlers) => {
1266 document.addEventListener(eventName, e => {
1267 const target = e.target;
1268 let args = {
1269 e,
1270 target
1271 };
1272 eventHandlers.forEach(eventHandler => {
1273 args = {
1274 ...args,
1275 ...eventHandler
1276 };
1277
1278 //console.log( args );
1279
1280 // Check condition before call back
1281 if (eventHandler.conditionBeforeCallBack) {
1282 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1283 return;
1284 }
1285 }
1286
1287 // Special check for keydown event with checkIsEventEnter = true
1288 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1289 if (e.key !== 'Enter') {
1290 return;
1291 }
1292 }
1293 if (target.closest(eventHandler.selector)) {
1294 if (eventHandler.class) {
1295 // Call method of class, function callBack will understand exactly {this} is class object.
1296 eventHandler.class[eventHandler.callBack](args);
1297 } else {
1298 // For send args is objected, {this} is eventHandler object, not class object.
1299 eventHandler.callBack(args);
1300 }
1301 }
1302 });
1303 });
1304 };
1305
1306 /**
1307 * Debounce - delays function execution until after `wait` ms of inactivity.
1308 *
1309 * Each call resets the timer. Only the last call in a burst executes.
1310 *
1311 * USE CASES:
1312 * - Search inputs, form validation, window resize
1313 * - Multiple elements need independent timers
1314 * - When you need to call with different arguments
1315 *
1316 * EXAMPLES:
1317 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1318 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1319 *
1320 * const debouncedResize = debounce( recalculateLayout, 250 );
1321 * window.addEventListener('resize', debouncedResize);
1322 *
1323 * ⚠️ Create ONCE outside event handlers, not inside.
1324 *
1325 * @param {Function} func - Function to debounce (can be anonymous)
1326 * @param {number} wait - Milliseconds to wait (default: 500)
1327 * @return {Function} Debounced wrapper function
1328 * @since 4.3.7
1329 * @version 1.0.0
1330 */
1331 const debounce = (func, wait = 500) => {
1332 let timer;
1333 return args => {
1334 clearTimeout(timer);
1335 timer = setTimeout(() => func(args), wait);
1336 };
1337 };
1338
1339 /***/ },
1340
1341 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1342 /*!*****************************************************************************************!*\
1343 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1344 \*****************************************************************************************/
1345 (module, __webpack_exports__, __webpack_require__) {
1346
1347 "use strict";
1348 __webpack_require__.r(__webpack_exports__);
1349 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1350 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1351 /* harmony export */ });
1352 /* 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");
1353 /* 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__);
1354 /* 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");
1355 /* 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__);
1356 // Imports
1357
1358
1359 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()));
1360 // Module
1361 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1362 * Toastify js 1.12.0
1363 * https://github.com/apvarun/toastify-js
1364 * @license MIT licensed
1365 *
1366 * Copyright (C) 2018 Varun A P
1367 */
1368
1369 .toastify {
1370 padding: 12px 20px;
1371 color: #ffffff;
1372 display: inline-block;
1373 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1374 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1375 background: linear-gradient(135deg, #73a5ff, #5477f5);
1376 position: fixed;
1377 opacity: 0;
1378 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1379 border-radius: 2px;
1380 cursor: pointer;
1381 text-decoration: none;
1382 max-width: calc(50% - 20px);
1383 z-index: 2147483647;
1384 }
1385
1386 .toastify.on {
1387 opacity: 1;
1388 }
1389
1390 .toast-close {
1391 background: transparent;
1392 border: 0;
1393 color: white;
1394 cursor: pointer;
1395 font-family: inherit;
1396 font-size: 1em;
1397 opacity: 0.4;
1398 padding: 0 5px;
1399 }
1400
1401 .toastify-right {
1402 right: 15px;
1403 }
1404
1405 .toastify-left {
1406 left: 15px;
1407 }
1408
1409 .toastify-top {
1410 top: -150px;
1411 }
1412
1413 .toastify-bottom {
1414 bottom: -150px;
1415 }
1416
1417 .toastify-rounded {
1418 border-radius: 25px;
1419 }
1420
1421 .toastify-avatar {
1422 width: 1.5em;
1423 height: 1.5em;
1424 margin: -7px 5px;
1425 border-radius: 2px;
1426 }
1427
1428 .toastify-center {
1429 margin-left: auto;
1430 margin-right: auto;
1431 left: 0;
1432 right: 0;
1433 max-width: fit-content;
1434 max-width: -moz-fit-content;
1435 }
1436
1437 @media only screen and (max-width: 360px) {
1438 .toastify-right, .toastify-left {
1439 margin-left: auto;
1440 margin-right: auto;
1441 left: 0;
1442 right: 0;
1443 max-width: fit-content;
1444 }
1445 }
1446 `, "",{"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":""}]);
1447 // Exports
1448 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1449
1450
1451 /***/ },
1452
1453 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1454 /*!*****************************************************!*\
1455 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1456 \*****************************************************/
1457 (module) {
1458
1459 "use strict";
1460
1461
1462 /*
1463 MIT License http://www.opensource.org/licenses/mit-license.php
1464 Author Tobias Koppers @sokra
1465 */
1466 module.exports = function (cssWithMappingToString) {
1467 var list = [];
1468
1469 // return the list of modules as css string
1470 list.toString = function toString() {
1471 return this.map(function (item) {
1472 var content = "";
1473 var needLayer = typeof item[5] !== "undefined";
1474 if (item[4]) {
1475 content += "@supports (".concat(item[4], ") {");
1476 }
1477 if (item[2]) {
1478 content += "@media ".concat(item[2], " {");
1479 }
1480 if (needLayer) {
1481 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1482 }
1483 content += cssWithMappingToString(item);
1484 if (needLayer) {
1485 content += "}";
1486 }
1487 if (item[2]) {
1488 content += "}";
1489 }
1490 if (item[4]) {
1491 content += "}";
1492 }
1493 return content;
1494 }).join("");
1495 };
1496
1497 // import a list of modules into the list
1498 list.i = function i(modules, media, dedupe, supports, layer) {
1499 if (typeof modules === "string") {
1500 modules = [[null, modules, undefined]];
1501 }
1502 var alreadyImportedModules = {};
1503 if (dedupe) {
1504 for (var k = 0; k < this.length; k++) {
1505 var id = this[k][0];
1506 if (id != null) {
1507 alreadyImportedModules[id] = true;
1508 }
1509 }
1510 }
1511 for (var _k = 0; _k < modules.length; _k++) {
1512 var item = [].concat(modules[_k]);
1513 if (dedupe && alreadyImportedModules[item[0]]) {
1514 continue;
1515 }
1516 if (typeof layer !== "undefined") {
1517 if (typeof item[5] === "undefined") {
1518 item[5] = layer;
1519 } else {
1520 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1521 item[5] = layer;
1522 }
1523 }
1524 if (media) {
1525 if (!item[2]) {
1526 item[2] = media;
1527 } else {
1528 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1529 item[2] = media;
1530 }
1531 }
1532 if (supports) {
1533 if (!item[4]) {
1534 item[4] = "".concat(supports);
1535 } else {
1536 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1537 item[4] = supports;
1538 }
1539 }
1540 list.push(item);
1541 }
1542 };
1543 return list;
1544 };
1545
1546 /***/ },
1547
1548 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1549 /*!************************************************************!*\
1550 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1551 \************************************************************/
1552 (module) {
1553
1554 "use strict";
1555
1556
1557 module.exports = function (item) {
1558 var content = item[1];
1559 var cssMapping = item[3];
1560 if (!cssMapping) {
1561 return content;
1562 }
1563 if (typeof btoa === "function") {
1564 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1565 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1566 var sourceMapping = "/*# ".concat(data, " */");
1567 return [content].concat([sourceMapping]).join("\n");
1568 }
1569 return [content].join("\n");
1570 };
1571
1572 /***/ },
1573
1574 /***/ "./node_modules/toastify-js/src/toastify.css"
1575 /*!***************************************************!*\
1576 !*** ./node_modules/toastify-js/src/toastify.css ***!
1577 \***************************************************/
1578 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1579
1580 "use strict";
1581 __webpack_require__.r(__webpack_exports__);
1582 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1583 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1584 /* harmony export */ });
1585 /* 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");
1586 /* 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__);
1587 /* 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");
1588 /* 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__);
1589 /* 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");
1590 /* 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__);
1591 /* 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");
1592 /* 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__);
1593 /* 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");
1594 /* 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__);
1595 /* 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");
1596 /* 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__);
1597 /* 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");
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609 var options = {};
1610
1611 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1612 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1613
1614 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1615
1616 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1617 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1618
1619 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);
1620
1621
1622
1623
1624 /* 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);
1625
1626
1627 /***/ },
1628
1629 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1630 /*!****************************************************************************!*\
1631 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1632 \****************************************************************************/
1633 (module) {
1634
1635 "use strict";
1636
1637
1638 var stylesInDOM = [];
1639 function getIndexByIdentifier(identifier) {
1640 var result = -1;
1641 for (var i = 0; i < stylesInDOM.length; i++) {
1642 if (stylesInDOM[i].identifier === identifier) {
1643 result = i;
1644 break;
1645 }
1646 }
1647 return result;
1648 }
1649 function modulesToDom(list, options) {
1650 var idCountMap = {};
1651 var identifiers = [];
1652 for (var i = 0; i < list.length; i++) {
1653 var item = list[i];
1654 var id = options.base ? item[0] + options.base : item[0];
1655 var count = idCountMap[id] || 0;
1656 var identifier = "".concat(id, " ").concat(count);
1657 idCountMap[id] = count + 1;
1658 var indexByIdentifier = getIndexByIdentifier(identifier);
1659 var obj = {
1660 css: item[1],
1661 media: item[2],
1662 sourceMap: item[3],
1663 supports: item[4],
1664 layer: item[5]
1665 };
1666 if (indexByIdentifier !== -1) {
1667 stylesInDOM[indexByIdentifier].references++;
1668 stylesInDOM[indexByIdentifier].updater(obj);
1669 } else {
1670 var updater = addElementStyle(obj, options);
1671 options.byIndex = i;
1672 stylesInDOM.splice(i, 0, {
1673 identifier: identifier,
1674 updater: updater,
1675 references: 1
1676 });
1677 }
1678 identifiers.push(identifier);
1679 }
1680 return identifiers;
1681 }
1682 function addElementStyle(obj, options) {
1683 var api = options.domAPI(options);
1684 api.update(obj);
1685 var updater = function updater(newObj) {
1686 if (newObj) {
1687 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1688 return;
1689 }
1690 api.update(obj = newObj);
1691 } else {
1692 api.remove();
1693 }
1694 };
1695 return updater;
1696 }
1697 module.exports = function (list, options) {
1698 options = options || {};
1699 list = list || [];
1700 var lastIdentifiers = modulesToDom(list, options);
1701 return function update(newList) {
1702 newList = newList || [];
1703 for (var i = 0; i < lastIdentifiers.length; i++) {
1704 var identifier = lastIdentifiers[i];
1705 var index = getIndexByIdentifier(identifier);
1706 stylesInDOM[index].references--;
1707 }
1708 var newLastIdentifiers = modulesToDom(newList, options);
1709 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1710 var _identifier = lastIdentifiers[_i];
1711 var _index = getIndexByIdentifier(_identifier);
1712 if (stylesInDOM[_index].references === 0) {
1713 stylesInDOM[_index].updater();
1714 stylesInDOM.splice(_index, 1);
1715 }
1716 }
1717 lastIdentifiers = newLastIdentifiers;
1718 };
1719 };
1720
1721 /***/ },
1722
1723 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1724 /*!********************************************************************!*\
1725 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1726 \********************************************************************/
1727 (module) {
1728
1729 "use strict";
1730
1731
1732 var memo = {};
1733
1734 /* istanbul ignore next */
1735 function getTarget(target) {
1736 if (typeof memo[target] === "undefined") {
1737 var styleTarget = document.querySelector(target);
1738
1739 // Special case to return head of iframe instead of iframe itself
1740 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1741 try {
1742 // This will throw an exception if access to iframe is blocked
1743 // due to cross-origin restrictions
1744 styleTarget = styleTarget.contentDocument.head;
1745 } catch (e) {
1746 // istanbul ignore next
1747 styleTarget = null;
1748 }
1749 }
1750 memo[target] = styleTarget;
1751 }
1752 return memo[target];
1753 }
1754
1755 /* istanbul ignore next */
1756 function insertBySelector(insert, style) {
1757 var target = getTarget(insert);
1758 if (!target) {
1759 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1760 }
1761 target.appendChild(style);
1762 }
1763 module.exports = insertBySelector;
1764
1765 /***/ },
1766
1767 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1768 /*!**********************************************************************!*\
1769 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1770 \**********************************************************************/
1771 (module) {
1772
1773 "use strict";
1774
1775
1776 /* istanbul ignore next */
1777 function insertStyleElement(options) {
1778 var element = document.createElement("style");
1779 options.setAttributes(element, options.attributes);
1780 options.insert(element, options.options);
1781 return element;
1782 }
1783 module.exports = insertStyleElement;
1784
1785 /***/ },
1786
1787 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1788 /*!**********************************************************************************!*\
1789 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1790 \**********************************************************************************/
1791 (module, __unused_webpack_exports, __webpack_require__) {
1792
1793 "use strict";
1794
1795
1796 /* istanbul ignore next */
1797 function setAttributesWithoutAttributes(styleElement) {
1798 var nonce = true ? __webpack_require__.nc : 0;
1799 if (nonce) {
1800 styleElement.setAttribute("nonce", nonce);
1801 }
1802 }
1803 module.exports = setAttributesWithoutAttributes;
1804
1805 /***/ },
1806
1807 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1808 /*!***************************************************************!*\
1809 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1810 \***************************************************************/
1811 (module) {
1812
1813 "use strict";
1814
1815
1816 /* istanbul ignore next */
1817 function apply(styleElement, options, obj) {
1818 var css = "";
1819 if (obj.supports) {
1820 css += "@supports (".concat(obj.supports, ") {");
1821 }
1822 if (obj.media) {
1823 css += "@media ".concat(obj.media, " {");
1824 }
1825 var needLayer = typeof obj.layer !== "undefined";
1826 if (needLayer) {
1827 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1828 }
1829 css += obj.css;
1830 if (needLayer) {
1831 css += "}";
1832 }
1833 if (obj.media) {
1834 css += "}";
1835 }
1836 if (obj.supports) {
1837 css += "}";
1838 }
1839 var sourceMap = obj.sourceMap;
1840 if (sourceMap && typeof btoa !== "undefined") {
1841 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1842 }
1843
1844 // For old IE
1845 /* istanbul ignore if */
1846 options.styleTagTransform(css, styleElement, options.options);
1847 }
1848 function removeStyleElement(styleElement) {
1849 // istanbul ignore if
1850 if (styleElement.parentNode === null) {
1851 return false;
1852 }
1853 styleElement.parentNode.removeChild(styleElement);
1854 }
1855
1856 /* istanbul ignore next */
1857 function domAPI(options) {
1858 if (typeof document === "undefined") {
1859 return {
1860 update: function update() {},
1861 remove: function remove() {}
1862 };
1863 }
1864 var styleElement = options.insertStyleElement(options);
1865 return {
1866 update: function update(obj) {
1867 apply(styleElement, options, obj);
1868 },
1869 remove: function remove() {
1870 removeStyleElement(styleElement);
1871 }
1872 };
1873 }
1874 module.exports = domAPI;
1875
1876 /***/ },
1877
1878 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
1879 /*!*********************************************************************!*\
1880 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
1881 \*********************************************************************/
1882 (module) {
1883
1884 "use strict";
1885
1886
1887 /* istanbul ignore next */
1888 function styleTagTransform(css, styleElement) {
1889 if (styleElement.styleSheet) {
1890 styleElement.styleSheet.cssText = css;
1891 } else {
1892 while (styleElement.firstChild) {
1893 styleElement.removeChild(styleElement.firstChild);
1894 }
1895 styleElement.appendChild(document.createTextNode(css));
1896 }
1897 }
1898 module.exports = styleTagTransform;
1899
1900 /***/ },
1901
1902 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
1903 /*!**********************************************************!*\
1904 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
1905 \**********************************************************/
1906 (module) {
1907
1908 /*!
1909 * sweetalert2 v11.26.25
1910 * Released under the MIT License.
1911 */
1912 (function (global, factory) {
1913 true ? module.exports = factory() :
1914 0;
1915 })(this, (function () { 'use strict';
1916
1917 function _assertClassBrand(e, t, n) {
1918 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
1919 throw new TypeError("Private element is not present on this object");
1920 }
1921 function _checkPrivateRedeclaration(e, t) {
1922 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
1923 }
1924 function _classPrivateFieldGet2(s, a) {
1925 return s.get(_assertClassBrand(s, a));
1926 }
1927 function _classPrivateFieldInitSpec(e, t, a) {
1928 _checkPrivateRedeclaration(e, t), t.set(e, a);
1929 }
1930 function _classPrivateFieldSet2(s, a, r) {
1931 return s.set(_assertClassBrand(s, a), r), r;
1932 }
1933
1934 const RESTORE_FOCUS_TIMEOUT = 100;
1935
1936 /** @type {GlobalState} */
1937 const globalState = {};
1938 const focusPreviousActiveElement = () => {
1939 if (globalState.previousActiveElement instanceof HTMLElement) {
1940 globalState.previousActiveElement.focus();
1941 globalState.previousActiveElement = null;
1942 } else if (document.body) {
1943 document.body.focus();
1944 }
1945 };
1946
1947 /**
1948 * Restore previous active (focused) element
1949 *
1950 * @param {boolean} returnFocus
1951 * @returns {Promise<void>}
1952 */
1953 const restoreActiveElement = returnFocus => {
1954 return new Promise(resolve => {
1955 if (!returnFocus) {
1956 return resolve();
1957 }
1958 const x = window.scrollX;
1959 const y = window.scrollY;
1960 globalState.restoreFocusTimeout = setTimeout(() => {
1961 focusPreviousActiveElement();
1962 resolve();
1963 }, RESTORE_FOCUS_TIMEOUT); // issues/900
1964
1965 window.scrollTo(x, y);
1966 });
1967 };
1968
1969 const swalPrefix = 'swal2-';
1970
1971 /**
1972 * @typedef {Record<SwalClass, string>} SwalClasses
1973 */
1974
1975 /**
1976 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
1977 * @typedef {Record<SwalIcon, string>} SwalIcons
1978 */
1979
1980 /** @type {SwalClass[]} */
1981 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'];
1982 const swalClasses = classNames.reduce((acc, className) => {
1983 acc[className] = swalPrefix + className;
1984 return acc;
1985 }, /** @type {SwalClasses} */{});
1986
1987 /** @type {SwalIcon[]} */
1988 const icons = ['success', 'warning', 'info', 'question', 'error'];
1989 const iconTypes = icons.reduce((acc, icon) => {
1990 acc[icon] = swalPrefix + icon;
1991 return acc;
1992 }, /** @type {SwalIcons} */{});
1993
1994 const consolePrefix = 'SweetAlert2:';
1995
1996 /**
1997 * Capitalize the first letter of a string
1998 *
1999 * @param {string} str
2000 * @returns {string}
2001 */
2002 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2003
2004 /**
2005 * Standardize console warnings
2006 *
2007 * @param {string | string[]} message
2008 */
2009 const warn = message => {
2010 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2011 };
2012
2013 /**
2014 * Standardize console errors
2015 *
2016 * @param {string} message
2017 */
2018 const error = message => {
2019 console.error(`${consolePrefix} ${message}`);
2020 };
2021
2022 /**
2023 * Private global state for `warnOnce`
2024 *
2025 * @type {string[]}
2026 * @private
2027 */
2028 const previousWarnOnceMessages = [];
2029
2030 /**
2031 * Show a console warning, but only if it hasn't already been shown
2032 *
2033 * @param {string} message
2034 */
2035 const warnOnce = message => {
2036 if (!previousWarnOnceMessages.includes(message)) {
2037 previousWarnOnceMessages.push(message);
2038 warn(message);
2039 }
2040 };
2041
2042 /**
2043 * Show a one-time console warning about deprecated params/methods
2044 *
2045 * @param {string} deprecatedParam
2046 * @param {string?} useInstead
2047 */
2048 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2049 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2050 };
2051
2052 /**
2053 * If `arg` is a function, call it (with no arguments or context) and return the result.
2054 * Otherwise, just pass the value through
2055 *
2056 * @param {(() => *) | *} arg
2057 * @returns {*}
2058 */
2059 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2060
2061 /**
2062 * @param {*} arg
2063 * @returns {boolean}
2064 */
2065 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2066
2067 /**
2068 * @param {*} arg
2069 * @returns {Promise<*>}
2070 */
2071 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2072
2073 /**
2074 * @param {*} arg
2075 * @returns {boolean}
2076 */
2077 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2078
2079 /**
2080 * @returns {boolean}
2081 */
2082 const isFirefox = () => navigator.userAgent.includes('Firefox');
2083
2084 /**
2085 * Gets the popup container which contains the backdrop and the popup itself.
2086 *
2087 * @returns {HTMLElement | null}
2088 */
2089 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2090
2091 /**
2092 * @param {string} selectorString
2093 * @returns {HTMLElement | null}
2094 */
2095 const elementBySelector = selectorString => {
2096 const container = getContainer();
2097 return container ? container.querySelector(selectorString) : null;
2098 };
2099
2100 /**
2101 * @param {string} className
2102 * @returns {HTMLElement | null}
2103 */
2104 const elementByClass = className => {
2105 return elementBySelector(`.${className}`);
2106 };
2107
2108 /**
2109 * @returns {HTMLElement | null}
2110 */
2111 const getPopup = () => elementByClass(swalClasses.popup);
2112
2113 /**
2114 * @returns {HTMLElement | null}
2115 */
2116 const getIcon = () => elementByClass(swalClasses.icon);
2117
2118 /**
2119 * @returns {HTMLElement | null}
2120 */
2121 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2122
2123 /**
2124 * @returns {HTMLElement | null}
2125 */
2126 const getTitle = () => elementByClass(swalClasses.title);
2127
2128 /**
2129 * @returns {HTMLElement | null}
2130 */
2131 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2132
2133 /**
2134 * @returns {HTMLElement | null}
2135 */
2136 const getImage = () => elementByClass(swalClasses.image);
2137
2138 /**
2139 * @returns {HTMLElement | null}
2140 */
2141 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2142
2143 /**
2144 * @returns {HTMLElement | null}
2145 */
2146 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2147
2148 /**
2149 * @returns {HTMLButtonElement | null}
2150 */
2151 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2152
2153 /**
2154 * @returns {HTMLButtonElement | null}
2155 */
2156 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2157
2158 /**
2159 * @returns {HTMLButtonElement | null}
2160 */
2161 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2162
2163 /**
2164 * @returns {HTMLElement | null}
2165 */
2166 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2167
2168 /**
2169 * @returns {HTMLElement | null}
2170 */
2171 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2172
2173 /**
2174 * @returns {HTMLElement | null}
2175 */
2176 const getActions = () => elementByClass(swalClasses.actions);
2177
2178 /**
2179 * @returns {HTMLElement | null}
2180 */
2181 const getFooter = () => elementByClass(swalClasses.footer);
2182
2183 /**
2184 * @returns {HTMLElement | null}
2185 */
2186 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2187
2188 /**
2189 * @returns {HTMLElement | null}
2190 */
2191 const getCloseButton = () => elementByClass(swalClasses.close);
2192
2193 // https://github.com/jkup/focusable/blob/master/index.js
2194 const focusable = `
2195 a[href],
2196 area[href],
2197 input:not([disabled]),
2198 select:not([disabled]),
2199 textarea:not([disabled]),
2200 button:not([disabled]),
2201 iframe,
2202 object,
2203 embed,
2204 [tabindex="0"],
2205 [contenteditable],
2206 audio[controls],
2207 video[controls],
2208 summary
2209 `;
2210 /**
2211 * @returns {HTMLElement[]}
2212 */
2213 const getFocusableElements = () => {
2214 const popup = getPopup();
2215 if (!popup) {
2216 return [];
2217 }
2218 /** @type {NodeListOf<HTMLElement>} */
2219 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2220 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2221 // sort according to tabindex
2222 .sort((a, b) => {
2223 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2224 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2225 if (tabindexA > tabindexB) {
2226 return 1;
2227 } else if (tabindexA < tabindexB) {
2228 return -1;
2229 }
2230 return 0;
2231 });
2232
2233 /** @type {NodeListOf<HTMLElement>} */
2234 const otherFocusableElements = popup.querySelectorAll(focusable);
2235 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2236 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2237 };
2238
2239 /**
2240 * @returns {boolean}
2241 */
2242 const isModal = () => {
2243 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2244 };
2245
2246 /**
2247 * @returns {boolean}
2248 */
2249 const isToast = () => {
2250 const popup = getPopup();
2251 if (!popup) {
2252 return false;
2253 }
2254 return hasClass(popup, swalClasses.toast);
2255 };
2256
2257 /**
2258 * @returns {boolean}
2259 */
2260 const isLoading = () => {
2261 const popup = getPopup();
2262 if (!popup) {
2263 return false;
2264 }
2265 return popup.hasAttribute('data-loading');
2266 };
2267
2268 /**
2269 * Securely set innerHTML of an element
2270 * https://github.com/sweetalert2/sweetalert2/issues/1926
2271 *
2272 * @param {HTMLElement} elem
2273 * @param {string} html
2274 */
2275 const setInnerHtml = (elem, html) => {
2276 elem.textContent = '';
2277 if (html) {
2278 const parser = new DOMParser();
2279 const parsed = parser.parseFromString(html, `text/html`);
2280 const head = parsed.querySelector('head');
2281 if (head) {
2282 Array.from(head.childNodes).forEach(child => {
2283 elem.appendChild(child);
2284 });
2285 }
2286 const body = parsed.querySelector('body');
2287 if (body) {
2288 Array.from(body.childNodes).forEach(child => {
2289 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2290 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2291 } else {
2292 elem.appendChild(child);
2293 }
2294 });
2295 }
2296 }
2297 };
2298
2299 /**
2300 * @param {HTMLElement} elem
2301 * @param {string} className
2302 * @returns {boolean}
2303 */
2304 const hasClass = (elem, className) => {
2305 if (!className) {
2306 return false;
2307 }
2308 return className.split(/\s+/).every(cls => elem.classList.contains(cls));
2309 };
2310
2311 /**
2312 * @param {HTMLElement} elem
2313 * @param {SweetAlertOptions} params
2314 */
2315 const removeCustomClasses = (elem, params) => {
2316 Array.from(elem.classList).forEach(className => {
2317 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2318 elem.classList.remove(className);
2319 }
2320 });
2321 };
2322
2323 /**
2324 * @param {HTMLElement} elem
2325 * @param {SweetAlertOptions} params
2326 * @param {string} className
2327 */
2328 const applyCustomClass = (elem, params, className) => {
2329 removeCustomClasses(elem, params);
2330 if (!params.customClass) {
2331 return;
2332 }
2333 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2334 if (!customClass) {
2335 return;
2336 }
2337 if (typeof customClass !== 'string' && !customClass.forEach) {
2338 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2339 return;
2340 }
2341 addClass(elem, customClass);
2342 };
2343
2344 /**
2345 * @param {HTMLElement} popup
2346 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2347 * @returns {HTMLInputElement | null}
2348 */
2349 const getInput$1 = (popup, inputClass) => {
2350 if (!inputClass) {
2351 return null;
2352 }
2353 switch (inputClass) {
2354 case 'select':
2355 case 'textarea':
2356 case 'file':
2357 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2358 case 'checkbox':
2359 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2360 case 'radio':
2361 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2362 case 'range':
2363 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2364 default:
2365 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2366 }
2367 };
2368
2369 /**
2370 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2371 */
2372 const focusInput = input => {
2373 input.focus();
2374
2375 // place cursor at end of text in text input
2376 if (input.type !== 'file') {
2377 // http://stackoverflow.com/a/2345915
2378 const val = input.value;
2379 input.value = '';
2380 input.value = val;
2381 }
2382 };
2383
2384 /**
2385 * @param {HTMLElement | HTMLElement[] | null} target
2386 * @param {string | string[] | readonly string[] | undefined} classList
2387 * @param {boolean} condition
2388 */
2389 const toggleClass = (target, classList, condition) => {
2390 if (!target || !classList) {
2391 return;
2392 }
2393 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
2394 const targets = Array.isArray(target) ? target : [target];
2395 targets.forEach(elem => {
2396 classes.forEach(className => {
2397 if (condition) {
2398 elem.classList.add(className);
2399 } else {
2400 elem.classList.remove(className);
2401 }
2402 });
2403 });
2404 };
2405
2406 /**
2407 * @param {HTMLElement | HTMLElement[] | null} target
2408 * @param {string | string[] | readonly string[] | undefined} classList
2409 */
2410 const addClass = (target, classList) => {
2411 toggleClass(target, classList, true);
2412 };
2413
2414 /**
2415 * @param {HTMLElement | HTMLElement[] | null} target
2416 * @param {string | string[] | readonly string[] | undefined} classList
2417 */
2418 const removeClass = (target, classList) => {
2419 toggleClass(target, classList, false);
2420 };
2421
2422 /**
2423 * Get direct child of an element by class name
2424 *
2425 * @param {HTMLElement} elem
2426 * @param {string} className
2427 * @returns {HTMLElement | undefined}
2428 */
2429 const getDirectChildByClass = (elem, className) => (/** @type {HTMLElement | undefined} */
2430 Array.from(elem.children).find(child => child instanceof HTMLElement && hasClass(child, className)));
2431
2432 /**
2433 * @param {HTMLElement} elem
2434 * @param {string} property
2435 * @param {string | number | null | undefined} value
2436 */
2437 const applyNumericalStyle = (elem, property, value) => {
2438 if (value === `${parseInt(`${value}`)}`) {
2439 value = parseInt(value);
2440 }
2441 if (value || value === 0) {
2442 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2443 } else {
2444 elem.style.removeProperty(property);
2445 }
2446 };
2447
2448 /**
2449 * @param {HTMLElement | null} elem
2450 * @param {string} display
2451 */
2452 const show = (elem, display = 'flex') => {
2453 if (!elem) {
2454 return;
2455 }
2456 elem.style.display = display;
2457 };
2458
2459 /**
2460 * @param {HTMLElement | null} elem
2461 */
2462 const hide = elem => {
2463 if (!elem) {
2464 return;
2465 }
2466 elem.style.display = 'none';
2467 };
2468
2469 /**
2470 * @param {HTMLElement | null} elem
2471 * @param {string} display
2472 */
2473 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2474 if (!elem) {
2475 return;
2476 }
2477 new MutationObserver(() => {
2478 toggle(elem, elem.innerHTML, display);
2479 }).observe(elem, {
2480 childList: true,
2481 subtree: true
2482 });
2483 };
2484
2485 /**
2486 * @param {HTMLElement} parent
2487 * @param {string} selector
2488 * @param {string} property
2489 * @param {string} value
2490 */
2491 const setStyle = (parent, selector, property, value) => {
2492 /** @type {HTMLElement | null} */
2493 const el = parent.querySelector(selector);
2494 if (el) {
2495 el.style.setProperty(property, value);
2496 }
2497 };
2498
2499 /**
2500 * @param {HTMLElement} elem
2501 * @param {boolean | string | null | undefined} condition
2502 * @param {string} display
2503 */
2504 const toggle = (elem, condition, display = 'flex') => {
2505 if (condition) {
2506 show(elem, display);
2507 } else {
2508 hide(elem);
2509 }
2510 };
2511
2512 /**
2513 * borrowed from jquery $(elem).is(':visible') implementation
2514 *
2515 * @param {HTMLElement | null} elem
2516 * @returns {boolean}
2517 */
2518 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2519
2520 /**
2521 * @returns {boolean}
2522 */
2523 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2524
2525 /**
2526 * @param {HTMLElement} elem
2527 * @returns {boolean}
2528 */
2529 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2530
2531 /**
2532 * @param {HTMLElement} element
2533 * @param {HTMLElement} stopElement
2534 * @returns {boolean}
2535 */
2536 const selfOrParentIsScrollable = (element, stopElement) => {
2537 let parent = /** @type {HTMLElement | null} */element;
2538 while (parent && parent !== stopElement) {
2539 if (isScrollable(parent)) {
2540 return true;
2541 }
2542 parent = parent.parentElement;
2543 }
2544 return false;
2545 };
2546
2547 /**
2548 * borrowed from https://stackoverflow.com/a/46352119
2549 *
2550 * @param {HTMLElement} elem
2551 * @returns {boolean}
2552 */
2553 const hasCssAnimation = elem => {
2554 const style = window.getComputedStyle(elem);
2555 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2556 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2557 return animDuration > 0 || transDuration > 0;
2558 };
2559
2560 /**
2561 * @param {number} timer
2562 * @param {boolean} reset
2563 */
2564 const animateTimerProgressBar = (timer, reset = false) => {
2565 const timerProgressBar = getTimerProgressBar();
2566 if (!timerProgressBar) {
2567 return;
2568 }
2569 if (isVisible$1(timerProgressBar)) {
2570 if (reset) {
2571 timerProgressBar.style.transition = 'none';
2572 timerProgressBar.style.width = '100%';
2573 }
2574 setTimeout(() => {
2575 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2576 timerProgressBar.style.width = '0%';
2577 }, 10);
2578 }
2579 };
2580 const stopTimerProgressBar = () => {
2581 const timerProgressBar = getTimerProgressBar();
2582 if (!timerProgressBar) {
2583 return;
2584 }
2585 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2586 timerProgressBar.style.removeProperty('transition');
2587 timerProgressBar.style.width = '100%';
2588 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2589 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2590 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2591 };
2592
2593 /**
2594 * Detect Node env
2595 *
2596 * @returns {boolean}
2597 */
2598 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2599
2600 const sweetHTML = `
2601 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2602 <button type="button" class="${swalClasses.close}"></button>
2603 <ul class="${swalClasses['progress-steps']}"></ul>
2604 <div class="${swalClasses.icon}"></div>
2605 <img class="${swalClasses.image}" />
2606 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2607 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2608 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2609 <input type="file" class="${swalClasses.file}" />
2610 <div class="${swalClasses.range}">
2611 <input type="range" />
2612 <output></output>
2613 </div>
2614 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2615 <div class="${swalClasses.radio}"></div>
2616 <label class="${swalClasses.checkbox}">
2617 <input type="checkbox" id="${swalClasses.checkbox}" />
2618 <span class="${swalClasses.label}"></span>
2619 </label>
2620 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2621 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2622 <div class="${swalClasses.actions}">
2623 <div class="${swalClasses.loader}"></div>
2624 <button type="button" class="${swalClasses.confirm}"></button>
2625 <button type="button" class="${swalClasses.deny}"></button>
2626 <button type="button" class="${swalClasses.cancel}"></button>
2627 </div>
2628 <div class="${swalClasses.footer}"></div>
2629 <div class="${swalClasses['timer-progress-bar-container']}">
2630 <div class="${swalClasses['timer-progress-bar']}"></div>
2631 </div>
2632 </div>
2633 `.replace(/(^|\n)\s*/g, '');
2634
2635 /**
2636 * @returns {boolean}
2637 */
2638 const resetOldContainer = () => {
2639 const oldContainer = getContainer();
2640 if (!oldContainer) {
2641 return false;
2642 }
2643 oldContainer.remove();
2644 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2645 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2646 swalClasses['has-column']]);
2647 return true;
2648 };
2649 const resetValidationMessage$1 = () => {
2650 if (globalState.currentInstance) {
2651 globalState.currentInstance.resetValidationMessage();
2652 }
2653 };
2654 const addInputChangeListeners = () => {
2655 const popup = getPopup();
2656 if (!popup) {
2657 return;
2658 }
2659 const input = getDirectChildByClass(popup, swalClasses.input);
2660 const file = getDirectChildByClass(popup, swalClasses.file);
2661 /** @type {HTMLInputElement | null} */
2662 const range = popup.querySelector(`.${swalClasses.range} input`);
2663 /** @type {HTMLOutputElement | null} */
2664 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2665 const select = getDirectChildByClass(popup, swalClasses.select);
2666 /** @type {HTMLInputElement | null} */
2667 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2668 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2669 if (input) {
2670 input.oninput = resetValidationMessage$1;
2671 }
2672 if (file) {
2673 file.onchange = resetValidationMessage$1;
2674 }
2675 if (select) {
2676 select.onchange = resetValidationMessage$1;
2677 }
2678 if (checkbox) {
2679 checkbox.onchange = resetValidationMessage$1;
2680 }
2681 if (textarea) {
2682 textarea.oninput = resetValidationMessage$1;
2683 }
2684 if (range && rangeOutput) {
2685 range.oninput = () => {
2686 resetValidationMessage$1();
2687 rangeOutput.value = range.value;
2688 };
2689 range.onchange = () => {
2690 resetValidationMessage$1();
2691 rangeOutput.value = range.value;
2692 };
2693 }
2694 };
2695
2696 /**
2697 * @param {string | HTMLElement} target
2698 * @returns {HTMLElement}
2699 */
2700 const getTarget = target => {
2701 if (typeof target === 'string') {
2702 const element = document.querySelector(target);
2703 if (!element) {
2704 throw new Error(`Target element "${target}" not found`);
2705 }
2706 return /** @type {HTMLElement} */element;
2707 }
2708 return target;
2709 };
2710
2711 /**
2712 * @param {SweetAlertOptions} params
2713 */
2714 const setupAccessibility = params => {
2715 const popup = getPopup();
2716 if (!popup) {
2717 return;
2718 }
2719 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2720 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2721 if (!params.toast) {
2722 popup.setAttribute('aria-modal', 'true');
2723 }
2724 };
2725
2726 /**
2727 * @param {HTMLElement} targetElement
2728 */
2729 const setupRTL = targetElement => {
2730 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2731 addClass(getContainer(), swalClasses.rtl);
2732 globalState.isRTL = true;
2733 }
2734 };
2735
2736 /**
2737 * Add modal + backdrop to DOM
2738 *
2739 * @param {SweetAlertOptions} params
2740 */
2741 const init = params => {
2742 // Clean up the old popup container if it exists
2743 const oldContainerExisted = resetOldContainer();
2744 if (isNodeEnv()) {
2745 error('SweetAlert2 requires document to initialize');
2746 return;
2747 }
2748 const container = document.createElement('div');
2749 container.className = swalClasses.container;
2750 if (oldContainerExisted) {
2751 addClass(container, swalClasses['no-transition']);
2752 }
2753 setInnerHtml(container, sweetHTML);
2754 container.dataset['swal2Theme'] = params.theme;
2755 const targetElement = getTarget(params.target || 'body');
2756 targetElement.appendChild(container);
2757 if (params.topLayer) {
2758 container.setAttribute('popover', '');
2759 container.showPopover();
2760 }
2761 setupAccessibility(params);
2762 setupRTL(targetElement);
2763 addInputChangeListeners();
2764 };
2765
2766 /**
2767 * @param {HTMLElement | object | string} param
2768 * @param {HTMLElement} target
2769 */
2770 const parseHtmlToContainer = (param, target) => {
2771 // DOM element
2772 if (param instanceof HTMLElement) {
2773 target.appendChild(param);
2774 }
2775
2776 // Object
2777 else if (typeof param === 'object') {
2778 handleObject(param, target);
2779 }
2780
2781 // Plain string
2782 else if (param) {
2783 setInnerHtml(target, param);
2784 }
2785 };
2786
2787 /**
2788 * @param {object} param
2789 * @param {HTMLElement} target
2790 */
2791 const handleObject = (param, target) => {
2792 // JQuery element(s)
2793 if ('jquery' in param) {
2794 handleJqueryElem(target, param);
2795 }
2796
2797 // For other objects use their string representation
2798 else {
2799 setInnerHtml(target, param.toString());
2800 }
2801 };
2802
2803 /**
2804 * @param {HTMLElement} target
2805 * @param {any} elem
2806 */
2807 const handleJqueryElem = (target, elem) => {
2808 target.textContent = '';
2809 if (0 in elem) {
2810 for (let i = 0; i in elem; i++) {
2811 target.appendChild(elem[i].cloneNode(true));
2812 }
2813 } else {
2814 target.appendChild(elem.cloneNode(true));
2815 }
2816 };
2817
2818 /**
2819 * @param {SweetAlert} instance
2820 * @param {SweetAlertOptions} params
2821 */
2822 const renderActions = (instance, params) => {
2823 const actions = getActions();
2824 const loader = getLoader();
2825 if (!actions || !loader) {
2826 return;
2827 }
2828
2829 // Actions (buttons) wrapper
2830 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2831 hide(actions);
2832 } else {
2833 show(actions);
2834 }
2835
2836 // Custom class
2837 applyCustomClass(actions, params, 'actions');
2838
2839 // Render all the buttons
2840 renderButtons(actions, loader, params);
2841
2842 // Loader
2843 setInnerHtml(loader, params.loaderHtml || '');
2844 applyCustomClass(loader, params, 'loader');
2845 };
2846
2847 /**
2848 * @param {HTMLElement} actions
2849 * @param {HTMLElement} loader
2850 * @param {SweetAlertOptions} params
2851 */
2852 function renderButtons(actions, loader, params) {
2853 const confirmButton = getConfirmButton();
2854 const denyButton = getDenyButton();
2855 const cancelButton = getCancelButton();
2856 if (!confirmButton || !denyButton || !cancelButton) {
2857 return;
2858 }
2859
2860 // Render buttons
2861 renderButton(confirmButton, 'confirm', params);
2862 renderButton(denyButton, 'deny', params);
2863 renderButton(cancelButton, 'cancel', params);
2864 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
2865 if (params.reverseButtons) {
2866 if (params.toast) {
2867 actions.insertBefore(cancelButton, confirmButton);
2868 actions.insertBefore(denyButton, confirmButton);
2869 } else {
2870 actions.insertBefore(cancelButton, loader);
2871 actions.insertBefore(denyButton, loader);
2872 actions.insertBefore(confirmButton, loader);
2873 }
2874 }
2875 }
2876
2877 /**
2878 * @param {HTMLElement} confirmButton
2879 * @param {HTMLElement} denyButton
2880 * @param {HTMLElement} cancelButton
2881 * @param {SweetAlertOptions} params
2882 */
2883 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
2884 if (!params.buttonsStyling) {
2885 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2886 return;
2887 }
2888 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
2889
2890 // Apply custom background colors and outline colors to action buttons
2891 /** @type {[HTMLElement, string, string | undefined][]} */
2892 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
2893 buttons.forEach(([button, type, color]) => {
2894 if (color) {
2895 button.style.setProperty(`--swal2-${type}-button-background-color`, color);
2896 }
2897 applyOutlineColor(button);
2898 });
2899 }
2900
2901 /**
2902 * @param {HTMLElement} button
2903 */
2904 function applyOutlineColor(button) {
2905 const buttonStyle = window.getComputedStyle(button);
2906 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
2907 // If the button already has a custom outline color, no need to change it
2908 return;
2909 }
2910 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
2911 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
2912 }
2913
2914 /**
2915 * @param {HTMLElement} button
2916 * @param {'confirm' | 'deny' | 'cancel'} buttonType
2917 * @param {SweetAlertOptions} params
2918 */
2919 function renderButton(button, buttonType, params) {
2920 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
2921 toggle(button, params[`show${buttonName}Button`], 'inline-block');
2922 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
2923 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
2924
2925 // Add buttons custom classes
2926 button.className = swalClasses[buttonType];
2927 applyCustomClass(button, params, `${buttonType}Button`);
2928 }
2929
2930 /**
2931 * @param {SweetAlert} instance
2932 * @param {SweetAlertOptions} params
2933 */
2934 const renderCloseButton = (instance, params) => {
2935 const closeButton = getCloseButton();
2936 if (!closeButton) {
2937 return;
2938 }
2939 setInnerHtml(closeButton, params.closeButtonHtml || '');
2940
2941 // Custom class
2942 applyCustomClass(closeButton, params, 'closeButton');
2943 toggle(closeButton, params.showCloseButton);
2944 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
2945 };
2946
2947 /**
2948 * @param {SweetAlert} instance
2949 * @param {SweetAlertOptions} params
2950 */
2951 const renderContainer = (instance, params) => {
2952 const container = getContainer();
2953 if (!container) {
2954 return;
2955 }
2956 handleBackdropParam(container, params.backdrop);
2957 handlePositionParam(container, params.position);
2958 handleGrowParam(container, params.grow);
2959
2960 // Custom class
2961 applyCustomClass(container, params, 'container');
2962 };
2963
2964 /**
2965 * @param {HTMLElement} container
2966 * @param {SweetAlertOptions['backdrop']} backdrop
2967 */
2968 function handleBackdropParam(container, backdrop) {
2969 if (typeof backdrop === 'string') {
2970 container.style.background = backdrop;
2971 } else if (!backdrop) {
2972 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
2973 }
2974 }
2975
2976 /**
2977 * @param {HTMLElement} container
2978 * @param {SweetAlertOptions['position']} position
2979 */
2980 function handlePositionParam(container, position) {
2981 if (!position) {
2982 return;
2983 }
2984 if (position in swalClasses) {
2985 addClass(container, swalClasses[position]);
2986 } else {
2987 warn('The "position" parameter is not valid, defaulting to "center"');
2988 addClass(container, swalClasses.center);
2989 }
2990 }
2991
2992 /**
2993 * @param {HTMLElement} container
2994 * @param {SweetAlertOptions['grow']} grow
2995 */
2996 function handleGrowParam(container, grow) {
2997 if (!grow) {
2998 return;
2999 }
3000 addClass(container, swalClasses[`grow-${grow}`]);
3001 }
3002
3003 /**
3004 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3005 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3006 * This is the approach that Babel will probably take to implement private methods/fields
3007 * https://github.com/tc39/proposal-private-methods
3008 * https://github.com/babel/babel/pull/7555
3009 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3010 * then we can use that language feature.
3011 */
3012
3013 var privateProps = {
3014 innerParams: new WeakMap(),
3015 domCache: new WeakMap(),
3016 focusedElement: new WeakMap()
3017 };
3018
3019 /// <reference path="../../../../sweetalert2.d.ts"/>
3020
3021
3022 /** @type {InputClass[]} */
3023 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3024
3025 /**
3026 * @param {SweetAlert} instance
3027 * @param {SweetAlertOptions} params
3028 */
3029 const renderInput = (instance, params) => {
3030 const popup = getPopup();
3031 if (!popup) {
3032 return;
3033 }
3034 const innerParams = privateProps.innerParams.get(instance);
3035 const rerender = !innerParams || params.input !== innerParams.input;
3036 inputClasses.forEach(inputClass => {
3037 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3038 if (!inputContainer) {
3039 return;
3040 }
3041
3042 // set attributes
3043 setAttributes(inputClass, params.inputAttributes);
3044
3045 // set class
3046 inputContainer.className = swalClasses[inputClass];
3047 if (rerender) {
3048 hide(inputContainer);
3049 }
3050 });
3051 if (params.input) {
3052 if (rerender) {
3053 showInput(params);
3054 }
3055 // set custom class
3056 setCustomClass(params);
3057 }
3058 };
3059
3060 /**
3061 * @param {SweetAlertOptions} params
3062 */
3063 const showInput = params => {
3064 if (!params.input) {
3065 return;
3066 }
3067 if (!renderInputType[params.input]) {
3068 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3069 return;
3070 }
3071 const inputContainer = getInputContainer(params.input);
3072 if (!inputContainer) {
3073 return;
3074 }
3075 const input = renderInputType[params.input](inputContainer, params);
3076 show(inputContainer);
3077
3078 // input autofocus
3079 if (params.inputAutoFocus) {
3080 setTimeout(() => {
3081 focusInput(input);
3082 });
3083 }
3084 };
3085
3086 /**
3087 * @param {HTMLInputElement} input
3088 */
3089 const removeAttributes = input => {
3090 for (const {
3091 name
3092 } of Array.from(input.attributes)) {
3093 if (!['id', 'type', 'value', 'style'].includes(name)) {
3094 input.removeAttribute(name);
3095 }
3096 }
3097 };
3098
3099 /**
3100 * @param {InputClass} inputClass
3101 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3102 */
3103 const setAttributes = (inputClass, inputAttributes) => {
3104 const popup = getPopup();
3105 if (!popup) {
3106 return;
3107 }
3108 const input = getInput$1(popup, inputClass);
3109 if (!input) {
3110 return;
3111 }
3112 removeAttributes(input);
3113 for (const attr in inputAttributes) {
3114 input.setAttribute(attr, inputAttributes[attr]);
3115 }
3116 };
3117
3118 /**
3119 * @param {SweetAlertOptions} params
3120 */
3121 const setCustomClass = params => {
3122 if (!params.input) {
3123 return;
3124 }
3125 const inputContainer = getInputContainer(params.input);
3126 if (inputContainer) {
3127 applyCustomClass(inputContainer, params, 'input');
3128 }
3129 };
3130
3131 /**
3132 * @param {HTMLInputElement | HTMLTextAreaElement} input
3133 * @param {SweetAlertOptions} params
3134 */
3135 const setInputPlaceholder = (input, params) => {
3136 if (!input.placeholder && params.inputPlaceholder) {
3137 input.placeholder = params.inputPlaceholder;
3138 }
3139 };
3140
3141 /**
3142 * @param {Input} input
3143 * @param {Input} prependTo
3144 * @param {SweetAlertOptions} params
3145 */
3146 const setInputLabel = (input, prependTo, params) => {
3147 if (params.inputLabel) {
3148 const label = document.createElement('label');
3149 const labelClass = swalClasses['input-label'];
3150 label.setAttribute('for', input.id);
3151 label.className = labelClass;
3152 if (typeof params.customClass === 'object') {
3153 addClass(label, params.customClass.inputLabel);
3154 }
3155 label.innerText = params.inputLabel;
3156 prependTo.insertAdjacentElement('beforebegin', label);
3157 }
3158 };
3159
3160 /**
3161 * @param {SweetAlertInput} inputType
3162 * @returns {HTMLElement | undefined}
3163 */
3164 const getInputContainer = inputType => {
3165 const popup = getPopup();
3166 if (!popup) {
3167 return;
3168 }
3169 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3170 };
3171
3172 /**
3173 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3174 * @param {SweetAlertOptions['inputValue']} inputValue
3175 */
3176 const checkAndSetInputValue = (input, inputValue) => {
3177 if (['string', 'number'].includes(typeof inputValue)) {
3178 input.value = `${inputValue}`;
3179 } else if (!isPromise(inputValue)) {
3180 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3181 }
3182 };
3183
3184 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3185 const renderInputType = {};
3186
3187 /**
3188 * @param {Input | HTMLElement} input
3189 * @param {SweetAlertOptions} params
3190 * @returns {Input}
3191 */
3192 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} */
3193 (input, params) => {
3194 // oxfmt-ignore
3195 const inputElement = /** @type {HTMLInputElement} */input;
3196 checkAndSetInputValue(inputElement, params.inputValue);
3197 setInputLabel(inputElement, inputElement, params);
3198 setInputPlaceholder(inputElement, params);
3199 // oxfmt-ignore
3200 inputElement.type = /** @type {string} */params.input;
3201 return inputElement;
3202 };
3203
3204 /**
3205 * @param {Input | HTMLElement} input
3206 * @param {SweetAlertOptions} params
3207 * @returns {Input}
3208 */
3209 renderInputType.file = (input, params) => {
3210 const inputElement = /** @type {HTMLInputElement} */input;
3211 setInputLabel(inputElement, inputElement, params);
3212 setInputPlaceholder(inputElement, params);
3213 return inputElement;
3214 };
3215
3216 /**
3217 * @param {Input | HTMLElement} range
3218 * @param {SweetAlertOptions} params
3219 * @returns {Input}
3220 */
3221 renderInputType.range = (range, params) => {
3222 const rangeContainer = /** @type {HTMLElement} */range;
3223 const rangeInput = rangeContainer.querySelector('input');
3224 const rangeOutput = rangeContainer.querySelector('output');
3225 if (rangeInput) {
3226 checkAndSetInputValue(rangeInput, params.inputValue);
3227 rangeInput.type = /** @type {string} */params.input;
3228 setInputLabel(rangeInput, /** @type {Input} */range, params);
3229 }
3230 if (rangeOutput) {
3231 checkAndSetInputValue(rangeOutput, params.inputValue);
3232 }
3233 return /** @type {Input} */range;
3234 };
3235
3236 /**
3237 * @param {Input | HTMLElement} select
3238 * @param {SweetAlertOptions} params
3239 * @returns {Input}
3240 */
3241 renderInputType.select = (select, params) => {
3242 const selectElement = /** @type {HTMLSelectElement} */select;
3243 selectElement.textContent = '';
3244 if (params.inputPlaceholder) {
3245 const placeholder = document.createElement('option');
3246 setInnerHtml(placeholder, params.inputPlaceholder);
3247 placeholder.value = '';
3248 placeholder.disabled = true;
3249 placeholder.selected = true;
3250 selectElement.appendChild(placeholder);
3251 }
3252 setInputLabel(selectElement, selectElement, params);
3253 return selectElement;
3254 };
3255
3256 /**
3257 * @param {Input | HTMLElement} radio
3258 * @returns {Input}
3259 */
3260 renderInputType.radio = radio => {
3261 const radioElement = /** @type {HTMLElement} */radio;
3262 radioElement.textContent = '';
3263 return /** @type {Input} */radio;
3264 };
3265
3266 /**
3267 * @param {Input | HTMLElement} checkboxContainer
3268 * @param {SweetAlertOptions} params
3269 * @returns {Input}
3270 */
3271 renderInputType.checkbox = (checkboxContainer, params) => {
3272 const popup = getPopup();
3273 if (!popup) {
3274 throw new Error('Popup not found');
3275 }
3276 const checkbox = getInput$1(popup, 'checkbox');
3277 if (!checkbox) {
3278 throw new Error('Checkbox input not found');
3279 }
3280 checkbox.value = '1';
3281 checkbox.checked = Boolean(params.inputValue);
3282 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3283 const label = containerElement.querySelector('span');
3284 if (label) {
3285 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3286 if (placeholderOrLabel) {
3287 setInnerHtml(label, placeholderOrLabel);
3288 }
3289 }
3290 return checkbox;
3291 };
3292
3293 /**
3294 * @param {Input | HTMLElement} textarea
3295 * @param {SweetAlertOptions} params
3296 * @returns {Input}
3297 */
3298 renderInputType.textarea = (textarea, params) => {
3299 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3300 checkAndSetInputValue(textareaElement, params.inputValue);
3301 setInputPlaceholder(textareaElement, params);
3302 setInputLabel(textareaElement, textareaElement, params);
3303
3304 /**
3305 * @param {HTMLElement} el
3306 * @returns {number}
3307 */
3308 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3309
3310 // https://github.com/sweetalert2/sweetalert2/issues/2291
3311 setTimeout(() => {
3312 // https://github.com/sweetalert2/sweetalert2/issues/1699
3313 if ('MutationObserver' in window) {
3314 const popup = getPopup();
3315 if (!popup) {
3316 return;
3317 }
3318 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3319 const textareaResizeHandler = () => {
3320 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3321 if (!document.body.contains(textareaElement)) {
3322 return;
3323 }
3324 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3325 const popupElement = getPopup();
3326 if (popupElement) {
3327 if (textareaWidth > initialPopupWidth) {
3328 popupElement.style.width = `${textareaWidth}px`;
3329 } else {
3330 applyNumericalStyle(popupElement, 'width', params.width);
3331 }
3332 }
3333 };
3334 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3335 attributes: true,
3336 attributeFilter: ['style']
3337 });
3338 }
3339 });
3340 return textareaElement;
3341 };
3342
3343 /**
3344 * @param {SweetAlert} instance
3345 * @param {SweetAlertOptions} params
3346 */
3347 const renderContent = (instance, params) => {
3348 const htmlContainer = getHtmlContainer();
3349 if (!htmlContainer) {
3350 return;
3351 }
3352 showWhenInnerHtmlPresent(htmlContainer);
3353 applyCustomClass(htmlContainer, params, 'htmlContainer');
3354
3355 // Content as HTML
3356 if (params.html) {
3357 parseHtmlToContainer(params.html, htmlContainer);
3358 show(htmlContainer, 'block');
3359 }
3360
3361 // Content as plain text
3362 else if (params.text) {
3363 htmlContainer.textContent = params.text;
3364 show(htmlContainer, 'block');
3365 }
3366
3367 // No content
3368 else {
3369 hide(htmlContainer);
3370 }
3371 renderInput(instance, params);
3372 };
3373
3374 /**
3375 * @param {SweetAlert} instance
3376 * @param {SweetAlertOptions} params
3377 */
3378 const renderFooter = (instance, params) => {
3379 const footer = getFooter();
3380 if (!footer) {
3381 return;
3382 }
3383 showWhenInnerHtmlPresent(footer);
3384 toggle(footer, Boolean(params.footer), 'block');
3385 if (params.footer) {
3386 parseHtmlToContainer(params.footer, footer);
3387 }
3388
3389 // Custom class
3390 applyCustomClass(footer, params, 'footer');
3391 };
3392
3393 /**
3394 * @param {SweetAlert} instance
3395 * @param {SweetAlertOptions} params
3396 */
3397 const renderIcon = (instance, params) => {
3398 const innerParams = privateProps.innerParams.get(instance);
3399 const icon = getIcon();
3400 if (!icon) {
3401 return;
3402 }
3403
3404 // if the given icon already rendered, apply the styling without re-rendering the icon
3405 if (innerParams && params.icon === innerParams.icon) {
3406 // Custom or default content
3407 setContent(icon, params);
3408 applyStyles(icon, params);
3409 return;
3410 }
3411 if (!params.icon && !params.iconHtml) {
3412 hide(icon);
3413 return;
3414 }
3415 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3416 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3417 hide(icon);
3418 return;
3419 }
3420 show(icon);
3421
3422 // Custom or default content
3423 setContent(icon, params);
3424 applyStyles(icon, params);
3425
3426 // Animate icon
3427 addClass(icon, params.showClass && params.showClass.icon);
3428
3429 // Re-adjust the success icon on system theme change
3430 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3431 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3432 };
3433
3434 /**
3435 * @param {HTMLElement} icon
3436 * @param {SweetAlertOptions} params
3437 */
3438 const applyStyles = (icon, params) => {
3439 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3440 if (params.icon !== iconType) {
3441 removeClass(icon, iconClassName);
3442 }
3443 }
3444 addClass(icon, params.icon && iconTypes[params.icon]);
3445
3446 // Icon color
3447 setColor(icon, params);
3448
3449 // Success icon background color
3450 adjustSuccessIconBackgroundColor();
3451
3452 // Custom class
3453 applyCustomClass(icon, params, 'icon');
3454 };
3455
3456 // Adjust success icon background color to match the popup background color
3457 const adjustSuccessIconBackgroundColor = () => {
3458 const popup = getPopup();
3459 if (!popup) {
3460 return;
3461 }
3462 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3463 /** @type {NodeListOf<HTMLElement>} */
3464 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3465 successIconParts.forEach(part => {
3466 part.style.backgroundColor = popupBackgroundColor;
3467 });
3468 };
3469
3470 /**
3471 *
3472 * @param {SweetAlertOptions} params
3473 * @returns {string}
3474 */
3475 const successIconHtml = params => `
3476 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3477 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3478 <div class="swal2-success-ring"></div>
3479 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3480 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3481 `;
3482 const errorIconHtml = `
3483 <span class="swal2-x-mark">
3484 <span class="swal2-x-mark-line-left"></span>
3485 <span class="swal2-x-mark-line-right"></span>
3486 </span>
3487 `;
3488
3489 /**
3490 * @param {HTMLElement} icon
3491 * @param {SweetAlertOptions} params
3492 */
3493 const setContent = (icon, params) => {
3494 if (!params.icon && !params.iconHtml) {
3495 return;
3496 }
3497 let oldContent = icon.innerHTML;
3498 let newContent = '';
3499 if (params.iconHtml) {
3500 newContent = iconContent(params.iconHtml);
3501 } else if (params.icon === 'success') {
3502 newContent = successIconHtml(params);
3503 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3504 } else if (params.icon === 'error') {
3505 newContent = errorIconHtml;
3506 } else if (params.icon) {
3507 const defaultIconHtml = {
3508 question: '?',
3509 warning: '!',
3510 info: 'i'
3511 };
3512 newContent = iconContent(defaultIconHtml[params.icon]);
3513 }
3514 if (oldContent.trim() !== newContent.trim()) {
3515 setInnerHtml(icon, newContent);
3516 }
3517 };
3518
3519 /**
3520 * @param {HTMLElement} icon
3521 * @param {SweetAlertOptions} params
3522 */
3523 const setColor = (icon, params) => {
3524 if (!params.iconColor) {
3525 return;
3526 }
3527 icon.style.color = params.iconColor;
3528 icon.style.borderColor = params.iconColor;
3529 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3530 setStyle(icon, sel, 'background-color', params.iconColor);
3531 }
3532 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3533 };
3534
3535 /**
3536 * @param {string} content
3537 * @returns {string}
3538 */
3539 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3540
3541 /**
3542 * @param {SweetAlert} instance
3543 * @param {SweetAlertOptions} params
3544 */
3545 const renderImage = (instance, params) => {
3546 const image = getImage();
3547 if (!image) {
3548 return;
3549 }
3550 if (!params.imageUrl) {
3551 hide(image);
3552 return;
3553 }
3554 show(image, '');
3555
3556 // Src, alt
3557 image.setAttribute('src', params.imageUrl);
3558 image.setAttribute('alt', params.imageAlt || '');
3559
3560 // Width, height
3561 applyNumericalStyle(image, 'width', params.imageWidth);
3562 applyNumericalStyle(image, 'height', params.imageHeight);
3563
3564 // Class
3565 image.className = swalClasses.image;
3566 applyCustomClass(image, params, 'image');
3567 };
3568
3569 let dragging = false;
3570 let mousedownX = 0;
3571 let mousedownY = 0;
3572 let initialX = 0;
3573 let initialY = 0;
3574
3575 /**
3576 * @param {HTMLElement} popup
3577 */
3578 const addDraggableListeners = popup => {
3579 popup.addEventListener('mousedown', down);
3580 document.body.addEventListener('mousemove', move);
3581 popup.addEventListener('mouseup', up);
3582 popup.addEventListener('touchstart', down);
3583 document.body.addEventListener('touchmove', move);
3584 popup.addEventListener('touchend', up);
3585 };
3586
3587 /**
3588 * @param {HTMLElement} popup
3589 */
3590 const removeDraggableListeners = popup => {
3591 popup.removeEventListener('mousedown', down);
3592 document.body.removeEventListener('mousemove', move);
3593 popup.removeEventListener('mouseup', up);
3594 popup.removeEventListener('touchstart', down);
3595 document.body.removeEventListener('touchmove', move);
3596 popup.removeEventListener('touchend', up);
3597 };
3598
3599 /**
3600 * @param {MouseEvent | TouchEvent} event
3601 */
3602 const down = event => {
3603 const popup = getPopup();
3604 if (!popup) {
3605 return;
3606 }
3607 const icon = getIcon();
3608 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3609 dragging = true;
3610 const clientXY = getClientXY(event);
3611 mousedownX = clientXY.clientX;
3612 mousedownY = clientXY.clientY;
3613 initialX = parseInt(popup.style.insetInlineStart) || 0;
3614 initialY = parseInt(popup.style.insetBlockStart) || 0;
3615 addClass(popup, 'swal2-dragging');
3616 }
3617 };
3618
3619 /**
3620 * @param {MouseEvent | TouchEvent} event
3621 */
3622 const move = event => {
3623 const popup = getPopup();
3624 if (!popup) {
3625 return;
3626 }
3627 if (dragging) {
3628 let {
3629 clientX,
3630 clientY
3631 } = getClientXY(event);
3632 const deltaX = clientX - mousedownX;
3633 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3634 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3635 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3636 }
3637 };
3638 const up = () => {
3639 const popup = getPopup();
3640 dragging = false;
3641 removeClass(popup, 'swal2-dragging');
3642 };
3643
3644 /**
3645 * @param {MouseEvent | TouchEvent} event
3646 * @returns {{ clientX: number, clientY: number }}
3647 */
3648 const getClientXY = event => {
3649 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
3650 return {
3651 clientX: source.clientX,
3652 clientY: source.clientY
3653 };
3654 };
3655
3656 /**
3657 * @param {SweetAlert} instance
3658 * @param {SweetAlertOptions} params
3659 */
3660 const renderPopup = (instance, params) => {
3661 const container = getContainer();
3662 const popup = getPopup();
3663 if (!container || !popup) {
3664 return;
3665 }
3666
3667 // Width
3668 // https://github.com/sweetalert2/sweetalert2/issues/2170
3669 if (params.toast) {
3670 applyNumericalStyle(container, 'width', params.width);
3671 popup.style.width = '100%';
3672 const loader = getLoader();
3673 if (loader) {
3674 popup.insertBefore(loader, getIcon());
3675 }
3676 } else {
3677 applyNumericalStyle(popup, 'width', params.width);
3678 }
3679
3680 // Padding
3681 applyNumericalStyle(popup, 'padding', params.padding);
3682
3683 // Color
3684 if (params.color) {
3685 popup.style.color = params.color;
3686 }
3687
3688 // Background
3689 if (params.background) {
3690 popup.style.background = params.background;
3691 }
3692 hide(getValidationMessage());
3693
3694 // Classes
3695 addClasses$1(popup, params);
3696 if (params.draggable && !params.toast) {
3697 addClass(popup, swalClasses.draggable);
3698 addDraggableListeners(popup);
3699 } else {
3700 removeClass(popup, swalClasses.draggable);
3701 removeDraggableListeners(popup);
3702 }
3703 };
3704
3705 /**
3706 * @param {HTMLElement} popup
3707 * @param {SweetAlertOptions} params
3708 */
3709 const addClasses$1 = (popup, params) => {
3710 const showClass = params.showClass || {};
3711 // Default Class + showClass when updating Swal.update({})
3712 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3713 if (params.toast) {
3714 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3715 addClass(popup, swalClasses.toast);
3716 } else {
3717 addClass(popup, swalClasses.modal);
3718 }
3719
3720 // Custom class
3721 applyCustomClass(popup, params, 'popup');
3722 // TODO: remove in the next major
3723 if (typeof params.customClass === 'string') {
3724 addClass(popup, params.customClass);
3725 }
3726
3727 // Icon class (#1842)
3728 if (params.icon) {
3729 addClass(popup, swalClasses[`icon-${params.icon}`]);
3730 }
3731 };
3732
3733 /**
3734 * @param {SweetAlert} instance
3735 * @param {SweetAlertOptions} params
3736 */
3737 const renderProgressSteps = (instance, params) => {
3738 const progressStepsContainer = getProgressSteps();
3739 if (!progressStepsContainer) {
3740 return;
3741 }
3742 const {
3743 progressSteps,
3744 currentProgressStep
3745 } = params;
3746 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3747 hide(progressStepsContainer);
3748 return;
3749 }
3750 show(progressStepsContainer);
3751 progressStepsContainer.textContent = '';
3752 if (currentProgressStep >= progressSteps.length) {
3753 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3754 }
3755 progressSteps.forEach((step, index) => {
3756 const stepEl = createStepElement(step);
3757 progressStepsContainer.appendChild(stepEl);
3758 if (index === currentProgressStep) {
3759 addClass(stepEl, swalClasses['active-progress-step']);
3760 }
3761 if (index !== progressSteps.length - 1) {
3762 const lineEl = createLineElement(params);
3763 progressStepsContainer.appendChild(lineEl);
3764 }
3765 });
3766 };
3767
3768 /**
3769 * @param {string} step
3770 * @returns {HTMLLIElement}
3771 */
3772 const createStepElement = step => {
3773 const stepEl = document.createElement('li');
3774 addClass(stepEl, swalClasses['progress-step']);
3775 setInnerHtml(stepEl, step);
3776 return stepEl;
3777 };
3778
3779 /**
3780 * @param {SweetAlertOptions} params
3781 * @returns {HTMLLIElement}
3782 */
3783 const createLineElement = params => {
3784 const lineEl = document.createElement('li');
3785 addClass(lineEl, swalClasses['progress-step-line']);
3786 if (params.progressStepsDistance) {
3787 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3788 }
3789 return lineEl;
3790 };
3791
3792 /**
3793 * @param {SweetAlert} instance
3794 * @param {SweetAlertOptions} params
3795 */
3796 const renderTitle = (instance, params) => {
3797 const title = getTitle();
3798 if (!title) {
3799 return;
3800 }
3801 showWhenInnerHtmlPresent(title);
3802 toggle(title, Boolean(params.title || params.titleText), 'block');
3803 if (params.title) {
3804 parseHtmlToContainer(params.title, title);
3805 }
3806 if (params.titleText) {
3807 title.innerText = params.titleText;
3808 }
3809
3810 // Custom class
3811 applyCustomClass(title, params, 'title');
3812 };
3813
3814 /**
3815 * @param {SweetAlert} instance
3816 * @param {SweetAlertOptions} params
3817 */
3818 const render = (instance, params) => {
3819 var _globalState$eventEmi;
3820 renderPopup(instance, params);
3821 renderContainer(instance, params);
3822 renderProgressSteps(instance, params);
3823 renderIcon(instance, params);
3824 renderImage(instance, params);
3825 renderTitle(instance, params);
3826 renderCloseButton(instance, params);
3827 renderContent(instance, params);
3828 renderActions(instance, params);
3829 renderFooter(instance, params);
3830 const popup = getPopup();
3831 if (typeof params.didRender === 'function' && popup) {
3832 params.didRender(popup);
3833 }
3834 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3835 };
3836
3837 /*
3838 * Global function to determine if SweetAlert2 popup is shown
3839 */
3840 const isVisible = () => {
3841 return isVisible$1(getPopup());
3842 };
3843
3844 /*
3845 * Global function to click 'Confirm' button
3846 */
3847 const clickConfirm = () => {
3848 var _dom$getConfirmButton;
3849 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
3850 };
3851
3852 /*
3853 * Global function to click 'Deny' button
3854 */
3855 const clickDeny = () => {
3856 var _dom$getDenyButton;
3857 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
3858 };
3859
3860 /*
3861 * Global function to click 'Cancel' button
3862 */
3863 const clickCancel = () => {
3864 var _dom$getCancelButton;
3865 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
3866 };
3867
3868 /** @type {Record<DismissReason, DismissReason>} */
3869 const DismissReason = Object.freeze({
3870 cancel: 'cancel',
3871 backdrop: 'backdrop',
3872 close: 'close',
3873 esc: 'esc',
3874 timer: 'timer'
3875 });
3876
3877 /**
3878 * @param {GlobalState} globalState
3879 */
3880 const removeKeydownHandler = globalState => {
3881 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
3882 const handler = /** @type {EventListenerOrEventListenerObject} */
3883 /** @type {unknown} */globalState.keydownHandler;
3884 globalState.keydownTarget.removeEventListener('keydown', handler, {
3885 capture: globalState.keydownListenerCapture
3886 });
3887 globalState.keydownHandlerAdded = false;
3888 }
3889 };
3890
3891 /**
3892 * @param {GlobalState} globalState
3893 * @param {SweetAlertOptions} innerParams
3894 * @param {(dismiss: DismissReason) => void} dismissWith
3895 */
3896 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
3897 removeKeydownHandler(globalState);
3898 if (!innerParams.toast) {
3899 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
3900 const handler = e => keydownHandler(innerParams, e, dismissWith);
3901 globalState.keydownHandler = handler;
3902 const target = innerParams.keydownListenerCapture ? window : getPopup();
3903 if (target) {
3904 globalState.keydownTarget = target;
3905 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
3906 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
3907 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
3908 capture: globalState.keydownListenerCapture
3909 });
3910 globalState.keydownHandlerAdded = true;
3911 }
3912 }
3913 };
3914
3915 /**
3916 * @param {number} index
3917 * @param {number} increment
3918 * @returns {boolean} shouldPreventDefault
3919 */
3920 const setFocus = (index, increment) => {
3921 var _dom$getPopup;
3922 const focusableElements = getFocusableElements();
3923 // search for visible elements and select the next possible match
3924 if (focusableElements.length) {
3925 index = index + increment;
3926
3927 // shift + tab when .swal2-popup is focused
3928 if (index === -2) {
3929 index = focusableElements.length - 1;
3930 }
3931
3932 // rollover to first item
3933 if (index === focusableElements.length) {
3934 index = 0;
3935
3936 // go to last item
3937 } else if (index === -1) {
3938 index = focusableElements.length - 1;
3939 }
3940 focusableElements[index].focus();
3941
3942 // don't prevent default for iframes (Firefox fix)
3943 // https://github.com/sweetalert2/sweetalert2/issues/2931
3944 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
3945 return false;
3946 }
3947 return true;
3948 }
3949 // no visible focusable elements, focus the popup
3950 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
3951 return true;
3952 };
3953 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
3954 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
3955
3956 /**
3957 * @param {SweetAlertOptions} innerParams
3958 * @param {KeyboardEvent} event
3959 * @param {(dismiss: DismissReason) => void} dismissWith
3960 */
3961 const keydownHandler = (innerParams, event, dismissWith) => {
3962 if (!innerParams) {
3963 return; // This instance has already been destroyed
3964 }
3965
3966 // Ignore keydown during IME composition
3967 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
3968 // https://github.com/sweetalert2/sweetalert2/issues/720
3969 // https://github.com/sweetalert2/sweetalert2/issues/2406
3970 if (event.isComposing || event.keyCode === 229) {
3971 return;
3972 }
3973 if (innerParams.stopKeydownPropagation) {
3974 event.stopPropagation();
3975 }
3976
3977 // ENTER
3978 if (event.key === 'Enter') {
3979 handleEnter(event, innerParams);
3980 }
3981
3982 // TAB
3983 else if (event.key === 'Tab') {
3984 handleTab(event);
3985 }
3986
3987 // ARROWS - switch focus between buttons
3988 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
3989 handleArrows(event.key);
3990 }
3991
3992 // ESC
3993 else if (event.key === 'Escape') {
3994 handleEsc(event, innerParams, dismissWith);
3995 }
3996 };
3997
3998 /**
3999 * @param {KeyboardEvent} event
4000 * @param {SweetAlertOptions} innerParams
4001 */
4002 const handleEnter = (event, innerParams) => {
4003 // https://github.com/sweetalert2/sweetalert2/issues/2386
4004 if (!callIfFunction(innerParams.allowEnterKey)) {
4005 return;
4006 }
4007 const popup = getPopup();
4008 if (!popup || !innerParams.input) {
4009 return;
4010 }
4011 const input = getInput$1(popup, innerParams.input);
4012 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4013 if (['textarea', 'file'].includes(innerParams.input)) {
4014 return; // do not submit
4015 }
4016 clickConfirm();
4017 event.preventDefault();
4018 }
4019 };
4020
4021 /**
4022 * @param {KeyboardEvent} event
4023 */
4024 const handleTab = event => {
4025 const targetElement = event.target;
4026 const focusableElements = getFocusableElements();
4027 const btnIndex = focusableElements.findIndex(el => el === targetElement);
4028
4029 // don't prevent default for iframes (Firefox fix)
4030 // https://github.com/sweetalert2/sweetalert2/issues/2931
4031 let shouldPreventDefault = true;
4032
4033 // Cycle to the next button
4034 if (!event.shiftKey) {
4035 shouldPreventDefault = setFocus(btnIndex, 1);
4036 }
4037
4038 // Cycle to the prev button
4039 else {
4040 shouldPreventDefault = setFocus(btnIndex, -1);
4041 }
4042 event.stopPropagation();
4043 if (shouldPreventDefault) {
4044 event.preventDefault();
4045 }
4046 };
4047
4048 /**
4049 * @param {string} key
4050 */
4051 const handleArrows = key => {
4052 const actions = getActions();
4053 const confirmButton = getConfirmButton();
4054 const denyButton = getDenyButton();
4055 const cancelButton = getCancelButton();
4056 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4057 return;
4058 }
4059 /** @type HTMLElement[] */
4060 const buttons = [confirmButton, denyButton, cancelButton];
4061 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4062 return;
4063 }
4064 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4065 let buttonToFocus = document.activeElement;
4066 if (!buttonToFocus) {
4067 return;
4068 }
4069 for (let i = 0; i < actions.children.length; i++) {
4070 buttonToFocus = buttonToFocus[sibling];
4071 if (!buttonToFocus) {
4072 return;
4073 }
4074 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4075 break;
4076 }
4077 }
4078 if (buttonToFocus instanceof HTMLButtonElement) {
4079 buttonToFocus.focus();
4080 }
4081 };
4082
4083 /**
4084 * @param {KeyboardEvent} event
4085 * @param {SweetAlertOptions} innerParams
4086 * @param {(dismiss: DismissReason) => void} dismissWith
4087 */
4088 const handleEsc = (event, innerParams, dismissWith) => {
4089 event.preventDefault();
4090 if (callIfFunction(innerParams.allowEscapeKey)) {
4091 dismissWith(DismissReason.esc);
4092 }
4093 };
4094
4095 /**
4096 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4097 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4098 * This is the approach that Babel will probably take to implement private methods/fields
4099 * https://github.com/tc39/proposal-private-methods
4100 * https://github.com/babel/babel/pull/7555
4101 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4102 * then we can use that language feature.
4103 */
4104
4105 var privateMethods = {
4106 swalPromiseResolve: new WeakMap(),
4107 swalPromiseReject: new WeakMap()
4108 };
4109
4110 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4111 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4112 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4113 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4114
4115 const setAriaHidden = () => {
4116 const container = getContainer();
4117 const bodyChildren = Array.from(document.body.children);
4118 bodyChildren.forEach(el => {
4119 if (el.contains(container)) {
4120 return;
4121 }
4122 if (el.hasAttribute('aria-hidden')) {
4123 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4124 }
4125 el.setAttribute('aria-hidden', 'true');
4126 });
4127 };
4128 const unsetAriaHidden = () => {
4129 const bodyChildren = Array.from(document.body.children);
4130 bodyChildren.forEach(el => {
4131 if (el.hasAttribute('data-previous-aria-hidden')) {
4132 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4133 el.removeAttribute('data-previous-aria-hidden');
4134 } else {
4135 el.removeAttribute('aria-hidden');
4136 }
4137 });
4138 };
4139
4140 // @ts-ignore
4141 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4142
4143 // @ts-ignore
4144 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
4145
4146 /**
4147 * Fix iOS scrolling
4148 * http://stackoverflow.com/q/39626302
4149 */
4150 const iOSfix = () => {
4151 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4152 const offset = document.body.scrollTop;
4153 document.body.style.top = `${offset * -1}px`;
4154 addClass(document.body, swalClasses.iosfix);
4155 lockBodyScroll();
4156 }
4157 };
4158
4159 /**
4160 * https://github.com/sweetalert2/sweetalert2/issues/1246
4161 */
4162 const lockBodyScroll = () => {
4163 const container = getContainer();
4164 if (!container) {
4165 return;
4166 }
4167 /** @type {boolean} */
4168 let preventTouchMove;
4169 /**
4170 * @param {TouchEvent} event
4171 */
4172 container.ontouchstart = event => {
4173 preventTouchMove = shouldPreventTouchMove(event);
4174 };
4175 /**
4176 * @param {TouchEvent} event
4177 */
4178 container.ontouchmove = event => {
4179 if (preventTouchMove) {
4180 event.preventDefault();
4181 event.stopPropagation();
4182 }
4183 };
4184 };
4185
4186 /**
4187 * @param {TouchEvent} event
4188 * @returns {boolean}
4189 */
4190 const shouldPreventTouchMove = event => {
4191 const target = event.target;
4192 const container = getContainer();
4193 const htmlContainer = getHtmlContainer();
4194 if (!container || !htmlContainer) {
4195 return false;
4196 }
4197 if (isStylus(event) || isZoom(event)) {
4198 return false;
4199 }
4200 if (target === container) {
4201 return true;
4202 }
4203 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4204 // #2823
4205 target.tagName !== 'INPUT' &&
4206 // #1603
4207 target.tagName !== 'TEXTAREA' &&
4208 // #2266
4209 !(isScrollable(htmlContainer) &&
4210 // #1944
4211 htmlContainer.contains(target))) {
4212 return true;
4213 }
4214 return false;
4215 };
4216
4217 /**
4218 * https://github.com/sweetalert2/sweetalert2/issues/1786
4219 *
4220 * @param {TouchEvent} event
4221 * @returns {boolean}
4222 */
4223 const isStylus = event => {
4224 return Boolean(event.touches && event.touches.length &&
4225 // @ts-ignore - touchType is not a standard property
4226 event.touches[0].touchType === 'stylus');
4227 };
4228
4229 /**
4230 * https://github.com/sweetalert2/sweetalert2/issues/1891
4231 *
4232 * @param {TouchEvent} event
4233 * @returns {boolean}
4234 */
4235 const isZoom = event => {
4236 return event.touches && event.touches.length > 1;
4237 };
4238 const undoIOSfix = () => {
4239 if (hasClass(document.body, swalClasses.iosfix)) {
4240 const offset = parseInt(document.body.style.top, 10);
4241 removeClass(document.body, swalClasses.iosfix);
4242 document.body.style.top = '';
4243 document.body.scrollTop = offset * -1;
4244 }
4245 };
4246
4247 /**
4248 * Measure scrollbar width for padding body during modal show/hide
4249 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4250 *
4251 * @returns {number}
4252 */
4253 const measureScrollbar = () => {
4254 const scrollDiv = document.createElement('div');
4255 scrollDiv.className = swalClasses['scrollbar-measure'];
4256 document.body.appendChild(scrollDiv);
4257 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4258 document.body.removeChild(scrollDiv);
4259 return scrollbarWidth;
4260 };
4261
4262 /**
4263 * Remember state in cases where opening and handling a modal will fiddle with it.
4264 * @type {number | null}
4265 */
4266 let previousBodyPadding = null;
4267
4268 /**
4269 * @param {string} initialBodyOverflow
4270 */
4271 const replaceScrollbarWithPadding = initialBodyOverflow => {
4272 // for queues, do not do this more than once
4273 if (previousBodyPadding !== null) {
4274 return;
4275 }
4276 // if the body has overflow
4277 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4278 ) {
4279 // add padding so the content doesn't shift after removal of scrollbar
4280 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4281 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4282 }
4283 };
4284 const undoReplaceScrollbarWithPadding = () => {
4285 if (previousBodyPadding !== null) {
4286 document.body.style.paddingRight = `${previousBodyPadding}px`;
4287 previousBodyPadding = null;
4288 }
4289 };
4290
4291 /**
4292 * @param {SweetAlert} instance
4293 * @param {HTMLElement} container
4294 * @param {boolean} returnFocus
4295 * @param {(() => void) | undefined} didClose
4296 */
4297 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4298 if (isToast()) {
4299 triggerDidCloseAndDispose(instance, didClose);
4300 } else {
4301 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4302 removeKeydownHandler(globalState);
4303 }
4304
4305 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4306 // for some reason removing the container in Safari will scroll the document to bottom
4307 if (isSafariOrIOS) {
4308 container.setAttribute('style', 'display:none !important');
4309 container.removeAttribute('class');
4310 container.innerHTML = '';
4311 } else {
4312 container.remove();
4313 }
4314 if (isModal()) {
4315 undoReplaceScrollbarWithPadding();
4316 undoIOSfix();
4317 unsetAriaHidden();
4318 }
4319 removeBodyClasses();
4320 }
4321
4322 /**
4323 * Remove SweetAlert2 classes from body
4324 */
4325 function removeBodyClasses() {
4326 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4327 }
4328
4329 /**
4330 * Instance method to close sweetAlert
4331 *
4332 * @param {SweetAlertResult | undefined} resolveValue
4333 * @this {SweetAlert}
4334 */
4335 function close(resolveValue) {
4336 resolveValue = prepareResolveValue(resolveValue);
4337 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4338 const didClose = triggerClosePopup(this);
4339 if (this.isAwaitingPromise) {
4340 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4341 if (!resolveValue.isDismissed) {
4342 handleAwaitingPromise(this);
4343 swalPromiseResolve(resolveValue);
4344 }
4345 } else if (didClose) {
4346 // Resolve Swal promise
4347 swalPromiseResolve(resolveValue);
4348 }
4349 }
4350
4351 /**
4352 * @param {SweetAlert} instance
4353 * @returns {boolean}
4354 */
4355 const triggerClosePopup = instance => {
4356 const popup = getPopup();
4357 if (!popup) {
4358 return false;
4359 }
4360 const innerParams = privateProps.innerParams.get(instance);
4361 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4362 return false;
4363 }
4364 removeClass(popup, innerParams.showClass.popup);
4365 addClass(popup, innerParams.hideClass.popup);
4366 const backdrop = getContainer();
4367 removeClass(backdrop, innerParams.showClass.backdrop);
4368 addClass(backdrop, innerParams.hideClass.backdrop);
4369 handlePopupAnimation(instance, popup, innerParams);
4370 return true;
4371 };
4372
4373 /**
4374 * @param {Error | string} error
4375 * @this {SweetAlert}
4376 */
4377 function rejectPromise(error) {
4378 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4379 handleAwaitingPromise(this);
4380 if (rejectPromise) {
4381 // Reject Swal promise
4382 rejectPromise(error);
4383 }
4384 }
4385
4386 /**
4387 * @param {SweetAlert} instance
4388 */
4389 const handleAwaitingPromise = instance => {
4390 if (instance.isAwaitingPromise) {
4391 // @ts-ignore
4392 delete instance.isAwaitingPromise;
4393 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4394 if (!privateProps.innerParams.get(instance)) {
4395 instance._destroy();
4396 }
4397 }
4398 };
4399
4400 /**
4401 * @param {SweetAlertResult | undefined} resolveValue
4402 * @returns {SweetAlertResult}
4403 */
4404 const prepareResolveValue = resolveValue => {
4405 // When user calls Swal.close()
4406 if (typeof resolveValue === 'undefined') {
4407 return {
4408 isConfirmed: false,
4409 isDenied: false,
4410 isDismissed: true
4411 };
4412 }
4413 return Object.assign({
4414 isConfirmed: false,
4415 isDenied: false,
4416 isDismissed: false
4417 }, resolveValue);
4418 };
4419
4420 /**
4421 * @param {SweetAlert} instance
4422 * @param {HTMLElement} popup
4423 * @param {SweetAlertOptions} innerParams
4424 */
4425 const handlePopupAnimation = (instance, popup, innerParams) => {
4426 var _globalState$eventEmi;
4427 const container = getContainer();
4428 // If animation is supported, animate
4429 const animationIsSupported = hasCssAnimation(popup);
4430 if (typeof innerParams.willClose === 'function') {
4431 innerParams.willClose(popup);
4432 }
4433 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4434 if (animationIsSupported && container) {
4435 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4436 } else if (container) {
4437 // Otherwise, remove immediately
4438 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4439 }
4440 };
4441
4442 /**
4443 * @param {SweetAlert} instance
4444 * @param {HTMLElement} popup
4445 * @param {HTMLElement} container
4446 * @param {boolean} returnFocus
4447 * @param {(() => void) | undefined} didClose
4448 */
4449 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4450 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4451 /**
4452 * @param {AnimationEvent | TransitionEvent} e
4453 */
4454 const swalCloseAnimationFinished = function (e) {
4455 if (e.target === popup) {
4456 var _globalState$swalClos;
4457 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4458 delete globalState.swalCloseEventFinishedCallback;
4459 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4460 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4461 }
4462 };
4463 popup.addEventListener('animationend', swalCloseAnimationFinished);
4464 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4465 };
4466
4467 /**
4468 * @param {SweetAlert} instance
4469 * @param {(() => void) | undefined} didClose
4470 */
4471 const triggerDidCloseAndDispose = (instance, didClose) => {
4472 setTimeout(() => {
4473 var _globalState$eventEmi2;
4474 if (typeof didClose === 'function') {
4475 didClose.bind(instance.params)();
4476 }
4477 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4478 // instance might have been destroyed already
4479 if (instance._destroy) {
4480 instance._destroy();
4481 }
4482 });
4483 };
4484
4485 /**
4486 * Shows loader (spinner), this is useful with AJAX requests.
4487 * By default the loader be shown instead of the "Confirm" button.
4488 *
4489 * @param {HTMLButtonElement | null} [buttonToReplace]
4490 */
4491 const showLoading = buttonToReplace => {
4492 let popup = getPopup();
4493 if (!popup) {
4494 new Swal();
4495 }
4496 popup = getPopup();
4497 if (!popup) {
4498 return;
4499 }
4500 const loader = getLoader();
4501 if (isToast()) {
4502 hide(getIcon());
4503 } else {
4504 replaceButton(popup, buttonToReplace);
4505 }
4506 show(loader);
4507 popup.setAttribute('data-loading', 'true');
4508 popup.setAttribute('aria-busy', 'true');
4509 popup.focus();
4510 };
4511
4512 /**
4513 * @param {HTMLElement} popup
4514 * @param {HTMLButtonElement | null} [buttonToReplace]
4515 */
4516 const replaceButton = (popup, buttonToReplace) => {
4517 const actions = getActions();
4518 const loader = getLoader();
4519 if (!actions || !loader) {
4520 return;
4521 }
4522 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4523 buttonToReplace = getConfirmButton();
4524 }
4525 show(actions);
4526 if (buttonToReplace) {
4527 hide(buttonToReplace);
4528 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4529 actions.insertBefore(loader, buttonToReplace);
4530 }
4531 addClass([popup, actions], swalClasses.loading);
4532 };
4533
4534 /**
4535 * @param {SweetAlert} instance
4536 * @param {SweetAlertOptions} params
4537 */
4538 const handleInputOptionsAndValue = (instance, params) => {
4539 if (params.input === 'select' || params.input === 'radio') {
4540 handleInputOptions(instance, params);
4541 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4542 showLoading(getConfirmButton());
4543 handleInputValue(instance, params);
4544 }
4545 };
4546
4547 /**
4548 * @param {SweetAlert} instance
4549 * @param {SweetAlertOptions} innerParams
4550 * @returns {SweetAlertInputValue}
4551 */
4552 const getInputValue = (instance, innerParams) => {
4553 const input = instance.getInput();
4554 if (!input) {
4555 return null;
4556 }
4557 switch (innerParams.input) {
4558 case 'checkbox':
4559 return getCheckboxValue(input);
4560 case 'radio':
4561 return getRadioValue(input);
4562 case 'file':
4563 return getFileValue(input);
4564 default:
4565 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4566 }
4567 };
4568
4569 /**
4570 * @param {HTMLInputElement} input
4571 * @returns {number}
4572 */
4573 const getCheckboxValue = input => input.checked ? 1 : 0;
4574
4575 /**
4576 * @param {HTMLInputElement} input
4577 * @returns {string | null}
4578 */
4579 const getRadioValue = input => input.checked ? input.value : null;
4580
4581 /**
4582 * @param {HTMLInputElement} input
4583 * @returns {FileList | File | null}
4584 */
4585 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4586
4587 /**
4588 * @param {SweetAlert} instance
4589 * @param {SweetAlertOptions} params
4590 */
4591 const handleInputOptions = (instance, params) => {
4592 const popup = getPopup();
4593 if (!popup) {
4594 return;
4595 }
4596 /**
4597 * @param {*} inputOptions
4598 */
4599 const processInputOptions = inputOptions => {
4600 if (params.input === 'select') {
4601 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4602 } else if (params.input === 'radio') {
4603 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4604 }
4605 };
4606 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4607 showLoading(getConfirmButton());
4608 asPromise(params.inputOptions).then(inputOptions => {
4609 instance.hideLoading();
4610 processInputOptions(inputOptions);
4611 });
4612 } else if (typeof params.inputOptions === 'object') {
4613 processInputOptions(params.inputOptions);
4614 } else {
4615 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4616 }
4617 };
4618
4619 /**
4620 * @param {SweetAlert} instance
4621 * @param {SweetAlertOptions} params
4622 */
4623 const handleInputValue = (instance, params) => {
4624 const input = instance.getInput();
4625 if (!input) {
4626 return;
4627 }
4628 hide(input);
4629 asPromise(params.inputValue).then(inputValue => {
4630 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4631 show(input);
4632 input.focus();
4633 instance.hideLoading();
4634 }).catch(err => {
4635 error(`Error in inputValue promise: ${err}`);
4636 input.value = '';
4637 show(input);
4638 input.focus();
4639 instance.hideLoading();
4640 });
4641 };
4642
4643 /**
4644 * @param {HTMLElement} popup
4645 * @param {InputOptionFlattened[]} inputOptions
4646 * @param {SweetAlertOptions} params
4647 */
4648 function populateSelectOptions(popup, inputOptions, params) {
4649 const select = getDirectChildByClass(popup, swalClasses.select);
4650 if (!select) {
4651 return;
4652 }
4653 /**
4654 * @param {HTMLElement} parent
4655 * @param {string} optionLabel
4656 * @param {string} optionValue
4657 */
4658 const renderOption = (parent, optionLabel, optionValue) => {
4659 const option = document.createElement('option');
4660 option.value = optionValue;
4661 setInnerHtml(option, optionLabel);
4662 option.selected = isSelected(optionValue, params.inputValue);
4663 parent.appendChild(option);
4664 };
4665 inputOptions.forEach(inputOption => {
4666 const optionValue = inputOption[0];
4667 const optionLabel = inputOption[1];
4668 // <optgroup> spec:
4669 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4670 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4671 // check whether this is a <optgroup>
4672 if (Array.isArray(optionLabel)) {
4673 // if it is an array, then it is an <optgroup>
4674 const optgroup = document.createElement('optgroup');
4675 optgroup.label = optionValue;
4676 optgroup.disabled = false; // not configurable for now
4677 select.appendChild(optgroup);
4678 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4679 } else {
4680 // case of <option>
4681 renderOption(select, optionLabel, optionValue);
4682 }
4683 });
4684 select.focus();
4685 }
4686
4687 /**
4688 * @param {HTMLElement} popup
4689 * @param {InputOptionFlattened[]} inputOptions
4690 * @param {SweetAlertOptions} params
4691 */
4692 function populateRadioOptions(popup, inputOptions, params) {
4693 const radio = getDirectChildByClass(popup, swalClasses.radio);
4694 if (!radio) {
4695 return;
4696 }
4697 inputOptions.forEach(inputOption => {
4698 const radioValue = inputOption[0];
4699 const radioLabel = inputOption[1];
4700 const radioInput = document.createElement('input');
4701 const radioLabelElement = document.createElement('label');
4702 radioInput.type = 'radio';
4703 radioInput.name = swalClasses.radio;
4704 radioInput.value = radioValue;
4705 if (isSelected(radioValue, params.inputValue)) {
4706 radioInput.checked = true;
4707 }
4708 const label = document.createElement('span');
4709 setInnerHtml(label, radioLabel);
4710 label.className = swalClasses.label;
4711 radioLabelElement.appendChild(radioInput);
4712 radioLabelElement.appendChild(label);
4713 radio.appendChild(radioLabelElement);
4714 });
4715 const radios = radio.querySelectorAll('input');
4716 if (radios.length) {
4717 radios[0].focus();
4718 }
4719 }
4720
4721 /**
4722 * Converts `inputOptions` into an array of `[value, label]`s
4723 *
4724 * @param {*} inputOptions
4725 * @typedef {string[]} InputOptionFlattened
4726 * @returns {InputOptionFlattened[]}
4727 */
4728 const formatInputOptions = inputOptions => {
4729 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
4730 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
4731 };
4732
4733 /**
4734 * @param {string} optionValue
4735 * @param {SweetAlertInputValue} inputValue
4736 * @returns {boolean}
4737 */
4738 const isSelected = (optionValue, inputValue) => Boolean(inputValue) && inputValue != null && inputValue.toString() === optionValue.toString();
4739
4740 /**
4741 * @param {SweetAlert} instance
4742 */
4743 const handleConfirmButtonClick = instance => {
4744 const innerParams = privateProps.innerParams.get(instance);
4745 instance.disableButtons();
4746 if (innerParams.input) {
4747 handleConfirmOrDenyWithInput(instance, 'confirm');
4748 } else {
4749 confirm(instance, true);
4750 }
4751 };
4752
4753 /**
4754 * @param {SweetAlert} instance
4755 */
4756 const handleDenyButtonClick = instance => {
4757 const innerParams = privateProps.innerParams.get(instance);
4758 instance.disableButtons();
4759 if (innerParams.returnInputValueOnDeny) {
4760 handleConfirmOrDenyWithInput(instance, 'deny');
4761 } else {
4762 deny(instance, false);
4763 }
4764 };
4765
4766 /**
4767 * @param {SweetAlert} instance
4768 * @param {(dismiss: DismissReason) => void} dismissWith
4769 */
4770 const handleCancelButtonClick = (instance, dismissWith) => {
4771 instance.disableButtons();
4772 dismissWith(DismissReason.cancel);
4773 };
4774
4775 /**
4776 * @param {SweetAlert} instance
4777 * @param {'confirm' | 'deny'} type
4778 */
4779 const handleConfirmOrDenyWithInput = (instance, type) => {
4780 const innerParams = privateProps.innerParams.get(instance);
4781 if (!innerParams.input) {
4782 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4783 return;
4784 }
4785 const input = instance.getInput();
4786 const inputValue = getInputValue(instance, innerParams);
4787 if (innerParams.inputValidator) {
4788 handleInputValidator(instance, inputValue, type);
4789 } else if (input && !input.checkValidity()) {
4790 instance.enableButtons();
4791 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4792 } else if (type === 'deny') {
4793 deny(instance, inputValue);
4794 } else {
4795 confirm(instance, inputValue);
4796 }
4797 };
4798
4799 /**
4800 * @param {SweetAlert} instance
4801 * @param {SweetAlertInputValue} inputValue
4802 * @param {'confirm' | 'deny'} type
4803 */
4804 const handleInputValidator = (instance, inputValue, type) => {
4805 const innerParams = privateProps.innerParams.get(instance);
4806 instance.disableInput();
4807 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4808 validationPromise.then(validationMessage => {
4809 instance.enableButtons();
4810 instance.enableInput();
4811 if (validationMessage) {
4812 instance.showValidationMessage(validationMessage);
4813 } else if (type === 'deny') {
4814 deny(instance, inputValue);
4815 } else {
4816 confirm(instance, inputValue);
4817 }
4818 });
4819 };
4820
4821 /**
4822 * @param {SweetAlert} instance
4823 * @param {*} value
4824 */
4825 const deny = (instance, value) => {
4826 const innerParams = privateProps.innerParams.get(instance);
4827 if (innerParams.showLoaderOnDeny) {
4828 showLoading(getDenyButton());
4829 }
4830 if (innerParams.preDeny) {
4831 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
4832 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
4833 preDenyPromise.then(preDenyValue => {
4834 if (preDenyValue === false) {
4835 instance.hideLoading();
4836 handleAwaitingPromise(instance);
4837 } else {
4838 instance.close(/** @type SweetAlertResult */{
4839 isDenied: true,
4840 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
4841 });
4842 }
4843 }).catch(error => rejectWith(instance, error));
4844 } else {
4845 instance.close(/** @type SweetAlertResult */{
4846 isDenied: true,
4847 value
4848 });
4849 }
4850 };
4851
4852 /**
4853 * @param {SweetAlert} instance
4854 * @param {*} value
4855 */
4856 const succeedWith = (instance, value) => {
4857 instance.close(/** @type SweetAlertResult */{
4858 isConfirmed: true,
4859 value
4860 });
4861 };
4862
4863 /**
4864 *
4865 * @param {SweetAlert} instance
4866 * @param {string} error
4867 */
4868 const rejectWith = (instance, error) => {
4869 instance.rejectPromise(error);
4870 };
4871
4872 /**
4873 *
4874 * @param {SweetAlert} instance
4875 * @param {*} value
4876 */
4877 const confirm = (instance, value) => {
4878 const innerParams = privateProps.innerParams.get(instance);
4879 if (innerParams.showLoaderOnConfirm) {
4880 showLoading();
4881 }
4882 if (innerParams.preConfirm) {
4883 instance.resetValidationMessage();
4884 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
4885 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
4886 preConfirmPromise.then(preConfirmValue => {
4887 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
4888 instance.hideLoading();
4889 handleAwaitingPromise(instance);
4890 } else {
4891 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
4892 }
4893 }).catch(error => rejectWith(instance, error));
4894 } else {
4895 succeedWith(instance, value);
4896 }
4897 };
4898
4899 /**
4900 * Hides loader and shows back the button which was hidden by .showLoading()
4901 * @this {SweetAlert}
4902 */
4903 function hideLoading() {
4904 // do nothing if popup is closed
4905 const innerParams = privateProps.innerParams.get(this);
4906 if (!innerParams) {
4907 return;
4908 }
4909 const domCache = privateProps.domCache.get(this);
4910 hide(domCache.loader);
4911 if (isToast()) {
4912 if (innerParams.icon) {
4913 show(getIcon());
4914 }
4915 } else {
4916 showRelatedButton(domCache);
4917 }
4918 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
4919 domCache.popup.removeAttribute('aria-busy');
4920 domCache.popup.removeAttribute('data-loading');
4921 this.enableButtons();
4922 }
4923
4924 /**
4925 * @param {DomCache} domCache
4926 */
4927 const showRelatedButton = domCache => {
4928 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
4929 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
4930 if (buttonToReplace.length) {
4931 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
4932 } else if (allButtonsAreHidden()) {
4933 hide(domCache.actions);
4934 }
4935 };
4936
4937 /**
4938 * Gets the input DOM node, this method works with input parameter.
4939 *
4940 * @returns {HTMLInputElement | null}
4941 * @this {SweetAlert}
4942 */
4943 function getInput() {
4944 const innerParams = privateProps.innerParams.get(this);
4945 const domCache = privateProps.domCache.get(this);
4946 if (!domCache) {
4947 return null;
4948 }
4949 return getInput$1(domCache.popup, innerParams.input);
4950 }
4951
4952 /**
4953 * @param {SweetAlert} instance
4954 * @param {string[]} buttons
4955 * @param {boolean} disabled
4956 */
4957 function setButtonsDisabled(instance, buttons, disabled) {
4958 const domCache = privateProps.domCache.get(instance);
4959 buttons.forEach(button => {
4960 domCache[button].disabled = disabled;
4961 });
4962 }
4963
4964 /**
4965 * @param {HTMLInputElement | null} input
4966 * @param {boolean} disabled
4967 */
4968 function setInputDisabled(input, disabled) {
4969 const popup = getPopup();
4970 if (!popup || !input) {
4971 return;
4972 }
4973 if (input.type === 'radio') {
4974 /** @type {NodeListOf<HTMLInputElement>} */
4975 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
4976 radios.forEach(radio => {
4977 radio.disabled = disabled;
4978 });
4979 } else {
4980 input.disabled = disabled;
4981 }
4982 }
4983
4984 /**
4985 * Enable all the buttons
4986 * @this {SweetAlert}
4987 */
4988 function enableButtons() {
4989 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
4990 const focusedElement = privateProps.focusedElement.get(this);
4991 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
4992 focusedElement.focus();
4993 }
4994 privateProps.focusedElement.delete(this);
4995 }
4996
4997 /**
4998 * Disable all the buttons
4999 * @this {SweetAlert}
5000 */
5001 function disableButtons() {
5002 privateProps.focusedElement.set(this, document.activeElement);
5003 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5004 }
5005
5006 /**
5007 * Enable the input field
5008 * @this {SweetAlert}
5009 */
5010 function enableInput() {
5011 setInputDisabled(this.getInput(), false);
5012 }
5013
5014 /**
5015 * Disable the input field
5016 * @this {SweetAlert}
5017 */
5018 function disableInput() {
5019 setInputDisabled(this.getInput(), true);
5020 }
5021
5022 /**
5023 * Show block with validation message
5024 *
5025 * @param {string} error
5026 * @this {SweetAlert}
5027 */
5028 function showValidationMessage(error) {
5029 const domCache = privateProps.domCache.get(this);
5030 const params = privateProps.innerParams.get(this);
5031 setInnerHtml(domCache.validationMessage, error);
5032 domCache.validationMessage.className = swalClasses['validation-message'];
5033 if (params.customClass && params.customClass.validationMessage) {
5034 addClass(domCache.validationMessage, params.customClass.validationMessage);
5035 }
5036 show(domCache.validationMessage);
5037 const input = this.getInput();
5038 if (input) {
5039 input.setAttribute('aria-invalid', 'true');
5040 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5041 focusInput(input);
5042 addClass(input, swalClasses.inputerror);
5043 }
5044 }
5045
5046 /**
5047 * Hide block with validation message
5048 *
5049 * @this {SweetAlert}
5050 */
5051 function resetValidationMessage() {
5052 const domCache = privateProps.domCache.get(this);
5053 if (domCache.validationMessage) {
5054 hide(domCache.validationMessage);
5055 }
5056 const input = this.getInput();
5057 if (input) {
5058 input.removeAttribute('aria-invalid');
5059 input.removeAttribute('aria-describedby');
5060 removeClass(input, swalClasses.inputerror);
5061 }
5062 }
5063
5064 const defaultParams = {
5065 title: '',
5066 titleText: '',
5067 text: '',
5068 html: '',
5069 footer: '',
5070 icon: undefined,
5071 iconColor: undefined,
5072 iconHtml: undefined,
5073 template: undefined,
5074 toast: false,
5075 draggable: false,
5076 animation: true,
5077 theme: 'light',
5078 showClass: {
5079 popup: 'swal2-show',
5080 backdrop: 'swal2-backdrop-show',
5081 icon: 'swal2-icon-show'
5082 },
5083 hideClass: {
5084 popup: 'swal2-hide',
5085 backdrop: 'swal2-backdrop-hide',
5086 icon: 'swal2-icon-hide'
5087 },
5088 customClass: {},
5089 target: 'body',
5090 color: undefined,
5091 backdrop: true,
5092 heightAuto: true,
5093 allowOutsideClick: true,
5094 allowEscapeKey: true,
5095 allowEnterKey: true,
5096 stopKeydownPropagation: true,
5097 keydownListenerCapture: false,
5098 showConfirmButton: true,
5099 showDenyButton: false,
5100 showCancelButton: false,
5101 preConfirm: undefined,
5102 preDeny: undefined,
5103 confirmButtonText: 'OK',
5104 confirmButtonAriaLabel: '',
5105 confirmButtonColor: undefined,
5106 denyButtonText: 'No',
5107 denyButtonAriaLabel: '',
5108 denyButtonColor: undefined,
5109 cancelButtonText: 'Cancel',
5110 cancelButtonAriaLabel: '',
5111 cancelButtonColor: undefined,
5112 buttonsStyling: true,
5113 reverseButtons: false,
5114 focusConfirm: true,
5115 focusDeny: false,
5116 focusCancel: false,
5117 returnFocus: true,
5118 showCloseButton: false,
5119 closeButtonHtml: '&times;',
5120 closeButtonAriaLabel: 'Close this dialog',
5121 loaderHtml: '',
5122 showLoaderOnConfirm: false,
5123 showLoaderOnDeny: false,
5124 imageUrl: undefined,
5125 imageWidth: undefined,
5126 imageHeight: undefined,
5127 imageAlt: '',
5128 timer: undefined,
5129 timerProgressBar: false,
5130 width: undefined,
5131 padding: undefined,
5132 background: undefined,
5133 input: undefined,
5134 inputPlaceholder: '',
5135 inputLabel: '',
5136 inputValue: '',
5137 inputOptions: {},
5138 inputAutoFocus: true,
5139 inputAutoTrim: true,
5140 inputAttributes: {},
5141 inputValidator: undefined,
5142 returnInputValueOnDeny: false,
5143 validationMessage: undefined,
5144 grow: false,
5145 position: 'center',
5146 progressSteps: [],
5147 currentProgressStep: undefined,
5148 progressStepsDistance: undefined,
5149 willOpen: undefined,
5150 didOpen: undefined,
5151 didRender: undefined,
5152 willClose: undefined,
5153 didClose: undefined,
5154 didDestroy: undefined,
5155 scrollbarPadding: true,
5156 topLayer: false
5157 };
5158 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'];
5159
5160 /** @type {Record<string, string | undefined>} */
5161 const deprecatedParams = {
5162 allowEnterKey: undefined
5163 };
5164 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5165
5166 /**
5167 * Is valid parameter
5168 *
5169 * @param {string} paramName
5170 * @returns {boolean}
5171 */
5172 const isValidParameter = paramName => {
5173 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5174 };
5175
5176 /**
5177 * Is valid parameter for Swal.update() method
5178 *
5179 * @param {string} paramName
5180 * @returns {boolean}
5181 */
5182 const isUpdatableParameter = paramName => {
5183 return updatableParams.indexOf(paramName) !== -1;
5184 };
5185
5186 /**
5187 * Is deprecated parameter
5188 *
5189 * @param {string} paramName
5190 * @returns {string | undefined}
5191 */
5192 const isDeprecatedParameter = paramName => {
5193 return deprecatedParams[paramName];
5194 };
5195
5196 /**
5197 * @param {string} param
5198 */
5199 const checkIfParamIsValid = param => {
5200 if (!isValidParameter(param)) {
5201 warn(`Unknown parameter "${param}"`);
5202 }
5203 };
5204
5205 /**
5206 * @param {string} param
5207 */
5208 const checkIfToastParamIsValid = param => {
5209 if (toastIncompatibleParams.includes(param)) {
5210 warn(`The parameter "${param}" is incompatible with toasts`);
5211 }
5212 };
5213
5214 /**
5215 * @param {string} param
5216 */
5217 const checkIfParamIsDeprecated = param => {
5218 const isDeprecated = isDeprecatedParameter(param);
5219 if (isDeprecated) {
5220 warnAboutDeprecation(param, isDeprecated);
5221 }
5222 };
5223
5224 /**
5225 * Show relevant warnings for given params
5226 *
5227 * @param {SweetAlertOptions} params
5228 */
5229 const showWarningsForParams = params => {
5230 if (params.backdrop === false && params.allowOutsideClick) {
5231 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5232 }
5233 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)) {
5234 warn(`Invalid theme "${params.theme}"`);
5235 }
5236 for (const param in params) {
5237 checkIfParamIsValid(param);
5238 if (params.toast) {
5239 checkIfToastParamIsValid(param);
5240 }
5241 checkIfParamIsDeprecated(param);
5242 }
5243 };
5244
5245 /**
5246 * Updates popup parameters.
5247 *
5248 * @this {any}
5249 * @param {SweetAlertOptions} params
5250 */
5251 function update(params) {
5252 const container = getContainer();
5253 const popup = getPopup();
5254 const innerParams = privateProps.innerParams.get(this);
5255 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5256 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.`);
5257 return;
5258 }
5259 const validUpdatableParams = filterValidParams(params);
5260 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5261 showWarningsForParams(updatedParams);
5262 if (container) {
5263 container.dataset['swal2Theme'] = updatedParams.theme;
5264 }
5265 render(this, updatedParams);
5266 privateProps.innerParams.set(this, updatedParams);
5267 Object.defineProperties(this, {
5268 params: {
5269 value: Object.assign({}, this.params, params),
5270 writable: false,
5271 enumerable: true
5272 }
5273 });
5274 }
5275
5276 /**
5277 * @param {SweetAlertOptions} params
5278 * @returns {SweetAlertOptions}
5279 */
5280 const filterValidParams = params => {
5281 /** @type {Record<string, any>} */
5282 const validUpdatableParams = {};
5283 Object.keys(params).forEach(param => {
5284 if (isUpdatableParameter(param)) {
5285 const typedParams = /** @type {Record<string, any>} */params;
5286 validUpdatableParams[param] = typedParams[param];
5287 } else {
5288 warn(`Invalid parameter to update: ${param}`);
5289 }
5290 });
5291 return validUpdatableParams;
5292 };
5293
5294 /**
5295 * Dispose the current SweetAlert2 instance
5296 * @this {SweetAlert}
5297 */
5298 function _destroy() {
5299 var _globalState$eventEmi;
5300 const domCache = privateProps.domCache.get(this);
5301 const innerParams = privateProps.innerParams.get(this);
5302 if (!innerParams) {
5303 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5304 return; // This instance has already been destroyed
5305 }
5306
5307 // Check if there is another Swal closing
5308 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5309 globalState.swalCloseEventFinishedCallback();
5310 delete globalState.swalCloseEventFinishedCallback;
5311 }
5312 if (typeof innerParams.didDestroy === 'function') {
5313 innerParams.didDestroy();
5314 }
5315 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5316 disposeSwal(this);
5317 }
5318
5319 /**
5320 * @param {SweetAlert} instance
5321 */
5322 const disposeSwal = instance => {
5323 disposeWeakMaps(instance);
5324 // Unset this.params so GC will dispose it (#1569)
5325 // @ts-ignore
5326 delete instance.params;
5327 // Unset globalState props so GC will dispose globalState (#1569)
5328 delete globalState.keydownHandler;
5329 delete globalState.keydownTarget;
5330 // Unset currentInstance
5331 delete globalState.currentInstance;
5332 };
5333
5334 /**
5335 * @param {SweetAlert} instance
5336 */
5337 const disposeWeakMaps = instance => {
5338 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5339 if (instance.isAwaitingPromise) {
5340 unsetWeakMaps(privateProps, instance);
5341 instance.isAwaitingPromise = true;
5342 } else {
5343 unsetWeakMaps(privateMethods, instance);
5344 unsetWeakMaps(privateProps, instance);
5345
5346 // @ts-ignore
5347 delete instance.isAwaitingPromise;
5348 // Unset instance methods
5349 // @ts-ignore
5350 delete instance.disableButtons;
5351 // @ts-ignore
5352 delete instance.enableButtons;
5353 // @ts-ignore
5354 delete instance.getInput;
5355 // @ts-ignore
5356 delete instance.disableInput;
5357 // @ts-ignore
5358 delete instance.enableInput;
5359 // @ts-ignore
5360 delete instance.hideLoading;
5361 // @ts-ignore
5362 delete instance.disableLoading;
5363 // @ts-ignore
5364 delete instance.showValidationMessage;
5365 // @ts-ignore
5366 delete instance.resetValidationMessage;
5367 // @ts-ignore
5368 delete instance.close;
5369 // @ts-ignore
5370 delete instance.closePopup;
5371 // @ts-ignore
5372 delete instance.closeModal;
5373 // @ts-ignore
5374 delete instance.closeToast;
5375 // @ts-ignore
5376 delete instance.rejectPromise;
5377 // @ts-ignore
5378 delete instance.update;
5379 // @ts-ignore
5380 delete instance._destroy;
5381 }
5382 };
5383
5384 /**
5385 * @param {Record<string, WeakMap<any, any>>} obj
5386 * @param {SweetAlert} instance
5387 */
5388 const unsetWeakMaps = (obj, instance) => {
5389 for (const i in obj) {
5390 obj[i].delete(instance);
5391 }
5392 };
5393
5394 var instanceMethods = /*#__PURE__*/Object.freeze({
5395 __proto__: null,
5396 _destroy: _destroy,
5397 close: close,
5398 closeModal: close,
5399 closePopup: close,
5400 closeToast: close,
5401 disableButtons: disableButtons,
5402 disableInput: disableInput,
5403 disableLoading: hideLoading,
5404 enableButtons: enableButtons,
5405 enableInput: enableInput,
5406 getInput: getInput,
5407 handleAwaitingPromise: handleAwaitingPromise,
5408 hideLoading: hideLoading,
5409 rejectPromise: rejectPromise,
5410 resetValidationMessage: resetValidationMessage,
5411 showValidationMessage: showValidationMessage,
5412 update: update
5413 });
5414
5415 /**
5416 * @param {SweetAlertOptions} innerParams
5417 * @param {DomCache} domCache
5418 * @param {(dismiss: DismissReason) => void} dismissWith
5419 */
5420 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5421 if (innerParams.toast) {
5422 handleToastClick(innerParams, domCache, dismissWith);
5423 } else {
5424 // Ignore click events that had mousedown on the popup but mouseup on the container
5425 // This can happen when the user drags a slider
5426 handleModalMousedown(domCache);
5427
5428 // Ignore click events that had mousedown on the container but mouseup on the popup
5429 handleContainerMousedown(domCache);
5430 handleModalClick(innerParams, domCache, dismissWith);
5431 }
5432 };
5433
5434 /**
5435 * @param {SweetAlertOptions} innerParams
5436 * @param {DomCache} domCache
5437 * @param {(dismiss: DismissReason) => void} dismissWith
5438 */
5439 const handleToastClick = (innerParams, domCache, dismissWith) => {
5440 // Closing toast by internal click
5441 domCache.popup.onclick = () => {
5442 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5443 return;
5444 }
5445 dismissWith(DismissReason.close);
5446 };
5447 };
5448
5449 /**
5450 * @param {SweetAlertOptions} innerParams
5451 * @returns {boolean}
5452 */
5453 const isAnyButtonShown = innerParams => {
5454 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5455 };
5456 let ignoreOutsideClick = false;
5457
5458 /**
5459 * @param {DomCache} domCache
5460 */
5461 const handleModalMousedown = domCache => {
5462 domCache.popup.onmousedown = () => {
5463 domCache.container.onmouseup = function (e) {
5464 domCache.container.onmouseup = () => {};
5465 // We only check if the mouseup target is the container because usually it doesn't
5466 // have any other direct children aside of the popup
5467 if (e.target === domCache.container) {
5468 ignoreOutsideClick = true;
5469 }
5470 };
5471 };
5472 };
5473
5474 /**
5475 * @param {DomCache} domCache
5476 */
5477 const handleContainerMousedown = domCache => {
5478 domCache.container.onmousedown = e => {
5479 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5480 if (e.target === domCache.container) {
5481 e.preventDefault();
5482 }
5483 domCache.popup.onmouseup = function (e) {
5484 domCache.popup.onmouseup = () => {};
5485 // We also need to check if the mouseup target is a child of the popup
5486 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5487 ignoreOutsideClick = true;
5488 }
5489 };
5490 };
5491 };
5492
5493 /**
5494 * @param {SweetAlertOptions} innerParams
5495 * @param {DomCache} domCache
5496 * @param {(dismiss: DismissReason) => void} dismissWith
5497 */
5498 const handleModalClick = (innerParams, domCache, dismissWith) => {
5499 domCache.container.onclick = e => {
5500 if (ignoreOutsideClick) {
5501 ignoreOutsideClick = false;
5502 return;
5503 }
5504 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5505 dismissWith(DismissReason.backdrop);
5506 }
5507 };
5508 };
5509
5510 /**
5511 * @param {unknown} elem
5512 * @returns {boolean}
5513 */
5514 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
5515
5516 /**
5517 * @param {unknown} elem
5518 * @returns {boolean}
5519 */
5520 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5521
5522 /**
5523 * @param {ReadonlyArray<unknown>} args
5524 * @returns {SweetAlertOptions}
5525 */
5526 const argsToParams = args => {
5527 /** @type {Record<string, unknown>} */
5528 const params = {};
5529 if (typeof args[0] === 'object' && !isElement(args[0])) {
5530 Object.assign(params, args[0]);
5531 } else {
5532 ['title', 'html', 'icon'].forEach((name, index) => {
5533 const arg = args[index];
5534 if (typeof arg === 'string' || isElement(arg)) {
5535 params[name] = arg;
5536 } else if (arg !== undefined) {
5537 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5538 }
5539 });
5540 }
5541 return /** @type {SweetAlertOptions} */params;
5542 };
5543
5544 /**
5545 * Main method to create a new SweetAlert2 popup
5546 *
5547 * @this {new (...args: any[]) => any}
5548 * @param {...SweetAlertOptions} args
5549 * @returns {Promise<SweetAlertResult>}
5550 */
5551 function fire(...args) {
5552 return new this(...args);
5553 }
5554
5555 /**
5556 * Returns an extended version of `Swal` containing `params` as defaults.
5557 * Useful for reusing Swal configuration.
5558 *
5559 * For example:
5560 *
5561 * Before:
5562 * const textPromptOptions = { input: 'text', showCancelButton: true }
5563 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5564 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5565 *
5566 * After:
5567 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5568 * const {value: firstName} = await TextPrompt('What is your first name?')
5569 * const {value: lastName} = await TextPrompt('What is your last name?')
5570 *
5571 * @param {SweetAlertOptions} mixinParams
5572 * @returns {SweetAlert}
5573 * @this {typeof import('../SweetAlert.js').SweetAlert}
5574 */
5575 function mixin(mixinParams) {
5576 // @ts-ignore: 'this' refers to the SweetAlert constructor
5577 class MixinSwal extends this {
5578 /**
5579 * @param {any} params
5580 * @param {any} priorityMixinParams
5581 */
5582 _main(params, priorityMixinParams) {
5583 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5584 }
5585 }
5586 // @ts-ignore
5587 return MixinSwal;
5588 }
5589
5590 /**
5591 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5592 * Otherwise, returns undefined.
5593 *
5594 * @returns {number | undefined}
5595 */
5596 const getTimerLeft = () => {
5597 return globalState.timeout && globalState.timeout.getTimerLeft();
5598 };
5599
5600 /**
5601 * Stop timer. Returns number of milliseconds of timer remained.
5602 * If `timer` parameter isn't set, returns undefined.
5603 *
5604 * @returns {number | undefined}
5605 */
5606 const stopTimer = () => {
5607 if (globalState.timeout) {
5608 stopTimerProgressBar();
5609 return globalState.timeout.stop();
5610 }
5611 };
5612
5613 /**
5614 * Resume timer. Returns number of milliseconds of timer remained.
5615 * If `timer` parameter isn't set, returns undefined.
5616 *
5617 * @returns {number | undefined}
5618 */
5619 const resumeTimer = () => {
5620 if (globalState.timeout) {
5621 const remaining = globalState.timeout.start();
5622 animateTimerProgressBar(remaining);
5623 return remaining;
5624 }
5625 };
5626
5627 /**
5628 * Resume timer. Returns number of milliseconds of timer remained.
5629 * If `timer` parameter isn't set, returns undefined.
5630 *
5631 * @returns {number | undefined}
5632 */
5633 const toggleTimer = () => {
5634 const timer = globalState.timeout;
5635 return timer && (timer.running ? stopTimer() : resumeTimer());
5636 };
5637
5638 /**
5639 * Increase timer. Returns number of milliseconds of an updated timer.
5640 * If `timer` parameter isn't set, returns undefined.
5641 *
5642 * @param {number} ms
5643 * @returns {number | undefined}
5644 */
5645 const increaseTimer = ms => {
5646 if (globalState.timeout) {
5647 const remaining = globalState.timeout.increase(ms);
5648 animateTimerProgressBar(remaining, true);
5649 return remaining;
5650 }
5651 };
5652
5653 /**
5654 * Check if timer is running. Returns true if timer is running
5655 * or false if timer is paused or stopped.
5656 * If `timer` parameter isn't set, returns undefined
5657 *
5658 * @returns {boolean}
5659 */
5660 const isTimerRunning = () => {
5661 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5662 };
5663
5664 let bodyClickListenerAdded = false;
5665 /** @type {Record<string, any>} */
5666 const clickHandlers = {};
5667
5668 /**
5669 * @this {any}
5670 * @param {string} attr
5671 */
5672 function bindClickHandler(attr = 'data-swal-template') {
5673 clickHandlers[attr] = this;
5674 if (!bodyClickListenerAdded) {
5675 document.body.addEventListener('click', bodyClickListener);
5676 bodyClickListenerAdded = true;
5677 }
5678 }
5679
5680 /**
5681 * @param {MouseEvent} event
5682 */
5683 const bodyClickListener = event => {
5684 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5685 for (const attr in clickHandlers) {
5686 const template = el.getAttribute && el.getAttribute(attr);
5687 if (template) {
5688 clickHandlers[attr].fire({
5689 template
5690 });
5691 return;
5692 }
5693 }
5694 }
5695 };
5696
5697 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5698
5699 class EventEmitter {
5700 constructor() {
5701 /** @type {Events} */
5702 this.events = {};
5703 }
5704
5705 /**
5706 * @param {string} eventName
5707 * @returns {EventHandlers}
5708 */
5709 _getHandlersByEventName(eventName) {
5710 if (typeof this.events[eventName] === 'undefined') {
5711 // not Set because we need to keep the FIFO order
5712 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5713 this.events[eventName] = [];
5714 }
5715 return this.events[eventName];
5716 }
5717
5718 /**
5719 * @param {string} eventName
5720 * @param {EventHandler} eventHandler
5721 */
5722 on(eventName, eventHandler) {
5723 const currentHandlers = this._getHandlersByEventName(eventName);
5724 if (!currentHandlers.includes(eventHandler)) {
5725 currentHandlers.push(eventHandler);
5726 }
5727 }
5728
5729 /**
5730 * @param {string} eventName
5731 * @param {EventHandler} eventHandler
5732 */
5733 once(eventName, eventHandler) {
5734 /**
5735 * @param {...any} args
5736 */
5737 const onceFn = (...args) => {
5738 this.removeListener(eventName, onceFn);
5739 // @ts-ignore
5740 eventHandler.apply(this, args);
5741 };
5742 this.on(eventName, onceFn);
5743 }
5744
5745 /**
5746 * @param {string} eventName
5747 * @param {...any} args
5748 */
5749 emit(eventName, ...args) {
5750 this._getHandlersByEventName(eventName).forEach(
5751 /**
5752 * @param {EventHandler} eventHandler
5753 */
5754 eventHandler => {
5755 try {
5756 // @ts-ignore
5757 eventHandler.apply(this, args);
5758 } catch (error) {
5759 console.error(error);
5760 }
5761 });
5762 }
5763
5764 /**
5765 * @param {string} eventName
5766 * @param {EventHandler} eventHandler
5767 */
5768 removeListener(eventName, eventHandler) {
5769 const currentHandlers = this._getHandlersByEventName(eventName);
5770 const index = currentHandlers.indexOf(eventHandler);
5771 if (index > -1) {
5772 currentHandlers.splice(index, 1);
5773 }
5774 }
5775
5776 /**
5777 * @param {string} eventName
5778 */
5779 removeAllListeners(eventName) {
5780 if (this.events[eventName] !== undefined) {
5781 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5782 this.events[eventName].length = 0;
5783 }
5784 }
5785 reset() {
5786 this.events = {};
5787 }
5788 }
5789
5790 globalState.eventEmitter = new EventEmitter();
5791
5792 /**
5793 * @param {string} eventName
5794 * @param {EventHandler} eventHandler
5795 */
5796 const on = (eventName, eventHandler) => {
5797 if (globalState.eventEmitter) {
5798 globalState.eventEmitter.on(eventName, eventHandler);
5799 }
5800 };
5801
5802 /**
5803 * @param {string} eventName
5804 * @param {EventHandler} eventHandler
5805 */
5806 const once = (eventName, eventHandler) => {
5807 if (globalState.eventEmitter) {
5808 globalState.eventEmitter.once(eventName, eventHandler);
5809 }
5810 };
5811
5812 /**
5813 * @param {string} [eventName]
5814 * @param {EventHandler} [eventHandler]
5815 */
5816 const off = (eventName, eventHandler) => {
5817 if (!globalState.eventEmitter) {
5818 return;
5819 }
5820
5821 // Remove all handlers for all events
5822 if (!eventName) {
5823 globalState.eventEmitter.reset();
5824 return;
5825 }
5826 if (eventHandler) {
5827 // Remove a specific handler
5828 globalState.eventEmitter.removeListener(eventName, eventHandler);
5829 } else {
5830 // Remove all handlers for a specific event
5831 globalState.eventEmitter.removeAllListeners(eventName);
5832 }
5833 };
5834
5835 var staticMethods = /*#__PURE__*/Object.freeze({
5836 __proto__: null,
5837 argsToParams: argsToParams,
5838 bindClickHandler: bindClickHandler,
5839 clickCancel: clickCancel,
5840 clickConfirm: clickConfirm,
5841 clickDeny: clickDeny,
5842 enableLoading: showLoading,
5843 fire: fire,
5844 getActions: getActions,
5845 getCancelButton: getCancelButton,
5846 getCloseButton: getCloseButton,
5847 getConfirmButton: getConfirmButton,
5848 getContainer: getContainer,
5849 getDenyButton: getDenyButton,
5850 getFocusableElements: getFocusableElements,
5851 getFooter: getFooter,
5852 getHtmlContainer: getHtmlContainer,
5853 getIcon: getIcon,
5854 getIconContent: getIconContent,
5855 getImage: getImage,
5856 getInputLabel: getInputLabel,
5857 getLoader: getLoader,
5858 getPopup: getPopup,
5859 getProgressSteps: getProgressSteps,
5860 getTimerLeft: getTimerLeft,
5861 getTimerProgressBar: getTimerProgressBar,
5862 getTitle: getTitle,
5863 getValidationMessage: getValidationMessage,
5864 increaseTimer: increaseTimer,
5865 isDeprecatedParameter: isDeprecatedParameter,
5866 isLoading: isLoading,
5867 isTimerRunning: isTimerRunning,
5868 isUpdatableParameter: isUpdatableParameter,
5869 isValidParameter: isValidParameter,
5870 isVisible: isVisible,
5871 mixin: mixin,
5872 off: off,
5873 on: on,
5874 once: once,
5875 resumeTimer: resumeTimer,
5876 showLoading: showLoading,
5877 stopTimer: stopTimer,
5878 toggleTimer: toggleTimer
5879 });
5880
5881 class Timer {
5882 /**
5883 * @param {() => void} callback
5884 * @param {number} delay
5885 */
5886 constructor(callback, delay) {
5887 this.callback = callback;
5888 this.remaining = delay;
5889 this.running = false;
5890 this.start();
5891 }
5892
5893 /**
5894 * @returns {number}
5895 */
5896 start() {
5897 if (!this.running) {
5898 this.running = true;
5899 this.started = new Date();
5900 this.id = setTimeout(this.callback, this.remaining);
5901 }
5902 return this.remaining;
5903 }
5904
5905 /**
5906 * @returns {number}
5907 */
5908 stop() {
5909 if (this.started && this.running) {
5910 this.running = false;
5911 clearTimeout(this.id);
5912 this.remaining -= new Date().getTime() - this.started.getTime();
5913 }
5914 return this.remaining;
5915 }
5916
5917 /**
5918 * @param {number} n
5919 * @returns {number}
5920 */
5921 increase(n) {
5922 const running = this.running;
5923 if (running) {
5924 this.stop();
5925 }
5926 this.remaining += n;
5927 if (running) {
5928 this.start();
5929 }
5930 return this.remaining;
5931 }
5932
5933 /**
5934 * @returns {number}
5935 */
5936 getTimerLeft() {
5937 if (this.running) {
5938 this.stop();
5939 this.start();
5940 }
5941 return this.remaining;
5942 }
5943
5944 /**
5945 * @returns {boolean}
5946 */
5947 isRunning() {
5948 return this.running;
5949 }
5950 }
5951
5952 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
5953
5954 /**
5955 * @param {SweetAlertOptions} params
5956 * @returns {SweetAlertOptions}
5957 */
5958 const getTemplateParams = params => {
5959 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
5960 if (!template) {
5961 return {};
5962 }
5963 /** @type {DocumentFragment} */
5964 const templateContent = template.content;
5965 showWarningsForElements(templateContent);
5966 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
5967 return result;
5968 };
5969
5970 /**
5971 * @param {DocumentFragment} templateContent
5972 * @returns {Record<string, string | boolean | number>}
5973 */
5974 const getSwalParams = templateContent => {
5975 /** @type {Record<string, string | boolean | number>} */
5976 const result = {};
5977 /** @type {HTMLElement[]} */
5978 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
5979 swalParams.forEach(param => {
5980 showWarningsForAttributes(param, ['name', 'value']);
5981 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
5982 const value = param.getAttribute('value');
5983 if (!paramName || !value) {
5984 return;
5985 }
5986 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
5987 result[paramName] = value !== 'false';
5988 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
5989 result[paramName] = JSON.parse(value);
5990 } else {
5991 result[paramName] = value;
5992 }
5993 });
5994 return result;
5995 };
5996
5997 /**
5998 * @param {DocumentFragment} templateContent
5999 * @returns {Record<string, () => void>}
6000 */
6001 const getSwalFunctionParams = templateContent => {
6002 /** @type {Record<string, () => void>} */
6003 const result = {};
6004 /** @type {HTMLElement[]} */
6005 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6006 swalFunctions.forEach(param => {
6007 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6008 const value = param.getAttribute('value');
6009 if (!paramName || !value) {
6010 return;
6011 }
6012 result[paramName] = new Function(`return ${value}`)();
6013 });
6014 return result;
6015 };
6016
6017 /**
6018 * @param {DocumentFragment} templateContent
6019 * @returns {Record<string, string | boolean>}
6020 */
6021 const getSwalButtons = templateContent => {
6022 /** @type {Record<string, string | boolean>} */
6023 const result = {};
6024 /** @type {HTMLElement[]} */
6025 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6026 swalButtons.forEach(button => {
6027 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6028 const type = button.getAttribute('type');
6029 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6030 return;
6031 }
6032 result[`${type}ButtonText`] = button.innerHTML;
6033 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6034 const color = button.getAttribute('color');
6035 if (color !== null) {
6036 result[`${type}ButtonColor`] = color;
6037 }
6038 const ariaLabel = button.getAttribute('aria-label');
6039 if (ariaLabel !== null) {
6040 result[`${type}ButtonAriaLabel`] = ariaLabel;
6041 }
6042 });
6043 return result;
6044 };
6045
6046 /**
6047 * @param {DocumentFragment} templateContent
6048 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6049 */
6050 const getSwalImage = templateContent => {
6051 const result = {};
6052 /** @type {HTMLElement | null} */
6053 const image = templateContent.querySelector('swal-image');
6054 if (image) {
6055 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6056 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
6057 const src = image.getAttribute('src');
6058 if (src !== null) result.imageUrl = src || undefined;
6059 const width = image.getAttribute('width');
6060 if (width !== null) result.imageWidth = width || undefined;
6061 const height = image.getAttribute('height');
6062 if (height !== null) result.imageHeight = height || undefined;
6063 const alt = image.getAttribute('alt');
6064 if (alt !== null) result.imageAlt = alt || undefined;
6065 }
6066 return result;
6067 };
6068
6069 /**
6070 * @param {DocumentFragment} templateContent
6071 * @returns {object}
6072 */
6073 const getSwalIcon = templateContent => {
6074 const result = {};
6075 /** @type {HTMLElement | null} */
6076 const icon = templateContent.querySelector('swal-icon');
6077 if (icon) {
6078 showWarningsForAttributes(icon, ['type', 'color']);
6079 if (icon.hasAttribute('type')) {
6080 result.icon = icon.getAttribute('type');
6081 }
6082 if (icon.hasAttribute('color')) {
6083 result.iconColor = icon.getAttribute('color');
6084 }
6085 result.iconHtml = icon.innerHTML;
6086 }
6087 return result;
6088 };
6089
6090 /**
6091 * @param {DocumentFragment} templateContent
6092 * @returns {object}
6093 */
6094 const getSwalInput = templateContent => {
6095 /** @type {Record<string, any>} */
6096 const result = {};
6097 /** @type {HTMLElement | null} */
6098 const input = templateContent.querySelector('swal-input');
6099 if (input) {
6100 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6101 result.input = input.getAttribute('type') || 'text';
6102 if (input.hasAttribute('label')) {
6103 result.inputLabel = input.getAttribute('label');
6104 }
6105 if (input.hasAttribute('placeholder')) {
6106 result.inputPlaceholder = input.getAttribute('placeholder');
6107 }
6108 if (input.hasAttribute('value')) {
6109 result.inputValue = input.getAttribute('value');
6110 }
6111 }
6112 /** @type {HTMLElement[]} */
6113 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6114 if (inputOptions.length) {
6115 result.inputOptions = {};
6116 inputOptions.forEach(option => {
6117 showWarningsForAttributes(option, ['value']);
6118 const optionValue = option.getAttribute('value');
6119 if (!optionValue) {
6120 return;
6121 }
6122 const optionName = option.innerHTML;
6123 result.inputOptions[optionValue] = optionName;
6124 });
6125 }
6126 return result;
6127 };
6128
6129 /**
6130 * @param {DocumentFragment} templateContent
6131 * @param {string[]} paramNames
6132 * @returns {Record<string, string>}
6133 */
6134 const getSwalStringParams = (templateContent, paramNames) => {
6135 /** @type {Record<string, string>} */
6136 const result = {};
6137 for (const i in paramNames) {
6138 const paramName = paramNames[i];
6139 /** @type {HTMLElement | null} */
6140 const tag = templateContent.querySelector(paramName);
6141 if (tag) {
6142 showWarningsForAttributes(tag, []);
6143 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6144 }
6145 }
6146 return result;
6147 };
6148
6149 /**
6150 * @param {DocumentFragment} templateContent
6151 */
6152 const showWarningsForElements = templateContent => {
6153 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6154 Array.from(templateContent.children).forEach(el => {
6155 const tagName = el.tagName.toLowerCase();
6156 if (!allowedElements.includes(tagName)) {
6157 warn(`Unrecognized element <${tagName}>`);
6158 }
6159 });
6160 };
6161
6162 /**
6163 * @param {HTMLElement} el
6164 * @param {string[]} allowedAttributes
6165 */
6166 const showWarningsForAttributes = (el, allowedAttributes) => {
6167 Array.from(el.attributes).forEach(attribute => {
6168 if (allowedAttributes.indexOf(attribute.name) === -1) {
6169 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.'}`]);
6170 }
6171 });
6172 };
6173
6174 const SHOW_CLASS_TIMEOUT = 10;
6175
6176 /**
6177 * Open popup, add necessary classes and styles, fix scrollbar
6178 *
6179 * @param {SweetAlertOptions} params
6180 */
6181 const openPopup = params => {
6182 var _globalState$eventEmi, _globalState$eventEmi2;
6183 const container = getContainer();
6184 const popup = getPopup();
6185 if (!container || !popup) {
6186 return;
6187 }
6188 if (typeof params.willOpen === 'function') {
6189 params.willOpen(popup);
6190 }
6191 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6192 const bodyStyles = window.getComputedStyle(document.body);
6193 const initialBodyOverflow = bodyStyles.overflowY;
6194 addClasses(container, popup, params);
6195
6196 // scrolling is 'hidden' until animation is done, after that 'auto'
6197 setTimeout(() => {
6198 setScrollingVisibility(container, popup);
6199 }, SHOW_CLASS_TIMEOUT);
6200 if (isModal()) {
6201 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6202 setAriaHidden();
6203 }
6204
6205 // https://github.com/sweetalert2/sweetalert2/issues/2923
6206 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
6207 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
6208 container.style.pointerEvents = 'auto';
6209 }
6210 if (!isToast() && !globalState.previousActiveElement) {
6211 globalState.previousActiveElement = document.activeElement;
6212 }
6213 if (typeof params.didOpen === 'function') {
6214 const didOpen = params.didOpen;
6215 setTimeout(() => didOpen(popup));
6216 }
6217 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6218 };
6219
6220 /**
6221 * @param {Event} event
6222 */
6223 const swalOpenAnimationFinished = event => {
6224 const popup = getPopup();
6225 if (!popup || event.target !== popup) {
6226 return;
6227 }
6228 const container = getContainer();
6229 if (!container) {
6230 return;
6231 }
6232 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6233 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6234 container.style.overflowY = 'auto';
6235
6236 // no-transition is added in init() in case one swal is opened right after another
6237 removeClass(container, swalClasses['no-transition']);
6238 };
6239
6240 /**
6241 * @param {HTMLElement} container
6242 * @param {HTMLElement} popup
6243 */
6244 const setScrollingVisibility = (container, popup) => {
6245 if (hasCssAnimation(popup)) {
6246 container.style.overflowY = 'hidden';
6247 popup.addEventListener('animationend', swalOpenAnimationFinished);
6248 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6249 } else {
6250 container.style.overflowY = 'auto';
6251 }
6252 };
6253
6254 /**
6255 * @param {HTMLElement} container
6256 * @param {boolean} scrollbarPadding
6257 * @param {string} initialBodyOverflow
6258 */
6259 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6260 iOSfix();
6261 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6262 replaceScrollbarWithPadding(initialBodyOverflow);
6263 }
6264
6265 // sweetalert2/issues/1247
6266 setTimeout(() => {
6267 container.scrollTop = 0;
6268 });
6269 };
6270
6271 /**
6272 * @param {HTMLElement} container
6273 * @param {HTMLElement} popup
6274 * @param {SweetAlertOptions} params
6275 */
6276 const addClasses = (container, popup, params) => {
6277 var _params$showClass;
6278 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6279 addClass(container, params.showClass.backdrop);
6280 }
6281 if (params.animation) {
6282 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6283 popup.style.setProperty('opacity', '0', 'important');
6284 show(popup, 'grid');
6285 setTimeout(() => {
6286 var _params$showClass2;
6287 // Animate popup right after showing it
6288 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6289 addClass(popup, params.showClass.popup);
6290 }
6291 // and remove the opacity workaround
6292 popup.style.removeProperty('opacity');
6293 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6294 } else {
6295 show(popup, 'grid');
6296 }
6297 addClass([document.documentElement, document.body], swalClasses.shown);
6298 if (params.heightAuto && params.backdrop && !params.toast) {
6299 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6300 }
6301 };
6302
6303 var defaultInputValidators = {
6304 /**
6305 * @param {string} string
6306 * @param {string} [validationMessage]
6307 * @returns {Promise<string | void>}
6308 */
6309 email: (string, validationMessage) => {
6310 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6311 },
6312 /**
6313 * @param {string} string
6314 * @param {string} [validationMessage]
6315 * @returns {Promise<string | void>}
6316 */
6317 url: (string, validationMessage) => {
6318 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6319 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');
6320 }
6321 };
6322
6323 /**
6324 * @param {SweetAlertOptions} params
6325 */
6326 function setDefaultInputValidators(params) {
6327 // Use default `inputValidator` for supported input types if not provided
6328 if (params.inputValidator) {
6329 return;
6330 }
6331 if (params.input === 'email') {
6332 params.inputValidator = defaultInputValidators['email'];
6333 }
6334 if (params.input === 'url') {
6335 params.inputValidator = defaultInputValidators['url'];
6336 }
6337 }
6338
6339 /**
6340 * @param {SweetAlertOptions} params
6341 */
6342 function validateCustomTargetElement(params) {
6343 // Determine if the custom target element is valid
6344 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6345 warn('Target parameter is not valid, defaulting to "body"');
6346 params.target = 'body';
6347 }
6348 }
6349
6350 /**
6351 * Set type, text and actions on popup
6352 *
6353 * @param {SweetAlertOptions} params
6354 */
6355 function setParameters(params) {
6356 setDefaultInputValidators(params);
6357
6358 // showLoaderOnConfirm && preConfirm
6359 if (params.showLoaderOnConfirm && !params.preConfirm) {
6360 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');
6361 }
6362 validateCustomTargetElement(params);
6363
6364 // Replace newlines with <br> in title
6365 if (typeof params.title === 'string') {
6366 params.title = params.title.split('\n').join('<br />');
6367 }
6368 init(params);
6369 }
6370
6371 /** @type {SweetAlert} */
6372 let currentInstance;
6373 var _promise = /*#__PURE__*/new WeakMap();
6374 class SweetAlert {
6375 /**
6376 * @param {...(SweetAlertOptions | string)} args
6377 * @this {SweetAlert}
6378 */
6379 constructor(...args) {
6380 /**
6381 * @type {Promise<SweetAlertResult>}
6382 */
6383 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
6384 Promise.resolve({
6385 isConfirmed: false,
6386 isDenied: false,
6387 isDismissed: true
6388 }));
6389 // Prevent run in Node env
6390 if (typeof window === 'undefined') {
6391 return;
6392 }
6393 currentInstance = this;
6394
6395 // @ts-ignore
6396 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6397
6398 /** @type {Readonly<SweetAlertOptions>} */
6399 this.params = outerParams;
6400
6401 /** @type {boolean} */
6402 this.isAwaitingPromise = false;
6403 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6404 }
6405
6406 /**
6407 * @param {any} userParams
6408 * @param {any} mixinParams
6409 */
6410 _main(userParams, mixinParams = {}) {
6411 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6412 if (globalState.currentInstance) {
6413 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6414 const {
6415 isAwaitingPromise
6416 } = globalState.currentInstance;
6417 globalState.currentInstance._destroy();
6418 if (!isAwaitingPromise) {
6419 swalPromiseResolve({
6420 isDismissed: true
6421 });
6422 }
6423 if (isModal()) {
6424 unsetAriaHidden();
6425 }
6426 }
6427 globalState.currentInstance = currentInstance;
6428 const innerParams = prepareParams(userParams, mixinParams);
6429 setParameters(innerParams);
6430 Object.freeze(innerParams);
6431
6432 // clear the previous timer
6433 if (globalState.timeout) {
6434 globalState.timeout.stop();
6435 delete globalState.timeout;
6436 }
6437
6438 // clear the restore focus timeout
6439 clearTimeout(globalState.restoreFocusTimeout);
6440 const domCache = populateDomCache(currentInstance);
6441 render(currentInstance, innerParams);
6442 privateProps.innerParams.set(currentInstance, innerParams);
6443 return swalPromise(currentInstance, domCache, innerParams);
6444 }
6445
6446 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6447 /**
6448 * @param {any} onFulfilled
6449 */
6450 // oxlint-disable-next-line unicorn/no-thenable
6451 then(onFulfilled) {
6452 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6453 }
6454
6455 /**
6456 * @param {any} onFinally
6457 */
6458 finally(onFinally) {
6459 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6460 }
6461 }
6462
6463 /**
6464 * @param {SweetAlert} instance
6465 * @param {DomCache} domCache
6466 * @param {SweetAlertOptions} innerParams
6467 * @returns {Promise<SweetAlertResult>}
6468 */
6469 const swalPromise = (instance, domCache, innerParams) => {
6470 return new Promise((resolve, reject) => {
6471 // functions to handle all closings/dismissals
6472 /**
6473 * @param {DismissReason} dismiss
6474 */
6475 const dismissWith = dismiss => {
6476 instance.close({
6477 isDismissed: true,
6478 dismiss,
6479 isConfirmed: false,
6480 isDenied: false
6481 });
6482 };
6483 privateMethods.swalPromiseResolve.set(instance, resolve);
6484 privateMethods.swalPromiseReject.set(instance, reject);
6485 domCache.confirmButton.onclick = () => {
6486 handleConfirmButtonClick(instance);
6487 };
6488 domCache.denyButton.onclick = () => {
6489 handleDenyButtonClick(instance);
6490 };
6491 domCache.cancelButton.onclick = () => {
6492 handleCancelButtonClick(instance, dismissWith);
6493 };
6494 domCache.closeButton.onclick = () => {
6495 dismissWith(DismissReason.close);
6496 };
6497 handlePopupClick(innerParams, domCache, dismissWith);
6498 addKeydownHandler(globalState, innerParams, dismissWith);
6499 handleInputOptionsAndValue(instance, innerParams);
6500 openPopup(innerParams);
6501 setupTimer(globalState, innerParams, dismissWith);
6502 initFocus(domCache, innerParams);
6503
6504 // Scroll container to top on open (#1247, #1946)
6505 setTimeout(() => {
6506 domCache.container.scrollTop = 0;
6507 });
6508 });
6509 };
6510
6511 /**
6512 * @param {SweetAlertOptions} userParams
6513 * @param {SweetAlertOptions} mixinParams
6514 * @returns {SweetAlertOptions}
6515 */
6516 const prepareParams = (userParams, mixinParams) => {
6517 const templateParams = getTemplateParams(userParams);
6518 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6519 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6520 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6521 if (params.animation === false) {
6522 params.showClass = {
6523 backdrop: 'swal2-noanimation'
6524 };
6525 params.hideClass = {};
6526 }
6527 return params;
6528 };
6529
6530 /**
6531 * @param {SweetAlert} instance
6532 * @returns {DomCache}
6533 */
6534 const populateDomCache = instance => {
6535 const domCache = /** @type {DomCache} */{
6536 popup: (/** @type {HTMLElement} */getPopup()),
6537 container: (/** @type {HTMLElement} */getContainer()),
6538 actions: (/** @type {HTMLElement} */getActions()),
6539 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6540 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6541 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6542 loader: (/** @type {HTMLElement} */getLoader()),
6543 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6544 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6545 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6546 };
6547 privateProps.domCache.set(instance, domCache);
6548 return domCache;
6549 };
6550
6551 /**
6552 * @param {GlobalState} globalState
6553 * @param {SweetAlertOptions} innerParams
6554 * @param {(dismiss: DismissReason) => void} dismissWith
6555 */
6556 const setupTimer = (globalState, innerParams, dismissWith) => {
6557 const timerProgressBar = getTimerProgressBar();
6558 hide(timerProgressBar);
6559 if (innerParams.timer) {
6560 globalState.timeout = new Timer(() => {
6561 dismissWith('timer');
6562 delete globalState.timeout;
6563 }, innerParams.timer);
6564 if (innerParams.timerProgressBar && timerProgressBar) {
6565 show(timerProgressBar);
6566 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6567 setTimeout(() => {
6568 if (globalState.timeout && globalState.timeout.running) {
6569 // timer can be already stopped or unset at this point
6570 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6571 }
6572 });
6573 }
6574 }
6575 };
6576
6577 /**
6578 * Initialize focus in the popup:
6579 *
6580 * 1. If `toast` is `true`, don't steal focus from the document.
6581 * 2. Else if there is an [autofocus] element, focus it.
6582 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6583 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6584 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6585 * 6. Else focus the first focusable element in a popup (if any).
6586 *
6587 * @param {DomCache} domCache
6588 * @param {SweetAlertOptions} innerParams
6589 */
6590 const initFocus = (domCache, innerParams) => {
6591 if (innerParams.toast) {
6592 return;
6593 }
6594 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6595 if (!callIfFunction(innerParams.allowEnterKey)) {
6596 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
6597 domCache.popup.focus();
6598 return;
6599 }
6600 if (focusAutofocus(domCache)) {
6601 return;
6602 }
6603 if (focusButton(domCache, innerParams)) {
6604 return;
6605 }
6606 setFocus(-1, 1);
6607 };
6608
6609 /**
6610 * @param {DomCache} domCache
6611 * @returns {boolean}
6612 */
6613 const focusAutofocus = domCache => {
6614 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6615 for (const autofocusElement of autofocusElements) {
6616 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6617 autofocusElement.focus();
6618 return true;
6619 }
6620 }
6621 return false;
6622 };
6623
6624 /**
6625 * @param {DomCache} domCache
6626 * @param {SweetAlertOptions} innerParams
6627 * @returns {boolean}
6628 */
6629 const focusButton = (domCache, innerParams) => {
6630 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6631 domCache.denyButton.focus();
6632 return true;
6633 }
6634 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6635 domCache.cancelButton.focus();
6636 return true;
6637 }
6638 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6639 domCache.confirmButton.focus();
6640 return true;
6641 }
6642 return false;
6643 };
6644
6645 // Assign instance methods from src/instanceMethods/*.js to prototype
6646 SweetAlert.prototype.disableButtons = disableButtons;
6647 SweetAlert.prototype.enableButtons = enableButtons;
6648 SweetAlert.prototype.getInput = getInput;
6649 SweetAlert.prototype.disableInput = disableInput;
6650 SweetAlert.prototype.enableInput = enableInput;
6651 SweetAlert.prototype.hideLoading = hideLoading;
6652 SweetAlert.prototype.disableLoading = hideLoading;
6653 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6654 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6655 SweetAlert.prototype.close = close;
6656 SweetAlert.prototype.closePopup = close;
6657 SweetAlert.prototype.closeModal = close;
6658 SweetAlert.prototype.closeToast = close;
6659 SweetAlert.prototype.rejectPromise = rejectPromise;
6660 SweetAlert.prototype.update = update;
6661 SweetAlert.prototype._destroy = _destroy;
6662
6663 // Assign static methods from src/staticMethods/*.js to constructor
6664 Object.assign(SweetAlert, staticMethods);
6665
6666 // Proxy to instance methods to constructor, for now, for backwards compatibility
6667 Object.keys(instanceMethods).forEach(key => {
6668 /**
6669 * @param {...(SweetAlertOptions | string | undefined)} args
6670 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6671 */
6672 // @ts-ignore: Dynamic property assignment for backwards compatibility
6673 SweetAlert[key] = function (...args) {
6674 // @ts-ignore
6675 if (currentInstance && currentInstance[key]) {
6676 // @ts-ignore
6677 return currentInstance[key](...args);
6678 }
6679 return undefined;
6680 };
6681 });
6682 SweetAlert.DismissReason = DismissReason;
6683 SweetAlert.version = '11.26.25';
6684
6685 const Swal = SweetAlert;
6686 // @ts-ignore
6687 Swal.default = Swal;
6688
6689 return Swal;
6690
6691 }));
6692 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6693 "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}}");
6694
6695 /***/ },
6696
6697 /***/ "./node_modules/toastify-js/src/toastify.js"
6698 /*!**************************************************!*\
6699 !*** ./node_modules/toastify-js/src/toastify.js ***!
6700 \**************************************************/
6701 (module) {
6702
6703 /*!
6704 * Toastify js 1.12.0
6705 * https://github.com/apvarun/toastify-js
6706 * @license MIT licensed
6707 *
6708 * Copyright (C) 2018 Varun A P
6709 */
6710 (function(root, factory) {
6711 if ( true && module.exports) {
6712 module.exports = factory();
6713 } else {
6714 root.Toastify = factory();
6715 }
6716 })(this, function(global) {
6717 // Object initialization
6718 var Toastify = function(options) {
6719 // Returning a new init object
6720 return new Toastify.lib.init(options);
6721 },
6722 // Library version
6723 version = "1.12.0";
6724
6725 // Set the default global options
6726 Toastify.defaults = {
6727 oldestFirst: true,
6728 text: "Toastify is awesome!",
6729 node: undefined,
6730 duration: 3000,
6731 selector: undefined,
6732 callback: function () {
6733 },
6734 destination: undefined,
6735 newWindow: false,
6736 close: false,
6737 gravity: "toastify-top",
6738 positionLeft: false,
6739 position: '',
6740 backgroundColor: '',
6741 avatar: "",
6742 className: "",
6743 stopOnFocus: true,
6744 onClick: function () {
6745 },
6746 offset: {x: 0, y: 0},
6747 escapeMarkup: true,
6748 ariaLive: 'polite',
6749 style: {background: ''}
6750 };
6751
6752 // Defining the prototype of the object
6753 Toastify.lib = Toastify.prototype = {
6754 toastify: version,
6755
6756 constructor: Toastify,
6757
6758 // Initializing the object with required parameters
6759 init: function(options) {
6760 // Verifying and validating the input object
6761 if (!options) {
6762 options = {};
6763 }
6764
6765 // Creating the options object
6766 this.options = {};
6767
6768 this.toastElement = null;
6769
6770 // Validating the options
6771 this.options.text = options.text || Toastify.defaults.text; // Display message
6772 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6773 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6774 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6775 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6776 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6777 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6778 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6779 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6780 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6781 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6782 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6783 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6784 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6785 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6786 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6787 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6788 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6789 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6790 this.options.style = options.style || Toastify.defaults.style;
6791 if(options.backgroundColor) {
6792 this.options.style.background = options.backgroundColor;
6793 }
6794
6795 // Returning the current object for chaining functions
6796 return this;
6797 },
6798
6799 // Building the DOM element
6800 buildToast: function() {
6801 // Validating if the options are defined
6802 if (!this.options) {
6803 throw "Toastify is not initialized";
6804 }
6805
6806 // Creating the DOM object
6807 var divElement = document.createElement("div");
6808 divElement.className = "toastify on " + this.options.className;
6809
6810 // Positioning toast to left or right or center
6811 if (!!this.options.position) {
6812 divElement.className += " toastify-" + this.options.position;
6813 } else {
6814 // To be depreciated in further versions
6815 if (this.options.positionLeft === true) {
6816 divElement.className += " toastify-left";
6817 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6818 } else {
6819 // Default position
6820 divElement.className += " toastify-right";
6821 }
6822 }
6823
6824 // Assigning gravity of element
6825 divElement.className += " " + this.options.gravity;
6826
6827 if (this.options.backgroundColor) {
6828 // This is being deprecated in favor of using the style HTML DOM property
6829 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
6830 }
6831
6832 // Loop through our style object and apply styles to divElement
6833 for (var property in this.options.style) {
6834 divElement.style[property] = this.options.style[property];
6835 }
6836
6837 // Announce the toast to screen readers
6838 if (this.options.ariaLive) {
6839 divElement.setAttribute('aria-live', this.options.ariaLive)
6840 }
6841
6842 // Adding the toast message/node
6843 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
6844 // If we have a valid node, we insert it
6845 divElement.appendChild(this.options.node)
6846 } else {
6847 if (this.options.escapeMarkup) {
6848 divElement.innerText = this.options.text;
6849 } else {
6850 divElement.innerHTML = this.options.text;
6851 }
6852
6853 if (this.options.avatar !== "") {
6854 var avatarElement = document.createElement("img");
6855 avatarElement.src = this.options.avatar;
6856
6857 avatarElement.className = "toastify-avatar";
6858
6859 if (this.options.position == "left" || this.options.positionLeft === true) {
6860 // Adding close icon on the left of content
6861 divElement.appendChild(avatarElement);
6862 } else {
6863 // Adding close icon on the right of content
6864 divElement.insertAdjacentElement("afterbegin", avatarElement);
6865 }
6866 }
6867 }
6868
6869 // Adding a close icon to the toast
6870 if (this.options.close === true) {
6871 // Create a span for close element
6872 var closeElement = document.createElement("button");
6873 closeElement.type = "button";
6874 closeElement.setAttribute("aria-label", "Close");
6875 closeElement.className = "toast-close";
6876 closeElement.innerHTML = "&#10006;";
6877
6878 // Triggering the removal of toast from DOM on close click
6879 closeElement.addEventListener(
6880 "click",
6881 function(event) {
6882 event.stopPropagation();
6883 this.removeElement(this.toastElement);
6884 window.clearTimeout(this.toastElement.timeOutValue);
6885 }.bind(this)
6886 );
6887
6888 //Calculating screen width
6889 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
6890
6891 // Adding the close icon to the toast element
6892 // Display on the right if screen width is less than or equal to 360px
6893 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
6894 // Adding close icon on the left of content
6895 divElement.insertAdjacentElement("afterbegin", closeElement);
6896 } else {
6897 // Adding close icon on the right of content
6898 divElement.appendChild(closeElement);
6899 }
6900 }
6901
6902 // Clear timeout while toast is focused
6903 if (this.options.stopOnFocus && this.options.duration > 0) {
6904 var self = this;
6905 // stop countdown
6906 divElement.addEventListener(
6907 "mouseover",
6908 function(event) {
6909 window.clearTimeout(divElement.timeOutValue);
6910 }
6911 )
6912 // add back the timeout
6913 divElement.addEventListener(
6914 "mouseleave",
6915 function() {
6916 divElement.timeOutValue = window.setTimeout(
6917 function() {
6918 // Remove the toast from DOM
6919 self.removeElement(divElement);
6920 },
6921 self.options.duration
6922 )
6923 }
6924 )
6925 }
6926
6927 // Adding an on-click destination path
6928 if (typeof this.options.destination !== "undefined") {
6929 divElement.addEventListener(
6930 "click",
6931 function(event) {
6932 event.stopPropagation();
6933 if (this.options.newWindow === true) {
6934 window.open(this.options.destination, "_blank");
6935 } else {
6936 window.location = this.options.destination;
6937 }
6938 }.bind(this)
6939 );
6940 }
6941
6942 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
6943 divElement.addEventListener(
6944 "click",
6945 function(event) {
6946 event.stopPropagation();
6947 this.options.onClick();
6948 }.bind(this)
6949 );
6950 }
6951
6952 // Adding offset
6953 if(typeof this.options.offset === "object") {
6954
6955 var x = getAxisOffsetAValue("x", this.options);
6956 var y = getAxisOffsetAValue("y", this.options);
6957
6958 var xOffset = this.options.position == "left" ? x : "-" + x;
6959 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
6960
6961 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
6962
6963 }
6964
6965 // Returning the generated element
6966 return divElement;
6967 },
6968
6969 // Displaying the toast
6970 showToast: function() {
6971 // Creating the DOM object for the toast
6972 this.toastElement = this.buildToast();
6973
6974 // Getting the root element to with the toast needs to be added
6975 var rootElement;
6976 if (typeof this.options.selector === "string") {
6977 rootElement = document.getElementById(this.options.selector);
6978 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
6979 rootElement = this.options.selector;
6980 } else {
6981 rootElement = document.body;
6982 }
6983
6984 // Validating if root element is present in DOM
6985 if (!rootElement) {
6986 throw "Root element is not defined";
6987 }
6988
6989 // Adding the DOM element
6990 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
6991 rootElement.insertBefore(this.toastElement, elementToInsert);
6992
6993 // Repositioning the toasts in case multiple toasts are present
6994 Toastify.reposition();
6995
6996 if (this.options.duration > 0) {
6997 this.toastElement.timeOutValue = window.setTimeout(
6998 function() {
6999 // Remove the toast from DOM
7000 this.removeElement(this.toastElement);
7001 }.bind(this),
7002 this.options.duration
7003 ); // Binding `this` for function invocation
7004 }
7005
7006 // Supporting function chaining
7007 return this;
7008 },
7009
7010 hideToast: function() {
7011 if (this.toastElement.timeOutValue) {
7012 clearTimeout(this.toastElement.timeOutValue);
7013 }
7014 this.removeElement(this.toastElement);
7015 },
7016
7017 // Removing the element from the DOM
7018 removeElement: function(toastElement) {
7019 // Hiding the element
7020 // toastElement.classList.remove("on");
7021 toastElement.className = toastElement.className.replace(" on", "");
7022
7023 // Removing the element from DOM after transition end
7024 window.setTimeout(
7025 function() {
7026 // remove options node if any
7027 if (this.options.node && this.options.node.parentNode) {
7028 this.options.node.parentNode.removeChild(this.options.node);
7029 }
7030
7031 // Remove the element from the DOM, only when the parent node was not removed before.
7032 if (toastElement.parentNode) {
7033 toastElement.parentNode.removeChild(toastElement);
7034 }
7035
7036 // Calling the callback function
7037 this.options.callback.call(toastElement);
7038
7039 // Repositioning the toasts again
7040 Toastify.reposition();
7041 }.bind(this),
7042 400
7043 ); // Binding `this` for function invocation
7044 },
7045 };
7046
7047 // Positioning the toasts on the DOM
7048 Toastify.reposition = function() {
7049
7050 // Top margins with gravity
7051 var topLeftOffsetSize = {
7052 top: 15,
7053 bottom: 15,
7054 };
7055 var topRightOffsetSize = {
7056 top: 15,
7057 bottom: 15,
7058 };
7059 var offsetSize = {
7060 top: 15,
7061 bottom: 15,
7062 };
7063
7064 // Get all toast messages on the DOM
7065 var allToasts = document.getElementsByClassName("toastify");
7066
7067 var classUsed;
7068
7069 // Modifying the position of each toast element
7070 for (var i = 0; i < allToasts.length; i++) {
7071 // Getting the applied gravity
7072 if (containsClass(allToasts[i], "toastify-top") === true) {
7073 classUsed = "toastify-top";
7074 } else {
7075 classUsed = "toastify-bottom";
7076 }
7077
7078 var height = allToasts[i].offsetHeight;
7079 classUsed = classUsed.substr(9, classUsed.length-1)
7080 // Spacing between toasts
7081 var offset = 15;
7082
7083 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7084
7085 // Show toast in center if screen with less than or equal to 360px
7086 if (width <= 360) {
7087 // Setting the position
7088 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7089
7090 offsetSize[classUsed] += height + offset;
7091 } else {
7092 if (containsClass(allToasts[i], "toastify-left") === true) {
7093 // Setting the position
7094 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7095
7096 topLeftOffsetSize[classUsed] += height + offset;
7097 } else {
7098 // Setting the position
7099 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7100
7101 topRightOffsetSize[classUsed] += height + offset;
7102 }
7103 }
7104 }
7105
7106 // Supporting function chaining
7107 return this;
7108 };
7109
7110 // Helper function to get offset.
7111 function getAxisOffsetAValue(axis, options) {
7112
7113 if(options.offset[axis]) {
7114 if(isNaN(options.offset[axis])) {
7115 return options.offset[axis];
7116 }
7117 else {
7118 return options.offset[axis] + 'px';
7119 }
7120 }
7121
7122 return '0px';
7123
7124 }
7125
7126 function containsClass(elem, yourClass) {
7127 if (!elem || typeof yourClass !== "string") {
7128 return false;
7129 } else if (
7130 elem.className &&
7131 elem.className
7132 .trim()
7133 .split(/\s+/gi)
7134 .indexOf(yourClass) > -1
7135 ) {
7136 return true;
7137 } else {
7138 return false;
7139 }
7140 }
7141
7142 // Setting up the prototype for the init object
7143 Toastify.lib.init.prototype = Toastify.lib;
7144
7145 // Returning the Toastify function to be assigned to the window object/module
7146 return Toastify;
7147 });
7148
7149
7150 /***/ },
7151
7152 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7153 /*!**********************************************************!*\
7154 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7155 \**********************************************************/
7156 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7157
7158 "use strict";
7159 __webpack_require__.r(__webpack_exports__);
7160 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7161 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7162 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7163 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7164 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7165 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7166 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7167 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7168 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7169 /* harmony export */ });
7170 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7171 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7172 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7173 /**
7174 * sifter.js
7175 * Copyright (c) 2013–2020 Brian Reavis & contributors
7176 *
7177 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7178 * file except in compliance with the License. You may obtain a copy of the License at:
7179 * http://www.apache.org/licenses/LICENSE-2.0
7180 *
7181 * Unless required by applicable law or agreed to in writing, software distributed under
7182 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7183 * ANY KIND, either express or implied. See the License for the specific language
7184 * governing permissions and limitations under the License.
7185 *
7186 * @author Brian Reavis <brian@thirdroute.com>
7187 */
7188
7189
7190 class Sifter {
7191 items; // []|{};
7192 settings;
7193 /**
7194 * Textually searches arrays and hashes of objects
7195 * by property (or multiple properties). Designed
7196 * specifically for autocomplete.
7197 *
7198 */
7199 constructor(items, settings) {
7200 this.items = items;
7201 this.settings = settings || { diacritics: true };
7202 }
7203 ;
7204 /**
7205 * Splits a search string into an array of individual
7206 * regexps to be used to match results.
7207 *
7208 */
7209 tokenize(query, respect_word_boundaries, weights) {
7210 if (!query || !query.length)
7211 return [];
7212 const tokens = [];
7213 const words = query.split(/\s+/);
7214 var field_regex;
7215 if (weights) {
7216 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7217 }
7218 words.forEach((word) => {
7219 let field_match;
7220 let field = null;
7221 let regex = null;
7222 // look for "field:query" tokens
7223 if (field_regex && (field_match = word.match(field_regex))) {
7224 field = field_match[1];
7225 word = field_match[2];
7226 }
7227 if (word.length > 0) {
7228 if (this.settings.diacritics) {
7229 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7230 }
7231 else {
7232 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7233 }
7234 if (regex && respect_word_boundaries)
7235 regex = "\\b" + regex;
7236 }
7237 tokens.push({
7238 string: word,
7239 regex: regex ? new RegExp(regex, 'iu') : null,
7240 field: field,
7241 });
7242 });
7243 return tokens;
7244 }
7245 ;
7246 /**
7247 * Returns a function to be used to score individual results.
7248 *
7249 * Good matches will have a higher score than poor matches.
7250 * If an item is not a match, 0 will be returned by the function.
7251 *
7252 * @returns {T.ScoreFn}
7253 */
7254 getScoreFunction(query, options) {
7255 var search = this.prepareSearch(query, options);
7256 return this._getScoreFunction(search);
7257 }
7258 /**
7259 * @returns {T.ScoreFn}
7260 *
7261 */
7262 _getScoreFunction(search) {
7263 const tokens = search.tokens, token_count = tokens.length;
7264 if (!token_count) {
7265 return function () { return 0; };
7266 }
7267 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7268 if (!field_count) {
7269 return function () { return 1; };
7270 }
7271 /**
7272 * Calculates the score of an object
7273 * against the search query.
7274 *
7275 */
7276 const scoreObject = (function () {
7277 if (field_count === 1) {
7278 return function (token, data) {
7279 const field = fields[0].field;
7280 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7281 };
7282 }
7283 return function (token, data) {
7284 var sum = 0;
7285 // is the token specific to a field?
7286 if (token.field) {
7287 const value = getAttrFn(data, token.field);
7288 if (!token.regex && value) {
7289 sum += (1 / field_count);
7290 }
7291 else {
7292 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7293 }
7294 }
7295 else {
7296 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7297 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7298 });
7299 }
7300 return sum / field_count;
7301 };
7302 })();
7303 if (token_count === 1) {
7304 return function (data) {
7305 return scoreObject(tokens[0], data);
7306 };
7307 }
7308 if (search.options.conjunction === 'and') {
7309 return function (data) {
7310 var score, sum = 0;
7311 for (let token of tokens) {
7312 score = scoreObject(token, data);
7313 if (score <= 0)
7314 return 0;
7315 sum += score;
7316 }
7317 return sum / token_count;
7318 };
7319 }
7320 else {
7321 return function (data) {
7322 var sum = 0;
7323 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7324 sum += scoreObject(token, data);
7325 });
7326 return sum / token_count;
7327 };
7328 }
7329 }
7330 ;
7331 /**
7332 * Returns a function that can be used to compare two
7333 * results, for sorting purposes. If no sorting should
7334 * be performed, `null` will be returned.
7335 *
7336 * @return function(a,b)
7337 */
7338 getSortFunction(query, options) {
7339 var search = this.prepareSearch(query, options);
7340 return this._getSortFunction(search);
7341 }
7342 _getSortFunction(search) {
7343 var implicit_score, sort_flds = [];
7344 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
7345 if (typeof sort == 'function') {
7346 return sort.bind(this);
7347 }
7348 /**
7349 * Fetches the specified sort field value
7350 * from a search result item.
7351 *
7352 */
7353 const get_field = function (name, result) {
7354 if (name === '$score')
7355 return result.score;
7356 return search.getAttrFn(self.items[result.id], name);
7357 };
7358 // parse options
7359 if (sort) {
7360 for (let s of sort) {
7361 if (search.query || s.field !== '$score') {
7362 sort_flds.push(s);
7363 }
7364 }
7365 }
7366 // the "$score" field is implied to be the primary
7367 // sort field, unless it's manually specified
7368 if (search.query) {
7369 implicit_score = true;
7370 for (let fld of sort_flds) {
7371 if (fld.field === '$score') {
7372 implicit_score = false;
7373 break;
7374 }
7375 }
7376 if (implicit_score) {
7377 sort_flds.unshift({ field: '$score', direction: 'desc' });
7378 }
7379 // without a search.query, all items will have the same score
7380 }
7381 else {
7382 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
7383 }
7384 // build function
7385 const sort_flds_count = sort_flds.length;
7386 if (!sort_flds_count) {
7387 return null;
7388 }
7389 return function (a, b) {
7390 var result, field;
7391 for (let sort_fld of sort_flds) {
7392 field = sort_fld.field;
7393 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
7394 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
7395 if (result)
7396 return result;
7397 }
7398 return 0;
7399 };
7400 }
7401 ;
7402 /**
7403 * Parses a search query and returns an object
7404 * with tokens and fields ready to be populated
7405 * with results.
7406 *
7407 */
7408 prepareSearch(query, optsUser) {
7409 const weights = {};
7410 var options = Object.assign({}, optsUser);
7411 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
7412 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
7413 // convert fields to new format
7414 if (options.fields) {
7415 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
7416 const fields = [];
7417 options.fields.forEach((field) => {
7418 if (typeof field == 'string') {
7419 field = { field: field, weight: 1 };
7420 }
7421 fields.push(field);
7422 weights[field.field] = ('weight' in field) ? field.weight : 1;
7423 });
7424 options.fields = fields;
7425 }
7426 return {
7427 options: options,
7428 query: query.toLowerCase().trim(),
7429 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
7430 total: 0,
7431 items: [],
7432 weights: weights,
7433 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
7434 };
7435 }
7436 ;
7437 /**
7438 * Searches through all items and returns a sorted array of matches.
7439 *
7440 */
7441 search(query, options) {
7442 var self = this, score, search;
7443 search = this.prepareSearch(query, options);
7444 options = search.options;
7445 query = search.query;
7446 // generate result scoring function
7447 const fn_score = options.score || self._getScoreFunction(search);
7448 // perform search and sort
7449 if (query.length) {
7450 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
7451 score = fn_score(item);
7452 if (options.filter === false || score > 0) {
7453 search.items.push({ 'score': score, 'id': id });
7454 }
7455 });
7456 }
7457 else {
7458 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
7459 search.items.push({ 'score': 1, 'id': id });
7460 });
7461 }
7462 const fn_sort = self._getSortFunction(search);
7463 if (fn_sort)
7464 search.items.sort(fn_sort);
7465 // apply limits
7466 search.total = search.items.length;
7467 if (typeof options.limit === 'number') {
7468 search.items = search.items.slice(0, options.limit);
7469 }
7470 return search;
7471 }
7472 ;
7473 }
7474
7475
7476 //# sourceMappingURL=sifter.js.map
7477
7478 /***/ },
7479
7480 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
7481 /*!*********************************************************!*\
7482 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
7483 \*********************************************************/
7484 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7485
7486 "use strict";
7487 __webpack_require__.r(__webpack_exports__);
7488
7489 //# sourceMappingURL=types.js.map
7490
7491 /***/ },
7492
7493 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
7494 /*!*********************************************************!*\
7495 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
7496 \*********************************************************/
7497 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7498
7499 "use strict";
7500 __webpack_require__.r(__webpack_exports__);
7501 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7502 /* harmony export */ cmp: () => (/* binding */ cmp),
7503 /* harmony export */ getAttr: () => (/* binding */ getAttr),
7504 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
7505 /* harmony export */ iterate: () => (/* binding */ iterate),
7506 /* harmony export */ propToArray: () => (/* binding */ propToArray),
7507 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
7508 /* harmony export */ });
7509 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7510
7511 /**
7512 * A property getter resolving dot-notation
7513 * @param {Object} obj The root object to fetch property on
7514 * @param {String} name The optionally dotted property name to fetch
7515 * @return {Object} The resolved property value
7516 */
7517 const getAttr = (obj, name) => {
7518 if (!obj)
7519 return;
7520 return obj[name];
7521 };
7522 /**
7523 * A property getter resolving dot-notation
7524 * @param {Object} obj The root object to fetch property on
7525 * @param {String} name The optionally dotted property name to fetch
7526 * @return {Object} The resolved property value
7527 */
7528 const getAttrNesting = (obj, name) => {
7529 if (!obj)
7530 return;
7531 var part, names = name.split(".");
7532 while ((part = names.shift()) && (obj = obj[part]))
7533 ;
7534 return obj;
7535 };
7536 /**
7537 * Calculates how close of a match the
7538 * given value is against a search token.
7539 *
7540 */
7541 const scoreValue = (value, token, weight) => {
7542 var score, pos;
7543 if (!value)
7544 return 0;
7545 value = value + '';
7546 if (token.regex == null)
7547 return 0;
7548 pos = value.search(token.regex);
7549 if (pos === -1)
7550 return 0;
7551 score = token.string.length / value.length;
7552 if (pos === 0)
7553 score += 0.5;
7554 return score * weight;
7555 };
7556 /**
7557 * Cast object property to an array if it exists and has a value
7558 *
7559 */
7560 const propToArray = (obj, key) => {
7561 var value = obj[key];
7562 if (typeof value == 'function')
7563 return value;
7564 if (value && !Array.isArray(value)) {
7565 obj[key] = [value];
7566 }
7567 };
7568 /**
7569 * Iterates over arrays and hashes.
7570 *
7571 * ```
7572 * iterate(this.items, function(item, id) {
7573 * // invoked for each item
7574 * });
7575 * ```
7576 *
7577 */
7578 const iterate = (object, callback) => {
7579 if (Array.isArray(object)) {
7580 object.forEach(callback);
7581 }
7582 else {
7583 for (var key in object) {
7584 if (object.hasOwnProperty(key)) {
7585 callback(object[key], key);
7586 }
7587 }
7588 }
7589 };
7590 const cmp = (a, b) => {
7591 if (typeof a === 'number' && typeof b === 'number') {
7592 return a > b ? 1 : (a < b ? -1 : 0);
7593 }
7594 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
7595 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
7596 if (a > b)
7597 return 1;
7598 if (b > a)
7599 return -1;
7600 return 0;
7601 };
7602 //# sourceMappingURL=utils.js.map
7603
7604 /***/ },
7605
7606 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
7607 /*!*******************************************************************!*\
7608 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
7609 \*******************************************************************/
7610 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7611
7612 "use strict";
7613 __webpack_require__.r(__webpack_exports__);
7614 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7615 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
7616 /* harmony export */ asciifold: () => (/* binding */ asciifold),
7617 /* harmony export */ code_points: () => (/* binding */ code_points),
7618 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
7619 /* harmony export */ generateMap: () => (/* binding */ generateMap),
7620 /* harmony export */ generateSets: () => (/* binding */ generateSets),
7621 /* harmony export */ generator: () => (/* binding */ generator),
7622 /* harmony export */ getPattern: () => (/* binding */ getPattern),
7623 /* harmony export */ initialize: () => (/* binding */ initialize),
7624 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
7625 /* harmony export */ normalize: () => (/* binding */ normalize),
7626 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
7627 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
7628 /* harmony export */ });
7629 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
7630 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
7631
7632
7633 const code_points = [[0, 65535]];
7634 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
7635 let unicode_map;
7636 let multi_char_reg;
7637 const max_char_length = 3;
7638 const latin_convert = {};
7639 const latin_condensed = {
7640 '/': '⁄∕',
7641 '0': '߀',
7642 "a": "ⱥɐɑ",
7643 "aa": "ꜳ",
7644 "ae": "æǽǣ",
7645 "ao": "ꜵ",
7646 "au": "ꜷ",
7647 "av": "ꜹꜻ",
7648 "ay": "ꜽ",
7649 "b": "ƀɓƃ",
7650 "c": "ꜿƈȼↄ",
7651 "d": "đɗɖᴅƌꮷԁɦ",
7652 "e": "ɛǝᴇɇ",
7653 "f": "ꝼƒ",
7654 "g": "ǥɠꞡᵹꝿɢ",
7655 "h": "ħⱨⱶɥ",
7656 "i": "ɨı",
7657 "j": "ɉȷ",
7658 "k": "ƙⱪꝁꝃꝅꞣ",
7659 "l": "łƚɫⱡꝉꝇꞁɭ",
7660 "m": "ɱɯϻ",
7661 "n": "ꞥƞɲꞑᴎлԉ",
7662 "o": "øǿɔɵꝋꝍᴑ",
7663 "oe": "œ",
7664 "oi": "ƣ",
7665 "oo": "ꝏ",
7666 "ou": "ȣ",
7667 "p": "ƥᵽꝑꝓꝕρ",
7668 "q": "ꝗꝙɋ",
7669 "r": "ɍɽꝛꞧꞃ",
7670 "s": "ßȿꞩꞅʂ",
7671 "t": "ŧƭʈⱦꞇ",
7672 "th": "þ",
7673 "tz": "ꜩ",
7674 "u": "ʉ",
7675 "v": "ʋꝟʌ",
7676 "vy": "ꝡ",
7677 "w": "ⱳ",
7678 "y": "ƴɏỿ",
7679 "z": "ƶȥɀⱬꝣ",
7680 "hv": "ƕ"
7681 };
7682 for (let latin in latin_condensed) {
7683 let unicode = latin_condensed[latin] || '';
7684 for (let i = 0; i < unicode.length; i++) {
7685 let char = unicode.substring(i, i + 1);
7686 latin_convert[char] = latin;
7687 }
7688 }
7689 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
7690 /**
7691 * Initialize the unicode_map from the give code point ranges
7692 */
7693 const initialize = (_code_points) => {
7694 if (unicode_map !== undefined)
7695 return;
7696 unicode_map = generateMap(_code_points || code_points);
7697 };
7698 /**
7699 * Helper method for normalize a string
7700 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
7701 */
7702 const normalize = (str, form = 'NFKD') => str.normalize(form);
7703 /**
7704 * Remove accents without reordering string
7705 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
7706 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
7707 */
7708 const asciifold = (str) => {
7709 return Array.from(str).reduce(
7710 /**
7711 * @param {string} result
7712 * @param {string} char
7713 */
7714 (result, char) => {
7715 return result + _asciifold(char);
7716 }, '');
7717 };
7718 const _asciifold = (str) => {
7719 str = normalize(str)
7720 .toLowerCase()
7721 .replace(convert_pat, (/** @type {string} */ char) => {
7722 return latin_convert[char] || '';
7723 });
7724 //return str;
7725 return normalize(str, 'NFC');
7726 };
7727 /**
7728 * Generate a list of unicode variants from the list of code points
7729 */
7730 function* generator(code_points) {
7731 for (const [code_point_min, code_point_max] of code_points) {
7732 for (let i = code_point_min; i <= code_point_max; i++) {
7733 let composed = String.fromCharCode(i);
7734 let folded = asciifold(composed);
7735 if (folded == composed.toLowerCase()) {
7736 continue;
7737 }
7738 // skip when folded is a string longer than 3 characters long
7739 // bc the resulting regex patterns will be long
7740 // eg:
7741 // folded صلى الله عليه وسلم length 18 code point 65018
7742 // folded جل جلاله length 8 code point 65019
7743 if (folded.length > max_char_length) {
7744 continue;
7745 }
7746 if (folded.length == 0) {
7747 continue;
7748 }
7749 yield { folded: folded, composed: composed, code_point: i };
7750 }
7751 }
7752 }
7753 /**
7754 * Generate a unicode map from the list of code points
7755 */
7756 const generateSets = (code_points) => {
7757 const unicode_sets = {};
7758 const addMatching = (folded, to_add) => {
7759 /** @type {Set<string>} */
7760 const folded_set = unicode_sets[folded] || new Set();
7761 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
7762 if (to_add.match(patt)) {
7763 return;
7764 }
7765 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
7766 unicode_sets[folded] = folded_set;
7767 };
7768 for (let value of generator(code_points)) {
7769 addMatching(value.folded, value.folded);
7770 addMatching(value.folded, value.composed);
7771 }
7772 return unicode_sets;
7773 };
7774 /**
7775 * Generate a unicode map from the list of code points
7776 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
7777 */
7778 const generateMap = (code_points) => {
7779 const unicode_sets = generateSets(code_points);
7780 const unicode_map = {};
7781 let multi_char = [];
7782 for (let folded in unicode_sets) {
7783 let set = unicode_sets[folded];
7784 if (set) {
7785 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
7786 }
7787 if (folded.length > 1) {
7788 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
7789 }
7790 }
7791 multi_char.sort((a, b) => b.length - a.length);
7792 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
7793 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
7794 return unicode_map;
7795 };
7796 /**
7797 * Map each element of an array from its folded value to all possible unicode matches
7798 */
7799 const mapSequence = (strings, min_replacement = 1) => {
7800 let chars_replaced = 0;
7801 strings = strings.map((str) => {
7802 if (unicode_map[str]) {
7803 chars_replaced += str.length;
7804 }
7805 return unicode_map[str] || str;
7806 });
7807 if (chars_replaced >= min_replacement) {
7808 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
7809 }
7810 return '';
7811 };
7812 /**
7813 * Convert a short string and split it into all possible patterns
7814 * Keep a pattern only if min_replacement is met
7815 *
7816 * 'abc'
7817 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
7818 * => ['abc-pattern','ab-c-pattern'...]
7819 */
7820 const substringsToPattern = (str, min_replacement = 1) => {
7821 min_replacement = Math.max(min_replacement, str.length - 1);
7822 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
7823 return mapSequence(sub_pat, min_replacement);
7824 }));
7825 };
7826 /**
7827 * Convert an array of sequences into a pattern
7828 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
7829 */
7830 const sequencesToPattern = (sequences, all = true) => {
7831 let min_replacement = sequences.length > 1 ? 1 : 0;
7832 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
7833 let seq = [];
7834 const len = all ? sequence.length() : sequence.length() - 1;
7835 for (let j = 0; j < len; j++) {
7836 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
7837 }
7838 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
7839 }));
7840 };
7841 /**
7842 * Return true if the sequence is already in the sequences
7843 */
7844 const inSequences = (needle_seq, sequences) => {
7845 for (const seq of sequences) {
7846 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
7847 continue;
7848 }
7849 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
7850 continue;
7851 }
7852 let needle_parts = needle_seq.parts;
7853 const filter = (part) => {
7854 for (const needle_part of needle_parts) {
7855 if (needle_part.start === part.start && needle_part.substr === part.substr) {
7856 return false;
7857 }
7858 if (part.length == 1 || needle_part.length == 1) {
7859 continue;
7860 }
7861 // check for overlapping parts
7862 // a = ['::=','==']
7863 // b = ['::','===']
7864 // a = ['r','sm']
7865 // b = ['rs','m']
7866 if (part.start < needle_part.start && part.end > needle_part.start) {
7867 return true;
7868 }
7869 if (needle_part.start < part.start && needle_part.end > part.start) {
7870 return true;
7871 }
7872 }
7873 return false;
7874 };
7875 let filtered = seq.parts.filter(filter);
7876 if (filtered.length > 0) {
7877 continue;
7878 }
7879 return true;
7880 }
7881 return false;
7882 };
7883 class Sequence {
7884 parts;
7885 substrs;
7886 start;
7887 end;
7888 constructor() {
7889 this.parts = [];
7890 this.substrs = [];
7891 this.start = 0;
7892 this.end = 0;
7893 }
7894 add(part) {
7895 if (part) {
7896 this.parts.push(part);
7897 this.substrs.push(part.substr);
7898 this.start = Math.min(part.start, this.start);
7899 this.end = Math.max(part.end, this.end);
7900 }
7901 }
7902 last() {
7903 return this.parts[this.parts.length - 1];
7904 }
7905 length() {
7906 return this.parts.length;
7907 }
7908 clone(position, last_piece) {
7909 let clone = new Sequence();
7910 let parts = JSON.parse(JSON.stringify(this.parts));
7911 let last_part = parts.pop();
7912 for (const part of parts) {
7913 clone.add(part);
7914 }
7915 let last_substr = last_piece.substr.substring(0, position - last_part.start);
7916 let clone_last_len = last_substr.length;
7917 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
7918 return clone;
7919 }
7920 }
7921 /**
7922 * Expand a regular expression pattern to include unicode variants
7923 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
7924 *
7925 * Issue:
7926 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
7927 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
7928 *
7929 * İIJ = IIJ = ⅡJ
7930 *
7931 * 1/2/4
7932 */
7933 const getPattern = (str) => {
7934 initialize();
7935 str = asciifold(str);
7936 let pattern = '';
7937 let sequences = [new Sequence()];
7938 for (let i = 0; i < str.length; i++) {
7939 let substr = str.substring(i);
7940 let match = substr.match(multi_char_reg);
7941 const char = str.substring(i, i + 1);
7942 const match_str = match ? match[0] : null;
7943 // loop through sequences
7944 // add either the char or multi_match
7945 let overlapping = [];
7946 let added_types = new Set();
7947 for (const sequence of sequences) {
7948 const last_piece = sequence.last();
7949 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
7950 // if we have a multi match
7951 if (match_str) {
7952 const len = match_str.length;
7953 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
7954 added_types.add('1');
7955 }
7956 else {
7957 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
7958 added_types.add('2');
7959 }
7960 }
7961 else if (match_str) {
7962 let clone = sequence.clone(i, last_piece);
7963 const len = match_str.length;
7964 clone.add({ start: i, end: i + len, length: len, substr: match_str });
7965 overlapping.push(clone);
7966 }
7967 else {
7968 // don't add char
7969 // adding would create invalid patterns: 234 => [2,34,4]
7970 added_types.add('3');
7971 }
7972 }
7973 // if we have overlapping
7974 if (overlapping.length > 0) {
7975 // ['ii','iii'] before ['i','i','iii']
7976 overlapping = overlapping.sort((a, b) => {
7977 return a.length() - b.length();
7978 });
7979 for (let clone of overlapping) {
7980 // don't add if we already have an equivalent sequence
7981 if (inSequences(clone, sequences)) {
7982 continue;
7983 }
7984 sequences.push(clone);
7985 }
7986 continue;
7987 }
7988 // if we haven't done anything unique
7989 // clean up the patterns
7990 // helps keep patterns smaller
7991 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
7992 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
7993 pattern += sequencesToPattern(sequences, false);
7994 let new_seq = new Sequence();
7995 const old_seq = sequences[0];
7996 if (old_seq) {
7997 new_seq.add(old_seq.last());
7998 }
7999 sequences = [new_seq];
8000 }
8001 }
8002 pattern += sequencesToPattern(sequences, true);
8003 return pattern;
8004 };
8005
8006 //# sourceMappingURL=index.js.map
8007
8008 /***/ },
8009
8010 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8011 /*!*******************************************************************!*\
8012 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8013 \*******************************************************************/
8014 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8015
8016 "use strict";
8017 __webpack_require__.r(__webpack_exports__);
8018 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8019 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8020 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8021 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8022 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8023 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8024 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8025 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8026 /* harmony export */ });
8027 /**
8028 * Convert array of strings to a regular expression
8029 * ex ['ab','a'] => (?:ab|a)
8030 * ex ['a','b'] => [ab]
8031 */
8032 const arrayToPattern = (chars) => {
8033 chars = chars.filter(Boolean);
8034 if (chars.length < 2) {
8035 return chars[0] || '';
8036 }
8037 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8038 };
8039 const sequencePattern = (array) => {
8040 if (!hasDuplicates(array)) {
8041 return array.join('');
8042 }
8043 let pattern = '';
8044 let prev_char_count = 0;
8045 const prev_pattern = () => {
8046 if (prev_char_count > 1) {
8047 pattern += '{' + prev_char_count + '}';
8048 }
8049 };
8050 array.forEach((char, i) => {
8051 if (char === array[i - 1]) {
8052 prev_char_count++;
8053 return;
8054 }
8055 prev_pattern();
8056 pattern += char;
8057 prev_char_count = 1;
8058 });
8059 prev_pattern();
8060 return pattern;
8061 };
8062 /**
8063 * Convert array of strings to a regular expression
8064 * ex ['ab','a'] => (?:ab|a)
8065 * ex ['a','b'] => [ab]
8066 */
8067 const setToPattern = (chars) => {
8068 let array = Array.from(chars);
8069 return arrayToPattern(array);
8070 };
8071 /**
8072 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8073 */
8074 const hasDuplicates = (array) => {
8075 return (new Set(array)).size !== array.length;
8076 };
8077 /**
8078 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8079 */
8080 const escape_regex = (str) => {
8081 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8082 };
8083 /**
8084 * Return the max length of array values
8085 */
8086 const maxValueLength = (array) => {
8087 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8088 };
8089 const unicodeLength = (str) => {
8090 return Array.from(str).length;
8091 };
8092 //# sourceMappingURL=regex.js.map
8093
8094 /***/ },
8095
8096 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8097 /*!*********************************************************************!*\
8098 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8099 \*********************************************************************/
8100 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8101
8102 "use strict";
8103 __webpack_require__.r(__webpack_exports__);
8104 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8105 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8106 /* harmony export */ });
8107 /**
8108 * Get all possible combinations of substrings that add up to the given string
8109 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8110 */
8111 const allSubstrings = (input) => {
8112 if (input.length === 1)
8113 return [[input]];
8114 let result = [];
8115 const start = input.substring(1);
8116 const suba = allSubstrings(start);
8117 suba.forEach(function (subresult) {
8118 let tmp = subresult.slice(0);
8119 tmp[0] = input.charAt(0) + tmp[0];
8120 result.push(tmp);
8121 tmp = subresult.slice(0);
8122 tmp.unshift(input.charAt(0));
8123 result.push(tmp);
8124 });
8125 return result;
8126 };
8127 //# sourceMappingURL=strings.js.map
8128
8129 /***/ },
8130
8131 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8132 /*!*******************************************************!*\
8133 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8134 \*******************************************************/
8135 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8136
8137 "use strict";
8138 __webpack_require__.r(__webpack_exports__);
8139 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8140 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8141 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8142 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8143 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8144 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8145 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8146 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8147 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8148 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8149 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8150 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8151 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8152 /* harmony export */ });
8153 const KEY_A = 65;
8154 const KEY_RETURN = 13;
8155 const KEY_ESC = 27;
8156 const KEY_LEFT = 37;
8157 const KEY_UP = 38;
8158 const KEY_RIGHT = 39;
8159 const KEY_DOWN = 40;
8160 const KEY_BACKSPACE = 8;
8161 const KEY_DELETE = 46;
8162 const KEY_TAB = 9;
8163 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8164 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8165 //# sourceMappingURL=constants.js.map
8166
8167 /***/ },
8168
8169 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8170 /*!***************************************************************!*\
8171 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8172 \***************************************************************/
8173 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8174
8175 "use strict";
8176 __webpack_require__.r(__webpack_exports__);
8177 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8178 /* harmony export */ highlight: () => (/* binding */ highlight),
8179 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8180 /* harmony export */ });
8181 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8182 /**
8183 * highlight v3 | MIT license | Johann Burkard <jb@eaio.com>
8184 * Highlights arbitrary terms in a node.
8185 *
8186 * - Modified by Marshal <beatgates@gmail.com> 2011-6-24 (added regex)
8187 * - Modified by Brian Reavis <brian@thirdroute.com> 2012-8-27 (cleanup)
8188 */
8189
8190 const highlight = (element, regex) => {
8191 if (regex === null)
8192 return;
8193 // convet string to regex
8194 if (typeof regex === 'string') {
8195 if (!regex.length)
8196 return;
8197 regex = new RegExp(regex, 'i');
8198 }
8199 // Wrap matching part of text node with highlighting <span>, e.g.
8200 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8201 const highlightText = (node) => {
8202 var match = node.data.match(regex);
8203 if (match && node.data.length > 0) {
8204 var spannode = document.createElement('span');
8205 spannode.className = 'highlight';
8206 var middlebit = node.splitText(match.index);
8207 middlebit.splitText(match[0].length);
8208 var middleclone = middlebit.cloneNode(true);
8209 spannode.appendChild(middleclone);
8210 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8211 return 1;
8212 }
8213 return 0;
8214 };
8215 // Recurse element node, looking for child text nodes to highlight, unless element
8216 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8217 const highlightChildren = (node) => {
8218 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8219 Array.from(node.childNodes).forEach(element => {
8220 highlightRecursive(element);
8221 });
8222 }
8223 };
8224 const highlightRecursive = (node) => {
8225 if (node.nodeType === 3) {
8226 return highlightText(node);
8227 }
8228 highlightChildren(node);
8229 return 0;
8230 };
8231 highlightRecursive(element);
8232 };
8233 /**
8234 * removeHighlight fn copied from highlight v5 and
8235 * edited to remove with(), pass js strict mode, and use without jquery
8236 */
8237 const removeHighlight = (el) => {
8238 var elements = el.querySelectorAll("span.highlight");
8239 Array.prototype.forEach.call(elements, function (el) {
8240 var parent = el.parentNode;
8241 parent.replaceChild(el.firstChild, el);
8242 parent.normalize();
8243 });
8244 };
8245 //# sourceMappingURL=highlight.js.map
8246
8247 /***/ },
8248
8249 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8250 /*!****************************************************************!*\
8251 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8252 \****************************************************************/
8253 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8254
8255 "use strict";
8256 __webpack_require__.r(__webpack_exports__);
8257 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8258 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8259 /* harmony export */ });
8260 /**
8261 * MicroEvent - to make any js object an event emitter
8262 *
8263 * - pure javascript - server compatible, browser compatible
8264 * - dont rely on the browser doms
8265 * - super simple - you get it immediatly, no mistery, no magic involved
8266 *
8267 * @author Jerome Etienne (https://github.com/jeromeetienne)
8268 */
8269 /**
8270 * Execute callback for each event in space separated list of event names
8271 *
8272 */
8273 function forEvents(events, callback) {
8274 events.split(/\s+/).forEach((event) => {
8275 callback(event);
8276 });
8277 }
8278 class MicroEvent {
8279 constructor() {
8280 this._events = {};
8281 }
8282 on(events, fct) {
8283 forEvents(events, (event) => {
8284 const event_array = this._events[event] || [];
8285 event_array.push(fct);
8286 this._events[event] = event_array;
8287 });
8288 }
8289 off(events, fct) {
8290 var n = arguments.length;
8291 if (n === 0) {
8292 this._events = {};
8293 return;
8294 }
8295 forEvents(events, (event) => {
8296 if (n === 1) {
8297 delete this._events[event];
8298 return;
8299 }
8300 const event_array = this._events[event];
8301 if (event_array === undefined)
8302 return;
8303 event_array.splice(event_array.indexOf(fct), 1);
8304 this._events[event] = event_array;
8305 });
8306 }
8307 trigger(events, ...args) {
8308 var self = this;
8309 forEvents(events, (event) => {
8310 const event_array = self._events[event];
8311 if (event_array === undefined)
8312 return;
8313 event_array.forEach(fct => {
8314 fct.apply(self, args);
8315 });
8316 });
8317 }
8318 }
8319 ;
8320 //# sourceMappingURL=microevent.js.map
8321
8322 /***/ },
8323
8324 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
8325 /*!*****************************************************************!*\
8326 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
8327 \*****************************************************************/
8328 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8329
8330 "use strict";
8331 __webpack_require__.r(__webpack_exports__);
8332 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8333 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
8334 /* harmony export */ });
8335 /**
8336 * microplugin.js
8337 * Copyright (c) 2013 Brian Reavis & contributors
8338 *
8339 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8340 * file except in compliance with the License. You may obtain a copy of the License at:
8341 * http://www.apache.org/licenses/LICENSE-2.0
8342 *
8343 * Unless required by applicable law or agreed to in writing, software distributed under
8344 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8345 * ANY KIND, either express or implied. See the License for the specific language
8346 * governing permissions and limitations under the License.
8347 *
8348 * @author Brian Reavis <brian@thirdroute.com>
8349 */
8350 function MicroPlugin(Interface) {
8351 Interface.plugins = {};
8352 return class extends Interface {
8353 constructor() {
8354 super(...arguments);
8355 this.plugins = {
8356 names: [],
8357 settings: {},
8358 requested: {},
8359 loaded: {}
8360 };
8361 }
8362 /**
8363 * Registers a plugin.
8364 *
8365 * @param {function} fn
8366 */
8367 static define(name, fn) {
8368 Interface.plugins[name] = {
8369 'name': name,
8370 'fn': fn
8371 };
8372 }
8373 /**
8374 * Initializes the listed plugins (with options).
8375 * Acceptable formats:
8376 *
8377 * List (without options):
8378 * ['a', 'b', 'c']
8379 *
8380 * List (with options):
8381 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
8382 *
8383 * Hash (with options):
8384 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
8385 *
8386 * @param {array|object} plugins
8387 */
8388 initializePlugins(plugins) {
8389 var key, name;
8390 const self = this;
8391 const queue = [];
8392 if (Array.isArray(plugins)) {
8393 plugins.forEach((plugin) => {
8394 if (typeof plugin === 'string') {
8395 queue.push(plugin);
8396 }
8397 else {
8398 self.plugins.settings[plugin.name] = plugin.options;
8399 queue.push(plugin.name);
8400 }
8401 });
8402 }
8403 else if (plugins) {
8404 for (key in plugins) {
8405 if (plugins.hasOwnProperty(key)) {
8406 self.plugins.settings[key] = plugins[key];
8407 queue.push(key);
8408 }
8409 }
8410 }
8411 while (name = queue.shift()) {
8412 self.require(name);
8413 }
8414 }
8415 loadPlugin(name) {
8416 var self = this;
8417 var plugins = self.plugins;
8418 var plugin = Interface.plugins[name];
8419 if (!Interface.plugins.hasOwnProperty(name)) {
8420 throw new Error('Unable to find "' + name + '" plugin');
8421 }
8422 plugins.requested[name] = true;
8423 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
8424 plugins.names.push(name);
8425 }
8426 /**
8427 * Initializes a plugin.
8428 *
8429 */
8430 require(name) {
8431 var self = this;
8432 var plugins = self.plugins;
8433 if (!self.plugins.loaded.hasOwnProperty(name)) {
8434 if (plugins.requested[name]) {
8435 throw new Error('Plugin has circular dependency ("' + name + '")');
8436 }
8437 self.loadPlugin(name);
8438 }
8439 return plugins.loaded[name];
8440 }
8441 };
8442 }
8443 //# sourceMappingURL=microplugin.js.map
8444
8445 /***/ },
8446
8447 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
8448 /*!******************************************************!*\
8449 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
8450 \******************************************************/
8451 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8452
8453 "use strict";
8454 __webpack_require__.r(__webpack_exports__);
8455 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8456 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8457 /* harmony export */ });
8458 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
8459 options: [],
8460 optgroups: [],
8461 plugins: [],
8462 delimiter: ',',
8463 splitOn: null, // regexp or string for splitting up values from a paste command
8464 persist: true,
8465 diacritics: true,
8466 create: null,
8467 createOnBlur: false,
8468 createFilter: null,
8469 clearAfterSelect: false,
8470 highlight: true,
8471 openOnFocus: true,
8472 shouldOpen: null,
8473 maxOptions: 50,
8474 maxItems: null,
8475 hideSelected: null,
8476 duplicates: false,
8477 addPrecedence: false,
8478 selectOnTab: false,
8479 preload: null,
8480 allowEmptyOption: false,
8481 //closeAfterSelect: false,
8482 refreshThrottle: 300,
8483 loadThrottle: 300,
8484 loadingClass: 'loading',
8485 dataAttr: null, //'data-data',
8486 optgroupField: 'optgroup',
8487 valueField: 'value',
8488 labelField: 'text',
8489 disabledField: 'disabled',
8490 optgroupLabelField: 'label',
8491 optgroupValueField: 'value',
8492 lockOptgroupOrder: false,
8493 sortField: '$order',
8494 searchField: ['text'],
8495 searchConjunction: 'and',
8496 mode: null,
8497 wrapperClass: 'ts-wrapper',
8498 controlClass: 'ts-control',
8499 dropdownClass: 'ts-dropdown',
8500 dropdownContentClass: 'ts-dropdown-content',
8501 itemClass: 'item',
8502 optionClass: 'option',
8503 dropdownParent: null,
8504 controlInput: '<input type="text" autocomplete="off" size="1" />',
8505 copyClassesToDropdown: false,
8506 placeholder: null,
8507 hidePlaceholder: null,
8508 shouldLoad: function (query) {
8509 return query.length > 0;
8510 },
8511 /*
8512 load : null, // function(query, callback) { ... }
8513 score : null, // function(search) { ... }
8514 onInitialize : null, // function() { ... }
8515 onChange : null, // function(value) { ... }
8516 onItemAdd : null, // function(value, $item) { ... }
8517 onItemRemove : null, // function(value) { ... }
8518 onClear : null, // function() { ... }
8519 onOptionAdd : null, // function(value, data) { ... }
8520 onOptionRemove : null, // function(value) { ... }
8521 onOptionClear : null, // function() { ... }
8522 onOptionGroupAdd : null, // function(id, data) { ... }
8523 onOptionGroupRemove : null, // function(id) { ... }
8524 onOptionGroupClear : null, // function() { ... }
8525 onDropdownOpen : null, // function(dropdown) { ... }
8526 onDropdownClose : null, // function(dropdown) { ... }
8527 onType : null, // function(str) { ... }
8528 onDelete : null, // function(values) { ... }
8529 */
8530 render: {
8531 /*
8532 item: null,
8533 optgroup: null,
8534 optgroup_header: null,
8535 option: null,
8536 option_create: null
8537 */
8538 }
8539 });
8540 //# sourceMappingURL=defaults.js.map
8541
8542 /***/ },
8543
8544 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
8545 /*!*********************************************************!*\
8546 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
8547 \*********************************************************/
8548 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8549
8550 "use strict";
8551 __webpack_require__.r(__webpack_exports__);
8552 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8553 /* harmony export */ "default": () => (/* binding */ getSettings)
8554 /* harmony export */ });
8555 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
8556 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8557
8558
8559 function getSettings(input, settings_user) {
8560 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
8561 var attr_data = settings.dataAttr;
8562 var field_label = settings.labelField;
8563 var field_value = settings.valueField;
8564 var field_disabled = settings.disabledField;
8565 var field_optgroup = settings.optgroupField;
8566 var field_optgroup_label = settings.optgroupLabelField;
8567 var field_optgroup_value = settings.optgroupValueField;
8568 var tag_name = input.tagName.toLowerCase();
8569 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
8570 if (!placeholder && !settings.allowEmptyOption) {
8571 let option = input.querySelector('option[value=""]');
8572 if (option) {
8573 placeholder = option.textContent;
8574 }
8575 }
8576 var settings_element = {
8577 placeholder: placeholder,
8578 options: [],
8579 optgroups: [],
8580 items: [],
8581 maxItems: null,
8582 };
8583 /**
8584 * Initialize from a <select> element.
8585 *
8586 */
8587 var init_select = () => {
8588 var tagName;
8589 var options = settings_element.options;
8590 var optionsMap = {};
8591 var group_count = 1;
8592 let $order = 0;
8593 var readData = (el) => {
8594 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
8595 var json = attr_data && data[attr_data];
8596 if (typeof json === 'string' && json.length) {
8597 data = Object.assign(data, JSON.parse(json));
8598 }
8599 return data;
8600 };
8601 var addOption = (option, group) => {
8602 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
8603 if (value == null)
8604 return;
8605 if (!value && !settings.allowEmptyOption)
8606 return;
8607 // if the option already exists, it's probably been
8608 // duplicated in another optgroup. in this case, push
8609 // the current group to the "optgroup" property on the
8610 // existing option so that it's rendered in both places.
8611 if (optionsMap.hasOwnProperty(value)) {
8612 if (group) {
8613 var arr = optionsMap[value][field_optgroup];
8614 if (!arr) {
8615 optionsMap[value][field_optgroup] = group;
8616 }
8617 else if (!Array.isArray(arr)) {
8618 optionsMap[value][field_optgroup] = [arr, group];
8619 }
8620 else {
8621 arr.push(group);
8622 }
8623 }
8624 }
8625 else {
8626 var option_data = readData(option);
8627 option_data[field_label] = option_data[field_label] || option.textContent;
8628 option_data[field_value] = option_data[field_value] || value;
8629 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
8630 option_data[field_optgroup] = option_data[field_optgroup] || group;
8631 option_data.$option = option;
8632 option_data.$order = option_data.$order || ++$order;
8633 optionsMap[value] = option_data;
8634 options.push(option_data);
8635 }
8636 if (option.selected) {
8637 settings_element.items.push(value);
8638 }
8639 };
8640 var addGroup = (optgroup) => {
8641 var id, optgroup_data;
8642 optgroup_data = readData(optgroup);
8643 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
8644 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
8645 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
8646 optgroup_data.$order = optgroup_data.$order || ++$order;
8647 settings_element.optgroups.push(optgroup_data);
8648 id = optgroup_data[field_optgroup_value];
8649 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
8650 addOption(option, id);
8651 });
8652 };
8653 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
8654 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
8655 tagName = child.tagName.toLowerCase();
8656 if (tagName === 'optgroup') {
8657 addGroup(child);
8658 }
8659 else if (tagName === 'option') {
8660 addOption(child);
8661 }
8662 });
8663 };
8664 /**
8665 * Initialize from a <input type="text"> element.
8666 *
8667 */
8668 var init_textbox = () => {
8669 var _a, _b;
8670 const data_raw = input.getAttribute(attr_data);
8671 if (!data_raw) {
8672 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 : '';
8673 if (!settings.allowEmptyOption && !value.length)
8674 return;
8675 const values = value.split(settings.delimiter);
8676 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
8677 const option = {};
8678 option[field_label] = value;
8679 option[field_value] = value;
8680 settings_element.options.push(option);
8681 });
8682 settings_element.items = values;
8683 }
8684 else {
8685 settings_element.options = JSON.parse(data_raw);
8686 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
8687 settings_element.items.push(opt[field_value]);
8688 });
8689 }
8690 };
8691 if (tag_name === 'select') {
8692 init_select();
8693 }
8694 else {
8695 init_textbox();
8696 }
8697 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
8698 }
8699 ;
8700 //# sourceMappingURL=getSettings.js.map
8701
8702 /***/ },
8703
8704 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
8705 /*!***************************************************************************!*\
8706 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
8707 \***************************************************************************/
8708 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8709
8710 "use strict";
8711 __webpack_require__.r(__webpack_exports__);
8712 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8713 /* harmony export */ "default": () => (/* binding */ plugin)
8714 /* harmony export */ });
8715 /**
8716 * Tom Select v2.6.2
8717 * Licensed under the Apache License, Version 2.0 (the "License");
8718 */
8719
8720 /**
8721 * Converts a scalar to its best string representation
8722 * for hash keys and HTML attribute values.
8723 *
8724 * Transformations:
8725 * 'str' -> 'str'
8726 * null -> ''
8727 * undefined -> ''
8728 * true -> '1'
8729 * false -> '0'
8730 * 0 -> '0'
8731 * 1 -> '1'
8732 *
8733 */
8734
8735 /**
8736 * Iterates over arrays and hashes.
8737 *
8738 * ```
8739 * iterate(this.items, function(item, id) {
8740 * // invoked for each item
8741 * });
8742 * ```
8743 *
8744 */
8745 const iterate = (object, callback) => {
8746 if (Array.isArray(object)) {
8747 object.forEach(callback);
8748 } else {
8749 for (var key in object) {
8750 if (object.hasOwnProperty(key)) {
8751 callback(object[key], key);
8752 }
8753 }
8754 }
8755 };
8756
8757 /**
8758 * Remove css classes
8759 *
8760 */
8761 const removeClasses = (elmts, ...classes) => {
8762 var norm_classes = classesArray(classes);
8763 elmts = castAsArray(elmts);
8764 elmts.map(el => {
8765 norm_classes.map(cls => {
8766 el.classList.remove(cls);
8767 });
8768 });
8769 };
8770
8771 /**
8772 * Return arguments
8773 *
8774 */
8775 const classesArray = args => {
8776 var classes = [];
8777 iterate(args, _classes => {
8778 if (typeof _classes === 'string') {
8779 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8780 }
8781 if (Array.isArray(_classes)) {
8782 classes = classes.concat(_classes);
8783 }
8784 });
8785 return classes.filter(Boolean);
8786 };
8787
8788 /**
8789 * Create an array from arg if it's not already an array
8790 *
8791 */
8792 const castAsArray = arg => {
8793 if (!Array.isArray(arg)) {
8794 arg = [arg];
8795 }
8796 return arg;
8797 };
8798
8799 /**
8800 * Get the index of an element amongst sibling nodes of the same type
8801 *
8802 */
8803 const nodeIndex = (el, amongst) => {
8804 if (!el) return -1;
8805 amongst = amongst || el.nodeName;
8806 var i = 0;
8807 while (el = el.previousElementSibling) {
8808 if (el.matches(amongst)) {
8809 i++;
8810 }
8811 }
8812 return i;
8813 };
8814
8815 /**
8816 * Plugin: "dropdown_input" (Tom Select)
8817 * Copyright (c) contributors
8818 *
8819 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8820 * file except in compliance with the License. You may obtain a copy of the License at:
8821 * http://www.apache.org/licenses/LICENSE-2.0
8822 *
8823 * Unless required by applicable law or agreed to in writing, software distributed under
8824 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8825 * ANY KIND, either express or implied. See the License for the specific language
8826 * governing permissions and limitations under the License.
8827 *
8828 */
8829
8830 function plugin () {
8831 var self = this;
8832
8833 /**
8834 * Moves the caret to the specified index.
8835 *
8836 * The input must be moved by leaving it in place and moving the
8837 * siblings, due to the fact that focus cannot be restored once lost
8838 * on mobile webkit devices
8839 *
8840 */
8841 self.hook('instead', 'setCaret', new_pos => {
8842 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
8843 new_pos = self.items.length;
8844 } else {
8845 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
8846 if (new_pos != self.caretPos && !self.isPending) {
8847 self.controlChildren().forEach((child, j) => {
8848 if (j < new_pos) {
8849 self.control_input.insertAdjacentElement('beforebegin', child);
8850 } else {
8851 self.control.appendChild(child);
8852 }
8853 });
8854 }
8855 }
8856 self.caretPos = new_pos;
8857 });
8858 self.hook('instead', 'moveCaret', direction => {
8859 if (!self.isFocused) return;
8860
8861 // move caret before or after selected items
8862 const last_active = self.getLastActive(direction);
8863 if (last_active) {
8864 const idx = nodeIndex(last_active);
8865 self.setCaret(direction > 0 ? idx + 1 : idx);
8866 self.setActiveItem();
8867 removeClasses(last_active, 'last-active');
8868
8869 // move caret left or right of current position
8870 } else {
8871 self.setCaret(self.caretPos + direction);
8872 }
8873 });
8874 }
8875
8876
8877 //# sourceMappingURL=plugin.js.map
8878
8879
8880 /***/ },
8881
8882 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
8883 /*!****************************************************************************!*\
8884 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
8885 \****************************************************************************/
8886 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8887
8888 "use strict";
8889 __webpack_require__.r(__webpack_exports__);
8890 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8891 /* harmony export */ "default": () => (/* binding */ plugin)
8892 /* harmony export */ });
8893 /**
8894 * Tom Select v2.6.2
8895 * Licensed under the Apache License, Version 2.0 (the "License");
8896 */
8897
8898 /**
8899 * Converts a scalar to its best string representation
8900 * for hash keys and HTML attribute values.
8901 *
8902 * Transformations:
8903 * 'str' -> 'str'
8904 * null -> ''
8905 * undefined -> ''
8906 * true -> '1'
8907 * false -> '0'
8908 * 0 -> '0'
8909 * 1 -> '1'
8910 *
8911 */
8912
8913 /**
8914 * Add event helper
8915 *
8916 */
8917 const addEvent = (target, type, callback, options) => {
8918 target.addEventListener(type, callback, options);
8919 };
8920
8921 /**
8922 * Plugin: "change_listener" (Tom Select)
8923 * Copyright (c) contributors
8924 *
8925 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8926 * file except in compliance with the License. You may obtain a copy of the License at:
8927 * http://www.apache.org/licenses/LICENSE-2.0
8928 *
8929 * Unless required by applicable law or agreed to in writing, software distributed under
8930 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8931 * ANY KIND, either express or implied. See the License for the specific language
8932 * governing permissions and limitations under the License.
8933 *
8934 */
8935
8936 function plugin () {
8937 addEvent(this.input, 'change', () => {
8938 this.sync();
8939 });
8940 }
8941
8942
8943 //# sourceMappingURL=plugin.js.map
8944
8945
8946 /***/ },
8947
8948 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
8949 /*!*****************************************************************************!*\
8950 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
8951 \*****************************************************************************/
8952 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8953
8954 "use strict";
8955 __webpack_require__.r(__webpack_exports__);
8956 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8957 /* harmony export */ "default": () => (/* binding */ plugin)
8958 /* harmony export */ });
8959 /**
8960 * Tom Select v2.6.2
8961 * Licensed under the Apache License, Version 2.0 (the "License");
8962 */
8963
8964 /**
8965 * Converts a scalar to its best string representation
8966 * for hash keys and HTML attribute values.
8967 *
8968 * Transformations:
8969 * 'str' -> 'str'
8970 * null -> ''
8971 * undefined -> ''
8972 * true -> '1'
8973 * false -> '0'
8974 * 0 -> '0'
8975 * 1 -> '1'
8976 *
8977 */
8978 const hash_key = value => {
8979 if (typeof value === 'undefined' || value === null) return null;
8980 return get_hash(value);
8981 };
8982 const get_hash = value => {
8983 if (typeof value === 'boolean') return value ? '1' : '0';
8984 return value + '';
8985 };
8986
8987 /**
8988 * Prevent default
8989 *
8990 */
8991 const preventDefault = (evt, stop = false) => {
8992 if (evt) {
8993 evt.preventDefault();
8994 if (stop) {
8995 evt.stopPropagation();
8996 }
8997 }
8998 };
8999
9000 /**
9001 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9002 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9003 *
9004 * param query should be {}
9005 */
9006 const getDom = query => {
9007 if (query.jquery) {
9008 return query[0];
9009 }
9010 if (query instanceof HTMLElement) {
9011 return query;
9012 }
9013 if (isHtmlString(query)) {
9014 var tpl = document.createElement('template');
9015 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9016 return tpl.content.firstChild;
9017 }
9018 return document.querySelector(query);
9019 };
9020 const isHtmlString = arg => {
9021 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9022 return true;
9023 }
9024 return false;
9025 };
9026
9027 /**
9028 * Plugin: "checkbox_options" (Tom Select)
9029 * Copyright (c) contributors
9030 *
9031 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9032 * file except in compliance with the License. You may obtain a copy of the License at:
9033 * http://www.apache.org/licenses/LICENSE-2.0
9034 *
9035 * Unless required by applicable law or agreed to in writing, software distributed under
9036 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9037 * ANY KIND, either express or implied. See the License for the specific language
9038 * governing permissions and limitations under the License.
9039 *
9040 */
9041
9042 function plugin (userOptions) {
9043 var self = this;
9044 var orig_onOptionSelect = self.onOptionSelect;
9045 self.settings.hideSelected = false;
9046 const cbOptions = Object.assign({
9047 // so that the user may add different ones as well
9048 className: "tomselect-checkbox",
9049 // the following default to the historic plugin's values
9050 checkedClassNames: undefined,
9051 uncheckedClassNames: undefined
9052 }, userOptions);
9053 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9054 if (toCheck) {
9055 checkbox.checked = true;
9056 if (cbOptions.uncheckedClassNames) {
9057 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9058 }
9059 if (cbOptions.checkedClassNames) {
9060 checkbox.classList.add(...cbOptions.checkedClassNames);
9061 }
9062 } else {
9063 checkbox.checked = false;
9064 if (cbOptions.checkedClassNames) {
9065 checkbox.classList.remove(...cbOptions.checkedClassNames);
9066 }
9067 if (cbOptions.uncheckedClassNames) {
9068 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9069 }
9070 }
9071 };
9072
9073 // update the checkbox for an option
9074 var UpdateCheckbox = function UpdateCheckbox(option) {
9075 setTimeout(() => {
9076 var checkbox = option.querySelector('input.' + cbOptions.className);
9077 if (checkbox instanceof HTMLInputElement) {
9078 UpdateChecked(checkbox, option.classList.contains('selected'));
9079 }
9080 }, 1);
9081 };
9082
9083 // add checkbox to option template
9084 self.hook('after', 'setupTemplates', () => {
9085 var orig_render_option = self.settings.render.option;
9086 self.settings.render.option = (data, escape_html) => {
9087 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9088 var checkbox = document.createElement('input');
9089 if (cbOptions.className) {
9090 checkbox.classList.add(cbOptions.className);
9091 }
9092 checkbox.addEventListener('click', function (evt) {
9093 preventDefault(evt);
9094 });
9095 checkbox.type = 'checkbox';
9096 const hashed = hash_key(data[self.settings.valueField]);
9097 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9098 rendered.prepend(checkbox);
9099 return rendered;
9100 };
9101 });
9102
9103 // uncheck when item removed
9104 self.on('item_remove', value => {
9105 var option = self.getOption(value);
9106 if (option) {
9107 // if dropdown hasn't been opened yet, the option won't exist
9108 option.classList.remove('selected'); // selected class won't be removed yet
9109 UpdateCheckbox(option);
9110 }
9111 });
9112
9113 // check when item added
9114 self.on('item_add', value => {
9115 var option = self.getOption(value);
9116 if (option) {
9117 // if dropdown hasn't been opened yet, the option won't exist
9118 UpdateCheckbox(option);
9119 }
9120 });
9121
9122 // remove items when selected option is clicked
9123 self.hook('instead', 'onOptionSelect', (evt, option) => {
9124 if (option.classList.contains('selected')) {
9125 option.classList.remove('selected');
9126 self.removeItem(option.dataset.value);
9127 self.refreshOptions();
9128 preventDefault(evt, true);
9129 return;
9130 }
9131 orig_onOptionSelect.call(self, evt, option);
9132 UpdateCheckbox(option);
9133 });
9134 }
9135
9136
9137 //# sourceMappingURL=plugin.js.map
9138
9139
9140 /***/ },
9141
9142 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9143 /*!*************************************************************************!*\
9144 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9145 \*************************************************************************/
9146 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9147
9148 "use strict";
9149 __webpack_require__.r(__webpack_exports__);
9150 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9151 /* harmony export */ "default": () => (/* binding */ plugin)
9152 /* harmony export */ });
9153 /**
9154 * Tom Select v2.6.2
9155 * Licensed under the Apache License, Version 2.0 (the "License");
9156 */
9157
9158 /**
9159 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9160 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9161 *
9162 * param query should be {}
9163 */
9164 const getDom = query => {
9165 if (query.jquery) {
9166 return query[0];
9167 }
9168 if (query instanceof HTMLElement) {
9169 return query;
9170 }
9171 if (isHtmlString(query)) {
9172 var tpl = document.createElement('template');
9173 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9174 return tpl.content.firstChild;
9175 }
9176 return document.querySelector(query);
9177 };
9178 const isHtmlString = arg => {
9179 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9180 return true;
9181 }
9182 return false;
9183 };
9184
9185 /**
9186 * Plugin: "dropdown_header" (Tom Select)
9187 * Copyright (c) contributors
9188 *
9189 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9190 * file except in compliance with the License. You may obtain a copy of the License at:
9191 * http://www.apache.org/licenses/LICENSE-2.0
9192 *
9193 * Unless required by applicable law or agreed to in writing, software distributed under
9194 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9195 * ANY KIND, either express or implied. See the License for the specific language
9196 * governing permissions and limitations under the License.
9197 *
9198 */
9199
9200 function plugin (userOptions) {
9201 const self = this;
9202 const options = Object.assign({
9203 className: 'clear-button',
9204 title: 'Clear All',
9205 role: 'button',
9206 tabindex: 0,
9207 html: data => {
9208 return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">&times;</div>`;
9209 }
9210 }, userOptions);
9211 self.on('initialize', () => {
9212 var button = getDom(options.html(options));
9213 button.addEventListener('click', evt => {
9214 if (self.isLocked) return;
9215 self.clear();
9216 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9217 self.addItem('');
9218 }
9219 self.refreshOptions(false);
9220 evt.preventDefault();
9221 evt.stopPropagation();
9222 });
9223 self.control.appendChild(button);
9224 });
9225 }
9226
9227
9228 //# sourceMappingURL=plugin.js.map
9229
9230
9231 /***/ },
9232
9233 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9234 /*!**********************************************************************!*\
9235 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9236 \**********************************************************************/
9237 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9238
9239 "use strict";
9240 __webpack_require__.r(__webpack_exports__);
9241 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9242 /* harmony export */ "default": () => (/* binding */ plugin)
9243 /* harmony export */ });
9244 /**
9245 * Tom Select v2.6.2
9246 * Licensed under the Apache License, Version 2.0 (the "License");
9247 */
9248
9249 /**
9250 * Converts a scalar to its best string representation
9251 * for hash keys and HTML attribute values.
9252 *
9253 * Transformations:
9254 * 'str' -> 'str'
9255 * null -> ''
9256 * undefined -> ''
9257 * true -> '1'
9258 * false -> '0'
9259 * 0 -> '0'
9260 * 1 -> '1'
9261 *
9262 */
9263
9264 /**
9265 * Prevent default
9266 *
9267 */
9268 const preventDefault = (evt, stop = false) => {
9269 if (evt) {
9270 evt.preventDefault();
9271 if (stop) {
9272 evt.stopPropagation();
9273 }
9274 }
9275 };
9276
9277 /**
9278 * Add event helper
9279 *
9280 */
9281 const addEvent = (target, type, callback, options) => {
9282 target.addEventListener(type, callback, options);
9283 };
9284
9285 /**
9286 * Iterates over arrays and hashes.
9287 *
9288 * ```
9289 * iterate(this.items, function(item, id) {
9290 * // invoked for each item
9291 * });
9292 * ```
9293 *
9294 */
9295 const iterate = (object, callback) => {
9296 if (Array.isArray(object)) {
9297 object.forEach(callback);
9298 } else {
9299 for (var key in object) {
9300 if (object.hasOwnProperty(key)) {
9301 callback(object[key], key);
9302 }
9303 }
9304 }
9305 };
9306
9307 /**
9308 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9309 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9310 *
9311 * param query should be {}
9312 */
9313 const getDom = query => {
9314 if (query.jquery) {
9315 return query[0];
9316 }
9317 if (query instanceof HTMLElement) {
9318 return query;
9319 }
9320 if (isHtmlString(query)) {
9321 var tpl = document.createElement('template');
9322 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9323 return tpl.content.firstChild;
9324 }
9325 return document.querySelector(query);
9326 };
9327 const isHtmlString = arg => {
9328 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9329 return true;
9330 }
9331 return false;
9332 };
9333
9334 /**
9335 * Set attributes of an element
9336 *
9337 */
9338 const setAttr = (el, attrs) => {
9339 iterate(attrs, (val, attr) => {
9340 if (val == null) {
9341 el.removeAttribute(attr);
9342 } else {
9343 el.setAttribute(attr, '' + val);
9344 }
9345 });
9346 };
9347
9348 /**
9349 * Plugin: "drag_drop" (Tom Select)
9350 * Copyright (c) contributors
9351 *
9352 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9353 * file except in compliance with the License. You may obtain a copy of the License at:
9354 * http://www.apache.org/licenses/LICENSE-2.0
9355 *
9356 * Unless required by applicable law or agreed to in writing, software distributed under
9357 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9358 * ANY KIND, either express or implied. See the License for the specific language
9359 * governing permissions and limitations under the License.
9360 *
9361 */
9362
9363 const insertAfter = (referenceNode, newNode) => {
9364 var _referenceNode$parent;
9365 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
9366 };
9367 const insertBefore = (referenceNode, newNode) => {
9368 var _referenceNode$parent2;
9369 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
9370 };
9371 const isBefore = (referenceNode, newNode) => {
9372 do {
9373 var _newNode;
9374 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
9375 if (referenceNode == newNode) {
9376 return true;
9377 }
9378 } while (newNode && newNode.previousElementSibling);
9379 return false;
9380 };
9381 function plugin () {
9382 var self = this;
9383 if (self.settings.mode !== 'multi') return;
9384 var orig_lock = self.lock;
9385 var orig_unlock = self.unlock;
9386 let sortable = true;
9387 let drag_item;
9388
9389 /**
9390 * Add draggable attribute to item
9391 */
9392 self.hook('after', 'setupTemplates', () => {
9393 var orig_render_item = self.settings.render.item;
9394 self.settings.render.item = (data, escape) => {
9395 const item = getDom(orig_render_item.call(self, data, escape));
9396 setAttr(item, {
9397 'draggable': 'true'
9398 });
9399
9400 // prevent doc_mousedown (see tom-select.ts)
9401 const mousedown = evt => {
9402 if (!sortable) preventDefault(evt);
9403 evt.stopPropagation();
9404 };
9405 const dragStart = evt => {
9406 drag_item = item;
9407 setTimeout(() => {
9408 item.classList.add('ts-dragging');
9409 }, 0);
9410 };
9411 const dragOver = evt => {
9412 evt.preventDefault();
9413 item.classList.add('ts-drag-over');
9414 moveitem(item, drag_item);
9415 };
9416 const dragLeave = () => {
9417 item.classList.remove('ts-drag-over');
9418 };
9419 const moveitem = (targetitem, dragitem) => {
9420 if (dragitem === undefined) return;
9421 if (isBefore(dragitem, item)) {
9422 insertAfter(targetitem, dragitem);
9423 } else {
9424 insertBefore(targetitem, dragitem);
9425 }
9426 };
9427 const dragend = () => {
9428 var _drag_item;
9429 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
9430 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
9431 drag_item = undefined;
9432 var values = [];
9433 self.control.querySelectorAll(`[data-value]`).forEach(el => {
9434 if (el.dataset.value) {
9435 let value = el.dataset.value;
9436 if (value) {
9437 values.push(value);
9438 }
9439 }
9440 });
9441 self.setValue(values);
9442 };
9443 addEvent(item, 'mousedown', mousedown);
9444 addEvent(item, 'dragstart', dragStart);
9445 addEvent(item, 'dragenter', dragOver);
9446 addEvent(item, 'dragover', dragOver);
9447 addEvent(item, 'dragleave', dragLeave);
9448 addEvent(item, 'dragend', dragend);
9449 return item;
9450 };
9451 });
9452 self.hook('instead', 'lock', () => {
9453 sortable = false;
9454 return orig_lock.call(self);
9455 });
9456 self.hook('instead', 'unlock', () => {
9457 sortable = true;
9458 return orig_unlock.call(self);
9459 });
9460 }
9461
9462
9463 //# sourceMappingURL=plugin.js.map
9464
9465
9466 /***/ },
9467
9468 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
9469 /*!****************************************************************************!*\
9470 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
9471 \****************************************************************************/
9472 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9473
9474 "use strict";
9475 __webpack_require__.r(__webpack_exports__);
9476 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9477 /* harmony export */ "default": () => (/* binding */ plugin)
9478 /* harmony export */ });
9479 /**
9480 * Tom Select v2.6.2
9481 * Licensed under the Apache License, Version 2.0 (the "License");
9482 */
9483
9484 /**
9485 * Converts a scalar to its best string representation
9486 * for hash keys and HTML attribute values.
9487 *
9488 * Transformations:
9489 * 'str' -> 'str'
9490 * null -> ''
9491 * undefined -> ''
9492 * true -> '1'
9493 * false -> '0'
9494 * 0 -> '0'
9495 * 1 -> '1'
9496 *
9497 */
9498
9499 /**
9500 * Prevent default
9501 *
9502 */
9503 const preventDefault = (evt, stop = false) => {
9504 if (evt) {
9505 evt.preventDefault();
9506 if (stop) {
9507 evt.stopPropagation();
9508 }
9509 }
9510 };
9511
9512 /**
9513 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9514 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9515 *
9516 * param query should be {}
9517 */
9518 const getDom = query => {
9519 if (query.jquery) {
9520 return query[0];
9521 }
9522 if (query instanceof HTMLElement) {
9523 return query;
9524 }
9525 if (isHtmlString(query)) {
9526 var tpl = document.createElement('template');
9527 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9528 return tpl.content.firstChild;
9529 }
9530 return document.querySelector(query);
9531 };
9532 const isHtmlString = arg => {
9533 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9534 return true;
9535 }
9536 return false;
9537 };
9538
9539 /**
9540 * Plugin: "dropdown_header" (Tom Select)
9541 * Copyright (c) contributors
9542 *
9543 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9544 * file except in compliance with the License. You may obtain a copy of the License at:
9545 * http://www.apache.org/licenses/LICENSE-2.0
9546 *
9547 * Unless required by applicable law or agreed to in writing, software distributed under
9548 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9549 * ANY KIND, either express or implied. See the License for the specific language
9550 * governing permissions and limitations under the License.
9551 *
9552 */
9553
9554 function plugin (userOptions) {
9555 const self = this;
9556 const options = Object.assign({
9557 title: 'Untitled',
9558 headerClass: 'dropdown-header',
9559 titleRowClass: 'dropdown-header-title',
9560 labelClass: 'dropdown-header-label',
9561 closeClass: 'dropdown-header-close',
9562 html: data => {
9563 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
9564 }
9565 }, userOptions);
9566 self.on('initialize', () => {
9567 var header = getDom(options.html(options));
9568 var close_link = header.querySelector('.' + options.closeClass);
9569 if (close_link) {
9570 close_link.addEventListener('click', evt => {
9571 preventDefault(evt, true);
9572 self.close();
9573 });
9574 }
9575 self.dropdown.insertBefore(header, self.dropdown.firstChild);
9576 });
9577 }
9578
9579
9580 //# sourceMappingURL=plugin.js.map
9581
9582
9583 /***/ },
9584
9585 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
9586 /*!***************************************************************************!*\
9587 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
9588 \***************************************************************************/
9589 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9590
9591 "use strict";
9592 __webpack_require__.r(__webpack_exports__);
9593 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9594 /* harmony export */ "default": () => (/* binding */ plugin)
9595 /* harmony export */ });
9596 /**
9597 * Tom Select v2.6.2
9598 * Licensed under the Apache License, Version 2.0 (the "License");
9599 */
9600
9601 const KEY_ESC = 27;
9602 const KEY_TAB = 9;
9603 // ctrl key or apple key for ma
9604
9605 /**
9606 * Converts a scalar to its best string representation
9607 * for hash keys and HTML attribute values.
9608 *
9609 * Transformations:
9610 * 'str' -> 'str'
9611 * null -> ''
9612 * undefined -> ''
9613 * true -> '1'
9614 * false -> '0'
9615 * 0 -> '0'
9616 * 1 -> '1'
9617 *
9618 */
9619
9620 /**
9621 * Prevent default
9622 *
9623 */
9624 const preventDefault = (evt, stop = false) => {
9625 if (evt) {
9626 evt.preventDefault();
9627 if (stop) {
9628 evt.stopPropagation();
9629 }
9630 }
9631 };
9632
9633 /**
9634 * Add event helper
9635 *
9636 */
9637 const addEvent = (target, type, callback, options) => {
9638 target.addEventListener(type, callback, options);
9639 };
9640
9641 /**
9642 * Iterates over arrays and hashes.
9643 *
9644 * ```
9645 * iterate(this.items, function(item, id) {
9646 * // invoked for each item
9647 * });
9648 * ```
9649 *
9650 */
9651 const iterate = (object, callback) => {
9652 if (Array.isArray(object)) {
9653 object.forEach(callback);
9654 } else {
9655 for (var key in object) {
9656 if (object.hasOwnProperty(key)) {
9657 callback(object[key], key);
9658 }
9659 }
9660 }
9661 };
9662
9663 /**
9664 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9665 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9666 *
9667 * param query should be {}
9668 */
9669 const getDom = query => {
9670 if (query.jquery) {
9671 return query[0];
9672 }
9673 if (query instanceof HTMLElement) {
9674 return query;
9675 }
9676 if (isHtmlString(query)) {
9677 var tpl = document.createElement('template');
9678 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9679 return tpl.content.firstChild;
9680 }
9681 return document.querySelector(query);
9682 };
9683 const isHtmlString = arg => {
9684 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9685 return true;
9686 }
9687 return false;
9688 };
9689
9690 /**
9691 * Add css classes
9692 *
9693 */
9694 const addClasses = (elmts, ...classes) => {
9695 var norm_classes = classesArray(classes);
9696 elmts = castAsArray(elmts);
9697 elmts.map(el => {
9698 norm_classes.map(cls => {
9699 el.classList.add(cls);
9700 });
9701 });
9702 };
9703
9704 /**
9705 * Return arguments
9706 *
9707 */
9708 const classesArray = args => {
9709 var classes = [];
9710 iterate(args, _classes => {
9711 if (typeof _classes === 'string') {
9712 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9713 }
9714 if (Array.isArray(_classes)) {
9715 classes = classes.concat(_classes);
9716 }
9717 });
9718 return classes.filter(Boolean);
9719 };
9720
9721 /**
9722 * Create an array from arg if it's not already an array
9723 *
9724 */
9725 const castAsArray = arg => {
9726 if (!Array.isArray(arg)) {
9727 arg = [arg];
9728 }
9729 return arg;
9730 };
9731
9732 /**
9733 * Plugin: "dropdown_input" (Tom Select)
9734 * Copyright (c) contributors
9735 *
9736 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9737 * file except in compliance with the License. You may obtain a copy of the License at:
9738 * http://www.apache.org/licenses/LICENSE-2.0
9739 *
9740 * Unless required by applicable law or agreed to in writing, software distributed under
9741 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9742 * ANY KIND, either express or implied. See the License for the specific language
9743 * governing permissions and limitations under the License.
9744 *
9745 */
9746
9747 function plugin () {
9748 const self = this;
9749 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
9750
9751 self.hook('before', 'setup', () => {
9752 var _self$input;
9753 self.focus_node = self.control;
9754 addClasses(self.control_input, 'dropdown-input');
9755 const div = getDom('<div class="dropdown-input-wrap">');
9756 div.append(self.control_input);
9757 self.dropdown.insertBefore(div, self.dropdown.firstChild);
9758
9759 // set a placeholder in the select control
9760 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
9761 placeholder.placeholder = self.settings.placeholder || '';
9762 self.control.append(placeholder);
9763 /**
9764 * TomSelect renders a custom control with a focusable <input class="items-placeholder">.
9765 * The source <select>'s aria-label is not automatically propagated to that input,
9766 * which triggers "Missing form label" accessibility warnings.
9767 * This helper copies the label from the <select> onto the generated input.
9768 */
9769 const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label');
9770 if (!label) return;
9771 placeholder.setAttribute('aria-label', label);
9772 });
9773 self.on('initialize', () => {
9774 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
9775 self.control_input.addEventListener('keydown', evt => {
9776 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
9777 switch (evt.keyCode) {
9778 case KEY_ESC:
9779 if (self.isOpen) {
9780 preventDefault(evt, true);
9781 self.close();
9782 }
9783 self.clearActiveItems();
9784 return;
9785 case KEY_TAB:
9786 self.focus_node.tabIndex = -1;
9787 break;
9788 }
9789 return self.onKeyDown.call(self, evt);
9790 });
9791 self.on('blur', () => {
9792 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
9793 });
9794
9795 // give the control_input focus when the dropdown is open
9796 self.on('dropdown_open', () => {
9797 self.control_input.focus();
9798 });
9799
9800 // prevent onBlur from closing when focus is on the control_input
9801 const orig_onBlur = self.onBlur;
9802 self.hook('instead', 'onBlur', evt => {
9803 if (evt && evt.relatedTarget == self.control_input) return;
9804 return orig_onBlur.call(self);
9805 });
9806 addEvent(self.control_input, 'blur', () => self.onBlur());
9807
9808 // return focus to control to allow further keyboard input
9809 self.hook('before', 'close', () => {
9810 if (!self.isOpen) return;
9811 self.focus_node.focus({
9812 preventScroll: true
9813 });
9814 });
9815 });
9816 }
9817
9818
9819 //# sourceMappingURL=plugin.js.map
9820
9821
9822 /***/ },
9823
9824 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
9825 /*!***************************************************************************!*\
9826 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
9827 \***************************************************************************/
9828 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9829
9830 "use strict";
9831 __webpack_require__.r(__webpack_exports__);
9832 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9833 /* harmony export */ "default": () => (/* binding */ plugin)
9834 /* harmony export */ });
9835 /**
9836 * Tom Select v2.6.2
9837 * Licensed under the Apache License, Version 2.0 (the "License");
9838 */
9839
9840 /**
9841 * Converts a scalar to its best string representation
9842 * for hash keys and HTML attribute values.
9843 *
9844 * Transformations:
9845 * 'str' -> 'str'
9846 * null -> ''
9847 * undefined -> ''
9848 * true -> '1'
9849 * false -> '0'
9850 * 0 -> '0'
9851 * 1 -> '1'
9852 *
9853 */
9854
9855 /**
9856 * Add event helper
9857 *
9858 */
9859 const addEvent = (target, type, callback, options) => {
9860 target.addEventListener(type, callback, options);
9861 };
9862
9863 /**
9864 * Plugin: "input_autogrow" (Tom Select)
9865 *
9866 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9867 * file except in compliance with the License. You may obtain a copy of the License at:
9868 * http://www.apache.org/licenses/LICENSE-2.0
9869 *
9870 * Unless required by applicable law or agreed to in writing, software distributed under
9871 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9872 * ANY KIND, either express or implied. See the License for the specific language
9873 * governing permissions and limitations under the License.
9874 *
9875 */
9876
9877 function plugin () {
9878 var self = this;
9879 self.on('initialize', () => {
9880 var test_input = document.createElement('span');
9881 var control = self.control_input;
9882 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
9883 self.wrapper.appendChild(test_input);
9884 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
9885 for (const style_name of transfer_styles) {
9886 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
9887 test_input.style[style_name] = control.style[style_name];
9888 }
9889
9890 /**
9891 * Set the control width
9892 *
9893 */
9894 var resize = () => {
9895 test_input.textContent = control.value;
9896 control.style.width = test_input.clientWidth + 'px';
9897 };
9898 resize();
9899 self.on('update item_add item_remove', resize);
9900 addEvent(control, 'input', resize);
9901 addEvent(control, 'keyup', resize);
9902 addEvent(control, 'blur', resize);
9903 addEvent(control, 'update', resize);
9904 });
9905 }
9906
9907
9908 //# sourceMappingURL=plugin.js.map
9909
9910
9911 /***/ },
9912
9913 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
9914 /*!****************************************************************************!*\
9915 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
9916 \****************************************************************************/
9917 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9918
9919 "use strict";
9920 __webpack_require__.r(__webpack_exports__);
9921 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9922 /* harmony export */ "default": () => (/* binding */ plugin)
9923 /* harmony export */ });
9924 /**
9925 * Tom Select v2.6.2
9926 * Licensed under the Apache License, Version 2.0 (the "License");
9927 */
9928
9929 /**
9930 * Plugin: "no_active_items" (Tom Select)
9931 *
9932 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9933 * file except in compliance with the License. You may obtain a copy of the License at:
9934 * http://www.apache.org/licenses/LICENSE-2.0
9935 *
9936 * Unless required by applicable law or agreed to in writing, software distributed under
9937 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9938 * ANY KIND, either express or implied. See the License for the specific language
9939 * governing permissions and limitations under the License.
9940 *
9941 */
9942
9943 function plugin () {
9944 this.hook('instead', 'setActiveItem', () => {});
9945 this.hook('instead', 'selectAll', () => {});
9946 }
9947
9948
9949 //# sourceMappingURL=plugin.js.map
9950
9951
9952 /***/ },
9953
9954 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
9955 /*!********************************************************************************!*\
9956 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
9957 \********************************************************************************/
9958 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9959
9960 "use strict";
9961 __webpack_require__.r(__webpack_exports__);
9962 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9963 /* harmony export */ "default": () => (/* binding */ plugin)
9964 /* harmony export */ });
9965 /**
9966 * Tom Select v2.6.2
9967 * Licensed under the Apache License, Version 2.0 (the "License");
9968 */
9969
9970 /**
9971 * Plugin: "input_autogrow" (Tom Select)
9972 *
9973 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9974 * file except in compliance with the License. You may obtain a copy of the License at:
9975 * http://www.apache.org/licenses/LICENSE-2.0
9976 *
9977 * Unless required by applicable law or agreed to in writing, software distributed under
9978 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9979 * ANY KIND, either express or implied. See the License for the specific language
9980 * governing permissions and limitations under the License.
9981 *
9982 */
9983
9984 function plugin () {
9985 var self = this;
9986 var orig_deleteSelection = self.deleteSelection;
9987 this.hook('instead', 'deleteSelection', evt => {
9988 if (self.activeItems.length) {
9989 return orig_deleteSelection.call(self, evt);
9990 }
9991 return false;
9992 });
9993 }
9994
9995
9996 //# sourceMappingURL=plugin.js.map
9997
9998
9999 /***/ },
10000
10001 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10002 /*!*****************************************************************************!*\
10003 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10004 \*****************************************************************************/
10005 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10006
10007 "use strict";
10008 __webpack_require__.r(__webpack_exports__);
10009 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10010 /* harmony export */ "default": () => (/* binding */ plugin)
10011 /* harmony export */ });
10012 /**
10013 * Tom Select v2.6.2
10014 * Licensed under the Apache License, Version 2.0 (the "License");
10015 */
10016
10017 const KEY_LEFT = 37;
10018 const KEY_RIGHT = 39;
10019 // ctrl key or apple key for ma
10020
10021 /**
10022 * Get the closest node to the evt.target matching the selector
10023 * Stops at wrapper
10024 *
10025 */
10026 const parentMatch = (target, selector, wrapper) => {
10027 while (target && target.matches) {
10028 if (target.matches(selector)) {
10029 return target;
10030 }
10031 target = target.parentNode;
10032 }
10033 };
10034
10035 /**
10036 * Get the index of an element amongst sibling nodes of the same type
10037 *
10038 */
10039 const nodeIndex = (el, amongst) => {
10040 if (!el) return -1;
10041 amongst = amongst || el.nodeName;
10042 var i = 0;
10043 while (el = el.previousElementSibling) {
10044 if (el.matches(amongst)) {
10045 i++;
10046 }
10047 }
10048 return i;
10049 };
10050
10051 /**
10052 * Plugin: "optgroup_columns" (Tom Select.js)
10053 * Copyright (c) contributors
10054 *
10055 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10056 * file except in compliance with the License. You may obtain a copy of the License at:
10057 * http://www.apache.org/licenses/LICENSE-2.0
10058 *
10059 * Unless required by applicable law or agreed to in writing, software distributed under
10060 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10061 * ANY KIND, either express or implied. See the License for the specific language
10062 * governing permissions and limitations under the License.
10063 *
10064 */
10065
10066 function plugin () {
10067 var self = this;
10068 var orig_keydown = self.onKeyDown;
10069 self.hook('instead', 'onKeyDown', evt => {
10070 var index, option, options, optgroup;
10071 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10072 return orig_keydown.call(self, evt);
10073 }
10074 self.ignoreHover = true;
10075 optgroup = parentMatch(self.activeOption, '[data-group]');
10076 index = nodeIndex(self.activeOption, '[data-selectable]');
10077 if (!optgroup) {
10078 return;
10079 }
10080 if (evt.keyCode === KEY_LEFT) {
10081 optgroup = optgroup.previousSibling;
10082 } else {
10083 optgroup = optgroup.nextSibling;
10084 }
10085 if (!optgroup) {
10086 return;
10087 }
10088 options = optgroup.querySelectorAll('[data-selectable]');
10089 option = options[Math.min(options.length - 1, index)];
10090 if (option) {
10091 self.setActiveOption(option);
10092 }
10093 });
10094 }
10095
10096
10097 //# sourceMappingURL=plugin.js.map
10098
10099
10100 /***/ },
10101
10102 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10103 /*!**************************************************************************!*\
10104 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10105 \**************************************************************************/
10106 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10107
10108 "use strict";
10109 __webpack_require__.r(__webpack_exports__);
10110 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10111 /* harmony export */ "default": () => (/* binding */ plugin)
10112 /* harmony export */ });
10113 /**
10114 * Tom Select v2.6.2
10115 * Licensed under the Apache License, Version 2.0 (the "License");
10116 */
10117
10118 /**
10119 * Converts a scalar to its best string representation
10120 * for hash keys and HTML attribute values.
10121 *
10122 * Transformations:
10123 * 'str' -> 'str'
10124 * null -> ''
10125 * undefined -> ''
10126 * true -> '1'
10127 * false -> '0'
10128 * 0 -> '0'
10129 * 1 -> '1'
10130 *
10131 */
10132
10133 /**
10134 * Prevent default
10135 *
10136 */
10137 const preventDefault = (evt, stop = false) => {
10138 if (evt) {
10139 evt.preventDefault();
10140 if (stop) {
10141 evt.stopPropagation();
10142 }
10143 }
10144 };
10145
10146 /**
10147 * Add event helper
10148 *
10149 */
10150 const addEvent = (target, type, callback, options) => {
10151 target.addEventListener(type, callback, options);
10152 };
10153
10154 /**
10155 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10156 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10157 *
10158 * param query should be {}
10159 */
10160 const getDom = query => {
10161 if (query.jquery) {
10162 return query[0];
10163 }
10164 if (query instanceof HTMLElement) {
10165 return query;
10166 }
10167 if (isHtmlString(query)) {
10168 var tpl = document.createElement('template');
10169 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10170 return tpl.content.firstChild;
10171 }
10172 return document.querySelector(query);
10173 };
10174 const isHtmlString = arg => {
10175 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10176 return true;
10177 }
10178 return false;
10179 };
10180
10181 /**
10182 * Plugin: "remove_button" (Tom Select)
10183 * Copyright (c) contributors
10184 *
10185 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10186 * file except in compliance with the License. You may obtain a copy of the License at:
10187 * http://www.apache.org/licenses/LICENSE-2.0
10188 *
10189 * Unless required by applicable law or agreed to in writing, software distributed under
10190 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10191 * ANY KIND, either express or implied. See the License for the specific language
10192 * governing permissions and limitations under the License.
10193 *
10194 */
10195
10196 function plugin (userOptions) {
10197 const self = this;
10198 const options = Object.assign({
10199 label: '×',
10200 title: 'Remove',
10201 className: 'remove',
10202 tabindex: -1,
10203 role: 'button',
10204 html: data => {
10205 var _data$tabindex;
10206 const el = document.createElement('div');
10207 el.className = data.className || '';
10208 el.title = data.title || '';
10209 el.setAttribute('role', data.role || 'button');
10210 el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1;
10211 el.textContent = data.label || '';
10212 return el;
10213 }
10214 }, userOptions);
10215 self.hook('after', 'setupTemplates', () => {
10216 var orig_render_item = self.settings.render.item;
10217 self.settings.render.item = (data, escape) => {
10218 var item = getDom(orig_render_item.call(self, data, escape));
10219 var close_button = getDom(options.html(options));
10220 item.appendChild(close_button);
10221 addEvent(close_button, 'mousedown', evt => {
10222 preventDefault(evt, true);
10223 });
10224 addEvent(close_button, 'click', evt => {
10225 if (self.isLocked) return;
10226
10227 // propagating will trigger the dropdown to show for single mode
10228 preventDefault(evt, true);
10229 if (self.isLocked) return;
10230 if (!self.shouldDelete([item], evt)) return;
10231 self.removeItem(item);
10232 self.refreshOptions(false);
10233 self.inputState();
10234 });
10235 return item;
10236 };
10237 });
10238 }
10239
10240
10241 //# sourceMappingURL=plugin.js.map
10242
10243
10244 /***/ },
10245
10246 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10247 /*!*********************************************************************************!*\
10248 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10249 \*********************************************************************************/
10250 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10251
10252 "use strict";
10253 __webpack_require__.r(__webpack_exports__);
10254 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10255 /* harmony export */ "default": () => (/* binding */ plugin)
10256 /* harmony export */ });
10257 /**
10258 * Tom Select v2.6.2
10259 * Licensed under the Apache License, Version 2.0 (the "License");
10260 */
10261
10262 /**
10263 * Plugin: "restore_on_backspace" (Tom Select)
10264 * Copyright (c) contributors
10265 *
10266 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10267 * file except in compliance with the License. You may obtain a copy of the License at:
10268 * http://www.apache.org/licenses/LICENSE-2.0
10269 *
10270 * Unless required by applicable law or agreed to in writing, software distributed under
10271 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10272 * ANY KIND, either express or implied. See the License for the specific language
10273 * governing permissions and limitations under the License.
10274 *
10275 */
10276
10277 function plugin (userOptions) {
10278 const self = this;
10279 const options = Object.assign({
10280 text: option => {
10281 return option[self.settings.labelField];
10282 }
10283 }, userOptions);
10284 self.on('item_remove', function (value) {
10285 if (!self.isFocused) {
10286 return;
10287 }
10288 if (self.control_input.value.trim() === '') {
10289 var option = self.options[value];
10290 if (option) {
10291 self.setTextboxValue(options.text.call(self, option));
10292 }
10293 }
10294 });
10295 }
10296
10297
10298 //# sourceMappingURL=plugin.js.map
10299
10300
10301 /***/ },
10302
10303 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10304 /*!***************************************************************************!*\
10305 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10306 \***************************************************************************/
10307 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10308
10309 "use strict";
10310 __webpack_require__.r(__webpack_exports__);
10311 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10312 /* harmony export */ "default": () => (/* binding */ plugin)
10313 /* harmony export */ });
10314 /**
10315 * Tom Select v2.6.2
10316 * Licensed under the Apache License, Version 2.0 (the "License");
10317 */
10318
10319 /**
10320 * Converts a scalar to its best string representation
10321 * for hash keys and HTML attribute values.
10322 *
10323 * Transformations:
10324 * 'str' -> 'str'
10325 * null -> ''
10326 * undefined -> ''
10327 * true -> '1'
10328 * false -> '0'
10329 * 0 -> '0'
10330 * 1 -> '1'
10331 *
10332 */
10333
10334 /**
10335 * Iterates over arrays and hashes.
10336 *
10337 * ```
10338 * iterate(this.items, function(item, id) {
10339 * // invoked for each item
10340 * });
10341 * ```
10342 *
10343 */
10344 const iterate = (object, callback) => {
10345 if (Array.isArray(object)) {
10346 object.forEach(callback);
10347 } else {
10348 for (var key in object) {
10349 if (object.hasOwnProperty(key)) {
10350 callback(object[key], key);
10351 }
10352 }
10353 }
10354 };
10355
10356 /**
10357 * Add css classes
10358 *
10359 */
10360 const addClasses = (elmts, ...classes) => {
10361 var norm_classes = classesArray(classes);
10362 elmts = castAsArray(elmts);
10363 elmts.map(el => {
10364 norm_classes.map(cls => {
10365 el.classList.add(cls);
10366 });
10367 });
10368 };
10369
10370 /**
10371 * Return arguments
10372 *
10373 */
10374 const classesArray = args => {
10375 var classes = [];
10376 iterate(args, _classes => {
10377 if (typeof _classes === 'string') {
10378 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10379 }
10380 if (Array.isArray(_classes)) {
10381 classes = classes.concat(_classes);
10382 }
10383 });
10384 return classes.filter(Boolean);
10385 };
10386
10387 /**
10388 * Create an array from arg if it's not already an array
10389 *
10390 */
10391 const castAsArray = arg => {
10392 if (!Array.isArray(arg)) {
10393 arg = [arg];
10394 }
10395 return arg;
10396 };
10397
10398 /**
10399 * Plugin: "virtual_scroll" (Tom Select)
10400 * Copyright (c) contributors
10401 *
10402 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10403 * file except in compliance with the License. You may obtain a copy of the License at:
10404 * http://www.apache.org/licenses/LICENSE-2.0
10405 *
10406 * Unless required by applicable law or agreed to in writing, software distributed under
10407 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10408 * ANY KIND, either express or implied. See the License for the specific language
10409 * governing permissions and limitations under the License.
10410 *
10411 */
10412
10413 function plugin () {
10414 const self = this;
10415 const orig_canLoad = self.canLoad;
10416 const orig_clearActiveOption = self.clearActiveOption;
10417 const orig_loadCallback = self.loadCallback;
10418 var pagination = {};
10419 var dropdown_content;
10420 var loading_more = false;
10421 var load_more_opt;
10422 var default_values = [];
10423 var default_values_loaded = false;
10424 var default_pagination;
10425 var default_options = [];
10426 var html_values = [];
10427 if (!self.settings.shouldLoadMore) {
10428 // return true if additional results should be loaded
10429 self.settings.shouldLoadMore = () => {
10430 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
10431 if (scroll_percent > 0.9) {
10432 return true;
10433 }
10434 if (self.activeOption) {
10435 var selectable = self.selectable();
10436 var index = Array.from(selectable).indexOf(self.activeOption);
10437 if (index >= selectable.length - 2) {
10438 return true;
10439 }
10440 }
10441 return false;
10442 };
10443 }
10444 if (!self.settings.firstUrl) {
10445 throw 'virtual_scroll plugin requires a firstUrl() method';
10446 }
10447
10448 // in order for virtual scrolling to work,
10449 // options need to be ordered the same way they're returned from the remote data source
10450 self.settings.sortField = [{
10451 field: '$order'
10452 }, {
10453 field: '$score'
10454 }];
10455
10456 // can we load more results for given query?
10457 const canLoadMore = query => {
10458 if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
10459 return false;
10460 }
10461 if (query in pagination && pagination[query]) {
10462 return true;
10463 }
10464 return false;
10465 };
10466 const clearFilter = (option, value) => {
10467 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
10468 return true;
10469 }
10470 return false;
10471 };
10472
10473 // set the next url that will be
10474 self.setNextUrl = (value, next_url) => {
10475 pagination[value] = next_url;
10476 };
10477
10478 // getUrl() to be used in settings.load()
10479 self.getUrl = query => {
10480 if (query in pagination) {
10481 const next_url = pagination[query];
10482 pagination[query] = false;
10483 return next_url;
10484 }
10485
10486 // if the user goes back to a previous query
10487 // we need to load the first page again
10488 self.clearPagination();
10489 return self.settings.firstUrl.call(self, query);
10490 };
10491
10492 // clear pagination
10493 self.clearPagination = () => {
10494 pagination = {};
10495 };
10496
10497 // don't clear the active option (and cause unwanted dropdown scroll)
10498 // while loading more results
10499 self.hook('instead', 'clearActiveOption', () => {
10500 if (loading_more) {
10501 return;
10502 }
10503 return orig_clearActiveOption.call(self);
10504 });
10505
10506 // override the canLoad method
10507 self.hook('instead', 'canLoad', query => {
10508 // first time the query has been seen
10509 if (!(query in pagination)) {
10510 return orig_canLoad.call(self, query);
10511 }
10512 return canLoadMore(query);
10513 });
10514
10515 // wrap the load
10516 self.hook('instead', 'loadCallback', (options, optgroups) => {
10517 if (!loading_more) {
10518 // When searching (non-empty query), keep selected items and HTML default options,
10519 // but remove preloaded remote options so they don't bleed into search results.
10520 // For empty query, use clearFilter (keeps default_values + items).
10521 const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter;
10522 self.clearOptions(activeFilter);
10523 } else if (load_more_opt) {
10524 const first_option = options[0];
10525 if (first_option !== undefined) {
10526 load_more_opt.dataset.value = first_option[self.settings.valueField];
10527 }
10528 }
10529 orig_loadCallback.call(self, options, optgroups);
10530
10531 // After the initial preload (empty query), snapshot default_values and option objects
10532 // so they can be restored when the user clears their search.
10533 if (!loading_more && !default_values_loaded) {
10534 default_values_loaded = true;
10535 if (self.lastValue === '') {
10536 default_values = Object.keys(self.options);
10537 default_pagination = pagination[''];
10538 default_options = Object.values(self.options);
10539 }
10540 }
10541 loading_more = false;
10542 });
10543
10544 // as the “loading_more” element will be removed from the dropdown,
10545 // we activate the previous option if needed
10546 // to avoid the dropdown being scrolled back to the first one
10547 self.hook('before', 'refreshOptions', () => {
10548 if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) {
10549 self.setActiveOption(self.activeOption.previousElementSibling);
10550 }
10551 });
10552
10553 // add templates to dropdown
10554 // loading_more if we have another url in the queue
10555 // no_more_results if we don't have another url in the queue
10556 self.hook('after', 'refreshOptions', () => {
10557 const query = self.lastValue;
10558 var option;
10559 if (canLoadMore(query)) {
10560 option = self.render('loading_more', {
10561 query: query
10562 });
10563 if (option) {
10564 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
10565 load_more_opt = option;
10566 }
10567 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
10568 option = self.render('no_more_results', {
10569 query: query
10570 });
10571 }
10572 if (option) {
10573 addClasses(option, self.settings.optionClass);
10574 dropdown_content.append(option);
10575 }
10576 });
10577
10578 // Restore preloaded options and pagination when clearing search
10579 const restoreDefaults = () => {
10580 if (!default_values_loaded) {
10581 return;
10582 }
10583 // Re-add preloaded option objects (clearOptions can only remove, not restore)
10584 self.addOptions(default_options);
10585 // Remove any search results that are not part of the preloaded defaults
10586 self.clearOptions(clearFilter);
10587 if (default_pagination) {
10588 pagination[''] = default_pagination;
10589 }
10590 };
10591 self.on('type', query => {
10592 if (query === '') {
10593 restoreDefaults();
10594 self.refreshOptions(false);
10595 }
10596 });
10597 self.on('dropdown_close', restoreDefaults);
10598
10599 // add scroll listener and default templates
10600 self.on('initialize', () => {
10601 html_values = Object.keys(self.options);
10602 default_values = Object.keys(self.options);
10603 dropdown_content = self.dropdown_content;
10604
10605 // default templates
10606 self.settings.render = Object.assign({}, {
10607 loading_more: () => {
10608 return `<div class="loading-more-results">Loading more results ... </div>`;
10609 },
10610 no_more_results: () => {
10611 return `<div class="no-more-results">No more results</div>`;
10612 }
10613 }, self.settings.render);
10614
10615 // watch dropdown content scroll position
10616 dropdown_content.addEventListener('scroll', () => {
10617 if (!self.settings.shouldLoadMore.call(self)) {
10618 return;
10619 }
10620
10621 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
10622 if (!canLoadMore(self.lastValue)) {
10623 return;
10624 }
10625
10626 // don't call load() too much
10627 if (loading_more) return;
10628 loading_more = true;
10629 self.load.call(self, self.lastValue);
10630 });
10631 });
10632 }
10633
10634
10635 //# sourceMappingURL=plugin.js.map
10636
10637
10638 /***/ },
10639
10640 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
10641 /*!*****************************************************************!*\
10642 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
10643 \*****************************************************************/
10644 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10645
10646 "use strict";
10647 __webpack_require__.r(__webpack_exports__);
10648 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10649 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10650 /* harmony export */ });
10651 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
10652 /* 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");
10653 /* 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");
10654 /* 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");
10655 /* 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");
10656 /* 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");
10657 /* 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");
10658 /* 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");
10659 /* 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");
10660 /* 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");
10661 /* 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");
10662 /* 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");
10663 /* 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");
10664 /* 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");
10665 /* 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");
10666
10667
10668
10669
10670
10671
10672
10673
10674
10675
10676
10677
10678
10679
10680
10681 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
10682 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
10683 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
10684 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
10685 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
10686 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
10687 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
10688 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
10689 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
10690 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
10691 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
10692 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
10693 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
10694 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
10695 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
10696 //# sourceMappingURL=tom-select.complete.js.map
10697
10698 /***/ },
10699
10700 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
10701 /*!********************************************************!*\
10702 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
10703 \********************************************************/
10704 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10705
10706 "use strict";
10707 __webpack_require__.r(__webpack_exports__);
10708 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10709 /* harmony export */ "default": () => (/* binding */ TomSelect)
10710 /* harmony export */ });
10711 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
10712 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
10713 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
10714 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10715 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
10716 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
10717 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
10718 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
10719 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
10720
10721
10722
10723
10724
10725
10726
10727
10728
10729 var instance_i = 0;
10730 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
10731 constructor(input_arg, user_settings) {
10732 super();
10733 this.order = 0;
10734 this.isOpen = false;
10735 this.isDisabled = false;
10736 this.isReadOnly = false;
10737 this.isInvalid = false; // @deprecated 1.8
10738 this.isValid = true;
10739 this.isLocked = false;
10740 this.isFocused = false;
10741 this.isInputHidden = false;
10742 this.isSetup = false;
10743 this.isDropdownContentStale = true;
10744 this.ignoreFocus = false;
10745 this.ignoreHover = false;
10746 this.hasOptions = false;
10747 this.lastValue = '';
10748 this.caretPos = 0;
10749 this.loading = 0;
10750 this.loadedSearches = {};
10751 this.activeOption = null;
10752 this.activeItems = [];
10753 this.optgroups = {};
10754 this.options = {};
10755 this.userOptions = {};
10756 this.items = [];
10757 this.refreshTimeout = null;
10758 instance_i++;
10759 var dir;
10760 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
10761 if (input.tomselect) {
10762 throw new Error('Tom Select already initialized on this element');
10763 }
10764 input.tomselect = this;
10765 // detect rtl environment
10766 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
10767 dir = computedStyle.getPropertyValue('direction');
10768 // setup default state
10769 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
10770 this.settings = settings;
10771 this.input = input;
10772 this.tabIndex = input.tabIndex || 0;
10773 this.is_select_tag = input.tagName.toLowerCase() === 'select';
10774 this.rtl = /rtl/i.test(dir);
10775 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
10776 this.isRequired = input.required;
10777 // search system
10778 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
10779 // option-dependent defaults
10780 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
10781 if (typeof settings.hideSelected !== 'boolean') {
10782 settings.hideSelected = settings.mode === 'multi';
10783 }
10784 if (typeof settings.hidePlaceholder !== 'boolean') {
10785 settings.hidePlaceholder = settings.mode !== 'multi';
10786 }
10787 // set up createFilter callback
10788 var filter = settings.createFilter;
10789 if (typeof filter !== 'function') {
10790 if (typeof filter === 'string') {
10791 filter = new RegExp(filter);
10792 }
10793 if (filter instanceof RegExp) {
10794 settings.createFilter = (input) => filter.test(input);
10795 }
10796 else {
10797 settings.createFilter = (value) => {
10798 return this.settings.duplicates || !this.options[value];
10799 };
10800 }
10801 }
10802 this.initializePlugins(settings.plugins);
10803 this.setupCallbacks();
10804 this.setupTemplates();
10805 // Create all elements
10806 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10807 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10808 const dropdown = this._render('dropdown');
10809 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
10810 const classes = this.input.getAttribute('class') || '';
10811 const inputMode = settings.mode;
10812 var control_input;
10813 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
10814 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
10815 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
10816 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
10817 if (settings.copyClassesToDropdown) {
10818 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
10819 }
10820 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
10821 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
10822 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
10823 // default controlInput
10824 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
10825 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10826 // set attributes
10827 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
10828 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
10829 if (input.getAttribute(attr)) {
10830 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
10831 }
10832 });
10833 control_input.tabIndex = -1;
10834 control.appendChild(control_input);
10835 this.focus_node = control_input;
10836 // dom element
10837 }
10838 else if (settings.controlInput) {
10839 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10840 this.focus_node = control_input;
10841 }
10842 else {
10843 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
10844 this.focus_node = control;
10845 }
10846 this.wrapper = wrapper;
10847 this.dropdown = dropdown;
10848 this.dropdown_content = dropdown_content;
10849 this.control = control;
10850 this.control_input = control_input;
10851 this.setup();
10852 }
10853 /**
10854 * set up event bindings.
10855 *
10856 */
10857 setup() {
10858 const self = this;
10859 const settings = self.settings;
10860 const control_input = self.control_input;
10861 const dropdown = self.dropdown;
10862 const dropdown_content = self.dropdown_content;
10863 const wrapper = self.wrapper;
10864 const control = self.control;
10865 const input = self.input;
10866 const focus_node = self.focus_node;
10867 const passive_event = { passive: true };
10868 const listboxId = self.inputId + '-ts-dropdown';
10869 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
10870 id: listboxId
10871 });
10872 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
10873 role: 'combobox',
10874 'aria-haspopup': 'listbox',
10875 'aria-expanded': 'false',
10876 'aria-controls': listboxId
10877 });
10878 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
10879 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
10880 const label = document.querySelector(query);
10881 const label_click = self.focus.bind(self);
10882 if (label) {
10883 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
10884 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
10885 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
10886 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
10887 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
10888 }
10889 wrapper.style.width = input.style.width;
10890 wrapper.style.minWidth = input.style.minWidth;
10891 wrapper.style.maxWidth = input.style.maxWidth;
10892 if (self.plugins.names.length) {
10893 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
10894 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
10895 }
10896 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
10897 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
10898 }
10899 if (settings.placeholder) {
10900 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
10901 }
10902 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
10903 if (!settings.splitOn && settings.delimiter) {
10904 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
10905 }
10906 // debounce user defined load() if loadThrottle > 0
10907 // after initializePlugins() so plugins can create/modify user defined loaders
10908 if (settings.load && settings.loadThrottle) {
10909 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
10910 }
10911 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
10912 self.ignoreHover = false;
10913 });
10914 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
10915 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
10916 if (target_match)
10917 self.onOptionHover(e, target_match);
10918 }, { capture: true });
10919 // clicking on an option should select it
10920 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
10921 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
10922 if (option) {
10923 self.onOptionSelect(evt, option);
10924 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10925 }
10926 });
10927 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
10928 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
10929 if (target_match && self.onItemSelect(evt, target_match)) {
10930 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10931 return;
10932 }
10933 // retain focus (see control_input mousedown)
10934 if (control_input.value != '') {
10935 return;
10936 }
10937 self.onClick();
10938 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10939 });
10940 // keydown on focus_node for arrow_down/arrow_up
10941 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
10942 // keypress and input/keyup
10943 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
10944 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
10945 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
10946 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
10947 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
10948 const doc_mousedown = (evt) => {
10949 // blur if target is outside of this instance
10950 // dropdown is not always inside wrapper
10951 const target = evt.composedPath()[0];
10952 if (!wrapper.contains(target) && !dropdown.contains(target)) {
10953 if (self.isFocused) {
10954 self.blur();
10955 }
10956 self.inputState();
10957 return;
10958 }
10959 // retain focus by preventing native handling. if the
10960 // event target is the input it should not be modified.
10961 // otherwise, text selection within the input won't work.
10962 // Fixes bug #212 which is no covered by tests
10963 if (target == control_input && self.isOpen) {
10964 evt.stopPropagation();
10965 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
10966 }
10967 else {
10968 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
10969 }
10970 };
10971 const win_scroll = () => {
10972 if (self.isOpen) {
10973 self.positionDropdown();
10974 }
10975 };
10976 const input_invalid = () => {
10977 if (self.isValid) {
10978 self.isValid = false;
10979 self.isInvalid = true;
10980 self.refreshState();
10981 }
10982 };
10983 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid);
10984 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
10985 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
10986 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
10987 this._destroy = () => {
10988 input.removeEventListener('invalid', input_invalid);
10989 document.removeEventListener('mousedown', doc_mousedown);
10990 window.removeEventListener('scroll', win_scroll);
10991 window.removeEventListener('resize', win_scroll);
10992 if (label)
10993 label.removeEventListener('click', label_click);
10994 };
10995 // store original html and tab index so that they can be
10996 // restored when the destroy() method is called.
10997 this.revertSettings = {
10998 innerHTML: input.innerHTML,
10999 tabIndex: input.tabIndex
11000 };
11001 input.tabIndex = -1;
11002 input.insertAdjacentElement('afterend', self.wrapper);
11003 self.sync(false);
11004 settings.items = [];
11005 delete settings.optgroups;
11006 delete settings.options;
11007 self.refreshItems();
11008 self.close(false);
11009 self.inputState();
11010 self.isSetup = true;
11011 self.on('change', this.onChange);
11012 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11013 self.trigger('initialize');
11014 // preload options
11015 if (settings.preload === true) {
11016 self.preload();
11017 }
11018 }
11019 /**
11020 * Register options and optgroups
11021 *
11022 */
11023 setupOptions(options = [], optgroups = []) {
11024 // build options table
11025 this.addOptions(options);
11026 // build optgroup table
11027 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11028 this.registerOptionGroup(optgroup);
11029 });
11030 }
11031 /**
11032 * Sets up default rendering functions.
11033 */
11034 setupTemplates() {
11035 var self = this;
11036 var field_label = self.settings.labelField;
11037 var field_optgroup = self.settings.optgroupLabelField;
11038 var templates = {
11039 'optgroup': (data) => {
11040 let optgroup = document.createElement('div');
11041 optgroup.className = 'optgroup';
11042 optgroup.appendChild(data.options);
11043 return optgroup;
11044 },
11045 'optgroup_header': (data, escape) => {
11046 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11047 },
11048 'option': (data, escape) => {
11049 return '<div>' + escape(data[field_label]) + '</div>';
11050 },
11051 'item': (data, escape) => {
11052 return '<div>' + escape(data[field_label]) + '</div>';
11053 },
11054 'option_create': (data, escape) => {
11055 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11056 },
11057 'no_results': () => {
11058 return '<div class="no-results">No results found</div>';
11059 },
11060 'loading': () => {
11061 return '<div class="spinner"></div>';
11062 },
11063 'not_loading': () => { },
11064 'dropdown': () => {
11065 return '<div></div>';
11066 }
11067 };
11068 self.settings.render = Object.assign({}, templates, self.settings.render);
11069 }
11070 /**
11071 * Maps fired events to callbacks provided
11072 * in the settings used when creating the control.
11073 */
11074 setupCallbacks() {
11075 var key, fn;
11076 var callbacks = {
11077 'initialize': 'onInitialize',
11078 'change': 'onChange',
11079 'item_add': 'onItemAdd',
11080 'item_remove': 'onItemRemove',
11081 'item_select': 'onItemSelect',
11082 'clear': 'onClear',
11083 'option_add': 'onOptionAdd',
11084 'option_remove': 'onOptionRemove',
11085 'option_clear': 'onOptionClear',
11086 'optgroup_add': 'onOptionGroupAdd',
11087 'optgroup_remove': 'onOptionGroupRemove',
11088 'optgroup_clear': 'onOptionGroupClear',
11089 'dropdown_open': 'onDropdownOpen',
11090 'dropdown_close': 'onDropdownClose',
11091 'type': 'onType',
11092 'load': 'onLoad',
11093 'focus': 'onFocus',
11094 'blur': 'onBlur'
11095 };
11096 for (key in callbacks) {
11097 fn = this.settings[callbacks[key]];
11098 if (fn)
11099 this.on(key, fn);
11100 }
11101 }
11102 /**
11103 * Sync the Tom Select instance with the original input or select
11104 *
11105 */
11106 sync(get_settings = true) {
11107 const self = this;
11108 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings;
11109 self.setupOptions(settings.options, settings.optgroups);
11110 self.setValue(settings.items || [], true); // silent prevents recursion
11111 if (self.input.disabled) {
11112 self.disable();
11113 }
11114 else if (self.input.readOnly) {
11115 self.setReadOnly(true);
11116 }
11117 else {
11118 self.enable(); //sets tabIndex
11119 }
11120 self.lastQuery = null; // so updated options will be displayed in dropdown
11121 }
11122 /**
11123 * Triggered when the main control element
11124 * has a click event.
11125 *
11126 */
11127 onClick() {
11128 var self = this;
11129 if (self.activeItems.length > 0) {
11130 self.clearActiveItems();
11131 self.focus();
11132 return;
11133 }
11134 if (self.isFocused && self.isOpen) {
11135 self.blur();
11136 }
11137 else {
11138 self.focus();
11139 }
11140 }
11141 /**
11142 * @deprecated v1.7
11143 *
11144 */
11145 onMouseDown() { }
11146 /**
11147 * Triggered when the value of the control has been changed.
11148 * This should propagate the event to the original DOM
11149 * input / select element.
11150 */
11151 onChange() {
11152 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11153 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11154 }
11155 /**
11156 * Triggered on <input> paste.
11157 *
11158 */
11159 onPaste(e) {
11160 var self = this;
11161 if (self.isInputHidden || self.isLocked) {
11162 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11163 return;
11164 }
11165 // If a regex or string is included, this will split the pasted
11166 // input and create Items for each separate value
11167 if (!self.settings.splitOn) {
11168 return;
11169 }
11170 // Wait for pasted text to be recognized in value
11171 setTimeout(() => {
11172 var pastedText = self.inputValue();
11173 if (!pastedText.match(self.settings.splitOn)) {
11174 return;
11175 }
11176 var splitInput = pastedText.trim().split(self.settings.splitOn);
11177 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11178 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11179 if (hash) {
11180 if (this.options[piece]) {
11181 self.addItem(piece);
11182 }
11183 else {
11184 self.createItem(piece);
11185 }
11186 }
11187 });
11188 }, 0);
11189 }
11190 /**
11191 * Triggered on <input> keypress.
11192 *
11193 */
11194 onKeyPress(e) {
11195 var self = this;
11196 if (self.isLocked) {
11197 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11198 return;
11199 }
11200 var character = String.fromCharCode(e.keyCode || e.which);
11201 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11202 self.createItem();
11203 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11204 return;
11205 }
11206 }
11207 /**
11208 * Triggered on <input> keydown.
11209 *
11210 */
11211 onKeyDown(e) {
11212 var self = this;
11213 self.ignoreHover = true;
11214 if (self.isLocked) {
11215 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11216 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11217 }
11218 return;
11219 }
11220 switch (e.keyCode) {
11221 // ctrl+A: select all
11222 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11223 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11224 if (self.control_input.value == '') {
11225 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11226 self.selectAll();
11227 return;
11228 }
11229 }
11230 break;
11231 // esc: close dropdown
11232 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11233 if (self.isOpen) {
11234 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11235 self.close();
11236 }
11237 self.clearActiveItems();
11238 return;
11239 // down: open dropdown or move selection down
11240 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11241 if (!self.isOpen && self.hasOptions) {
11242 self.open();
11243 }
11244 else if (self.activeOption) {
11245 let next = self.getAdjacent(self.activeOption, 1);
11246 if (next)
11247 self.setActiveOption(next);
11248 }
11249 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11250 return;
11251 // up: move selection up
11252 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11253 if (self.activeOption) {
11254 let prev = self.getAdjacent(self.activeOption, -1);
11255 if (prev)
11256 self.setActiveOption(prev);
11257 }
11258 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11259 return;
11260 // return: select active option
11261 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11262 if (self.canSelect(self.activeOption)) {
11263 self.onOptionSelect(e, self.activeOption);
11264 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11265 // if the option_create=null, the dropdown might be closed
11266 }
11267 else if (self.settings.create && self.createItem()) {
11268 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11269 // don't submit form when searching for a value
11270 }
11271 else if (document.activeElement == self.control_input && self.isOpen) {
11272 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11273 }
11274 return;
11275 // left: modifiy item selection to the left
11276 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11277 self.advanceSelection(-1, e);
11278 return;
11279 // right: modifiy item selection to the right
11280 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11281 self.advanceSelection(1, e);
11282 return;
11283 // tab: select active option and/or create item
11284 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11285 if (self.settings.selectOnTab) {
11286 if (self.canSelect(self.activeOption)) {
11287 self.onOptionSelect(e, self.activeOption);
11288 // prevent default [tab] behaviour of jump to the next field
11289 // if select isFull, then the dropdown won't be open and [tab] will work normally
11290 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11291 }
11292 else if (self.settings.create && self.createItem()) {
11293 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11294 }
11295 }
11296 return;
11297 // delete|backspace: delete items
11298 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11299 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11300 self.deleteSelection(e);
11301 return;
11302 }
11303 // don't enter text in the control_input when active items are selected
11304 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11305 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11306 }
11307 }
11308 /**
11309 * Triggered on <input> keyup.
11310 *
11311 */
11312 onInput(e) {
11313 if (this.isLocked) {
11314 return;
11315 }
11316 const value = this.inputValue();
11317 if (this.lastValue === value)
11318 return;
11319 this.lastValue = value;
11320 if (value == '') {
11321 this._onInput();
11322 return;
11323 }
11324 if (this.refreshTimeout) {
11325 window.clearTimeout(this.refreshTimeout);
11326 }
11327 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11328 this.refreshTimeout = null;
11329 this._onInput();
11330 }, this.settings.refreshThrottle);
11331 }
11332 _onInput() {
11333 const value = this.lastValue;
11334 if (this.settings.shouldLoad.call(this, value)) {
11335 this.load(value);
11336 }
11337 this.refreshOptions();
11338 this.trigger('type', value);
11339 }
11340 /**
11341 * Triggered when the user rolls over
11342 * an option in the autocomplete dropdown menu.
11343 *
11344 */
11345 onOptionHover(evt, option) {
11346 if (this.ignoreHover)
11347 return;
11348 this.setActiveOption(option, false);
11349 }
11350 /**
11351 * Triggered on <input> focus.
11352 *
11353 */
11354 onFocus(e) {
11355 var self = this;
11356 var wasFocused = self.isFocused;
11357 if (self.isDisabled || self.isReadOnly) {
11358 self.blur();
11359 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11360 return;
11361 }
11362 if (self.ignoreFocus)
11363 return;
11364 self.isFocused = true;
11365 if (self.settings.preload === 'focus')
11366 self.preload();
11367 if (!wasFocused)
11368 self.trigger('focus');
11369 if (!self.activeItems.length) {
11370 self.inputState();
11371 self.refreshOptions(!!self.settings.openOnFocus);
11372 }
11373 self.refreshState();
11374 }
11375 /**
11376 * Triggered on <input> blur.
11377 *
11378 */
11379 onBlur(e) {
11380 if (document.hasFocus() === false)
11381 return;
11382 var self = this;
11383 if (!self.isFocused)
11384 return;
11385 self.isFocused = false;
11386 self.ignoreFocus = false;
11387 var deactivate = () => {
11388 self.close();
11389 self.setActiveItem();
11390 self.setCaret(self.items.length);
11391 self.trigger('blur');
11392 };
11393 if (self.settings.create && self.settings.createOnBlur) {
11394 self.createItem(null, deactivate);
11395 }
11396 else {
11397 deactivate();
11398 }
11399 }
11400 /**
11401 * Triggered when the user clicks on an option
11402 * in the autocomplete dropdown menu.
11403 *
11404 */
11405 onOptionSelect(evt, option) {
11406 var value, self = this;
11407 // should not be possible to trigger a option under a disabled optgroup
11408 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
11409 return;
11410 }
11411 if (option.classList.contains('create')) {
11412 self.createItem(null, () => {
11413 if (self.settings.closeAfterSelect) {
11414 self.close();
11415 }
11416 else if (self.settings.clearAfterSelect) {
11417 self.setTextboxValue();
11418 }
11419 });
11420 }
11421 else {
11422 value = option.dataset.value;
11423 if (typeof value !== 'undefined') {
11424 self.isDropdownContentStale = self.settings.hideSelected;
11425 self.addItem(value);
11426 if (self.settings.closeAfterSelect) {
11427 self.close();
11428 }
11429 else if (self.settings.clearAfterSelect) {
11430 self.setTextboxValue();
11431 }
11432 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
11433 self.setActiveOption(option);
11434 }
11435 }
11436 }
11437 }
11438 /**
11439 * Return true if the given option can be selected
11440 *
11441 */
11442 canSelect(option) {
11443 if (this.isOpen && option && this.dropdown_content.contains(option)) {
11444 return true;
11445 }
11446 return false;
11447 }
11448 /**
11449 * Triggered when the user clicks on an item
11450 * that has been selected.
11451 *
11452 */
11453 onItemSelect(evt, item) {
11454 var self = this;
11455 if (!self.isLocked && self.settings.mode === 'multi') {
11456 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
11457 self.setActiveItem(item, evt);
11458 return true;
11459 }
11460 return false;
11461 }
11462 /**
11463 * Determines whether or not to invoke
11464 * the user-provided option provider / loader
11465 *
11466 * Note, there is a subtle difference between
11467 * this.canLoad() and this.settings.shouldLoad();
11468 *
11469 * - settings.shouldLoad() is a user-input validator.
11470 * When false is returned, the not_loading template
11471 * will be added to the dropdown
11472 *
11473 * - canLoad() is lower level validator that checks
11474 * the Tom Select instance. There is no inherent user
11475 * feedback when canLoad returns false
11476 *
11477 */
11478 canLoad(value) {
11479 if (!this.settings.load)
11480 return false;
11481 if (this.loadedSearches.hasOwnProperty(value))
11482 return false;
11483 return true;
11484 }
11485 /**
11486 * Invokes the user-provided option provider / loader.
11487 *
11488 */
11489 load(value) {
11490 const self = this;
11491 if (!self.canLoad(value))
11492 return;
11493 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
11494 self.loading++;
11495 const callback = self.loadCallback.bind(self);
11496 self.settings.load.call(self, value, callback);
11497 }
11498 /**
11499 * Invoked by the user-provided option provider
11500 *
11501 */
11502 loadCallback(options, optgroups) {
11503 const self = this;
11504 self.loading = Math.max(self.loading - 1, 0);
11505 self.isDropdownContentStale = true;
11506 self.clearActiveOption(); // when new results load, focus should be on first option
11507 self.setupOptions(options, optgroups);
11508 self.refreshOptions(self.isFocused && !self.isInputHidden);
11509 if (!self.loading) {
11510 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
11511 }
11512 self.trigger('load', options, optgroups);
11513 }
11514 preload() {
11515 var classList = this.wrapper.classList;
11516 if (classList.contains('preloaded'))
11517 return;
11518 classList.add('preloaded');
11519 this.load('');
11520 }
11521 /**
11522 * Sets the input field of the control to the specified value.
11523 *
11524 */
11525 setTextboxValue(value = '') {
11526 var input = this.control_input;
11527 var changed = input.value !== value;
11528 if (changed) {
11529 input.value = value;
11530 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
11531 this.lastValue = value;
11532 }
11533 }
11534 /**
11535 * Returns the value of the control. If multiple items
11536 * can be selected (e.g. <select multiple>), this returns
11537 * an array. If only one item can be selected, this
11538 * returns a string.
11539 *
11540 */
11541 getValue() {
11542 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
11543 return this.items;
11544 }
11545 return this.items.join(this.settings.delimiter);
11546 }
11547 /**
11548 * Resets the selected items to the given value.
11549 *
11550 */
11551 setValue(value, silent) {
11552 var events = silent ? [] : ['change'];
11553 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
11554 this.clear(silent);
11555 this.addItems(value, silent);
11556 });
11557 }
11558 /**
11559 * Resets the number of max items to the given value
11560 *
11561 */
11562 setMaxItems(value) {
11563 if (value === 0)
11564 value = null; //reset to unlimited items.
11565 this.settings.maxItems = value;
11566 this.refreshState();
11567 }
11568 /**
11569 * Sets the selected item.
11570 *
11571 */
11572 setActiveItem(item, e) {
11573 var self = this;
11574 var eventName;
11575 var i, begin, end, swap;
11576 var last;
11577 if (self.settings.mode === 'single')
11578 return;
11579 // clear the active selection
11580 if (!item) {
11581 self.clearActiveItems();
11582 if (self.isFocused) {
11583 self.inputState();
11584 }
11585 return;
11586 }
11587 // modify selection
11588 eventName = e && e.type.toLowerCase();
11589 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
11590 last = self.getLastActive();
11591 begin = Array.prototype.indexOf.call(self.control.children, last);
11592 end = Array.prototype.indexOf.call(self.control.children, item);
11593 if (begin > end) {
11594 swap = begin;
11595 begin = end;
11596 end = swap;
11597 }
11598 for (i = begin; i <= end; i++) {
11599 item = self.control.children[i];
11600 if (self.activeItems.indexOf(item) === -1) {
11601 self.setActiveItemClass(item);
11602 }
11603 }
11604 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11605 }
11606 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))) {
11607 if (item.classList.contains('active')) {
11608 self.removeActiveItem(item);
11609 }
11610 else {
11611 self.setActiveItemClass(item);
11612 }
11613 }
11614 else {
11615 self.clearActiveItems();
11616 self.setActiveItemClass(item);
11617 }
11618 // ensure control has focus
11619 self.inputState();
11620 if (!self.isFocused) {
11621 self.focus();
11622 }
11623 }
11624 /**
11625 * Set the active and last-active classes
11626 *
11627 */
11628 setActiveItemClass(item) {
11629 const self = this;
11630 const last_active = self.control.querySelector('.last-active');
11631 if (last_active)
11632 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
11633 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
11634 self.trigger('item_select', item);
11635 if (self.activeItems.indexOf(item) == -1) {
11636 self.activeItems.push(item);
11637 }
11638 }
11639 /**
11640 * Remove active item
11641 *
11642 */
11643 removeActiveItem(item) {
11644 var idx = this.activeItems.indexOf(item);
11645 this.activeItems.splice(idx, 1);
11646 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
11647 }
11648 /**
11649 * Clears all the active items
11650 *
11651 */
11652 clearActiveItems() {
11653 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
11654 this.activeItems = [];
11655 }
11656 /**
11657 * Sets the selected item in the dropdown menu
11658 * of available options.
11659 *
11660 */
11661 setActiveOption(option, scroll = true) {
11662 if (option === this.activeOption) {
11663 return;
11664 }
11665 this.clearActiveOption();
11666 if (!option)
11667 return;
11668 this.activeOption = option;
11669 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
11670 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
11671 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
11672 if (scroll)
11673 this.scrollToOption(option);
11674 }
11675 /**
11676 * Sets the dropdown_content scrollTop to display the option
11677 *
11678 */
11679 scrollToOption(option, behavior) {
11680 if (!option)
11681 return;
11682 const content = this.dropdown_content;
11683 const height_menu = content.clientHeight;
11684 const scrollTop = content.scrollTop || 0;
11685 const height_item = option.offsetHeight;
11686 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
11687 if (y + height_item > height_menu + scrollTop) {
11688 this.scroll(y - height_menu + height_item, behavior);
11689 }
11690 else if (y < scrollTop) {
11691 this.scroll(y, behavior);
11692 }
11693 }
11694 /**
11695 * Scroll the dropdown to the given position
11696 *
11697 */
11698 scroll(scrollTop, behavior) {
11699 const content = this.dropdown_content;
11700 if (behavior) {
11701 content.style.scrollBehavior = behavior;
11702 }
11703 content.scrollTop = scrollTop;
11704 content.style.scrollBehavior = '';
11705 }
11706 /**
11707 * Clears the active option
11708 *
11709 */
11710 clearActiveOption() {
11711 if (this.activeOption) {
11712 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
11713 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
11714 }
11715 this.activeOption = null;
11716 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
11717 }
11718 /**
11719 * Selects all items (CTRL + A).
11720 */
11721 selectAll() {
11722 const self = this;
11723 if (self.settings.mode === 'single')
11724 return;
11725 const activeItems = self.controlChildren();
11726 if (!activeItems.length)
11727 return;
11728 self.inputState();
11729 self.close();
11730 self.activeItems = activeItems;
11731 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
11732 self.setActiveItemClass(item);
11733 });
11734 }
11735 /**
11736 * Determines if the control_input should be in a hidden or visible state
11737 *
11738 */
11739 inputState() {
11740 var self = this;
11741 if (!self.control.contains(self.control_input))
11742 return;
11743 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
11744 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
11745 self.setTextboxValue();
11746 self.isInputHidden = true;
11747 }
11748 else {
11749 if (self.settings.hidePlaceholder && self.items.length > 0) {
11750 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
11751 }
11752 self.isInputHidden = false;
11753 }
11754 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
11755 }
11756 /**
11757 * Get the input value
11758 */
11759 inputValue() {
11760 return this.control_input.value.trim();
11761 }
11762 /**
11763 * Gives the control focus.
11764 */
11765 focus() {
11766 var self = this;
11767 if (self.isDisabled || self.isReadOnly)
11768 return;
11769 self.ignoreFocus = true;
11770 const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node;
11771 focusTarget.focus();
11772 setTimeout(() => {
11773 self.ignoreFocus = false;
11774 // Fix https://github.com/orchidjs/tom-select/issues/806
11775 // Only proceed if this instance's element is still the active element. If Edge autofill
11776 // (or anything else) has moved focus to a different element in the interim, calling
11777 // onFocus() here would steal focus back and restart the cascade loop.
11778 const root = focusTarget.getRootNode();
11779 if (root.activeElement !== focusTarget) {
11780 return;
11781 }
11782 this.onFocus();
11783 }, 0);
11784 }
11785 /**
11786 * Forces the control out of focus.
11787 *
11788 */
11789 blur() {
11790 this.focus_node.blur();
11791 this.onBlur();
11792 }
11793 /**
11794 * Returns a function that scores an object
11795 * to show how good of a match it is to the
11796 * provided query.
11797 *
11798 * @return {function}
11799 */
11800 getScoreFunction(query) {
11801 return this.sifter.getScoreFunction(query, this.getSearchOptions());
11802 }
11803 /**
11804 * Returns search options for sifter (the system
11805 * for scoring and sorting results).
11806 *
11807 * @see https://github.com/orchidjs/sifter.js
11808 * @return {object}
11809 */
11810 getSearchOptions() {
11811 var settings = this.settings;
11812 var sort = settings.sortField;
11813 if (typeof settings.sortField === 'string') {
11814 sort = [{ field: settings.sortField }];
11815 }
11816 return {
11817 fields: settings.searchField,
11818 conjunction: settings.searchConjunction,
11819 sort: sort,
11820 nesting: settings.nesting
11821 };
11822 }
11823 /**
11824 * Searches through available options and returns
11825 * a sorted array of matches.
11826 *
11827 */
11828 search(query) {
11829 var result, calculateScore;
11830 var self = this;
11831 var options = this.getSearchOptions();
11832 // validate user-provided result scoring function
11833 if (self.settings.score) {
11834 calculateScore = self.settings.score.call(self, query);
11835 if (typeof calculateScore !== 'function') {
11836 throw new Error('Tom Select "score" setting must be a function that returns a function');
11837 }
11838 }
11839 // perform search
11840 if (self.isDropdownContentStale || query !== self.lastQuery) {
11841 self.lastQuery = query;
11842 // temp fix for https://github.com/orchidjs/tom-select/issues/987
11843 // UI crashed when more than 30 same chars in a row, prevent search and return empt result
11844 if (/(.)\1{15,}/.test(query)) {
11845 query = '';
11846 }
11847 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
11848 self.currentResults = result;
11849 }
11850 else {
11851 result = Object.assign({}, self.currentResults);
11852 }
11853 // filter out selected items
11854 if (self.settings.hideSelected) {
11855 result.items = result.items.filter((item) => {
11856 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
11857 return !(hashed !== null && self.items.indexOf(hashed) !== -1);
11858 });
11859 }
11860 return result;
11861 }
11862 /**
11863 * Refreshes the list of available options shown
11864 * in the autocomplete dropdown menu.
11865 *
11866 */
11867 refreshOptions(triggerDropdown = true) {
11868 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
11869 var create;
11870 const groups = {};
11871 const groups_order = [];
11872 var self = this;
11873 var query = self.inputValue();
11874 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
11875 var results = self.search(query);
11876 var active_option = null;
11877 var show_dropdown = self.settings.shouldOpen || false;
11878 var dropdown_content = self.dropdown_content;
11879 if (same_query) {
11880 active_option = self.activeOption;
11881 if (active_option) {
11882 active_group = active_option.closest('[data-group]');
11883 }
11884 }
11885 // build markup
11886 n = results.items.length;
11887 if (typeof self.settings.maxOptions === 'number') {
11888 n = Math.min(n, self.settings.maxOptions);
11889 }
11890 if (n > 0) {
11891 show_dropdown = true;
11892 }
11893 // get fragment for group and the position of the group in group_order
11894 const getGroupFragment = (optgroup, order) => {
11895 let group_order_i = groups[optgroup];
11896 if (group_order_i !== undefined) {
11897 let order_group = groups_order[group_order_i];
11898 if (order_group !== undefined) {
11899 return [group_order_i, order_group.fragment];
11900 }
11901 }
11902 let group_fragment = document.createDocumentFragment();
11903 group_order_i = groups_order.length;
11904 groups_order.push({ fragment: group_fragment, order, optgroup });
11905 return [group_order_i, group_fragment];
11906 };
11907 // render and group available options individually
11908 for (i = 0; i < n; i++) {
11909 // get option dom element
11910 let item = results.items[i];
11911 if (!item)
11912 continue;
11913 let opt_value = item.id;
11914 let option = self.options[opt_value];
11915 if (option === undefined)
11916 continue;
11917 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
11918 let option_el = self.getOption(opt_hash, true);
11919 // toggle 'selected' class
11920 if (!self.settings.hideSelected) {
11921 option_el.classList.toggle('selected', self.items.includes(opt_hash));
11922 }
11923 optgroup = option[self.settings.optgroupField] || '';
11924 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
11925 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
11926 optgroup = optgroups[j];
11927 let order = option.$order;
11928 let self_optgroup = self.optgroups[optgroup];
11929 if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') {
11930 var regGroup;
11931 if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) {
11932 self.registerOptionGroup(regGroup);
11933 }
11934 }
11935 self_optgroup = self.optgroups[optgroup];
11936 if (self_optgroup === undefined) {
11937 optgroup = '';
11938 }
11939 else {
11940 order = self_optgroup.$order;
11941 }
11942 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
11943 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
11944 if (j > 0) {
11945 option_el = option_el.cloneNode(true);
11946 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
11947 option_el.classList.add('ts-cloned');
11948 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
11949 // make sure we keep the activeOption in the same group
11950 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
11951 if (active_group && active_group.dataset.group === optgroup.toString()) {
11952 active_option = option_el;
11953 }
11954 }
11955 }
11956 group_fragment.appendChild(option_el);
11957 if (optgroup != '') {
11958 groups[optgroup] = group_order_i;
11959 }
11960 }
11961 }
11962 // sort optgroups
11963 if (self.settings.lockOptgroupOrder) {
11964 groups_order.sort((a, b) => {
11965 return a.order - b.order;
11966 });
11967 }
11968 // render optgroup headers & join groups
11969 html = document.createDocumentFragment();
11970 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
11971 let group_fragment = group_order.fragment;
11972 let optgroup = group_order.optgroup;
11973 if (!group_fragment || !group_fragment.children.length)
11974 return;
11975 let group_heading = self.optgroups[optgroup];
11976 if (group_heading !== undefined) {
11977 let group_options = document.createDocumentFragment();
11978 let header = self.render('optgroup_header', group_heading);
11979 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
11980 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
11981 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
11982 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
11983 }
11984 else {
11985 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
11986 }
11987 });
11988 dropdown_content.innerHTML = '';
11989 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
11990 self.isDropdownContentStale = false;
11991 // highlight matching terms inline
11992 if (self.settings.highlight) {
11993 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
11994 if (results.query.length && results.tokens.length) {
11995 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
11996 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
11997 });
11998 }
11999 }
12000 // helper method for adding templates to dropdown
12001 var add_template = (template) => {
12002 let content = self.render(template, { input: query });
12003 if (content) {
12004 show_dropdown = true;
12005 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12006 }
12007 return content;
12008 };
12009 // add loading message
12010 if (self.loading) {
12011 add_template('loading');
12012 // invalid query
12013 }
12014 else if (!self.settings.shouldLoad.call(self, query)) {
12015 add_template('not_loading');
12016 // add no_results message
12017 }
12018 else if (results.items.length === 0) {
12019 add_template('no_results');
12020 }
12021 // add create option
12022 has_create_option = self.canCreate(query);
12023 if (has_create_option) {
12024 create = add_template('option_create');
12025 }
12026 // activate
12027 self.hasOptions = results.items.length > 0 || has_create_option;
12028 if (show_dropdown) {
12029 if (results.items.length > 0) {
12030 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12031 active_option = self.getOption(self.items[0]);
12032 }
12033 if (!dropdown_content.contains(active_option)) {
12034 let active_index = 0;
12035 if (create && !self.settings.addPrecedence) {
12036 active_index = 1;
12037 }
12038 active_option = self.selectable()[active_index];
12039 }
12040 }
12041 else if (create) {
12042 active_option = create;
12043 }
12044 if (triggerDropdown && !self.isOpen) {
12045 self.open();
12046 self.scrollToOption(active_option, 'auto');
12047 }
12048 self.setActiveOption(active_option);
12049 }
12050 else {
12051 self.clearActiveOption();
12052 if (triggerDropdown && self.isOpen) {
12053 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12054 }
12055 }
12056 }
12057 /**
12058 * Return list of selectable options
12059 *
12060 */
12061 selectable() {
12062 return this.dropdown_content.querySelectorAll('[data-selectable]');
12063 }
12064 /**
12065 * Adds an available option. If it already exists,
12066 * nothing will happen. Note: this does not refresh
12067 * the options list dropdown (use `refreshOptions`
12068 * for that).
12069 *
12070 * Usage:
12071 *
12072 * this.addOption(data)
12073 *
12074 */
12075 addOption(data, user_created = false) {
12076 const self = this;
12077 // @deprecated 1.7.7
12078 // use addOptions( array, user_created ) for adding multiple options
12079 if (Array.isArray(data)) {
12080 self.addOptions(data, user_created);
12081 return false;
12082 }
12083 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12084 if (key === null || self.options.hasOwnProperty(key)) {
12085 self.updateOption(data[self.settings.valueField], data);
12086 return false;
12087 }
12088 data.$order = data.$order || ++self.order;
12089 data.$id = self.inputId + '-opt-' + data.$order;
12090 self.options[key] = data;
12091 self.isDropdownContentStale = true;
12092 if (user_created) {
12093 self.userOptions[key] = user_created;
12094 self.trigger('option_add', key, data);
12095 }
12096 return key;
12097 }
12098 /**
12099 * Add multiple options
12100 *
12101 */
12102 addOptions(data, user_created = false) {
12103 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12104 this.addOption(dat, user_created);
12105 });
12106 }
12107 /**
12108 * @deprecated 1.7.7
12109 */
12110 registerOption(data) {
12111 return this.addOption(data);
12112 }
12113 /**
12114 * Registers an option group to the pool of option groups.
12115 *
12116 * @return {boolean|string}
12117 */
12118 registerOptionGroup(data) {
12119 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12120 if (key === null)
12121 return false;
12122 data.$order = data.$order || ++this.order;
12123 this.optgroups[key] = data;
12124 return key;
12125 }
12126 /**
12127 * Registers a new optgroup for options
12128 * to be bucketed into.
12129 *
12130 */
12131 addOptionGroup(id, data) {
12132 var hashed_id;
12133 data[this.settings.optgroupValueField] = id;
12134 if (hashed_id = this.registerOptionGroup(data)) {
12135 this.trigger('optgroup_add', hashed_id, data);
12136 }
12137 }
12138 /**
12139 * Removes an existing option group.
12140 *
12141 */
12142 removeOptionGroup(id) {
12143 if (this.optgroups.hasOwnProperty(id)) {
12144 delete this.optgroups[id];
12145 this.clearCache();
12146 this.trigger('optgroup_remove', id);
12147 }
12148 }
12149 /**
12150 * Clears all existing option groups.
12151 */
12152 clearOptionGroups() {
12153 this.optgroups = {};
12154 this.clearCache();
12155 this.trigger('optgroup_clear');
12156 }
12157 /**
12158 * Updates an option available for selection. If
12159 * it is visible in the selected items or options
12160 * dropdown, it will be re-rendered automatically.
12161 *
12162 */
12163 updateOption(value, data) {
12164 const self = this;
12165 var item_new;
12166 var index_item;
12167 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12168 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12169 // sanity checks
12170 if (value_old === null)
12171 return;
12172 const data_old = self.options[value_old];
12173 if (data_old == undefined)
12174 return;
12175 if (typeof value_new !== 'string')
12176 throw new Error('Value must be set in option data');
12177 const option = self.getOption(value_old);
12178 const item = self.getItem(value_old);
12179 data.$order = data.$order || data_old.$order;
12180 delete self.options[value_old];
12181 // invalidate render cache
12182 // don't remove existing node yet, we'll remove it after replacing it
12183 self.uncacheValue(value_new);
12184 self.options[value_new] = data;
12185 // update the option if it's in the dropdown
12186 if (option) {
12187 if (self.dropdown_content.contains(option)) {
12188 const option_new = self._render('option', data);
12189 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12190 if (self.activeOption === option) {
12191 self.setActiveOption(option_new);
12192 }
12193 }
12194 option.remove();
12195 }
12196 // update the item if we have one
12197 if (item) {
12198 index_item = self.items.indexOf(value_old);
12199 if (index_item !== -1) {
12200 self.items.splice(index_item, 1, value_new);
12201 }
12202 item_new = self._render('item', data);
12203 if (item.classList.contains('active'))
12204 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12205 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12206 }
12207 // we might have updated the sortField
12208 self.isDropdownContentStale = true;
12209 }
12210 /**
12211 * Removes a single option.
12212 *
12213 */
12214 removeOption(value, silent) {
12215 const self = this;
12216 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12217 self.uncacheValue(value);
12218 delete self.userOptions[value];
12219 delete self.options[value];
12220 self.isDropdownContentStale = true;
12221 self.trigger('option_remove', value);
12222 self.removeItem(value, silent);
12223 }
12224 /**
12225 * Clears all options.
12226 */
12227 clearOptions(filter) {
12228 const boundFilter = (filter || this.clearFilter).bind(this);
12229 this.loadedSearches = {};
12230 this.userOptions = {};
12231 this.clearCache();
12232 const selected = {};
12233 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12234 if (boundFilter(option, key)) {
12235 selected[key] = option;
12236 }
12237 });
12238 this.options = this.sifter.items = selected;
12239 this.isDropdownContentStale = true;
12240 this.trigger('option_clear');
12241 }
12242 /**
12243 * Used by clearOptions() to decide whether or not an option should be removed
12244 * Return true to keep an option, false to remove
12245 *
12246 */
12247 clearFilter(option, value) {
12248 if (this.items.indexOf(value) >= 0) {
12249 return true;
12250 }
12251 return false;
12252 }
12253 /**
12254 * Returns the dom element of the option
12255 * matching the given value.
12256 *
12257 */
12258 getOption(value, create = false) {
12259 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12260 if (hashed === null)
12261 return null;
12262 const option = this.options[hashed];
12263 if (option != undefined) {
12264 if (option.$div) {
12265 return option.$div;
12266 }
12267 if (create) {
12268 return this._render('option', option);
12269 }
12270 }
12271 return null;
12272 }
12273 /**
12274 * Returns the dom element of the next or previous dom element of the same type
12275 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12276 *
12277 */
12278 getAdjacent(option, direction, type = 'option') {
12279 var self = this, all;
12280 if (!option) {
12281 return null;
12282 }
12283 if (type == 'item') {
12284 all = self.controlChildren();
12285 }
12286 else {
12287 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12288 }
12289 for (let i = 0; i < all.length; i++) {
12290 if (all[i] != option) {
12291 continue;
12292 }
12293 if (direction > 0) {
12294 return all[i + 1];
12295 }
12296 return all[i - 1];
12297 }
12298 return null;
12299 }
12300 /**
12301 * Returns the dom element of the item
12302 * matching the given value.
12303 *
12304 */
12305 getItem(item) {
12306 if (typeof item == 'object') {
12307 return item;
12308 }
12309 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12310 return value !== null
12311 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12312 : null;
12313 }
12314 /**
12315 * "Selects" multiple items at once. Adds them to the list
12316 * at the current caret position.
12317 *
12318 */
12319 addItems(values, silent) {
12320 var self = this;
12321 var items = Array.isArray(values) ? values : [values];
12322 items = items.filter(x => self.items.indexOf(x) === -1);
12323 const last_item = items[items.length - 1];
12324 items.forEach(item => {
12325 self.isPending = (item !== last_item);
12326 self.addItem(item, silent);
12327 });
12328 }
12329 /**
12330 * "Selects" an item. Adds it to the list
12331 * at the current caret position.
12332 *
12333 */
12334 addItem(value, silent) {
12335 var events = silent ? [] : ['change', 'dropdown_close'];
12336 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12337 var item, wasFull;
12338 const self = this;
12339 const inputMode = self.settings.mode;
12340 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12341 if (hashed && self.items.indexOf(hashed) !== -1) {
12342 if (inputMode === 'single') {
12343 self.close();
12344 }
12345 if (inputMode === 'single' || !self.settings.duplicates) {
12346 return;
12347 }
12348 }
12349 if (hashed === null || !self.options.hasOwnProperty(hashed))
12350 return;
12351 if (inputMode === 'single')
12352 self.clear(silent);
12353 if (inputMode === 'multi' && self.isFull())
12354 return;
12355 item = self._render('item', self.options[hashed]);
12356 if (self.control.contains(item)) { // duplicates
12357 item = item.cloneNode(true);
12358 }
12359 wasFull = self.isFull();
12360 self.items.splice(self.caretPos, 0, hashed);
12361 self.insertAtCaret(item);
12362 if (self.isSetup) {
12363 // update menu / remove the option (if this is not one item being added as part of series)
12364 if (!self.isPending && self.settings.hideSelected) {
12365 let option = self.getOption(hashed);
12366 let next = self.getAdjacent(option, 1);
12367 if (next) {
12368 self.setActiveOption(next);
12369 }
12370 }
12371 //remove input value when enabled
12372 if (self.settings.clearAfterSelect) {
12373 self.setTextboxValue();
12374 }
12375 // refreshOptions after setActiveOption(),
12376 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12377 if (!self.isPending && !self.settings.closeAfterSelect) {
12378 self.refreshOptions(self.isFocused && inputMode !== 'single');
12379 }
12380 // hide the menu if the maximum number of items have been selected or no options are left
12381 if (self.settings.closeAfterSelect != false && self.isFull()) {
12382 self.close();
12383 }
12384 else if (!self.isPending) {
12385 self.positionDropdown();
12386 }
12387 self.trigger('item_add', hashed, item);
12388 if (!self.isPending) {
12389 self.updateOriginalInput({ silent: silent });
12390 }
12391 }
12392 if (!self.isPending || (!wasFull && self.isFull())) {
12393 self.inputState();
12394 self.refreshState();
12395 }
12396 });
12397 }
12398 /**
12399 * Removes the selected item matching
12400 * the provided value.
12401 *
12402 */
12403 removeItem(item = null, silent) {
12404 const self = this;
12405 item = self.getItem(item);
12406 if (!item)
12407 return;
12408 var i, idx;
12409 const value = item.dataset.value;
12410 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
12411 item.remove();
12412 if (item.classList.contains('active')) {
12413 idx = self.activeItems.indexOf(item);
12414 self.activeItems.splice(idx, 1);
12415 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12416 }
12417 self.items.splice(i, 1);
12418 self.isDropdownContentStale = true;
12419 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
12420 self.removeOption(value, silent);
12421 }
12422 if (i < self.caretPos) {
12423 self.setCaret(self.caretPos - 1);
12424 }
12425 self.updateOriginalInput({ silent: silent });
12426 self.refreshState();
12427 self.positionDropdown();
12428 self.trigger('item_remove', value, item);
12429 }
12430 /**
12431 * Invokes the `create` method provided in the
12432 * TomSelect options that should provide the data
12433 * for the new item, given the user input.
12434 *
12435 * Once this completes, it will be added
12436 * to the item list.
12437 *
12438 */
12439 createItem(input = null, callback = () => { }) {
12440 // triggerDropdown parameter @deprecated 2.1.1
12441 if (arguments.length === 3) {
12442 callback = arguments[2];
12443 }
12444 if (typeof callback != 'function') {
12445 callback = () => { };
12446 }
12447 var self = this;
12448 var caret = self.caretPos;
12449 var output;
12450 input = input || self.inputValue();
12451 if (!self.canCreate(input)) {
12452 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input);
12453 if (hash) {
12454 if (this.options[input]) {
12455 self.addItem(input);
12456 }
12457 }
12458 callback();
12459 return false;
12460 }
12461 self.lock();
12462 var created = false;
12463 var create = (data) => {
12464 self.unlock();
12465 if (!data || typeof data !== 'object')
12466 return callback();
12467 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12468 if (typeof value !== 'string') {
12469 return callback();
12470 }
12471 self.setTextboxValue();
12472 self.addOption(data, true);
12473 self.setCaret(caret);
12474 self.addItem(value);
12475 callback(data);
12476 created = true;
12477 };
12478 if (typeof self.settings.create === 'function') {
12479 output = self.settings.create.call(this, input, create);
12480 }
12481 else {
12482 output = {
12483 [self.settings.labelField]: input,
12484 [self.settings.valueField]: input,
12485 };
12486 }
12487 if (!created) {
12488 create(output);
12489 }
12490 return true;
12491 }
12492 /**
12493 * Re-renders the selected item lists.
12494 */
12495 refreshItems() {
12496 var self = this;
12497 self.isDropdownContentStale = true;
12498 if (self.isSetup) {
12499 self.addItems(self.items);
12500 }
12501 self.updateOriginalInput();
12502 self.refreshState();
12503 }
12504 /**
12505 * Updates all state-dependent attributes
12506 * and CSS classes.
12507 */
12508 refreshState() {
12509 const self = this;
12510 self.refreshValidityState();
12511 const isFull = self.isFull();
12512 const isLocked = self.isLocked;
12513 self.wrapper.classList.toggle('rtl', self.rtl);
12514 const wrap_classList = self.wrapper.classList;
12515 wrap_classList.toggle('focus', self.isFocused);
12516 wrap_classList.toggle('disabled', self.isDisabled);
12517 wrap_classList.toggle('readonly', self.isReadOnly);
12518 wrap_classList.toggle('required', self.isRequired);
12519 wrap_classList.toggle('invalid', !self.isValid);
12520 wrap_classList.toggle('locked', isLocked);
12521 wrap_classList.toggle('full', isFull);
12522 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
12523 wrap_classList.toggle('dropdown-active', self.isOpen);
12524 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
12525 wrap_classList.toggle('has-items', self.items.length > 0);
12526 }
12527 /**
12528 * Update the `required` attribute of both input and control input.
12529 *
12530 * The `required` property needs to be activated on the control input
12531 * for the error to be displayed at the right place. `required` also
12532 * needs to be temporarily deactivated on the input since the input is
12533 * hidden and can't show errors.
12534 */
12535 refreshValidityState() {
12536 var self = this;
12537 if (!self.input.validity) {
12538 return;
12539 }
12540 self.isValid = self.input.validity.valid;
12541 self.isInvalid = !self.isValid;
12542 }
12543 /**
12544 * Determines whether or not more items can be added
12545 * to the control without exceeding the user-defined maximum.
12546 *
12547 * @returns {boolean}
12548 */
12549 isFull() {
12550 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
12551 }
12552 /**
12553 * Refreshes the original <select> or <input>
12554 * element to reflect the current state.
12555 *
12556 */
12557 updateOriginalInput(opts = {}) {
12558 const self = this;
12559 var option, label;
12560 const empty_option = self.input.querySelector('option[value=""]');
12561 if (self.is_select_tag) {
12562 const selected = [];
12563 const has_selected = self.input.querySelectorAll('option:checked').length;
12564 function AddSelected(option_el, value, label) {
12565 if (!option_el) {
12566 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>');
12567 }
12568 // don't move empty option from top of list
12569 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
12570 if (option_el != empty_option) {
12571 self.input.append(option_el);
12572 }
12573 selected.push(option_el);
12574 // marking empty option as selected can break validation
12575 // fixes https://github.com/orchidjs/tom-select/issues/303
12576 if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') {
12577 option_el.selected = true;
12578 }
12579 return option_el;
12580 }
12581 // unselect all selected options
12582 self.input.querySelectorAll('option:checked').forEach((option_el) => {
12583 option_el.selected = false;
12584 });
12585 // nothing selected?
12586 if (self.items.length == 0 && self.settings.mode == 'single') {
12587 AddSelected(empty_option, "", "");
12588 // order selected <option> tags for values in self.items
12589 }
12590 else {
12591 self.items.forEach((value) => {
12592 option = self.options[value];
12593 label = option[self.settings.labelField] || '';
12594 if (selected.includes(option.$option)) {
12595 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
12596 AddSelected(reuse_opt, value, label);
12597 }
12598 else {
12599 option.$option = AddSelected(option.$option, value, label);
12600 }
12601 });
12602 }
12603 }
12604 else {
12605 self.input.value = self.getValue();
12606 }
12607 if (self.isSetup) {
12608 if (!opts.silent) {
12609 self.trigger('change', self.getValue());
12610 }
12611 }
12612 }
12613 /**
12614 * Shows the autocomplete dropdown containing
12615 * the available options.
12616 */
12617 open() {
12618 var self = this;
12619 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
12620 return;
12621 self.isOpen = true;
12622 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
12623 self.refreshState();
12624 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
12625 self.positionDropdown();
12626 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
12627 self.focus();
12628 self.trigger('dropdown_open', self.dropdown);
12629 }
12630 /**
12631 * Closes the autocomplete dropdown menu.
12632 */
12633 close(setTextboxValue = true) {
12634 var self = this;
12635 var trigger = self.isOpen;
12636 if (setTextboxValue) {
12637 // before blur() to prevent form onchange event
12638 self.setTextboxValue();
12639 if (self.settings.mode === 'single' && self.items.length) {
12640 self.inputState();
12641 }
12642 }
12643 self.isOpen = false;
12644 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
12645 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
12646 if (self.settings.hideSelected) {
12647 self.clearActiveOption();
12648 }
12649 self.refreshState();
12650 if (trigger)
12651 self.trigger('dropdown_close', self.dropdown);
12652 }
12653 /**
12654 * Calculates and applies the appropriate
12655 * position of the dropdown if dropdownParent = 'body'.
12656 * Otherwise, position is determined by css
12657 */
12658 positionDropdown() {
12659 if (this.settings.dropdownParent !== 'body') {
12660 return;
12661 }
12662 var context = this.control;
12663 var rect = context.getBoundingClientRect();
12664 var top = context.offsetHeight + rect.top + window.scrollY;
12665 var left = rect.left + window.scrollX;
12666 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
12667 width: rect.width + 'px',
12668 top: top + 'px',
12669 left: left + 'px'
12670 });
12671 }
12672 /**
12673 * Resets / clears all selected items
12674 * from the control.
12675 *
12676 */
12677 clear(silent) {
12678 var self = this;
12679 if (!self.items.length)
12680 return;
12681 var items = self.controlChildren();
12682 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
12683 self.removeItem(item, true);
12684 });
12685 self.inputState();
12686 if (!silent)
12687 self.updateOriginalInput();
12688 self.trigger('clear');
12689 }
12690 /**
12691 * A helper method for inserting an element
12692 * at the current caret position.
12693 *
12694 */
12695 insertAtCaret(el) {
12696 const self = this;
12697 const caret = self.caretPos;
12698 const target = self.control;
12699 target.insertBefore(el, target.children[caret] || null);
12700 self.setCaret(caret + 1);
12701 }
12702 /**
12703 * Removes the current selected item(s).
12704 *
12705 */
12706 deleteSelection(e) {
12707 var direction, selection, caret, tail;
12708 var self = this;
12709 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
12710 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
12711 // determine items that will be removed
12712 const rm_items = [];
12713 if (self.activeItems.length) {
12714 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
12715 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
12716 if (direction > 0) {
12717 caret++;
12718 }
12719 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
12720 }
12721 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
12722 const items = self.controlChildren();
12723 let rm_item;
12724 if (direction < 0 && selection.start === 0 && selection.length === 0) {
12725 rm_item = items[self.caretPos - 1];
12726 }
12727 else if (direction > 0 && selection.start === self.inputValue().length) {
12728 rm_item = items[self.caretPos];
12729 }
12730 if (rm_item !== undefined) {
12731 rm_items.push(rm_item);
12732 }
12733 }
12734 if (!self.shouldDelete(rm_items, e)) {
12735 return false;
12736 }
12737 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
12738 // perform removal
12739 if (typeof caret !== 'undefined') {
12740 self.setCaret(caret);
12741 }
12742 while (rm_items.length) {
12743 self.removeItem(rm_items.pop());
12744 }
12745 self.inputState();
12746 self.positionDropdown();
12747 self.refreshOptions(false);
12748 return true;
12749 }
12750 /**
12751 * Return true if the items should be deleted
12752 */
12753 shouldDelete(items, evt) {
12754 const values = items.map(item => item.dataset.value);
12755 // allow the callback to abort
12756 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) {
12757 return false;
12758 }
12759 return true;
12760 }
12761 /**
12762 * Selects the previous / next item (depending on the `direction` argument).
12763 *
12764 * > 0 - right
12765 * < 0 - left
12766 *
12767 */
12768 advanceSelection(direction, e) {
12769 var last_active, adjacent, self = this;
12770 if (self.rtl)
12771 direction *= -1;
12772 if (self.inputValue().length)
12773 return;
12774 // add or remove to active items
12775 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)) {
12776 last_active = self.getLastActive(direction);
12777 if (last_active) {
12778 if (!last_active.classList.contains('active')) {
12779 adjacent = last_active;
12780 }
12781 else {
12782 adjacent = self.getAdjacent(last_active, direction, 'item');
12783 }
12784 // if no active item, get items adjacent to the control input
12785 }
12786 else if (direction > 0) {
12787 adjacent = self.control_input.nextElementSibling;
12788 }
12789 else {
12790 adjacent = self.control_input.previousElementSibling;
12791 }
12792 if (adjacent) {
12793 if (adjacent.classList.contains('active')) {
12794 self.removeActiveItem(last_active);
12795 }
12796 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
12797 }
12798 // move caret to the left or right
12799 }
12800 else {
12801 self.moveCaret(direction);
12802 }
12803 }
12804 moveCaret(direction) { }
12805 /**
12806 * Get the last active item
12807 *
12808 */
12809 getLastActive(direction) {
12810 let last_active = this.control.querySelector('.last-active');
12811 if (last_active) {
12812 return last_active;
12813 }
12814 var result = this.control.querySelectorAll('.active');
12815 if (result) {
12816 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
12817 }
12818 }
12819 /**
12820 * Moves the caret to the specified index.
12821 *
12822 * The input must be moved by leaving it in place and moving the
12823 * siblings, due to the fact that focus cannot be restored once lost
12824 * on mobile webkit devices
12825 *
12826 */
12827 setCaret(new_pos) {
12828 this.caretPos = this.items.length;
12829 }
12830 /**
12831 * Return list of item dom elements
12832 *
12833 */
12834 controlChildren() {
12835 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
12836 }
12837 /**
12838 * Disables user input on the control. Used while
12839 * items are being asynchronously created.
12840 */
12841 lock() {
12842 this.setLocked(true);
12843 }
12844 /**
12845 * Re-enables user input on the control.
12846 */
12847 unlock() {
12848 this.setLocked(false);
12849 }
12850 /**
12851 * Disable or enable user input on the control
12852 */
12853 setLocked(lock = this.isReadOnly || this.isDisabled) {
12854 this.isLocked = lock;
12855 this.refreshState();
12856 }
12857 /**
12858 * Disables user input on the control completely.
12859 * While disabled, it cannot receive focus.
12860 */
12861 disable() {
12862 this.setDisabled(true);
12863 this.close();
12864 }
12865 /**
12866 * Enables the control so that it can respond
12867 * to focus and user input.
12868 */
12869 enable() {
12870 this.setDisabled(false);
12871 }
12872 setDisabled(disabled) {
12873 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
12874 this.isDisabled = disabled;
12875 this.input.disabled = disabled;
12876 this.control_input.disabled = disabled;
12877 this.setLocked();
12878 }
12879 setReadOnly(isReadOnly) {
12880 this.isReadOnly = isReadOnly;
12881 this.input.readOnly = isReadOnly;
12882 this.control_input.readOnly = isReadOnly;
12883 this.setLocked();
12884 }
12885 /**
12886 * Completely destroys the control and
12887 * unbinds all event listeners so that it can
12888 * be garbage collected.
12889 */
12890 destroy() {
12891 var self = this;
12892 var revertSettings = self.revertSettings;
12893 self.trigger('destroy');
12894 self.off();
12895 self.wrapper.remove();
12896 self.dropdown.remove();
12897 self.input.innerHTML = revertSettings.innerHTML;
12898 self.input.tabIndex = revertSettings.tabIndex;
12899 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
12900 self._destroy();
12901 delete self.input.tomselect;
12902 }
12903 /**
12904 * A helper method for rendering "item" and
12905 * "option" templates, given the data.
12906 *
12907 */
12908 render(templateName, data) {
12909 var id, html;
12910 const self = this;
12911 if (typeof this.settings.render[templateName] !== 'function') {
12912 return null;
12913 }
12914 // render markup
12915 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
12916 if (!html) {
12917 return null;
12918 }
12919 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
12920 // add mandatory attributes
12921 if (templateName === 'option' || templateName === 'option_create') {
12922 if (data[self.settings.disabledField]) {
12923 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
12924 }
12925 else {
12926 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
12927 }
12928 }
12929 else if (templateName === 'optgroup') {
12930 id = data.group[self.settings.optgroupValueField];
12931 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
12932 if (data.group[self.settings.disabledField]) {
12933 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
12934 }
12935 }
12936 if (templateName === 'option' || templateName === 'item') {
12937 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
12938 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
12939 // make sure we have some classes if a template is overwritten
12940 if (templateName === 'item') {
12941 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
12942 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
12943 }
12944 else {
12945 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
12946 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
12947 role: 'option',
12948 id: data.$id
12949 });
12950 // update cache
12951 data.$div = html;
12952 self.options[value] = data;
12953 }
12954 }
12955 return html;
12956 }
12957 /**
12958 * Type guarded rendering
12959 *
12960 */
12961 _render(templateName, data) {
12962 const html = this.render(templateName, data);
12963 if (html == null) {
12964 throw 'HTMLElement expected';
12965 }
12966 return html;
12967 }
12968 /**
12969 * Clears the render cache for a template. If
12970 * no template is given, clears all render
12971 * caches.
12972 *
12973 */
12974 clearCache() {
12975 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
12976 if (option.$div) {
12977 option.$div.remove();
12978 delete option.$div;
12979 }
12980 });
12981 }
12982 /**
12983 * Removes a value from item and option caches
12984 *
12985 */
12986 uncacheValue(value) {
12987 const option_el = this.getOption(value);
12988 if (option_el)
12989 option_el.remove();
12990 }
12991 /**
12992 * Determines whether or not to display the
12993 * create item prompt, given a user input.
12994 *
12995 */
12996 canCreate(input) {
12997 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
12998 }
12999 /**
13000 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13001 *
13002 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13003 *
13004 * });
13005 */
13006 hook(when, method, new_fn) {
13007 var self = this;
13008 var orig_method = self[method];
13009 self[method] = function () {
13010 var result, result_new;
13011 if (when === 'after') {
13012 result = orig_method.apply(self, arguments);
13013 }
13014 result_new = new_fn.apply(self, arguments);
13015 if (when === 'instead') {
13016 return result_new;
13017 }
13018 if (when === 'before') {
13019 result = orig_method.apply(self, arguments);
13020 }
13021 return result;
13022 };
13023 }
13024 }
13025 ;
13026 //# sourceMappingURL=tom-select.js.map
13027
13028 /***/ },
13029
13030 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13031 /*!***************************************************!*\
13032 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13033 \***************************************************/
13034 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13035
13036 "use strict";
13037 __webpack_require__.r(__webpack_exports__);
13038 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13039 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13040 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13041 /* harmony export */ append: () => (/* binding */ append),
13042 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13043 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13044 /* harmony export */ getId: () => (/* binding */ getId),
13045 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13046 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13047 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13048 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13049 /* harmony export */ iterate: () => (/* binding */ iterate),
13050 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13051 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13052 /* harmony export */ timeout: () => (/* binding */ timeout)
13053 /* harmony export */ });
13054 /**
13055 * Converts a scalar to its best string representation
13056 * for hash keys and HTML attribute values.
13057 *
13058 * Transformations:
13059 * 'str' -> 'str'
13060 * null -> ''
13061 * undefined -> ''
13062 * true -> '1'
13063 * false -> '0'
13064 * 0 -> '0'
13065 * 1 -> '1'
13066 *
13067 */
13068 const hash_key = (value) => {
13069 if (typeof value === 'undefined' || value === null)
13070 return null;
13071 return get_hash(value);
13072 };
13073 const get_hash = (value) => {
13074 if (typeof value === 'boolean')
13075 return value ? '1' : '0';
13076 return value + '';
13077 };
13078 /**
13079 * Escapes a string for use within HTML.
13080 *
13081 */
13082 const escape_html = (str) => {
13083 return (str + '')
13084 .replace(/&/g, '&amp;')
13085 .replace(/</g, '&lt;')
13086 .replace(/>/g, '&gt;')
13087 .replace(/"/g, '&quot;');
13088 };
13089 /**
13090 * use setTimeout if timeout > 0
13091 */
13092 const timeout = (fn, timeout) => {
13093 if (timeout > 0) {
13094 return window.setTimeout(fn, timeout);
13095 }
13096 fn.call(null);
13097 return null;
13098 };
13099 /**
13100 * Debounce the user provided load function
13101 *
13102 */
13103 const loadDebounce = (fn, delay) => {
13104 var timeout;
13105 return function (value, callback) {
13106 var self = this;
13107 if (timeout) {
13108 self.loading = Math.max(self.loading - 1, 0);
13109 clearTimeout(timeout);
13110 }
13111 timeout = setTimeout(function () {
13112 timeout = null;
13113 self.loadedSearches[value] = true;
13114 fn.call(self, value, callback);
13115 }, delay);
13116 };
13117 };
13118 /**
13119 * Debounce all fired events types listed in `types`
13120 * while executing the provided `fn`.
13121 *
13122 */
13123 const debounce_events = (self, types, fn) => {
13124 var type;
13125 var trigger = self.trigger;
13126 var event_args = {};
13127 // override trigger method
13128 self.trigger = function () {
13129 var type = arguments[0];
13130 if (types.indexOf(type) !== -1) {
13131 event_args[type] = arguments;
13132 }
13133 else {
13134 return trigger.apply(self, arguments);
13135 }
13136 };
13137 // invoke provided function
13138 fn.apply(self, []);
13139 self.trigger = trigger;
13140 // trigger queued events
13141 for (type of types) {
13142 if (type in event_args) {
13143 trigger.apply(self, event_args[type]);
13144 }
13145 }
13146 };
13147 /**
13148 * Determines the current selection within a text input control.
13149 * Returns an object containing:
13150 * - start
13151 * - length
13152 *
13153 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13154 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13155 */
13156 const getSelection = (input) => {
13157 return {
13158 start: input.selectionStart || 0,
13159 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13160 };
13161 };
13162 /**
13163 * Prevent default
13164 *
13165 */
13166 const preventDefault = (evt, stop = false) => {
13167 if (evt) {
13168 evt.preventDefault();
13169 if (stop) {
13170 evt.stopPropagation();
13171 }
13172 }
13173 };
13174 /**
13175 * Add event helper
13176 *
13177 */
13178 const addEvent = (target, type, callback, options) => {
13179 target.addEventListener(type, callback, options);
13180 };
13181 /**
13182 * Return true if the requested key is down
13183 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13184 * The current evt may not always set ( eg calling advanceSelection() )
13185 *
13186 */
13187 const isKeyDown = (key_name, evt) => {
13188 if (!evt) {
13189 return false;
13190 }
13191 if (!evt[key_name]) {
13192 return false;
13193 }
13194 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13195 if (count === 1) {
13196 return true;
13197 }
13198 return false;
13199 };
13200 /**
13201 * Get the id of an element
13202 * If the id attribute is not set, set the attribute with the given id
13203 *
13204 */
13205 const getId = (el, id) => {
13206 const existing_id = el.getAttribute('id');
13207 if (existing_id) {
13208 return existing_id;
13209 }
13210 el.setAttribute('id', id);
13211 return id;
13212 };
13213 /**
13214 * Returns a string with backslashes added before characters that need to be escaped.
13215 */
13216 const addSlashes = (str) => {
13217 return str.replace(/[\\"']/g, '\\$&');
13218 };
13219 /**
13220 *
13221 */
13222 const append = (parent, node) => {
13223 if (node)
13224 parent.append(node);
13225 };
13226 /**
13227 * Iterates over arrays and hashes.
13228 *
13229 * ```
13230 * iterate(this.items, function(item, id) {
13231 * // invoked for each item
13232 * });
13233 * ```
13234 *
13235 */
13236 const iterate = (object, callback) => {
13237 if (Array.isArray(object)) {
13238 object.forEach(callback);
13239 }
13240 else {
13241 for (var key in object) {
13242 if (object.hasOwnProperty(key)) {
13243 callback(object[key], key);
13244 }
13245 }
13246 }
13247 };
13248 //# sourceMappingURL=utils.js.map
13249
13250 /***/ },
13251
13252 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13253 /*!*****************************************************!*\
13254 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13255 \*****************************************************/
13256 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13257
13258 "use strict";
13259 __webpack_require__.r(__webpack_exports__);
13260 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13261 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13262 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13263 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13264 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13265 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13266 /* harmony export */ getDom: () => (/* binding */ getDom),
13267 /* harmony export */ getTail: () => (/* binding */ getTail),
13268 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13269 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13270 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13271 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13272 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13273 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13274 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13275 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13276 /* harmony export */ });
13277 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13278
13279 /**
13280 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13281 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13282 *
13283 * param query should be {}
13284 */
13285 const getDom = (query) => {
13286 if (query.jquery) {
13287 return query[0];
13288 }
13289 if (query instanceof HTMLElement) {
13290 return query;
13291 }
13292 if (isHtmlString(query)) {
13293 var tpl = document.createElement('template');
13294 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13295 return tpl.content.firstChild;
13296 }
13297 return document.querySelector(query);
13298 };
13299 const isHtmlString = (arg) => {
13300 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13301 return true;
13302 }
13303 return false;
13304 };
13305 const escapeQuery = (query) => {
13306 return query.replace(/['"\\]/g, '\\$&');
13307 };
13308 /**
13309 * Dispatch an event
13310 *
13311 */
13312 const triggerEvent = (dom_el, event_name) => {
13313 var event = document.createEvent('HTMLEvents');
13314 event.initEvent(event_name, true, false);
13315 dom_el.dispatchEvent(event);
13316 };
13317 /**
13318 * Apply CSS rules to a dom element
13319 *
13320 */
13321 const applyCSS = (dom_el, css) => {
13322 Object.assign(dom_el.style, css);
13323 };
13324 /**
13325 * Add css classes
13326 *
13327 */
13328 const addClasses = (elmts, ...classes) => {
13329 var norm_classes = classesArray(classes);
13330 elmts = castAsArray(elmts);
13331 elmts.map(el => {
13332 norm_classes.map(cls => {
13333 el.classList.add(cls);
13334 });
13335 });
13336 };
13337 /**
13338 * Remove css classes
13339 *
13340 */
13341 const removeClasses = (elmts, ...classes) => {
13342 var norm_classes = classesArray(classes);
13343 elmts = castAsArray(elmts);
13344 elmts.map(el => {
13345 norm_classes.map(cls => {
13346 el.classList.remove(cls);
13347 });
13348 });
13349 };
13350 /**
13351 * Return arguments
13352 *
13353 */
13354 const classesArray = (args) => {
13355 var classes = [];
13356 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13357 if (typeof _classes === 'string') {
13358 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13359 }
13360 if (Array.isArray(_classes)) {
13361 classes = classes.concat(_classes);
13362 }
13363 });
13364 return classes.filter(Boolean);
13365 };
13366 /**
13367 * Create an array from arg if it's not already an array
13368 *
13369 */
13370 const castAsArray = (arg) => {
13371 if (!Array.isArray(arg)) {
13372 arg = [arg];
13373 }
13374 return arg;
13375 };
13376 /**
13377 * Get the closest node to the evt.target matching the selector
13378 * Stops at wrapper
13379 *
13380 */
13381 const parentMatch = (target, selector, wrapper) => {
13382 if (wrapper && !wrapper.contains(target)) {
13383 return;
13384 }
13385 while (target && target.matches) {
13386 if (target.matches(selector)) {
13387 return target;
13388 }
13389 target = target.parentNode;
13390 }
13391 };
13392 /**
13393 * Get the first or last item from an array
13394 *
13395 * > 0 - right (last)
13396 * <= 0 - left (first)
13397 *
13398 */
13399 const getTail = (list, direction = 0) => {
13400 if (direction > 0) {
13401 return list[list.length - 1];
13402 }
13403 return list[0];
13404 };
13405 /**
13406 * Return true if an object is empty
13407 *
13408 */
13409 const isEmptyObject = (obj) => {
13410 return (Object.keys(obj).length === 0);
13411 };
13412 /**
13413 * Get the index of an element amongst sibling nodes of the same type
13414 *
13415 */
13416 const nodeIndex = (el, amongst) => {
13417 if (!el)
13418 return -1;
13419 amongst = amongst || el.nodeName;
13420 var i = 0;
13421 while (el = el.previousElementSibling) {
13422 if (el.matches(amongst)) {
13423 i++;
13424 }
13425 }
13426 return i;
13427 };
13428 /**
13429 * Set attributes of an element
13430 *
13431 */
13432 const setAttr = (el, attrs) => {
13433 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
13434 if (val == null) {
13435 el.removeAttribute(attr);
13436 }
13437 else {
13438 el.setAttribute(attr, '' + val);
13439 }
13440 });
13441 };
13442 /**
13443 * Replace a node
13444 */
13445 const replaceNode = (existing, replacement) => {
13446 if (existing.parentNode)
13447 existing.parentNode.replaceChild(replacement, existing);
13448 };
13449 //# sourceMappingURL=vanilla.js.map
13450
13451 /***/ }
13452
13453 /******/ });
13454 /************************************************************************/
13455 /******/ // The module cache
13456 /******/ const __webpack_module_cache__ = {};
13457 /******/
13458 /******/ // The require function
13459 /******/ function __webpack_require__(moduleId) {
13460 /******/ // Check if module is in cache
13461 /******/ const cachedModule = __webpack_module_cache__[moduleId];
13462 /******/ if (cachedModule !== undefined) {
13463 /******/ return cachedModule.exports;
13464 /******/ }
13465 /******/ // Create a new module (and put it into the cache)
13466 /******/ const module = __webpack_module_cache__[moduleId] = {
13467 /******/ id: moduleId,
13468 /******/ // no module.loaded needed
13469 /******/ exports: {}
13470 /******/ };
13471 /******/
13472 /******/ // Execute the module function
13473 /******/ if (!(moduleId in __webpack_modules__)) {
13474 /******/ delete __webpack_module_cache__[moduleId];
13475 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
13476 /******/ e.code = 'MODULE_NOT_FOUND';
13477 /******/ throw e;
13478 /******/ }
13479 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
13480 /******/
13481 /******/ // Return the exports of the module
13482 /******/ return module.exports;
13483 /******/ }
13484 /******/
13485 /************************************************************************/
13486 /******/ /* webpack/runtime/compat get default export */
13487 /******/ (() => {
13488 /******/ // getDefaultExport function for compatibility with non-harmony modules
13489 /******/ __webpack_require__.n = (module) => {
13490 /******/ const getter = module && module.__esModule ?
13491 /******/ () => (module['default']) :
13492 /******/ () => (module);
13493 /******/ __webpack_require__.d(getter, { a: getter });
13494 /******/ return getter;
13495 /******/ };
13496 /******/ })();
13497 /******/
13498 /******/ /* webpack/runtime/define property getters */
13499 /******/ (() => {
13500 /******/ // define getter/value functions for harmony exports
13501 /******/ __webpack_require__.d = (exports, definition) => {
13502 /******/ if(Array.isArray(definition)) {
13503 /******/ var i = 0;
13504 /******/ while(i < definition.length) {
13505 /******/ var key = definition[i++];
13506 /******/ var binding = definition[i++];
13507 /******/ if(!__webpack_require__.o(exports, key)) {
13508 /******/ if(binding === 0) {
13509 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
13510 /******/ } else {
13511 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
13512 /******/ }
13513 /******/ } else if(binding === 0) { i++; }
13514 /******/ }
13515 /******/ } else {
13516 /******/ for(var key in definition) {
13517 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13518 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
13519 /******/ }
13520 /******/ }
13521 /******/ }
13522 /******/ };
13523 /******/ })();
13524 /******/
13525 /******/ /* webpack/runtime/hasOwnProperty shorthand */
13526 /******/ (() => {
13527 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
13528 /******/ })();
13529 /******/
13530 /******/ /* webpack/runtime/make namespace object */
13531 /******/ (() => {
13532 /******/ // define __esModule on exports
13533 /******/ __webpack_require__.r = (exports) => {
13534 /******/ if(Symbol.toStringTag) {
13535 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13536 /******/ }
13537 /******/ Object.defineProperty(exports, '__esModule', { value: true });
13538 /******/ };
13539 /******/ })();
13540 /******/
13541 /******/ /* webpack/runtime/nonce */
13542 /******/ (() => {
13543 /******/ __webpack_require__.nc = undefined;
13544 /******/ })();
13545 /******/
13546 /************************************************************************/
13547 let __webpack_exports__ = {};
13548 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
13549 (() => {
13550 "use strict";
13551 /*!********************************************!*\
13552 !*** ./assets/src/js/admin/admin-order.js ***!
13553 \********************************************/
13554 __webpack_require__.r(__webpack_exports__);
13555 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
13556 /* 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");
13557 /* harmony import */ var _order_refund_order__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./order/refund-order */ "./assets/src/js/admin/order/refund-order.js");
13558
13559
13560 //import modalSearchCourses from './order/modal-search-courses';
13561
13562
13563 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
13564 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
13565 (0,_order_refund_order__WEBPACK_IMPORTED_MODULE_2__["default"])();
13566 })();
13567
13568 /******/ })()
13569 ;
13570 //# sourceMappingURL=admin-order.js.map