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

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

13,630 lines 475.2 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 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
897 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
898 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
899 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
900 };
901 }
902 if ('undefined' !== typeof lpData) {
903 lp_rest_url = lpData.lp_rest_url;
904 lplistAPI.frontend = {
905 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
906 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
907 // Deprecated API, don't load from v4.3.7
908 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
909 // Deprecated since 4.3.0
910 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
911 };
912 }
913 if (lp_rest_url) {
914 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
915 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
916 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
917 }
918 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
919
920 /***/ },
921
922 /***/ "./assets/src/js/lpToastify.js"
923 /*!*************************************!*\
924 !*** ./assets/src/js/lpToastify.js ***!
925 \*************************************/
926 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
927
928 "use strict";
929 __webpack_require__.r(__webpack_exports__);
930 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
931 /* harmony export */ show: () => (/* binding */ show)
932 /* harmony export */ });
933 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
934 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_0__);
935 /* 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");
936 /**
937 * Utils functions
938 *
939 * @param url
940 * @param data
941 * @param functions
942 * @since 4.3.0
943 * @version 1.0.0
944 */
945
946
947 const argsToastify = {
948 text: '',
949 gravity: lpData.toast.gravity,
950 // `top` or `bottom`
951 position: lpData.toast.position,
952 // `left`, `center` or `right`
953 className: `${lpData.toast.classPrefix}`,
954 close: lpData.toast.close == 1,
955 stopOnFocus: lpData.toast.stopOnFocus == 1,
956 duration: lpData.toast.duration
957 };
958 const show = (message, status = 'success', argsCustom) => {
959 let args = argsToastify;
960 if (argsCustom) {
961 args = {
962 ...args,
963 ...argsCustom
964 };
965 }
966 const toastify = new (toastify_js__WEBPACK_IMPORTED_MODULE_0___default())({
967 ...args,
968 text: message,
969 className: `${lpData.toast.classPrefix} ${status}`
970 });
971 toastify.showToast();
972 };
973
974 /***/ },
975
976 /***/ "./assets/src/js/utils.js"
977 /*!********************************!*\
978 !*** ./assets/src/js/utils.js ***!
979 \********************************/
980 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
981
982 "use strict";
983 __webpack_require__.r(__webpack_exports__);
984 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
985 /* harmony export */ debounce: () => (/* binding */ debounce),
986 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
987 /* harmony export */ fullScreenView: () => (/* binding */ fullScreenView),
988 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
989 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
990 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
991 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
992 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
993 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
994 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
995 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
996 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
997 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
998 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
999 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1000 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1001 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse),
1002 /* harmony export */ toggleEnable: () => (/* binding */ toggleEnable)
1003 /* harmony export */ });
1004 /**
1005 * Utils functions
1006 *
1007 * @param url
1008 * @param data
1009 * @param functions
1010 * @since 4.2.5.1
1011 * @version 1.0.7
1012 */
1013 const lpClassName = {
1014 hidden: 'lp-hidden',
1015 loading: 'loading',
1016 elCollapse: 'lp-collapse',
1017 elSectionToggle: '.lp-section-toggle',
1018 elTriggerToggle: '.lp-trigger-toggle',
1019 elBtnFullScreen: '.lp-btn-full-screen-view',
1020 elFullScreen: 'lp-full-screen-view',
1021 elBtnFullScreenClose: 'lp-full-screen-view__close'
1022 };
1023 const lpFetchAPI = (url, data = {}, functions = {}) => {
1024 if ('function' === typeof functions.before) {
1025 functions.before();
1026 }
1027 fetch(url, {
1028 method: 'GET',
1029 ...data
1030 }).then(response => response.json()).then(response => {
1031 if ('function' === typeof functions.success) {
1032 functions.success(response);
1033 }
1034 }).catch(err => {
1035 if ('function' === typeof functions.error) {
1036 functions.error(err);
1037 }
1038 }).finally(() => {
1039 if ('function' === typeof functions.completed) {
1040 functions.completed();
1041 }
1042 });
1043 };
1044
1045 /**
1046 * Get current URL without params.
1047 *
1048 * @since 4.2.5.1
1049 */
1050 const lpGetCurrentURLNoParam = () => {
1051 let currentUrl = window.location.href;
1052 const hasParams = currentUrl.includes('?');
1053 if (hasParams) {
1054 currentUrl = currentUrl.split('?')[0];
1055 }
1056 return currentUrl;
1057 };
1058 const lpAddQueryArgs = (endpoint, args) => {
1059 const url = new URL(endpoint);
1060 Object.keys(args).forEach(arg => {
1061 url.searchParams.set(arg, args[arg]);
1062 });
1063 return url;
1064 };
1065
1066 /**
1067 * Listen element viewed.
1068 *
1069 * @param el
1070 * @param callback
1071 * @since 4.2.5.8
1072 */
1073 const listenElementViewed = (el, callback) => {
1074 const observerSeeItem = new IntersectionObserver(function (entries) {
1075 for (const entry of entries) {
1076 if (entry.isIntersecting) {
1077 callback(entry);
1078 }
1079 }
1080 });
1081 observerSeeItem.observe(el);
1082 };
1083
1084 /**
1085 * Listen element created.
1086 *
1087 * @param callback
1088 * @since 4.2.5.8
1089 */
1090 const listenElementCreated = callback => {
1091 const observerCreateItem = new MutationObserver(function (mutations) {
1092 mutations.forEach(function (mutation) {
1093 if (mutation.addedNodes) {
1094 mutation.addedNodes.forEach(function (node) {
1095 if (node.nodeType === 1) {
1096 callback(node);
1097 }
1098 });
1099 }
1100 });
1101 });
1102 observerCreateItem.observe(document, {
1103 childList: true,
1104 subtree: true
1105 });
1106 // End.
1107 };
1108
1109 /**
1110 * Listen element created.
1111 *
1112 * @param selector
1113 * @param callback
1114 * @since 4.2.7.1
1115 */
1116 const lpOnElementReady = (selector, callback) => {
1117 const element = document.querySelector(selector);
1118 if (element) {
1119 callback(element);
1120 return;
1121 }
1122 const observer = new MutationObserver((mutations, obs) => {
1123 const element = document.querySelector(selector);
1124 if (element) {
1125 obs.disconnect();
1126 callback(element);
1127 }
1128 });
1129 observer.observe(document.documentElement, {
1130 childList: true,
1131 subtree: true
1132 });
1133 };
1134
1135 // Parse JSON from string with content include LP_AJAX_START.
1136 const lpAjaxParseJsonOld = data => {
1137 if (typeof data !== 'string') {
1138 return data;
1139 }
1140 const m = String.raw({
1141 raw: data
1142 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1143 try {
1144 if (m) {
1145 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1146 } else {
1147 data = JSON.parse(data);
1148 }
1149 } catch (e) {
1150 data = {};
1151 }
1152 return data;
1153 };
1154
1155 // status 0: hide, 1: show
1156 const lpShowHideEl = (el, status = 0) => {
1157 if (!el) {
1158 return;
1159 }
1160 if (!status) {
1161 el.classList.add(lpClassName.hidden);
1162 } else {
1163 el.classList.remove(lpClassName.hidden);
1164 }
1165 };
1166
1167 // status 0: hide, 1: show
1168 const lpSetLoadingEl = (el, status) => {
1169 if (!el) {
1170 return;
1171 }
1172 if (!status) {
1173 el.classList.remove(lpClassName.loading);
1174 } else {
1175 el.classList.add(lpClassName.loading);
1176 }
1177 };
1178
1179 // Toggle collapse section
1180 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1181 if (!elTriggerClassName) {
1182 elTriggerClassName = lpClassName.elTriggerToggle;
1183 }
1184
1185 // Exclude elements, which should not trigger the collapse toggle
1186 if (elsExclude && elsExclude.length > 0) {
1187 for (const elExclude of elsExclude) {
1188 if (target.closest(elExclude)) {
1189 return;
1190 }
1191 }
1192 }
1193 const elTrigger = target.closest(elTriggerClassName);
1194 if (!elTrigger) {
1195 return;
1196 }
1197
1198 //console.log( 'elTrigger', elTrigger );
1199
1200 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1201 if (!elSectionToggle) {
1202 return;
1203 }
1204 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1205 if ('function' === typeof callback) {
1206 callback(elSectionToggle);
1207 }
1208 };
1209
1210 // Get data of form
1211 const getDataOfForm = form => {
1212 const dataSend = {};
1213 const formData = new FormData(form);
1214 for (const pair of formData.entries()) {
1215 const key = pair[0];
1216 const value = formData.getAll(key);
1217 if (!dataSend.hasOwnProperty(key)) {
1218 // Convert value array to string.
1219 dataSend[key] = value.join(',');
1220 }
1221 }
1222 return dataSend;
1223 };
1224
1225 // Get field keys of form
1226 const getFieldKeysOfForm = form => {
1227 const keys = [];
1228 const elements = form.elements;
1229 for (let i = 0; i < elements.length; i++) {
1230 const name = elements[i].name;
1231 if (name && !keys.includes(name)) {
1232 keys.push(name);
1233 }
1234 }
1235 return keys;
1236 };
1237
1238 // Merge data handle with data form.
1239 const mergeDataWithDatForm = (elForm, dataHandle) => {
1240 const dataForm = getDataOfForm(elForm);
1241 const keys = getFieldKeysOfForm(elForm);
1242 keys.forEach(key => {
1243 if (!dataForm.hasOwnProperty(key)) {
1244 delete dataHandle[key];
1245 } else if (dataForm[key][0] === '') {
1246 delete dataForm[key];
1247 delete dataHandle[key];
1248 }
1249 });
1250 dataHandle = {
1251 ...dataHandle,
1252 ...dataForm
1253 };
1254 return dataHandle;
1255 };
1256
1257 /**
1258 * Event trigger
1259 * For each list of event handlers, listen event on document.
1260 *
1261 * eventName: 'click', 'change', ...
1262 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1263 *
1264 * @param eventName
1265 * @param eventHandlers
1266 */
1267 const eventHandlers = (eventName, eventHandlers) => {
1268 document.addEventListener(eventName, e => {
1269 const target = e.target;
1270 let args = {
1271 e,
1272 target
1273 };
1274 eventHandlers.forEach(eventHandler => {
1275 args = {
1276 ...args,
1277 ...eventHandler
1278 };
1279
1280 //console.log( args );
1281
1282 // Check condition before call back
1283 if (eventHandler.conditionBeforeCallBack) {
1284 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1285 return;
1286 }
1287 }
1288
1289 // Special check for keydown event with checkIsEventEnter = true
1290 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1291 if (e.key !== 'Enter') {
1292 return;
1293 }
1294 }
1295 if (target.closest(eventHandler.selector)) {
1296 if (eventHandler.class) {
1297 // Call method of class, function callBack will understand exactly {this} is class object.
1298 eventHandler.class[eventHandler.callBack](args);
1299 } else {
1300 // For send args is objected, {this} is eventHandler object, not class object.
1301 eventHandler.callBack(args);
1302 }
1303 }
1304 });
1305 });
1306 };
1307
1308 /**
1309 * Debounce - delays function execution until after `wait` ms of inactivity.
1310 *
1311 * Each call resets the timer. Only the last call in a burst executes.
1312 *
1313 * USE CASES:
1314 * - Search inputs, form validation, window resize
1315 * - Multiple elements need independent timers
1316 * - When you need to call with different arguments
1317 *
1318 * EXAMPLES:
1319 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1320 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1321 *
1322 * const debouncedResize = debounce( recalculateLayout, 250 );
1323 * window.addEventListener('resize', debouncedResize);
1324 *
1325 * ⚠️ Create ONCE outside event handlers, not inside.
1326 *
1327 * @param {Function} func - Function to debounce (can be anonymous)
1328 * @param {number} wait - Milliseconds to wait (default: 500)
1329 * @return {Function} Debounced wrapper function
1330 * @since 4.3.7
1331 * @version 1.0.0
1332 */
1333 const debounce = (func, wait = 500) => {
1334 let timer;
1335 return args => {
1336 clearTimeout(timer);
1337 timer = setTimeout(() => func(args), wait);
1338 };
1339 };
1340
1341 /**
1342 * Initialize lp-toggle-enable components.
1343 *
1344 * Finds all `.lp-toggle-enable` elements and wires up toggle behavior.
1345 * Reads initial state from `data-enabled` attribute ("true"/"false").
1346 * Calls `data-on-toggle` callback (if provided via options) on state change.
1347 *
1348 * HTML structure:
1349 * <label class="lp-toggle-enable" data-enabled="true">
1350 * <input type="checkbox" class="lp-toggle-enable__input" />
1351 * <span class="lp-toggle-enable__track"></span>
1352 * </label>
1353 *
1354 * @param {string} selector CSS selector for toggle elements (default: '.lp-toggle-enable')
1355 * @param {Function} onToggle Optional callback( el, isEnabled ) called on state change
1356 * @since 4.4.5
1357 * @version 1.0.0
1358 */
1359 window.lpToggleEnableInit = 0;
1360 const toggleEnable = (onToggle = null) => {
1361 if (window.lpToggleEnableInit) {
1362 return;
1363 }
1364 window.lpToggleEnableInit = 1;
1365 const selector = '.lp-toggle-enable';
1366 const updateUI = (toggle, isEnabled) => {
1367 toggle.classList.toggle('is-enabled', isEnabled);
1368 const input = toggle.querySelector('.lp-toggle-enable__input');
1369 if (input) {
1370 input.checked = isEnabled;
1371 input.value = isEnabled ? '1' : '0';
1372 }
1373 };
1374
1375 // Delegate click handling via eventHandlers.
1376 eventHandlers('click', [{
1377 selector,
1378 callBack: args => {
1379 const {
1380 e,
1381 target
1382 } = args;
1383 const toggle = target.closest(selector);
1384 if (!toggle || toggle.classList.contains('is-disabled')) {
1385 return;
1386 }
1387 e.preventDefault();
1388 const isEnabled = !toggle.classList.contains('is-enabled');
1389 updateUI(toggle, isEnabled);
1390 if ('function' === typeof onToggle) {
1391 onToggle(toggle, isEnabled);
1392 }
1393 }
1394 }]);
1395 };
1396
1397 /**
1398 * Initialize custom fullscreen view buttons.
1399 *
1400 * Delegates clicks on `.lp-btn-full-screen-view` buttons to
1401 * `lpToggleFullscreenView`. Reads the `data-target` attribute to find the
1402 * target element. Falls back to the button's parent element when
1403 * `data-target` is not provided.
1404 *
1405 * @since 4.4.5
1406 * @version 1.0.0
1407 */
1408 window.lpFullScreenViewInit = 0;
1409 const fullScreenView = () => {
1410 if (window.lpFullScreenViewInit) {
1411 return;
1412 }
1413 window.lpFullScreenViewInit = 1;
1414 let lastScrollY = 0;
1415 const lpToggleFullscreenView = (elTarget, elBtnFullScreen = null) => {
1416 const isFullscreen = elTarget.classList.contains(lpClassName.elFullScreen);
1417 if (isFullscreen) {
1418 elTarget.classList.remove(lpClassName.elFullScreen);
1419 document.documentElement.classList.remove('lp-full-screen-active');
1420 window.scrollTo(0, lastScrollY);
1421 } else {
1422 lastScrollY = window.scrollY;
1423 elTarget.classList.add(lpClassName.elFullScreen);
1424 document.documentElement.classList.add('lp-full-screen-active');
1425 }
1426 if (!isFullscreen) {
1427 if (!elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`)) {
1428 const closeButton = document.createElement('button');
1429 closeButton.type = 'button';
1430 closeButton.className = lpClassName.elBtnFullScreenClose;
1431 closeButton.setAttribute('aria-label', 'Close');
1432 closeButton.innerHTML = lpData.i18n.closeButtonFullScreen || 'Close &times;';
1433 closeButton.addEventListener('click', e => {
1434 e.preventDefault();
1435 lpToggleFullscreenView(elTarget);
1436 });
1437 elTarget.appendChild(closeButton);
1438 }
1439 } else {
1440 const closeButton = elTarget.querySelector(`.${lpClassName.elBtnFullScreenClose}`);
1441 if (closeButton) {
1442 closeButton.remove();
1443 }
1444 }
1445 };
1446 eventHandlers('click', [{
1447 selector: lpClassName.elBtnFullScreen,
1448 callBack: args => {
1449 const {
1450 e,
1451 target
1452 } = args;
1453 const elBtnFullScreen = target.closest(lpClassName.elBtnFullScreen);
1454 if (!elBtnFullScreen) {
1455 console.log('No full screen button found');
1456 return;
1457 }
1458 e.preventDefault();
1459 let elTarget = null;
1460 const targetSelector = elBtnFullScreen.dataset.targetFullscreen;
1461 console.log(targetSelector);
1462 if (targetSelector) {
1463 elTarget = document.querySelector(targetSelector);
1464 }
1465 if (!elTarget) {
1466 console.log('No target element found');
1467 return;
1468 }
1469 lpToggleFullscreenView(elTarget, elBtnFullScreen);
1470 }
1471 }]);
1472 };
1473
1474 /***/ },
1475
1476 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
1477 /*!*****************************************************************************************!*\
1478 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
1479 \*****************************************************************************************/
1480 (module, __webpack_exports__, __webpack_require__) {
1481
1482 "use strict";
1483 __webpack_require__.r(__webpack_exports__);
1484 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1485 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1486 /* harmony export */ });
1487 /* 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");
1488 /* 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__);
1489 /* 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");
1490 /* 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__);
1491 // Imports
1492
1493
1494 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()));
1495 // Module
1496 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
1497 * Toastify js 1.12.0
1498 * https://github.com/apvarun/toastify-js
1499 * @license MIT licensed
1500 *
1501 * Copyright (C) 2018 Varun A P
1502 */
1503
1504 .toastify {
1505 padding: 12px 20px;
1506 color: #ffffff;
1507 display: inline-block;
1508 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
1509 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
1510 background: linear-gradient(135deg, #73a5ff, #5477f5);
1511 position: fixed;
1512 opacity: 0;
1513 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
1514 border-radius: 2px;
1515 cursor: pointer;
1516 text-decoration: none;
1517 max-width: calc(50% - 20px);
1518 z-index: 2147483647;
1519 }
1520
1521 .toastify.on {
1522 opacity: 1;
1523 }
1524
1525 .toast-close {
1526 background: transparent;
1527 border: 0;
1528 color: white;
1529 cursor: pointer;
1530 font-family: inherit;
1531 font-size: 1em;
1532 opacity: 0.4;
1533 padding: 0 5px;
1534 }
1535
1536 .toastify-right {
1537 right: 15px;
1538 }
1539
1540 .toastify-left {
1541 left: 15px;
1542 }
1543
1544 .toastify-top {
1545 top: -150px;
1546 }
1547
1548 .toastify-bottom {
1549 bottom: -150px;
1550 }
1551
1552 .toastify-rounded {
1553 border-radius: 25px;
1554 }
1555
1556 .toastify-avatar {
1557 width: 1.5em;
1558 height: 1.5em;
1559 margin: -7px 5px;
1560 border-radius: 2px;
1561 }
1562
1563 .toastify-center {
1564 margin-left: auto;
1565 margin-right: auto;
1566 left: 0;
1567 right: 0;
1568 max-width: fit-content;
1569 max-width: -moz-fit-content;
1570 }
1571
1572 @media only screen and (max-width: 360px) {
1573 .toastify-right, .toastify-left {
1574 margin-left: auto;
1575 margin-right: auto;
1576 left: 0;
1577 right: 0;
1578 max-width: fit-content;
1579 }
1580 }
1581 `, "",{"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":""}]);
1582 // Exports
1583 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
1584
1585
1586 /***/ },
1587
1588 /***/ "./node_modules/css-loader/dist/runtime/api.js"
1589 /*!*****************************************************!*\
1590 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
1591 \*****************************************************/
1592 (module) {
1593
1594 "use strict";
1595
1596
1597 /*
1598 MIT License http://www.opensource.org/licenses/mit-license.php
1599 Author Tobias Koppers @sokra
1600 */
1601 module.exports = function (cssWithMappingToString) {
1602 var list = [];
1603
1604 // return the list of modules as css string
1605 list.toString = function toString() {
1606 return this.map(function (item) {
1607 var content = "";
1608 var needLayer = typeof item[5] !== "undefined";
1609 if (item[4]) {
1610 content += "@supports (".concat(item[4], ") {");
1611 }
1612 if (item[2]) {
1613 content += "@media ".concat(item[2], " {");
1614 }
1615 if (needLayer) {
1616 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
1617 }
1618 content += cssWithMappingToString(item);
1619 if (needLayer) {
1620 content += "}";
1621 }
1622 if (item[2]) {
1623 content += "}";
1624 }
1625 if (item[4]) {
1626 content += "}";
1627 }
1628 return content;
1629 }).join("");
1630 };
1631
1632 // import a list of modules into the list
1633 list.i = function i(modules, media, dedupe, supports, layer) {
1634 if (typeof modules === "string") {
1635 modules = [[null, modules, undefined]];
1636 }
1637 var alreadyImportedModules = {};
1638 if (dedupe) {
1639 for (var k = 0; k < this.length; k++) {
1640 var id = this[k][0];
1641 if (id != null) {
1642 alreadyImportedModules[id] = true;
1643 }
1644 }
1645 }
1646 for (var _k = 0; _k < modules.length; _k++) {
1647 var item = [].concat(modules[_k]);
1648 if (dedupe && alreadyImportedModules[item[0]]) {
1649 continue;
1650 }
1651 if (typeof layer !== "undefined") {
1652 if (typeof item[5] === "undefined") {
1653 item[5] = layer;
1654 } else {
1655 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
1656 item[5] = layer;
1657 }
1658 }
1659 if (media) {
1660 if (!item[2]) {
1661 item[2] = media;
1662 } else {
1663 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
1664 item[2] = media;
1665 }
1666 }
1667 if (supports) {
1668 if (!item[4]) {
1669 item[4] = "".concat(supports);
1670 } else {
1671 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
1672 item[4] = supports;
1673 }
1674 }
1675 list.push(item);
1676 }
1677 };
1678 return list;
1679 };
1680
1681 /***/ },
1682
1683 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
1684 /*!************************************************************!*\
1685 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
1686 \************************************************************/
1687 (module) {
1688
1689 "use strict";
1690
1691
1692 module.exports = function (item) {
1693 var content = item[1];
1694 var cssMapping = item[3];
1695 if (!cssMapping) {
1696 return content;
1697 }
1698 if (typeof btoa === "function") {
1699 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
1700 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
1701 var sourceMapping = "/*# ".concat(data, " */");
1702 return [content].concat([sourceMapping]).join("\n");
1703 }
1704 return [content].join("\n");
1705 };
1706
1707 /***/ },
1708
1709 /***/ "./node_modules/toastify-js/src/toastify.css"
1710 /*!***************************************************!*\
1711 !*** ./node_modules/toastify-js/src/toastify.css ***!
1712 \***************************************************/
1713 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1714
1715 "use strict";
1716 __webpack_require__.r(__webpack_exports__);
1717 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1718 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1719 /* harmony export */ });
1720 /* 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");
1721 /* 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__);
1722 /* 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");
1723 /* 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__);
1724 /* 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");
1725 /* 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__);
1726 /* 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");
1727 /* 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__);
1728 /* 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");
1729 /* 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__);
1730 /* 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");
1731 /* 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__);
1732 /* 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");
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744 var options = {};
1745
1746 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
1747 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
1748
1749 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
1750
1751 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
1752 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
1753
1754 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);
1755
1756
1757
1758
1759 /* 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);
1760
1761
1762 /***/ },
1763
1764 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
1765 /*!****************************************************************************!*\
1766 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
1767 \****************************************************************************/
1768 (module) {
1769
1770 "use strict";
1771
1772
1773 var stylesInDOM = [];
1774 function getIndexByIdentifier(identifier) {
1775 var result = -1;
1776 for (var i = 0; i < stylesInDOM.length; i++) {
1777 if (stylesInDOM[i].identifier === identifier) {
1778 result = i;
1779 break;
1780 }
1781 }
1782 return result;
1783 }
1784 function modulesToDom(list, options) {
1785 var idCountMap = {};
1786 var identifiers = [];
1787 for (var i = 0; i < list.length; i++) {
1788 var item = list[i];
1789 var id = options.base ? item[0] + options.base : item[0];
1790 var count = idCountMap[id] || 0;
1791 var identifier = "".concat(id, " ").concat(count);
1792 idCountMap[id] = count + 1;
1793 var indexByIdentifier = getIndexByIdentifier(identifier);
1794 var obj = {
1795 css: item[1],
1796 media: item[2],
1797 sourceMap: item[3],
1798 supports: item[4],
1799 layer: item[5]
1800 };
1801 if (indexByIdentifier !== -1) {
1802 stylesInDOM[indexByIdentifier].references++;
1803 stylesInDOM[indexByIdentifier].updater(obj);
1804 } else {
1805 var updater = addElementStyle(obj, options);
1806 options.byIndex = i;
1807 stylesInDOM.splice(i, 0, {
1808 identifier: identifier,
1809 updater: updater,
1810 references: 1
1811 });
1812 }
1813 identifiers.push(identifier);
1814 }
1815 return identifiers;
1816 }
1817 function addElementStyle(obj, options) {
1818 var api = options.domAPI(options);
1819 api.update(obj);
1820 var updater = function updater(newObj) {
1821 if (newObj) {
1822 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
1823 return;
1824 }
1825 api.update(obj = newObj);
1826 } else {
1827 api.remove();
1828 }
1829 };
1830 return updater;
1831 }
1832 module.exports = function (list, options) {
1833 options = options || {};
1834 list = list || [];
1835 var lastIdentifiers = modulesToDom(list, options);
1836 return function update(newList) {
1837 newList = newList || [];
1838 for (var i = 0; i < lastIdentifiers.length; i++) {
1839 var identifier = lastIdentifiers[i];
1840 var index = getIndexByIdentifier(identifier);
1841 stylesInDOM[index].references--;
1842 }
1843 var newLastIdentifiers = modulesToDom(newList, options);
1844 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
1845 var _identifier = lastIdentifiers[_i];
1846 var _index = getIndexByIdentifier(_identifier);
1847 if (stylesInDOM[_index].references === 0) {
1848 stylesInDOM[_index].updater();
1849 stylesInDOM.splice(_index, 1);
1850 }
1851 }
1852 lastIdentifiers = newLastIdentifiers;
1853 };
1854 };
1855
1856 /***/ },
1857
1858 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
1859 /*!********************************************************************!*\
1860 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
1861 \********************************************************************/
1862 (module) {
1863
1864 "use strict";
1865
1866
1867 var memo = {};
1868
1869 /* istanbul ignore next */
1870 function getTarget(target) {
1871 if (typeof memo[target] === "undefined") {
1872 var styleTarget = document.querySelector(target);
1873
1874 // Special case to return head of iframe instead of iframe itself
1875 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
1876 try {
1877 // This will throw an exception if access to iframe is blocked
1878 // due to cross-origin restrictions
1879 styleTarget = styleTarget.contentDocument.head;
1880 } catch (e) {
1881 // istanbul ignore next
1882 styleTarget = null;
1883 }
1884 }
1885 memo[target] = styleTarget;
1886 }
1887 return memo[target];
1888 }
1889
1890 /* istanbul ignore next */
1891 function insertBySelector(insert, style) {
1892 var target = getTarget(insert);
1893 if (!target) {
1894 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
1895 }
1896 target.appendChild(style);
1897 }
1898 module.exports = insertBySelector;
1899
1900 /***/ },
1901
1902 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
1903 /*!**********************************************************************!*\
1904 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
1905 \**********************************************************************/
1906 (module) {
1907
1908 "use strict";
1909
1910
1911 /* istanbul ignore next */
1912 function insertStyleElement(options) {
1913 var element = document.createElement("style");
1914 options.setAttributes(element, options.attributes);
1915 options.insert(element, options.options);
1916 return element;
1917 }
1918 module.exports = insertStyleElement;
1919
1920 /***/ },
1921
1922 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
1923 /*!**********************************************************************************!*\
1924 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
1925 \**********************************************************************************/
1926 (module, __unused_webpack_exports, __webpack_require__) {
1927
1928 "use strict";
1929
1930
1931 /* istanbul ignore next */
1932 function setAttributesWithoutAttributes(styleElement) {
1933 var nonce = true ? __webpack_require__.nc : 0;
1934 if (nonce) {
1935 styleElement.setAttribute("nonce", nonce);
1936 }
1937 }
1938 module.exports = setAttributesWithoutAttributes;
1939
1940 /***/ },
1941
1942 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
1943 /*!***************************************************************!*\
1944 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
1945 \***************************************************************/
1946 (module) {
1947
1948 "use strict";
1949
1950
1951 /* istanbul ignore next */
1952 function apply(styleElement, options, obj) {
1953 var css = "";
1954 if (obj.supports) {
1955 css += "@supports (".concat(obj.supports, ") {");
1956 }
1957 if (obj.media) {
1958 css += "@media ".concat(obj.media, " {");
1959 }
1960 var needLayer = typeof obj.layer !== "undefined";
1961 if (needLayer) {
1962 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
1963 }
1964 css += obj.css;
1965 if (needLayer) {
1966 css += "}";
1967 }
1968 if (obj.media) {
1969 css += "}";
1970 }
1971 if (obj.supports) {
1972 css += "}";
1973 }
1974 var sourceMap = obj.sourceMap;
1975 if (sourceMap && typeof btoa !== "undefined") {
1976 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
1977 }
1978
1979 // For old IE
1980 /* istanbul ignore if */
1981 options.styleTagTransform(css, styleElement, options.options);
1982 }
1983 function removeStyleElement(styleElement) {
1984 // istanbul ignore if
1985 if (styleElement.parentNode === null) {
1986 return false;
1987 }
1988 styleElement.parentNode.removeChild(styleElement);
1989 }
1990
1991 /* istanbul ignore next */
1992 function domAPI(options) {
1993 if (typeof document === "undefined") {
1994 return {
1995 update: function update() {},
1996 remove: function remove() {}
1997 };
1998 }
1999 var styleElement = options.insertStyleElement(options);
2000 return {
2001 update: function update(obj) {
2002 apply(styleElement, options, obj);
2003 },
2004 remove: function remove() {
2005 removeStyleElement(styleElement);
2006 }
2007 };
2008 }
2009 module.exports = domAPI;
2010
2011 /***/ },
2012
2013 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
2014 /*!*********************************************************************!*\
2015 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
2016 \*********************************************************************/
2017 (module) {
2018
2019 "use strict";
2020
2021
2022 /* istanbul ignore next */
2023 function styleTagTransform(css, styleElement) {
2024 if (styleElement.styleSheet) {
2025 styleElement.styleSheet.cssText = css;
2026 } else {
2027 while (styleElement.firstChild) {
2028 styleElement.removeChild(styleElement.firstChild);
2029 }
2030 styleElement.appendChild(document.createTextNode(css));
2031 }
2032 }
2033 module.exports = styleTagTransform;
2034
2035 /***/ },
2036
2037 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
2038 /*!**********************************************************!*\
2039 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
2040 \**********************************************************/
2041 (module) {
2042
2043 /*!
2044 * sweetalert2 v11.26.17
2045 * Released under the MIT License.
2046 */
2047 (function (global, factory) {
2048 true ? module.exports = factory() :
2049 0;
2050 })(this, (function () { 'use strict';
2051
2052 function _assertClassBrand(e, t, n) {
2053 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2054 throw new TypeError("Private element is not present on this object");
2055 }
2056 function _checkPrivateRedeclaration(e, t) {
2057 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2058 }
2059 function _classPrivateFieldGet2(s, a) {
2060 return s.get(_assertClassBrand(s, a));
2061 }
2062 function _classPrivateFieldInitSpec(e, t, a) {
2063 _checkPrivateRedeclaration(e, t), t.set(e, a);
2064 }
2065 function _classPrivateFieldSet2(s, a, r) {
2066 return s.set(_assertClassBrand(s, a), r), r;
2067 }
2068
2069 const RESTORE_FOCUS_TIMEOUT = 100;
2070
2071 /** @type {GlobalState} */
2072 const globalState = {};
2073 const focusPreviousActiveElement = () => {
2074 if (globalState.previousActiveElement instanceof HTMLElement) {
2075 globalState.previousActiveElement.focus();
2076 globalState.previousActiveElement = null;
2077 } else if (document.body) {
2078 document.body.focus();
2079 }
2080 };
2081
2082 /**
2083 * Restore previous active (focused) element
2084 *
2085 * @param {boolean} returnFocus
2086 * @returns {Promise<void>}
2087 */
2088 const restoreActiveElement = returnFocus => {
2089 return new Promise(resolve => {
2090 if (!returnFocus) {
2091 return resolve();
2092 }
2093 const x = window.scrollX;
2094 const y = window.scrollY;
2095 globalState.restoreFocusTimeout = setTimeout(() => {
2096 focusPreviousActiveElement();
2097 resolve();
2098 }, RESTORE_FOCUS_TIMEOUT); // issues/900
2099
2100 window.scrollTo(x, y);
2101 });
2102 };
2103
2104 const swalPrefix = 'swal2-';
2105
2106 /**
2107 * @typedef {Record<SwalClass, string>} SwalClasses
2108 */
2109
2110 /**
2111 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
2112 * @typedef {Record<SwalIcon, string>} SwalIcons
2113 */
2114
2115 /** @type {SwalClass[]} */
2116 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'];
2117 const swalClasses = classNames.reduce((acc, className) => {
2118 acc[className] = swalPrefix + className;
2119 return acc;
2120 }, /** @type {SwalClasses} */{});
2121
2122 /** @type {SwalIcon[]} */
2123 const icons = ['success', 'warning', 'info', 'question', 'error'];
2124 const iconTypes = icons.reduce((acc, icon) => {
2125 acc[icon] = swalPrefix + icon;
2126 return acc;
2127 }, /** @type {SwalIcons} */{});
2128
2129 const consolePrefix = 'SweetAlert2:';
2130
2131 /**
2132 * Capitalize the first letter of a string
2133 *
2134 * @param {string} str
2135 * @returns {string}
2136 */
2137 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
2138
2139 /**
2140 * Standardize console warnings
2141 *
2142 * @param {string | string[]} message
2143 */
2144 const warn = message => {
2145 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
2146 };
2147
2148 /**
2149 * Standardize console errors
2150 *
2151 * @param {string} message
2152 */
2153 const error = message => {
2154 console.error(`${consolePrefix} ${message}`);
2155 };
2156
2157 /**
2158 * Private global state for `warnOnce`
2159 *
2160 * @type {string[]}
2161 * @private
2162 */
2163 const previousWarnOnceMessages = [];
2164
2165 /**
2166 * Show a console warning, but only if it hasn't already been shown
2167 *
2168 * @param {string} message
2169 */
2170 const warnOnce = message => {
2171 if (!previousWarnOnceMessages.includes(message)) {
2172 previousWarnOnceMessages.push(message);
2173 warn(message);
2174 }
2175 };
2176
2177 /**
2178 * Show a one-time console warning about deprecated params/methods
2179 *
2180 * @param {string} deprecatedParam
2181 * @param {string?} useInstead
2182 */
2183 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
2184 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
2185 };
2186
2187 /**
2188 * If `arg` is a function, call it (with no arguments or context) and return the result.
2189 * Otherwise, just pass the value through
2190 *
2191 * @param {(() => *) | *} arg
2192 * @returns {*}
2193 */
2194 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
2195
2196 /**
2197 * @param {*} arg
2198 * @returns {boolean}
2199 */
2200 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
2201
2202 /**
2203 * @param {*} arg
2204 * @returns {Promise<*>}
2205 */
2206 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
2207
2208 /**
2209 * @param {*} arg
2210 * @returns {boolean}
2211 */
2212 const isPromise = arg => arg && Promise.resolve(arg) === arg;
2213
2214 /**
2215 * Gets the popup container which contains the backdrop and the popup itself.
2216 *
2217 * @returns {HTMLElement | null}
2218 */
2219 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2220
2221 /**
2222 * @param {string} selectorString
2223 * @returns {HTMLElement | null}
2224 */
2225 const elementBySelector = selectorString => {
2226 const container = getContainer();
2227 return container ? container.querySelector(selectorString) : null;
2228 };
2229
2230 /**
2231 * @param {string} className
2232 * @returns {HTMLElement | null}
2233 */
2234 const elementByClass = className => {
2235 return elementBySelector(`.${className}`);
2236 };
2237
2238 /**
2239 * @returns {HTMLElement | null}
2240 */
2241 const getPopup = () => elementByClass(swalClasses.popup);
2242
2243 /**
2244 * @returns {HTMLElement | null}
2245 */
2246 const getIcon = () => elementByClass(swalClasses.icon);
2247
2248 /**
2249 * @returns {HTMLElement | null}
2250 */
2251 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2252
2253 /**
2254 * @returns {HTMLElement | null}
2255 */
2256 const getTitle = () => elementByClass(swalClasses.title);
2257
2258 /**
2259 * @returns {HTMLElement | null}
2260 */
2261 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2262
2263 /**
2264 * @returns {HTMLElement | null}
2265 */
2266 const getImage = () => elementByClass(swalClasses.image);
2267
2268 /**
2269 * @returns {HTMLElement | null}
2270 */
2271 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2272
2273 /**
2274 * @returns {HTMLElement | null}
2275 */
2276 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2277
2278 /**
2279 * @returns {HTMLButtonElement | null}
2280 */
2281 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2282
2283 /**
2284 * @returns {HTMLButtonElement | null}
2285 */
2286 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2287
2288 /**
2289 * @returns {HTMLButtonElement | null}
2290 */
2291 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2292
2293 /**
2294 * @returns {HTMLElement | null}
2295 */
2296 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2297
2298 /**
2299 * @returns {HTMLElement | null}
2300 */
2301 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2302
2303 /**
2304 * @returns {HTMLElement | null}
2305 */
2306 const getActions = () => elementByClass(swalClasses.actions);
2307
2308 /**
2309 * @returns {HTMLElement | null}
2310 */
2311 const getFooter = () => elementByClass(swalClasses.footer);
2312
2313 /**
2314 * @returns {HTMLElement | null}
2315 */
2316 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2317
2318 /**
2319 * @returns {HTMLElement | null}
2320 */
2321 const getCloseButton = () => elementByClass(swalClasses.close);
2322
2323 // https://github.com/jkup/focusable/blob/master/index.js
2324 const focusable = `
2325 a[href],
2326 area[href],
2327 input:not([disabled]),
2328 select:not([disabled]),
2329 textarea:not([disabled]),
2330 button:not([disabled]),
2331 iframe,
2332 object,
2333 embed,
2334 [tabindex="0"],
2335 [contenteditable],
2336 audio[controls],
2337 video[controls],
2338 summary
2339 `;
2340 /**
2341 * @returns {HTMLElement[]}
2342 */
2343 const getFocusableElements = () => {
2344 const popup = getPopup();
2345 if (!popup) {
2346 return [];
2347 }
2348 /** @type {NodeListOf<HTMLElement>} */
2349 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2350 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2351 // sort according to tabindex
2352 .sort((a, b) => {
2353 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2354 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2355 if (tabindexA > tabindexB) {
2356 return 1;
2357 } else if (tabindexA < tabindexB) {
2358 return -1;
2359 }
2360 return 0;
2361 });
2362
2363 /** @type {NodeListOf<HTMLElement>} */
2364 const otherFocusableElements = popup.querySelectorAll(focusable);
2365 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2366 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2367 };
2368
2369 /**
2370 * @returns {boolean}
2371 */
2372 const isModal = () => {
2373 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2374 };
2375
2376 /**
2377 * @returns {boolean}
2378 */
2379 const isToast = () => {
2380 const popup = getPopup();
2381 if (!popup) {
2382 return false;
2383 }
2384 return hasClass(popup, swalClasses.toast);
2385 };
2386
2387 /**
2388 * @returns {boolean}
2389 */
2390 const isLoading = () => {
2391 const popup = getPopup();
2392 if (!popup) {
2393 return false;
2394 }
2395 return popup.hasAttribute('data-loading');
2396 };
2397
2398 /**
2399 * Securely set innerHTML of an element
2400 * https://github.com/sweetalert2/sweetalert2/issues/1926
2401 *
2402 * @param {HTMLElement} elem
2403 * @param {string} html
2404 */
2405 const setInnerHtml = (elem, html) => {
2406 elem.textContent = '';
2407 if (html) {
2408 const parser = new DOMParser();
2409 const parsed = parser.parseFromString(html, `text/html`);
2410 const head = parsed.querySelector('head');
2411 if (head) {
2412 Array.from(head.childNodes).forEach(child => {
2413 elem.appendChild(child);
2414 });
2415 }
2416 const body = parsed.querySelector('body');
2417 if (body) {
2418 Array.from(body.childNodes).forEach(child => {
2419 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2420 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2421 } else {
2422 elem.appendChild(child);
2423 }
2424 });
2425 }
2426 }
2427 };
2428
2429 /**
2430 * @param {HTMLElement} elem
2431 * @param {string} className
2432 * @returns {boolean}
2433 */
2434 const hasClass = (elem, className) => {
2435 if (!className) {
2436 return false;
2437 }
2438 const classList = className.split(/\s+/);
2439 for (let i = 0; i < classList.length; i++) {
2440 if (!elem.classList.contains(classList[i])) {
2441 return false;
2442 }
2443 }
2444 return true;
2445 };
2446
2447 /**
2448 * @param {HTMLElement} elem
2449 * @param {SweetAlertOptions} params
2450 */
2451 const removeCustomClasses = (elem, params) => {
2452 Array.from(elem.classList).forEach(className => {
2453 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2454 elem.classList.remove(className);
2455 }
2456 });
2457 };
2458
2459 /**
2460 * @param {HTMLElement} elem
2461 * @param {SweetAlertOptions} params
2462 * @param {string} className
2463 */
2464 const applyCustomClass = (elem, params, className) => {
2465 removeCustomClasses(elem, params);
2466 if (!params.customClass) {
2467 return;
2468 }
2469 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2470 if (!customClass) {
2471 return;
2472 }
2473 if (typeof customClass !== 'string' && !customClass.forEach) {
2474 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2475 return;
2476 }
2477 addClass(elem, customClass);
2478 };
2479
2480 /**
2481 * @param {HTMLElement} popup
2482 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2483 * @returns {HTMLInputElement | null}
2484 */
2485 const getInput$1 = (popup, inputClass) => {
2486 if (!inputClass) {
2487 return null;
2488 }
2489 switch (inputClass) {
2490 case 'select':
2491 case 'textarea':
2492 case 'file':
2493 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2494 case 'checkbox':
2495 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2496 case 'radio':
2497 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2498 case 'range':
2499 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2500 default:
2501 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2502 }
2503 };
2504
2505 /**
2506 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2507 */
2508 const focusInput = input => {
2509 input.focus();
2510
2511 // place cursor at end of text in text input
2512 if (input.type !== 'file') {
2513 // http://stackoverflow.com/a/2345915
2514 const val = input.value;
2515 input.value = '';
2516 input.value = val;
2517 }
2518 };
2519
2520 /**
2521 * @param {HTMLElement | HTMLElement[] | null} target
2522 * @param {string | string[] | readonly string[] | undefined} classList
2523 * @param {boolean} condition
2524 */
2525 const toggleClass = (target, classList, condition) => {
2526 if (!target || !classList) {
2527 return;
2528 }
2529 if (typeof classList === 'string') {
2530 classList = classList.split(/\s+/).filter(Boolean);
2531 }
2532 classList.forEach(className => {
2533 if (Array.isArray(target)) {
2534 target.forEach(elem => {
2535 if (condition) {
2536 elem.classList.add(className);
2537 } else {
2538 elem.classList.remove(className);
2539 }
2540 });
2541 } else {
2542 if (condition) {
2543 target.classList.add(className);
2544 } else {
2545 target.classList.remove(className);
2546 }
2547 }
2548 });
2549 };
2550
2551 /**
2552 * @param {HTMLElement | HTMLElement[] | null} target
2553 * @param {string | string[] | readonly string[] | undefined} classList
2554 */
2555 const addClass = (target, classList) => {
2556 toggleClass(target, classList, true);
2557 };
2558
2559 /**
2560 * @param {HTMLElement | HTMLElement[] | null} target
2561 * @param {string | string[] | readonly string[] | undefined} classList
2562 */
2563 const removeClass = (target, classList) => {
2564 toggleClass(target, classList, false);
2565 };
2566
2567 /**
2568 * Get direct child of an element by class name
2569 *
2570 * @param {HTMLElement} elem
2571 * @param {string} className
2572 * @returns {HTMLElement | undefined}
2573 */
2574 const getDirectChildByClass = (elem, className) => {
2575 const children = Array.from(elem.children);
2576 for (let i = 0; i < children.length; i++) {
2577 const child = children[i];
2578 if (child instanceof HTMLElement && hasClass(child, className)) {
2579 return child;
2580 }
2581 }
2582 };
2583
2584 /**
2585 * @param {HTMLElement} elem
2586 * @param {string} property
2587 * @param {string | number | null | undefined} value
2588 */
2589 const applyNumericalStyle = (elem, property, value) => {
2590 if (value === `${parseInt(`${value}`)}`) {
2591 value = parseInt(value);
2592 }
2593 if (value || parseInt(`${value}`) === 0) {
2594 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2595 } else {
2596 elem.style.removeProperty(property);
2597 }
2598 };
2599
2600 /**
2601 * @param {HTMLElement | null} elem
2602 * @param {string} display
2603 */
2604 const show = (elem, display = 'flex') => {
2605 if (!elem) {
2606 return;
2607 }
2608 elem.style.display = display;
2609 };
2610
2611 /**
2612 * @param {HTMLElement | null} elem
2613 */
2614 const hide = elem => {
2615 if (!elem) {
2616 return;
2617 }
2618 elem.style.display = 'none';
2619 };
2620
2621 /**
2622 * @param {HTMLElement | null} elem
2623 * @param {string} display
2624 */
2625 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2626 if (!elem) {
2627 return;
2628 }
2629 new MutationObserver(() => {
2630 toggle(elem, elem.innerHTML, display);
2631 }).observe(elem, {
2632 childList: true,
2633 subtree: true
2634 });
2635 };
2636
2637 /**
2638 * @param {HTMLElement} parent
2639 * @param {string} selector
2640 * @param {string} property
2641 * @param {string} value
2642 */
2643 const setStyle = (parent, selector, property, value) => {
2644 /** @type {HTMLElement | null} */
2645 const el = parent.querySelector(selector);
2646 if (el) {
2647 el.style.setProperty(property, value);
2648 }
2649 };
2650
2651 /**
2652 * @param {HTMLElement} elem
2653 * @param {boolean | string | null | undefined} condition
2654 * @param {string} display
2655 */
2656 const toggle = (elem, condition, display = 'flex') => {
2657 if (condition) {
2658 show(elem, display);
2659 } else {
2660 hide(elem);
2661 }
2662 };
2663
2664 /**
2665 * borrowed from jquery $(elem).is(':visible') implementation
2666 *
2667 * @param {HTMLElement | null} elem
2668 * @returns {boolean}
2669 */
2670 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2671
2672 /**
2673 * @returns {boolean}
2674 */
2675 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2676
2677 /**
2678 * @param {HTMLElement} elem
2679 * @returns {boolean}
2680 */
2681 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2682
2683 /**
2684 * @param {HTMLElement} element
2685 * @param {HTMLElement} stopElement
2686 * @returns {boolean}
2687 */
2688 const selfOrParentIsScrollable = (element, stopElement) => {
2689 let parent = /** @type {HTMLElement | null} */element;
2690 while (parent && parent !== stopElement) {
2691 if (isScrollable(parent)) {
2692 return true;
2693 }
2694 parent = parent.parentElement;
2695 }
2696 return false;
2697 };
2698
2699 /**
2700 * borrowed from https://stackoverflow.com/a/46352119
2701 *
2702 * @param {HTMLElement} elem
2703 * @returns {boolean}
2704 */
2705 const hasCssAnimation = elem => {
2706 const style = window.getComputedStyle(elem);
2707 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2708 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2709 return animDuration > 0 || transDuration > 0;
2710 };
2711
2712 /**
2713 * @param {number} timer
2714 * @param {boolean} reset
2715 */
2716 const animateTimerProgressBar = (timer, reset = false) => {
2717 const timerProgressBar = getTimerProgressBar();
2718 if (!timerProgressBar) {
2719 return;
2720 }
2721 if (isVisible$1(timerProgressBar)) {
2722 if (reset) {
2723 timerProgressBar.style.transition = 'none';
2724 timerProgressBar.style.width = '100%';
2725 }
2726 setTimeout(() => {
2727 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2728 timerProgressBar.style.width = '0%';
2729 }, 10);
2730 }
2731 };
2732 const stopTimerProgressBar = () => {
2733 const timerProgressBar = getTimerProgressBar();
2734 if (!timerProgressBar) {
2735 return;
2736 }
2737 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2738 timerProgressBar.style.removeProperty('transition');
2739 timerProgressBar.style.width = '100%';
2740 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2741 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2742 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2743 };
2744
2745 /**
2746 * Detect Node env
2747 *
2748 * @returns {boolean}
2749 */
2750 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2751
2752 const sweetHTML = `
2753 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2754 <button type="button" class="${swalClasses.close}"></button>
2755 <ul class="${swalClasses['progress-steps']}"></ul>
2756 <div class="${swalClasses.icon}"></div>
2757 <img class="${swalClasses.image}" />
2758 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2759 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2760 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2761 <input type="file" class="${swalClasses.file}" />
2762 <div class="${swalClasses.range}">
2763 <input type="range" />
2764 <output></output>
2765 </div>
2766 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2767 <div class="${swalClasses.radio}"></div>
2768 <label class="${swalClasses.checkbox}">
2769 <input type="checkbox" id="${swalClasses.checkbox}" />
2770 <span class="${swalClasses.label}"></span>
2771 </label>
2772 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2773 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2774 <div class="${swalClasses.actions}">
2775 <div class="${swalClasses.loader}"></div>
2776 <button type="button" class="${swalClasses.confirm}"></button>
2777 <button type="button" class="${swalClasses.deny}"></button>
2778 <button type="button" class="${swalClasses.cancel}"></button>
2779 </div>
2780 <div class="${swalClasses.footer}"></div>
2781 <div class="${swalClasses['timer-progress-bar-container']}">
2782 <div class="${swalClasses['timer-progress-bar']}"></div>
2783 </div>
2784 </div>
2785 `.replace(/(^|\n)\s*/g, '');
2786
2787 /**
2788 * @returns {boolean}
2789 */
2790 const resetOldContainer = () => {
2791 const oldContainer = getContainer();
2792 if (!oldContainer) {
2793 return false;
2794 }
2795 oldContainer.remove();
2796 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2797 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2798 swalClasses['has-column']]);
2799 return true;
2800 };
2801 const resetValidationMessage$1 = () => {
2802 if (globalState.currentInstance) {
2803 globalState.currentInstance.resetValidationMessage();
2804 }
2805 };
2806 const addInputChangeListeners = () => {
2807 const popup = getPopup();
2808 if (!popup) {
2809 return;
2810 }
2811 const input = getDirectChildByClass(popup, swalClasses.input);
2812 const file = getDirectChildByClass(popup, swalClasses.file);
2813 /** @type {HTMLInputElement | null} */
2814 const range = popup.querySelector(`.${swalClasses.range} input`);
2815 /** @type {HTMLOutputElement | null} */
2816 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2817 const select = getDirectChildByClass(popup, swalClasses.select);
2818 /** @type {HTMLInputElement | null} */
2819 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2820 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2821 if (input) {
2822 input.oninput = resetValidationMessage$1;
2823 }
2824 if (file) {
2825 file.onchange = resetValidationMessage$1;
2826 }
2827 if (select) {
2828 select.onchange = resetValidationMessage$1;
2829 }
2830 if (checkbox) {
2831 checkbox.onchange = resetValidationMessage$1;
2832 }
2833 if (textarea) {
2834 textarea.oninput = resetValidationMessage$1;
2835 }
2836 if (range && rangeOutput) {
2837 range.oninput = () => {
2838 resetValidationMessage$1();
2839 rangeOutput.value = range.value;
2840 };
2841 range.onchange = () => {
2842 resetValidationMessage$1();
2843 rangeOutput.value = range.value;
2844 };
2845 }
2846 };
2847
2848 /**
2849 * @param {string | HTMLElement} target
2850 * @returns {HTMLElement}
2851 */
2852 const getTarget = target => {
2853 if (typeof target === 'string') {
2854 const element = document.querySelector(target);
2855 if (!element) {
2856 throw new Error(`Target element "${target}" not found`);
2857 }
2858 return /** @type {HTMLElement} */element;
2859 }
2860 return target;
2861 };
2862
2863 /**
2864 * @param {SweetAlertOptions} params
2865 */
2866 const setupAccessibility = params => {
2867 const popup = getPopup();
2868 if (!popup) {
2869 return;
2870 }
2871 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2872 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2873 if (!params.toast) {
2874 popup.setAttribute('aria-modal', 'true');
2875 }
2876 };
2877
2878 /**
2879 * @param {HTMLElement} targetElement
2880 */
2881 const setupRTL = targetElement => {
2882 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2883 addClass(getContainer(), swalClasses.rtl);
2884 globalState.isRTL = true;
2885 }
2886 };
2887
2888 /**
2889 * Add modal + backdrop to DOM
2890 *
2891 * @param {SweetAlertOptions} params
2892 */
2893 const init = params => {
2894 // Clean up the old popup container if it exists
2895 const oldContainerExisted = resetOldContainer();
2896 if (isNodeEnv()) {
2897 error('SweetAlert2 requires document to initialize');
2898 return;
2899 }
2900 const container = document.createElement('div');
2901 container.className = swalClasses.container;
2902 if (oldContainerExisted) {
2903 addClass(container, swalClasses['no-transition']);
2904 }
2905 setInnerHtml(container, sweetHTML);
2906 container.dataset['swal2Theme'] = params.theme;
2907 const targetElement = getTarget(params.target || 'body');
2908 targetElement.appendChild(container);
2909 if (params.topLayer) {
2910 container.setAttribute('popover', '');
2911 container.showPopover();
2912 }
2913 setupAccessibility(params);
2914 setupRTL(targetElement);
2915 addInputChangeListeners();
2916 };
2917
2918 /**
2919 * @param {HTMLElement | object | string} param
2920 * @param {HTMLElement} target
2921 */
2922 const parseHtmlToContainer = (param, target) => {
2923 // DOM element
2924 if (param instanceof HTMLElement) {
2925 target.appendChild(param);
2926 }
2927
2928 // Object
2929 else if (typeof param === 'object') {
2930 handleObject(param, target);
2931 }
2932
2933 // Plain string
2934 else if (param) {
2935 setInnerHtml(target, param);
2936 }
2937 };
2938
2939 /**
2940 * @param {object} param
2941 * @param {HTMLElement} target
2942 */
2943 const handleObject = (param, target) => {
2944 // JQuery element(s)
2945 if ('jquery' in param) {
2946 handleJqueryElem(target, param);
2947 }
2948
2949 // For other objects use their string representation
2950 else {
2951 setInnerHtml(target, param.toString());
2952 }
2953 };
2954
2955 /**
2956 * @param {HTMLElement} target
2957 * @param {any} elem
2958 */
2959 const handleJqueryElem = (target, elem) => {
2960 target.textContent = '';
2961 if (0 in elem) {
2962 for (let i = 0; i in elem; i++) {
2963 target.appendChild(elem[i].cloneNode(true));
2964 }
2965 } else {
2966 target.appendChild(elem.cloneNode(true));
2967 }
2968 };
2969
2970 /**
2971 * @param {SweetAlert} instance
2972 * @param {SweetAlertOptions} params
2973 */
2974 const renderActions = (instance, params) => {
2975 const actions = getActions();
2976 const loader = getLoader();
2977 if (!actions || !loader) {
2978 return;
2979 }
2980
2981 // Actions (buttons) wrapper
2982 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2983 hide(actions);
2984 } else {
2985 show(actions);
2986 }
2987
2988 // Custom class
2989 applyCustomClass(actions, params, 'actions');
2990
2991 // Render all the buttons
2992 renderButtons(actions, loader, params);
2993
2994 // Loader
2995 setInnerHtml(loader, params.loaderHtml || '');
2996 applyCustomClass(loader, params, 'loader');
2997 };
2998
2999 /**
3000 * @param {HTMLElement} actions
3001 * @param {HTMLElement} loader
3002 * @param {SweetAlertOptions} params
3003 */
3004 function renderButtons(actions, loader, params) {
3005 const confirmButton = getConfirmButton();
3006 const denyButton = getDenyButton();
3007 const cancelButton = getCancelButton();
3008 if (!confirmButton || !denyButton || !cancelButton) {
3009 return;
3010 }
3011
3012 // Render buttons
3013 renderButton(confirmButton, 'confirm', params);
3014 renderButton(denyButton, 'deny', params);
3015 renderButton(cancelButton, 'cancel', params);
3016 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3017 if (params.reverseButtons) {
3018 if (params.toast) {
3019 actions.insertBefore(cancelButton, confirmButton);
3020 actions.insertBefore(denyButton, confirmButton);
3021 } else {
3022 actions.insertBefore(cancelButton, loader);
3023 actions.insertBefore(denyButton, loader);
3024 actions.insertBefore(confirmButton, loader);
3025 }
3026 }
3027 }
3028
3029 /**
3030 * @param {HTMLElement} confirmButton
3031 * @param {HTMLElement} denyButton
3032 * @param {HTMLElement} cancelButton
3033 * @param {SweetAlertOptions} params
3034 */
3035 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3036 if (!params.buttonsStyling) {
3037 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3038 return;
3039 }
3040 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3041
3042 // Apply custom background colors to action buttons
3043 if (params.confirmButtonColor) {
3044 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
3045 }
3046 if (params.denyButtonColor) {
3047 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
3048 }
3049 if (params.cancelButtonColor) {
3050 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
3051 }
3052
3053 // Apply the outline color to action buttons
3054 applyOutlineColor(confirmButton);
3055 applyOutlineColor(denyButton);
3056 applyOutlineColor(cancelButton);
3057 }
3058
3059 /**
3060 * @param {HTMLElement} button
3061 */
3062 function applyOutlineColor(button) {
3063 const buttonStyle = window.getComputedStyle(button);
3064 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3065 // If the button already has a custom outline color, no need to change it
3066 return;
3067 }
3068 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3069 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3070 }
3071
3072 /**
3073 * @param {HTMLElement} button
3074 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3075 * @param {SweetAlertOptions} params
3076 */
3077 function renderButton(button, buttonType, params) {
3078 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3079 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3080 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3081 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3082
3083 // Add buttons custom classes
3084 button.className = swalClasses[buttonType];
3085 applyCustomClass(button, params, `${buttonType}Button`);
3086 }
3087
3088 /**
3089 * @param {SweetAlert} instance
3090 * @param {SweetAlertOptions} params
3091 */
3092 const renderCloseButton = (instance, params) => {
3093 const closeButton = getCloseButton();
3094 if (!closeButton) {
3095 return;
3096 }
3097 setInnerHtml(closeButton, params.closeButtonHtml || '');
3098
3099 // Custom class
3100 applyCustomClass(closeButton, params, 'closeButton');
3101 toggle(closeButton, params.showCloseButton);
3102 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3103 };
3104
3105 /**
3106 * @param {SweetAlert} instance
3107 * @param {SweetAlertOptions} params
3108 */
3109 const renderContainer = (instance, params) => {
3110 const container = getContainer();
3111 if (!container) {
3112 return;
3113 }
3114 handleBackdropParam(container, params.backdrop);
3115 handlePositionParam(container, params.position);
3116 handleGrowParam(container, params.grow);
3117
3118 // Custom class
3119 applyCustomClass(container, params, 'container');
3120 };
3121
3122 /**
3123 * @param {HTMLElement} container
3124 * @param {SweetAlertOptions['backdrop']} backdrop
3125 */
3126 function handleBackdropParam(container, backdrop) {
3127 if (typeof backdrop === 'string') {
3128 container.style.background = backdrop;
3129 } else if (!backdrop) {
3130 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3131 }
3132 }
3133
3134 /**
3135 * @param {HTMLElement} container
3136 * @param {SweetAlertOptions['position']} position
3137 */
3138 function handlePositionParam(container, position) {
3139 if (!position) {
3140 return;
3141 }
3142 if (position in swalClasses) {
3143 addClass(container, swalClasses[position]);
3144 } else {
3145 warn('The "position" parameter is not valid, defaulting to "center"');
3146 addClass(container, swalClasses.center);
3147 }
3148 }
3149
3150 /**
3151 * @param {HTMLElement} container
3152 * @param {SweetAlertOptions['grow']} grow
3153 */
3154 function handleGrowParam(container, grow) {
3155 if (!grow) {
3156 return;
3157 }
3158 addClass(container, swalClasses[`grow-${grow}`]);
3159 }
3160
3161 /**
3162 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3163 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3164 * This is the approach that Babel will probably take to implement private methods/fields
3165 * https://github.com/tc39/proposal-private-methods
3166 * https://github.com/babel/babel/pull/7555
3167 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3168 * then we can use that language feature.
3169 */
3170
3171 var privateProps = {
3172 innerParams: new WeakMap(),
3173 domCache: new WeakMap()
3174 };
3175
3176 /// <reference path="../../../../sweetalert2.d.ts"/>
3177
3178
3179 /** @type {InputClass[]} */
3180 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3181
3182 /**
3183 * @param {SweetAlert} instance
3184 * @param {SweetAlertOptions} params
3185 */
3186 const renderInput = (instance, params) => {
3187 const popup = getPopup();
3188 if (!popup) {
3189 return;
3190 }
3191 const innerParams = privateProps.innerParams.get(instance);
3192 const rerender = !innerParams || params.input !== innerParams.input;
3193 inputClasses.forEach(inputClass => {
3194 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3195 if (!inputContainer) {
3196 return;
3197 }
3198
3199 // set attributes
3200 setAttributes(inputClass, params.inputAttributes);
3201
3202 // set class
3203 inputContainer.className = swalClasses[inputClass];
3204 if (rerender) {
3205 hide(inputContainer);
3206 }
3207 });
3208 if (params.input) {
3209 if (rerender) {
3210 showInput(params);
3211 }
3212 // set custom class
3213 setCustomClass(params);
3214 }
3215 };
3216
3217 /**
3218 * @param {SweetAlertOptions} params
3219 */
3220 const showInput = params => {
3221 if (!params.input) {
3222 return;
3223 }
3224 if (!renderInputType[params.input]) {
3225 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3226 return;
3227 }
3228 const inputContainer = getInputContainer(params.input);
3229 if (!inputContainer) {
3230 return;
3231 }
3232 const input = renderInputType[params.input](inputContainer, params);
3233 show(inputContainer);
3234
3235 // input autofocus
3236 if (params.inputAutoFocus) {
3237 setTimeout(() => {
3238 focusInput(input);
3239 });
3240 }
3241 };
3242
3243 /**
3244 * @param {HTMLInputElement} input
3245 */
3246 const removeAttributes = input => {
3247 for (let i = 0; i < input.attributes.length; i++) {
3248 const attrName = input.attributes[i].name;
3249 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
3250 input.removeAttribute(attrName);
3251 }
3252 }
3253 };
3254
3255 /**
3256 * @param {InputClass} inputClass
3257 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3258 */
3259 const setAttributes = (inputClass, inputAttributes) => {
3260 const popup = getPopup();
3261 if (!popup) {
3262 return;
3263 }
3264 const input = getInput$1(popup, inputClass);
3265 if (!input) {
3266 return;
3267 }
3268 removeAttributes(input);
3269 for (const attr in inputAttributes) {
3270 input.setAttribute(attr, inputAttributes[attr]);
3271 }
3272 };
3273
3274 /**
3275 * @param {SweetAlertOptions} params
3276 */
3277 const setCustomClass = params => {
3278 if (!params.input) {
3279 return;
3280 }
3281 const inputContainer = getInputContainer(params.input);
3282 if (inputContainer) {
3283 applyCustomClass(inputContainer, params, 'input');
3284 }
3285 };
3286
3287 /**
3288 * @param {HTMLInputElement | HTMLTextAreaElement} input
3289 * @param {SweetAlertOptions} params
3290 */
3291 const setInputPlaceholder = (input, params) => {
3292 if (!input.placeholder && params.inputPlaceholder) {
3293 input.placeholder = params.inputPlaceholder;
3294 }
3295 };
3296
3297 /**
3298 * @param {Input} input
3299 * @param {Input} prependTo
3300 * @param {SweetAlertOptions} params
3301 */
3302 const setInputLabel = (input, prependTo, params) => {
3303 if (params.inputLabel) {
3304 const label = document.createElement('label');
3305 const labelClass = swalClasses['input-label'];
3306 label.setAttribute('for', input.id);
3307 label.className = labelClass;
3308 if (typeof params.customClass === 'object') {
3309 addClass(label, params.customClass.inputLabel);
3310 }
3311 label.innerText = params.inputLabel;
3312 prependTo.insertAdjacentElement('beforebegin', label);
3313 }
3314 };
3315
3316 /**
3317 * @param {SweetAlertInput} inputType
3318 * @returns {HTMLElement | undefined}
3319 */
3320 const getInputContainer = inputType => {
3321 const popup = getPopup();
3322 if (!popup) {
3323 return;
3324 }
3325 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3326 };
3327
3328 /**
3329 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3330 * @param {SweetAlertOptions['inputValue']} inputValue
3331 */
3332 const checkAndSetInputValue = (input, inputValue) => {
3333 if (['string', 'number'].includes(typeof inputValue)) {
3334 input.value = `${inputValue}`;
3335 } else if (!isPromise(inputValue)) {
3336 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3337 }
3338 };
3339
3340 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3341 const renderInputType = {};
3342
3343 /**
3344 * @param {Input | HTMLElement} input
3345 * @param {SweetAlertOptions} params
3346 * @returns {Input}
3347 */
3348 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} */
3349 (input, params) => {
3350 const inputElement = /** @type {HTMLInputElement} */input;
3351 checkAndSetInputValue(inputElement, params.inputValue);
3352 setInputLabel(inputElement, inputElement, params);
3353 setInputPlaceholder(inputElement, params);
3354 inputElement.type = /** @type {string} */params.input;
3355 return inputElement;
3356 };
3357
3358 /**
3359 * @param {Input | HTMLElement} input
3360 * @param {SweetAlertOptions} params
3361 * @returns {Input}
3362 */
3363 renderInputType.file = (input, params) => {
3364 const inputElement = /** @type {HTMLInputElement} */input;
3365 setInputLabel(inputElement, inputElement, params);
3366 setInputPlaceholder(inputElement, params);
3367 return inputElement;
3368 };
3369
3370 /**
3371 * @param {Input | HTMLElement} range
3372 * @param {SweetAlertOptions} params
3373 * @returns {Input}
3374 */
3375 renderInputType.range = (range, params) => {
3376 const rangeContainer = /** @type {HTMLElement} */range;
3377 const rangeInput = rangeContainer.querySelector('input');
3378 const rangeOutput = rangeContainer.querySelector('output');
3379 if (rangeInput) {
3380 checkAndSetInputValue(rangeInput, params.inputValue);
3381 rangeInput.type = /** @type {string} */params.input;
3382 setInputLabel(rangeInput, /** @type {Input} */range, params);
3383 }
3384 if (rangeOutput) {
3385 checkAndSetInputValue(rangeOutput, params.inputValue);
3386 }
3387 return /** @type {Input} */range;
3388 };
3389
3390 /**
3391 * @param {Input | HTMLElement} select
3392 * @param {SweetAlertOptions} params
3393 * @returns {Input}
3394 */
3395 renderInputType.select = (select, params) => {
3396 const selectElement = /** @type {HTMLSelectElement} */select;
3397 selectElement.textContent = '';
3398 if (params.inputPlaceholder) {
3399 const placeholder = document.createElement('option');
3400 setInnerHtml(placeholder, params.inputPlaceholder);
3401 placeholder.value = '';
3402 placeholder.disabled = true;
3403 placeholder.selected = true;
3404 selectElement.appendChild(placeholder);
3405 }
3406 setInputLabel(selectElement, selectElement, params);
3407 return selectElement;
3408 };
3409
3410 /**
3411 * @param {Input | HTMLElement} radio
3412 * @returns {Input}
3413 */
3414 renderInputType.radio = radio => {
3415 const radioElement = /** @type {HTMLElement} */radio;
3416 radioElement.textContent = '';
3417 return /** @type {Input} */radio;
3418 };
3419
3420 /**
3421 * @param {Input | HTMLElement} checkboxContainer
3422 * @param {SweetAlertOptions} params
3423 * @returns {Input}
3424 */
3425 renderInputType.checkbox = (checkboxContainer, params) => {
3426 const popup = getPopup();
3427 if (!popup) {
3428 throw new Error('Popup not found');
3429 }
3430 const checkbox = getInput$1(popup, 'checkbox');
3431 if (!checkbox) {
3432 throw new Error('Checkbox input not found');
3433 }
3434 checkbox.value = '1';
3435 checkbox.checked = Boolean(params.inputValue);
3436 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3437 const label = containerElement.querySelector('span');
3438 if (label) {
3439 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3440 if (placeholderOrLabel) {
3441 setInnerHtml(label, placeholderOrLabel);
3442 }
3443 }
3444 return checkbox;
3445 };
3446
3447 /**
3448 * @param {Input | HTMLElement} textarea
3449 * @param {SweetAlertOptions} params
3450 * @returns {Input}
3451 */
3452 renderInputType.textarea = (textarea, params) => {
3453 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3454 checkAndSetInputValue(textareaElement, params.inputValue);
3455 setInputPlaceholder(textareaElement, params);
3456 setInputLabel(textareaElement, textareaElement, params);
3457
3458 /**
3459 * @param {HTMLElement} el
3460 * @returns {number}
3461 */
3462 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3463
3464 // https://github.com/sweetalert2/sweetalert2/issues/2291
3465 setTimeout(() => {
3466 // https://github.com/sweetalert2/sweetalert2/issues/1699
3467 if ('MutationObserver' in window) {
3468 const popup = getPopup();
3469 if (!popup) {
3470 return;
3471 }
3472 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3473 const textareaResizeHandler = () => {
3474 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3475 if (!document.body.contains(textareaElement)) {
3476 return;
3477 }
3478 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3479 const popupElement = getPopup();
3480 if (popupElement) {
3481 if (textareaWidth > initialPopupWidth) {
3482 popupElement.style.width = `${textareaWidth}px`;
3483 } else {
3484 applyNumericalStyle(popupElement, 'width', params.width);
3485 }
3486 }
3487 };
3488 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3489 attributes: true,
3490 attributeFilter: ['style']
3491 });
3492 }
3493 });
3494 return textareaElement;
3495 };
3496
3497 /**
3498 * @param {SweetAlert} instance
3499 * @param {SweetAlertOptions} params
3500 */
3501 const renderContent = (instance, params) => {
3502 const htmlContainer = getHtmlContainer();
3503 if (!htmlContainer) {
3504 return;
3505 }
3506 showWhenInnerHtmlPresent(htmlContainer);
3507 applyCustomClass(htmlContainer, params, 'htmlContainer');
3508
3509 // Content as HTML
3510 if (params.html) {
3511 parseHtmlToContainer(params.html, htmlContainer);
3512 show(htmlContainer, 'block');
3513 }
3514
3515 // Content as plain text
3516 else if (params.text) {
3517 htmlContainer.textContent = params.text;
3518 show(htmlContainer, 'block');
3519 }
3520
3521 // No content
3522 else {
3523 hide(htmlContainer);
3524 }
3525 renderInput(instance, params);
3526 };
3527
3528 /**
3529 * @param {SweetAlert} instance
3530 * @param {SweetAlertOptions} params
3531 */
3532 const renderFooter = (instance, params) => {
3533 const footer = getFooter();
3534 if (!footer) {
3535 return;
3536 }
3537 showWhenInnerHtmlPresent(footer);
3538 toggle(footer, Boolean(params.footer), 'block');
3539 if (params.footer) {
3540 parseHtmlToContainer(params.footer, footer);
3541 }
3542
3543 // Custom class
3544 applyCustomClass(footer, params, 'footer');
3545 };
3546
3547 /**
3548 * @param {SweetAlert} instance
3549 * @param {SweetAlertOptions} params
3550 */
3551 const renderIcon = (instance, params) => {
3552 const innerParams = privateProps.innerParams.get(instance);
3553 const icon = getIcon();
3554 if (!icon) {
3555 return;
3556 }
3557
3558 // if the given icon already rendered, apply the styling without re-rendering the icon
3559 if (innerParams && params.icon === innerParams.icon) {
3560 // Custom or default content
3561 setContent(icon, params);
3562 applyStyles(icon, params);
3563 return;
3564 }
3565 if (!params.icon && !params.iconHtml) {
3566 hide(icon);
3567 return;
3568 }
3569 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3570 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3571 hide(icon);
3572 return;
3573 }
3574 show(icon);
3575
3576 // Custom or default content
3577 setContent(icon, params);
3578 applyStyles(icon, params);
3579
3580 // Animate icon
3581 addClass(icon, params.showClass && params.showClass.icon);
3582
3583 // Re-adjust the success icon on system theme change
3584 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3585 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3586 };
3587
3588 /**
3589 * @param {HTMLElement} icon
3590 * @param {SweetAlertOptions} params
3591 */
3592 const applyStyles = (icon, params) => {
3593 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3594 if (params.icon !== iconType) {
3595 removeClass(icon, iconClassName);
3596 }
3597 }
3598 addClass(icon, params.icon && iconTypes[params.icon]);
3599
3600 // Icon color
3601 setColor(icon, params);
3602
3603 // Success icon background color
3604 adjustSuccessIconBackgroundColor();
3605
3606 // Custom class
3607 applyCustomClass(icon, params, 'icon');
3608 };
3609
3610 // Adjust success icon background color to match the popup background color
3611 const adjustSuccessIconBackgroundColor = () => {
3612 const popup = getPopup();
3613 if (!popup) {
3614 return;
3615 }
3616 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3617 /** @type {NodeListOf<HTMLElement>} */
3618 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3619 for (let i = 0; i < successIconParts.length; i++) {
3620 successIconParts[i].style.backgroundColor = popupBackgroundColor;
3621 }
3622 };
3623
3624 /**
3625 *
3626 * @param {SweetAlertOptions} params
3627 * @returns {string}
3628 */
3629 const successIconHtml = params => `
3630 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3631 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3632 <div class="swal2-success-ring"></div>
3633 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3634 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3635 `;
3636 const errorIconHtml = `
3637 <span class="swal2-x-mark">
3638 <span class="swal2-x-mark-line-left"></span>
3639 <span class="swal2-x-mark-line-right"></span>
3640 </span>
3641 `;
3642
3643 /**
3644 * @param {HTMLElement} icon
3645 * @param {SweetAlertOptions} params
3646 */
3647 const setContent = (icon, params) => {
3648 if (!params.icon && !params.iconHtml) {
3649 return;
3650 }
3651 let oldContent = icon.innerHTML;
3652 let newContent = '';
3653 if (params.iconHtml) {
3654 newContent = iconContent(params.iconHtml);
3655 } else if (params.icon === 'success') {
3656 newContent = successIconHtml(params);
3657 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3658 } else if (params.icon === 'error') {
3659 newContent = errorIconHtml;
3660 } else if (params.icon) {
3661 const defaultIconHtml = {
3662 question: '?',
3663 warning: '!',
3664 info: 'i'
3665 };
3666 newContent = iconContent(defaultIconHtml[params.icon]);
3667 }
3668 if (oldContent.trim() !== newContent.trim()) {
3669 setInnerHtml(icon, newContent);
3670 }
3671 };
3672
3673 /**
3674 * @param {HTMLElement} icon
3675 * @param {SweetAlertOptions} params
3676 */
3677 const setColor = (icon, params) => {
3678 if (!params.iconColor) {
3679 return;
3680 }
3681 icon.style.color = params.iconColor;
3682 icon.style.borderColor = params.iconColor;
3683 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3684 setStyle(icon, sel, 'background-color', params.iconColor);
3685 }
3686 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3687 };
3688
3689 /**
3690 * @param {string} content
3691 * @returns {string}
3692 */
3693 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3694
3695 /**
3696 * @param {SweetAlert} instance
3697 * @param {SweetAlertOptions} params
3698 */
3699 const renderImage = (instance, params) => {
3700 const image = getImage();
3701 if (!image) {
3702 return;
3703 }
3704 if (!params.imageUrl) {
3705 hide(image);
3706 return;
3707 }
3708 show(image, '');
3709
3710 // Src, alt
3711 image.setAttribute('src', params.imageUrl);
3712 image.setAttribute('alt', params.imageAlt || '');
3713
3714 // Width, height
3715 applyNumericalStyle(image, 'width', params.imageWidth);
3716 applyNumericalStyle(image, 'height', params.imageHeight);
3717
3718 // Class
3719 image.className = swalClasses.image;
3720 applyCustomClass(image, params, 'image');
3721 };
3722
3723 let dragging = false;
3724 let mousedownX = 0;
3725 let mousedownY = 0;
3726 let initialX = 0;
3727 let initialY = 0;
3728
3729 /**
3730 * @param {HTMLElement} popup
3731 */
3732 const addDraggableListeners = popup => {
3733 popup.addEventListener('mousedown', down);
3734 document.body.addEventListener('mousemove', move);
3735 popup.addEventListener('mouseup', up);
3736 popup.addEventListener('touchstart', down);
3737 document.body.addEventListener('touchmove', move);
3738 popup.addEventListener('touchend', up);
3739 };
3740
3741 /**
3742 * @param {HTMLElement} popup
3743 */
3744 const removeDraggableListeners = popup => {
3745 popup.removeEventListener('mousedown', down);
3746 document.body.removeEventListener('mousemove', move);
3747 popup.removeEventListener('mouseup', up);
3748 popup.removeEventListener('touchstart', down);
3749 document.body.removeEventListener('touchmove', move);
3750 popup.removeEventListener('touchend', up);
3751 };
3752
3753 /**
3754 * @param {MouseEvent | TouchEvent} event
3755 */
3756 const down = event => {
3757 const popup = getPopup();
3758 if (!popup) {
3759 return;
3760 }
3761 const icon = getIcon();
3762 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3763 dragging = true;
3764 const clientXY = getClientXY(event);
3765 mousedownX = clientXY.clientX;
3766 mousedownY = clientXY.clientY;
3767 initialX = parseInt(popup.style.insetInlineStart) || 0;
3768 initialY = parseInt(popup.style.insetBlockStart) || 0;
3769 addClass(popup, 'swal2-dragging');
3770 }
3771 };
3772
3773 /**
3774 * @param {MouseEvent | TouchEvent} event
3775 */
3776 const move = event => {
3777 const popup = getPopup();
3778 if (!popup) {
3779 return;
3780 }
3781 if (dragging) {
3782 let {
3783 clientX,
3784 clientY
3785 } = getClientXY(event);
3786 const deltaX = clientX - mousedownX;
3787 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3788 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3789 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3790 }
3791 };
3792 const up = () => {
3793 const popup = getPopup();
3794 dragging = false;
3795 removeClass(popup, 'swal2-dragging');
3796 };
3797
3798 /**
3799 * @param {MouseEvent | TouchEvent} event
3800 * @returns {{ clientX: number, clientY: number }}
3801 */
3802 const getClientXY = event => {
3803 let clientX = 0,
3804 clientY = 0;
3805 if (event.type.startsWith('mouse')) {
3806 clientX = /** @type {MouseEvent} */event.clientX;
3807 clientY = /** @type {MouseEvent} */event.clientY;
3808 } else if (event.type.startsWith('touch')) {
3809 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
3810 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
3811 }
3812 return {
3813 clientX,
3814 clientY
3815 };
3816 };
3817
3818 /**
3819 * @param {SweetAlert} instance
3820 * @param {SweetAlertOptions} params
3821 */
3822 const renderPopup = (instance, params) => {
3823 const container = getContainer();
3824 const popup = getPopup();
3825 if (!container || !popup) {
3826 return;
3827 }
3828
3829 // Width
3830 // https://github.com/sweetalert2/sweetalert2/issues/2170
3831 if (params.toast) {
3832 applyNumericalStyle(container, 'width', params.width);
3833 popup.style.width = '100%';
3834 const loader = getLoader();
3835 if (loader) {
3836 popup.insertBefore(loader, getIcon());
3837 }
3838 } else {
3839 applyNumericalStyle(popup, 'width', params.width);
3840 }
3841
3842 // Padding
3843 applyNumericalStyle(popup, 'padding', params.padding);
3844
3845 // Color
3846 if (params.color) {
3847 popup.style.color = params.color;
3848 }
3849
3850 // Background
3851 if (params.background) {
3852 popup.style.background = params.background;
3853 }
3854 hide(getValidationMessage());
3855
3856 // Classes
3857 addClasses$1(popup, params);
3858 if (params.draggable && !params.toast) {
3859 addClass(popup, swalClasses.draggable);
3860 addDraggableListeners(popup);
3861 } else {
3862 removeClass(popup, swalClasses.draggable);
3863 removeDraggableListeners(popup);
3864 }
3865 };
3866
3867 /**
3868 * @param {HTMLElement} popup
3869 * @param {SweetAlertOptions} params
3870 */
3871 const addClasses$1 = (popup, params) => {
3872 const showClass = params.showClass || {};
3873 // Default Class + showClass when updating Swal.update({})
3874 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3875 if (params.toast) {
3876 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3877 addClass(popup, swalClasses.toast);
3878 } else {
3879 addClass(popup, swalClasses.modal);
3880 }
3881
3882 // Custom class
3883 applyCustomClass(popup, params, 'popup');
3884 // TODO: remove in the next major
3885 if (typeof params.customClass === 'string') {
3886 addClass(popup, params.customClass);
3887 }
3888
3889 // Icon class (#1842)
3890 if (params.icon) {
3891 addClass(popup, swalClasses[`icon-${params.icon}`]);
3892 }
3893 };
3894
3895 /**
3896 * @param {SweetAlert} instance
3897 * @param {SweetAlertOptions} params
3898 */
3899 const renderProgressSteps = (instance, params) => {
3900 const progressStepsContainer = getProgressSteps();
3901 if (!progressStepsContainer) {
3902 return;
3903 }
3904 const {
3905 progressSteps,
3906 currentProgressStep
3907 } = params;
3908 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3909 hide(progressStepsContainer);
3910 return;
3911 }
3912 show(progressStepsContainer);
3913 progressStepsContainer.textContent = '';
3914 if (currentProgressStep >= progressSteps.length) {
3915 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3916 }
3917 progressSteps.forEach((step, index) => {
3918 const stepEl = createStepElement(step);
3919 progressStepsContainer.appendChild(stepEl);
3920 if (index === currentProgressStep) {
3921 addClass(stepEl, swalClasses['active-progress-step']);
3922 }
3923 if (index !== progressSteps.length - 1) {
3924 const lineEl = createLineElement(params);
3925 progressStepsContainer.appendChild(lineEl);
3926 }
3927 });
3928 };
3929
3930 /**
3931 * @param {string} step
3932 * @returns {HTMLLIElement}
3933 */
3934 const createStepElement = step => {
3935 const stepEl = document.createElement('li');
3936 addClass(stepEl, swalClasses['progress-step']);
3937 setInnerHtml(stepEl, step);
3938 return stepEl;
3939 };
3940
3941 /**
3942 * @param {SweetAlertOptions} params
3943 * @returns {HTMLLIElement}
3944 */
3945 const createLineElement = params => {
3946 const lineEl = document.createElement('li');
3947 addClass(lineEl, swalClasses['progress-step-line']);
3948 if (params.progressStepsDistance) {
3949 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3950 }
3951 return lineEl;
3952 };
3953
3954 /**
3955 * @param {SweetAlert} instance
3956 * @param {SweetAlertOptions} params
3957 */
3958 const renderTitle = (instance, params) => {
3959 const title = getTitle();
3960 if (!title) {
3961 return;
3962 }
3963 showWhenInnerHtmlPresent(title);
3964 toggle(title, Boolean(params.title || params.titleText), 'block');
3965 if (params.title) {
3966 parseHtmlToContainer(params.title, title);
3967 }
3968 if (params.titleText) {
3969 title.innerText = params.titleText;
3970 }
3971
3972 // Custom class
3973 applyCustomClass(title, params, 'title');
3974 };
3975
3976 /**
3977 * @param {SweetAlert} instance
3978 * @param {SweetAlertOptions} params
3979 */
3980 const render = (instance, params) => {
3981 var _globalState$eventEmi;
3982 renderPopup(instance, params);
3983 renderContainer(instance, params);
3984 renderProgressSteps(instance, params);
3985 renderIcon(instance, params);
3986 renderImage(instance, params);
3987 renderTitle(instance, params);
3988 renderCloseButton(instance, params);
3989 renderContent(instance, params);
3990 renderActions(instance, params);
3991 renderFooter(instance, params);
3992 const popup = getPopup();
3993 if (typeof params.didRender === 'function' && popup) {
3994 params.didRender(popup);
3995 }
3996 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3997 };
3998
3999 /*
4000 * Global function to determine if SweetAlert2 popup is shown
4001 */
4002 const isVisible = () => {
4003 return isVisible$1(getPopup());
4004 };
4005
4006 /*
4007 * Global function to click 'Confirm' button
4008 */
4009 const clickConfirm = () => {
4010 var _dom$getConfirmButton;
4011 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
4012 };
4013
4014 /*
4015 * Global function to click 'Deny' button
4016 */
4017 const clickDeny = () => {
4018 var _dom$getDenyButton;
4019 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
4020 };
4021
4022 /*
4023 * Global function to click 'Cancel' button
4024 */
4025 const clickCancel = () => {
4026 var _dom$getCancelButton;
4027 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4028 };
4029
4030 /** @type {Record<DismissReason, DismissReason>} */
4031 const DismissReason = Object.freeze({
4032 cancel: 'cancel',
4033 backdrop: 'backdrop',
4034 close: 'close',
4035 esc: 'esc',
4036 timer: 'timer'
4037 });
4038
4039 /**
4040 * @param {GlobalState} globalState
4041 */
4042 const removeKeydownHandler = globalState => {
4043 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4044 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
4045 globalState.keydownTarget.removeEventListener('keydown', handler, {
4046 capture: globalState.keydownListenerCapture
4047 });
4048 globalState.keydownHandlerAdded = false;
4049 }
4050 };
4051
4052 /**
4053 * @param {GlobalState} globalState
4054 * @param {SweetAlertOptions} innerParams
4055 * @param {(dismiss: DismissReason) => void} dismissWith
4056 */
4057 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4058 removeKeydownHandler(globalState);
4059 if (!innerParams.toast) {
4060 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4061 const handler = e => keydownHandler(innerParams, e, dismissWith);
4062 globalState.keydownHandler = handler;
4063 const target = innerParams.keydownListenerCapture ? window : getPopup();
4064 if (target) {
4065 globalState.keydownTarget = target;
4066 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4067 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4068 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4069 capture: globalState.keydownListenerCapture
4070 });
4071 globalState.keydownHandlerAdded = true;
4072 }
4073 }
4074 };
4075
4076 /**
4077 * @param {number} index
4078 * @param {number} increment
4079 */
4080 const setFocus = (index, increment) => {
4081 var _dom$getPopup;
4082 const focusableElements = getFocusableElements();
4083 // search for visible elements and select the next possible match
4084 if (focusableElements.length) {
4085 index = index + increment;
4086
4087 // shift + tab when .swal2-popup is focused
4088 if (index === -2) {
4089 index = focusableElements.length - 1;
4090 }
4091
4092 // rollover to first item
4093 if (index === focusableElements.length) {
4094 index = 0;
4095
4096 // go to last item
4097 } else if (index === -1) {
4098 index = focusableElements.length - 1;
4099 }
4100 focusableElements[index].focus();
4101 return;
4102 }
4103 // no visible focusable elements, focus the popup
4104 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4105 };
4106 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4107 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4108
4109 /**
4110 * @param {SweetAlertOptions} innerParams
4111 * @param {KeyboardEvent} event
4112 * @param {(dismiss: DismissReason) => void} dismissWith
4113 */
4114 const keydownHandler = (innerParams, event, dismissWith) => {
4115 if (!innerParams) {
4116 return; // This instance has already been destroyed
4117 }
4118
4119 // Ignore keydown during IME composition
4120 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4121 // https://github.com/sweetalert2/sweetalert2/issues/720
4122 // https://github.com/sweetalert2/sweetalert2/issues/2406
4123 if (event.isComposing || event.keyCode === 229) {
4124 return;
4125 }
4126 if (innerParams.stopKeydownPropagation) {
4127 event.stopPropagation();
4128 }
4129
4130 // ENTER
4131 if (event.key === 'Enter') {
4132 handleEnter(event, innerParams);
4133 }
4134
4135 // TAB
4136 else if (event.key === 'Tab') {
4137 handleTab(event);
4138 }
4139
4140 // ARROWS - switch focus between buttons
4141 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4142 handleArrows(event.key);
4143 }
4144
4145 // ESC
4146 else if (event.key === 'Escape') {
4147 handleEsc(event, innerParams, dismissWith);
4148 }
4149 };
4150
4151 /**
4152 * @param {KeyboardEvent} event
4153 * @param {SweetAlertOptions} innerParams
4154 */
4155 const handleEnter = (event, innerParams) => {
4156 // https://github.com/sweetalert2/sweetalert2/issues/2386
4157 if (!callIfFunction(innerParams.allowEnterKey)) {
4158 return;
4159 }
4160 const popup = getPopup();
4161 if (!popup || !innerParams.input) {
4162 return;
4163 }
4164 const input = getInput$1(popup, innerParams.input);
4165 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4166 if (['textarea', 'file'].includes(innerParams.input)) {
4167 return; // do not submit
4168 }
4169 clickConfirm();
4170 event.preventDefault();
4171 }
4172 };
4173
4174 /**
4175 * @param {KeyboardEvent} event
4176 */
4177 const handleTab = event => {
4178 const targetElement = event.target;
4179 const focusableElements = getFocusableElements();
4180 let btnIndex = -1;
4181 for (let i = 0; i < focusableElements.length; i++) {
4182 if (targetElement === focusableElements[i]) {
4183 btnIndex = i;
4184 break;
4185 }
4186 }
4187
4188 // Cycle to the next button
4189 if (!event.shiftKey) {
4190 setFocus(btnIndex, 1);
4191 }
4192
4193 // Cycle to the prev button
4194 else {
4195 setFocus(btnIndex, -1);
4196 }
4197 event.stopPropagation();
4198 event.preventDefault();
4199 };
4200
4201 /**
4202 * @param {string} key
4203 */
4204 const handleArrows = key => {
4205 const actions = getActions();
4206 const confirmButton = getConfirmButton();
4207 const denyButton = getDenyButton();
4208 const cancelButton = getCancelButton();
4209 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4210 return;
4211 }
4212 /** @type HTMLElement[] */
4213 const buttons = [confirmButton, denyButton, cancelButton];
4214 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4215 return;
4216 }
4217 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4218 let buttonToFocus = document.activeElement;
4219 if (!buttonToFocus) {
4220 return;
4221 }
4222 for (let i = 0; i < actions.children.length; i++) {
4223 buttonToFocus = buttonToFocus[sibling];
4224 if (!buttonToFocus) {
4225 return;
4226 }
4227 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4228 break;
4229 }
4230 }
4231 if (buttonToFocus instanceof HTMLButtonElement) {
4232 buttonToFocus.focus();
4233 }
4234 };
4235
4236 /**
4237 * @param {KeyboardEvent} event
4238 * @param {SweetAlertOptions} innerParams
4239 * @param {(dismiss: DismissReason) => void} dismissWith
4240 */
4241 const handleEsc = (event, innerParams, dismissWith) => {
4242 event.preventDefault();
4243 if (callIfFunction(innerParams.allowEscapeKey)) {
4244 dismissWith(DismissReason.esc);
4245 }
4246 };
4247
4248 /**
4249 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4250 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4251 * This is the approach that Babel will probably take to implement private methods/fields
4252 * https://github.com/tc39/proposal-private-methods
4253 * https://github.com/babel/babel/pull/7555
4254 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4255 * then we can use that language feature.
4256 */
4257
4258 var privateMethods = {
4259 swalPromiseResolve: new WeakMap(),
4260 swalPromiseReject: new WeakMap()
4261 };
4262
4263 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4264 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4265 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4266 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4267
4268 const setAriaHidden = () => {
4269 const container = getContainer();
4270 const bodyChildren = Array.from(document.body.children);
4271 bodyChildren.forEach(el => {
4272 if (el.contains(container)) {
4273 return;
4274 }
4275 if (el.hasAttribute('aria-hidden')) {
4276 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4277 }
4278 el.setAttribute('aria-hidden', 'true');
4279 });
4280 };
4281 const unsetAriaHidden = () => {
4282 const bodyChildren = Array.from(document.body.children);
4283 bodyChildren.forEach(el => {
4284 if (el.hasAttribute('data-previous-aria-hidden')) {
4285 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4286 el.removeAttribute('data-previous-aria-hidden');
4287 } else {
4288 el.removeAttribute('aria-hidden');
4289 }
4290 });
4291 };
4292
4293 // @ts-ignore
4294 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4295
4296 /**
4297 * Fix iOS scrolling
4298 * http://stackoverflow.com/q/39626302
4299 */
4300 const iOSfix = () => {
4301 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4302 const offset = document.body.scrollTop;
4303 document.body.style.top = `${offset * -1}px`;
4304 addClass(document.body, swalClasses.iosfix);
4305 lockBodyScroll();
4306 }
4307 };
4308
4309 /**
4310 * https://github.com/sweetalert2/sweetalert2/issues/1246
4311 */
4312 const lockBodyScroll = () => {
4313 const container = getContainer();
4314 if (!container) {
4315 return;
4316 }
4317 /** @type {boolean} */
4318 let preventTouchMove;
4319 /**
4320 * @param {TouchEvent} event
4321 */
4322 container.ontouchstart = event => {
4323 preventTouchMove = shouldPreventTouchMove(event);
4324 };
4325 /**
4326 * @param {TouchEvent} event
4327 */
4328 container.ontouchmove = event => {
4329 if (preventTouchMove) {
4330 event.preventDefault();
4331 event.stopPropagation();
4332 }
4333 };
4334 };
4335
4336 /**
4337 * @param {TouchEvent} event
4338 * @returns {boolean}
4339 */
4340 const shouldPreventTouchMove = event => {
4341 const target = event.target;
4342 const container = getContainer();
4343 const htmlContainer = getHtmlContainer();
4344 if (!container || !htmlContainer) {
4345 return false;
4346 }
4347 if (isStylus(event) || isZoom(event)) {
4348 return false;
4349 }
4350 if (target === container) {
4351 return true;
4352 }
4353 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4354 // #2823
4355 target.tagName !== 'INPUT' &&
4356 // #1603
4357 target.tagName !== 'TEXTAREA' &&
4358 // #2266
4359 !(isScrollable(htmlContainer) &&
4360 // #1944
4361 htmlContainer.contains(target))) {
4362 return true;
4363 }
4364 return false;
4365 };
4366
4367 /**
4368 * https://github.com/sweetalert2/sweetalert2/issues/1786
4369 *
4370 * @param {TouchEvent} event
4371 * @returns {boolean}
4372 */
4373 const isStylus = event => {
4374 return Boolean(event.touches && event.touches.length &&
4375 // @ts-ignore - touchType is not a standard property
4376 event.touches[0].touchType === 'stylus');
4377 };
4378
4379 /**
4380 * https://github.com/sweetalert2/sweetalert2/issues/1891
4381 *
4382 * @param {TouchEvent} event
4383 * @returns {boolean}
4384 */
4385 const isZoom = event => {
4386 return event.touches && event.touches.length > 1;
4387 };
4388 const undoIOSfix = () => {
4389 if (hasClass(document.body, swalClasses.iosfix)) {
4390 const offset = parseInt(document.body.style.top, 10);
4391 removeClass(document.body, swalClasses.iosfix);
4392 document.body.style.top = '';
4393 document.body.scrollTop = offset * -1;
4394 }
4395 };
4396
4397 /**
4398 * Measure scrollbar width for padding body during modal show/hide
4399 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4400 *
4401 * @returns {number}
4402 */
4403 const measureScrollbar = () => {
4404 const scrollDiv = document.createElement('div');
4405 scrollDiv.className = swalClasses['scrollbar-measure'];
4406 document.body.appendChild(scrollDiv);
4407 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4408 document.body.removeChild(scrollDiv);
4409 return scrollbarWidth;
4410 };
4411
4412 /**
4413 * Remember state in cases where opening and handling a modal will fiddle with it.
4414 * @type {number | null}
4415 */
4416 let previousBodyPadding = null;
4417
4418 /**
4419 * @param {string} initialBodyOverflow
4420 */
4421 const replaceScrollbarWithPadding = initialBodyOverflow => {
4422 // for queues, do not do this more than once
4423 if (previousBodyPadding !== null) {
4424 return;
4425 }
4426 // if the body has overflow
4427 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4428 ) {
4429 // add padding so the content doesn't shift after removal of scrollbar
4430 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4431 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4432 }
4433 };
4434 const undoReplaceScrollbarWithPadding = () => {
4435 if (previousBodyPadding !== null) {
4436 document.body.style.paddingRight = `${previousBodyPadding}px`;
4437 previousBodyPadding = null;
4438 }
4439 };
4440
4441 /**
4442 * @param {SweetAlert} instance
4443 * @param {HTMLElement} container
4444 * @param {boolean} returnFocus
4445 * @param {(() => void) | undefined} didClose
4446 */
4447 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4448 if (isToast()) {
4449 triggerDidCloseAndDispose(instance, didClose);
4450 } else {
4451 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4452 removeKeydownHandler(globalState);
4453 }
4454
4455 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4456 // for some reason removing the container in Safari will scroll the document to bottom
4457 if (isSafariOrIOS) {
4458 container.setAttribute('style', 'display:none !important');
4459 container.removeAttribute('class');
4460 container.innerHTML = '';
4461 } else {
4462 container.remove();
4463 }
4464 if (isModal()) {
4465 undoReplaceScrollbarWithPadding();
4466 undoIOSfix();
4467 unsetAriaHidden();
4468 }
4469 removeBodyClasses();
4470 }
4471
4472 /**
4473 * Remove SweetAlert2 classes from body
4474 */
4475 function removeBodyClasses() {
4476 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4477 }
4478
4479 /**
4480 * Instance method to close sweetAlert
4481 *
4482 * @param {SweetAlertResult | undefined} resolveValue
4483 * @this {SweetAlert}
4484 */
4485 function close(resolveValue) {
4486 resolveValue = prepareResolveValue(resolveValue);
4487 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4488 const didClose = triggerClosePopup(this);
4489 if (this.isAwaitingPromise) {
4490 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4491 if (!resolveValue.isDismissed) {
4492 handleAwaitingPromise(this);
4493 swalPromiseResolve(resolveValue);
4494 }
4495 } else if (didClose) {
4496 // Resolve Swal promise
4497 swalPromiseResolve(resolveValue);
4498 }
4499 }
4500
4501 /**
4502 * @param {SweetAlert} instance
4503 * @returns {boolean}
4504 */
4505 const triggerClosePopup = instance => {
4506 const popup = getPopup();
4507 if (!popup) {
4508 return false;
4509 }
4510 const innerParams = privateProps.innerParams.get(instance);
4511 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4512 return false;
4513 }
4514 removeClass(popup, innerParams.showClass.popup);
4515 addClass(popup, innerParams.hideClass.popup);
4516 const backdrop = getContainer();
4517 removeClass(backdrop, innerParams.showClass.backdrop);
4518 addClass(backdrop, innerParams.hideClass.backdrop);
4519 handlePopupAnimation(instance, popup, innerParams);
4520 return true;
4521 };
4522
4523 /**
4524 * @param {Error | string} error
4525 * @this {SweetAlert}
4526 */
4527 function rejectPromise(error) {
4528 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4529 handleAwaitingPromise(this);
4530 if (rejectPromise) {
4531 // Reject Swal promise
4532 rejectPromise(error);
4533 }
4534 }
4535
4536 /**
4537 * @param {SweetAlert} instance
4538 */
4539 const handleAwaitingPromise = instance => {
4540 if (instance.isAwaitingPromise) {
4541 // @ts-ignore
4542 delete instance.isAwaitingPromise;
4543 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4544 if (!privateProps.innerParams.get(instance)) {
4545 instance._destroy();
4546 }
4547 }
4548 };
4549
4550 /**
4551 * @param {SweetAlertResult | undefined} resolveValue
4552 * @returns {SweetAlertResult}
4553 */
4554 const prepareResolveValue = resolveValue => {
4555 // When user calls Swal.close()
4556 if (typeof resolveValue === 'undefined') {
4557 return {
4558 isConfirmed: false,
4559 isDenied: false,
4560 isDismissed: true
4561 };
4562 }
4563 return Object.assign({
4564 isConfirmed: false,
4565 isDenied: false,
4566 isDismissed: false
4567 }, resolveValue);
4568 };
4569
4570 /**
4571 * @param {SweetAlert} instance
4572 * @param {HTMLElement} popup
4573 * @param {SweetAlertOptions} innerParams
4574 */
4575 const handlePopupAnimation = (instance, popup, innerParams) => {
4576 var _globalState$eventEmi;
4577 const container = getContainer();
4578 // If animation is supported, animate
4579 const animationIsSupported = hasCssAnimation(popup);
4580 if (typeof innerParams.willClose === 'function') {
4581 innerParams.willClose(popup);
4582 }
4583 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4584 if (animationIsSupported && container) {
4585 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4586 } else if (container) {
4587 // Otherwise, remove immediately
4588 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4589 }
4590 };
4591
4592 /**
4593 * @param {SweetAlert} instance
4594 * @param {HTMLElement} popup
4595 * @param {HTMLElement} container
4596 * @param {boolean} returnFocus
4597 * @param {(() => void) | undefined} didClose
4598 */
4599 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4600 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4601 /**
4602 * @param {AnimationEvent | TransitionEvent} e
4603 */
4604 const swalCloseAnimationFinished = function (e) {
4605 if (e.target === popup) {
4606 var _globalState$swalClos;
4607 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4608 delete globalState.swalCloseEventFinishedCallback;
4609 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4610 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4611 }
4612 };
4613 popup.addEventListener('animationend', swalCloseAnimationFinished);
4614 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4615 };
4616
4617 /**
4618 * @param {SweetAlert} instance
4619 * @param {(() => void) | undefined} didClose
4620 */
4621 const triggerDidCloseAndDispose = (instance, didClose) => {
4622 setTimeout(() => {
4623 var _globalState$eventEmi2;
4624 if (typeof didClose === 'function') {
4625 didClose.bind(instance.params)();
4626 }
4627 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4628 // instance might have been destroyed already
4629 if (instance._destroy) {
4630 instance._destroy();
4631 }
4632 });
4633 };
4634
4635 /**
4636 * Shows loader (spinner), this is useful with AJAX requests.
4637 * By default the loader be shown instead of the "Confirm" button.
4638 *
4639 * @param {HTMLButtonElement | null} [buttonToReplace]
4640 */
4641 const showLoading = buttonToReplace => {
4642 let popup = getPopup();
4643 if (!popup) {
4644 new Swal();
4645 }
4646 popup = getPopup();
4647 if (!popup) {
4648 return;
4649 }
4650 const loader = getLoader();
4651 if (isToast()) {
4652 hide(getIcon());
4653 } else {
4654 replaceButton(popup, buttonToReplace);
4655 }
4656 show(loader);
4657 popup.setAttribute('data-loading', 'true');
4658 popup.setAttribute('aria-busy', 'true');
4659 popup.focus();
4660 };
4661
4662 /**
4663 * @param {HTMLElement} popup
4664 * @param {HTMLButtonElement | null} [buttonToReplace]
4665 */
4666 const replaceButton = (popup, buttonToReplace) => {
4667 const actions = getActions();
4668 const loader = getLoader();
4669 if (!actions || !loader) {
4670 return;
4671 }
4672 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4673 buttonToReplace = getConfirmButton();
4674 }
4675 show(actions);
4676 if (buttonToReplace) {
4677 hide(buttonToReplace);
4678 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4679 actions.insertBefore(loader, buttonToReplace);
4680 }
4681 addClass([popup, actions], swalClasses.loading);
4682 };
4683
4684 /**
4685 * @param {SweetAlert} instance
4686 * @param {SweetAlertOptions} params
4687 */
4688 const handleInputOptionsAndValue = (instance, params) => {
4689 if (params.input === 'select' || params.input === 'radio') {
4690 handleInputOptions(instance, params);
4691 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4692 showLoading(getConfirmButton());
4693 handleInputValue(instance, params);
4694 }
4695 };
4696
4697 /**
4698 * @param {SweetAlert} instance
4699 * @param {SweetAlertOptions} innerParams
4700 * @returns {SweetAlertInputValue}
4701 */
4702 const getInputValue = (instance, innerParams) => {
4703 const input = instance.getInput();
4704 if (!input) {
4705 return null;
4706 }
4707 switch (innerParams.input) {
4708 case 'checkbox':
4709 return getCheckboxValue(input);
4710 case 'radio':
4711 return getRadioValue(input);
4712 case 'file':
4713 return getFileValue(input);
4714 default:
4715 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4716 }
4717 };
4718
4719 /**
4720 * @param {HTMLInputElement} input
4721 * @returns {number}
4722 */
4723 const getCheckboxValue = input => input.checked ? 1 : 0;
4724
4725 /**
4726 * @param {HTMLInputElement} input
4727 * @returns {string | null}
4728 */
4729 const getRadioValue = input => input.checked ? input.value : null;
4730
4731 /**
4732 * @param {HTMLInputElement} input
4733 * @returns {FileList | File | null}
4734 */
4735 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4736
4737 /**
4738 * @param {SweetAlert} instance
4739 * @param {SweetAlertOptions} params
4740 */
4741 const handleInputOptions = (instance, params) => {
4742 const popup = getPopup();
4743 if (!popup) {
4744 return;
4745 }
4746 /**
4747 * @param {*} inputOptions
4748 */
4749 const processInputOptions = inputOptions => {
4750 if (params.input === 'select') {
4751 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4752 } else if (params.input === 'radio') {
4753 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4754 }
4755 };
4756 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4757 showLoading(getConfirmButton());
4758 asPromise(params.inputOptions).then(inputOptions => {
4759 instance.hideLoading();
4760 processInputOptions(inputOptions);
4761 });
4762 } else if (typeof params.inputOptions === 'object') {
4763 processInputOptions(params.inputOptions);
4764 } else {
4765 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4766 }
4767 };
4768
4769 /**
4770 * @param {SweetAlert} instance
4771 * @param {SweetAlertOptions} params
4772 */
4773 const handleInputValue = (instance, params) => {
4774 const input = instance.getInput();
4775 if (!input) {
4776 return;
4777 }
4778 hide(input);
4779 asPromise(params.inputValue).then(inputValue => {
4780 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4781 show(input);
4782 input.focus();
4783 instance.hideLoading();
4784 }).catch(err => {
4785 error(`Error in inputValue promise: ${err}`);
4786 input.value = '';
4787 show(input);
4788 input.focus();
4789 instance.hideLoading();
4790 });
4791 };
4792
4793 /**
4794 * @param {HTMLElement} popup
4795 * @param {InputOptionFlattened[]} inputOptions
4796 * @param {SweetAlertOptions} params
4797 */
4798 function populateSelectOptions(popup, inputOptions, params) {
4799 const select = getDirectChildByClass(popup, swalClasses.select);
4800 if (!select) {
4801 return;
4802 }
4803 /**
4804 * @param {HTMLElement} parent
4805 * @param {string} optionLabel
4806 * @param {string} optionValue
4807 */
4808 const renderOption = (parent, optionLabel, optionValue) => {
4809 const option = document.createElement('option');
4810 option.value = optionValue;
4811 setInnerHtml(option, optionLabel);
4812 option.selected = isSelected(optionValue, params.inputValue);
4813 parent.appendChild(option);
4814 };
4815 inputOptions.forEach(inputOption => {
4816 const optionValue = inputOption[0];
4817 const optionLabel = inputOption[1];
4818 // <optgroup> spec:
4819 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4820 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4821 // check whether this is a <optgroup>
4822 if (Array.isArray(optionLabel)) {
4823 // if it is an array, then it is an <optgroup>
4824 const optgroup = document.createElement('optgroup');
4825 optgroup.label = optionValue;
4826 optgroup.disabled = false; // not configurable for now
4827 select.appendChild(optgroup);
4828 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4829 } else {
4830 // case of <option>
4831 renderOption(select, optionLabel, optionValue);
4832 }
4833 });
4834 select.focus();
4835 }
4836
4837 /**
4838 * @param {HTMLElement} popup
4839 * @param {InputOptionFlattened[]} inputOptions
4840 * @param {SweetAlertOptions} params
4841 */
4842 function populateRadioOptions(popup, inputOptions, params) {
4843 const radio = getDirectChildByClass(popup, swalClasses.radio);
4844 if (!radio) {
4845 return;
4846 }
4847 inputOptions.forEach(inputOption => {
4848 const radioValue = inputOption[0];
4849 const radioLabel = inputOption[1];
4850 const radioInput = document.createElement('input');
4851 const radioLabelElement = document.createElement('label');
4852 radioInput.type = 'radio';
4853 radioInput.name = swalClasses.radio;
4854 radioInput.value = radioValue;
4855 if (isSelected(radioValue, params.inputValue)) {
4856 radioInput.checked = true;
4857 }
4858 const label = document.createElement('span');
4859 setInnerHtml(label, radioLabel);
4860 label.className = swalClasses.label;
4861 radioLabelElement.appendChild(radioInput);
4862 radioLabelElement.appendChild(label);
4863 radio.appendChild(radioLabelElement);
4864 });
4865 const radios = radio.querySelectorAll('input');
4866 if (radios.length) {
4867 radios[0].focus();
4868 }
4869 }
4870
4871 /**
4872 * Converts `inputOptions` into an array of `[value, label]`s
4873 *
4874 * @param {*} inputOptions
4875 * @typedef {string[]} InputOptionFlattened
4876 * @returns {InputOptionFlattened[]}
4877 */
4878 const formatInputOptions = inputOptions => {
4879 /** @type {InputOptionFlattened[]} */
4880 const result = [];
4881 if (inputOptions instanceof Map) {
4882 inputOptions.forEach((value, key) => {
4883 let valueFormatted = value;
4884 if (typeof valueFormatted === 'object') {
4885 // case of <optgroup>
4886 valueFormatted = formatInputOptions(valueFormatted);
4887 }
4888 result.push([key, valueFormatted]);
4889 });
4890 } else {
4891 Object.keys(inputOptions).forEach(key => {
4892 let valueFormatted = inputOptions[key];
4893 if (typeof valueFormatted === 'object') {
4894 // case of <optgroup>
4895 valueFormatted = formatInputOptions(valueFormatted);
4896 }
4897 result.push([key, valueFormatted]);
4898 });
4899 }
4900 return result;
4901 };
4902
4903 /**
4904 * @param {string} optionValue
4905 * @param {SweetAlertInputValue} inputValue
4906 * @returns {boolean}
4907 */
4908 const isSelected = (optionValue, inputValue) => {
4909 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
4910 };
4911
4912 /**
4913 * @param {SweetAlert} instance
4914 */
4915 const handleConfirmButtonClick = instance => {
4916 const innerParams = privateProps.innerParams.get(instance);
4917 instance.disableButtons();
4918 if (innerParams.input) {
4919 handleConfirmOrDenyWithInput(instance, 'confirm');
4920 } else {
4921 confirm(instance, true);
4922 }
4923 };
4924
4925 /**
4926 * @param {SweetAlert} instance
4927 */
4928 const handleDenyButtonClick = instance => {
4929 const innerParams = privateProps.innerParams.get(instance);
4930 instance.disableButtons();
4931 if (innerParams.returnInputValueOnDeny) {
4932 handleConfirmOrDenyWithInput(instance, 'deny');
4933 } else {
4934 deny(instance, false);
4935 }
4936 };
4937
4938 /**
4939 * @param {SweetAlert} instance
4940 * @param {(dismiss: DismissReason) => void} dismissWith
4941 */
4942 const handleCancelButtonClick = (instance, dismissWith) => {
4943 instance.disableButtons();
4944 dismissWith(DismissReason.cancel);
4945 };
4946
4947 /**
4948 * @param {SweetAlert} instance
4949 * @param {'confirm' | 'deny'} type
4950 */
4951 const handleConfirmOrDenyWithInput = (instance, type) => {
4952 const innerParams = privateProps.innerParams.get(instance);
4953 if (!innerParams.input) {
4954 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4955 return;
4956 }
4957 const input = instance.getInput();
4958 const inputValue = getInputValue(instance, innerParams);
4959 if (innerParams.inputValidator) {
4960 handleInputValidator(instance, inputValue, type);
4961 } else if (input && !input.checkValidity()) {
4962 instance.enableButtons();
4963 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4964 } else if (type === 'deny') {
4965 deny(instance, inputValue);
4966 } else {
4967 confirm(instance, inputValue);
4968 }
4969 };
4970
4971 /**
4972 * @param {SweetAlert} instance
4973 * @param {SweetAlertInputValue} inputValue
4974 * @param {'confirm' | 'deny'} type
4975 */
4976 const handleInputValidator = (instance, inputValue, type) => {
4977 const innerParams = privateProps.innerParams.get(instance);
4978 instance.disableInput();
4979 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4980 validationPromise.then(validationMessage => {
4981 instance.enableButtons();
4982 instance.enableInput();
4983 if (validationMessage) {
4984 instance.showValidationMessage(validationMessage);
4985 } else if (type === 'deny') {
4986 deny(instance, inputValue);
4987 } else {
4988 confirm(instance, inputValue);
4989 }
4990 });
4991 };
4992
4993 /**
4994 * @param {SweetAlert} instance
4995 * @param {*} value
4996 */
4997 const deny = (instance, value) => {
4998 const innerParams = privateProps.innerParams.get(instance);
4999 if (innerParams.showLoaderOnDeny) {
5000 showLoading(getDenyButton());
5001 }
5002 if (innerParams.preDeny) {
5003 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
5004 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
5005 preDenyPromise.then(preDenyValue => {
5006 if (preDenyValue === false) {
5007 instance.hideLoading();
5008 handleAwaitingPromise(instance);
5009 } else {
5010 instance.close(/** @type SweetAlertResult */{
5011 isDenied: true,
5012 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
5013 });
5014 }
5015 }).catch(error => rejectWith(instance, error));
5016 } else {
5017 instance.close(/** @type SweetAlertResult */{
5018 isDenied: true,
5019 value
5020 });
5021 }
5022 };
5023
5024 /**
5025 * @param {SweetAlert} instance
5026 * @param {*} value
5027 */
5028 const succeedWith = (instance, value) => {
5029 instance.close(/** @type SweetAlertResult */{
5030 isConfirmed: true,
5031 value
5032 });
5033 };
5034
5035 /**
5036 *
5037 * @param {SweetAlert} instance
5038 * @param {string} error
5039 */
5040 const rejectWith = (instance, error) => {
5041 instance.rejectPromise(error);
5042 };
5043
5044 /**
5045 *
5046 * @param {SweetAlert} instance
5047 * @param {*} value
5048 */
5049 const confirm = (instance, value) => {
5050 const innerParams = privateProps.innerParams.get(instance);
5051 if (innerParams.showLoaderOnConfirm) {
5052 showLoading();
5053 }
5054 if (innerParams.preConfirm) {
5055 instance.resetValidationMessage();
5056 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
5057 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5058 preConfirmPromise.then(preConfirmValue => {
5059 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5060 instance.hideLoading();
5061 handleAwaitingPromise(instance);
5062 } else {
5063 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5064 }
5065 }).catch(error => rejectWith(instance, error));
5066 } else {
5067 succeedWith(instance, value);
5068 }
5069 };
5070
5071 /**
5072 * Hides loader and shows back the button which was hidden by .showLoading()
5073 * @this {SweetAlert}
5074 */
5075 function hideLoading() {
5076 // do nothing if popup is closed
5077 const innerParams = privateProps.innerParams.get(this);
5078 if (!innerParams) {
5079 return;
5080 }
5081 const domCache = privateProps.domCache.get(this);
5082 hide(domCache.loader);
5083 if (isToast()) {
5084 if (innerParams.icon) {
5085 show(getIcon());
5086 }
5087 } else {
5088 showRelatedButton(domCache);
5089 }
5090 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5091 domCache.popup.removeAttribute('aria-busy');
5092 domCache.popup.removeAttribute('data-loading');
5093 domCache.confirmButton.disabled = false;
5094 domCache.denyButton.disabled = false;
5095 domCache.cancelButton.disabled = false;
5096 }
5097
5098 /**
5099 * @param {DomCache} domCache
5100 */
5101 const showRelatedButton = domCache => {
5102 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5103 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5104 if (buttonToReplace.length) {
5105 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5106 } else if (allButtonsAreHidden()) {
5107 hide(domCache.actions);
5108 }
5109 };
5110
5111 /**
5112 * Gets the input DOM node, this method works with input parameter.
5113 *
5114 * @returns {HTMLInputElement | null}
5115 * @this {SweetAlert}
5116 */
5117 function getInput() {
5118 const innerParams = privateProps.innerParams.get(this);
5119 const domCache = privateProps.domCache.get(this);
5120 if (!domCache) {
5121 return null;
5122 }
5123 return getInput$1(domCache.popup, innerParams.input);
5124 }
5125
5126 /**
5127 * @param {SweetAlert} instance
5128 * @param {string[]} buttons
5129 * @param {boolean} disabled
5130 */
5131 function setButtonsDisabled(instance, buttons, disabled) {
5132 const domCache = privateProps.domCache.get(instance);
5133 buttons.forEach(button => {
5134 domCache[button].disabled = disabled;
5135 });
5136 }
5137
5138 /**
5139 * @param {HTMLInputElement | null} input
5140 * @param {boolean} disabled
5141 */
5142 function setInputDisabled(input, disabled) {
5143 const popup = getPopup();
5144 if (!popup || !input) {
5145 return;
5146 }
5147 if (input.type === 'radio') {
5148 /** @type {NodeListOf<HTMLInputElement>} */
5149 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5150 for (let i = 0; i < radios.length; i++) {
5151 radios[i].disabled = disabled;
5152 }
5153 } else {
5154 input.disabled = disabled;
5155 }
5156 }
5157
5158 /**
5159 * Enable all the buttons
5160 * @this {SweetAlert}
5161 */
5162 function enableButtons() {
5163 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5164 }
5165
5166 /**
5167 * Disable all the buttons
5168 * @this {SweetAlert}
5169 */
5170 function disableButtons() {
5171 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5172 }
5173
5174 /**
5175 * Enable the input field
5176 * @this {SweetAlert}
5177 */
5178 function enableInput() {
5179 setInputDisabled(this.getInput(), false);
5180 }
5181
5182 /**
5183 * Disable the input field
5184 * @this {SweetAlert}
5185 */
5186 function disableInput() {
5187 setInputDisabled(this.getInput(), true);
5188 }
5189
5190 /**
5191 * Show block with validation message
5192 *
5193 * @param {string} error
5194 * @this {SweetAlert}
5195 */
5196 function showValidationMessage(error) {
5197 const domCache = privateProps.domCache.get(this);
5198 const params = privateProps.innerParams.get(this);
5199 setInnerHtml(domCache.validationMessage, error);
5200 domCache.validationMessage.className = swalClasses['validation-message'];
5201 if (params.customClass && params.customClass.validationMessage) {
5202 addClass(domCache.validationMessage, params.customClass.validationMessage);
5203 }
5204 show(domCache.validationMessage);
5205 const input = this.getInput();
5206 if (input) {
5207 input.setAttribute('aria-invalid', 'true');
5208 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5209 focusInput(input);
5210 addClass(input, swalClasses.inputerror);
5211 }
5212 }
5213
5214 /**
5215 * Hide block with validation message
5216 *
5217 * @this {SweetAlert}
5218 */
5219 function resetValidationMessage() {
5220 const domCache = privateProps.domCache.get(this);
5221 if (domCache.validationMessage) {
5222 hide(domCache.validationMessage);
5223 }
5224 const input = this.getInput();
5225 if (input) {
5226 input.removeAttribute('aria-invalid');
5227 input.removeAttribute('aria-describedby');
5228 removeClass(input, swalClasses.inputerror);
5229 }
5230 }
5231
5232 const defaultParams = {
5233 title: '',
5234 titleText: '',
5235 text: '',
5236 html: '',
5237 footer: '',
5238 icon: undefined,
5239 iconColor: undefined,
5240 iconHtml: undefined,
5241 template: undefined,
5242 toast: false,
5243 draggable: false,
5244 animation: true,
5245 theme: 'light',
5246 showClass: {
5247 popup: 'swal2-show',
5248 backdrop: 'swal2-backdrop-show',
5249 icon: 'swal2-icon-show'
5250 },
5251 hideClass: {
5252 popup: 'swal2-hide',
5253 backdrop: 'swal2-backdrop-hide',
5254 icon: 'swal2-icon-hide'
5255 },
5256 customClass: {},
5257 target: 'body',
5258 color: undefined,
5259 backdrop: true,
5260 heightAuto: true,
5261 allowOutsideClick: true,
5262 allowEscapeKey: true,
5263 allowEnterKey: true,
5264 stopKeydownPropagation: true,
5265 keydownListenerCapture: false,
5266 showConfirmButton: true,
5267 showDenyButton: false,
5268 showCancelButton: false,
5269 preConfirm: undefined,
5270 preDeny: undefined,
5271 confirmButtonText: 'OK',
5272 confirmButtonAriaLabel: '',
5273 confirmButtonColor: undefined,
5274 denyButtonText: 'No',
5275 denyButtonAriaLabel: '',
5276 denyButtonColor: undefined,
5277 cancelButtonText: 'Cancel',
5278 cancelButtonAriaLabel: '',
5279 cancelButtonColor: undefined,
5280 buttonsStyling: true,
5281 reverseButtons: false,
5282 focusConfirm: true,
5283 focusDeny: false,
5284 focusCancel: false,
5285 returnFocus: true,
5286 showCloseButton: false,
5287 closeButtonHtml: '&times;',
5288 closeButtonAriaLabel: 'Close this dialog',
5289 loaderHtml: '',
5290 showLoaderOnConfirm: false,
5291 showLoaderOnDeny: false,
5292 imageUrl: undefined,
5293 imageWidth: undefined,
5294 imageHeight: undefined,
5295 imageAlt: '',
5296 timer: undefined,
5297 timerProgressBar: false,
5298 width: undefined,
5299 padding: undefined,
5300 background: undefined,
5301 input: undefined,
5302 inputPlaceholder: '',
5303 inputLabel: '',
5304 inputValue: '',
5305 inputOptions: {},
5306 inputAutoFocus: true,
5307 inputAutoTrim: true,
5308 inputAttributes: {},
5309 inputValidator: undefined,
5310 returnInputValueOnDeny: false,
5311 validationMessage: undefined,
5312 grow: false,
5313 position: 'center',
5314 progressSteps: [],
5315 currentProgressStep: undefined,
5316 progressStepsDistance: undefined,
5317 willOpen: undefined,
5318 didOpen: undefined,
5319 didRender: undefined,
5320 willClose: undefined,
5321 didClose: undefined,
5322 didDestroy: undefined,
5323 scrollbarPadding: true,
5324 topLayer: false
5325 };
5326 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'];
5327
5328 /** @type {Record<string, string | undefined>} */
5329 const deprecatedParams = {
5330 allowEnterKey: undefined
5331 };
5332 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5333
5334 /**
5335 * Is valid parameter
5336 *
5337 * @param {string} paramName
5338 * @returns {boolean}
5339 */
5340 const isValidParameter = paramName => {
5341 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5342 };
5343
5344 /**
5345 * Is valid parameter for Swal.update() method
5346 *
5347 * @param {string} paramName
5348 * @returns {boolean}
5349 */
5350 const isUpdatableParameter = paramName => {
5351 return updatableParams.indexOf(paramName) !== -1;
5352 };
5353
5354 /**
5355 * Is deprecated parameter
5356 *
5357 * @param {string} paramName
5358 * @returns {string | undefined}
5359 */
5360 const isDeprecatedParameter = paramName => {
5361 return deprecatedParams[paramName];
5362 };
5363
5364 /**
5365 * @param {string} param
5366 */
5367 const checkIfParamIsValid = param => {
5368 if (!isValidParameter(param)) {
5369 warn(`Unknown parameter "${param}"`);
5370 }
5371 };
5372
5373 /**
5374 * @param {string} param
5375 */
5376 const checkIfToastParamIsValid = param => {
5377 if (toastIncompatibleParams.includes(param)) {
5378 warn(`The parameter "${param}" is incompatible with toasts`);
5379 }
5380 };
5381
5382 /**
5383 * @param {string} param
5384 */
5385 const checkIfParamIsDeprecated = param => {
5386 const isDeprecated = isDeprecatedParameter(param);
5387 if (isDeprecated) {
5388 warnAboutDeprecation(param, isDeprecated);
5389 }
5390 };
5391
5392 /**
5393 * Show relevant warnings for given params
5394 *
5395 * @param {SweetAlertOptions} params
5396 */
5397 const showWarningsForParams = params => {
5398 if (params.backdrop === false && params.allowOutsideClick) {
5399 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5400 }
5401 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)) {
5402 warn(`Invalid theme "${params.theme}"`);
5403 }
5404 for (const param in params) {
5405 checkIfParamIsValid(param);
5406 if (params.toast) {
5407 checkIfToastParamIsValid(param);
5408 }
5409 checkIfParamIsDeprecated(param);
5410 }
5411 };
5412
5413 /**
5414 * Updates popup parameters.
5415 *
5416 * @this {any}
5417 * @param {SweetAlertOptions} params
5418 */
5419 function update(params) {
5420 const container = getContainer();
5421 const popup = getPopup();
5422 const innerParams = privateProps.innerParams.get(this);
5423 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5424 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.`);
5425 return;
5426 }
5427 const validUpdatableParams = filterValidParams(params);
5428 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5429 showWarningsForParams(updatedParams);
5430 if (container) {
5431 container.dataset['swal2Theme'] = updatedParams.theme;
5432 }
5433 render(this, updatedParams);
5434 privateProps.innerParams.set(this, updatedParams);
5435 Object.defineProperties(this, {
5436 params: {
5437 value: Object.assign({}, this.params, params),
5438 writable: false,
5439 enumerable: true
5440 }
5441 });
5442 }
5443
5444 /**
5445 * @param {SweetAlertOptions} params
5446 * @returns {SweetAlertOptions}
5447 */
5448 const filterValidParams = params => {
5449 /** @type {Record<string, any>} */
5450 const validUpdatableParams = {};
5451 Object.keys(params).forEach(param => {
5452 if (isUpdatableParameter(param)) {
5453 const typedParams = /** @type {Record<string, any>} */params;
5454 validUpdatableParams[param] = typedParams[param];
5455 } else {
5456 warn(`Invalid parameter to update: ${param}`);
5457 }
5458 });
5459 return validUpdatableParams;
5460 };
5461
5462 /**
5463 * Dispose the current SweetAlert2 instance
5464 * @this {SweetAlert}
5465 */
5466 function _destroy() {
5467 var _globalState$eventEmi;
5468 const domCache = privateProps.domCache.get(this);
5469 const innerParams = privateProps.innerParams.get(this);
5470 if (!innerParams) {
5471 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5472 return; // This instance has already been destroyed
5473 }
5474
5475 // Check if there is another Swal closing
5476 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5477 globalState.swalCloseEventFinishedCallback();
5478 delete globalState.swalCloseEventFinishedCallback;
5479 }
5480 if (typeof innerParams.didDestroy === 'function') {
5481 innerParams.didDestroy();
5482 }
5483 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5484 disposeSwal(this);
5485 }
5486
5487 /**
5488 * @param {SweetAlert} instance
5489 */
5490 const disposeSwal = instance => {
5491 disposeWeakMaps(instance);
5492 // Unset this.params so GC will dispose it (#1569)
5493 // @ts-ignore
5494 delete instance.params;
5495 // Unset globalState props so GC will dispose globalState (#1569)
5496 delete globalState.keydownHandler;
5497 delete globalState.keydownTarget;
5498 // Unset currentInstance
5499 delete globalState.currentInstance;
5500 };
5501
5502 /**
5503 * @param {SweetAlert} instance
5504 */
5505 const disposeWeakMaps = instance => {
5506 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5507 if (instance.isAwaitingPromise) {
5508 unsetWeakMaps(privateProps, instance);
5509 instance.isAwaitingPromise = true;
5510 } else {
5511 unsetWeakMaps(privateMethods, instance);
5512 unsetWeakMaps(privateProps, instance);
5513
5514 // @ts-ignore
5515 delete instance.isAwaitingPromise;
5516 // Unset instance methods
5517 // @ts-ignore
5518 delete instance.disableButtons;
5519 // @ts-ignore
5520 delete instance.enableButtons;
5521 // @ts-ignore
5522 delete instance.getInput;
5523 // @ts-ignore
5524 delete instance.disableInput;
5525 // @ts-ignore
5526 delete instance.enableInput;
5527 // @ts-ignore
5528 delete instance.hideLoading;
5529 // @ts-ignore
5530 delete instance.disableLoading;
5531 // @ts-ignore
5532 delete instance.showValidationMessage;
5533 // @ts-ignore
5534 delete instance.resetValidationMessage;
5535 // @ts-ignore
5536 delete instance.close;
5537 // @ts-ignore
5538 delete instance.closePopup;
5539 // @ts-ignore
5540 delete instance.closeModal;
5541 // @ts-ignore
5542 delete instance.closeToast;
5543 // @ts-ignore
5544 delete instance.rejectPromise;
5545 // @ts-ignore
5546 delete instance.update;
5547 // @ts-ignore
5548 delete instance._destroy;
5549 }
5550 };
5551
5552 /**
5553 * @param {Record<string, WeakMap<any, any>>} obj
5554 * @param {SweetAlert} instance
5555 */
5556 const unsetWeakMaps = (obj, instance) => {
5557 for (const i in obj) {
5558 obj[i].delete(instance);
5559 }
5560 };
5561
5562 var instanceMethods = /*#__PURE__*/Object.freeze({
5563 __proto__: null,
5564 _destroy: _destroy,
5565 close: close,
5566 closeModal: close,
5567 closePopup: close,
5568 closeToast: close,
5569 disableButtons: disableButtons,
5570 disableInput: disableInput,
5571 disableLoading: hideLoading,
5572 enableButtons: enableButtons,
5573 enableInput: enableInput,
5574 getInput: getInput,
5575 handleAwaitingPromise: handleAwaitingPromise,
5576 hideLoading: hideLoading,
5577 rejectPromise: rejectPromise,
5578 resetValidationMessage: resetValidationMessage,
5579 showValidationMessage: showValidationMessage,
5580 update: update
5581 });
5582
5583 /**
5584 * @param {SweetAlertOptions} innerParams
5585 * @param {DomCache} domCache
5586 * @param {(dismiss: DismissReason) => void} dismissWith
5587 */
5588 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5589 if (innerParams.toast) {
5590 handleToastClick(innerParams, domCache, dismissWith);
5591 } else {
5592 // Ignore click events that had mousedown on the popup but mouseup on the container
5593 // This can happen when the user drags a slider
5594 handleModalMousedown(domCache);
5595
5596 // Ignore click events that had mousedown on the container but mouseup on the popup
5597 handleContainerMousedown(domCache);
5598 handleModalClick(innerParams, domCache, dismissWith);
5599 }
5600 };
5601
5602 /**
5603 * @param {SweetAlertOptions} innerParams
5604 * @param {DomCache} domCache
5605 * @param {(dismiss: DismissReason) => void} dismissWith
5606 */
5607 const handleToastClick = (innerParams, domCache, dismissWith) => {
5608 // Closing toast by internal click
5609 domCache.popup.onclick = () => {
5610 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5611 return;
5612 }
5613 dismissWith(DismissReason.close);
5614 };
5615 };
5616
5617 /**
5618 * @param {SweetAlertOptions} innerParams
5619 * @returns {boolean}
5620 */
5621 const isAnyButtonShown = innerParams => {
5622 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5623 };
5624 let ignoreOutsideClick = false;
5625
5626 /**
5627 * @param {DomCache} domCache
5628 */
5629 const handleModalMousedown = domCache => {
5630 domCache.popup.onmousedown = () => {
5631 domCache.container.onmouseup = function (e) {
5632 domCache.container.onmouseup = () => {};
5633 // We only check if the mouseup target is the container because usually it doesn't
5634 // have any other direct children aside of the popup
5635 if (e.target === domCache.container) {
5636 ignoreOutsideClick = true;
5637 }
5638 };
5639 };
5640 };
5641
5642 /**
5643 * @param {DomCache} domCache
5644 */
5645 const handleContainerMousedown = domCache => {
5646 domCache.container.onmousedown = e => {
5647 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5648 if (e.target === domCache.container) {
5649 e.preventDefault();
5650 }
5651 domCache.popup.onmouseup = function (e) {
5652 domCache.popup.onmouseup = () => {};
5653 // We also need to check if the mouseup target is a child of the popup
5654 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5655 ignoreOutsideClick = true;
5656 }
5657 };
5658 };
5659 };
5660
5661 /**
5662 * @param {SweetAlertOptions} innerParams
5663 * @param {DomCache} domCache
5664 * @param {(dismiss: DismissReason) => void} dismissWith
5665 */
5666 const handleModalClick = (innerParams, domCache, dismissWith) => {
5667 domCache.container.onclick = e => {
5668 if (ignoreOutsideClick) {
5669 ignoreOutsideClick = false;
5670 return;
5671 }
5672 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5673 dismissWith(DismissReason.backdrop);
5674 }
5675 };
5676 };
5677
5678 /**
5679 * @param {any} elem
5680 * @returns {boolean}
5681 */
5682 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
5683
5684 /**
5685 * @param {any} elem
5686 * @returns {boolean}
5687 */
5688 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5689
5690 /**
5691 * @param {any[]} args
5692 * @returns {SweetAlertOptions}
5693 */
5694 const argsToParams = args => {
5695 /** @type {Record<string, any>} */
5696 const params = {};
5697 if (typeof args[0] === 'object' && !isElement(args[0])) {
5698 Object.assign(params, args[0]);
5699 } else {
5700 ['title', 'html', 'icon'].forEach((name, index) => {
5701 const arg = args[index];
5702 if (typeof arg === 'string' || isElement(arg)) {
5703 params[name] = arg;
5704 } else if (arg !== undefined) {
5705 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5706 }
5707 });
5708 }
5709 return params;
5710 };
5711
5712 /**
5713 * Main method to create a new SweetAlert2 popup
5714 *
5715 * @this {new (...args: any[]) => any}
5716 * @param {...SweetAlertOptions} args
5717 * @returns {Promise<SweetAlertResult>}
5718 */
5719 function fire(...args) {
5720 return new this(...args);
5721 }
5722
5723 /**
5724 * Returns an extended version of `Swal` containing `params` as defaults.
5725 * Useful for reusing Swal configuration.
5726 *
5727 * For example:
5728 *
5729 * Before:
5730 * const textPromptOptions = { input: 'text', showCancelButton: true }
5731 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5732 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5733 *
5734 * After:
5735 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5736 * const {value: firstName} = await TextPrompt('What is your first name?')
5737 * const {value: lastName} = await TextPrompt('What is your last name?')
5738 *
5739 * @param {SweetAlertOptions} mixinParams
5740 * @returns {SweetAlert}
5741 * @this {typeof import('../SweetAlert.js').SweetAlert}
5742 */
5743 function mixin(mixinParams) {
5744 // @ts-ignore: 'this' refers to the SweetAlert constructor
5745 class MixinSwal extends this {
5746 /**
5747 * @param {any} params
5748 * @param {any} priorityMixinParams
5749 */
5750 _main(params, priorityMixinParams) {
5751 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5752 }
5753 }
5754 // @ts-ignore
5755 return MixinSwal;
5756 }
5757
5758 /**
5759 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5760 * Otherwise, returns undefined.
5761 *
5762 * @returns {number | undefined}
5763 */
5764 const getTimerLeft = () => {
5765 return globalState.timeout && globalState.timeout.getTimerLeft();
5766 };
5767
5768 /**
5769 * Stop timer. Returns number of milliseconds of timer remained.
5770 * If `timer` parameter isn't set, returns undefined.
5771 *
5772 * @returns {number | undefined}
5773 */
5774 const stopTimer = () => {
5775 if (globalState.timeout) {
5776 stopTimerProgressBar();
5777 return globalState.timeout.stop();
5778 }
5779 };
5780
5781 /**
5782 * Resume timer. Returns number of milliseconds of timer remained.
5783 * If `timer` parameter isn't set, returns undefined.
5784 *
5785 * @returns {number | undefined}
5786 */
5787 const resumeTimer = () => {
5788 if (globalState.timeout) {
5789 const remaining = globalState.timeout.start();
5790 animateTimerProgressBar(remaining);
5791 return remaining;
5792 }
5793 };
5794
5795 /**
5796 * Resume timer. Returns number of milliseconds of timer remained.
5797 * If `timer` parameter isn't set, returns undefined.
5798 *
5799 * @returns {number | undefined}
5800 */
5801 const toggleTimer = () => {
5802 const timer = globalState.timeout;
5803 return timer && (timer.running ? stopTimer() : resumeTimer());
5804 };
5805
5806 /**
5807 * Increase timer. Returns number of milliseconds of an updated timer.
5808 * If `timer` parameter isn't set, returns undefined.
5809 *
5810 * @param {number} ms
5811 * @returns {number | undefined}
5812 */
5813 const increaseTimer = ms => {
5814 if (globalState.timeout) {
5815 const remaining = globalState.timeout.increase(ms);
5816 animateTimerProgressBar(remaining, true);
5817 return remaining;
5818 }
5819 };
5820
5821 /**
5822 * Check if timer is running. Returns true if timer is running
5823 * or false if timer is paused or stopped.
5824 * If `timer` parameter isn't set, returns undefined
5825 *
5826 * @returns {boolean}
5827 */
5828 const isTimerRunning = () => {
5829 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5830 };
5831
5832 let bodyClickListenerAdded = false;
5833 /** @type {Record<string, any>} */
5834 const clickHandlers = {};
5835
5836 /**
5837 * @this {any}
5838 * @param {string} attr
5839 */
5840 function bindClickHandler(attr = 'data-swal-template') {
5841 clickHandlers[attr] = this;
5842 if (!bodyClickListenerAdded) {
5843 document.body.addEventListener('click', bodyClickListener);
5844 bodyClickListenerAdded = true;
5845 }
5846 }
5847
5848 /**
5849 * @param {MouseEvent} event
5850 */
5851 const bodyClickListener = event => {
5852 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5853 for (const attr in clickHandlers) {
5854 const template = el.getAttribute && el.getAttribute(attr);
5855 if (template) {
5856 clickHandlers[attr].fire({
5857 template
5858 });
5859 return;
5860 }
5861 }
5862 }
5863 };
5864
5865 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5866
5867 class EventEmitter {
5868 constructor() {
5869 /** @type {Events} */
5870 this.events = {};
5871 }
5872
5873 /**
5874 * @param {string} eventName
5875 * @returns {EventHandlers}
5876 */
5877 _getHandlersByEventName(eventName) {
5878 if (typeof this.events[eventName] === 'undefined') {
5879 // not Set because we need to keep the FIFO order
5880 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5881 this.events[eventName] = [];
5882 }
5883 return this.events[eventName];
5884 }
5885
5886 /**
5887 * @param {string} eventName
5888 * @param {EventHandler} eventHandler
5889 */
5890 on(eventName, eventHandler) {
5891 const currentHandlers = this._getHandlersByEventName(eventName);
5892 if (!currentHandlers.includes(eventHandler)) {
5893 currentHandlers.push(eventHandler);
5894 }
5895 }
5896
5897 /**
5898 * @param {string} eventName
5899 * @param {EventHandler} eventHandler
5900 */
5901 once(eventName, eventHandler) {
5902 /**
5903 * @param {...any} args
5904 */
5905 const onceFn = (...args) => {
5906 this.removeListener(eventName, onceFn);
5907 // @ts-ignore
5908 eventHandler.apply(this, args);
5909 };
5910 this.on(eventName, onceFn);
5911 }
5912
5913 /**
5914 * @param {string} eventName
5915 * @param {...any} args
5916 */
5917 emit(eventName, ...args) {
5918 this._getHandlersByEventName(eventName).forEach(
5919 /**
5920 * @param {EventHandler} eventHandler
5921 */
5922 eventHandler => {
5923 try {
5924 // @ts-ignore
5925 eventHandler.apply(this, args);
5926 } catch (error) {
5927 console.error(error);
5928 }
5929 });
5930 }
5931
5932 /**
5933 * @param {string} eventName
5934 * @param {EventHandler} eventHandler
5935 */
5936 removeListener(eventName, eventHandler) {
5937 const currentHandlers = this._getHandlersByEventName(eventName);
5938 const index = currentHandlers.indexOf(eventHandler);
5939 if (index > -1) {
5940 currentHandlers.splice(index, 1);
5941 }
5942 }
5943
5944 /**
5945 * @param {string} eventName
5946 */
5947 removeAllListeners(eventName) {
5948 if (this.events[eventName] !== undefined) {
5949 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5950 this.events[eventName].length = 0;
5951 }
5952 }
5953 reset() {
5954 this.events = {};
5955 }
5956 }
5957
5958 globalState.eventEmitter = new EventEmitter();
5959
5960 /**
5961 * @param {string} eventName
5962 * @param {EventHandler} eventHandler
5963 */
5964 const on = (eventName, eventHandler) => {
5965 if (globalState.eventEmitter) {
5966 globalState.eventEmitter.on(eventName, eventHandler);
5967 }
5968 };
5969
5970 /**
5971 * @param {string} eventName
5972 * @param {EventHandler} eventHandler
5973 */
5974 const once = (eventName, eventHandler) => {
5975 if (globalState.eventEmitter) {
5976 globalState.eventEmitter.once(eventName, eventHandler);
5977 }
5978 };
5979
5980 /**
5981 * @param {string} [eventName]
5982 * @param {EventHandler} [eventHandler]
5983 */
5984 const off = (eventName, eventHandler) => {
5985 if (!globalState.eventEmitter) {
5986 return;
5987 }
5988
5989 // Remove all handlers for all events
5990 if (!eventName) {
5991 globalState.eventEmitter.reset();
5992 return;
5993 }
5994 if (eventHandler) {
5995 // Remove a specific handler
5996 globalState.eventEmitter.removeListener(eventName, eventHandler);
5997 } else {
5998 // Remove all handlers for a specific event
5999 globalState.eventEmitter.removeAllListeners(eventName);
6000 }
6001 };
6002
6003 var staticMethods = /*#__PURE__*/Object.freeze({
6004 __proto__: null,
6005 argsToParams: argsToParams,
6006 bindClickHandler: bindClickHandler,
6007 clickCancel: clickCancel,
6008 clickConfirm: clickConfirm,
6009 clickDeny: clickDeny,
6010 enableLoading: showLoading,
6011 fire: fire,
6012 getActions: getActions,
6013 getCancelButton: getCancelButton,
6014 getCloseButton: getCloseButton,
6015 getConfirmButton: getConfirmButton,
6016 getContainer: getContainer,
6017 getDenyButton: getDenyButton,
6018 getFocusableElements: getFocusableElements,
6019 getFooter: getFooter,
6020 getHtmlContainer: getHtmlContainer,
6021 getIcon: getIcon,
6022 getIconContent: getIconContent,
6023 getImage: getImage,
6024 getInputLabel: getInputLabel,
6025 getLoader: getLoader,
6026 getPopup: getPopup,
6027 getProgressSteps: getProgressSteps,
6028 getTimerLeft: getTimerLeft,
6029 getTimerProgressBar: getTimerProgressBar,
6030 getTitle: getTitle,
6031 getValidationMessage: getValidationMessage,
6032 increaseTimer: increaseTimer,
6033 isDeprecatedParameter: isDeprecatedParameter,
6034 isLoading: isLoading,
6035 isTimerRunning: isTimerRunning,
6036 isUpdatableParameter: isUpdatableParameter,
6037 isValidParameter: isValidParameter,
6038 isVisible: isVisible,
6039 mixin: mixin,
6040 off: off,
6041 on: on,
6042 once: once,
6043 resumeTimer: resumeTimer,
6044 showLoading: showLoading,
6045 stopTimer: stopTimer,
6046 toggleTimer: toggleTimer
6047 });
6048
6049 class Timer {
6050 /**
6051 * @param {() => void} callback
6052 * @param {number} delay
6053 */
6054 constructor(callback, delay) {
6055 this.callback = callback;
6056 this.remaining = delay;
6057 this.running = false;
6058 this.start();
6059 }
6060
6061 /**
6062 * @returns {number}
6063 */
6064 start() {
6065 if (!this.running) {
6066 this.running = true;
6067 this.started = new Date();
6068 this.id = setTimeout(this.callback, this.remaining);
6069 }
6070 return this.remaining;
6071 }
6072
6073 /**
6074 * @returns {number}
6075 */
6076 stop() {
6077 if (this.started && this.running) {
6078 this.running = false;
6079 clearTimeout(this.id);
6080 this.remaining -= new Date().getTime() - this.started.getTime();
6081 }
6082 return this.remaining;
6083 }
6084
6085 /**
6086 * @param {number} n
6087 * @returns {number}
6088 */
6089 increase(n) {
6090 const running = this.running;
6091 if (running) {
6092 this.stop();
6093 }
6094 this.remaining += n;
6095 if (running) {
6096 this.start();
6097 }
6098 return this.remaining;
6099 }
6100
6101 /**
6102 * @returns {number}
6103 */
6104 getTimerLeft() {
6105 if (this.running) {
6106 this.stop();
6107 this.start();
6108 }
6109 return this.remaining;
6110 }
6111
6112 /**
6113 * @returns {boolean}
6114 */
6115 isRunning() {
6116 return this.running;
6117 }
6118 }
6119
6120 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6121
6122 /**
6123 * @param {SweetAlertOptions} params
6124 * @returns {SweetAlertOptions}
6125 */
6126 const getTemplateParams = params => {
6127 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6128 if (!template) {
6129 return {};
6130 }
6131 /** @type {DocumentFragment} */
6132 const templateContent = template.content;
6133 showWarningsForElements(templateContent);
6134 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6135 return result;
6136 };
6137
6138 /**
6139 * @param {DocumentFragment} templateContent
6140 * @returns {Record<string, string | boolean | number>}
6141 */
6142 const getSwalParams = templateContent => {
6143 /** @type {Record<string, string | boolean | number>} */
6144 const result = {};
6145 /** @type {HTMLElement[]} */
6146 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6147 swalParams.forEach(param => {
6148 showWarningsForAttributes(param, ['name', 'value']);
6149 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6150 const value = param.getAttribute('value');
6151 if (!paramName || !value) {
6152 return;
6153 }
6154 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6155 result[paramName] = value !== 'false';
6156 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6157 result[paramName] = JSON.parse(value);
6158 } else {
6159 result[paramName] = value;
6160 }
6161 });
6162 return result;
6163 };
6164
6165 /**
6166 * @param {DocumentFragment} templateContent
6167 * @returns {Record<string, () => void>}
6168 */
6169 const getSwalFunctionParams = templateContent => {
6170 /** @type {Record<string, () => void>} */
6171 const result = {};
6172 /** @type {HTMLElement[]} */
6173 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6174 swalFunctions.forEach(param => {
6175 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6176 const value = param.getAttribute('value');
6177 if (!paramName || !value) {
6178 return;
6179 }
6180 result[paramName] = new Function(`return ${value}`)();
6181 });
6182 return result;
6183 };
6184
6185 /**
6186 * @param {DocumentFragment} templateContent
6187 * @returns {Record<string, string | boolean>}
6188 */
6189 const getSwalButtons = templateContent => {
6190 /** @type {Record<string, string | boolean>} */
6191 const result = {};
6192 /** @type {HTMLElement[]} */
6193 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6194 swalButtons.forEach(button => {
6195 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6196 const type = button.getAttribute('type');
6197 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6198 return;
6199 }
6200 result[`${type}ButtonText`] = button.innerHTML;
6201 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6202 if (button.hasAttribute('color')) {
6203 const color = button.getAttribute('color');
6204 if (color !== null) {
6205 result[`${type}ButtonColor`] = color;
6206 }
6207 }
6208 if (button.hasAttribute('aria-label')) {
6209 const ariaLabel = button.getAttribute('aria-label');
6210 if (ariaLabel !== null) {
6211 result[`${type}ButtonAriaLabel`] = ariaLabel;
6212 }
6213 }
6214 });
6215 return result;
6216 };
6217
6218 /**
6219 * @param {DocumentFragment} templateContent
6220 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6221 */
6222 const getSwalImage = templateContent => {
6223 const result = {};
6224 /** @type {HTMLElement | null} */
6225 const image = templateContent.querySelector('swal-image');
6226 if (image) {
6227 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6228 if (image.hasAttribute('src')) {
6229 result.imageUrl = image.getAttribute('src') || undefined;
6230 }
6231 if (image.hasAttribute('width')) {
6232 result.imageWidth = image.getAttribute('width') || undefined;
6233 }
6234 if (image.hasAttribute('height')) {
6235 result.imageHeight = image.getAttribute('height') || undefined;
6236 }
6237 if (image.hasAttribute('alt')) {
6238 result.imageAlt = image.getAttribute('alt') || undefined;
6239 }
6240 }
6241 return result;
6242 };
6243
6244 /**
6245 * @param {DocumentFragment} templateContent
6246 * @returns {object}
6247 */
6248 const getSwalIcon = templateContent => {
6249 const result = {};
6250 /** @type {HTMLElement | null} */
6251 const icon = templateContent.querySelector('swal-icon');
6252 if (icon) {
6253 showWarningsForAttributes(icon, ['type', 'color']);
6254 if (icon.hasAttribute('type')) {
6255 result.icon = icon.getAttribute('type');
6256 }
6257 if (icon.hasAttribute('color')) {
6258 result.iconColor = icon.getAttribute('color');
6259 }
6260 result.iconHtml = icon.innerHTML;
6261 }
6262 return result;
6263 };
6264
6265 /**
6266 * @param {DocumentFragment} templateContent
6267 * @returns {object}
6268 */
6269 const getSwalInput = templateContent => {
6270 /** @type {Record<string, any>} */
6271 const result = {};
6272 /** @type {HTMLElement | null} */
6273 const input = templateContent.querySelector('swal-input');
6274 if (input) {
6275 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6276 result.input = input.getAttribute('type') || 'text';
6277 if (input.hasAttribute('label')) {
6278 result.inputLabel = input.getAttribute('label');
6279 }
6280 if (input.hasAttribute('placeholder')) {
6281 result.inputPlaceholder = input.getAttribute('placeholder');
6282 }
6283 if (input.hasAttribute('value')) {
6284 result.inputValue = input.getAttribute('value');
6285 }
6286 }
6287 /** @type {HTMLElement[]} */
6288 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6289 if (inputOptions.length) {
6290 result.inputOptions = {};
6291 inputOptions.forEach(option => {
6292 showWarningsForAttributes(option, ['value']);
6293 const optionValue = option.getAttribute('value');
6294 if (!optionValue) {
6295 return;
6296 }
6297 const optionName = option.innerHTML;
6298 result.inputOptions[optionValue] = optionName;
6299 });
6300 }
6301 return result;
6302 };
6303
6304 /**
6305 * @param {DocumentFragment} templateContent
6306 * @param {string[]} paramNames
6307 * @returns {Record<string, string>}
6308 */
6309 const getSwalStringParams = (templateContent, paramNames) => {
6310 /** @type {Record<string, string>} */
6311 const result = {};
6312 for (const i in paramNames) {
6313 const paramName = paramNames[i];
6314 /** @type {HTMLElement | null} */
6315 const tag = templateContent.querySelector(paramName);
6316 if (tag) {
6317 showWarningsForAttributes(tag, []);
6318 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6319 }
6320 }
6321 return result;
6322 };
6323
6324 /**
6325 * @param {DocumentFragment} templateContent
6326 */
6327 const showWarningsForElements = templateContent => {
6328 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6329 Array.from(templateContent.children).forEach(el => {
6330 const tagName = el.tagName.toLowerCase();
6331 if (!allowedElements.includes(tagName)) {
6332 warn(`Unrecognized element <${tagName}>`);
6333 }
6334 });
6335 };
6336
6337 /**
6338 * @param {HTMLElement} el
6339 * @param {string[]} allowedAttributes
6340 */
6341 const showWarningsForAttributes = (el, allowedAttributes) => {
6342 Array.from(el.attributes).forEach(attribute => {
6343 if (allowedAttributes.indexOf(attribute.name) === -1) {
6344 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.'}`]);
6345 }
6346 });
6347 };
6348
6349 const SHOW_CLASS_TIMEOUT = 10;
6350
6351 /**
6352 * Open popup, add necessary classes and styles, fix scrollbar
6353 *
6354 * @param {SweetAlertOptions} params
6355 */
6356 const openPopup = params => {
6357 var _globalState$eventEmi, _globalState$eventEmi2;
6358 const container = getContainer();
6359 const popup = getPopup();
6360 if (!container || !popup) {
6361 return;
6362 }
6363 if (typeof params.willOpen === 'function') {
6364 params.willOpen(popup);
6365 }
6366 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6367 const bodyStyles = window.getComputedStyle(document.body);
6368 const initialBodyOverflow = bodyStyles.overflowY;
6369 addClasses(container, popup, params);
6370
6371 // scrolling is 'hidden' until animation is done, after that 'auto'
6372 setTimeout(() => {
6373 setScrollingVisibility(container, popup);
6374 }, SHOW_CLASS_TIMEOUT);
6375 if (isModal()) {
6376 // Using ternary instead of ?? operator for Webpack 4 compatibility
6377 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6378 setAriaHidden();
6379 }
6380 if (!isToast() && !globalState.previousActiveElement) {
6381 globalState.previousActiveElement = document.activeElement;
6382 }
6383 if (typeof params.didOpen === 'function') {
6384 const didOpen = params.didOpen;
6385 setTimeout(() => didOpen(popup));
6386 }
6387 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6388 };
6389
6390 /**
6391 * @param {Event} event
6392 */
6393 const swalOpenAnimationFinished = event => {
6394 const popup = getPopup();
6395 if (!popup || event.target !== popup) {
6396 return;
6397 }
6398 const container = getContainer();
6399 if (!container) {
6400 return;
6401 }
6402 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6403 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6404 container.style.overflowY = 'auto';
6405
6406 // no-transition is added in init() in case one swal is opened right after another
6407 removeClass(container, swalClasses['no-transition']);
6408 };
6409
6410 /**
6411 * @param {HTMLElement} container
6412 * @param {HTMLElement} popup
6413 */
6414 const setScrollingVisibility = (container, popup) => {
6415 if (hasCssAnimation(popup)) {
6416 container.style.overflowY = 'hidden';
6417 popup.addEventListener('animationend', swalOpenAnimationFinished);
6418 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6419 } else {
6420 container.style.overflowY = 'auto';
6421 }
6422 };
6423
6424 /**
6425 * @param {HTMLElement} container
6426 * @param {boolean} scrollbarPadding
6427 * @param {string} initialBodyOverflow
6428 */
6429 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6430 iOSfix();
6431 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6432 replaceScrollbarWithPadding(initialBodyOverflow);
6433 }
6434
6435 // sweetalert2/issues/1247
6436 setTimeout(() => {
6437 container.scrollTop = 0;
6438 });
6439 };
6440
6441 /**
6442 * @param {HTMLElement} container
6443 * @param {HTMLElement} popup
6444 * @param {SweetAlertOptions} params
6445 */
6446 const addClasses = (container, popup, params) => {
6447 var _params$showClass;
6448 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6449 addClass(container, params.showClass.backdrop);
6450 }
6451 if (params.animation) {
6452 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6453 popup.style.setProperty('opacity', '0', 'important');
6454 show(popup, 'grid');
6455 setTimeout(() => {
6456 var _params$showClass2;
6457 // Animate popup right after showing it
6458 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6459 addClass(popup, params.showClass.popup);
6460 }
6461 // and remove the opacity workaround
6462 popup.style.removeProperty('opacity');
6463 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6464 } else {
6465 show(popup, 'grid');
6466 }
6467 addClass([document.documentElement, document.body], swalClasses.shown);
6468 if (params.heightAuto && params.backdrop && !params.toast) {
6469 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6470 }
6471 };
6472
6473 var defaultInputValidators = {
6474 /**
6475 * @param {string} string
6476 * @param {string} [validationMessage]
6477 * @returns {Promise<string | void>}
6478 */
6479 email: (string, validationMessage) => {
6480 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6481 },
6482 /**
6483 * @param {string} string
6484 * @param {string} [validationMessage]
6485 * @returns {Promise<string | void>}
6486 */
6487 url: (string, validationMessage) => {
6488 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6489 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');
6490 }
6491 };
6492
6493 /**
6494 * @param {SweetAlertOptions} params
6495 */
6496 function setDefaultInputValidators(params) {
6497 // Use default `inputValidator` for supported input types if not provided
6498 if (params.inputValidator) {
6499 return;
6500 }
6501 if (params.input === 'email') {
6502 params.inputValidator = defaultInputValidators['email'];
6503 }
6504 if (params.input === 'url') {
6505 params.inputValidator = defaultInputValidators['url'];
6506 }
6507 }
6508
6509 /**
6510 * @param {SweetAlertOptions} params
6511 */
6512 function validateCustomTargetElement(params) {
6513 // Determine if the custom target element is valid
6514 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6515 warn('Target parameter is not valid, defaulting to "body"');
6516 params.target = 'body';
6517 }
6518 }
6519
6520 /**
6521 * Set type, text and actions on popup
6522 *
6523 * @param {SweetAlertOptions} params
6524 */
6525 function setParameters(params) {
6526 setDefaultInputValidators(params);
6527
6528 // showLoaderOnConfirm && preConfirm
6529 if (params.showLoaderOnConfirm && !params.preConfirm) {
6530 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');
6531 }
6532 validateCustomTargetElement(params);
6533
6534 // Replace newlines with <br> in title
6535 if (typeof params.title === 'string') {
6536 params.title = params.title.split('\n').join('<br />');
6537 }
6538 init(params);
6539 }
6540
6541 /** @type {SweetAlert} */
6542 let currentInstance;
6543 var _promise = /*#__PURE__*/new WeakMap();
6544 class SweetAlert {
6545 /**
6546 * @param {...(SweetAlertOptions | string)} args
6547 * @this {SweetAlert}
6548 */
6549 constructor(...args) {
6550 /**
6551 * @type {Promise<SweetAlertResult>}
6552 */
6553 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
6554 isConfirmed: false,
6555 isDenied: false,
6556 isDismissed: true
6557 }));
6558 // Prevent run in Node env
6559 if (typeof window === 'undefined') {
6560 return;
6561 }
6562 currentInstance = this;
6563
6564 // @ts-ignore
6565 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6566
6567 /** @type {Readonly<SweetAlertOptions>} */
6568 this.params = outerParams;
6569
6570 /** @type {boolean} */
6571 this.isAwaitingPromise = false;
6572 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6573 }
6574
6575 /**
6576 * @param {any} userParams
6577 * @param {any} mixinParams
6578 */
6579 _main(userParams, mixinParams = {}) {
6580 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6581 if (globalState.currentInstance) {
6582 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6583 const {
6584 isAwaitingPromise
6585 } = globalState.currentInstance;
6586 globalState.currentInstance._destroy();
6587 if (!isAwaitingPromise) {
6588 swalPromiseResolve({
6589 isDismissed: true
6590 });
6591 }
6592 if (isModal()) {
6593 unsetAriaHidden();
6594 }
6595 }
6596 globalState.currentInstance = currentInstance;
6597 const innerParams = prepareParams(userParams, mixinParams);
6598 setParameters(innerParams);
6599 Object.freeze(innerParams);
6600
6601 // clear the previous timer
6602 if (globalState.timeout) {
6603 globalState.timeout.stop();
6604 delete globalState.timeout;
6605 }
6606
6607 // clear the restore focus timeout
6608 clearTimeout(globalState.restoreFocusTimeout);
6609 const domCache = populateDomCache(currentInstance);
6610 render(currentInstance, innerParams);
6611 privateProps.innerParams.set(currentInstance, innerParams);
6612 return swalPromise(currentInstance, domCache, innerParams);
6613 }
6614
6615 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6616 /**
6617 * @param {any} onFulfilled
6618 */
6619 then(onFulfilled) {
6620 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6621 }
6622
6623 /**
6624 * @param {any} onFinally
6625 */
6626 finally(onFinally) {
6627 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6628 }
6629 }
6630
6631 /**
6632 * @param {SweetAlert} instance
6633 * @param {DomCache} domCache
6634 * @param {SweetAlertOptions} innerParams
6635 * @returns {Promise<SweetAlertResult>}
6636 */
6637 const swalPromise = (instance, domCache, innerParams) => {
6638 return new Promise((resolve, reject) => {
6639 // functions to handle all closings/dismissals
6640 /**
6641 * @param {DismissReason} dismiss
6642 */
6643 const dismissWith = dismiss => {
6644 instance.close({
6645 isDismissed: true,
6646 dismiss,
6647 isConfirmed: false,
6648 isDenied: false
6649 });
6650 };
6651 privateMethods.swalPromiseResolve.set(instance, resolve);
6652 privateMethods.swalPromiseReject.set(instance, reject);
6653 domCache.confirmButton.onclick = () => {
6654 handleConfirmButtonClick(instance);
6655 };
6656 domCache.denyButton.onclick = () => {
6657 handleDenyButtonClick(instance);
6658 };
6659 domCache.cancelButton.onclick = () => {
6660 handleCancelButtonClick(instance, dismissWith);
6661 };
6662 domCache.closeButton.onclick = () => {
6663 dismissWith(DismissReason.close);
6664 };
6665 handlePopupClick(innerParams, domCache, dismissWith);
6666 addKeydownHandler(globalState, innerParams, dismissWith);
6667 handleInputOptionsAndValue(instance, innerParams);
6668 openPopup(innerParams);
6669 setupTimer(globalState, innerParams, dismissWith);
6670 initFocus(domCache, innerParams);
6671
6672 // Scroll container to top on open (#1247, #1946)
6673 setTimeout(() => {
6674 domCache.container.scrollTop = 0;
6675 });
6676 });
6677 };
6678
6679 /**
6680 * @param {SweetAlertOptions} userParams
6681 * @param {SweetAlertOptions} mixinParams
6682 * @returns {SweetAlertOptions}
6683 */
6684 const prepareParams = (userParams, mixinParams) => {
6685 const templateParams = getTemplateParams(userParams);
6686 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6687 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6688 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6689 if (params.animation === false) {
6690 params.showClass = {
6691 backdrop: 'swal2-noanimation'
6692 };
6693 params.hideClass = {};
6694 }
6695 return params;
6696 };
6697
6698 /**
6699 * @param {SweetAlert} instance
6700 * @returns {DomCache}
6701 */
6702 const populateDomCache = instance => {
6703 const domCache = /** @type {DomCache} */{
6704 popup: (/** @type {HTMLElement} */getPopup()),
6705 container: (/** @type {HTMLElement} */getContainer()),
6706 actions: (/** @type {HTMLElement} */getActions()),
6707 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6708 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6709 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6710 loader: (/** @type {HTMLElement} */getLoader()),
6711 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6712 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6713 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6714 };
6715 privateProps.domCache.set(instance, domCache);
6716 return domCache;
6717 };
6718
6719 /**
6720 * @param {GlobalState} globalState
6721 * @param {SweetAlertOptions} innerParams
6722 * @param {(dismiss: DismissReason) => void} dismissWith
6723 */
6724 const setupTimer = (globalState, innerParams, dismissWith) => {
6725 const timerProgressBar = getTimerProgressBar();
6726 hide(timerProgressBar);
6727 if (innerParams.timer) {
6728 globalState.timeout = new Timer(() => {
6729 dismissWith('timer');
6730 delete globalState.timeout;
6731 }, innerParams.timer);
6732 if (innerParams.timerProgressBar && timerProgressBar) {
6733 show(timerProgressBar);
6734 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6735 setTimeout(() => {
6736 if (globalState.timeout && globalState.timeout.running) {
6737 // timer can be already stopped or unset at this point
6738 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6739 }
6740 });
6741 }
6742 }
6743 };
6744
6745 /**
6746 * Initialize focus in the popup:
6747 *
6748 * 1. If `toast` is `true`, don't steal focus from the document.
6749 * 2. Else if there is an [autofocus] element, focus it.
6750 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6751 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6752 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6753 * 6. Else focus the first focusable element in a popup (if any).
6754 *
6755 * @param {DomCache} domCache
6756 * @param {SweetAlertOptions} innerParams
6757 */
6758 const initFocus = (domCache, innerParams) => {
6759 if (innerParams.toast) {
6760 return;
6761 }
6762 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6763 if (!callIfFunction(innerParams.allowEnterKey)) {
6764 warnAboutDeprecation('allowEnterKey');
6765 blurActiveElement();
6766 return;
6767 }
6768 if (focusAutofocus(domCache)) {
6769 return;
6770 }
6771 if (focusButton(domCache, innerParams)) {
6772 return;
6773 }
6774 setFocus(-1, 1);
6775 };
6776
6777 /**
6778 * @param {DomCache} domCache
6779 * @returns {boolean}
6780 */
6781 const focusAutofocus = domCache => {
6782 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6783 for (const autofocusElement of autofocusElements) {
6784 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6785 autofocusElement.focus();
6786 return true;
6787 }
6788 }
6789 return false;
6790 };
6791
6792 /**
6793 * @param {DomCache} domCache
6794 * @param {SweetAlertOptions} innerParams
6795 * @returns {boolean}
6796 */
6797 const focusButton = (domCache, innerParams) => {
6798 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6799 domCache.denyButton.focus();
6800 return true;
6801 }
6802 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6803 domCache.cancelButton.focus();
6804 return true;
6805 }
6806 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6807 domCache.confirmButton.focus();
6808 return true;
6809 }
6810 return false;
6811 };
6812 const blurActiveElement = () => {
6813 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
6814 document.activeElement.blur();
6815 }
6816 };
6817
6818 // Assign instance methods from src/instanceMethods/*.js to prototype
6819 SweetAlert.prototype.disableButtons = disableButtons;
6820 SweetAlert.prototype.enableButtons = enableButtons;
6821 SweetAlert.prototype.getInput = getInput;
6822 SweetAlert.prototype.disableInput = disableInput;
6823 SweetAlert.prototype.enableInput = enableInput;
6824 SweetAlert.prototype.hideLoading = hideLoading;
6825 SweetAlert.prototype.disableLoading = hideLoading;
6826 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6827 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6828 SweetAlert.prototype.close = close;
6829 SweetAlert.prototype.closePopup = close;
6830 SweetAlert.prototype.closeModal = close;
6831 SweetAlert.prototype.closeToast = close;
6832 SweetAlert.prototype.rejectPromise = rejectPromise;
6833 SweetAlert.prototype.update = update;
6834 SweetAlert.prototype._destroy = _destroy;
6835
6836 // Assign static methods from src/staticMethods/*.js to constructor
6837 Object.assign(SweetAlert, staticMethods);
6838
6839 // Proxy to instance methods to constructor, for now, for backwards compatibility
6840 Object.keys(instanceMethods).forEach(key => {
6841 /**
6842 * @param {...(SweetAlertOptions | string | undefined)} args
6843 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6844 */
6845 // @ts-ignore: Dynamic property assignment for backwards compatibility
6846 SweetAlert[key] = function (...args) {
6847 // @ts-ignore
6848 if (currentInstance && currentInstance[key]) {
6849 // @ts-ignore
6850 return currentInstance[key](...args);
6851 }
6852 return undefined;
6853 };
6854 });
6855 SweetAlert.DismissReason = DismissReason;
6856 SweetAlert.version = '11.26.17';
6857
6858 const Swal = SweetAlert;
6859 // @ts-ignore
6860 Swal.default = Swal;
6861
6862 return Swal;
6863
6864 }));
6865 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6866 "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}");
6867
6868 /***/ },
6869
6870 /***/ "./node_modules/toastify-js/src/toastify.js"
6871 /*!**************************************************!*\
6872 !*** ./node_modules/toastify-js/src/toastify.js ***!
6873 \**************************************************/
6874 (module) {
6875
6876 /*!
6877 * Toastify js 1.12.0
6878 * https://github.com/apvarun/toastify-js
6879 * @license MIT licensed
6880 *
6881 * Copyright (C) 2018 Varun A P
6882 */
6883 (function(root, factory) {
6884 if ( true && module.exports) {
6885 module.exports = factory();
6886 } else {
6887 root.Toastify = factory();
6888 }
6889 })(this, function(global) {
6890 // Object initialization
6891 var Toastify = function(options) {
6892 // Returning a new init object
6893 return new Toastify.lib.init(options);
6894 },
6895 // Library version
6896 version = "1.12.0";
6897
6898 // Set the default global options
6899 Toastify.defaults = {
6900 oldestFirst: true,
6901 text: "Toastify is awesome!",
6902 node: undefined,
6903 duration: 3000,
6904 selector: undefined,
6905 callback: function () {
6906 },
6907 destination: undefined,
6908 newWindow: false,
6909 close: false,
6910 gravity: "toastify-top",
6911 positionLeft: false,
6912 position: '',
6913 backgroundColor: '',
6914 avatar: "",
6915 className: "",
6916 stopOnFocus: true,
6917 onClick: function () {
6918 },
6919 offset: {x: 0, y: 0},
6920 escapeMarkup: true,
6921 ariaLive: 'polite',
6922 style: {background: ''}
6923 };
6924
6925 // Defining the prototype of the object
6926 Toastify.lib = Toastify.prototype = {
6927 toastify: version,
6928
6929 constructor: Toastify,
6930
6931 // Initializing the object with required parameters
6932 init: function(options) {
6933 // Verifying and validating the input object
6934 if (!options) {
6935 options = {};
6936 }
6937
6938 // Creating the options object
6939 this.options = {};
6940
6941 this.toastElement = null;
6942
6943 // Validating the options
6944 this.options.text = options.text || Toastify.defaults.text; // Display message
6945 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6946 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6947 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6948 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6949 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6950 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6951 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6952 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6953 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6954 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6955 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6956 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6957 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6958 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6959 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6960 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6961 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6962 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6963 this.options.style = options.style || Toastify.defaults.style;
6964 if(options.backgroundColor) {
6965 this.options.style.background = options.backgroundColor;
6966 }
6967
6968 // Returning the current object for chaining functions
6969 return this;
6970 },
6971
6972 // Building the DOM element
6973 buildToast: function() {
6974 // Validating if the options are defined
6975 if (!this.options) {
6976 throw "Toastify is not initialized";
6977 }
6978
6979 // Creating the DOM object
6980 var divElement = document.createElement("div");
6981 divElement.className = "toastify on " + this.options.className;
6982
6983 // Positioning toast to left or right or center
6984 if (!!this.options.position) {
6985 divElement.className += " toastify-" + this.options.position;
6986 } else {
6987 // To be depreciated in further versions
6988 if (this.options.positionLeft === true) {
6989 divElement.className += " toastify-left";
6990 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6991 } else {
6992 // Default position
6993 divElement.className += " toastify-right";
6994 }
6995 }
6996
6997 // Assigning gravity of element
6998 divElement.className += " " + this.options.gravity;
6999
7000 if (this.options.backgroundColor) {
7001 // This is being deprecated in favor of using the style HTML DOM property
7002 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
7003 }
7004
7005 // Loop through our style object and apply styles to divElement
7006 for (var property in this.options.style) {
7007 divElement.style[property] = this.options.style[property];
7008 }
7009
7010 // Announce the toast to screen readers
7011 if (this.options.ariaLive) {
7012 divElement.setAttribute('aria-live', this.options.ariaLive)
7013 }
7014
7015 // Adding the toast message/node
7016 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
7017 // If we have a valid node, we insert it
7018 divElement.appendChild(this.options.node)
7019 } else {
7020 if (this.options.escapeMarkup) {
7021 divElement.innerText = this.options.text;
7022 } else {
7023 divElement.innerHTML = this.options.text;
7024 }
7025
7026 if (this.options.avatar !== "") {
7027 var avatarElement = document.createElement("img");
7028 avatarElement.src = this.options.avatar;
7029
7030 avatarElement.className = "toastify-avatar";
7031
7032 if (this.options.position == "left" || this.options.positionLeft === true) {
7033 // Adding close icon on the left of content
7034 divElement.appendChild(avatarElement);
7035 } else {
7036 // Adding close icon on the right of content
7037 divElement.insertAdjacentElement("afterbegin", avatarElement);
7038 }
7039 }
7040 }
7041
7042 // Adding a close icon to the toast
7043 if (this.options.close === true) {
7044 // Create a span for close element
7045 var closeElement = document.createElement("button");
7046 closeElement.type = "button";
7047 closeElement.setAttribute("aria-label", "Close");
7048 closeElement.className = "toast-close";
7049 closeElement.innerHTML = "&#10006;";
7050
7051 // Triggering the removal of toast from DOM on close click
7052 closeElement.addEventListener(
7053 "click",
7054 function(event) {
7055 event.stopPropagation();
7056 this.removeElement(this.toastElement);
7057 window.clearTimeout(this.toastElement.timeOutValue);
7058 }.bind(this)
7059 );
7060
7061 //Calculating screen width
7062 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7063
7064 // Adding the close icon to the toast element
7065 // Display on the right if screen width is less than or equal to 360px
7066 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7067 // Adding close icon on the left of content
7068 divElement.insertAdjacentElement("afterbegin", closeElement);
7069 } else {
7070 // Adding close icon on the right of content
7071 divElement.appendChild(closeElement);
7072 }
7073 }
7074
7075 // Clear timeout while toast is focused
7076 if (this.options.stopOnFocus && this.options.duration > 0) {
7077 var self = this;
7078 // stop countdown
7079 divElement.addEventListener(
7080 "mouseover",
7081 function(event) {
7082 window.clearTimeout(divElement.timeOutValue);
7083 }
7084 )
7085 // add back the timeout
7086 divElement.addEventListener(
7087 "mouseleave",
7088 function() {
7089 divElement.timeOutValue = window.setTimeout(
7090 function() {
7091 // Remove the toast from DOM
7092 self.removeElement(divElement);
7093 },
7094 self.options.duration
7095 )
7096 }
7097 )
7098 }
7099
7100 // Adding an on-click destination path
7101 if (typeof this.options.destination !== "undefined") {
7102 divElement.addEventListener(
7103 "click",
7104 function(event) {
7105 event.stopPropagation();
7106 if (this.options.newWindow === true) {
7107 window.open(this.options.destination, "_blank");
7108 } else {
7109 window.location = this.options.destination;
7110 }
7111 }.bind(this)
7112 );
7113 }
7114
7115 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7116 divElement.addEventListener(
7117 "click",
7118 function(event) {
7119 event.stopPropagation();
7120 this.options.onClick();
7121 }.bind(this)
7122 );
7123 }
7124
7125 // Adding offset
7126 if(typeof this.options.offset === "object") {
7127
7128 var x = getAxisOffsetAValue("x", this.options);
7129 var y = getAxisOffsetAValue("y", this.options);
7130
7131 var xOffset = this.options.position == "left" ? x : "-" + x;
7132 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7133
7134 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7135
7136 }
7137
7138 // Returning the generated element
7139 return divElement;
7140 },
7141
7142 // Displaying the toast
7143 showToast: function() {
7144 // Creating the DOM object for the toast
7145 this.toastElement = this.buildToast();
7146
7147 // Getting the root element to with the toast needs to be added
7148 var rootElement;
7149 if (typeof this.options.selector === "string") {
7150 rootElement = document.getElementById(this.options.selector);
7151 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7152 rootElement = this.options.selector;
7153 } else {
7154 rootElement = document.body;
7155 }
7156
7157 // Validating if root element is present in DOM
7158 if (!rootElement) {
7159 throw "Root element is not defined";
7160 }
7161
7162 // Adding the DOM element
7163 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7164 rootElement.insertBefore(this.toastElement, elementToInsert);
7165
7166 // Repositioning the toasts in case multiple toasts are present
7167 Toastify.reposition();
7168
7169 if (this.options.duration > 0) {
7170 this.toastElement.timeOutValue = window.setTimeout(
7171 function() {
7172 // Remove the toast from DOM
7173 this.removeElement(this.toastElement);
7174 }.bind(this),
7175 this.options.duration
7176 ); // Binding `this` for function invocation
7177 }
7178
7179 // Supporting function chaining
7180 return this;
7181 },
7182
7183 hideToast: function() {
7184 if (this.toastElement.timeOutValue) {
7185 clearTimeout(this.toastElement.timeOutValue);
7186 }
7187 this.removeElement(this.toastElement);
7188 },
7189
7190 // Removing the element from the DOM
7191 removeElement: function(toastElement) {
7192 // Hiding the element
7193 // toastElement.classList.remove("on");
7194 toastElement.className = toastElement.className.replace(" on", "");
7195
7196 // Removing the element from DOM after transition end
7197 window.setTimeout(
7198 function() {
7199 // remove options node if any
7200 if (this.options.node && this.options.node.parentNode) {
7201 this.options.node.parentNode.removeChild(this.options.node);
7202 }
7203
7204 // Remove the element from the DOM, only when the parent node was not removed before.
7205 if (toastElement.parentNode) {
7206 toastElement.parentNode.removeChild(toastElement);
7207 }
7208
7209 // Calling the callback function
7210 this.options.callback.call(toastElement);
7211
7212 // Repositioning the toasts again
7213 Toastify.reposition();
7214 }.bind(this),
7215 400
7216 ); // Binding `this` for function invocation
7217 },
7218 };
7219
7220 // Positioning the toasts on the DOM
7221 Toastify.reposition = function() {
7222
7223 // Top margins with gravity
7224 var topLeftOffsetSize = {
7225 top: 15,
7226 bottom: 15,
7227 };
7228 var topRightOffsetSize = {
7229 top: 15,
7230 bottom: 15,
7231 };
7232 var offsetSize = {
7233 top: 15,
7234 bottom: 15,
7235 };
7236
7237 // Get all toast messages on the DOM
7238 var allToasts = document.getElementsByClassName("toastify");
7239
7240 var classUsed;
7241
7242 // Modifying the position of each toast element
7243 for (var i = 0; i < allToasts.length; i++) {
7244 // Getting the applied gravity
7245 if (containsClass(allToasts[i], "toastify-top") === true) {
7246 classUsed = "toastify-top";
7247 } else {
7248 classUsed = "toastify-bottom";
7249 }
7250
7251 var height = allToasts[i].offsetHeight;
7252 classUsed = classUsed.substr(9, classUsed.length-1)
7253 // Spacing between toasts
7254 var offset = 15;
7255
7256 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7257
7258 // Show toast in center if screen with less than or equal to 360px
7259 if (width <= 360) {
7260 // Setting the position
7261 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7262
7263 offsetSize[classUsed] += height + offset;
7264 } else {
7265 if (containsClass(allToasts[i], "toastify-left") === true) {
7266 // Setting the position
7267 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7268
7269 topLeftOffsetSize[classUsed] += height + offset;
7270 } else {
7271 // Setting the position
7272 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7273
7274 topRightOffsetSize[classUsed] += height + offset;
7275 }
7276 }
7277 }
7278
7279 // Supporting function chaining
7280 return this;
7281 };
7282
7283 // Helper function to get offset.
7284 function getAxisOffsetAValue(axis, options) {
7285
7286 if(options.offset[axis]) {
7287 if(isNaN(options.offset[axis])) {
7288 return options.offset[axis];
7289 }
7290 else {
7291 return options.offset[axis] + 'px';
7292 }
7293 }
7294
7295 return '0px';
7296
7297 }
7298
7299 function containsClass(elem, yourClass) {
7300 if (!elem || typeof yourClass !== "string") {
7301 return false;
7302 } else if (
7303 elem.className &&
7304 elem.className
7305 .trim()
7306 .split(/\s+/gi)
7307 .indexOf(yourClass) > -1
7308 ) {
7309 return true;
7310 } else {
7311 return false;
7312 }
7313 }
7314
7315 // Setting up the prototype for the init object
7316 Toastify.lib.init.prototype = Toastify.lib;
7317
7318 // Returning the Toastify function to be assigned to the window object/module
7319 return Toastify;
7320 });
7321
7322
7323 /***/ },
7324
7325 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7326 /*!**********************************************************!*\
7327 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7328 \**********************************************************/
7329 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7330
7331 "use strict";
7332 __webpack_require__.r(__webpack_exports__);
7333 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7334 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7335 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7336 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7337 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7338 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7339 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7340 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7341 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7342 /* harmony export */ });
7343 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7344 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7345 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7346 /**
7347 * sifter.js
7348 * Copyright (c) 2013–2020 Brian Reavis & contributors
7349 *
7350 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7351 * file except in compliance with the License. You may obtain a copy of the License at:
7352 * http://www.apache.org/licenses/LICENSE-2.0
7353 *
7354 * Unless required by applicable law or agreed to in writing, software distributed under
7355 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7356 * ANY KIND, either express or implied. See the License for the specific language
7357 * governing permissions and limitations under the License.
7358 *
7359 * @author Brian Reavis <[email protected]>
7360 */
7361
7362
7363 class Sifter {
7364 items; // []|{};
7365 settings;
7366 /**
7367 * Textually searches arrays and hashes of objects
7368 * by property (or multiple properties). Designed
7369 * specifically for autocomplete.
7370 *
7371 */
7372 constructor(items, settings) {
7373 this.items = items;
7374 this.settings = settings || { diacritics: true };
7375 }
7376 ;
7377 /**
7378 * Splits a search string into an array of individual
7379 * regexps to be used to match results.
7380 *
7381 */
7382 tokenize(query, respect_word_boundaries, weights) {
7383 if (!query || !query.length)
7384 return [];
7385 const tokens = [];
7386 const words = query.split(/\s+/);
7387 var field_regex;
7388 if (weights) {
7389 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7390 }
7391 words.forEach((word) => {
7392 let field_match;
7393 let field = null;
7394 let regex = null;
7395 // look for "field:query" tokens
7396 if (field_regex && (field_match = word.match(field_regex))) {
7397 field = field_match[1];
7398 word = field_match[2];
7399 }
7400 if (word.length > 0) {
7401 if (this.settings.diacritics) {
7402 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7403 }
7404 else {
7405 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7406 }
7407 if (regex && respect_word_boundaries)
7408 regex = "\\b" + regex;
7409 }
7410 tokens.push({
7411 string: word,
7412 regex: regex ? new RegExp(regex, 'iu') : null,
7413 field: field,
7414 });
7415 });
7416 return tokens;
7417 }
7418 ;
7419 /**
7420 * Returns a function to be used to score individual results.
7421 *
7422 * Good matches will have a higher score than poor matches.
7423 * If an item is not a match, 0 will be returned by the function.
7424 *
7425 * @returns {T.ScoreFn}
7426 */
7427 getScoreFunction(query, options) {
7428 var search = this.prepareSearch(query, options);
7429 return this._getScoreFunction(search);
7430 }
7431 /**
7432 * @returns {T.ScoreFn}
7433 *
7434 */
7435 _getScoreFunction(search) {
7436 const tokens = search.tokens, token_count = tokens.length;
7437 if (!token_count) {
7438 return function () { return 0; };
7439 }
7440 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7441 if (!field_count) {
7442 return function () { return 1; };
7443 }
7444 /**
7445 * Calculates the score of an object
7446 * against the search query.
7447 *
7448 */
7449 const scoreObject = (function () {
7450 if (field_count === 1) {
7451 return function (token, data) {
7452 const field = fields[0].field;
7453 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7454 };
7455 }
7456 return function (token, data) {
7457 var sum = 0;
7458 // is the token specific to a field?
7459 if (token.field) {
7460 const value = getAttrFn(data, token.field);
7461 if (!token.regex && value) {
7462 sum += (1 / field_count);
7463 }
7464 else {
7465 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7466 }
7467 }
7468 else {
7469 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7470 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7471 });
7472 }
7473 return sum / field_count;
7474 };
7475 })();
7476 if (token_count === 1) {
7477 return function (data) {
7478 return scoreObject(tokens[0], data);
7479 };
7480 }
7481 if (search.options.conjunction === 'and') {
7482 return function (data) {
7483 var score, sum = 0;
7484 for (let token of tokens) {
7485 score = scoreObject(token, data);
7486 if (score <= 0)
7487 return 0;
7488 sum += score;
7489 }
7490 return sum / token_count;
7491 };
7492 }
7493 else {
7494 return function (data) {
7495 var sum = 0;
7496 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7497 sum += scoreObject(token, data);
7498 });
7499 return sum / token_count;
7500 };
7501 }
7502 }
7503 ;
7504 /**
7505 * Returns a function that can be used to compare two
7506 * results, for sorting purposes. If no sorting should
7507 * be performed, `null` will be returned.
7508 *
7509 * @return function(a,b)
7510 */
7511 getSortFunction(query, options) {
7512 var search = this.prepareSearch(query, options);
7513 return this._getSortFunction(search);
7514 }
7515 _getSortFunction(search) {
7516 var implicit_score, sort_flds = [];
7517 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
7518 if (typeof sort == 'function') {
7519 return sort.bind(this);
7520 }
7521 /**
7522 * Fetches the specified sort field value
7523 * from a search result item.
7524 *
7525 */
7526 const get_field = function (name, result) {
7527 if (name === '$score')
7528 return result.score;
7529 return search.getAttrFn(self.items[result.id], name);
7530 };
7531 // parse options
7532 if (sort) {
7533 for (let s of sort) {
7534 if (search.query || s.field !== '$score') {
7535 sort_flds.push(s);
7536 }
7537 }
7538 }
7539 // the "$score" field is implied to be the primary
7540 // sort field, unless it's manually specified
7541 if (search.query) {
7542 implicit_score = true;
7543 for (let fld of sort_flds) {
7544 if (fld.field === '$score') {
7545 implicit_score = false;
7546 break;
7547 }
7548 }
7549 if (implicit_score) {
7550 sort_flds.unshift({ field: '$score', direction: 'desc' });
7551 }
7552 // without a search.query, all items will have the same score
7553 }
7554 else {
7555 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
7556 }
7557 // build function
7558 const sort_flds_count = sort_flds.length;
7559 if (!sort_flds_count) {
7560 return null;
7561 }
7562 return function (a, b) {
7563 var result, field;
7564 for (let sort_fld of sort_flds) {
7565 field = sort_fld.field;
7566 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
7567 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
7568 if (result)
7569 return result;
7570 }
7571 return 0;
7572 };
7573 }
7574 ;
7575 /**
7576 * Parses a search query and returns an object
7577 * with tokens and fields ready to be populated
7578 * with results.
7579 *
7580 */
7581 prepareSearch(query, optsUser) {
7582 const weights = {};
7583 var options = Object.assign({}, optsUser);
7584 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
7585 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
7586 // convert fields to new format
7587 if (options.fields) {
7588 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
7589 const fields = [];
7590 options.fields.forEach((field) => {
7591 if (typeof field == 'string') {
7592 field = { field: field, weight: 1 };
7593 }
7594 fields.push(field);
7595 weights[field.field] = ('weight' in field) ? field.weight : 1;
7596 });
7597 options.fields = fields;
7598 }
7599 return {
7600 options: options,
7601 query: query.toLowerCase().trim(),
7602 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
7603 total: 0,
7604 items: [],
7605 weights: weights,
7606 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
7607 };
7608 }
7609 ;
7610 /**
7611 * Searches through all items and returns a sorted array of matches.
7612 *
7613 */
7614 search(query, options) {
7615 var self = this, score, search;
7616 search = this.prepareSearch(query, options);
7617 options = search.options;
7618 query = search.query;
7619 // generate result scoring function
7620 const fn_score = options.score || self._getScoreFunction(search);
7621 // perform search and sort
7622 if (query.length) {
7623 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
7624 score = fn_score(item);
7625 if (options.filter === false || score > 0) {
7626 search.items.push({ 'score': score, 'id': id });
7627 }
7628 });
7629 }
7630 else {
7631 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
7632 search.items.push({ 'score': 1, 'id': id });
7633 });
7634 }
7635 const fn_sort = self._getSortFunction(search);
7636 if (fn_sort)
7637 search.items.sort(fn_sort);
7638 // apply limits
7639 search.total = search.items.length;
7640 if (typeof options.limit === 'number') {
7641 search.items = search.items.slice(0, options.limit);
7642 }
7643 return search;
7644 }
7645 ;
7646 }
7647
7648
7649 //# sourceMappingURL=sifter.js.map
7650
7651 /***/ },
7652
7653 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
7654 /*!*********************************************************!*\
7655 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
7656 \*********************************************************/
7657 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7658
7659 "use strict";
7660 __webpack_require__.r(__webpack_exports__);
7661
7662 //# sourceMappingURL=types.js.map
7663
7664 /***/ },
7665
7666 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
7667 /*!*********************************************************!*\
7668 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
7669 \*********************************************************/
7670 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7671
7672 "use strict";
7673 __webpack_require__.r(__webpack_exports__);
7674 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7675 /* harmony export */ cmp: () => (/* binding */ cmp),
7676 /* harmony export */ getAttr: () => (/* binding */ getAttr),
7677 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
7678 /* harmony export */ iterate: () => (/* binding */ iterate),
7679 /* harmony export */ propToArray: () => (/* binding */ propToArray),
7680 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
7681 /* harmony export */ });
7682 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7683
7684 /**
7685 * A property getter resolving dot-notation
7686 * @param {Object} obj The root object to fetch property on
7687 * @param {String} name The optionally dotted property name to fetch
7688 * @return {Object} The resolved property value
7689 */
7690 const getAttr = (obj, name) => {
7691 if (!obj)
7692 return;
7693 return obj[name];
7694 };
7695 /**
7696 * A property getter resolving dot-notation
7697 * @param {Object} obj The root object to fetch property on
7698 * @param {String} name The optionally dotted property name to fetch
7699 * @return {Object} The resolved property value
7700 */
7701 const getAttrNesting = (obj, name) => {
7702 if (!obj)
7703 return;
7704 var part, names = name.split(".");
7705 while ((part = names.shift()) && (obj = obj[part]))
7706 ;
7707 return obj;
7708 };
7709 /**
7710 * Calculates how close of a match the
7711 * given value is against a search token.
7712 *
7713 */
7714 const scoreValue = (value, token, weight) => {
7715 var score, pos;
7716 if (!value)
7717 return 0;
7718 value = value + '';
7719 if (token.regex == null)
7720 return 0;
7721 pos = value.search(token.regex);
7722 if (pos === -1)
7723 return 0;
7724 score = token.string.length / value.length;
7725 if (pos === 0)
7726 score += 0.5;
7727 return score * weight;
7728 };
7729 /**
7730 * Cast object property to an array if it exists and has a value
7731 *
7732 */
7733 const propToArray = (obj, key) => {
7734 var value = obj[key];
7735 if (typeof value == 'function')
7736 return value;
7737 if (value && !Array.isArray(value)) {
7738 obj[key] = [value];
7739 }
7740 };
7741 /**
7742 * Iterates over arrays and hashes.
7743 *
7744 * ```
7745 * iterate(this.items, function(item, id) {
7746 * // invoked for each item
7747 * });
7748 * ```
7749 *
7750 */
7751 const iterate = (object, callback) => {
7752 if (Array.isArray(object)) {
7753 object.forEach(callback);
7754 }
7755 else {
7756 for (var key in object) {
7757 if (object.hasOwnProperty(key)) {
7758 callback(object[key], key);
7759 }
7760 }
7761 }
7762 };
7763 const cmp = (a, b) => {
7764 if (typeof a === 'number' && typeof b === 'number') {
7765 return a > b ? 1 : (a < b ? -1 : 0);
7766 }
7767 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
7768 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
7769 if (a > b)
7770 return 1;
7771 if (b > a)
7772 return -1;
7773 return 0;
7774 };
7775 //# sourceMappingURL=utils.js.map
7776
7777 /***/ },
7778
7779 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
7780 /*!*******************************************************************!*\
7781 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
7782 \*******************************************************************/
7783 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7784
7785 "use strict";
7786 __webpack_require__.r(__webpack_exports__);
7787 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7788 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
7789 /* harmony export */ asciifold: () => (/* binding */ asciifold),
7790 /* harmony export */ code_points: () => (/* binding */ code_points),
7791 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
7792 /* harmony export */ generateMap: () => (/* binding */ generateMap),
7793 /* harmony export */ generateSets: () => (/* binding */ generateSets),
7794 /* harmony export */ generator: () => (/* binding */ generator),
7795 /* harmony export */ getPattern: () => (/* binding */ getPattern),
7796 /* harmony export */ initialize: () => (/* binding */ initialize),
7797 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
7798 /* harmony export */ normalize: () => (/* binding */ normalize),
7799 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
7800 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
7801 /* harmony export */ });
7802 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
7803 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
7804
7805
7806 const code_points = [[0, 65535]];
7807 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
7808 let unicode_map;
7809 let multi_char_reg;
7810 const max_char_length = 3;
7811 const latin_convert = {};
7812 const latin_condensed = {
7813 '/': '⁄∕',
7814 '0': '߀',
7815 "a": "ⱥɐɑ",
7816 "aa": "ꜳ",
7817 "ae": "æǽǣ",
7818 "ao": "ꜵ",
7819 "au": "ꜷ",
7820 "av": "ꜹꜻ",
7821 "ay": "ꜽ",
7822 "b": "ƀɓƃ",
7823 "c": "ꜿƈȼↄ",
7824 "d": "đɗɖᴅƌꮷԁɦ",
7825 "e": "ɛǝᴇɇ",
7826 "f": "ꝼƒ",
7827 "g": "ǥɠꞡᵹꝿɢ",
7828 "h": "ħⱨⱶɥ",
7829 "i": "ɨı",
7830 "j": "ɉȷ",
7831 "k": "ƙⱪꝁꝃꝅꞣ",
7832 "l": "łƚɫⱡꝉꝇꞁɭ",
7833 "m": "ɱɯϻ",
7834 "n": "ꞥƞɲꞑᴎлԉ",
7835 "o": "øǿɔɵꝋꝍᴑ",
7836 "oe": "œ",
7837 "oi": "ƣ",
7838 "oo": "ꝏ",
7839 "ou": "ȣ",
7840 "p": "ƥᵽꝑꝓꝕρ",
7841 "q": "ꝗꝙɋ",
7842 "r": "ɍɽꝛꞧꞃ",
7843 "s": "ßȿꞩꞅʂ",
7844 "t": "ŧƭʈⱦꞇ",
7845 "th": "þ",
7846 "tz": "ꜩ",
7847 "u": "ʉ",
7848 "v": "ʋꝟʌ",
7849 "vy": "ꝡ",
7850 "w": "ⱳ",
7851 "y": "ƴɏỿ",
7852 "z": "ƶȥɀⱬꝣ",
7853 "hv": "ƕ"
7854 };
7855 for (let latin in latin_condensed) {
7856 let unicode = latin_condensed[latin] || '';
7857 for (let i = 0; i < unicode.length; i++) {
7858 let char = unicode.substring(i, i + 1);
7859 latin_convert[char] = latin;
7860 }
7861 }
7862 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
7863 /**
7864 * Initialize the unicode_map from the give code point ranges
7865 */
7866 const initialize = (_code_points) => {
7867 if (unicode_map !== undefined)
7868 return;
7869 unicode_map = generateMap(_code_points || code_points);
7870 };
7871 /**
7872 * Helper method for normalize a string
7873 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
7874 */
7875 const normalize = (str, form = 'NFKD') => str.normalize(form);
7876 /**
7877 * Remove accents without reordering string
7878 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
7879 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
7880 */
7881 const asciifold = (str) => {
7882 return Array.from(str).reduce(
7883 /**
7884 * @param {string} result
7885 * @param {string} char
7886 */
7887 (result, char) => {
7888 return result + _asciifold(char);
7889 }, '');
7890 };
7891 const _asciifold = (str) => {
7892 str = normalize(str)
7893 .toLowerCase()
7894 .replace(convert_pat, (/** @type {string} */ char) => {
7895 return latin_convert[char] || '';
7896 });
7897 //return str;
7898 return normalize(str, 'NFC');
7899 };
7900 /**
7901 * Generate a list of unicode variants from the list of code points
7902 */
7903 function* generator(code_points) {
7904 for (const [code_point_min, code_point_max] of code_points) {
7905 for (let i = code_point_min; i <= code_point_max; i++) {
7906 let composed = String.fromCharCode(i);
7907 let folded = asciifold(composed);
7908 if (folded == composed.toLowerCase()) {
7909 continue;
7910 }
7911 // skip when folded is a string longer than 3 characters long
7912 // bc the resulting regex patterns will be long
7913 // eg:
7914 // folded صلى الله عليه وسلم length 18 code point 65018
7915 // folded جل جلاله length 8 code point 65019
7916 if (folded.length > max_char_length) {
7917 continue;
7918 }
7919 if (folded.length == 0) {
7920 continue;
7921 }
7922 yield { folded: folded, composed: composed, code_point: i };
7923 }
7924 }
7925 }
7926 /**
7927 * Generate a unicode map from the list of code points
7928 */
7929 const generateSets = (code_points) => {
7930 const unicode_sets = {};
7931 const addMatching = (folded, to_add) => {
7932 /** @type {Set<string>} */
7933 const folded_set = unicode_sets[folded] || new Set();
7934 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
7935 if (to_add.match(patt)) {
7936 return;
7937 }
7938 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
7939 unicode_sets[folded] = folded_set;
7940 };
7941 for (let value of generator(code_points)) {
7942 addMatching(value.folded, value.folded);
7943 addMatching(value.folded, value.composed);
7944 }
7945 return unicode_sets;
7946 };
7947 /**
7948 * Generate a unicode map from the list of code points
7949 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
7950 */
7951 const generateMap = (code_points) => {
7952 const unicode_sets = generateSets(code_points);
7953 const unicode_map = {};
7954 let multi_char = [];
7955 for (let folded in unicode_sets) {
7956 let set = unicode_sets[folded];
7957 if (set) {
7958 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
7959 }
7960 if (folded.length > 1) {
7961 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
7962 }
7963 }
7964 multi_char.sort((a, b) => b.length - a.length);
7965 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
7966 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
7967 return unicode_map;
7968 };
7969 /**
7970 * Map each element of an array from its folded value to all possible unicode matches
7971 */
7972 const mapSequence = (strings, min_replacement = 1) => {
7973 let chars_replaced = 0;
7974 strings = strings.map((str) => {
7975 if (unicode_map[str]) {
7976 chars_replaced += str.length;
7977 }
7978 return unicode_map[str] || str;
7979 });
7980 if (chars_replaced >= min_replacement) {
7981 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
7982 }
7983 return '';
7984 };
7985 /**
7986 * Convert a short string and split it into all possible patterns
7987 * Keep a pattern only if min_replacement is met
7988 *
7989 * 'abc'
7990 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
7991 * => ['abc-pattern','ab-c-pattern'...]
7992 */
7993 const substringsToPattern = (str, min_replacement = 1) => {
7994 min_replacement = Math.max(min_replacement, str.length - 1);
7995 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
7996 return mapSequence(sub_pat, min_replacement);
7997 }));
7998 };
7999 /**
8000 * Convert an array of sequences into a pattern
8001 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
8002 */
8003 const sequencesToPattern = (sequences, all = true) => {
8004 let min_replacement = sequences.length > 1 ? 1 : 0;
8005 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
8006 let seq = [];
8007 const len = all ? sequence.length() : sequence.length() - 1;
8008 for (let j = 0; j < len; j++) {
8009 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
8010 }
8011 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
8012 }));
8013 };
8014 /**
8015 * Return true if the sequence is already in the sequences
8016 */
8017 const inSequences = (needle_seq, sequences) => {
8018 for (const seq of sequences) {
8019 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
8020 continue;
8021 }
8022 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
8023 continue;
8024 }
8025 let needle_parts = needle_seq.parts;
8026 const filter = (part) => {
8027 for (const needle_part of needle_parts) {
8028 if (needle_part.start === part.start && needle_part.substr === part.substr) {
8029 return false;
8030 }
8031 if (part.length == 1 || needle_part.length == 1) {
8032 continue;
8033 }
8034 // check for overlapping parts
8035 // a = ['::=','==']
8036 // b = ['::','===']
8037 // a = ['r','sm']
8038 // b = ['rs','m']
8039 if (part.start < needle_part.start && part.end > needle_part.start) {
8040 return true;
8041 }
8042 if (needle_part.start < part.start && needle_part.end > part.start) {
8043 return true;
8044 }
8045 }
8046 return false;
8047 };
8048 let filtered = seq.parts.filter(filter);
8049 if (filtered.length > 0) {
8050 continue;
8051 }
8052 return true;
8053 }
8054 return false;
8055 };
8056 class Sequence {
8057 parts;
8058 substrs;
8059 start;
8060 end;
8061 constructor() {
8062 this.parts = [];
8063 this.substrs = [];
8064 this.start = 0;
8065 this.end = 0;
8066 }
8067 add(part) {
8068 if (part) {
8069 this.parts.push(part);
8070 this.substrs.push(part.substr);
8071 this.start = Math.min(part.start, this.start);
8072 this.end = Math.max(part.end, this.end);
8073 }
8074 }
8075 last() {
8076 return this.parts[this.parts.length - 1];
8077 }
8078 length() {
8079 return this.parts.length;
8080 }
8081 clone(position, last_piece) {
8082 let clone = new Sequence();
8083 let parts = JSON.parse(JSON.stringify(this.parts));
8084 let last_part = parts.pop();
8085 for (const part of parts) {
8086 clone.add(part);
8087 }
8088 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8089 let clone_last_len = last_substr.length;
8090 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8091 return clone;
8092 }
8093 }
8094 /**
8095 * Expand a regular expression pattern to include unicode variants
8096 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8097 *
8098 * Issue:
8099 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8100 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8101 *
8102 * İIJ = IIJ = ⅡJ
8103 *
8104 * 1/2/4
8105 */
8106 const getPattern = (str) => {
8107 initialize();
8108 str = asciifold(str);
8109 let pattern = '';
8110 let sequences = [new Sequence()];
8111 for (let i = 0; i < str.length; i++) {
8112 let substr = str.substring(i);
8113 let match = substr.match(multi_char_reg);
8114 const char = str.substring(i, i + 1);
8115 const match_str = match ? match[0] : null;
8116 // loop through sequences
8117 // add either the char or multi_match
8118 let overlapping = [];
8119 let added_types = new Set();
8120 for (const sequence of sequences) {
8121 const last_piece = sequence.last();
8122 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8123 // if we have a multi match
8124 if (match_str) {
8125 const len = match_str.length;
8126 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8127 added_types.add('1');
8128 }
8129 else {
8130 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8131 added_types.add('2');
8132 }
8133 }
8134 else if (match_str) {
8135 let clone = sequence.clone(i, last_piece);
8136 const len = match_str.length;
8137 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8138 overlapping.push(clone);
8139 }
8140 else {
8141 // don't add char
8142 // adding would create invalid patterns: 234 => [2,34,4]
8143 added_types.add('3');
8144 }
8145 }
8146 // if we have overlapping
8147 if (overlapping.length > 0) {
8148 // ['ii','iii'] before ['i','i','iii']
8149 overlapping = overlapping.sort((a, b) => {
8150 return a.length() - b.length();
8151 });
8152 for (let clone of overlapping) {
8153 // don't add if we already have an equivalent sequence
8154 if (inSequences(clone, sequences)) {
8155 continue;
8156 }
8157 sequences.push(clone);
8158 }
8159 continue;
8160 }
8161 // if we haven't done anything unique
8162 // clean up the patterns
8163 // helps keep patterns smaller
8164 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8165 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8166 pattern += sequencesToPattern(sequences, false);
8167 let new_seq = new Sequence();
8168 const old_seq = sequences[0];
8169 if (old_seq) {
8170 new_seq.add(old_seq.last());
8171 }
8172 sequences = [new_seq];
8173 }
8174 }
8175 pattern += sequencesToPattern(sequences, true);
8176 return pattern;
8177 };
8178
8179 //# sourceMappingURL=index.js.map
8180
8181 /***/ },
8182
8183 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8184 /*!*******************************************************************!*\
8185 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8186 \*******************************************************************/
8187 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8188
8189 "use strict";
8190 __webpack_require__.r(__webpack_exports__);
8191 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8192 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8193 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8194 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8195 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8196 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8197 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8198 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8199 /* harmony export */ });
8200 /**
8201 * Convert array of strings to a regular expression
8202 * ex ['ab','a'] => (?:ab|a)
8203 * ex ['a','b'] => [ab]
8204 */
8205 const arrayToPattern = (chars) => {
8206 chars = chars.filter(Boolean);
8207 if (chars.length < 2) {
8208 return chars[0] || '';
8209 }
8210 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8211 };
8212 const sequencePattern = (array) => {
8213 if (!hasDuplicates(array)) {
8214 return array.join('');
8215 }
8216 let pattern = '';
8217 let prev_char_count = 0;
8218 const prev_pattern = () => {
8219 if (prev_char_count > 1) {
8220 pattern += '{' + prev_char_count + '}';
8221 }
8222 };
8223 array.forEach((char, i) => {
8224 if (char === array[i - 1]) {
8225 prev_char_count++;
8226 return;
8227 }
8228 prev_pattern();
8229 pattern += char;
8230 prev_char_count = 1;
8231 });
8232 prev_pattern();
8233 return pattern;
8234 };
8235 /**
8236 * Convert array of strings to a regular expression
8237 * ex ['ab','a'] => (?:ab|a)
8238 * ex ['a','b'] => [ab]
8239 */
8240 const setToPattern = (chars) => {
8241 let array = Array.from(chars);
8242 return arrayToPattern(array);
8243 };
8244 /**
8245 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8246 */
8247 const hasDuplicates = (array) => {
8248 return (new Set(array)).size !== array.length;
8249 };
8250 /**
8251 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8252 */
8253 const escape_regex = (str) => {
8254 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8255 };
8256 /**
8257 * Return the max length of array values
8258 */
8259 const maxValueLength = (array) => {
8260 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8261 };
8262 const unicodeLength = (str) => {
8263 return Array.from(str).length;
8264 };
8265 //# sourceMappingURL=regex.js.map
8266
8267 /***/ },
8268
8269 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8270 /*!*********************************************************************!*\
8271 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8272 \*********************************************************************/
8273 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8274
8275 "use strict";
8276 __webpack_require__.r(__webpack_exports__);
8277 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8278 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8279 /* harmony export */ });
8280 /**
8281 * Get all possible combinations of substrings that add up to the given string
8282 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8283 */
8284 const allSubstrings = (input) => {
8285 if (input.length === 1)
8286 return [[input]];
8287 let result = [];
8288 const start = input.substring(1);
8289 const suba = allSubstrings(start);
8290 suba.forEach(function (subresult) {
8291 let tmp = subresult.slice(0);
8292 tmp[0] = input.charAt(0) + tmp[0];
8293 result.push(tmp);
8294 tmp = subresult.slice(0);
8295 tmp.unshift(input.charAt(0));
8296 result.push(tmp);
8297 });
8298 return result;
8299 };
8300 //# sourceMappingURL=strings.js.map
8301
8302 /***/ },
8303
8304 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8305 /*!*******************************************************!*\
8306 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8307 \*******************************************************/
8308 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8309
8310 "use strict";
8311 __webpack_require__.r(__webpack_exports__);
8312 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8313 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8314 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8315 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8316 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8317 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8318 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8319 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8320 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8321 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8322 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8323 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8324 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8325 /* harmony export */ });
8326 const KEY_A = 65;
8327 const KEY_RETURN = 13;
8328 const KEY_ESC = 27;
8329 const KEY_LEFT = 37;
8330 const KEY_UP = 38;
8331 const KEY_RIGHT = 39;
8332 const KEY_DOWN = 40;
8333 const KEY_BACKSPACE = 8;
8334 const KEY_DELETE = 46;
8335 const KEY_TAB = 9;
8336 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8337 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8338 //# sourceMappingURL=constants.js.map
8339
8340 /***/ },
8341
8342 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8343 /*!***************************************************************!*\
8344 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.js ***!
8345 \***************************************************************/
8346 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8347
8348 "use strict";
8349 __webpack_require__.r(__webpack_exports__);
8350 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8351 /* harmony export */ highlight: () => (/* binding */ highlight),
8352 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8353 /* harmony export */ });
8354 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8355 /**
8356 * highlight v3 | MIT license | Johann Burkard <[email protected]>
8357 * Highlights arbitrary terms in a node.
8358 *
8359 * - Modified by Marshal <[email protected]> 2011-6-24 (added regex)
8360 * - Modified by Brian Reavis <[email protected]> 2012-8-27 (cleanup)
8361 */
8362
8363 const highlight = (element, regex) => {
8364 if (regex === null)
8365 return;
8366 // convet string to regex
8367 if (typeof regex === 'string') {
8368 if (!regex.length)
8369 return;
8370 regex = new RegExp(regex, 'i');
8371 }
8372 // Wrap matching part of text node with highlighting <span>, e.g.
8373 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8374 const highlightText = (node) => {
8375 var match = node.data.match(regex);
8376 if (match && node.data.length > 0) {
8377 var spannode = document.createElement('span');
8378 spannode.className = 'highlight';
8379 var middlebit = node.splitText(match.index);
8380 middlebit.splitText(match[0].length);
8381 var middleclone = middlebit.cloneNode(true);
8382 spannode.appendChild(middleclone);
8383 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8384 return 1;
8385 }
8386 return 0;
8387 };
8388 // Recurse element node, looking for child text nodes to highlight, unless element
8389 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8390 const highlightChildren = (node) => {
8391 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8392 Array.from(node.childNodes).forEach(element => {
8393 highlightRecursive(element);
8394 });
8395 }
8396 };
8397 const highlightRecursive = (node) => {
8398 if (node.nodeType === 3) {
8399 return highlightText(node);
8400 }
8401 highlightChildren(node);
8402 return 0;
8403 };
8404 highlightRecursive(element);
8405 };
8406 /**
8407 * removeHighlight fn copied from highlight v5 and
8408 * edited to remove with(), pass js strict mode, and use without jquery
8409 */
8410 const removeHighlight = (el) => {
8411 var elements = el.querySelectorAll("span.highlight");
8412 Array.prototype.forEach.call(elements, function (el) {
8413 var parent = el.parentNode;
8414 parent.replaceChild(el.firstChild, el);
8415 parent.normalize();
8416 });
8417 };
8418 //# sourceMappingURL=highlight.js.map
8419
8420 /***/ },
8421
8422 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8423 /*!****************************************************************!*\
8424 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8425 \****************************************************************/
8426 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8427
8428 "use strict";
8429 __webpack_require__.r(__webpack_exports__);
8430 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8431 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8432 /* harmony export */ });
8433 /**
8434 * MicroEvent - to make any js object an event emitter
8435 *
8436 * - pure javascript - server compatible, browser compatible
8437 * - dont rely on the browser doms
8438 * - super simple - you get it immediatly, no mistery, no magic involved
8439 *
8440 * @author Jerome Etienne (https://github.com/jeromeetienne)
8441 */
8442 /**
8443 * Execute callback for each event in space separated list of event names
8444 *
8445 */
8446 function forEvents(events, callback) {
8447 events.split(/\s+/).forEach((event) => {
8448 callback(event);
8449 });
8450 }
8451 class MicroEvent {
8452 constructor() {
8453 this._events = {};
8454 }
8455 on(events, fct) {
8456 forEvents(events, (event) => {
8457 const event_array = this._events[event] || [];
8458 event_array.push(fct);
8459 this._events[event] = event_array;
8460 });
8461 }
8462 off(events, fct) {
8463 var n = arguments.length;
8464 if (n === 0) {
8465 this._events = {};
8466 return;
8467 }
8468 forEvents(events, (event) => {
8469 if (n === 1) {
8470 delete this._events[event];
8471 return;
8472 }
8473 const event_array = this._events[event];
8474 if (event_array === undefined)
8475 return;
8476 event_array.splice(event_array.indexOf(fct), 1);
8477 this._events[event] = event_array;
8478 });
8479 }
8480 trigger(events, ...args) {
8481 var self = this;
8482 forEvents(events, (event) => {
8483 const event_array = self._events[event];
8484 if (event_array === undefined)
8485 return;
8486 event_array.forEach(fct => {
8487 fct.apply(self, args);
8488 });
8489 });
8490 }
8491 }
8492 ;
8493 //# sourceMappingURL=microevent.js.map
8494
8495 /***/ },
8496
8497 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
8498 /*!*****************************************************************!*\
8499 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
8500 \*****************************************************************/
8501 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8502
8503 "use strict";
8504 __webpack_require__.r(__webpack_exports__);
8505 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8506 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
8507 /* harmony export */ });
8508 /**
8509 * microplugin.js
8510 * Copyright (c) 2013 Brian Reavis & contributors
8511 *
8512 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8513 * file except in compliance with the License. You may obtain a copy of the License at:
8514 * http://www.apache.org/licenses/LICENSE-2.0
8515 *
8516 * Unless required by applicable law or agreed to in writing, software distributed under
8517 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8518 * ANY KIND, either express or implied. See the License for the specific language
8519 * governing permissions and limitations under the License.
8520 *
8521 * @author Brian Reavis <[email protected]>
8522 */
8523 function MicroPlugin(Interface) {
8524 Interface.plugins = {};
8525 return class extends Interface {
8526 constructor() {
8527 super(...arguments);
8528 this.plugins = {
8529 names: [],
8530 settings: {},
8531 requested: {},
8532 loaded: {}
8533 };
8534 }
8535 /**
8536 * Registers a plugin.
8537 *
8538 * @param {function} fn
8539 */
8540 static define(name, fn) {
8541 Interface.plugins[name] = {
8542 'name': name,
8543 'fn': fn
8544 };
8545 }
8546 /**
8547 * Initializes the listed plugins (with options).
8548 * Acceptable formats:
8549 *
8550 * List (without options):
8551 * ['a', 'b', 'c']
8552 *
8553 * List (with options):
8554 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
8555 *
8556 * Hash (with options):
8557 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
8558 *
8559 * @param {array|object} plugins
8560 */
8561 initializePlugins(plugins) {
8562 var key, name;
8563 const self = this;
8564 const queue = [];
8565 if (Array.isArray(plugins)) {
8566 plugins.forEach((plugin) => {
8567 if (typeof plugin === 'string') {
8568 queue.push(plugin);
8569 }
8570 else {
8571 self.plugins.settings[plugin.name] = plugin.options;
8572 queue.push(plugin.name);
8573 }
8574 });
8575 }
8576 else if (plugins) {
8577 for (key in plugins) {
8578 if (plugins.hasOwnProperty(key)) {
8579 self.plugins.settings[key] = plugins[key];
8580 queue.push(key);
8581 }
8582 }
8583 }
8584 while (name = queue.shift()) {
8585 self.require(name);
8586 }
8587 }
8588 loadPlugin(name) {
8589 var self = this;
8590 var plugins = self.plugins;
8591 var plugin = Interface.plugins[name];
8592 if (!Interface.plugins.hasOwnProperty(name)) {
8593 throw new Error('Unable to find "' + name + '" plugin');
8594 }
8595 plugins.requested[name] = true;
8596 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
8597 plugins.names.push(name);
8598 }
8599 /**
8600 * Initializes a plugin.
8601 *
8602 */
8603 require(name) {
8604 var self = this;
8605 var plugins = self.plugins;
8606 if (!self.plugins.loaded.hasOwnProperty(name)) {
8607 if (plugins.requested[name]) {
8608 throw new Error('Plugin has circular dependency ("' + name + '")');
8609 }
8610 self.loadPlugin(name);
8611 }
8612 return plugins.loaded[name];
8613 }
8614 };
8615 }
8616 //# sourceMappingURL=microplugin.js.map
8617
8618 /***/ },
8619
8620 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
8621 /*!******************************************************!*\
8622 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
8623 \******************************************************/
8624 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8625
8626 "use strict";
8627 __webpack_require__.r(__webpack_exports__);
8628 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8629 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8630 /* harmony export */ });
8631 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
8632 options: [],
8633 optgroups: [],
8634 plugins: [],
8635 delimiter: ',',
8636 splitOn: null, // regexp or string for splitting up values from a paste command
8637 persist: true,
8638 diacritics: true,
8639 create: null,
8640 createOnBlur: false,
8641 createFilter: null,
8642 highlight: true,
8643 openOnFocus: true,
8644 shouldOpen: null,
8645 maxOptions: 50,
8646 maxItems: null,
8647 hideSelected: null,
8648 duplicates: false,
8649 addPrecedence: false,
8650 selectOnTab: false,
8651 preload: null,
8652 allowEmptyOption: false,
8653 //closeAfterSelect: false,
8654 refreshThrottle: 300,
8655 loadThrottle: 300,
8656 loadingClass: 'loading',
8657 dataAttr: null, //'data-data',
8658 optgroupField: 'optgroup',
8659 valueField: 'value',
8660 labelField: 'text',
8661 disabledField: 'disabled',
8662 optgroupLabelField: 'label',
8663 optgroupValueField: 'value',
8664 lockOptgroupOrder: false,
8665 sortField: '$order',
8666 searchField: ['text'],
8667 searchConjunction: 'and',
8668 mode: null,
8669 wrapperClass: 'ts-wrapper',
8670 controlClass: 'ts-control',
8671 dropdownClass: 'ts-dropdown',
8672 dropdownContentClass: 'ts-dropdown-content',
8673 itemClass: 'item',
8674 optionClass: 'option',
8675 dropdownParent: null,
8676 controlInput: '<input type="text" autocomplete="off" size="1" />',
8677 copyClassesToDropdown: false,
8678 placeholder: null,
8679 hidePlaceholder: null,
8680 shouldLoad: function (query) {
8681 return query.length > 0;
8682 },
8683 /*
8684 load : null, // function(query, callback) { ... }
8685 score : null, // function(search) { ... }
8686 onInitialize : null, // function() { ... }
8687 onChange : null, // function(value) { ... }
8688 onItemAdd : null, // function(value, $item) { ... }
8689 onItemRemove : null, // function(value) { ... }
8690 onClear : null, // function() { ... }
8691 onOptionAdd : null, // function(value, data) { ... }
8692 onOptionRemove : null, // function(value) { ... }
8693 onOptionClear : null, // function() { ... }
8694 onOptionGroupAdd : null, // function(id, data) { ... }
8695 onOptionGroupRemove : null, // function(id) { ... }
8696 onOptionGroupClear : null, // function() { ... }
8697 onDropdownOpen : null, // function(dropdown) { ... }
8698 onDropdownClose : null, // function(dropdown) { ... }
8699 onType : null, // function(str) { ... }
8700 onDelete : null, // function(values) { ... }
8701 */
8702 render: {
8703 /*
8704 item: null,
8705 optgroup: null,
8706 optgroup_header: null,
8707 option: null,
8708 option_create: null
8709 */
8710 }
8711 });
8712 //# sourceMappingURL=defaults.js.map
8713
8714 /***/ },
8715
8716 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
8717 /*!*********************************************************!*\
8718 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
8719 \*********************************************************/
8720 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8721
8722 "use strict";
8723 __webpack_require__.r(__webpack_exports__);
8724 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8725 /* harmony export */ "default": () => (/* binding */ getSettings)
8726 /* harmony export */ });
8727 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
8728 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8729
8730
8731 function getSettings(input, settings_user) {
8732 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
8733 var attr_data = settings.dataAttr;
8734 var field_label = settings.labelField;
8735 var field_value = settings.valueField;
8736 var field_disabled = settings.disabledField;
8737 var field_optgroup = settings.optgroupField;
8738 var field_optgroup_label = settings.optgroupLabelField;
8739 var field_optgroup_value = settings.optgroupValueField;
8740 var tag_name = input.tagName.toLowerCase();
8741 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
8742 if (!placeholder && !settings.allowEmptyOption) {
8743 let option = input.querySelector('option[value=""]');
8744 if (option) {
8745 placeholder = option.textContent;
8746 }
8747 }
8748 var settings_element = {
8749 placeholder: placeholder,
8750 options: [],
8751 optgroups: [],
8752 items: [],
8753 maxItems: null,
8754 };
8755 /**
8756 * Initialize from a <select> element.
8757 *
8758 */
8759 var init_select = () => {
8760 var tagName;
8761 var options = settings_element.options;
8762 var optionsMap = {};
8763 var group_count = 1;
8764 let $order = 0;
8765 var readData = (el) => {
8766 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
8767 var json = attr_data && data[attr_data];
8768 if (typeof json === 'string' && json.length) {
8769 data = Object.assign(data, JSON.parse(json));
8770 }
8771 return data;
8772 };
8773 var addOption = (option, group) => {
8774 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
8775 if (value == null)
8776 return;
8777 if (!value && !settings.allowEmptyOption)
8778 return;
8779 // if the option already exists, it's probably been
8780 // duplicated in another optgroup. in this case, push
8781 // the current group to the "optgroup" property on the
8782 // existing option so that it's rendered in both places.
8783 if (optionsMap.hasOwnProperty(value)) {
8784 if (group) {
8785 var arr = optionsMap[value][field_optgroup];
8786 if (!arr) {
8787 optionsMap[value][field_optgroup] = group;
8788 }
8789 else if (!Array.isArray(arr)) {
8790 optionsMap[value][field_optgroup] = [arr, group];
8791 }
8792 else {
8793 arr.push(group);
8794 }
8795 }
8796 }
8797 else {
8798 var option_data = readData(option);
8799 option_data[field_label] = option_data[field_label] || option.textContent;
8800 option_data[field_value] = option_data[field_value] || value;
8801 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
8802 option_data[field_optgroup] = option_data[field_optgroup] || group;
8803 option_data.$option = option;
8804 option_data.$order = option_data.$order || ++$order;
8805 optionsMap[value] = option_data;
8806 options.push(option_data);
8807 }
8808 if (option.selected) {
8809 settings_element.items.push(value);
8810 }
8811 };
8812 var addGroup = (optgroup) => {
8813 var id, optgroup_data;
8814 optgroup_data = readData(optgroup);
8815 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
8816 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
8817 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
8818 optgroup_data.$order = optgroup_data.$order || ++$order;
8819 settings_element.optgroups.push(optgroup_data);
8820 id = optgroup_data[field_optgroup_value];
8821 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
8822 addOption(option, id);
8823 });
8824 };
8825 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
8826 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
8827 tagName = child.tagName.toLowerCase();
8828 if (tagName === 'optgroup') {
8829 addGroup(child);
8830 }
8831 else if (tagName === 'option') {
8832 addOption(child);
8833 }
8834 });
8835 };
8836 /**
8837 * Initialize from a <input type="text"> element.
8838 *
8839 */
8840 var init_textbox = () => {
8841 const data_raw = input.getAttribute(attr_data);
8842 if (!data_raw) {
8843 var value = input.value.trim() || '';
8844 if (!settings.allowEmptyOption && !value.length)
8845 return;
8846 const values = value.split(settings.delimiter);
8847 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
8848 const option = {};
8849 option[field_label] = value;
8850 option[field_value] = value;
8851 settings_element.options.push(option);
8852 });
8853 settings_element.items = values;
8854 }
8855 else {
8856 settings_element.options = JSON.parse(data_raw);
8857 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
8858 settings_element.items.push(opt[field_value]);
8859 });
8860 }
8861 };
8862 if (tag_name === 'select') {
8863 init_select();
8864 }
8865 else {
8866 init_textbox();
8867 }
8868 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
8869 }
8870 ;
8871 //# sourceMappingURL=getSettings.js.map
8872
8873 /***/ },
8874
8875 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
8876 /*!***************************************************************************!*\
8877 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
8878 \***************************************************************************/
8879 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8880
8881 "use strict";
8882 __webpack_require__.r(__webpack_exports__);
8883 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8884 /* harmony export */ "default": () => (/* binding */ plugin)
8885 /* harmony export */ });
8886 /**
8887 * Tom Select v2.4.3
8888 * Licensed under the Apache License, Version 2.0 (the "License");
8889 */
8890
8891 /**
8892 * Converts a scalar to its best string representation
8893 * for hash keys and HTML attribute values.
8894 *
8895 * Transformations:
8896 * 'str' -> 'str'
8897 * null -> ''
8898 * undefined -> ''
8899 * true -> '1'
8900 * false -> '0'
8901 * 0 -> '0'
8902 * 1 -> '1'
8903 *
8904 */
8905
8906 /**
8907 * Iterates over arrays and hashes.
8908 *
8909 * ```
8910 * iterate(this.items, function(item, id) {
8911 * // invoked for each item
8912 * });
8913 * ```
8914 *
8915 */
8916 const iterate = (object, callback) => {
8917 if (Array.isArray(object)) {
8918 object.forEach(callback);
8919 } else {
8920 for (var key in object) {
8921 if (object.hasOwnProperty(key)) {
8922 callback(object[key], key);
8923 }
8924 }
8925 }
8926 };
8927
8928 /**
8929 * Remove css classes
8930 *
8931 */
8932 const removeClasses = (elmts, ...classes) => {
8933 var norm_classes = classesArray(classes);
8934 elmts = castAsArray(elmts);
8935 elmts.map(el => {
8936 norm_classes.map(cls => {
8937 el.classList.remove(cls);
8938 });
8939 });
8940 };
8941
8942 /**
8943 * Return arguments
8944 *
8945 */
8946 const classesArray = args => {
8947 var classes = [];
8948 iterate(args, _classes => {
8949 if (typeof _classes === 'string') {
8950 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8951 }
8952 if (Array.isArray(_classes)) {
8953 classes = classes.concat(_classes);
8954 }
8955 });
8956 return classes.filter(Boolean);
8957 };
8958
8959 /**
8960 * Create an array from arg if it's not already an array
8961 *
8962 */
8963 const castAsArray = arg => {
8964 if (!Array.isArray(arg)) {
8965 arg = [arg];
8966 }
8967 return arg;
8968 };
8969
8970 /**
8971 * Get the index of an element amongst sibling nodes of the same type
8972 *
8973 */
8974 const nodeIndex = (el, amongst) => {
8975 if (!el) return -1;
8976 amongst = amongst || el.nodeName;
8977 var i = 0;
8978 while (el = el.previousElementSibling) {
8979 if (el.matches(amongst)) {
8980 i++;
8981 }
8982 }
8983 return i;
8984 };
8985
8986 /**
8987 * Plugin: "dropdown_input" (Tom Select)
8988 * Copyright (c) contributors
8989 *
8990 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8991 * file except in compliance with the License. You may obtain a copy of the License at:
8992 * http://www.apache.org/licenses/LICENSE-2.0
8993 *
8994 * Unless required by applicable law or agreed to in writing, software distributed under
8995 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8996 * ANY KIND, either express or implied. See the License for the specific language
8997 * governing permissions and limitations under the License.
8998 *
8999 */
9000
9001 function plugin () {
9002 var self = this;
9003
9004 /**
9005 * Moves the caret to the specified index.
9006 *
9007 * The input must be moved by leaving it in place and moving the
9008 * siblings, due to the fact that focus cannot be restored once lost
9009 * on mobile webkit devices
9010 *
9011 */
9012 self.hook('instead', 'setCaret', new_pos => {
9013 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
9014 new_pos = self.items.length;
9015 } else {
9016 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
9017 if (new_pos != self.caretPos && !self.isPending) {
9018 self.controlChildren().forEach((child, j) => {
9019 if (j < new_pos) {
9020 self.control_input.insertAdjacentElement('beforebegin', child);
9021 } else {
9022 self.control.appendChild(child);
9023 }
9024 });
9025 }
9026 }
9027 self.caretPos = new_pos;
9028 });
9029 self.hook('instead', 'moveCaret', direction => {
9030 if (!self.isFocused) return;
9031
9032 // move caret before or after selected items
9033 const last_active = self.getLastActive(direction);
9034 if (last_active) {
9035 const idx = nodeIndex(last_active);
9036 self.setCaret(direction > 0 ? idx + 1 : idx);
9037 self.setActiveItem();
9038 removeClasses(last_active, 'last-active');
9039
9040 // move caret left or right of current position
9041 } else {
9042 self.setCaret(self.caretPos + direction);
9043 }
9044 });
9045 }
9046
9047
9048 //# sourceMappingURL=plugin.js.map
9049
9050
9051 /***/ },
9052
9053 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9054 /*!****************************************************************************!*\
9055 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9056 \****************************************************************************/
9057 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9058
9059 "use strict";
9060 __webpack_require__.r(__webpack_exports__);
9061 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9062 /* harmony export */ "default": () => (/* binding */ plugin)
9063 /* harmony export */ });
9064 /**
9065 * Tom Select v2.4.3
9066 * Licensed under the Apache License, Version 2.0 (the "License");
9067 */
9068
9069 /**
9070 * Converts a scalar to its best string representation
9071 * for hash keys and HTML attribute values.
9072 *
9073 * Transformations:
9074 * 'str' -> 'str'
9075 * null -> ''
9076 * undefined -> ''
9077 * true -> '1'
9078 * false -> '0'
9079 * 0 -> '0'
9080 * 1 -> '1'
9081 *
9082 */
9083
9084 /**
9085 * Add event helper
9086 *
9087 */
9088 const addEvent = (target, type, callback, options) => {
9089 target.addEventListener(type, callback, options);
9090 };
9091
9092 /**
9093 * Plugin: "change_listener" (Tom Select)
9094 * Copyright (c) contributors
9095 *
9096 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9097 * file except in compliance with the License. You may obtain a copy of the License at:
9098 * http://www.apache.org/licenses/LICENSE-2.0
9099 *
9100 * Unless required by applicable law or agreed to in writing, software distributed under
9101 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9102 * ANY KIND, either express or implied. See the License for the specific language
9103 * governing permissions and limitations under the License.
9104 *
9105 */
9106
9107 function plugin () {
9108 addEvent(this.input, 'change', () => {
9109 this.sync();
9110 });
9111 }
9112
9113
9114 //# sourceMappingURL=plugin.js.map
9115
9116
9117 /***/ },
9118
9119 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9120 /*!*****************************************************************************!*\
9121 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9122 \*****************************************************************************/
9123 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9124
9125 "use strict";
9126 __webpack_require__.r(__webpack_exports__);
9127 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9128 /* harmony export */ "default": () => (/* binding */ plugin)
9129 /* harmony export */ });
9130 /**
9131 * Tom Select v2.4.3
9132 * Licensed under the Apache License, Version 2.0 (the "License");
9133 */
9134
9135 /**
9136 * Converts a scalar to its best string representation
9137 * for hash keys and HTML attribute values.
9138 *
9139 * Transformations:
9140 * 'str' -> 'str'
9141 * null -> ''
9142 * undefined -> ''
9143 * true -> '1'
9144 * false -> '0'
9145 * 0 -> '0'
9146 * 1 -> '1'
9147 *
9148 */
9149 const hash_key = value => {
9150 if (typeof value === 'undefined' || value === null) return null;
9151 return get_hash(value);
9152 };
9153 const get_hash = value => {
9154 if (typeof value === 'boolean') return value ? '1' : '0';
9155 return value + '';
9156 };
9157
9158 /**
9159 * Prevent default
9160 *
9161 */
9162 const preventDefault = (evt, stop = false) => {
9163 if (evt) {
9164 evt.preventDefault();
9165 if (stop) {
9166 evt.stopPropagation();
9167 }
9168 }
9169 };
9170
9171 /**
9172 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9173 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9174 *
9175 * param query should be {}
9176 */
9177 const getDom = query => {
9178 if (query.jquery) {
9179 return query[0];
9180 }
9181 if (query instanceof HTMLElement) {
9182 return query;
9183 }
9184 if (isHtmlString(query)) {
9185 var tpl = document.createElement('template');
9186 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9187 return tpl.content.firstChild;
9188 }
9189 return document.querySelector(query);
9190 };
9191 const isHtmlString = arg => {
9192 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9193 return true;
9194 }
9195 return false;
9196 };
9197
9198 /**
9199 * Plugin: "checkbox_options" (Tom Select)
9200 * Copyright (c) contributors
9201 *
9202 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9203 * file except in compliance with the License. You may obtain a copy of the License at:
9204 * http://www.apache.org/licenses/LICENSE-2.0
9205 *
9206 * Unless required by applicable law or agreed to in writing, software distributed under
9207 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9208 * ANY KIND, either express or implied. See the License for the specific language
9209 * governing permissions and limitations under the License.
9210 *
9211 */
9212
9213 function plugin (userOptions) {
9214 var self = this;
9215 var orig_onOptionSelect = self.onOptionSelect;
9216 self.settings.hideSelected = false;
9217 const cbOptions = Object.assign({
9218 // so that the user may add different ones as well
9219 className: "tomselect-checkbox",
9220 // the following default to the historic plugin's values
9221 checkedClassNames: undefined,
9222 uncheckedClassNames: undefined
9223 }, userOptions);
9224 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9225 if (toCheck) {
9226 checkbox.checked = true;
9227 if (cbOptions.uncheckedClassNames) {
9228 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9229 }
9230 if (cbOptions.checkedClassNames) {
9231 checkbox.classList.add(...cbOptions.checkedClassNames);
9232 }
9233 } else {
9234 checkbox.checked = false;
9235 if (cbOptions.checkedClassNames) {
9236 checkbox.classList.remove(...cbOptions.checkedClassNames);
9237 }
9238 if (cbOptions.uncheckedClassNames) {
9239 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9240 }
9241 }
9242 };
9243
9244 // update the checkbox for an option
9245 var UpdateCheckbox = function UpdateCheckbox(option) {
9246 setTimeout(() => {
9247 var checkbox = option.querySelector('input.' + cbOptions.className);
9248 if (checkbox instanceof HTMLInputElement) {
9249 UpdateChecked(checkbox, option.classList.contains('selected'));
9250 }
9251 }, 1);
9252 };
9253
9254 // add checkbox to option template
9255 self.hook('after', 'setupTemplates', () => {
9256 var orig_render_option = self.settings.render.option;
9257 self.settings.render.option = (data, escape_html) => {
9258 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9259 var checkbox = document.createElement('input');
9260 if (cbOptions.className) {
9261 checkbox.classList.add(cbOptions.className);
9262 }
9263 checkbox.addEventListener('click', function (evt) {
9264 preventDefault(evt);
9265 });
9266 checkbox.type = 'checkbox';
9267 const hashed = hash_key(data[self.settings.valueField]);
9268 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9269 rendered.prepend(checkbox);
9270 return rendered;
9271 };
9272 });
9273
9274 // uncheck when item removed
9275 self.on('item_remove', value => {
9276 var option = self.getOption(value);
9277 if (option) {
9278 // if dropdown hasn't been opened yet, the option won't exist
9279 option.classList.remove('selected'); // selected class won't be removed yet
9280 UpdateCheckbox(option);
9281 }
9282 });
9283
9284 // check when item added
9285 self.on('item_add', value => {
9286 var option = self.getOption(value);
9287 if (option) {
9288 // if dropdown hasn't been opened yet, the option won't exist
9289 UpdateCheckbox(option);
9290 }
9291 });
9292
9293 // remove items when selected option is clicked
9294 self.hook('instead', 'onOptionSelect', (evt, option) => {
9295 if (option.classList.contains('selected')) {
9296 option.classList.remove('selected');
9297 self.removeItem(option.dataset.value);
9298 self.refreshOptions();
9299 preventDefault(evt, true);
9300 return;
9301 }
9302 orig_onOptionSelect.call(self, evt, option);
9303 UpdateCheckbox(option);
9304 });
9305 }
9306
9307
9308 //# sourceMappingURL=plugin.js.map
9309
9310
9311 /***/ },
9312
9313 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9314 /*!*************************************************************************!*\
9315 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9316 \*************************************************************************/
9317 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9318
9319 "use strict";
9320 __webpack_require__.r(__webpack_exports__);
9321 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9322 /* harmony export */ "default": () => (/* binding */ plugin)
9323 /* harmony export */ });
9324 /**
9325 * Tom Select v2.4.3
9326 * Licensed under the Apache License, Version 2.0 (the "License");
9327 */
9328
9329 /**
9330 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9331 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9332 *
9333 * param query should be {}
9334 */
9335 const getDom = query => {
9336 if (query.jquery) {
9337 return query[0];
9338 }
9339 if (query instanceof HTMLElement) {
9340 return query;
9341 }
9342 if (isHtmlString(query)) {
9343 var tpl = document.createElement('template');
9344 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9345 return tpl.content.firstChild;
9346 }
9347 return document.querySelector(query);
9348 };
9349 const isHtmlString = arg => {
9350 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9351 return true;
9352 }
9353 return false;
9354 };
9355
9356 /**
9357 * Plugin: "dropdown_header" (Tom Select)
9358 * Copyright (c) contributors
9359 *
9360 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9361 * file except in compliance with the License. You may obtain a copy of the License at:
9362 * http://www.apache.org/licenses/LICENSE-2.0
9363 *
9364 * Unless required by applicable law or agreed to in writing, software distributed under
9365 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9366 * ANY KIND, either express or implied. See the License for the specific language
9367 * governing permissions and limitations under the License.
9368 *
9369 */
9370
9371 function plugin (userOptions) {
9372 const self = this;
9373 const options = Object.assign({
9374 className: 'clear-button',
9375 title: 'Clear All',
9376 html: data => {
9377 return `<div class="${data.className}" title="${data.title}">&#10799;</div>`;
9378 }
9379 }, userOptions);
9380 self.on('initialize', () => {
9381 var button = getDom(options.html(options));
9382 button.addEventListener('click', evt => {
9383 if (self.isLocked) return;
9384 self.clear();
9385 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9386 self.addItem('');
9387 }
9388 evt.preventDefault();
9389 evt.stopPropagation();
9390 });
9391 self.control.appendChild(button);
9392 });
9393 }
9394
9395
9396 //# sourceMappingURL=plugin.js.map
9397
9398
9399 /***/ },
9400
9401 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9402 /*!**********************************************************************!*\
9403 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9404 \**********************************************************************/
9405 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9406
9407 "use strict";
9408 __webpack_require__.r(__webpack_exports__);
9409 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9410 /* harmony export */ "default": () => (/* binding */ plugin)
9411 /* harmony export */ });
9412 /**
9413 * Tom Select v2.4.3
9414 * Licensed under the Apache License, Version 2.0 (the "License");
9415 */
9416
9417 /**
9418 * Converts a scalar to its best string representation
9419 * for hash keys and HTML attribute values.
9420 *
9421 * Transformations:
9422 * 'str' -> 'str'
9423 * null -> ''
9424 * undefined -> ''
9425 * true -> '1'
9426 * false -> '0'
9427 * 0 -> '0'
9428 * 1 -> '1'
9429 *
9430 */
9431
9432 /**
9433 * Prevent default
9434 *
9435 */
9436 const preventDefault = (evt, stop = false) => {
9437 if (evt) {
9438 evt.preventDefault();
9439 if (stop) {
9440 evt.stopPropagation();
9441 }
9442 }
9443 };
9444
9445 /**
9446 * Add event helper
9447 *
9448 */
9449 const addEvent = (target, type, callback, options) => {
9450 target.addEventListener(type, callback, options);
9451 };
9452
9453 /**
9454 * Iterates over arrays and hashes.
9455 *
9456 * ```
9457 * iterate(this.items, function(item, id) {
9458 * // invoked for each item
9459 * });
9460 * ```
9461 *
9462 */
9463 const iterate = (object, callback) => {
9464 if (Array.isArray(object)) {
9465 object.forEach(callback);
9466 } else {
9467 for (var key in object) {
9468 if (object.hasOwnProperty(key)) {
9469 callback(object[key], key);
9470 }
9471 }
9472 }
9473 };
9474
9475 /**
9476 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9477 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9478 *
9479 * param query should be {}
9480 */
9481 const getDom = query => {
9482 if (query.jquery) {
9483 return query[0];
9484 }
9485 if (query instanceof HTMLElement) {
9486 return query;
9487 }
9488 if (isHtmlString(query)) {
9489 var tpl = document.createElement('template');
9490 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9491 return tpl.content.firstChild;
9492 }
9493 return document.querySelector(query);
9494 };
9495 const isHtmlString = arg => {
9496 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9497 return true;
9498 }
9499 return false;
9500 };
9501
9502 /**
9503 * Set attributes of an element
9504 *
9505 */
9506 const setAttr = (el, attrs) => {
9507 iterate(attrs, (val, attr) => {
9508 if (val == null) {
9509 el.removeAttribute(attr);
9510 } else {
9511 el.setAttribute(attr, '' + val);
9512 }
9513 });
9514 };
9515
9516 /**
9517 * Plugin: "drag_drop" (Tom Select)
9518 * Copyright (c) contributors
9519 *
9520 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9521 * file except in compliance with the License. You may obtain a copy of the License at:
9522 * http://www.apache.org/licenses/LICENSE-2.0
9523 *
9524 * Unless required by applicable law or agreed to in writing, software distributed under
9525 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9526 * ANY KIND, either express or implied. See the License for the specific language
9527 * governing permissions and limitations under the License.
9528 *
9529 */
9530
9531 const insertAfter = (referenceNode, newNode) => {
9532 var _referenceNode$parent;
9533 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
9534 };
9535 const insertBefore = (referenceNode, newNode) => {
9536 var _referenceNode$parent2;
9537 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
9538 };
9539 const isBefore = (referenceNode, newNode) => {
9540 do {
9541 var _newNode;
9542 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
9543 if (referenceNode == newNode) {
9544 return true;
9545 }
9546 } while (newNode && newNode.previousElementSibling);
9547 return false;
9548 };
9549 function plugin () {
9550 var self = this;
9551 if (self.settings.mode !== 'multi') return;
9552 var orig_lock = self.lock;
9553 var orig_unlock = self.unlock;
9554 let sortable = true;
9555 let drag_item;
9556
9557 /**
9558 * Add draggable attribute to item
9559 */
9560 self.hook('after', 'setupTemplates', () => {
9561 var orig_render_item = self.settings.render.item;
9562 self.settings.render.item = (data, escape) => {
9563 const item = getDom(orig_render_item.call(self, data, escape));
9564 setAttr(item, {
9565 'draggable': 'true'
9566 });
9567
9568 // prevent doc_mousedown (see tom-select.ts)
9569 const mousedown = evt => {
9570 if (!sortable) preventDefault(evt);
9571 evt.stopPropagation();
9572 };
9573 const dragStart = evt => {
9574 drag_item = item;
9575 setTimeout(() => {
9576 item.classList.add('ts-dragging');
9577 }, 0);
9578 };
9579 const dragOver = evt => {
9580 evt.preventDefault();
9581 item.classList.add('ts-drag-over');
9582 moveitem(item, drag_item);
9583 };
9584 const dragLeave = () => {
9585 item.classList.remove('ts-drag-over');
9586 };
9587 const moveitem = (targetitem, dragitem) => {
9588 if (dragitem === undefined) return;
9589 if (isBefore(dragitem, item)) {
9590 insertAfter(targetitem, dragitem);
9591 } else {
9592 insertBefore(targetitem, dragitem);
9593 }
9594 };
9595 const dragend = () => {
9596 var _drag_item;
9597 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
9598 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
9599 drag_item = undefined;
9600 var values = [];
9601 self.control.querySelectorAll(`[data-value]`).forEach(el => {
9602 if (el.dataset.value) {
9603 let value = el.dataset.value;
9604 if (value) {
9605 values.push(value);
9606 }
9607 }
9608 });
9609 self.setValue(values);
9610 };
9611 addEvent(item, 'mousedown', mousedown);
9612 addEvent(item, 'dragstart', dragStart);
9613 addEvent(item, 'dragenter', dragOver);
9614 addEvent(item, 'dragover', dragOver);
9615 addEvent(item, 'dragleave', dragLeave);
9616 addEvent(item, 'dragend', dragend);
9617 return item;
9618 };
9619 });
9620 self.hook('instead', 'lock', () => {
9621 sortable = false;
9622 return orig_lock.call(self);
9623 });
9624 self.hook('instead', 'unlock', () => {
9625 sortable = true;
9626 return orig_unlock.call(self);
9627 });
9628 }
9629
9630
9631 //# sourceMappingURL=plugin.js.map
9632
9633
9634 /***/ },
9635
9636 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
9637 /*!****************************************************************************!*\
9638 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
9639 \****************************************************************************/
9640 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9641
9642 "use strict";
9643 __webpack_require__.r(__webpack_exports__);
9644 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9645 /* harmony export */ "default": () => (/* binding */ plugin)
9646 /* harmony export */ });
9647 /**
9648 * Tom Select v2.4.3
9649 * Licensed under the Apache License, Version 2.0 (the "License");
9650 */
9651
9652 /**
9653 * Converts a scalar to its best string representation
9654 * for hash keys and HTML attribute values.
9655 *
9656 * Transformations:
9657 * 'str' -> 'str'
9658 * null -> ''
9659 * undefined -> ''
9660 * true -> '1'
9661 * false -> '0'
9662 * 0 -> '0'
9663 * 1 -> '1'
9664 *
9665 */
9666
9667 /**
9668 * Prevent default
9669 *
9670 */
9671 const preventDefault = (evt, stop = false) => {
9672 if (evt) {
9673 evt.preventDefault();
9674 if (stop) {
9675 evt.stopPropagation();
9676 }
9677 }
9678 };
9679
9680 /**
9681 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9682 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9683 *
9684 * param query should be {}
9685 */
9686 const getDom = query => {
9687 if (query.jquery) {
9688 return query[0];
9689 }
9690 if (query instanceof HTMLElement) {
9691 return query;
9692 }
9693 if (isHtmlString(query)) {
9694 var tpl = document.createElement('template');
9695 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9696 return tpl.content.firstChild;
9697 }
9698 return document.querySelector(query);
9699 };
9700 const isHtmlString = arg => {
9701 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9702 return true;
9703 }
9704 return false;
9705 };
9706
9707 /**
9708 * Plugin: "dropdown_header" (Tom Select)
9709 * Copyright (c) contributors
9710 *
9711 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9712 * file except in compliance with the License. You may obtain a copy of the License at:
9713 * http://www.apache.org/licenses/LICENSE-2.0
9714 *
9715 * Unless required by applicable law or agreed to in writing, software distributed under
9716 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9717 * ANY KIND, either express or implied. See the License for the specific language
9718 * governing permissions and limitations under the License.
9719 *
9720 */
9721
9722 function plugin (userOptions) {
9723 const self = this;
9724 const options = Object.assign({
9725 title: 'Untitled',
9726 headerClass: 'dropdown-header',
9727 titleRowClass: 'dropdown-header-title',
9728 labelClass: 'dropdown-header-label',
9729 closeClass: 'dropdown-header-close',
9730 html: data => {
9731 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
9732 }
9733 }, userOptions);
9734 self.on('initialize', () => {
9735 var header = getDom(options.html(options));
9736 var close_link = header.querySelector('.' + options.closeClass);
9737 if (close_link) {
9738 close_link.addEventListener('click', evt => {
9739 preventDefault(evt, true);
9740 self.close();
9741 });
9742 }
9743 self.dropdown.insertBefore(header, self.dropdown.firstChild);
9744 });
9745 }
9746
9747
9748 //# sourceMappingURL=plugin.js.map
9749
9750
9751 /***/ },
9752
9753 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
9754 /*!***************************************************************************!*\
9755 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
9756 \***************************************************************************/
9757 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9758
9759 "use strict";
9760 __webpack_require__.r(__webpack_exports__);
9761 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9762 /* harmony export */ "default": () => (/* binding */ plugin)
9763 /* harmony export */ });
9764 /**
9765 * Tom Select v2.4.3
9766 * Licensed under the Apache License, Version 2.0 (the "License");
9767 */
9768
9769 const KEY_ESC = 27;
9770 const KEY_TAB = 9;
9771 // ctrl key or apple key for ma
9772
9773 /**
9774 * Converts a scalar to its best string representation
9775 * for hash keys and HTML attribute values.
9776 *
9777 * Transformations:
9778 * 'str' -> 'str'
9779 * null -> ''
9780 * undefined -> ''
9781 * true -> '1'
9782 * false -> '0'
9783 * 0 -> '0'
9784 * 1 -> '1'
9785 *
9786 */
9787
9788 /**
9789 * Prevent default
9790 *
9791 */
9792 const preventDefault = (evt, stop = false) => {
9793 if (evt) {
9794 evt.preventDefault();
9795 if (stop) {
9796 evt.stopPropagation();
9797 }
9798 }
9799 };
9800
9801 /**
9802 * Add event helper
9803 *
9804 */
9805 const addEvent = (target, type, callback, options) => {
9806 target.addEventListener(type, callback, options);
9807 };
9808
9809 /**
9810 * Iterates over arrays and hashes.
9811 *
9812 * ```
9813 * iterate(this.items, function(item, id) {
9814 * // invoked for each item
9815 * });
9816 * ```
9817 *
9818 */
9819 const iterate = (object, callback) => {
9820 if (Array.isArray(object)) {
9821 object.forEach(callback);
9822 } else {
9823 for (var key in object) {
9824 if (object.hasOwnProperty(key)) {
9825 callback(object[key], key);
9826 }
9827 }
9828 }
9829 };
9830
9831 /**
9832 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9833 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9834 *
9835 * param query should be {}
9836 */
9837 const getDom = query => {
9838 if (query.jquery) {
9839 return query[0];
9840 }
9841 if (query instanceof HTMLElement) {
9842 return query;
9843 }
9844 if (isHtmlString(query)) {
9845 var tpl = document.createElement('template');
9846 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9847 return tpl.content.firstChild;
9848 }
9849 return document.querySelector(query);
9850 };
9851 const isHtmlString = arg => {
9852 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9853 return true;
9854 }
9855 return false;
9856 };
9857
9858 /**
9859 * Add css classes
9860 *
9861 */
9862 const addClasses = (elmts, ...classes) => {
9863 var norm_classes = classesArray(classes);
9864 elmts = castAsArray(elmts);
9865 elmts.map(el => {
9866 norm_classes.map(cls => {
9867 el.classList.add(cls);
9868 });
9869 });
9870 };
9871
9872 /**
9873 * Return arguments
9874 *
9875 */
9876 const classesArray = args => {
9877 var classes = [];
9878 iterate(args, _classes => {
9879 if (typeof _classes === 'string') {
9880 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9881 }
9882 if (Array.isArray(_classes)) {
9883 classes = classes.concat(_classes);
9884 }
9885 });
9886 return classes.filter(Boolean);
9887 };
9888
9889 /**
9890 * Create an array from arg if it's not already an array
9891 *
9892 */
9893 const castAsArray = arg => {
9894 if (!Array.isArray(arg)) {
9895 arg = [arg];
9896 }
9897 return arg;
9898 };
9899
9900 /**
9901 * Plugin: "dropdown_input" (Tom Select)
9902 * Copyright (c) contributors
9903 *
9904 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9905 * file except in compliance with the License. You may obtain a copy of the License at:
9906 * http://www.apache.org/licenses/LICENSE-2.0
9907 *
9908 * Unless required by applicable law or agreed to in writing, software distributed under
9909 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9910 * ANY KIND, either express or implied. See the License for the specific language
9911 * governing permissions and limitations under the License.
9912 *
9913 */
9914
9915 function plugin () {
9916 const self = this;
9917 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
9918
9919 self.hook('before', 'setup', () => {
9920 self.focus_node = self.control;
9921 addClasses(self.control_input, 'dropdown-input');
9922 const div = getDom('<div class="dropdown-input-wrap">');
9923 div.append(self.control_input);
9924 self.dropdown.insertBefore(div, self.dropdown.firstChild);
9925
9926 // set a placeholder in the select control
9927 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
9928 placeholder.placeholder = self.settings.placeholder || '';
9929 self.control.append(placeholder);
9930 });
9931 self.on('initialize', () => {
9932 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
9933 self.control_input.addEventListener('keydown', evt => {
9934 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
9935 switch (evt.keyCode) {
9936 case KEY_ESC:
9937 if (self.isOpen) {
9938 preventDefault(evt, true);
9939 self.close();
9940 }
9941 self.clearActiveItems();
9942 return;
9943 case KEY_TAB:
9944 self.focus_node.tabIndex = -1;
9945 break;
9946 }
9947 return self.onKeyDown.call(self, evt);
9948 });
9949 self.on('blur', () => {
9950 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
9951 });
9952
9953 // give the control_input focus when the dropdown is open
9954 self.on('dropdown_open', () => {
9955 self.control_input.focus();
9956 });
9957
9958 // prevent onBlur from closing when focus is on the control_input
9959 const orig_onBlur = self.onBlur;
9960 self.hook('instead', 'onBlur', evt => {
9961 if (evt && evt.relatedTarget == self.control_input) return;
9962 return orig_onBlur.call(self);
9963 });
9964 addEvent(self.control_input, 'blur', () => self.onBlur());
9965
9966 // return focus to control to allow further keyboard input
9967 self.hook('before', 'close', () => {
9968 if (!self.isOpen) return;
9969 self.focus_node.focus({
9970 preventScroll: true
9971 });
9972 });
9973 });
9974 }
9975
9976
9977 //# sourceMappingURL=plugin.js.map
9978
9979
9980 /***/ },
9981
9982 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
9983 /*!***************************************************************************!*\
9984 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
9985 \***************************************************************************/
9986 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9987
9988 "use strict";
9989 __webpack_require__.r(__webpack_exports__);
9990 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9991 /* harmony export */ "default": () => (/* binding */ plugin)
9992 /* harmony export */ });
9993 /**
9994 * Tom Select v2.4.3
9995 * Licensed under the Apache License, Version 2.0 (the "License");
9996 */
9997
9998 /**
9999 * Converts a scalar to its best string representation
10000 * for hash keys and HTML attribute values.
10001 *
10002 * Transformations:
10003 * 'str' -> 'str'
10004 * null -> ''
10005 * undefined -> ''
10006 * true -> '1'
10007 * false -> '0'
10008 * 0 -> '0'
10009 * 1 -> '1'
10010 *
10011 */
10012
10013 /**
10014 * Add event helper
10015 *
10016 */
10017 const addEvent = (target, type, callback, options) => {
10018 target.addEventListener(type, callback, options);
10019 };
10020
10021 /**
10022 * Plugin: "input_autogrow" (Tom Select)
10023 *
10024 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10025 * file except in compliance with the License. You may obtain a copy of the License at:
10026 * http://www.apache.org/licenses/LICENSE-2.0
10027 *
10028 * Unless required by applicable law or agreed to in writing, software distributed under
10029 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10030 * ANY KIND, either express or implied. See the License for the specific language
10031 * governing permissions and limitations under the License.
10032 *
10033 */
10034
10035 function plugin () {
10036 var self = this;
10037 self.on('initialize', () => {
10038 var test_input = document.createElement('span');
10039 var control = self.control_input;
10040 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10041 self.wrapper.appendChild(test_input);
10042 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10043 for (const style_name of transfer_styles) {
10044 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10045 test_input.style[style_name] = control.style[style_name];
10046 }
10047
10048 /**
10049 * Set the control width
10050 *
10051 */
10052 var resize = () => {
10053 test_input.textContent = control.value;
10054 control.style.width = test_input.clientWidth + 'px';
10055 };
10056 resize();
10057 self.on('update item_add item_remove', resize);
10058 addEvent(control, 'input', resize);
10059 addEvent(control, 'keyup', resize);
10060 addEvent(control, 'blur', resize);
10061 addEvent(control, 'update', resize);
10062 });
10063 }
10064
10065
10066 //# sourceMappingURL=plugin.js.map
10067
10068
10069 /***/ },
10070
10071 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10072 /*!****************************************************************************!*\
10073 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10074 \****************************************************************************/
10075 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10076
10077 "use strict";
10078 __webpack_require__.r(__webpack_exports__);
10079 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10080 /* harmony export */ "default": () => (/* binding */ plugin)
10081 /* harmony export */ });
10082 /**
10083 * Tom Select v2.4.3
10084 * Licensed under the Apache License, Version 2.0 (the "License");
10085 */
10086
10087 /**
10088 * Plugin: "no_active_items" (Tom Select)
10089 *
10090 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10091 * file except in compliance with the License. You may obtain a copy of the License at:
10092 * http://www.apache.org/licenses/LICENSE-2.0
10093 *
10094 * Unless required by applicable law or agreed to in writing, software distributed under
10095 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10096 * ANY KIND, either express or implied. See the License for the specific language
10097 * governing permissions and limitations under the License.
10098 *
10099 */
10100
10101 function plugin () {
10102 this.hook('instead', 'setActiveItem', () => {});
10103 this.hook('instead', 'selectAll', () => {});
10104 }
10105
10106
10107 //# sourceMappingURL=plugin.js.map
10108
10109
10110 /***/ },
10111
10112 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10113 /*!********************************************************************************!*\
10114 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10115 \********************************************************************************/
10116 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10117
10118 "use strict";
10119 __webpack_require__.r(__webpack_exports__);
10120 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10121 /* harmony export */ "default": () => (/* binding */ plugin)
10122 /* harmony export */ });
10123 /**
10124 * Tom Select v2.4.3
10125 * Licensed under the Apache License, Version 2.0 (the "License");
10126 */
10127
10128 /**
10129 * Plugin: "input_autogrow" (Tom Select)
10130 *
10131 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10132 * file except in compliance with the License. You may obtain a copy of the License at:
10133 * http://www.apache.org/licenses/LICENSE-2.0
10134 *
10135 * Unless required by applicable law or agreed to in writing, software distributed under
10136 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10137 * ANY KIND, either express or implied. See the License for the specific language
10138 * governing permissions and limitations under the License.
10139 *
10140 */
10141
10142 function plugin () {
10143 var self = this;
10144 var orig_deleteSelection = self.deleteSelection;
10145 this.hook('instead', 'deleteSelection', evt => {
10146 if (self.activeItems.length) {
10147 return orig_deleteSelection.call(self, evt);
10148 }
10149 return false;
10150 });
10151 }
10152
10153
10154 //# sourceMappingURL=plugin.js.map
10155
10156
10157 /***/ },
10158
10159 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10160 /*!*****************************************************************************!*\
10161 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10162 \*****************************************************************************/
10163 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10164
10165 "use strict";
10166 __webpack_require__.r(__webpack_exports__);
10167 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10168 /* harmony export */ "default": () => (/* binding */ plugin)
10169 /* harmony export */ });
10170 /**
10171 * Tom Select v2.4.3
10172 * Licensed under the Apache License, Version 2.0 (the "License");
10173 */
10174
10175 const KEY_LEFT = 37;
10176 const KEY_RIGHT = 39;
10177 // ctrl key or apple key for ma
10178
10179 /**
10180 * Get the closest node to the evt.target matching the selector
10181 * Stops at wrapper
10182 *
10183 */
10184 const parentMatch = (target, selector, wrapper) => {
10185 while (target && target.matches) {
10186 if (target.matches(selector)) {
10187 return target;
10188 }
10189 target = target.parentNode;
10190 }
10191 };
10192
10193 /**
10194 * Get the index of an element amongst sibling nodes of the same type
10195 *
10196 */
10197 const nodeIndex = (el, amongst) => {
10198 if (!el) return -1;
10199 amongst = amongst || el.nodeName;
10200 var i = 0;
10201 while (el = el.previousElementSibling) {
10202 if (el.matches(amongst)) {
10203 i++;
10204 }
10205 }
10206 return i;
10207 };
10208
10209 /**
10210 * Plugin: "optgroup_columns" (Tom Select.js)
10211 * Copyright (c) contributors
10212 *
10213 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10214 * file except in compliance with the License. You may obtain a copy of the License at:
10215 * http://www.apache.org/licenses/LICENSE-2.0
10216 *
10217 * Unless required by applicable law or agreed to in writing, software distributed under
10218 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10219 * ANY KIND, either express or implied. See the License for the specific language
10220 * governing permissions and limitations under the License.
10221 *
10222 */
10223
10224 function plugin () {
10225 var self = this;
10226 var orig_keydown = self.onKeyDown;
10227 self.hook('instead', 'onKeyDown', evt => {
10228 var index, option, options, optgroup;
10229 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10230 return orig_keydown.call(self, evt);
10231 }
10232 self.ignoreHover = true;
10233 optgroup = parentMatch(self.activeOption, '[data-group]');
10234 index = nodeIndex(self.activeOption, '[data-selectable]');
10235 if (!optgroup) {
10236 return;
10237 }
10238 if (evt.keyCode === KEY_LEFT) {
10239 optgroup = optgroup.previousSibling;
10240 } else {
10241 optgroup = optgroup.nextSibling;
10242 }
10243 if (!optgroup) {
10244 return;
10245 }
10246 options = optgroup.querySelectorAll('[data-selectable]');
10247 option = options[Math.min(options.length - 1, index)];
10248 if (option) {
10249 self.setActiveOption(option);
10250 }
10251 });
10252 }
10253
10254
10255 //# sourceMappingURL=plugin.js.map
10256
10257
10258 /***/ },
10259
10260 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10261 /*!**************************************************************************!*\
10262 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10263 \**************************************************************************/
10264 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10265
10266 "use strict";
10267 __webpack_require__.r(__webpack_exports__);
10268 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10269 /* harmony export */ "default": () => (/* binding */ plugin)
10270 /* harmony export */ });
10271 /**
10272 * Tom Select v2.4.3
10273 * Licensed under the Apache License, Version 2.0 (the "License");
10274 */
10275
10276 /**
10277 * Converts a scalar to its best string representation
10278 * for hash keys and HTML attribute values.
10279 *
10280 * Transformations:
10281 * 'str' -> 'str'
10282 * null -> ''
10283 * undefined -> ''
10284 * true -> '1'
10285 * false -> '0'
10286 * 0 -> '0'
10287 * 1 -> '1'
10288 *
10289 */
10290
10291 /**
10292 * Escapes a string for use within HTML.
10293 *
10294 */
10295 const escape_html = str => {
10296 return (str + '').replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
10297 };
10298
10299 /**
10300 * Prevent default
10301 *
10302 */
10303 const preventDefault = (evt, stop = false) => {
10304 if (evt) {
10305 evt.preventDefault();
10306 if (stop) {
10307 evt.stopPropagation();
10308 }
10309 }
10310 };
10311
10312 /**
10313 * Add event helper
10314 *
10315 */
10316 const addEvent = (target, type, callback, options) => {
10317 target.addEventListener(type, callback, options);
10318 };
10319
10320 /**
10321 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10322 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10323 *
10324 * param query should be {}
10325 */
10326 const getDom = query => {
10327 if (query.jquery) {
10328 return query[0];
10329 }
10330 if (query instanceof HTMLElement) {
10331 return query;
10332 }
10333 if (isHtmlString(query)) {
10334 var tpl = document.createElement('template');
10335 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10336 return tpl.content.firstChild;
10337 }
10338 return document.querySelector(query);
10339 };
10340 const isHtmlString = arg => {
10341 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10342 return true;
10343 }
10344 return false;
10345 };
10346
10347 /**
10348 * Plugin: "remove_button" (Tom Select)
10349 * Copyright (c) contributors
10350 *
10351 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10352 * file except in compliance with the License. You may obtain a copy of the License at:
10353 * http://www.apache.org/licenses/LICENSE-2.0
10354 *
10355 * Unless required by applicable law or agreed to in writing, software distributed under
10356 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10357 * ANY KIND, either express or implied. See the License for the specific language
10358 * governing permissions and limitations under the License.
10359 *
10360 */
10361
10362 function plugin (userOptions) {
10363 const options = Object.assign({
10364 label: '&times;',
10365 title: 'Remove',
10366 className: 'remove',
10367 append: true
10368 }, userOptions);
10369
10370 //options.className = 'remove-single';
10371 var self = this;
10372
10373 // override the render method to add remove button to each item
10374 if (!options.append) {
10375 return;
10376 }
10377 var html = '<a href="javascript:void(0)" class="' + options.className + '" tabindex="-1" title="' + escape_html(options.title) + '">' + options.label + '</a>';
10378 self.hook('after', 'setupTemplates', () => {
10379 var orig_render_item = self.settings.render.item;
10380 self.settings.render.item = (data, escape) => {
10381 var item = getDom(orig_render_item.call(self, data, escape));
10382 var close_button = getDom(html);
10383 item.appendChild(close_button);
10384 addEvent(close_button, 'mousedown', evt => {
10385 preventDefault(evt, true);
10386 });
10387 addEvent(close_button, 'click', evt => {
10388 if (self.isLocked) return;
10389
10390 // propagating will trigger the dropdown to show for single mode
10391 preventDefault(evt, true);
10392 if (self.isLocked) return;
10393 if (!self.shouldDelete([item], evt)) return;
10394 self.removeItem(item);
10395 self.refreshOptions(false);
10396 self.inputState();
10397 });
10398 return item;
10399 };
10400 });
10401 }
10402
10403
10404 //# sourceMappingURL=plugin.js.map
10405
10406
10407 /***/ },
10408
10409 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10410 /*!*********************************************************************************!*\
10411 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10412 \*********************************************************************************/
10413 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10414
10415 "use strict";
10416 __webpack_require__.r(__webpack_exports__);
10417 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10418 /* harmony export */ "default": () => (/* binding */ plugin)
10419 /* harmony export */ });
10420 /**
10421 * Tom Select v2.4.3
10422 * Licensed under the Apache License, Version 2.0 (the "License");
10423 */
10424
10425 /**
10426 * Plugin: "restore_on_backspace" (Tom Select)
10427 * Copyright (c) contributors
10428 *
10429 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10430 * file except in compliance with the License. You may obtain a copy of the License at:
10431 * http://www.apache.org/licenses/LICENSE-2.0
10432 *
10433 * Unless required by applicable law or agreed to in writing, software distributed under
10434 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10435 * ANY KIND, either express or implied. See the License for the specific language
10436 * governing permissions and limitations under the License.
10437 *
10438 */
10439
10440 function plugin (userOptions) {
10441 const self = this;
10442 const options = Object.assign({
10443 text: option => {
10444 return option[self.settings.labelField];
10445 }
10446 }, userOptions);
10447 self.on('item_remove', function (value) {
10448 if (!self.isFocused) {
10449 return;
10450 }
10451 if (self.control_input.value.trim() === '') {
10452 var option = self.options[value];
10453 if (option) {
10454 self.setTextboxValue(options.text.call(self, option));
10455 }
10456 }
10457 });
10458 }
10459
10460
10461 //# sourceMappingURL=plugin.js.map
10462
10463
10464 /***/ },
10465
10466 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10467 /*!***************************************************************************!*\
10468 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10469 \***************************************************************************/
10470 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10471
10472 "use strict";
10473 __webpack_require__.r(__webpack_exports__);
10474 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10475 /* harmony export */ "default": () => (/* binding */ plugin)
10476 /* harmony export */ });
10477 /**
10478 * Tom Select v2.4.3
10479 * Licensed under the Apache License, Version 2.0 (the "License");
10480 */
10481
10482 /**
10483 * Converts a scalar to its best string representation
10484 * for hash keys and HTML attribute values.
10485 *
10486 * Transformations:
10487 * 'str' -> 'str'
10488 * null -> ''
10489 * undefined -> ''
10490 * true -> '1'
10491 * false -> '0'
10492 * 0 -> '0'
10493 * 1 -> '1'
10494 *
10495 */
10496
10497 /**
10498 * Iterates over arrays and hashes.
10499 *
10500 * ```
10501 * iterate(this.items, function(item, id) {
10502 * // invoked for each item
10503 * });
10504 * ```
10505 *
10506 */
10507 const iterate = (object, callback) => {
10508 if (Array.isArray(object)) {
10509 object.forEach(callback);
10510 } else {
10511 for (var key in object) {
10512 if (object.hasOwnProperty(key)) {
10513 callback(object[key], key);
10514 }
10515 }
10516 }
10517 };
10518
10519 /**
10520 * Add css classes
10521 *
10522 */
10523 const addClasses = (elmts, ...classes) => {
10524 var norm_classes = classesArray(classes);
10525 elmts = castAsArray(elmts);
10526 elmts.map(el => {
10527 norm_classes.map(cls => {
10528 el.classList.add(cls);
10529 });
10530 });
10531 };
10532
10533 /**
10534 * Return arguments
10535 *
10536 */
10537 const classesArray = args => {
10538 var classes = [];
10539 iterate(args, _classes => {
10540 if (typeof _classes === 'string') {
10541 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10542 }
10543 if (Array.isArray(_classes)) {
10544 classes = classes.concat(_classes);
10545 }
10546 });
10547 return classes.filter(Boolean);
10548 };
10549
10550 /**
10551 * Create an array from arg if it's not already an array
10552 *
10553 */
10554 const castAsArray = arg => {
10555 if (!Array.isArray(arg)) {
10556 arg = [arg];
10557 }
10558 return arg;
10559 };
10560
10561 /**
10562 * Plugin: "restore_on_backspace" (Tom Select)
10563 * Copyright (c) contributors
10564 *
10565 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10566 * file except in compliance with the License. You may obtain a copy of the License at:
10567 * http://www.apache.org/licenses/LICENSE-2.0
10568 *
10569 * Unless required by applicable law or agreed to in writing, software distributed under
10570 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10571 * ANY KIND, either express or implied. See the License for the specific language
10572 * governing permissions and limitations under the License.
10573 *
10574 */
10575
10576 function plugin () {
10577 const self = this;
10578 const orig_canLoad = self.canLoad;
10579 const orig_clearActiveOption = self.clearActiveOption;
10580 const orig_loadCallback = self.loadCallback;
10581 var pagination = {};
10582 var dropdown_content;
10583 var loading_more = false;
10584 var load_more_opt;
10585 var default_values = [];
10586 if (!self.settings.shouldLoadMore) {
10587 // return true if additional results should be loaded
10588 self.settings.shouldLoadMore = () => {
10589 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
10590 if (scroll_percent > 0.9) {
10591 return true;
10592 }
10593 if (self.activeOption) {
10594 var selectable = self.selectable();
10595 var index = Array.from(selectable).indexOf(self.activeOption);
10596 if (index >= selectable.length - 2) {
10597 return true;
10598 }
10599 }
10600 return false;
10601 };
10602 }
10603 if (!self.settings.firstUrl) {
10604 throw 'virtual_scroll plugin requires a firstUrl() method';
10605 }
10606
10607 // in order for virtual scrolling to work,
10608 // options need to be ordered the same way they're returned from the remote data source
10609 self.settings.sortField = [{
10610 field: '$order'
10611 }, {
10612 field: '$score'
10613 }];
10614
10615 // can we load more results for given query?
10616 const canLoadMore = query => {
10617 if (typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
10618 return false;
10619 }
10620 if (query in pagination && pagination[query]) {
10621 return true;
10622 }
10623 return false;
10624 };
10625 const clearFilter = (option, value) => {
10626 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
10627 return true;
10628 }
10629 return false;
10630 };
10631
10632 // set the next url that will be
10633 self.setNextUrl = (value, next_url) => {
10634 pagination[value] = next_url;
10635 };
10636
10637 // getUrl() to be used in settings.load()
10638 self.getUrl = query => {
10639 if (query in pagination) {
10640 const next_url = pagination[query];
10641 pagination[query] = false;
10642 return next_url;
10643 }
10644
10645 // if the user goes back to a previous query
10646 // we need to load the first page again
10647 self.clearPagination();
10648 return self.settings.firstUrl.call(self, query);
10649 };
10650
10651 // clear pagination
10652 self.clearPagination = () => {
10653 pagination = {};
10654 };
10655
10656 // don't clear the active option (and cause unwanted dropdown scroll)
10657 // while loading more results
10658 self.hook('instead', 'clearActiveOption', () => {
10659 if (loading_more) {
10660 return;
10661 }
10662 return orig_clearActiveOption.call(self);
10663 });
10664
10665 // override the canLoad method
10666 self.hook('instead', 'canLoad', query => {
10667 // first time the query has been seen
10668 if (!(query in pagination)) {
10669 return orig_canLoad.call(self, query);
10670 }
10671 return canLoadMore(query);
10672 });
10673
10674 // wrap the load
10675 self.hook('instead', 'loadCallback', (options, optgroups) => {
10676 if (!loading_more) {
10677 self.clearOptions(clearFilter);
10678 } else if (load_more_opt) {
10679 const first_option = options[0];
10680 if (first_option !== undefined) {
10681 load_more_opt.dataset.value = first_option[self.settings.valueField];
10682 }
10683 }
10684 orig_loadCallback.call(self, options, optgroups);
10685 loading_more = false;
10686 });
10687
10688 // add templates to dropdown
10689 // loading_more if we have another url in the queue
10690 // no_more_results if we don't have another url in the queue
10691 self.hook('after', 'refreshOptions', () => {
10692 const query = self.lastValue;
10693 var option;
10694 if (canLoadMore(query)) {
10695 option = self.render('loading_more', {
10696 query: query
10697 });
10698 if (option) {
10699 option.setAttribute('data-selectable', ''); // so that navigating dropdown with [down] keypresses can navigate to this node
10700 load_more_opt = option;
10701 }
10702 } else if (query in pagination && !dropdown_content.querySelector('.no-results')) {
10703 option = self.render('no_more_results', {
10704 query: query
10705 });
10706 }
10707 if (option) {
10708 addClasses(option, self.settings.optionClass);
10709 dropdown_content.append(option);
10710 }
10711 });
10712
10713 // add scroll listener and default templates
10714 self.on('initialize', () => {
10715 default_values = Object.keys(self.options);
10716 dropdown_content = self.dropdown_content;
10717
10718 // default templates
10719 self.settings.render = Object.assign({}, {
10720 loading_more: () => {
10721 return `<div class="loading-more-results">Loading more results ... </div>`;
10722 },
10723 no_more_results: () => {
10724 return `<div class="no-more-results">No more results</div>`;
10725 }
10726 }, self.settings.render);
10727
10728 // watch dropdown content scroll position
10729 dropdown_content.addEventListener('scroll', () => {
10730 if (!self.settings.shouldLoadMore.call(self)) {
10731 return;
10732 }
10733
10734 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
10735 if (!canLoadMore(self.lastValue)) {
10736 return;
10737 }
10738
10739 // don't call load() too much
10740 if (loading_more) return;
10741 loading_more = true;
10742 self.load.call(self, self.lastValue);
10743 });
10744 });
10745 }
10746
10747
10748 //# sourceMappingURL=plugin.js.map
10749
10750
10751 /***/ },
10752
10753 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
10754 /*!*****************************************************************!*\
10755 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
10756 \*****************************************************************/
10757 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10758
10759 "use strict";
10760 __webpack_require__.r(__webpack_exports__);
10761 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10762 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10763 /* harmony export */ });
10764 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
10765 /* 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");
10766 /* 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");
10767 /* 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");
10768 /* 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");
10769 /* 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");
10770 /* 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");
10771 /* 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");
10772 /* 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");
10773 /* 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");
10774 /* 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");
10775 /* 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");
10776 /* 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");
10777 /* 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");
10778 /* 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");
10779
10780
10781
10782
10783
10784
10785
10786
10787
10788
10789
10790
10791
10792
10793
10794 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
10795 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
10796 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
10797 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
10798 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
10799 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
10800 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
10801 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
10802 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
10803 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
10804 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
10805 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
10806 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
10807 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
10808 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
10809 //# sourceMappingURL=tom-select.complete.js.map
10810
10811 /***/ },
10812
10813 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
10814 /*!********************************************************!*\
10815 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
10816 \********************************************************/
10817 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10818
10819 "use strict";
10820 __webpack_require__.r(__webpack_exports__);
10821 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10822 /* harmony export */ "default": () => (/* binding */ TomSelect)
10823 /* harmony export */ });
10824 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
10825 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
10826 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
10827 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10828 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
10829 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
10830 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
10831 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
10832 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
10833
10834
10835
10836
10837
10838
10839
10840
10841
10842 var instance_i = 0;
10843 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
10844 constructor(input_arg, user_settings) {
10845 super();
10846 this.order = 0;
10847 this.isOpen = false;
10848 this.isDisabled = false;
10849 this.isReadOnly = false;
10850 this.isInvalid = false; // @deprecated 1.8
10851 this.isValid = true;
10852 this.isLocked = false;
10853 this.isFocused = false;
10854 this.isInputHidden = false;
10855 this.isSetup = false;
10856 this.ignoreFocus = false;
10857 this.ignoreHover = false;
10858 this.hasOptions = false;
10859 this.lastValue = '';
10860 this.caretPos = 0;
10861 this.loading = 0;
10862 this.loadedSearches = {};
10863 this.activeOption = null;
10864 this.activeItems = [];
10865 this.optgroups = {};
10866 this.options = {};
10867 this.userOptions = {};
10868 this.items = [];
10869 this.refreshTimeout = null;
10870 instance_i++;
10871 var dir;
10872 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
10873 if (input.tomselect) {
10874 throw new Error('Tom Select already initialized on this element');
10875 }
10876 input.tomselect = this;
10877 // detect rtl environment
10878 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
10879 dir = computedStyle.getPropertyValue('direction');
10880 // setup default state
10881 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
10882 this.settings = settings;
10883 this.input = input;
10884 this.tabIndex = input.tabIndex || 0;
10885 this.is_select_tag = input.tagName.toLowerCase() === 'select';
10886 this.rtl = /rtl/i.test(dir);
10887 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
10888 this.isRequired = input.required;
10889 // search system
10890 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
10891 // option-dependent defaults
10892 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
10893 if (typeof settings.hideSelected !== 'boolean') {
10894 settings.hideSelected = settings.mode === 'multi';
10895 }
10896 if (typeof settings.hidePlaceholder !== 'boolean') {
10897 settings.hidePlaceholder = settings.mode !== 'multi';
10898 }
10899 // set up createFilter callback
10900 var filter = settings.createFilter;
10901 if (typeof filter !== 'function') {
10902 if (typeof filter === 'string') {
10903 filter = new RegExp(filter);
10904 }
10905 if (filter instanceof RegExp) {
10906 settings.createFilter = (input) => filter.test(input);
10907 }
10908 else {
10909 settings.createFilter = (value) => {
10910 return this.settings.duplicates || !this.options[value];
10911 };
10912 }
10913 }
10914 this.initializePlugins(settings.plugins);
10915 this.setupCallbacks();
10916 this.setupTemplates();
10917 // Create all elements
10918 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10919 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10920 const dropdown = this._render('dropdown');
10921 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
10922 const classes = this.input.getAttribute('class') || '';
10923 const inputMode = settings.mode;
10924 var control_input;
10925 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
10926 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
10927 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
10928 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
10929 if (settings.copyClassesToDropdown) {
10930 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
10931 }
10932 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
10933 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
10934 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
10935 // default controlInput
10936 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
10937 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10938 // set attributes
10939 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck'];
10940 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
10941 if (input.getAttribute(attr)) {
10942 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
10943 }
10944 });
10945 control_input.tabIndex = -1;
10946 control.appendChild(control_input);
10947 this.focus_node = control_input;
10948 // dom element
10949 }
10950 else if (settings.controlInput) {
10951 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10952 this.focus_node = control_input;
10953 }
10954 else {
10955 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
10956 this.focus_node = control;
10957 }
10958 this.wrapper = wrapper;
10959 this.dropdown = dropdown;
10960 this.dropdown_content = dropdown_content;
10961 this.control = control;
10962 this.control_input = control_input;
10963 this.setup();
10964 }
10965 /**
10966 * set up event bindings.
10967 *
10968 */
10969 setup() {
10970 const self = this;
10971 const settings = self.settings;
10972 const control_input = self.control_input;
10973 const dropdown = self.dropdown;
10974 const dropdown_content = self.dropdown_content;
10975 const wrapper = self.wrapper;
10976 const control = self.control;
10977 const input = self.input;
10978 const focus_node = self.focus_node;
10979 const passive_event = { passive: true };
10980 const listboxId = self.inputId + '-ts-dropdown';
10981 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
10982 id: listboxId
10983 });
10984 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
10985 role: 'combobox',
10986 'aria-haspopup': 'listbox',
10987 'aria-expanded': 'false',
10988 'aria-controls': listboxId
10989 });
10990 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
10991 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
10992 const label = document.querySelector(query);
10993 const label_click = self.focus.bind(self);
10994 if (label) {
10995 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
10996 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
10997 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
10998 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
10999 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11000 }
11001 wrapper.style.width = input.style.width;
11002 if (self.plugins.names.length) {
11003 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11004 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11005 }
11006 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11007 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11008 }
11009 if (settings.placeholder) {
11010 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11011 }
11012 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11013 if (!settings.splitOn && settings.delimiter) {
11014 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11015 }
11016 // debounce user defined load() if loadThrottle > 0
11017 // after initializePlugins() so plugins can create/modify user defined loaders
11018 if (settings.load && settings.loadThrottle) {
11019 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11020 }
11021 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11022 self.ignoreHover = false;
11023 });
11024 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11025 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11026 if (target_match)
11027 self.onOptionHover(e, target_match);
11028 }, { capture: true });
11029 // clicking on an option should select it
11030 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11031 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11032 if (option) {
11033 self.onOptionSelect(evt, option);
11034 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11035 }
11036 });
11037 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11038 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11039 if (target_match && self.onItemSelect(evt, target_match)) {
11040 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11041 return;
11042 }
11043 // retain focus (see control_input mousedown)
11044 if (control_input.value != '') {
11045 return;
11046 }
11047 self.onClick();
11048 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11049 });
11050 // keydown on focus_node for arrow_down/arrow_up
11051 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11052 // keypress and input/keyup
11053 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11054 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11055 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11056 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11057 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11058 const doc_mousedown = (evt) => {
11059 // blur if target is outside of this instance
11060 // dropdown is not always inside wrapper
11061 const target = evt.composedPath()[0];
11062 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11063 if (self.isFocused) {
11064 self.blur();
11065 }
11066 self.inputState();
11067 return;
11068 }
11069 // retain focus by preventing native handling. if the
11070 // event target is the input it should not be modified.
11071 // otherwise, text selection within the input won't work.
11072 // Fixes bug #212 which is no covered by tests
11073 if (target == control_input && self.isOpen) {
11074 evt.stopPropagation();
11075 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11076 }
11077 else {
11078 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11079 }
11080 };
11081 const win_scroll = () => {
11082 if (self.isOpen) {
11083 self.positionDropdown();
11084 }
11085 };
11086 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11087 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11088 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11089 this._destroy = () => {
11090 document.removeEventListener('mousedown', doc_mousedown);
11091 window.removeEventListener('scroll', win_scroll);
11092 window.removeEventListener('resize', win_scroll);
11093 if (label)
11094 label.removeEventListener('click', label_click);
11095 };
11096 // store original html and tab index so that they can be
11097 // restored when the destroy() method is called.
11098 this.revertSettings = {
11099 innerHTML: input.innerHTML,
11100 tabIndex: input.tabIndex
11101 };
11102 input.tabIndex = -1;
11103 input.insertAdjacentElement('afterend', self.wrapper);
11104 self.sync(false);
11105 settings.items = [];
11106 delete settings.optgroups;
11107 delete settings.options;
11108 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', () => {
11109 if (self.isValid) {
11110 self.isValid = false;
11111 self.isInvalid = true;
11112 self.refreshState();
11113 }
11114 });
11115 self.updateOriginalInput();
11116 self.refreshItems();
11117 self.close(false);
11118 self.inputState();
11119 self.isSetup = true;
11120 if (input.disabled) {
11121 self.disable();
11122 }
11123 else if (input.readOnly) {
11124 self.setReadOnly(true);
11125 }
11126 else {
11127 self.enable(); //sets tabIndex
11128 }
11129 self.on('change', this.onChange);
11130 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11131 self.trigger('initialize');
11132 // preload options
11133 if (settings.preload === true) {
11134 self.preload();
11135 }
11136 }
11137 /**
11138 * Register options and optgroups
11139 *
11140 */
11141 setupOptions(options = [], optgroups = []) {
11142 // build options table
11143 this.addOptions(options);
11144 // build optgroup table
11145 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11146 this.registerOptionGroup(optgroup);
11147 });
11148 }
11149 /**
11150 * Sets up default rendering functions.
11151 */
11152 setupTemplates() {
11153 var self = this;
11154 var field_label = self.settings.labelField;
11155 var field_optgroup = self.settings.optgroupLabelField;
11156 var templates = {
11157 'optgroup': (data) => {
11158 let optgroup = document.createElement('div');
11159 optgroup.className = 'optgroup';
11160 optgroup.appendChild(data.options);
11161 return optgroup;
11162 },
11163 'optgroup_header': (data, escape) => {
11164 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11165 },
11166 'option': (data, escape) => {
11167 return '<div>' + escape(data[field_label]) + '</div>';
11168 },
11169 'item': (data, escape) => {
11170 return '<div>' + escape(data[field_label]) + '</div>';
11171 },
11172 'option_create': (data, escape) => {
11173 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11174 },
11175 'no_results': () => {
11176 return '<div class="no-results">No results found</div>';
11177 },
11178 'loading': () => {
11179 return '<div class="spinner"></div>';
11180 },
11181 'not_loading': () => { },
11182 'dropdown': () => {
11183 return '<div></div>';
11184 }
11185 };
11186 self.settings.render = Object.assign({}, templates, self.settings.render);
11187 }
11188 /**
11189 * Maps fired events to callbacks provided
11190 * in the settings used when creating the control.
11191 */
11192 setupCallbacks() {
11193 var key, fn;
11194 var callbacks = {
11195 'initialize': 'onInitialize',
11196 'change': 'onChange',
11197 'item_add': 'onItemAdd',
11198 'item_remove': 'onItemRemove',
11199 'item_select': 'onItemSelect',
11200 'clear': 'onClear',
11201 'option_add': 'onOptionAdd',
11202 'option_remove': 'onOptionRemove',
11203 'option_clear': 'onOptionClear',
11204 'optgroup_add': 'onOptionGroupAdd',
11205 'optgroup_remove': 'onOptionGroupRemove',
11206 'optgroup_clear': 'onOptionGroupClear',
11207 'dropdown_open': 'onDropdownOpen',
11208 'dropdown_close': 'onDropdownClose',
11209 'type': 'onType',
11210 'load': 'onLoad',
11211 'focus': 'onFocus',
11212 'blur': 'onBlur'
11213 };
11214 for (key in callbacks) {
11215 fn = this.settings[callbacks[key]];
11216 if (fn)
11217 this.on(key, fn);
11218 }
11219 }
11220 /**
11221 * Sync the Tom Select instance with the original input or select
11222 *
11223 */
11224 sync(get_settings = true) {
11225 const self = this;
11226 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter }) : self.settings;
11227 self.setupOptions(settings.options, settings.optgroups);
11228 self.setValue(settings.items || [], true); // silent prevents recursion
11229 self.lastQuery = null; // so updated options will be displayed in dropdown
11230 }
11231 /**
11232 * Triggered when the main control element
11233 * has a click event.
11234 *
11235 */
11236 onClick() {
11237 var self = this;
11238 if (self.activeItems.length > 0) {
11239 self.clearActiveItems();
11240 self.focus();
11241 return;
11242 }
11243 if (self.isFocused && self.isOpen) {
11244 self.blur();
11245 }
11246 else {
11247 self.focus();
11248 }
11249 }
11250 /**
11251 * @deprecated v1.7
11252 *
11253 */
11254 onMouseDown() { }
11255 /**
11256 * Triggered when the value of the control has been changed.
11257 * This should propagate the event to the original DOM
11258 * input / select element.
11259 */
11260 onChange() {
11261 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11262 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11263 }
11264 /**
11265 * Triggered on <input> paste.
11266 *
11267 */
11268 onPaste(e) {
11269 var self = this;
11270 if (self.isInputHidden || self.isLocked) {
11271 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11272 return;
11273 }
11274 // If a regex or string is included, this will split the pasted
11275 // input and create Items for each separate value
11276 if (!self.settings.splitOn) {
11277 return;
11278 }
11279 // Wait for pasted text to be recognized in value
11280 setTimeout(() => {
11281 var pastedText = self.inputValue();
11282 if (!pastedText.match(self.settings.splitOn)) {
11283 return;
11284 }
11285 var splitInput = pastedText.trim().split(self.settings.splitOn);
11286 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11287 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11288 if (hash) {
11289 if (this.options[piece]) {
11290 self.addItem(piece);
11291 }
11292 else {
11293 self.createItem(piece);
11294 }
11295 }
11296 });
11297 }, 0);
11298 }
11299 /**
11300 * Triggered on <input> keypress.
11301 *
11302 */
11303 onKeyPress(e) {
11304 var self = this;
11305 if (self.isLocked) {
11306 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11307 return;
11308 }
11309 var character = String.fromCharCode(e.keyCode || e.which);
11310 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11311 self.createItem();
11312 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11313 return;
11314 }
11315 }
11316 /**
11317 * Triggered on <input> keydown.
11318 *
11319 */
11320 onKeyDown(e) {
11321 var self = this;
11322 self.ignoreHover = true;
11323 if (self.isLocked) {
11324 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11325 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11326 }
11327 return;
11328 }
11329 switch (e.keyCode) {
11330 // ctrl+A: select all
11331 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11332 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11333 if (self.control_input.value == '') {
11334 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11335 self.selectAll();
11336 return;
11337 }
11338 }
11339 break;
11340 // esc: close dropdown
11341 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11342 if (self.isOpen) {
11343 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11344 self.close();
11345 }
11346 self.clearActiveItems();
11347 return;
11348 // down: open dropdown or move selection down
11349 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11350 if (!self.isOpen && self.hasOptions) {
11351 self.open();
11352 }
11353 else if (self.activeOption) {
11354 let next = self.getAdjacent(self.activeOption, 1);
11355 if (next)
11356 self.setActiveOption(next);
11357 }
11358 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11359 return;
11360 // up: move selection up
11361 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11362 if (self.activeOption) {
11363 let prev = self.getAdjacent(self.activeOption, -1);
11364 if (prev)
11365 self.setActiveOption(prev);
11366 }
11367 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11368 return;
11369 // return: select active option
11370 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11371 if (self.canSelect(self.activeOption)) {
11372 self.onOptionSelect(e, self.activeOption);
11373 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11374 // if the option_create=null, the dropdown might be closed
11375 }
11376 else if (self.settings.create && self.createItem()) {
11377 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11378 // don't submit form when searching for a value
11379 }
11380 else if (document.activeElement == self.control_input && self.isOpen) {
11381 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11382 }
11383 return;
11384 // left: modifiy item selection to the left
11385 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11386 self.advanceSelection(-1, e);
11387 return;
11388 // right: modifiy item selection to the right
11389 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11390 self.advanceSelection(1, e);
11391 return;
11392 // tab: select active option and/or create item
11393 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11394 if (self.settings.selectOnTab) {
11395 if (self.canSelect(self.activeOption)) {
11396 self.onOptionSelect(e, self.activeOption);
11397 // prevent default [tab] behaviour of jump to the next field
11398 // if select isFull, then the dropdown won't be open and [tab] will work normally
11399 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11400 }
11401 if (self.settings.create && self.createItem()) {
11402 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11403 }
11404 }
11405 return;
11406 // delete|backspace: delete items
11407 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11408 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11409 self.deleteSelection(e);
11410 return;
11411 }
11412 // don't enter text in the control_input when active items are selected
11413 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11414 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11415 }
11416 }
11417 /**
11418 * Triggered on <input> keyup.
11419 *
11420 */
11421 onInput(e) {
11422 if (this.isLocked) {
11423 return;
11424 }
11425 const value = this.inputValue();
11426 if (this.lastValue === value)
11427 return;
11428 this.lastValue = value;
11429 if (value == '') {
11430 this._onInput();
11431 return;
11432 }
11433 if (this.refreshTimeout) {
11434 window.clearTimeout(this.refreshTimeout);
11435 }
11436 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11437 this.refreshTimeout = null;
11438 this._onInput();
11439 }, this.settings.refreshThrottle);
11440 }
11441 _onInput() {
11442 const value = this.lastValue;
11443 if (this.settings.shouldLoad.call(this, value)) {
11444 this.load(value);
11445 }
11446 this.refreshOptions();
11447 this.trigger('type', value);
11448 }
11449 /**
11450 * Triggered when the user rolls over
11451 * an option in the autocomplete dropdown menu.
11452 *
11453 */
11454 onOptionHover(evt, option) {
11455 if (this.ignoreHover)
11456 return;
11457 this.setActiveOption(option, false);
11458 }
11459 /**
11460 * Triggered on <input> focus.
11461 *
11462 */
11463 onFocus(e) {
11464 var self = this;
11465 var wasFocused = self.isFocused;
11466 if (self.isDisabled || self.isReadOnly) {
11467 self.blur();
11468 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11469 return;
11470 }
11471 if (self.ignoreFocus)
11472 return;
11473 self.isFocused = true;
11474 if (self.settings.preload === 'focus')
11475 self.preload();
11476 if (!wasFocused)
11477 self.trigger('focus');
11478 if (!self.activeItems.length) {
11479 self.inputState();
11480 self.refreshOptions(!!self.settings.openOnFocus);
11481 }
11482 self.refreshState();
11483 }
11484 /**
11485 * Triggered on <input> blur.
11486 *
11487 */
11488 onBlur(e) {
11489 if (document.hasFocus() === false)
11490 return;
11491 var self = this;
11492 if (!self.isFocused)
11493 return;
11494 self.isFocused = false;
11495 self.ignoreFocus = false;
11496 var deactivate = () => {
11497 self.close();
11498 self.setActiveItem();
11499 self.setCaret(self.items.length);
11500 self.trigger('blur');
11501 };
11502 if (self.settings.create && self.settings.createOnBlur) {
11503 self.createItem(null, deactivate);
11504 }
11505 else {
11506 deactivate();
11507 }
11508 }
11509 /**
11510 * Triggered when the user clicks on an option
11511 * in the autocomplete dropdown menu.
11512 *
11513 */
11514 onOptionSelect(evt, option) {
11515 var value, self = this;
11516 // should not be possible to trigger a option under a disabled optgroup
11517 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
11518 return;
11519 }
11520 if (option.classList.contains('create')) {
11521 self.createItem(null, () => {
11522 if (self.settings.closeAfterSelect) {
11523 self.close();
11524 }
11525 });
11526 }
11527 else {
11528 value = option.dataset.value;
11529 if (typeof value !== 'undefined') {
11530 self.lastQuery = null;
11531 self.addItem(value);
11532 if (self.settings.closeAfterSelect) {
11533 self.close();
11534 }
11535 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
11536 self.setActiveOption(option);
11537 }
11538 }
11539 }
11540 }
11541 /**
11542 * Return true if the given option can be selected
11543 *
11544 */
11545 canSelect(option) {
11546 if (this.isOpen && option && this.dropdown_content.contains(option)) {
11547 return true;
11548 }
11549 return false;
11550 }
11551 /**
11552 * Triggered when the user clicks on an item
11553 * that has been selected.
11554 *
11555 */
11556 onItemSelect(evt, item) {
11557 var self = this;
11558 if (!self.isLocked && self.settings.mode === 'multi') {
11559 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
11560 self.setActiveItem(item, evt);
11561 return true;
11562 }
11563 return false;
11564 }
11565 /**
11566 * Determines whether or not to invoke
11567 * the user-provided option provider / loader
11568 *
11569 * Note, there is a subtle difference between
11570 * this.canLoad() and this.settings.shouldLoad();
11571 *
11572 * - settings.shouldLoad() is a user-input validator.
11573 * When false is returned, the not_loading template
11574 * will be added to the dropdown
11575 *
11576 * - canLoad() is lower level validator that checks
11577 * the Tom Select instance. There is no inherent user
11578 * feedback when canLoad returns false
11579 *
11580 */
11581 canLoad(value) {
11582 if (!this.settings.load)
11583 return false;
11584 if (this.loadedSearches.hasOwnProperty(value))
11585 return false;
11586 return true;
11587 }
11588 /**
11589 * Invokes the user-provided option provider / loader.
11590 *
11591 */
11592 load(value) {
11593 const self = this;
11594 if (!self.canLoad(value))
11595 return;
11596 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
11597 self.loading++;
11598 const callback = self.loadCallback.bind(self);
11599 self.settings.load.call(self, value, callback);
11600 }
11601 /**
11602 * Invoked by the user-provided option provider
11603 *
11604 */
11605 loadCallback(options, optgroups) {
11606 const self = this;
11607 self.loading = Math.max(self.loading - 1, 0);
11608 self.lastQuery = null;
11609 self.clearActiveOption(); // when new results load, focus should be on first option
11610 self.setupOptions(options, optgroups);
11611 self.refreshOptions(self.isFocused && !self.isInputHidden);
11612 if (!self.loading) {
11613 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
11614 }
11615 self.trigger('load', options, optgroups);
11616 }
11617 preload() {
11618 var classList = this.wrapper.classList;
11619 if (classList.contains('preloaded'))
11620 return;
11621 classList.add('preloaded');
11622 this.load('');
11623 }
11624 /**
11625 * Sets the input field of the control to the specified value.
11626 *
11627 */
11628 setTextboxValue(value = '') {
11629 var input = this.control_input;
11630 var changed = input.value !== value;
11631 if (changed) {
11632 input.value = value;
11633 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
11634 this.lastValue = value;
11635 }
11636 }
11637 /**
11638 * Returns the value of the control. If multiple items
11639 * can be selected (e.g. <select multiple>), this returns
11640 * an array. If only one item can be selected, this
11641 * returns a string.
11642 *
11643 */
11644 getValue() {
11645 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
11646 return this.items;
11647 }
11648 return this.items.join(this.settings.delimiter);
11649 }
11650 /**
11651 * Resets the selected items to the given value.
11652 *
11653 */
11654 setValue(value, silent) {
11655 var events = silent ? [] : ['change'];
11656 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
11657 this.clear(silent);
11658 this.addItems(value, silent);
11659 });
11660 }
11661 /**
11662 * Resets the number of max items to the given value
11663 *
11664 */
11665 setMaxItems(value) {
11666 if (value === 0)
11667 value = null; //reset to unlimited items.
11668 this.settings.maxItems = value;
11669 this.refreshState();
11670 }
11671 /**
11672 * Sets the selected item.
11673 *
11674 */
11675 setActiveItem(item, e) {
11676 var self = this;
11677 var eventName;
11678 var i, begin, end, swap;
11679 var last;
11680 if (self.settings.mode === 'single')
11681 return;
11682 // clear the active selection
11683 if (!item) {
11684 self.clearActiveItems();
11685 if (self.isFocused) {
11686 self.inputState();
11687 }
11688 return;
11689 }
11690 // modify selection
11691 eventName = e && e.type.toLowerCase();
11692 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
11693 last = self.getLastActive();
11694 begin = Array.prototype.indexOf.call(self.control.children, last);
11695 end = Array.prototype.indexOf.call(self.control.children, item);
11696 if (begin > end) {
11697 swap = begin;
11698 begin = end;
11699 end = swap;
11700 }
11701 for (i = begin; i <= end; i++) {
11702 item = self.control.children[i];
11703 if (self.activeItems.indexOf(item) === -1) {
11704 self.setActiveItemClass(item);
11705 }
11706 }
11707 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11708 }
11709 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))) {
11710 if (item.classList.contains('active')) {
11711 self.removeActiveItem(item);
11712 }
11713 else {
11714 self.setActiveItemClass(item);
11715 }
11716 }
11717 else {
11718 self.clearActiveItems();
11719 self.setActiveItemClass(item);
11720 }
11721 // ensure control has focus
11722 self.inputState();
11723 if (!self.isFocused) {
11724 self.focus();
11725 }
11726 }
11727 /**
11728 * Set the active and last-active classes
11729 *
11730 */
11731 setActiveItemClass(item) {
11732 const self = this;
11733 const last_active = self.control.querySelector('.last-active');
11734 if (last_active)
11735 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
11736 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
11737 self.trigger('item_select', item);
11738 if (self.activeItems.indexOf(item) == -1) {
11739 self.activeItems.push(item);
11740 }
11741 }
11742 /**
11743 * Remove active item
11744 *
11745 */
11746 removeActiveItem(item) {
11747 var idx = this.activeItems.indexOf(item);
11748 this.activeItems.splice(idx, 1);
11749 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
11750 }
11751 /**
11752 * Clears all the active items
11753 *
11754 */
11755 clearActiveItems() {
11756 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
11757 this.activeItems = [];
11758 }
11759 /**
11760 * Sets the selected item in the dropdown menu
11761 * of available options.
11762 *
11763 */
11764 setActiveOption(option, scroll = true) {
11765 if (option === this.activeOption) {
11766 return;
11767 }
11768 this.clearActiveOption();
11769 if (!option)
11770 return;
11771 this.activeOption = option;
11772 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
11773 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
11774 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
11775 if (scroll)
11776 this.scrollToOption(option);
11777 }
11778 /**
11779 * Sets the dropdown_content scrollTop to display the option
11780 *
11781 */
11782 scrollToOption(option, behavior) {
11783 if (!option)
11784 return;
11785 const content = this.dropdown_content;
11786 const height_menu = content.clientHeight;
11787 const scrollTop = content.scrollTop || 0;
11788 const height_item = option.offsetHeight;
11789 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
11790 if (y + height_item > height_menu + scrollTop) {
11791 this.scroll(y - height_menu + height_item, behavior);
11792 }
11793 else if (y < scrollTop) {
11794 this.scroll(y, behavior);
11795 }
11796 }
11797 /**
11798 * Scroll the dropdown to the given position
11799 *
11800 */
11801 scroll(scrollTop, behavior) {
11802 const content = this.dropdown_content;
11803 if (behavior) {
11804 content.style.scrollBehavior = behavior;
11805 }
11806 content.scrollTop = scrollTop;
11807 content.style.scrollBehavior = '';
11808 }
11809 /**
11810 * Clears the active option
11811 *
11812 */
11813 clearActiveOption() {
11814 if (this.activeOption) {
11815 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
11816 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
11817 }
11818 this.activeOption = null;
11819 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
11820 }
11821 /**
11822 * Selects all items (CTRL + A).
11823 */
11824 selectAll() {
11825 const self = this;
11826 if (self.settings.mode === 'single')
11827 return;
11828 const activeItems = self.controlChildren();
11829 if (!activeItems.length)
11830 return;
11831 self.inputState();
11832 self.close();
11833 self.activeItems = activeItems;
11834 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
11835 self.setActiveItemClass(item);
11836 });
11837 }
11838 /**
11839 * Determines if the control_input should be in a hidden or visible state
11840 *
11841 */
11842 inputState() {
11843 var self = this;
11844 if (!self.control.contains(self.control_input))
11845 return;
11846 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
11847 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
11848 self.setTextboxValue();
11849 self.isInputHidden = true;
11850 }
11851 else {
11852 if (self.settings.hidePlaceholder && self.items.length > 0) {
11853 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
11854 }
11855 self.isInputHidden = false;
11856 }
11857 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
11858 }
11859 /**
11860 * Get the input value
11861 */
11862 inputValue() {
11863 return this.control_input.value.trim();
11864 }
11865 /**
11866 * Gives the control focus.
11867 */
11868 focus() {
11869 var self = this;
11870 if (self.isDisabled || self.isReadOnly)
11871 return;
11872 self.ignoreFocus = true;
11873 if (self.control_input.offsetWidth) {
11874 self.control_input.focus();
11875 }
11876 else {
11877 self.focus_node.focus();
11878 }
11879 setTimeout(() => {
11880 self.ignoreFocus = false;
11881 self.onFocus();
11882 }, 0);
11883 }
11884 /**
11885 * Forces the control out of focus.
11886 *
11887 */
11888 blur() {
11889 this.focus_node.blur();
11890 this.onBlur();
11891 }
11892 /**
11893 * Returns a function that scores an object
11894 * to show how good of a match it is to the
11895 * provided query.
11896 *
11897 * @return {function}
11898 */
11899 getScoreFunction(query) {
11900 return this.sifter.getScoreFunction(query, this.getSearchOptions());
11901 }
11902 /**
11903 * Returns search options for sifter (the system
11904 * for scoring and sorting results).
11905 *
11906 * @see https://github.com/orchidjs/sifter.js
11907 * @return {object}
11908 */
11909 getSearchOptions() {
11910 var settings = this.settings;
11911 var sort = settings.sortField;
11912 if (typeof settings.sortField === 'string') {
11913 sort = [{ field: settings.sortField }];
11914 }
11915 return {
11916 fields: settings.searchField,
11917 conjunction: settings.searchConjunction,
11918 sort: sort,
11919 nesting: settings.nesting
11920 };
11921 }
11922 /**
11923 * Searches through available options and returns
11924 * a sorted array of matches.
11925 *
11926 */
11927 search(query) {
11928 var result, calculateScore;
11929 var self = this;
11930 var options = this.getSearchOptions();
11931 // validate user-provided result scoring function
11932 if (self.settings.score) {
11933 calculateScore = self.settings.score.call(self, query);
11934 if (typeof calculateScore !== 'function') {
11935 throw new Error('Tom Select "score" setting must be a function that returns a function');
11936 }
11937 }
11938 // perform search
11939 if (query !== self.lastQuery) {
11940 self.lastQuery = query;
11941 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
11942 self.currentResults = result;
11943 }
11944 else {
11945 result = Object.assign({}, self.currentResults);
11946 }
11947 // filter out selected items
11948 if (self.settings.hideSelected) {
11949 result.items = result.items.filter((item) => {
11950 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
11951 return !(hashed && self.items.indexOf(hashed) !== -1);
11952 });
11953 }
11954 return result;
11955 }
11956 /**
11957 * Refreshes the list of available options shown
11958 * in the autocomplete dropdown menu.
11959 *
11960 */
11961 refreshOptions(triggerDropdown = true) {
11962 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
11963 var create;
11964 const groups = {};
11965 const groups_order = [];
11966 var self = this;
11967 var query = self.inputValue();
11968 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
11969 var results = self.search(query);
11970 var active_option = null;
11971 var show_dropdown = self.settings.shouldOpen || false;
11972 var dropdown_content = self.dropdown_content;
11973 if (same_query) {
11974 active_option = self.activeOption;
11975 if (active_option) {
11976 active_group = active_option.closest('[data-group]');
11977 }
11978 }
11979 // build markup
11980 n = results.items.length;
11981 if (typeof self.settings.maxOptions === 'number') {
11982 n = Math.min(n, self.settings.maxOptions);
11983 }
11984 if (n > 0) {
11985 show_dropdown = true;
11986 }
11987 // get fragment for group and the position of the group in group_order
11988 const getGroupFragment = (optgroup, order) => {
11989 let group_order_i = groups[optgroup];
11990 if (group_order_i !== undefined) {
11991 let order_group = groups_order[group_order_i];
11992 if (order_group !== undefined) {
11993 return [group_order_i, order_group.fragment];
11994 }
11995 }
11996 let group_fragment = document.createDocumentFragment();
11997 group_order_i = groups_order.length;
11998 groups_order.push({ fragment: group_fragment, order, optgroup });
11999 return [group_order_i, group_fragment];
12000 };
12001 // render and group available options individually
12002 for (i = 0; i < n; i++) {
12003 // get option dom element
12004 let item = results.items[i];
12005 if (!item)
12006 continue;
12007 let opt_value = item.id;
12008 let option = self.options[opt_value];
12009 if (option === undefined)
12010 continue;
12011 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12012 let option_el = self.getOption(opt_hash, true);
12013 // toggle 'selected' class
12014 if (!self.settings.hideSelected) {
12015 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12016 }
12017 optgroup = option[self.settings.optgroupField] || '';
12018 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12019 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12020 optgroup = optgroups[j];
12021 let order = option.$order;
12022 let self_optgroup = self.optgroups[optgroup];
12023 if (self_optgroup === undefined) {
12024 optgroup = '';
12025 }
12026 else {
12027 order = self_optgroup.$order;
12028 }
12029 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12030 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12031 if (j > 0) {
12032 option_el = option_el.cloneNode(true);
12033 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12034 option_el.classList.add('ts-cloned');
12035 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12036 // make sure we keep the activeOption in the same group
12037 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12038 if (active_group && active_group.dataset.group === optgroup.toString()) {
12039 active_option = option_el;
12040 }
12041 }
12042 }
12043 group_fragment.appendChild(option_el);
12044 if (optgroup != '') {
12045 groups[optgroup] = group_order_i;
12046 }
12047 }
12048 }
12049 // sort optgroups
12050 if (self.settings.lockOptgroupOrder) {
12051 groups_order.sort((a, b) => {
12052 return a.order - b.order;
12053 });
12054 }
12055 // render optgroup headers & join groups
12056 html = document.createDocumentFragment();
12057 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12058 let group_fragment = group_order.fragment;
12059 let optgroup = group_order.optgroup;
12060 if (!group_fragment || !group_fragment.children.length)
12061 return;
12062 let group_heading = self.optgroups[optgroup];
12063 if (group_heading !== undefined) {
12064 let group_options = document.createDocumentFragment();
12065 let header = self.render('optgroup_header', group_heading);
12066 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12067 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12068 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12069 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12070 }
12071 else {
12072 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12073 }
12074 });
12075 dropdown_content.innerHTML = '';
12076 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12077 // highlight matching terms inline
12078 if (self.settings.highlight) {
12079 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12080 if (results.query.length && results.tokens.length) {
12081 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12082 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12083 });
12084 }
12085 }
12086 // helper method for adding templates to dropdown
12087 var add_template = (template) => {
12088 let content = self.render(template, { input: query });
12089 if (content) {
12090 show_dropdown = true;
12091 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12092 }
12093 return content;
12094 };
12095 // add loading message
12096 if (self.loading) {
12097 add_template('loading');
12098 // invalid query
12099 }
12100 else if (!self.settings.shouldLoad.call(self, query)) {
12101 add_template('not_loading');
12102 // add no_results message
12103 }
12104 else if (results.items.length === 0) {
12105 add_template('no_results');
12106 }
12107 // add create option
12108 has_create_option = self.canCreate(query);
12109 if (has_create_option) {
12110 create = add_template('option_create');
12111 }
12112 // activate
12113 self.hasOptions = results.items.length > 0 || has_create_option;
12114 if (show_dropdown) {
12115 if (results.items.length > 0) {
12116 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12117 active_option = self.getOption(self.items[0]);
12118 }
12119 if (!dropdown_content.contains(active_option)) {
12120 let active_index = 0;
12121 if (create && !self.settings.addPrecedence) {
12122 active_index = 1;
12123 }
12124 active_option = self.selectable()[active_index];
12125 }
12126 }
12127 else if (create) {
12128 active_option = create;
12129 }
12130 if (triggerDropdown && !self.isOpen) {
12131 self.open();
12132 self.scrollToOption(active_option, 'auto');
12133 }
12134 self.setActiveOption(active_option);
12135 }
12136 else {
12137 self.clearActiveOption();
12138 if (triggerDropdown && self.isOpen) {
12139 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12140 }
12141 }
12142 }
12143 /**
12144 * Return list of selectable options
12145 *
12146 */
12147 selectable() {
12148 return this.dropdown_content.querySelectorAll('[data-selectable]');
12149 }
12150 /**
12151 * Adds an available option. If it already exists,
12152 * nothing will happen. Note: this does not refresh
12153 * the options list dropdown (use `refreshOptions`
12154 * for that).
12155 *
12156 * Usage:
12157 *
12158 * this.addOption(data)
12159 *
12160 */
12161 addOption(data, user_created = false) {
12162 const self = this;
12163 // @deprecated 1.7.7
12164 // use addOptions( array, user_created ) for adding multiple options
12165 if (Array.isArray(data)) {
12166 self.addOptions(data, user_created);
12167 return false;
12168 }
12169 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12170 if (key === null || self.options.hasOwnProperty(key)) {
12171 return false;
12172 }
12173 data.$order = data.$order || ++self.order;
12174 data.$id = self.inputId + '-opt-' + data.$order;
12175 self.options[key] = data;
12176 self.lastQuery = null;
12177 if (user_created) {
12178 self.userOptions[key] = user_created;
12179 self.trigger('option_add', key, data);
12180 }
12181 return key;
12182 }
12183 /**
12184 * Add multiple options
12185 *
12186 */
12187 addOptions(data, user_created = false) {
12188 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12189 this.addOption(dat, user_created);
12190 });
12191 }
12192 /**
12193 * @deprecated 1.7.7
12194 */
12195 registerOption(data) {
12196 return this.addOption(data);
12197 }
12198 /**
12199 * Registers an option group to the pool of option groups.
12200 *
12201 * @return {boolean|string}
12202 */
12203 registerOptionGroup(data) {
12204 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12205 if (key === null)
12206 return false;
12207 data.$order = data.$order || ++this.order;
12208 this.optgroups[key] = data;
12209 return key;
12210 }
12211 /**
12212 * Registers a new optgroup for options
12213 * to be bucketed into.
12214 *
12215 */
12216 addOptionGroup(id, data) {
12217 var hashed_id;
12218 data[this.settings.optgroupValueField] = id;
12219 if (hashed_id = this.registerOptionGroup(data)) {
12220 this.trigger('optgroup_add', hashed_id, data);
12221 }
12222 }
12223 /**
12224 * Removes an existing option group.
12225 *
12226 */
12227 removeOptionGroup(id) {
12228 if (this.optgroups.hasOwnProperty(id)) {
12229 delete this.optgroups[id];
12230 this.clearCache();
12231 this.trigger('optgroup_remove', id);
12232 }
12233 }
12234 /**
12235 * Clears all existing option groups.
12236 */
12237 clearOptionGroups() {
12238 this.optgroups = {};
12239 this.clearCache();
12240 this.trigger('optgroup_clear');
12241 }
12242 /**
12243 * Updates an option available for selection. If
12244 * it is visible in the selected items or options
12245 * dropdown, it will be re-rendered automatically.
12246 *
12247 */
12248 updateOption(value, data) {
12249 const self = this;
12250 var item_new;
12251 var index_item;
12252 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12253 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12254 // sanity checks
12255 if (value_old === null)
12256 return;
12257 const data_old = self.options[value_old];
12258 if (data_old == undefined)
12259 return;
12260 if (typeof value_new !== 'string')
12261 throw new Error('Value must be set in option data');
12262 const option = self.getOption(value_old);
12263 const item = self.getItem(value_old);
12264 data.$order = data.$order || data_old.$order;
12265 delete self.options[value_old];
12266 // invalidate render cache
12267 // don't remove existing node yet, we'll remove it after replacing it
12268 self.uncacheValue(value_new);
12269 self.options[value_new] = data;
12270 // update the option if it's in the dropdown
12271 if (option) {
12272 if (self.dropdown_content.contains(option)) {
12273 const option_new = self._render('option', data);
12274 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12275 if (self.activeOption === option) {
12276 self.setActiveOption(option_new);
12277 }
12278 }
12279 option.remove();
12280 }
12281 // update the item if we have one
12282 if (item) {
12283 index_item = self.items.indexOf(value_old);
12284 if (index_item !== -1) {
12285 self.items.splice(index_item, 1, value_new);
12286 }
12287 item_new = self._render('item', data);
12288 if (item.classList.contains('active'))
12289 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12290 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12291 }
12292 // invalidate last query because we might have updated the sortField
12293 self.lastQuery = null;
12294 }
12295 /**
12296 * Removes a single option.
12297 *
12298 */
12299 removeOption(value, silent) {
12300 const self = this;
12301 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12302 self.uncacheValue(value);
12303 delete self.userOptions[value];
12304 delete self.options[value];
12305 self.lastQuery = null;
12306 self.trigger('option_remove', value);
12307 self.removeItem(value, silent);
12308 }
12309 /**
12310 * Clears all options.
12311 */
12312 clearOptions(filter) {
12313 const boundFilter = (filter || this.clearFilter).bind(this);
12314 this.loadedSearches = {};
12315 this.userOptions = {};
12316 this.clearCache();
12317 const selected = {};
12318 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12319 if (boundFilter(option, key)) {
12320 selected[key] = option;
12321 }
12322 });
12323 this.options = this.sifter.items = selected;
12324 this.lastQuery = null;
12325 this.trigger('option_clear');
12326 }
12327 /**
12328 * Used by clearOptions() to decide whether or not an option should be removed
12329 * Return true to keep an option, false to remove
12330 *
12331 */
12332 clearFilter(option, value) {
12333 if (this.items.indexOf(value) >= 0) {
12334 return true;
12335 }
12336 return false;
12337 }
12338 /**
12339 * Returns the dom element of the option
12340 * matching the given value.
12341 *
12342 */
12343 getOption(value, create = false) {
12344 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12345 if (hashed === null)
12346 return null;
12347 const option = this.options[hashed];
12348 if (option != undefined) {
12349 if (option.$div) {
12350 return option.$div;
12351 }
12352 if (create) {
12353 return this._render('option', option);
12354 }
12355 }
12356 return null;
12357 }
12358 /**
12359 * Returns the dom element of the next or previous dom element of the same type
12360 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12361 *
12362 */
12363 getAdjacent(option, direction, type = 'option') {
12364 var self = this, all;
12365 if (!option) {
12366 return null;
12367 }
12368 if (type == 'item') {
12369 all = self.controlChildren();
12370 }
12371 else {
12372 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12373 }
12374 for (let i = 0; i < all.length; i++) {
12375 if (all[i] != option) {
12376 continue;
12377 }
12378 if (direction > 0) {
12379 return all[i + 1];
12380 }
12381 return all[i - 1];
12382 }
12383 return null;
12384 }
12385 /**
12386 * Returns the dom element of the item
12387 * matching the given value.
12388 *
12389 */
12390 getItem(item) {
12391 if (typeof item == 'object') {
12392 return item;
12393 }
12394 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12395 return value !== null
12396 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12397 : null;
12398 }
12399 /**
12400 * "Selects" multiple items at once. Adds them to the list
12401 * at the current caret position.
12402 *
12403 */
12404 addItems(values, silent) {
12405 var self = this;
12406 var items = Array.isArray(values) ? values : [values];
12407 items = items.filter(x => self.items.indexOf(x) === -1);
12408 const last_item = items[items.length - 1];
12409 items.forEach(item => {
12410 self.isPending = (item !== last_item);
12411 self.addItem(item, silent);
12412 });
12413 }
12414 /**
12415 * "Selects" an item. Adds it to the list
12416 * at the current caret position.
12417 *
12418 */
12419 addItem(value, silent) {
12420 var events = silent ? [] : ['change', 'dropdown_close'];
12421 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12422 var item, wasFull;
12423 const self = this;
12424 const inputMode = self.settings.mode;
12425 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12426 if (hashed && self.items.indexOf(hashed) !== -1) {
12427 if (inputMode === 'single') {
12428 self.close();
12429 }
12430 if (inputMode === 'single' || !self.settings.duplicates) {
12431 return;
12432 }
12433 }
12434 if (hashed === null || !self.options.hasOwnProperty(hashed))
12435 return;
12436 if (inputMode === 'single')
12437 self.clear(silent);
12438 if (inputMode === 'multi' && self.isFull())
12439 return;
12440 item = self._render('item', self.options[hashed]);
12441 if (self.control.contains(item)) { // duplicates
12442 item = item.cloneNode(true);
12443 }
12444 wasFull = self.isFull();
12445 self.items.splice(self.caretPos, 0, hashed);
12446 self.insertAtCaret(item);
12447 if (self.isSetup) {
12448 // update menu / remove the option (if this is not one item being added as part of series)
12449 if (!self.isPending && self.settings.hideSelected) {
12450 let option = self.getOption(hashed);
12451 let next = self.getAdjacent(option, 1);
12452 if (next) {
12453 self.setActiveOption(next);
12454 }
12455 }
12456 // refreshOptions after setActiveOption(),
12457 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12458 if (!self.isPending && !self.settings.closeAfterSelect) {
12459 self.refreshOptions(self.isFocused && inputMode !== 'single');
12460 }
12461 // hide the menu if the maximum number of items have been selected or no options are left
12462 if (self.settings.closeAfterSelect != false && self.isFull()) {
12463 self.close();
12464 }
12465 else if (!self.isPending) {
12466 self.positionDropdown();
12467 }
12468 self.trigger('item_add', hashed, item);
12469 if (!self.isPending) {
12470 self.updateOriginalInput({ silent: silent });
12471 }
12472 }
12473 if (!self.isPending || (!wasFull && self.isFull())) {
12474 self.inputState();
12475 self.refreshState();
12476 }
12477 });
12478 }
12479 /**
12480 * Removes the selected item matching
12481 * the provided value.
12482 *
12483 */
12484 removeItem(item = null, silent) {
12485 const self = this;
12486 item = self.getItem(item);
12487 if (!item)
12488 return;
12489 var i, idx;
12490 const value = item.dataset.value;
12491 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
12492 item.remove();
12493 if (item.classList.contains('active')) {
12494 idx = self.activeItems.indexOf(item);
12495 self.activeItems.splice(idx, 1);
12496 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12497 }
12498 self.items.splice(i, 1);
12499 self.lastQuery = null;
12500 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
12501 self.removeOption(value, silent);
12502 }
12503 if (i < self.caretPos) {
12504 self.setCaret(self.caretPos - 1);
12505 }
12506 self.updateOriginalInput({ silent: silent });
12507 self.refreshState();
12508 self.positionDropdown();
12509 self.trigger('item_remove', value, item);
12510 }
12511 /**
12512 * Invokes the `create` method provided in the
12513 * TomSelect options that should provide the data
12514 * for the new item, given the user input.
12515 *
12516 * Once this completes, it will be added
12517 * to the item list.
12518 *
12519 */
12520 createItem(input = null, callback = () => { }) {
12521 // triggerDropdown parameter @deprecated 2.1.1
12522 if (arguments.length === 3) {
12523 callback = arguments[2];
12524 }
12525 if (typeof callback != 'function') {
12526 callback = () => { };
12527 }
12528 var self = this;
12529 var caret = self.caretPos;
12530 var output;
12531 input = input || self.inputValue();
12532 if (!self.canCreate(input)) {
12533 callback();
12534 return false;
12535 }
12536 self.lock();
12537 var created = false;
12538 var create = (data) => {
12539 self.unlock();
12540 if (!data || typeof data !== 'object')
12541 return callback();
12542 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12543 if (typeof value !== 'string') {
12544 return callback();
12545 }
12546 self.setTextboxValue();
12547 self.addOption(data, true);
12548 self.setCaret(caret);
12549 self.addItem(value);
12550 callback(data);
12551 created = true;
12552 };
12553 if (typeof self.settings.create === 'function') {
12554 output = self.settings.create.call(this, input, create);
12555 }
12556 else {
12557 output = {
12558 [self.settings.labelField]: input,
12559 [self.settings.valueField]: input,
12560 };
12561 }
12562 if (!created) {
12563 create(output);
12564 }
12565 return true;
12566 }
12567 /**
12568 * Re-renders the selected item lists.
12569 */
12570 refreshItems() {
12571 var self = this;
12572 self.lastQuery = null;
12573 if (self.isSetup) {
12574 self.addItems(self.items);
12575 }
12576 self.updateOriginalInput();
12577 self.refreshState();
12578 }
12579 /**
12580 * Updates all state-dependent attributes
12581 * and CSS classes.
12582 */
12583 refreshState() {
12584 const self = this;
12585 self.refreshValidityState();
12586 const isFull = self.isFull();
12587 const isLocked = self.isLocked;
12588 self.wrapper.classList.toggle('rtl', self.rtl);
12589 const wrap_classList = self.wrapper.classList;
12590 wrap_classList.toggle('focus', self.isFocused);
12591 wrap_classList.toggle('disabled', self.isDisabled);
12592 wrap_classList.toggle('readonly', self.isReadOnly);
12593 wrap_classList.toggle('required', self.isRequired);
12594 wrap_classList.toggle('invalid', !self.isValid);
12595 wrap_classList.toggle('locked', isLocked);
12596 wrap_classList.toggle('full', isFull);
12597 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
12598 wrap_classList.toggle('dropdown-active', self.isOpen);
12599 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
12600 wrap_classList.toggle('has-items', self.items.length > 0);
12601 }
12602 /**
12603 * Update the `required` attribute of both input and control input.
12604 *
12605 * The `required` property needs to be activated on the control input
12606 * for the error to be displayed at the right place. `required` also
12607 * needs to be temporarily deactivated on the input since the input is
12608 * hidden and can't show errors.
12609 */
12610 refreshValidityState() {
12611 var self = this;
12612 if (!self.input.validity) {
12613 return;
12614 }
12615 self.isValid = self.input.validity.valid;
12616 self.isInvalid = !self.isValid;
12617 }
12618 /**
12619 * Determines whether or not more items can be added
12620 * to the control without exceeding the user-defined maximum.
12621 *
12622 * @returns {boolean}
12623 */
12624 isFull() {
12625 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
12626 }
12627 /**
12628 * Refreshes the original <select> or <input>
12629 * element to reflect the current state.
12630 *
12631 */
12632 updateOriginalInput(opts = {}) {
12633 const self = this;
12634 var option, label;
12635 const empty_option = self.input.querySelector('option[value=""]');
12636 if (self.is_select_tag) {
12637 const selected = [];
12638 const has_selected = self.input.querySelectorAll('option:checked').length;
12639 function AddSelected(option_el, value, label) {
12640 if (!option_el) {
12641 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>');
12642 }
12643 // don't move empty option from top of list
12644 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
12645 if (option_el != empty_option) {
12646 self.input.append(option_el);
12647 }
12648 selected.push(option_el);
12649 // marking empty option as selected can break validation
12650 // fixes https://github.com/orchidjs/tom-select/issues/303
12651 if (option_el != empty_option || has_selected > 0) {
12652 option_el.selected = true;
12653 }
12654 return option_el;
12655 }
12656 // unselect all selected options
12657 self.input.querySelectorAll('option:checked').forEach((option_el) => {
12658 option_el.selected = false;
12659 });
12660 // nothing selected?
12661 if (self.items.length == 0 && self.settings.mode == 'single') {
12662 AddSelected(empty_option, "", "");
12663 // order selected <option> tags for values in self.items
12664 }
12665 else {
12666 self.items.forEach((value) => {
12667 option = self.options[value];
12668 label = option[self.settings.labelField] || '';
12669 if (selected.includes(option.$option)) {
12670 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
12671 AddSelected(reuse_opt, value, label);
12672 }
12673 else {
12674 option.$option = AddSelected(option.$option, value, label);
12675 }
12676 });
12677 }
12678 }
12679 else {
12680 self.input.value = self.getValue();
12681 }
12682 if (self.isSetup) {
12683 if (!opts.silent) {
12684 self.trigger('change', self.getValue());
12685 }
12686 }
12687 }
12688 /**
12689 * Shows the autocomplete dropdown containing
12690 * the available options.
12691 */
12692 open() {
12693 var self = this;
12694 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
12695 return;
12696 self.isOpen = true;
12697 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
12698 self.refreshState();
12699 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
12700 self.positionDropdown();
12701 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
12702 self.focus();
12703 self.trigger('dropdown_open', self.dropdown);
12704 }
12705 /**
12706 * Closes the autocomplete dropdown menu.
12707 */
12708 close(setTextboxValue = true) {
12709 var self = this;
12710 var trigger = self.isOpen;
12711 if (setTextboxValue) {
12712 // before blur() to prevent form onchange event
12713 self.setTextboxValue();
12714 if (self.settings.mode === 'single' && self.items.length) {
12715 self.inputState();
12716 }
12717 }
12718 self.isOpen = false;
12719 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
12720 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
12721 if (self.settings.hideSelected) {
12722 self.clearActiveOption();
12723 }
12724 self.refreshState();
12725 if (trigger)
12726 self.trigger('dropdown_close', self.dropdown);
12727 }
12728 /**
12729 * Calculates and applies the appropriate
12730 * position of the dropdown if dropdownParent = 'body'.
12731 * Otherwise, position is determined by css
12732 */
12733 positionDropdown() {
12734 if (this.settings.dropdownParent !== 'body') {
12735 return;
12736 }
12737 var context = this.control;
12738 var rect = context.getBoundingClientRect();
12739 var top = context.offsetHeight + rect.top + window.scrollY;
12740 var left = rect.left + window.scrollX;
12741 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
12742 width: rect.width + 'px',
12743 top: top + 'px',
12744 left: left + 'px'
12745 });
12746 }
12747 /**
12748 * Resets / clears all selected items
12749 * from the control.
12750 *
12751 */
12752 clear(silent) {
12753 var self = this;
12754 if (!self.items.length)
12755 return;
12756 var items = self.controlChildren();
12757 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
12758 self.removeItem(item, true);
12759 });
12760 self.inputState();
12761 if (!silent)
12762 self.updateOriginalInput();
12763 self.trigger('clear');
12764 }
12765 /**
12766 * A helper method for inserting an element
12767 * at the current caret position.
12768 *
12769 */
12770 insertAtCaret(el) {
12771 const self = this;
12772 const caret = self.caretPos;
12773 const target = self.control;
12774 target.insertBefore(el, target.children[caret] || null);
12775 self.setCaret(caret + 1);
12776 }
12777 /**
12778 * Removes the current selected item(s).
12779 *
12780 */
12781 deleteSelection(e) {
12782 var direction, selection, caret, tail;
12783 var self = this;
12784 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
12785 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
12786 // determine items that will be removed
12787 const rm_items = [];
12788 if (self.activeItems.length) {
12789 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
12790 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
12791 if (direction > 0) {
12792 caret++;
12793 }
12794 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
12795 }
12796 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
12797 const items = self.controlChildren();
12798 let rm_item;
12799 if (direction < 0 && selection.start === 0 && selection.length === 0) {
12800 rm_item = items[self.caretPos - 1];
12801 }
12802 else if (direction > 0 && selection.start === self.inputValue().length) {
12803 rm_item = items[self.caretPos];
12804 }
12805 if (rm_item !== undefined) {
12806 rm_items.push(rm_item);
12807 }
12808 }
12809 if (!self.shouldDelete(rm_items, e)) {
12810 return false;
12811 }
12812 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
12813 // perform removal
12814 if (typeof caret !== 'undefined') {
12815 self.setCaret(caret);
12816 }
12817 while (rm_items.length) {
12818 self.removeItem(rm_items.pop());
12819 }
12820 self.inputState();
12821 self.positionDropdown();
12822 self.refreshOptions(false);
12823 return true;
12824 }
12825 /**
12826 * Return true if the items should be deleted
12827 */
12828 shouldDelete(items, evt) {
12829 const values = items.map(item => item.dataset.value);
12830 // allow the callback to abort
12831 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete(values, evt) === false)) {
12832 return false;
12833 }
12834 return true;
12835 }
12836 /**
12837 * Selects the previous / next item (depending on the `direction` argument).
12838 *
12839 * > 0 - right
12840 * < 0 - left
12841 *
12842 */
12843 advanceSelection(direction, e) {
12844 var last_active, adjacent, self = this;
12845 if (self.rtl)
12846 direction *= -1;
12847 if (self.inputValue().length)
12848 return;
12849 // add or remove to active items
12850 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)) {
12851 last_active = self.getLastActive(direction);
12852 if (last_active) {
12853 if (!last_active.classList.contains('active')) {
12854 adjacent = last_active;
12855 }
12856 else {
12857 adjacent = self.getAdjacent(last_active, direction, 'item');
12858 }
12859 // if no active item, get items adjacent to the control input
12860 }
12861 else if (direction > 0) {
12862 adjacent = self.control_input.nextElementSibling;
12863 }
12864 else {
12865 adjacent = self.control_input.previousElementSibling;
12866 }
12867 if (adjacent) {
12868 if (adjacent.classList.contains('active')) {
12869 self.removeActiveItem(last_active);
12870 }
12871 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
12872 }
12873 // move caret to the left or right
12874 }
12875 else {
12876 self.moveCaret(direction);
12877 }
12878 }
12879 moveCaret(direction) { }
12880 /**
12881 * Get the last active item
12882 *
12883 */
12884 getLastActive(direction) {
12885 let last_active = this.control.querySelector('.last-active');
12886 if (last_active) {
12887 return last_active;
12888 }
12889 var result = this.control.querySelectorAll('.active');
12890 if (result) {
12891 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
12892 }
12893 }
12894 /**
12895 * Moves the caret to the specified index.
12896 *
12897 * The input must be moved by leaving it in place and moving the
12898 * siblings, due to the fact that focus cannot be restored once lost
12899 * on mobile webkit devices
12900 *
12901 */
12902 setCaret(new_pos) {
12903 this.caretPos = this.items.length;
12904 }
12905 /**
12906 * Return list of item dom elements
12907 *
12908 */
12909 controlChildren() {
12910 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
12911 }
12912 /**
12913 * Disables user input on the control. Used while
12914 * items are being asynchronously created.
12915 */
12916 lock() {
12917 this.setLocked(true);
12918 }
12919 /**
12920 * Re-enables user input on the control.
12921 */
12922 unlock() {
12923 this.setLocked(false);
12924 }
12925 /**
12926 * Disable or enable user input on the control
12927 */
12928 setLocked(lock = this.isReadOnly || this.isDisabled) {
12929 this.isLocked = lock;
12930 this.refreshState();
12931 }
12932 /**
12933 * Disables user input on the control completely.
12934 * While disabled, it cannot receive focus.
12935 */
12936 disable() {
12937 this.setDisabled(true);
12938 this.close();
12939 }
12940 /**
12941 * Enables the control so that it can respond
12942 * to focus and user input.
12943 */
12944 enable() {
12945 this.setDisabled(false);
12946 }
12947 setDisabled(disabled) {
12948 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
12949 this.isDisabled = disabled;
12950 this.input.disabled = disabled;
12951 this.control_input.disabled = disabled;
12952 this.setLocked();
12953 }
12954 setReadOnly(isReadOnly) {
12955 this.isReadOnly = isReadOnly;
12956 this.input.readOnly = isReadOnly;
12957 this.control_input.readOnly = isReadOnly;
12958 this.setLocked();
12959 }
12960 /**
12961 * Completely destroys the control and
12962 * unbinds all event listeners so that it can
12963 * be garbage collected.
12964 */
12965 destroy() {
12966 var self = this;
12967 var revertSettings = self.revertSettings;
12968 self.trigger('destroy');
12969 self.off();
12970 self.wrapper.remove();
12971 self.dropdown.remove();
12972 self.input.innerHTML = revertSettings.innerHTML;
12973 self.input.tabIndex = revertSettings.tabIndex;
12974 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
12975 self._destroy();
12976 delete self.input.tomselect;
12977 }
12978 /**
12979 * A helper method for rendering "item" and
12980 * "option" templates, given the data.
12981 *
12982 */
12983 render(templateName, data) {
12984 var id, html;
12985 const self = this;
12986 if (typeof this.settings.render[templateName] !== 'function') {
12987 return null;
12988 }
12989 // render markup
12990 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
12991 if (!html) {
12992 return null;
12993 }
12994 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
12995 // add mandatory attributes
12996 if (templateName === 'option' || templateName === 'option_create') {
12997 if (data[self.settings.disabledField]) {
12998 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
12999 }
13000 else {
13001 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13002 }
13003 }
13004 else if (templateName === 'optgroup') {
13005 id = data.group[self.settings.optgroupValueField];
13006 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13007 if (data.group[self.settings.disabledField]) {
13008 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13009 }
13010 }
13011 if (templateName === 'option' || templateName === 'item') {
13012 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13013 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13014 // make sure we have some classes if a template is overwritten
13015 if (templateName === 'item') {
13016 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13017 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13018 }
13019 else {
13020 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13021 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13022 role: 'option',
13023 id: data.$id
13024 });
13025 // update cache
13026 data.$div = html;
13027 self.options[value] = data;
13028 }
13029 }
13030 return html;
13031 }
13032 /**
13033 * Type guarded rendering
13034 *
13035 */
13036 _render(templateName, data) {
13037 const html = this.render(templateName, data);
13038 if (html == null) {
13039 throw 'HTMLElement expected';
13040 }
13041 return html;
13042 }
13043 /**
13044 * Clears the render cache for a template. If
13045 * no template is given, clears all render
13046 * caches.
13047 *
13048 */
13049 clearCache() {
13050 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13051 if (option.$div) {
13052 option.$div.remove();
13053 delete option.$div;
13054 }
13055 });
13056 }
13057 /**
13058 * Removes a value from item and option caches
13059 *
13060 */
13061 uncacheValue(value) {
13062 const option_el = this.getOption(value);
13063 if (option_el)
13064 option_el.remove();
13065 }
13066 /**
13067 * Determines whether or not to display the
13068 * create item prompt, given a user input.
13069 *
13070 */
13071 canCreate(input) {
13072 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13073 }
13074 /**
13075 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13076 *
13077 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13078 *
13079 * });
13080 */
13081 hook(when, method, new_fn) {
13082 var self = this;
13083 var orig_method = self[method];
13084 self[method] = function () {
13085 var result, result_new;
13086 if (when === 'after') {
13087 result = orig_method.apply(self, arguments);
13088 }
13089 result_new = new_fn.apply(self, arguments);
13090 if (when === 'instead') {
13091 return result_new;
13092 }
13093 if (when === 'before') {
13094 result = orig_method.apply(self, arguments);
13095 }
13096 return result;
13097 };
13098 }
13099 }
13100 ;
13101 //# sourceMappingURL=tom-select.js.map
13102
13103 /***/ },
13104
13105 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13106 /*!***************************************************!*\
13107 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13108 \***************************************************/
13109 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13110
13111 "use strict";
13112 __webpack_require__.r(__webpack_exports__);
13113 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13114 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13115 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13116 /* harmony export */ append: () => (/* binding */ append),
13117 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13118 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13119 /* harmony export */ getId: () => (/* binding */ getId),
13120 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13121 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13122 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13123 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13124 /* harmony export */ iterate: () => (/* binding */ iterate),
13125 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13126 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13127 /* harmony export */ timeout: () => (/* binding */ timeout)
13128 /* harmony export */ });
13129 /**
13130 * Converts a scalar to its best string representation
13131 * for hash keys and HTML attribute values.
13132 *
13133 * Transformations:
13134 * 'str' -> 'str'
13135 * null -> ''
13136 * undefined -> ''
13137 * true -> '1'
13138 * false -> '0'
13139 * 0 -> '0'
13140 * 1 -> '1'
13141 *
13142 */
13143 const hash_key = (value) => {
13144 if (typeof value === 'undefined' || value === null)
13145 return null;
13146 return get_hash(value);
13147 };
13148 const get_hash = (value) => {
13149 if (typeof value === 'boolean')
13150 return value ? '1' : '0';
13151 return value + '';
13152 };
13153 /**
13154 * Escapes a string for use within HTML.
13155 *
13156 */
13157 const escape_html = (str) => {
13158 return (str + '')
13159 .replace(/&/g, '&amp;')
13160 .replace(/</g, '&lt;')
13161 .replace(/>/g, '&gt;')
13162 .replace(/"/g, '&quot;');
13163 };
13164 /**
13165 * use setTimeout if timeout > 0
13166 */
13167 const timeout = (fn, timeout) => {
13168 if (timeout > 0) {
13169 return window.setTimeout(fn, timeout);
13170 }
13171 fn.call(null);
13172 return null;
13173 };
13174 /**
13175 * Debounce the user provided load function
13176 *
13177 */
13178 const loadDebounce = (fn, delay) => {
13179 var timeout;
13180 return function (value, callback) {
13181 var self = this;
13182 if (timeout) {
13183 self.loading = Math.max(self.loading - 1, 0);
13184 clearTimeout(timeout);
13185 }
13186 timeout = setTimeout(function () {
13187 timeout = null;
13188 self.loadedSearches[value] = true;
13189 fn.call(self, value, callback);
13190 }, delay);
13191 };
13192 };
13193 /**
13194 * Debounce all fired events types listed in `types`
13195 * while executing the provided `fn`.
13196 *
13197 */
13198 const debounce_events = (self, types, fn) => {
13199 var type;
13200 var trigger = self.trigger;
13201 var event_args = {};
13202 // override trigger method
13203 self.trigger = function () {
13204 var type = arguments[0];
13205 if (types.indexOf(type) !== -1) {
13206 event_args[type] = arguments;
13207 }
13208 else {
13209 return trigger.apply(self, arguments);
13210 }
13211 };
13212 // invoke provided function
13213 fn.apply(self, []);
13214 self.trigger = trigger;
13215 // trigger queued events
13216 for (type of types) {
13217 if (type in event_args) {
13218 trigger.apply(self, event_args[type]);
13219 }
13220 }
13221 };
13222 /**
13223 * Determines the current selection within a text input control.
13224 * Returns an object containing:
13225 * - start
13226 * - length
13227 *
13228 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13229 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13230 */
13231 const getSelection = (input) => {
13232 return {
13233 start: input.selectionStart || 0,
13234 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13235 };
13236 };
13237 /**
13238 * Prevent default
13239 *
13240 */
13241 const preventDefault = (evt, stop = false) => {
13242 if (evt) {
13243 evt.preventDefault();
13244 if (stop) {
13245 evt.stopPropagation();
13246 }
13247 }
13248 };
13249 /**
13250 * Add event helper
13251 *
13252 */
13253 const addEvent = (target, type, callback, options) => {
13254 target.addEventListener(type, callback, options);
13255 };
13256 /**
13257 * Return true if the requested key is down
13258 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13259 * The current evt may not always set ( eg calling advanceSelection() )
13260 *
13261 */
13262 const isKeyDown = (key_name, evt) => {
13263 if (!evt) {
13264 return false;
13265 }
13266 if (!evt[key_name]) {
13267 return false;
13268 }
13269 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13270 if (count === 1) {
13271 return true;
13272 }
13273 return false;
13274 };
13275 /**
13276 * Get the id of an element
13277 * If the id attribute is not set, set the attribute with the given id
13278 *
13279 */
13280 const getId = (el, id) => {
13281 const existing_id = el.getAttribute('id');
13282 if (existing_id) {
13283 return existing_id;
13284 }
13285 el.setAttribute('id', id);
13286 return id;
13287 };
13288 /**
13289 * Returns a string with backslashes added before characters that need to be escaped.
13290 */
13291 const addSlashes = (str) => {
13292 return str.replace(/[\\"']/g, '\\$&');
13293 };
13294 /**
13295 *
13296 */
13297 const append = (parent, node) => {
13298 if (node)
13299 parent.append(node);
13300 };
13301 /**
13302 * Iterates over arrays and hashes.
13303 *
13304 * ```
13305 * iterate(this.items, function(item, id) {
13306 * // invoked for each item
13307 * });
13308 * ```
13309 *
13310 */
13311 const iterate = (object, callback) => {
13312 if (Array.isArray(object)) {
13313 object.forEach(callback);
13314 }
13315 else {
13316 for (var key in object) {
13317 if (object.hasOwnProperty(key)) {
13318 callback(object[key], key);
13319 }
13320 }
13321 }
13322 };
13323 //# sourceMappingURL=utils.js.map
13324
13325 /***/ },
13326
13327 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13328 /*!*****************************************************!*\
13329 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13330 \*****************************************************/
13331 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13332
13333 "use strict";
13334 __webpack_require__.r(__webpack_exports__);
13335 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13336 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13337 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13338 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13339 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13340 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13341 /* harmony export */ getDom: () => (/* binding */ getDom),
13342 /* harmony export */ getTail: () => (/* binding */ getTail),
13343 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13344 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13345 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13346 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13347 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13348 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13349 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13350 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13351 /* harmony export */ });
13352 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13353
13354 /**
13355 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13356 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13357 *
13358 * param query should be {}
13359 */
13360 const getDom = (query) => {
13361 if (query.jquery) {
13362 return query[0];
13363 }
13364 if (query instanceof HTMLElement) {
13365 return query;
13366 }
13367 if (isHtmlString(query)) {
13368 var tpl = document.createElement('template');
13369 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13370 return tpl.content.firstChild;
13371 }
13372 return document.querySelector(query);
13373 };
13374 const isHtmlString = (arg) => {
13375 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13376 return true;
13377 }
13378 return false;
13379 };
13380 const escapeQuery = (query) => {
13381 return query.replace(/['"\\]/g, '\\$&');
13382 };
13383 /**
13384 * Dispatch an event
13385 *
13386 */
13387 const triggerEvent = (dom_el, event_name) => {
13388 var event = document.createEvent('HTMLEvents');
13389 event.initEvent(event_name, true, false);
13390 dom_el.dispatchEvent(event);
13391 };
13392 /**
13393 * Apply CSS rules to a dom element
13394 *
13395 */
13396 const applyCSS = (dom_el, css) => {
13397 Object.assign(dom_el.style, css);
13398 };
13399 /**
13400 * Add css classes
13401 *
13402 */
13403 const addClasses = (elmts, ...classes) => {
13404 var norm_classes = classesArray(classes);
13405 elmts = castAsArray(elmts);
13406 elmts.map(el => {
13407 norm_classes.map(cls => {
13408 el.classList.add(cls);
13409 });
13410 });
13411 };
13412 /**
13413 * Remove css classes
13414 *
13415 */
13416 const removeClasses = (elmts, ...classes) => {
13417 var norm_classes = classesArray(classes);
13418 elmts = castAsArray(elmts);
13419 elmts.map(el => {
13420 norm_classes.map(cls => {
13421 el.classList.remove(cls);
13422 });
13423 });
13424 };
13425 /**
13426 * Return arguments
13427 *
13428 */
13429 const classesArray = (args) => {
13430 var classes = [];
13431 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13432 if (typeof _classes === 'string') {
13433 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13434 }
13435 if (Array.isArray(_classes)) {
13436 classes = classes.concat(_classes);
13437 }
13438 });
13439 return classes.filter(Boolean);
13440 };
13441 /**
13442 * Create an array from arg if it's not already an array
13443 *
13444 */
13445 const castAsArray = (arg) => {
13446 if (!Array.isArray(arg)) {
13447 arg = [arg];
13448 }
13449 return arg;
13450 };
13451 /**
13452 * Get the closest node to the evt.target matching the selector
13453 * Stops at wrapper
13454 *
13455 */
13456 const parentMatch = (target, selector, wrapper) => {
13457 if (wrapper && !wrapper.contains(target)) {
13458 return;
13459 }
13460 while (target && target.matches) {
13461 if (target.matches(selector)) {
13462 return target;
13463 }
13464 target = target.parentNode;
13465 }
13466 };
13467 /**
13468 * Get the first or last item from an array
13469 *
13470 * > 0 - right (last)
13471 * <= 0 - left (first)
13472 *
13473 */
13474 const getTail = (list, direction = 0) => {
13475 if (direction > 0) {
13476 return list[list.length - 1];
13477 }
13478 return list[0];
13479 };
13480 /**
13481 * Return true if an object is empty
13482 *
13483 */
13484 const isEmptyObject = (obj) => {
13485 return (Object.keys(obj).length === 0);
13486 };
13487 /**
13488 * Get the index of an element amongst sibling nodes of the same type
13489 *
13490 */
13491 const nodeIndex = (el, amongst) => {
13492 if (!el)
13493 return -1;
13494 amongst = amongst || el.nodeName;
13495 var i = 0;
13496 while (el = el.previousElementSibling) {
13497 if (el.matches(amongst)) {
13498 i++;
13499 }
13500 }
13501 return i;
13502 };
13503 /**
13504 * Set attributes of an element
13505 *
13506 */
13507 const setAttr = (el, attrs) => {
13508 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
13509 if (val == null) {
13510 el.removeAttribute(attr);
13511 }
13512 else {
13513 el.setAttribute(attr, '' + val);
13514 }
13515 });
13516 };
13517 /**
13518 * Replace a node
13519 */
13520 const replaceNode = (existing, replacement) => {
13521 if (existing.parentNode)
13522 existing.parentNode.replaceChild(replacement, existing);
13523 };
13524 //# sourceMappingURL=vanilla.js.map
13525
13526 /***/ }
13527
13528 /******/ });
13529 /************************************************************************/
13530 /******/ // The module cache
13531 /******/ var __webpack_module_cache__ = {};
13532 /******/
13533 /******/ // The require function
13534 /******/ function __webpack_require__(moduleId) {
13535 /******/ // Check if module is in cache
13536 /******/ var cachedModule = __webpack_module_cache__[moduleId];
13537 /******/ if (cachedModule !== undefined) {
13538 /******/ return cachedModule.exports;
13539 /******/ }
13540 /******/ // Create a new module (and put it into the cache)
13541 /******/ var module = __webpack_module_cache__[moduleId] = {
13542 /******/ id: moduleId,
13543 /******/ // no module.loaded needed
13544 /******/ exports: {}
13545 /******/ };
13546 /******/
13547 /******/ // Execute the module function
13548 /******/ if (!(moduleId in __webpack_modules__)) {
13549 /******/ delete __webpack_module_cache__[moduleId];
13550 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
13551 /******/ e.code = 'MODULE_NOT_FOUND';
13552 /******/ throw e;
13553 /******/ }
13554 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
13555 /******/
13556 /******/ // Return the exports of the module
13557 /******/ return module.exports;
13558 /******/ }
13559 /******/
13560 /************************************************************************/
13561 /******/ /* webpack/runtime/compat get default export */
13562 /******/ (() => {
13563 /******/ // getDefaultExport function for compatibility with non-harmony modules
13564 /******/ __webpack_require__.n = (module) => {
13565 /******/ var getter = module && module.__esModule ?
13566 /******/ () => (module['default']) :
13567 /******/ () => (module);
13568 /******/ __webpack_require__.d(getter, { a: getter });
13569 /******/ return getter;
13570 /******/ };
13571 /******/ })();
13572 /******/
13573 /******/ /* webpack/runtime/define property getters */
13574 /******/ (() => {
13575 /******/ // define getter functions for harmony exports
13576 /******/ __webpack_require__.d = (exports, definition) => {
13577 /******/ for(var key in definition) {
13578 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13579 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
13580 /******/ }
13581 /******/ }
13582 /******/ };
13583 /******/ })();
13584 /******/
13585 /******/ /* webpack/runtime/hasOwnProperty shorthand */
13586 /******/ (() => {
13587 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
13588 /******/ })();
13589 /******/
13590 /******/ /* webpack/runtime/make namespace object */
13591 /******/ (() => {
13592 /******/ // define __esModule on exports
13593 /******/ __webpack_require__.r = (exports) => {
13594 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
13595 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13596 /******/ }
13597 /******/ Object.defineProperty(exports, '__esModule', { value: true });
13598 /******/ };
13599 /******/ })();
13600 /******/
13601 /******/ /* webpack/runtime/nonce */
13602 /******/ (() => {
13603 /******/ __webpack_require__.nc = undefined;
13604 /******/ })();
13605 /******/
13606 /************************************************************************/
13607 var __webpack_exports__ = {};
13608 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
13609 (() => {
13610 "use strict";
13611 /*!********************************************!*\
13612 !*** ./assets/src/js/admin/admin-order.js ***!
13613 \********************************************/
13614 __webpack_require__.r(__webpack_exports__);
13615 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
13616 /* 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");
13617 /* harmony import */ var _order_refund_order__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./order/refund-order */ "./assets/src/js/admin/order/refund-order.js");
13618
13619
13620 //import modalSearchCourses from './order/modal-search-courses';
13621
13622
13623 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
13624 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
13625 (0,_order_refund_order__WEBPACK_IMPORTED_MODULE_2__["default"])();
13626 })();
13627
13628 /******/ })()
13629 ;
13630 //# sourceMappingURL=admin-order.js.map