PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9.1
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9.1
4.4.9.1 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 All 141 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.1, at assets/js/dist/admin/admin-order.js

13,705 lines 480.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.25
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 * @returns {boolean}
2216 */
2217 const isFirefox = () => navigator.userAgent.includes('Firefox');
2218
2219 /**
2220 * Gets the popup container which contains the backdrop and the popup itself.
2221 *
2222 * @returns {HTMLElement | null}
2223 */
2224 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
2225
2226 /**
2227 * @param {string} selectorString
2228 * @returns {HTMLElement | null}
2229 */
2230 const elementBySelector = selectorString => {
2231 const container = getContainer();
2232 return container ? container.querySelector(selectorString) : null;
2233 };
2234
2235 /**
2236 * @param {string} className
2237 * @returns {HTMLElement | null}
2238 */
2239 const elementByClass = className => {
2240 return elementBySelector(`.${className}`);
2241 };
2242
2243 /**
2244 * @returns {HTMLElement | null}
2245 */
2246 const getPopup = () => elementByClass(swalClasses.popup);
2247
2248 /**
2249 * @returns {HTMLElement | null}
2250 */
2251 const getIcon = () => elementByClass(swalClasses.icon);
2252
2253 /**
2254 * @returns {HTMLElement | null}
2255 */
2256 const getIconContent = () => elementByClass(swalClasses['icon-content']);
2257
2258 /**
2259 * @returns {HTMLElement | null}
2260 */
2261 const getTitle = () => elementByClass(swalClasses.title);
2262
2263 /**
2264 * @returns {HTMLElement | null}
2265 */
2266 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
2267
2268 /**
2269 * @returns {HTMLElement | null}
2270 */
2271 const getImage = () => elementByClass(swalClasses.image);
2272
2273 /**
2274 * @returns {HTMLElement | null}
2275 */
2276 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
2277
2278 /**
2279 * @returns {HTMLElement | null}
2280 */
2281 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
2282
2283 /**
2284 * @returns {HTMLButtonElement | null}
2285 */
2286 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
2287
2288 /**
2289 * @returns {HTMLButtonElement | null}
2290 */
2291 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
2292
2293 /**
2294 * @returns {HTMLButtonElement | null}
2295 */
2296 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
2297
2298 /**
2299 * @returns {HTMLElement | null}
2300 */
2301 const getInputLabel = () => elementByClass(swalClasses['input-label']);
2302
2303 /**
2304 * @returns {HTMLElement | null}
2305 */
2306 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
2307
2308 /**
2309 * @returns {HTMLElement | null}
2310 */
2311 const getActions = () => elementByClass(swalClasses.actions);
2312
2313 /**
2314 * @returns {HTMLElement | null}
2315 */
2316 const getFooter = () => elementByClass(swalClasses.footer);
2317
2318 /**
2319 * @returns {HTMLElement | null}
2320 */
2321 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
2322
2323 /**
2324 * @returns {HTMLElement | null}
2325 */
2326 const getCloseButton = () => elementByClass(swalClasses.close);
2327
2328 // https://github.com/jkup/focusable/blob/master/index.js
2329 const focusable = `
2330 a[href],
2331 area[href],
2332 input:not([disabled]),
2333 select:not([disabled]),
2334 textarea:not([disabled]),
2335 button:not([disabled]),
2336 iframe,
2337 object,
2338 embed,
2339 [tabindex="0"],
2340 [contenteditable],
2341 audio[controls],
2342 video[controls],
2343 summary
2344 `;
2345 /**
2346 * @returns {HTMLElement[]}
2347 */
2348 const getFocusableElements = () => {
2349 const popup = getPopup();
2350 if (!popup) {
2351 return [];
2352 }
2353 /** @type {NodeListOf<HTMLElement>} */
2354 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
2355 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
2356 // sort according to tabindex
2357 .sort((a, b) => {
2358 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
2359 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
2360 if (tabindexA > tabindexB) {
2361 return 1;
2362 } else if (tabindexA < tabindexB) {
2363 return -1;
2364 }
2365 return 0;
2366 });
2367
2368 /** @type {NodeListOf<HTMLElement>} */
2369 const otherFocusableElements = popup.querySelectorAll(focusable);
2370 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
2371 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
2372 };
2373
2374 /**
2375 * @returns {boolean}
2376 */
2377 const isModal = () => {
2378 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
2379 };
2380
2381 /**
2382 * @returns {boolean}
2383 */
2384 const isToast = () => {
2385 const popup = getPopup();
2386 if (!popup) {
2387 return false;
2388 }
2389 return hasClass(popup, swalClasses.toast);
2390 };
2391
2392 /**
2393 * @returns {boolean}
2394 */
2395 const isLoading = () => {
2396 const popup = getPopup();
2397 if (!popup) {
2398 return false;
2399 }
2400 return popup.hasAttribute('data-loading');
2401 };
2402
2403 /**
2404 * Securely set innerHTML of an element
2405 * https://github.com/sweetalert2/sweetalert2/issues/1926
2406 *
2407 * @param {HTMLElement} elem
2408 * @param {string} html
2409 */
2410 const setInnerHtml = (elem, html) => {
2411 elem.textContent = '';
2412 if (html) {
2413 const parser = new DOMParser();
2414 const parsed = parser.parseFromString(html, `text/html`);
2415 const head = parsed.querySelector('head');
2416 if (head) {
2417 Array.from(head.childNodes).forEach(child => {
2418 elem.appendChild(child);
2419 });
2420 }
2421 const body = parsed.querySelector('body');
2422 if (body) {
2423 Array.from(body.childNodes).forEach(child => {
2424 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
2425 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
2426 } else {
2427 elem.appendChild(child);
2428 }
2429 });
2430 }
2431 }
2432 };
2433
2434 /**
2435 * @param {HTMLElement} elem
2436 * @param {string} className
2437 * @returns {boolean}
2438 */
2439 const hasClass = (elem, className) => {
2440 if (!className) {
2441 return false;
2442 }
2443 return className.split(/\s+/).every(cls => elem.classList.contains(cls));
2444 };
2445
2446 /**
2447 * @param {HTMLElement} elem
2448 * @param {SweetAlertOptions} params
2449 */
2450 const removeCustomClasses = (elem, params) => {
2451 Array.from(elem.classList).forEach(className => {
2452 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
2453 elem.classList.remove(className);
2454 }
2455 });
2456 };
2457
2458 /**
2459 * @param {HTMLElement} elem
2460 * @param {SweetAlertOptions} params
2461 * @param {string} className
2462 */
2463 const applyCustomClass = (elem, params, className) => {
2464 removeCustomClasses(elem, params);
2465 if (!params.customClass) {
2466 return;
2467 }
2468 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
2469 if (!customClass) {
2470 return;
2471 }
2472 if (typeof customClass !== 'string' && !customClass.forEach) {
2473 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
2474 return;
2475 }
2476 addClass(elem, customClass);
2477 };
2478
2479 /**
2480 * @param {HTMLElement} popup
2481 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
2482 * @returns {HTMLInputElement | null}
2483 */
2484 const getInput$1 = (popup, inputClass) => {
2485 if (!inputClass) {
2486 return null;
2487 }
2488 switch (inputClass) {
2489 case 'select':
2490 case 'textarea':
2491 case 'file':
2492 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
2493 case 'checkbox':
2494 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
2495 case 'radio':
2496 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
2497 case 'range':
2498 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
2499 default:
2500 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
2501 }
2502 };
2503
2504 /**
2505 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
2506 */
2507 const focusInput = input => {
2508 input.focus();
2509
2510 // place cursor at end of text in text input
2511 if (input.type !== 'file') {
2512 // http://stackoverflow.com/a/2345915
2513 const val = input.value;
2514 input.value = '';
2515 input.value = val;
2516 }
2517 };
2518
2519 /**
2520 * @param {HTMLElement | HTMLElement[] | null} target
2521 * @param {string | string[] | readonly string[] | undefined} classList
2522 * @param {boolean} condition
2523 */
2524 const toggleClass = (target, classList, condition) => {
2525 if (!target || !classList) {
2526 return;
2527 }
2528 const classes = typeof classList === 'string' ? classList.split(/\s+/).filter(Boolean) : classList;
2529 const targets = Array.isArray(target) ? target : [target];
2530 targets.forEach(elem => {
2531 classes.forEach(className => {
2532 if (condition) {
2533 elem.classList.add(className);
2534 } else {
2535 elem.classList.remove(className);
2536 }
2537 });
2538 });
2539 };
2540
2541 /**
2542 * @param {HTMLElement | HTMLElement[] | null} target
2543 * @param {string | string[] | readonly string[] | undefined} classList
2544 */
2545 const addClass = (target, classList) => {
2546 toggleClass(target, classList, true);
2547 };
2548
2549 /**
2550 * @param {HTMLElement | HTMLElement[] | null} target
2551 * @param {string | string[] | readonly string[] | undefined} classList
2552 */
2553 const removeClass = (target, classList) => {
2554 toggleClass(target, classList, false);
2555 };
2556
2557 /**
2558 * Get direct child of an element by class name
2559 *
2560 * @param {HTMLElement} elem
2561 * @param {string} className
2562 * @returns {HTMLElement | undefined}
2563 */
2564 const getDirectChildByClass = (elem, className) => (/** @type {HTMLElement | undefined} */
2565 Array.from(elem.children).find(child => child instanceof HTMLElement && hasClass(child, className)));
2566
2567 /**
2568 * @param {HTMLElement} elem
2569 * @param {string} property
2570 * @param {string | number | null | undefined} value
2571 */
2572 const applyNumericalStyle = (elem, property, value) => {
2573 if (value === `${parseInt(`${value}`)}`) {
2574 value = parseInt(value);
2575 }
2576 if (value || value === 0) {
2577 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
2578 } else {
2579 elem.style.removeProperty(property);
2580 }
2581 };
2582
2583 /**
2584 * @param {HTMLElement | null} elem
2585 * @param {string} display
2586 */
2587 const show = (elem, display = 'flex') => {
2588 if (!elem) {
2589 return;
2590 }
2591 elem.style.display = display;
2592 };
2593
2594 /**
2595 * @param {HTMLElement | null} elem
2596 */
2597 const hide = elem => {
2598 if (!elem) {
2599 return;
2600 }
2601 elem.style.display = 'none';
2602 };
2603
2604 /**
2605 * @param {HTMLElement | null} elem
2606 * @param {string} display
2607 */
2608 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
2609 if (!elem) {
2610 return;
2611 }
2612 new MutationObserver(() => {
2613 toggle(elem, elem.innerHTML, display);
2614 }).observe(elem, {
2615 childList: true,
2616 subtree: true
2617 });
2618 };
2619
2620 /**
2621 * @param {HTMLElement} parent
2622 * @param {string} selector
2623 * @param {string} property
2624 * @param {string} value
2625 */
2626 const setStyle = (parent, selector, property, value) => {
2627 /** @type {HTMLElement | null} */
2628 const el = parent.querySelector(selector);
2629 if (el) {
2630 el.style.setProperty(property, value);
2631 }
2632 };
2633
2634 /**
2635 * @param {HTMLElement} elem
2636 * @param {boolean | string | null | undefined} condition
2637 * @param {string} display
2638 */
2639 const toggle = (elem, condition, display = 'flex') => {
2640 if (condition) {
2641 show(elem, display);
2642 } else {
2643 hide(elem);
2644 }
2645 };
2646
2647 /**
2648 * borrowed from jquery $(elem).is(':visible') implementation
2649 *
2650 * @param {HTMLElement | null} elem
2651 * @returns {boolean}
2652 */
2653 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
2654
2655 /**
2656 * @returns {boolean}
2657 */
2658 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
2659
2660 /**
2661 * @param {HTMLElement} elem
2662 * @returns {boolean}
2663 */
2664 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
2665
2666 /**
2667 * @param {HTMLElement} element
2668 * @param {HTMLElement} stopElement
2669 * @returns {boolean}
2670 */
2671 const selfOrParentIsScrollable = (element, stopElement) => {
2672 let parent = /** @type {HTMLElement | null} */element;
2673 while (parent && parent !== stopElement) {
2674 if (isScrollable(parent)) {
2675 return true;
2676 }
2677 parent = parent.parentElement;
2678 }
2679 return false;
2680 };
2681
2682 /**
2683 * borrowed from https://stackoverflow.com/a/46352119
2684 *
2685 * @param {HTMLElement} elem
2686 * @returns {boolean}
2687 */
2688 const hasCssAnimation = elem => {
2689 const style = window.getComputedStyle(elem);
2690 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
2691 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
2692 return animDuration > 0 || transDuration > 0;
2693 };
2694
2695 /**
2696 * @param {number} timer
2697 * @param {boolean} reset
2698 */
2699 const animateTimerProgressBar = (timer, reset = false) => {
2700 const timerProgressBar = getTimerProgressBar();
2701 if (!timerProgressBar) {
2702 return;
2703 }
2704 if (isVisible$1(timerProgressBar)) {
2705 if (reset) {
2706 timerProgressBar.style.transition = 'none';
2707 timerProgressBar.style.width = '100%';
2708 }
2709 setTimeout(() => {
2710 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
2711 timerProgressBar.style.width = '0%';
2712 }, 10);
2713 }
2714 };
2715 const stopTimerProgressBar = () => {
2716 const timerProgressBar = getTimerProgressBar();
2717 if (!timerProgressBar) {
2718 return;
2719 }
2720 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2721 timerProgressBar.style.removeProperty('transition');
2722 timerProgressBar.style.width = '100%';
2723 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
2724 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
2725 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
2726 };
2727
2728 /**
2729 * Detect Node env
2730 *
2731 * @returns {boolean}
2732 */
2733 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
2734
2735 const sweetHTML = `
2736 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
2737 <button type="button" class="${swalClasses.close}"></button>
2738 <ul class="${swalClasses['progress-steps']}"></ul>
2739 <div class="${swalClasses.icon}"></div>
2740 <img class="${swalClasses.image}" />
2741 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
2742 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
2743 <input class="${swalClasses.input}" id="${swalClasses.input}" />
2744 <input type="file" class="${swalClasses.file}" />
2745 <div class="${swalClasses.range}">
2746 <input type="range" />
2747 <output></output>
2748 </div>
2749 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
2750 <div class="${swalClasses.radio}"></div>
2751 <label class="${swalClasses.checkbox}">
2752 <input type="checkbox" id="${swalClasses.checkbox}" />
2753 <span class="${swalClasses.label}"></span>
2754 </label>
2755 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
2756 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
2757 <div class="${swalClasses.actions}">
2758 <div class="${swalClasses.loader}"></div>
2759 <button type="button" class="${swalClasses.confirm}"></button>
2760 <button type="button" class="${swalClasses.deny}"></button>
2761 <button type="button" class="${swalClasses.cancel}"></button>
2762 </div>
2763 <div class="${swalClasses.footer}"></div>
2764 <div class="${swalClasses['timer-progress-bar-container']}">
2765 <div class="${swalClasses['timer-progress-bar']}"></div>
2766 </div>
2767 </div>
2768 `.replace(/(^|\n)\s*/g, '');
2769
2770 /**
2771 * @returns {boolean}
2772 */
2773 const resetOldContainer = () => {
2774 const oldContainer = getContainer();
2775 if (!oldContainer) {
2776 return false;
2777 }
2778 oldContainer.remove();
2779 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
2780 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
2781 swalClasses['has-column']]);
2782 return true;
2783 };
2784 const resetValidationMessage$1 = () => {
2785 if (globalState.currentInstance) {
2786 globalState.currentInstance.resetValidationMessage();
2787 }
2788 };
2789 const addInputChangeListeners = () => {
2790 const popup = getPopup();
2791 if (!popup) {
2792 return;
2793 }
2794 const input = getDirectChildByClass(popup, swalClasses.input);
2795 const file = getDirectChildByClass(popup, swalClasses.file);
2796 /** @type {HTMLInputElement | null} */
2797 const range = popup.querySelector(`.${swalClasses.range} input`);
2798 /** @type {HTMLOutputElement | null} */
2799 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
2800 const select = getDirectChildByClass(popup, swalClasses.select);
2801 /** @type {HTMLInputElement | null} */
2802 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
2803 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
2804 if (input) {
2805 input.oninput = resetValidationMessage$1;
2806 }
2807 if (file) {
2808 file.onchange = resetValidationMessage$1;
2809 }
2810 if (select) {
2811 select.onchange = resetValidationMessage$1;
2812 }
2813 if (checkbox) {
2814 checkbox.onchange = resetValidationMessage$1;
2815 }
2816 if (textarea) {
2817 textarea.oninput = resetValidationMessage$1;
2818 }
2819 if (range && rangeOutput) {
2820 range.oninput = () => {
2821 resetValidationMessage$1();
2822 rangeOutput.value = range.value;
2823 };
2824 range.onchange = () => {
2825 resetValidationMessage$1();
2826 rangeOutput.value = range.value;
2827 };
2828 }
2829 };
2830
2831 /**
2832 * @param {string | HTMLElement} target
2833 * @returns {HTMLElement}
2834 */
2835 const getTarget = target => {
2836 if (typeof target === 'string') {
2837 const element = document.querySelector(target);
2838 if (!element) {
2839 throw new Error(`Target element "${target}" not found`);
2840 }
2841 return /** @type {HTMLElement} */element;
2842 }
2843 return target;
2844 };
2845
2846 /**
2847 * @param {SweetAlertOptions} params
2848 */
2849 const setupAccessibility = params => {
2850 const popup = getPopup();
2851 if (!popup) {
2852 return;
2853 }
2854 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
2855 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
2856 if (!params.toast) {
2857 popup.setAttribute('aria-modal', 'true');
2858 }
2859 };
2860
2861 /**
2862 * @param {HTMLElement} targetElement
2863 */
2864 const setupRTL = targetElement => {
2865 if (window.getComputedStyle(targetElement).direction === 'rtl') {
2866 addClass(getContainer(), swalClasses.rtl);
2867 globalState.isRTL = true;
2868 }
2869 };
2870
2871 /**
2872 * Add modal + backdrop to DOM
2873 *
2874 * @param {SweetAlertOptions} params
2875 */
2876 const init = params => {
2877 // Clean up the old popup container if it exists
2878 const oldContainerExisted = resetOldContainer();
2879 if (isNodeEnv()) {
2880 error('SweetAlert2 requires document to initialize');
2881 return;
2882 }
2883 const container = document.createElement('div');
2884 container.className = swalClasses.container;
2885 if (oldContainerExisted) {
2886 addClass(container, swalClasses['no-transition']);
2887 }
2888 setInnerHtml(container, sweetHTML);
2889 container.dataset['swal2Theme'] = params.theme;
2890 const targetElement = getTarget(params.target || 'body');
2891 targetElement.appendChild(container);
2892 if (params.topLayer) {
2893 container.setAttribute('popover', '');
2894 container.showPopover();
2895 }
2896 setupAccessibility(params);
2897 setupRTL(targetElement);
2898 addInputChangeListeners();
2899 };
2900
2901 /**
2902 * @param {HTMLElement | object | string} param
2903 * @param {HTMLElement} target
2904 */
2905 const parseHtmlToContainer = (param, target) => {
2906 // DOM element
2907 if (param instanceof HTMLElement) {
2908 target.appendChild(param);
2909 }
2910
2911 // Object
2912 else if (typeof param === 'object') {
2913 handleObject(param, target);
2914 }
2915
2916 // Plain string
2917 else if (param) {
2918 setInnerHtml(target, param);
2919 }
2920 };
2921
2922 /**
2923 * @param {object} param
2924 * @param {HTMLElement} target
2925 */
2926 const handleObject = (param, target) => {
2927 // JQuery element(s)
2928 if ('jquery' in param) {
2929 handleJqueryElem(target, param);
2930 }
2931
2932 // For other objects use their string representation
2933 else {
2934 setInnerHtml(target, param.toString());
2935 }
2936 };
2937
2938 /**
2939 * @param {HTMLElement} target
2940 * @param {any} elem
2941 */
2942 const handleJqueryElem = (target, elem) => {
2943 target.textContent = '';
2944 if (0 in elem) {
2945 for (let i = 0; i in elem; i++) {
2946 target.appendChild(elem[i].cloneNode(true));
2947 }
2948 } else {
2949 target.appendChild(elem.cloneNode(true));
2950 }
2951 };
2952
2953 /**
2954 * @param {SweetAlert} instance
2955 * @param {SweetAlertOptions} params
2956 */
2957 const renderActions = (instance, params) => {
2958 const actions = getActions();
2959 const loader = getLoader();
2960 if (!actions || !loader) {
2961 return;
2962 }
2963
2964 // Actions (buttons) wrapper
2965 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
2966 hide(actions);
2967 } else {
2968 show(actions);
2969 }
2970
2971 // Custom class
2972 applyCustomClass(actions, params, 'actions');
2973
2974 // Render all the buttons
2975 renderButtons(actions, loader, params);
2976
2977 // Loader
2978 setInnerHtml(loader, params.loaderHtml || '');
2979 applyCustomClass(loader, params, 'loader');
2980 };
2981
2982 /**
2983 * @param {HTMLElement} actions
2984 * @param {HTMLElement} loader
2985 * @param {SweetAlertOptions} params
2986 */
2987 function renderButtons(actions, loader, params) {
2988 const confirmButton = getConfirmButton();
2989 const denyButton = getDenyButton();
2990 const cancelButton = getCancelButton();
2991 if (!confirmButton || !denyButton || !cancelButton) {
2992 return;
2993 }
2994
2995 // Render buttons
2996 renderButton(confirmButton, 'confirm', params);
2997 renderButton(denyButton, 'deny', params);
2998 renderButton(cancelButton, 'cancel', params);
2999 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
3000 if (params.reverseButtons) {
3001 if (params.toast) {
3002 actions.insertBefore(cancelButton, confirmButton);
3003 actions.insertBefore(denyButton, confirmButton);
3004 } else {
3005 actions.insertBefore(cancelButton, loader);
3006 actions.insertBefore(denyButton, loader);
3007 actions.insertBefore(confirmButton, loader);
3008 }
3009 }
3010 }
3011
3012 /**
3013 * @param {HTMLElement} confirmButton
3014 * @param {HTMLElement} denyButton
3015 * @param {HTMLElement} cancelButton
3016 * @param {SweetAlertOptions} params
3017 */
3018 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
3019 if (!params.buttonsStyling) {
3020 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3021 return;
3022 }
3023 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
3024
3025 // Apply custom background colors and outline colors to action buttons
3026 /** @type {[HTMLElement, string, string | undefined][]} */
3027 const buttons = [[confirmButton, 'confirm', params.confirmButtonColor], [denyButton, 'deny', params.denyButtonColor], [cancelButton, 'cancel', params.cancelButtonColor]];
3028 buttons.forEach(([button, type, color]) => {
3029 if (color) {
3030 button.style.setProperty(`--swal2-${type}-button-background-color`, color);
3031 }
3032 applyOutlineColor(button);
3033 });
3034 }
3035
3036 /**
3037 * @param {HTMLElement} button
3038 */
3039 function applyOutlineColor(button) {
3040 const buttonStyle = window.getComputedStyle(button);
3041 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
3042 // If the button already has a custom outline color, no need to change it
3043 return;
3044 }
3045 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
3046 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
3047 }
3048
3049 /**
3050 * @param {HTMLElement} button
3051 * @param {'confirm' | 'deny' | 'cancel'} buttonType
3052 * @param {SweetAlertOptions} params
3053 */
3054 function renderButton(button, buttonType, params) {
3055 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
3056 toggle(button, params[`show${buttonName}Button`], 'inline-block');
3057 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
3058 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
3059
3060 // Add buttons custom classes
3061 button.className = swalClasses[buttonType];
3062 applyCustomClass(button, params, `${buttonType}Button`);
3063 }
3064
3065 /**
3066 * @param {SweetAlert} instance
3067 * @param {SweetAlertOptions} params
3068 */
3069 const renderCloseButton = (instance, params) => {
3070 const closeButton = getCloseButton();
3071 if (!closeButton) {
3072 return;
3073 }
3074 setInnerHtml(closeButton, params.closeButtonHtml || '');
3075
3076 // Custom class
3077 applyCustomClass(closeButton, params, 'closeButton');
3078 toggle(closeButton, params.showCloseButton);
3079 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
3080 };
3081
3082 /**
3083 * @param {SweetAlert} instance
3084 * @param {SweetAlertOptions} params
3085 */
3086 const renderContainer = (instance, params) => {
3087 const container = getContainer();
3088 if (!container) {
3089 return;
3090 }
3091 handleBackdropParam(container, params.backdrop);
3092 handlePositionParam(container, params.position);
3093 handleGrowParam(container, params.grow);
3094
3095 // Custom class
3096 applyCustomClass(container, params, 'container');
3097 };
3098
3099 /**
3100 * @param {HTMLElement} container
3101 * @param {SweetAlertOptions['backdrop']} backdrop
3102 */
3103 function handleBackdropParam(container, backdrop) {
3104 if (typeof backdrop === 'string') {
3105 container.style.background = backdrop;
3106 } else if (!backdrop) {
3107 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
3108 }
3109 }
3110
3111 /**
3112 * @param {HTMLElement} container
3113 * @param {SweetAlertOptions['position']} position
3114 */
3115 function handlePositionParam(container, position) {
3116 if (!position) {
3117 return;
3118 }
3119 if (position in swalClasses) {
3120 addClass(container, swalClasses[position]);
3121 } else {
3122 warn('The "position" parameter is not valid, defaulting to "center"');
3123 addClass(container, swalClasses.center);
3124 }
3125 }
3126
3127 /**
3128 * @param {HTMLElement} container
3129 * @param {SweetAlertOptions['grow']} grow
3130 */
3131 function handleGrowParam(container, grow) {
3132 if (!grow) {
3133 return;
3134 }
3135 addClass(container, swalClasses[`grow-${grow}`]);
3136 }
3137
3138 /**
3139 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
3140 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
3141 * This is the approach that Babel will probably take to implement private methods/fields
3142 * https://github.com/tc39/proposal-private-methods
3143 * https://github.com/babel/babel/pull/7555
3144 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
3145 * then we can use that language feature.
3146 */
3147
3148 var privateProps = {
3149 innerParams: new WeakMap(),
3150 domCache: new WeakMap(),
3151 focusedElement: new WeakMap()
3152 };
3153
3154 /// <reference path="../../../../sweetalert2.d.ts"/>
3155
3156
3157 /** @type {InputClass[]} */
3158 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
3159
3160 /**
3161 * @param {SweetAlert} instance
3162 * @param {SweetAlertOptions} params
3163 */
3164 const renderInput = (instance, params) => {
3165 const popup = getPopup();
3166 if (!popup) {
3167 return;
3168 }
3169 const innerParams = privateProps.innerParams.get(instance);
3170 const rerender = !innerParams || params.input !== innerParams.input;
3171 inputClasses.forEach(inputClass => {
3172 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
3173 if (!inputContainer) {
3174 return;
3175 }
3176
3177 // set attributes
3178 setAttributes(inputClass, params.inputAttributes);
3179
3180 // set class
3181 inputContainer.className = swalClasses[inputClass];
3182 if (rerender) {
3183 hide(inputContainer);
3184 }
3185 });
3186 if (params.input) {
3187 if (rerender) {
3188 showInput(params);
3189 }
3190 // set custom class
3191 setCustomClass(params);
3192 }
3193 };
3194
3195 /**
3196 * @param {SweetAlertOptions} params
3197 */
3198 const showInput = params => {
3199 if (!params.input) {
3200 return;
3201 }
3202 if (!renderInputType[params.input]) {
3203 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
3204 return;
3205 }
3206 const inputContainer = getInputContainer(params.input);
3207 if (!inputContainer) {
3208 return;
3209 }
3210 const input = renderInputType[params.input](inputContainer, params);
3211 show(inputContainer);
3212
3213 // input autofocus
3214 if (params.inputAutoFocus) {
3215 setTimeout(() => {
3216 focusInput(input);
3217 });
3218 }
3219 };
3220
3221 /**
3222 * @param {HTMLInputElement} input
3223 */
3224 const removeAttributes = input => {
3225 for (const {
3226 name
3227 } of Array.from(input.attributes)) {
3228 if (!['id', 'type', 'value', 'style'].includes(name)) {
3229 input.removeAttribute(name);
3230 }
3231 }
3232 };
3233
3234 /**
3235 * @param {InputClass} inputClass
3236 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
3237 */
3238 const setAttributes = (inputClass, inputAttributes) => {
3239 const popup = getPopup();
3240 if (!popup) {
3241 return;
3242 }
3243 const input = getInput$1(popup, inputClass);
3244 if (!input) {
3245 return;
3246 }
3247 removeAttributes(input);
3248 for (const attr in inputAttributes) {
3249 input.setAttribute(attr, inputAttributes[attr]);
3250 }
3251 };
3252
3253 /**
3254 * @param {SweetAlertOptions} params
3255 */
3256 const setCustomClass = params => {
3257 if (!params.input) {
3258 return;
3259 }
3260 const inputContainer = getInputContainer(params.input);
3261 if (inputContainer) {
3262 applyCustomClass(inputContainer, params, 'input');
3263 }
3264 };
3265
3266 /**
3267 * @param {HTMLInputElement | HTMLTextAreaElement} input
3268 * @param {SweetAlertOptions} params
3269 */
3270 const setInputPlaceholder = (input, params) => {
3271 if (!input.placeholder && params.inputPlaceholder) {
3272 input.placeholder = params.inputPlaceholder;
3273 }
3274 };
3275
3276 /**
3277 * @param {Input} input
3278 * @param {Input} prependTo
3279 * @param {SweetAlertOptions} params
3280 */
3281 const setInputLabel = (input, prependTo, params) => {
3282 if (params.inputLabel) {
3283 const label = document.createElement('label');
3284 const labelClass = swalClasses['input-label'];
3285 label.setAttribute('for', input.id);
3286 label.className = labelClass;
3287 if (typeof params.customClass === 'object') {
3288 addClass(label, params.customClass.inputLabel);
3289 }
3290 label.innerText = params.inputLabel;
3291 prependTo.insertAdjacentElement('beforebegin', label);
3292 }
3293 };
3294
3295 /**
3296 * @param {SweetAlertInput} inputType
3297 * @returns {HTMLElement | undefined}
3298 */
3299 const getInputContainer = inputType => {
3300 const popup = getPopup();
3301 if (!popup) {
3302 return;
3303 }
3304 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
3305 };
3306
3307 /**
3308 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
3309 * @param {SweetAlertOptions['inputValue']} inputValue
3310 */
3311 const checkAndSetInputValue = (input, inputValue) => {
3312 if (['string', 'number'].includes(typeof inputValue)) {
3313 input.value = `${inputValue}`;
3314 } else if (!isPromise(inputValue)) {
3315 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
3316 }
3317 };
3318
3319 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
3320 const renderInputType = {};
3321
3322 /**
3323 * @param {Input | HTMLElement} input
3324 * @param {SweetAlertOptions} params
3325 * @returns {Input}
3326 */
3327 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} */
3328 (input, params) => {
3329 // oxfmt-ignore
3330 const inputElement = /** @type {HTMLInputElement} */input;
3331 checkAndSetInputValue(inputElement, params.inputValue);
3332 setInputLabel(inputElement, inputElement, params);
3333 setInputPlaceholder(inputElement, params);
3334 // oxfmt-ignore
3335 inputElement.type = /** @type {string} */params.input;
3336 return inputElement;
3337 };
3338
3339 /**
3340 * @param {Input | HTMLElement} input
3341 * @param {SweetAlertOptions} params
3342 * @returns {Input}
3343 */
3344 renderInputType.file = (input, params) => {
3345 const inputElement = /** @type {HTMLInputElement} */input;
3346 setInputLabel(inputElement, inputElement, params);
3347 setInputPlaceholder(inputElement, params);
3348 return inputElement;
3349 };
3350
3351 /**
3352 * @param {Input | HTMLElement} range
3353 * @param {SweetAlertOptions} params
3354 * @returns {Input}
3355 */
3356 renderInputType.range = (range, params) => {
3357 const rangeContainer = /** @type {HTMLElement} */range;
3358 const rangeInput = rangeContainer.querySelector('input');
3359 const rangeOutput = rangeContainer.querySelector('output');
3360 if (rangeInput) {
3361 checkAndSetInputValue(rangeInput, params.inputValue);
3362 rangeInput.type = /** @type {string} */params.input;
3363 setInputLabel(rangeInput, /** @type {Input} */range, params);
3364 }
3365 if (rangeOutput) {
3366 checkAndSetInputValue(rangeOutput, params.inputValue);
3367 }
3368 return /** @type {Input} */range;
3369 };
3370
3371 /**
3372 * @param {Input | HTMLElement} select
3373 * @param {SweetAlertOptions} params
3374 * @returns {Input}
3375 */
3376 renderInputType.select = (select, params) => {
3377 const selectElement = /** @type {HTMLSelectElement} */select;
3378 selectElement.textContent = '';
3379 if (params.inputPlaceholder) {
3380 const placeholder = document.createElement('option');
3381 setInnerHtml(placeholder, params.inputPlaceholder);
3382 placeholder.value = '';
3383 placeholder.disabled = true;
3384 placeholder.selected = true;
3385 selectElement.appendChild(placeholder);
3386 }
3387 setInputLabel(selectElement, selectElement, params);
3388 return selectElement;
3389 };
3390
3391 /**
3392 * @param {Input | HTMLElement} radio
3393 * @returns {Input}
3394 */
3395 renderInputType.radio = radio => {
3396 const radioElement = /** @type {HTMLElement} */radio;
3397 radioElement.textContent = '';
3398 return /** @type {Input} */radio;
3399 };
3400
3401 /**
3402 * @param {Input | HTMLElement} checkboxContainer
3403 * @param {SweetAlertOptions} params
3404 * @returns {Input}
3405 */
3406 renderInputType.checkbox = (checkboxContainer, params) => {
3407 const popup = getPopup();
3408 if (!popup) {
3409 throw new Error('Popup not found');
3410 }
3411 const checkbox = getInput$1(popup, 'checkbox');
3412 if (!checkbox) {
3413 throw new Error('Checkbox input not found');
3414 }
3415 checkbox.value = '1';
3416 checkbox.checked = Boolean(params.inputValue);
3417 const containerElement = /** @type {HTMLElement} */checkboxContainer;
3418 const label = containerElement.querySelector('span');
3419 if (label) {
3420 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
3421 if (placeholderOrLabel) {
3422 setInnerHtml(label, placeholderOrLabel);
3423 }
3424 }
3425 return checkbox;
3426 };
3427
3428 /**
3429 * @param {Input | HTMLElement} textarea
3430 * @param {SweetAlertOptions} params
3431 * @returns {Input}
3432 */
3433 renderInputType.textarea = (textarea, params) => {
3434 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
3435 checkAndSetInputValue(textareaElement, params.inputValue);
3436 setInputPlaceholder(textareaElement, params);
3437 setInputLabel(textareaElement, textareaElement, params);
3438
3439 /**
3440 * @param {HTMLElement} el
3441 * @returns {number}
3442 */
3443 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
3444
3445 // https://github.com/sweetalert2/sweetalert2/issues/2291
3446 setTimeout(() => {
3447 // https://github.com/sweetalert2/sweetalert2/issues/1699
3448 if ('MutationObserver' in window) {
3449 const popup = getPopup();
3450 if (!popup) {
3451 return;
3452 }
3453 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
3454 const textareaResizeHandler = () => {
3455 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
3456 if (!document.body.contains(textareaElement)) {
3457 return;
3458 }
3459 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
3460 const popupElement = getPopup();
3461 if (popupElement) {
3462 if (textareaWidth > initialPopupWidth) {
3463 popupElement.style.width = `${textareaWidth}px`;
3464 } else {
3465 applyNumericalStyle(popupElement, 'width', params.width);
3466 }
3467 }
3468 };
3469 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
3470 attributes: true,
3471 attributeFilter: ['style']
3472 });
3473 }
3474 });
3475 return textareaElement;
3476 };
3477
3478 /**
3479 * @param {SweetAlert} instance
3480 * @param {SweetAlertOptions} params
3481 */
3482 const renderContent = (instance, params) => {
3483 const htmlContainer = getHtmlContainer();
3484 if (!htmlContainer) {
3485 return;
3486 }
3487 showWhenInnerHtmlPresent(htmlContainer);
3488 applyCustomClass(htmlContainer, params, 'htmlContainer');
3489
3490 // Content as HTML
3491 if (params.html) {
3492 parseHtmlToContainer(params.html, htmlContainer);
3493 show(htmlContainer, 'block');
3494 }
3495
3496 // Content as plain text
3497 else if (params.text) {
3498 htmlContainer.textContent = params.text;
3499 show(htmlContainer, 'block');
3500 }
3501
3502 // No content
3503 else {
3504 hide(htmlContainer);
3505 }
3506 renderInput(instance, params);
3507 };
3508
3509 /**
3510 * @param {SweetAlert} instance
3511 * @param {SweetAlertOptions} params
3512 */
3513 const renderFooter = (instance, params) => {
3514 const footer = getFooter();
3515 if (!footer) {
3516 return;
3517 }
3518 showWhenInnerHtmlPresent(footer);
3519 toggle(footer, Boolean(params.footer), 'block');
3520 if (params.footer) {
3521 parseHtmlToContainer(params.footer, footer);
3522 }
3523
3524 // Custom class
3525 applyCustomClass(footer, params, 'footer');
3526 };
3527
3528 /**
3529 * @param {SweetAlert} instance
3530 * @param {SweetAlertOptions} params
3531 */
3532 const renderIcon = (instance, params) => {
3533 const innerParams = privateProps.innerParams.get(instance);
3534 const icon = getIcon();
3535 if (!icon) {
3536 return;
3537 }
3538
3539 // if the given icon already rendered, apply the styling without re-rendering the icon
3540 if (innerParams && params.icon === innerParams.icon) {
3541 // Custom or default content
3542 setContent(icon, params);
3543 applyStyles(icon, params);
3544 return;
3545 }
3546 if (!params.icon && !params.iconHtml) {
3547 hide(icon);
3548 return;
3549 }
3550 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
3551 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
3552 hide(icon);
3553 return;
3554 }
3555 show(icon);
3556
3557 // Custom or default content
3558 setContent(icon, params);
3559 applyStyles(icon, params);
3560
3561 // Animate icon
3562 addClass(icon, params.showClass && params.showClass.icon);
3563
3564 // Re-adjust the success icon on system theme change
3565 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
3566 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
3567 };
3568
3569 /**
3570 * @param {HTMLElement} icon
3571 * @param {SweetAlertOptions} params
3572 */
3573 const applyStyles = (icon, params) => {
3574 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
3575 if (params.icon !== iconType) {
3576 removeClass(icon, iconClassName);
3577 }
3578 }
3579 addClass(icon, params.icon && iconTypes[params.icon]);
3580
3581 // Icon color
3582 setColor(icon, params);
3583
3584 // Success icon background color
3585 adjustSuccessIconBackgroundColor();
3586
3587 // Custom class
3588 applyCustomClass(icon, params, 'icon');
3589 };
3590
3591 // Adjust success icon background color to match the popup background color
3592 const adjustSuccessIconBackgroundColor = () => {
3593 const popup = getPopup();
3594 if (!popup) {
3595 return;
3596 }
3597 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
3598 /** @type {NodeListOf<HTMLElement>} */
3599 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
3600 successIconParts.forEach(part => {
3601 part.style.backgroundColor = popupBackgroundColor;
3602 });
3603 };
3604
3605 /**
3606 *
3607 * @param {SweetAlertOptions} params
3608 * @returns {string}
3609 */
3610 const successIconHtml = params => `
3611 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
3612 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
3613 <div class="swal2-success-ring"></div>
3614 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
3615 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
3616 `;
3617 const errorIconHtml = `
3618 <span class="swal2-x-mark">
3619 <span class="swal2-x-mark-line-left"></span>
3620 <span class="swal2-x-mark-line-right"></span>
3621 </span>
3622 `;
3623
3624 /**
3625 * @param {HTMLElement} icon
3626 * @param {SweetAlertOptions} params
3627 */
3628 const setContent = (icon, params) => {
3629 if (!params.icon && !params.iconHtml) {
3630 return;
3631 }
3632 let oldContent = icon.innerHTML;
3633 let newContent = '';
3634 if (params.iconHtml) {
3635 newContent = iconContent(params.iconHtml);
3636 } else if (params.icon === 'success') {
3637 newContent = successIconHtml(params);
3638 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
3639 } else if (params.icon === 'error') {
3640 newContent = errorIconHtml;
3641 } else if (params.icon) {
3642 const defaultIconHtml = {
3643 question: '?',
3644 warning: '!',
3645 info: 'i'
3646 };
3647 newContent = iconContent(defaultIconHtml[params.icon]);
3648 }
3649 if (oldContent.trim() !== newContent.trim()) {
3650 setInnerHtml(icon, newContent);
3651 }
3652 };
3653
3654 /**
3655 * @param {HTMLElement} icon
3656 * @param {SweetAlertOptions} params
3657 */
3658 const setColor = (icon, params) => {
3659 if (!params.iconColor) {
3660 return;
3661 }
3662 icon.style.color = params.iconColor;
3663 icon.style.borderColor = params.iconColor;
3664 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
3665 setStyle(icon, sel, 'background-color', params.iconColor);
3666 }
3667 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
3668 };
3669
3670 /**
3671 * @param {string} content
3672 * @returns {string}
3673 */
3674 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
3675
3676 /**
3677 * @param {SweetAlert} instance
3678 * @param {SweetAlertOptions} params
3679 */
3680 const renderImage = (instance, params) => {
3681 const image = getImage();
3682 if (!image) {
3683 return;
3684 }
3685 if (!params.imageUrl) {
3686 hide(image);
3687 return;
3688 }
3689 show(image, '');
3690
3691 // Src, alt
3692 image.setAttribute('src', params.imageUrl);
3693 image.setAttribute('alt', params.imageAlt || '');
3694
3695 // Width, height
3696 applyNumericalStyle(image, 'width', params.imageWidth);
3697 applyNumericalStyle(image, 'height', params.imageHeight);
3698
3699 // Class
3700 image.className = swalClasses.image;
3701 applyCustomClass(image, params, 'image');
3702 };
3703
3704 let dragging = false;
3705 let mousedownX = 0;
3706 let mousedownY = 0;
3707 let initialX = 0;
3708 let initialY = 0;
3709
3710 /**
3711 * @param {HTMLElement} popup
3712 */
3713 const addDraggableListeners = popup => {
3714 popup.addEventListener('mousedown', down);
3715 document.body.addEventListener('mousemove', move);
3716 popup.addEventListener('mouseup', up);
3717 popup.addEventListener('touchstart', down);
3718 document.body.addEventListener('touchmove', move);
3719 popup.addEventListener('touchend', up);
3720 };
3721
3722 /**
3723 * @param {HTMLElement} popup
3724 */
3725 const removeDraggableListeners = popup => {
3726 popup.removeEventListener('mousedown', down);
3727 document.body.removeEventListener('mousemove', move);
3728 popup.removeEventListener('mouseup', up);
3729 popup.removeEventListener('touchstart', down);
3730 document.body.removeEventListener('touchmove', move);
3731 popup.removeEventListener('touchend', up);
3732 };
3733
3734 /**
3735 * @param {MouseEvent | TouchEvent} event
3736 */
3737 const down = event => {
3738 const popup = getPopup();
3739 if (!popup) {
3740 return;
3741 }
3742 const icon = getIcon();
3743 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
3744 dragging = true;
3745 const clientXY = getClientXY(event);
3746 mousedownX = clientXY.clientX;
3747 mousedownY = clientXY.clientY;
3748 initialX = parseInt(popup.style.insetInlineStart) || 0;
3749 initialY = parseInt(popup.style.insetBlockStart) || 0;
3750 addClass(popup, 'swal2-dragging');
3751 }
3752 };
3753
3754 /**
3755 * @param {MouseEvent | TouchEvent} event
3756 */
3757 const move = event => {
3758 const popup = getPopup();
3759 if (!popup) {
3760 return;
3761 }
3762 if (dragging) {
3763 let {
3764 clientX,
3765 clientY
3766 } = getClientXY(event);
3767 const deltaX = clientX - mousedownX;
3768 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
3769 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
3770 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
3771 }
3772 };
3773 const up = () => {
3774 const popup = getPopup();
3775 dragging = false;
3776 removeClass(popup, 'swal2-dragging');
3777 };
3778
3779 /**
3780 * @param {MouseEvent | TouchEvent} event
3781 * @returns {{ clientX: number, clientY: number }}
3782 */
3783 const getClientXY = event => {
3784 const source = event.type.startsWith('touch') ? /** @type {TouchEvent} */event.touches[0] : (/** @type {MouseEvent} */event);
3785 return {
3786 clientX: source.clientX,
3787 clientY: source.clientY
3788 };
3789 };
3790
3791 /**
3792 * @param {SweetAlert} instance
3793 * @param {SweetAlertOptions} params
3794 */
3795 const renderPopup = (instance, params) => {
3796 const container = getContainer();
3797 const popup = getPopup();
3798 if (!container || !popup) {
3799 return;
3800 }
3801
3802 // Width
3803 // https://github.com/sweetalert2/sweetalert2/issues/2170
3804 if (params.toast) {
3805 applyNumericalStyle(container, 'width', params.width);
3806 popup.style.width = '100%';
3807 const loader = getLoader();
3808 if (loader) {
3809 popup.insertBefore(loader, getIcon());
3810 }
3811 } else {
3812 applyNumericalStyle(popup, 'width', params.width);
3813 }
3814
3815 // Padding
3816 applyNumericalStyle(popup, 'padding', params.padding);
3817
3818 // Color
3819 if (params.color) {
3820 popup.style.color = params.color;
3821 }
3822
3823 // Background
3824 if (params.background) {
3825 popup.style.background = params.background;
3826 }
3827 hide(getValidationMessage());
3828
3829 // Classes
3830 addClasses$1(popup, params);
3831 if (params.draggable && !params.toast) {
3832 addClass(popup, swalClasses.draggable);
3833 addDraggableListeners(popup);
3834 } else {
3835 removeClass(popup, swalClasses.draggable);
3836 removeDraggableListeners(popup);
3837 }
3838 };
3839
3840 /**
3841 * @param {HTMLElement} popup
3842 * @param {SweetAlertOptions} params
3843 */
3844 const addClasses$1 = (popup, params) => {
3845 const showClass = params.showClass || {};
3846 // Default Class + showClass when updating Swal.update({})
3847 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
3848 if (params.toast) {
3849 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
3850 addClass(popup, swalClasses.toast);
3851 } else {
3852 addClass(popup, swalClasses.modal);
3853 }
3854
3855 // Custom class
3856 applyCustomClass(popup, params, 'popup');
3857 // TODO: remove in the next major
3858 if (typeof params.customClass === 'string') {
3859 addClass(popup, params.customClass);
3860 }
3861
3862 // Icon class (#1842)
3863 if (params.icon) {
3864 addClass(popup, swalClasses[`icon-${params.icon}`]);
3865 }
3866 };
3867
3868 /**
3869 * @param {SweetAlert} instance
3870 * @param {SweetAlertOptions} params
3871 */
3872 const renderProgressSteps = (instance, params) => {
3873 const progressStepsContainer = getProgressSteps();
3874 if (!progressStepsContainer) {
3875 return;
3876 }
3877 const {
3878 progressSteps,
3879 currentProgressStep
3880 } = params;
3881 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
3882 hide(progressStepsContainer);
3883 return;
3884 }
3885 show(progressStepsContainer);
3886 progressStepsContainer.textContent = '';
3887 if (currentProgressStep >= progressSteps.length) {
3888 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
3889 }
3890 progressSteps.forEach((step, index) => {
3891 const stepEl = createStepElement(step);
3892 progressStepsContainer.appendChild(stepEl);
3893 if (index === currentProgressStep) {
3894 addClass(stepEl, swalClasses['active-progress-step']);
3895 }
3896 if (index !== progressSteps.length - 1) {
3897 const lineEl = createLineElement(params);
3898 progressStepsContainer.appendChild(lineEl);
3899 }
3900 });
3901 };
3902
3903 /**
3904 * @param {string} step
3905 * @returns {HTMLLIElement}
3906 */
3907 const createStepElement = step => {
3908 const stepEl = document.createElement('li');
3909 addClass(stepEl, swalClasses['progress-step']);
3910 setInnerHtml(stepEl, step);
3911 return stepEl;
3912 };
3913
3914 /**
3915 * @param {SweetAlertOptions} params
3916 * @returns {HTMLLIElement}
3917 */
3918 const createLineElement = params => {
3919 const lineEl = document.createElement('li');
3920 addClass(lineEl, swalClasses['progress-step-line']);
3921 if (params.progressStepsDistance) {
3922 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
3923 }
3924 return lineEl;
3925 };
3926
3927 /**
3928 * @param {SweetAlert} instance
3929 * @param {SweetAlertOptions} params
3930 */
3931 const renderTitle = (instance, params) => {
3932 const title = getTitle();
3933 if (!title) {
3934 return;
3935 }
3936 showWhenInnerHtmlPresent(title);
3937 toggle(title, Boolean(params.title || params.titleText), 'block');
3938 if (params.title) {
3939 parseHtmlToContainer(params.title, title);
3940 }
3941 if (params.titleText) {
3942 title.innerText = params.titleText;
3943 }
3944
3945 // Custom class
3946 applyCustomClass(title, params, 'title');
3947 };
3948
3949 /**
3950 * @param {SweetAlert} instance
3951 * @param {SweetAlertOptions} params
3952 */
3953 const render = (instance, params) => {
3954 var _globalState$eventEmi;
3955 renderPopup(instance, params);
3956 renderContainer(instance, params);
3957 renderProgressSteps(instance, params);
3958 renderIcon(instance, params);
3959 renderImage(instance, params);
3960 renderTitle(instance, params);
3961 renderCloseButton(instance, params);
3962 renderContent(instance, params);
3963 renderActions(instance, params);
3964 renderFooter(instance, params);
3965 const popup = getPopup();
3966 if (typeof params.didRender === 'function' && popup) {
3967 params.didRender(popup);
3968 }
3969 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
3970 };
3971
3972 /*
3973 * Global function to determine if SweetAlert2 popup is shown
3974 */
3975 const isVisible = () => {
3976 return isVisible$1(getPopup());
3977 };
3978
3979 /*
3980 * Global function to click 'Confirm' button
3981 */
3982 const clickConfirm = () => {
3983 var _dom$getConfirmButton;
3984 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
3985 };
3986
3987 /*
3988 * Global function to click 'Deny' button
3989 */
3990 const clickDeny = () => {
3991 var _dom$getDenyButton;
3992 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
3993 };
3994
3995 /*
3996 * Global function to click 'Cancel' button
3997 */
3998 const clickCancel = () => {
3999 var _dom$getCancelButton;
4000 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
4001 };
4002
4003 /** @type {Record<DismissReason, DismissReason>} */
4004 const DismissReason = Object.freeze({
4005 cancel: 'cancel',
4006 backdrop: 'backdrop',
4007 close: 'close',
4008 esc: 'esc',
4009 timer: 'timer'
4010 });
4011
4012 /**
4013 * @param {GlobalState} globalState
4014 */
4015 const removeKeydownHandler = globalState => {
4016 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
4017 const handler = /** @type {EventListenerOrEventListenerObject} */
4018 /** @type {unknown} */globalState.keydownHandler;
4019 globalState.keydownTarget.removeEventListener('keydown', handler, {
4020 capture: globalState.keydownListenerCapture
4021 });
4022 globalState.keydownHandlerAdded = false;
4023 }
4024 };
4025
4026 /**
4027 * @param {GlobalState} globalState
4028 * @param {SweetAlertOptions} innerParams
4029 * @param {(dismiss: DismissReason) => void} dismissWith
4030 */
4031 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
4032 removeKeydownHandler(globalState);
4033 if (!innerParams.toast) {
4034 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
4035 const handler = e => keydownHandler(innerParams, e, dismissWith);
4036 globalState.keydownHandler = handler;
4037 const target = innerParams.keydownListenerCapture ? window : getPopup();
4038 if (target) {
4039 globalState.keydownTarget = target;
4040 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
4041 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
4042 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
4043 capture: globalState.keydownListenerCapture
4044 });
4045 globalState.keydownHandlerAdded = true;
4046 }
4047 }
4048 };
4049
4050 /**
4051 * @param {number} index
4052 * @param {number} increment
4053 * @returns {boolean} shouldPreventDefault
4054 */
4055 const setFocus = (index, increment) => {
4056 var _dom$getPopup;
4057 const focusableElements = getFocusableElements();
4058 // search for visible elements and select the next possible match
4059 if (focusableElements.length) {
4060 index = index + increment;
4061
4062 // shift + tab when .swal2-popup is focused
4063 if (index === -2) {
4064 index = focusableElements.length - 1;
4065 }
4066
4067 // rollover to first item
4068 if (index === focusableElements.length) {
4069 index = 0;
4070
4071 // go to last item
4072 } else if (index === -1) {
4073 index = focusableElements.length - 1;
4074 }
4075 focusableElements[index].focus();
4076
4077 // don't prevent default for iframes (Firefox fix)
4078 // https://github.com/sweetalert2/sweetalert2/issues/2931
4079 if (isFirefox() && focusableElements[index] instanceof HTMLIFrameElement) {
4080 return false;
4081 }
4082 return true;
4083 }
4084 // no visible focusable elements, focus the popup
4085 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
4086 return true;
4087 };
4088 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
4089 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
4090
4091 /**
4092 * @param {SweetAlertOptions} innerParams
4093 * @param {KeyboardEvent} event
4094 * @param {(dismiss: DismissReason) => void} dismissWith
4095 */
4096 const keydownHandler = (innerParams, event, dismissWith) => {
4097 if (!innerParams) {
4098 return; // This instance has already been destroyed
4099 }
4100
4101 // Ignore keydown during IME composition
4102 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
4103 // https://github.com/sweetalert2/sweetalert2/issues/720
4104 // https://github.com/sweetalert2/sweetalert2/issues/2406
4105 if (event.isComposing || event.keyCode === 229) {
4106 return;
4107 }
4108 if (innerParams.stopKeydownPropagation) {
4109 event.stopPropagation();
4110 }
4111
4112 // ENTER
4113 if (event.key === 'Enter') {
4114 handleEnter(event, innerParams);
4115 }
4116
4117 // TAB
4118 else if (event.key === 'Tab') {
4119 handleTab(event);
4120 }
4121
4122 // ARROWS - switch focus between buttons
4123 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
4124 handleArrows(event.key);
4125 }
4126
4127 // ESC
4128 else if (event.key === 'Escape') {
4129 handleEsc(event, innerParams, dismissWith);
4130 }
4131 };
4132
4133 /**
4134 * @param {KeyboardEvent} event
4135 * @param {SweetAlertOptions} innerParams
4136 */
4137 const handleEnter = (event, innerParams) => {
4138 // https://github.com/sweetalert2/sweetalert2/issues/2386
4139 if (!callIfFunction(innerParams.allowEnterKey)) {
4140 return;
4141 }
4142 const popup = getPopup();
4143 if (!popup || !innerParams.input) {
4144 return;
4145 }
4146 const input = getInput$1(popup, innerParams.input);
4147 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
4148 if (['textarea', 'file'].includes(innerParams.input)) {
4149 return; // do not submit
4150 }
4151 clickConfirm();
4152 event.preventDefault();
4153 }
4154 };
4155
4156 /**
4157 * @param {KeyboardEvent} event
4158 */
4159 const handleTab = event => {
4160 const targetElement = event.target;
4161 const focusableElements = getFocusableElements();
4162 const btnIndex = focusableElements.findIndex(el => el === targetElement);
4163
4164 // don't prevent default for iframes (Firefox fix)
4165 // https://github.com/sweetalert2/sweetalert2/issues/2931
4166 let shouldPreventDefault = true;
4167
4168 // Cycle to the next button
4169 if (!event.shiftKey) {
4170 shouldPreventDefault = setFocus(btnIndex, 1);
4171 }
4172
4173 // Cycle to the prev button
4174 else {
4175 shouldPreventDefault = setFocus(btnIndex, -1);
4176 }
4177 event.stopPropagation();
4178 if (shouldPreventDefault) {
4179 event.preventDefault();
4180 }
4181 };
4182
4183 /**
4184 * @param {string} key
4185 */
4186 const handleArrows = key => {
4187 const actions = getActions();
4188 const confirmButton = getConfirmButton();
4189 const denyButton = getDenyButton();
4190 const cancelButton = getCancelButton();
4191 if (!actions || !confirmButton || !denyButton || !cancelButton) {
4192 return;
4193 }
4194 /** @type HTMLElement[] */
4195 const buttons = [confirmButton, denyButton, cancelButton];
4196 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
4197 return;
4198 }
4199 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
4200 let buttonToFocus = document.activeElement;
4201 if (!buttonToFocus) {
4202 return;
4203 }
4204 for (let i = 0; i < actions.children.length; i++) {
4205 buttonToFocus = buttonToFocus[sibling];
4206 if (!buttonToFocus) {
4207 return;
4208 }
4209 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
4210 break;
4211 }
4212 }
4213 if (buttonToFocus instanceof HTMLButtonElement) {
4214 buttonToFocus.focus();
4215 }
4216 };
4217
4218 /**
4219 * @param {KeyboardEvent} event
4220 * @param {SweetAlertOptions} innerParams
4221 * @param {(dismiss: DismissReason) => void} dismissWith
4222 */
4223 const handleEsc = (event, innerParams, dismissWith) => {
4224 event.preventDefault();
4225 if (callIfFunction(innerParams.allowEscapeKey)) {
4226 dismissWith(DismissReason.esc);
4227 }
4228 };
4229
4230 /**
4231 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
4232 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
4233 * This is the approach that Babel will probably take to implement private methods/fields
4234 * https://github.com/tc39/proposal-private-methods
4235 * https://github.com/babel/babel/pull/7555
4236 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
4237 * then we can use that language feature.
4238 */
4239
4240 var privateMethods = {
4241 swalPromiseResolve: new WeakMap(),
4242 swalPromiseReject: new WeakMap()
4243 };
4244
4245 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
4246 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
4247 // elements not within the active modal dialog will not be surfaced if a user opens a screen
4248 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
4249
4250 const setAriaHidden = () => {
4251 const container = getContainer();
4252 const bodyChildren = Array.from(document.body.children);
4253 bodyChildren.forEach(el => {
4254 if (el.contains(container)) {
4255 return;
4256 }
4257 if (el.hasAttribute('aria-hidden')) {
4258 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
4259 }
4260 el.setAttribute('aria-hidden', 'true');
4261 });
4262 };
4263 const unsetAriaHidden = () => {
4264 const bodyChildren = Array.from(document.body.children);
4265 bodyChildren.forEach(el => {
4266 if (el.hasAttribute('data-previous-aria-hidden')) {
4267 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
4268 el.removeAttribute('data-previous-aria-hidden');
4269 } else {
4270 el.removeAttribute('aria-hidden');
4271 }
4272 });
4273 };
4274
4275 // @ts-ignore
4276 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
4277
4278 // @ts-ignore
4279 const isIOS = isSafariOrIOS && /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
4280
4281 /**
4282 * Fix iOS scrolling
4283 * http://stackoverflow.com/q/39626302
4284 */
4285 const iOSfix = () => {
4286 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
4287 const offset = document.body.scrollTop;
4288 document.body.style.top = `${offset * -1}px`;
4289 addClass(document.body, swalClasses.iosfix);
4290 lockBodyScroll();
4291 }
4292 };
4293
4294 /**
4295 * https://github.com/sweetalert2/sweetalert2/issues/1246
4296 */
4297 const lockBodyScroll = () => {
4298 const container = getContainer();
4299 if (!container) {
4300 return;
4301 }
4302 /** @type {boolean} */
4303 let preventTouchMove;
4304 /**
4305 * @param {TouchEvent} event
4306 */
4307 container.ontouchstart = event => {
4308 preventTouchMove = shouldPreventTouchMove(event);
4309 };
4310 /**
4311 * @param {TouchEvent} event
4312 */
4313 container.ontouchmove = event => {
4314 if (preventTouchMove) {
4315 event.preventDefault();
4316 event.stopPropagation();
4317 }
4318 };
4319 };
4320
4321 /**
4322 * @param {TouchEvent} event
4323 * @returns {boolean}
4324 */
4325 const shouldPreventTouchMove = event => {
4326 const target = event.target;
4327 const container = getContainer();
4328 const htmlContainer = getHtmlContainer();
4329 if (!container || !htmlContainer) {
4330 return false;
4331 }
4332 if (isStylus(event) || isZoom(event)) {
4333 return false;
4334 }
4335 if (target === container) {
4336 return true;
4337 }
4338 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
4339 // #2823
4340 target.tagName !== 'INPUT' &&
4341 // #1603
4342 target.tagName !== 'TEXTAREA' &&
4343 // #2266
4344 !(isScrollable(htmlContainer) &&
4345 // #1944
4346 htmlContainer.contains(target))) {
4347 return true;
4348 }
4349 return false;
4350 };
4351
4352 /**
4353 * https://github.com/sweetalert2/sweetalert2/issues/1786
4354 *
4355 * @param {TouchEvent} event
4356 * @returns {boolean}
4357 */
4358 const isStylus = event => {
4359 return Boolean(event.touches && event.touches.length &&
4360 // @ts-ignore - touchType is not a standard property
4361 event.touches[0].touchType === 'stylus');
4362 };
4363
4364 /**
4365 * https://github.com/sweetalert2/sweetalert2/issues/1891
4366 *
4367 * @param {TouchEvent} event
4368 * @returns {boolean}
4369 */
4370 const isZoom = event => {
4371 return event.touches && event.touches.length > 1;
4372 };
4373 const undoIOSfix = () => {
4374 if (hasClass(document.body, swalClasses.iosfix)) {
4375 const offset = parseInt(document.body.style.top, 10);
4376 removeClass(document.body, swalClasses.iosfix);
4377 document.body.style.top = '';
4378 document.body.scrollTop = offset * -1;
4379 }
4380 };
4381
4382 /**
4383 * Measure scrollbar width for padding body during modal show/hide
4384 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
4385 *
4386 * @returns {number}
4387 */
4388 const measureScrollbar = () => {
4389 const scrollDiv = document.createElement('div');
4390 scrollDiv.className = swalClasses['scrollbar-measure'];
4391 document.body.appendChild(scrollDiv);
4392 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
4393 document.body.removeChild(scrollDiv);
4394 return scrollbarWidth;
4395 };
4396
4397 /**
4398 * Remember state in cases where opening and handling a modal will fiddle with it.
4399 * @type {number | null}
4400 */
4401 let previousBodyPadding = null;
4402
4403 /**
4404 * @param {string} initialBodyOverflow
4405 */
4406 const replaceScrollbarWithPadding = initialBodyOverflow => {
4407 // for queues, do not do this more than once
4408 if (previousBodyPadding !== null) {
4409 return;
4410 }
4411 // if the body has overflow
4412 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
4413 ) {
4414 // add padding so the content doesn't shift after removal of scrollbar
4415 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
4416 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
4417 }
4418 };
4419 const undoReplaceScrollbarWithPadding = () => {
4420 if (previousBodyPadding !== null) {
4421 document.body.style.paddingRight = `${previousBodyPadding}px`;
4422 previousBodyPadding = null;
4423 }
4424 };
4425
4426 /**
4427 * @param {SweetAlert} instance
4428 * @param {HTMLElement} container
4429 * @param {boolean} returnFocus
4430 * @param {(() => void) | undefined} didClose
4431 */
4432 function removePopupAndResetState(instance, container, returnFocus, didClose) {
4433 if (isToast()) {
4434 triggerDidCloseAndDispose(instance, didClose);
4435 } else {
4436 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
4437 removeKeydownHandler(globalState);
4438 }
4439
4440 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
4441 // for some reason removing the container in Safari will scroll the document to bottom
4442 if (isSafariOrIOS) {
4443 container.setAttribute('style', 'display:none !important');
4444 container.removeAttribute('class');
4445 container.innerHTML = '';
4446 } else {
4447 container.remove();
4448 }
4449 if (isModal()) {
4450 undoReplaceScrollbarWithPadding();
4451 undoIOSfix();
4452 unsetAriaHidden();
4453 }
4454 removeBodyClasses();
4455 }
4456
4457 /**
4458 * Remove SweetAlert2 classes from body
4459 */
4460 function removeBodyClasses() {
4461 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
4462 }
4463
4464 /**
4465 * Instance method to close sweetAlert
4466 *
4467 * @param {SweetAlertResult | undefined} resolveValue
4468 * @this {SweetAlert}
4469 */
4470 function close(resolveValue) {
4471 resolveValue = prepareResolveValue(resolveValue);
4472 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
4473 const didClose = triggerClosePopup(this);
4474 if (this.isAwaitingPromise) {
4475 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
4476 if (!resolveValue.isDismissed) {
4477 handleAwaitingPromise(this);
4478 swalPromiseResolve(resolveValue);
4479 }
4480 } else if (didClose) {
4481 // Resolve Swal promise
4482 swalPromiseResolve(resolveValue);
4483 }
4484 }
4485
4486 /**
4487 * @param {SweetAlert} instance
4488 * @returns {boolean}
4489 */
4490 const triggerClosePopup = instance => {
4491 const popup = getPopup();
4492 if (!popup) {
4493 return false;
4494 }
4495 const innerParams = privateProps.innerParams.get(instance);
4496 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
4497 return false;
4498 }
4499 removeClass(popup, innerParams.showClass.popup);
4500 addClass(popup, innerParams.hideClass.popup);
4501 const backdrop = getContainer();
4502 removeClass(backdrop, innerParams.showClass.backdrop);
4503 addClass(backdrop, innerParams.hideClass.backdrop);
4504 handlePopupAnimation(instance, popup, innerParams);
4505 return true;
4506 };
4507
4508 /**
4509 * @param {Error | string} error
4510 * @this {SweetAlert}
4511 */
4512 function rejectPromise(error) {
4513 const rejectPromise = privateMethods.swalPromiseReject.get(this);
4514 handleAwaitingPromise(this);
4515 if (rejectPromise) {
4516 // Reject Swal promise
4517 rejectPromise(error);
4518 }
4519 }
4520
4521 /**
4522 * @param {SweetAlert} instance
4523 */
4524 const handleAwaitingPromise = instance => {
4525 if (instance.isAwaitingPromise) {
4526 // @ts-ignore
4527 delete instance.isAwaitingPromise;
4528 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
4529 if (!privateProps.innerParams.get(instance)) {
4530 instance._destroy();
4531 }
4532 }
4533 };
4534
4535 /**
4536 * @param {SweetAlertResult | undefined} resolveValue
4537 * @returns {SweetAlertResult}
4538 */
4539 const prepareResolveValue = resolveValue => {
4540 // When user calls Swal.close()
4541 if (typeof resolveValue === 'undefined') {
4542 return {
4543 isConfirmed: false,
4544 isDenied: false,
4545 isDismissed: true
4546 };
4547 }
4548 return Object.assign({
4549 isConfirmed: false,
4550 isDenied: false,
4551 isDismissed: false
4552 }, resolveValue);
4553 };
4554
4555 /**
4556 * @param {SweetAlert} instance
4557 * @param {HTMLElement} popup
4558 * @param {SweetAlertOptions} innerParams
4559 */
4560 const handlePopupAnimation = (instance, popup, innerParams) => {
4561 var _globalState$eventEmi;
4562 const container = getContainer();
4563 // If animation is supported, animate
4564 const animationIsSupported = hasCssAnimation(popup);
4565 if (typeof innerParams.willClose === 'function') {
4566 innerParams.willClose(popup);
4567 }
4568 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
4569 if (animationIsSupported && container) {
4570 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4571 } else if (container) {
4572 // Otherwise, remove immediately
4573 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
4574 }
4575 };
4576
4577 /**
4578 * @param {SweetAlert} instance
4579 * @param {HTMLElement} popup
4580 * @param {HTMLElement} container
4581 * @param {boolean} returnFocus
4582 * @param {(() => void) | undefined} didClose
4583 */
4584 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
4585 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
4586 /**
4587 * @param {AnimationEvent | TransitionEvent} e
4588 */
4589 const swalCloseAnimationFinished = function (e) {
4590 if (e.target === popup) {
4591 var _globalState$swalClos;
4592 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
4593 delete globalState.swalCloseEventFinishedCallback;
4594 popup.removeEventListener('animationend', swalCloseAnimationFinished);
4595 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
4596 }
4597 };
4598 popup.addEventListener('animationend', swalCloseAnimationFinished);
4599 popup.addEventListener('transitionend', swalCloseAnimationFinished);
4600 };
4601
4602 /**
4603 * @param {SweetAlert} instance
4604 * @param {(() => void) | undefined} didClose
4605 */
4606 const triggerDidCloseAndDispose = (instance, didClose) => {
4607 setTimeout(() => {
4608 var _globalState$eventEmi2;
4609 if (typeof didClose === 'function') {
4610 didClose.bind(instance.params)();
4611 }
4612 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
4613 // instance might have been destroyed already
4614 if (instance._destroy) {
4615 instance._destroy();
4616 }
4617 });
4618 };
4619
4620 /**
4621 * Shows loader (spinner), this is useful with AJAX requests.
4622 * By default the loader be shown instead of the "Confirm" button.
4623 *
4624 * @param {HTMLButtonElement | null} [buttonToReplace]
4625 */
4626 const showLoading = buttonToReplace => {
4627 let popup = getPopup();
4628 if (!popup) {
4629 new Swal();
4630 }
4631 popup = getPopup();
4632 if (!popup) {
4633 return;
4634 }
4635 const loader = getLoader();
4636 if (isToast()) {
4637 hide(getIcon());
4638 } else {
4639 replaceButton(popup, buttonToReplace);
4640 }
4641 show(loader);
4642 popup.setAttribute('data-loading', 'true');
4643 popup.setAttribute('aria-busy', 'true');
4644 popup.focus();
4645 };
4646
4647 /**
4648 * @param {HTMLElement} popup
4649 * @param {HTMLButtonElement | null} [buttonToReplace]
4650 */
4651 const replaceButton = (popup, buttonToReplace) => {
4652 const actions = getActions();
4653 const loader = getLoader();
4654 if (!actions || !loader) {
4655 return;
4656 }
4657 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
4658 buttonToReplace = getConfirmButton();
4659 }
4660 show(actions);
4661 if (buttonToReplace) {
4662 hide(buttonToReplace);
4663 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
4664 actions.insertBefore(loader, buttonToReplace);
4665 }
4666 addClass([popup, actions], swalClasses.loading);
4667 };
4668
4669 /**
4670 * @param {SweetAlert} instance
4671 * @param {SweetAlertOptions} params
4672 */
4673 const handleInputOptionsAndValue = (instance, params) => {
4674 if (params.input === 'select' || params.input === 'radio') {
4675 handleInputOptions(instance, params);
4676 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
4677 showLoading(getConfirmButton());
4678 handleInputValue(instance, params);
4679 }
4680 };
4681
4682 /**
4683 * @param {SweetAlert} instance
4684 * @param {SweetAlertOptions} innerParams
4685 * @returns {SweetAlertInputValue}
4686 */
4687 const getInputValue = (instance, innerParams) => {
4688 const input = instance.getInput();
4689 if (!input) {
4690 return null;
4691 }
4692 switch (innerParams.input) {
4693 case 'checkbox':
4694 return getCheckboxValue(input);
4695 case 'radio':
4696 return getRadioValue(input);
4697 case 'file':
4698 return getFileValue(input);
4699 default:
4700 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
4701 }
4702 };
4703
4704 /**
4705 * @param {HTMLInputElement} input
4706 * @returns {number}
4707 */
4708 const getCheckboxValue = input => input.checked ? 1 : 0;
4709
4710 /**
4711 * @param {HTMLInputElement} input
4712 * @returns {string | null}
4713 */
4714 const getRadioValue = input => input.checked ? input.value : null;
4715
4716 /**
4717 * @param {HTMLInputElement} input
4718 * @returns {FileList | File | null}
4719 */
4720 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
4721
4722 /**
4723 * @param {SweetAlert} instance
4724 * @param {SweetAlertOptions} params
4725 */
4726 const handleInputOptions = (instance, params) => {
4727 const popup = getPopup();
4728 if (!popup) {
4729 return;
4730 }
4731 /**
4732 * @param {*} inputOptions
4733 */
4734 const processInputOptions = inputOptions => {
4735 if (params.input === 'select') {
4736 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
4737 } else if (params.input === 'radio') {
4738 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
4739 }
4740 };
4741 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
4742 showLoading(getConfirmButton());
4743 asPromise(params.inputOptions).then(inputOptions => {
4744 instance.hideLoading();
4745 processInputOptions(inputOptions);
4746 });
4747 } else if (typeof params.inputOptions === 'object') {
4748 processInputOptions(params.inputOptions);
4749 } else {
4750 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
4751 }
4752 };
4753
4754 /**
4755 * @param {SweetAlert} instance
4756 * @param {SweetAlertOptions} params
4757 */
4758 const handleInputValue = (instance, params) => {
4759 const input = instance.getInput();
4760 if (!input) {
4761 return;
4762 }
4763 hide(input);
4764 asPromise(params.inputValue).then(inputValue => {
4765 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
4766 show(input);
4767 input.focus();
4768 instance.hideLoading();
4769 }).catch(err => {
4770 error(`Error in inputValue promise: ${err}`);
4771 input.value = '';
4772 show(input);
4773 input.focus();
4774 instance.hideLoading();
4775 });
4776 };
4777
4778 /**
4779 * @param {HTMLElement} popup
4780 * @param {InputOptionFlattened[]} inputOptions
4781 * @param {SweetAlertOptions} params
4782 */
4783 function populateSelectOptions(popup, inputOptions, params) {
4784 const select = getDirectChildByClass(popup, swalClasses.select);
4785 if (!select) {
4786 return;
4787 }
4788 /**
4789 * @param {HTMLElement} parent
4790 * @param {string} optionLabel
4791 * @param {string} optionValue
4792 */
4793 const renderOption = (parent, optionLabel, optionValue) => {
4794 const option = document.createElement('option');
4795 option.value = optionValue;
4796 setInnerHtml(option, optionLabel);
4797 option.selected = isSelected(optionValue, params.inputValue);
4798 parent.appendChild(option);
4799 };
4800 inputOptions.forEach(inputOption => {
4801 const optionValue = inputOption[0];
4802 const optionLabel = inputOption[1];
4803 // <optgroup> spec:
4804 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
4805 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
4806 // check whether this is a <optgroup>
4807 if (Array.isArray(optionLabel)) {
4808 // if it is an array, then it is an <optgroup>
4809 const optgroup = document.createElement('optgroup');
4810 optgroup.label = optionValue;
4811 optgroup.disabled = false; // not configurable for now
4812 select.appendChild(optgroup);
4813 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
4814 } else {
4815 // case of <option>
4816 renderOption(select, optionLabel, optionValue);
4817 }
4818 });
4819 select.focus();
4820 }
4821
4822 /**
4823 * @param {HTMLElement} popup
4824 * @param {InputOptionFlattened[]} inputOptions
4825 * @param {SweetAlertOptions} params
4826 */
4827 function populateRadioOptions(popup, inputOptions, params) {
4828 const radio = getDirectChildByClass(popup, swalClasses.radio);
4829 if (!radio) {
4830 return;
4831 }
4832 inputOptions.forEach(inputOption => {
4833 const radioValue = inputOption[0];
4834 const radioLabel = inputOption[1];
4835 const radioInput = document.createElement('input');
4836 const radioLabelElement = document.createElement('label');
4837 radioInput.type = 'radio';
4838 radioInput.name = swalClasses.radio;
4839 radioInput.value = radioValue;
4840 if (isSelected(radioValue, params.inputValue)) {
4841 radioInput.checked = true;
4842 }
4843 const label = document.createElement('span');
4844 setInnerHtml(label, radioLabel);
4845 label.className = swalClasses.label;
4846 radioLabelElement.appendChild(radioInput);
4847 radioLabelElement.appendChild(label);
4848 radio.appendChild(radioLabelElement);
4849 });
4850 const radios = radio.querySelectorAll('input');
4851 if (radios.length) {
4852 radios[0].focus();
4853 }
4854 }
4855
4856 /**
4857 * Converts `inputOptions` into an array of `[value, label]`s
4858 *
4859 * @param {*} inputOptions
4860 * @typedef {string[]} InputOptionFlattened
4861 * @returns {InputOptionFlattened[]}
4862 */
4863 const formatInputOptions = inputOptions => {
4864 const entries = inputOptions instanceof Map ? Array.from(inputOptions) : Object.entries(inputOptions);
4865 return entries.map(([key, value]) => [key, typeof value === 'object' ? formatInputOptions(value) : value]); // case of <optgroup>
4866 };
4867
4868 /**
4869 * @param {string} optionValue
4870 * @param {SweetAlertInputValue} inputValue
4871 * @returns {boolean}
4872 */
4873 const isSelected = (optionValue, inputValue) => Boolean(inputValue) && inputValue != null && inputValue.toString() === optionValue.toString();
4874
4875 /**
4876 * @param {SweetAlert} instance
4877 */
4878 const handleConfirmButtonClick = instance => {
4879 const innerParams = privateProps.innerParams.get(instance);
4880 instance.disableButtons();
4881 if (innerParams.input) {
4882 handleConfirmOrDenyWithInput(instance, 'confirm');
4883 } else {
4884 confirm(instance, true);
4885 }
4886 };
4887
4888 /**
4889 * @param {SweetAlert} instance
4890 */
4891 const handleDenyButtonClick = instance => {
4892 const innerParams = privateProps.innerParams.get(instance);
4893 instance.disableButtons();
4894 if (innerParams.returnInputValueOnDeny) {
4895 handleConfirmOrDenyWithInput(instance, 'deny');
4896 } else {
4897 deny(instance, false);
4898 }
4899 };
4900
4901 /**
4902 * @param {SweetAlert} instance
4903 * @param {(dismiss: DismissReason) => void} dismissWith
4904 */
4905 const handleCancelButtonClick = (instance, dismissWith) => {
4906 instance.disableButtons();
4907 dismissWith(DismissReason.cancel);
4908 };
4909
4910 /**
4911 * @param {SweetAlert} instance
4912 * @param {'confirm' | 'deny'} type
4913 */
4914 const handleConfirmOrDenyWithInput = (instance, type) => {
4915 const innerParams = privateProps.innerParams.get(instance);
4916 if (!innerParams.input) {
4917 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
4918 return;
4919 }
4920 const input = instance.getInput();
4921 const inputValue = getInputValue(instance, innerParams);
4922 if (innerParams.inputValidator) {
4923 handleInputValidator(instance, inputValue, type);
4924 } else if (input && !input.checkValidity()) {
4925 instance.enableButtons();
4926 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
4927 } else if (type === 'deny') {
4928 deny(instance, inputValue);
4929 } else {
4930 confirm(instance, inputValue);
4931 }
4932 };
4933
4934 /**
4935 * @param {SweetAlert} instance
4936 * @param {SweetAlertInputValue} inputValue
4937 * @param {'confirm' | 'deny'} type
4938 */
4939 const handleInputValidator = (instance, inputValue, type) => {
4940 const innerParams = privateProps.innerParams.get(instance);
4941 instance.disableInput();
4942 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
4943 validationPromise.then(validationMessage => {
4944 instance.enableButtons();
4945 instance.enableInput();
4946 if (validationMessage) {
4947 instance.showValidationMessage(validationMessage);
4948 } else if (type === 'deny') {
4949 deny(instance, inputValue);
4950 } else {
4951 confirm(instance, inputValue);
4952 }
4953 });
4954 };
4955
4956 /**
4957 * @param {SweetAlert} instance
4958 * @param {*} value
4959 */
4960 const deny = (instance, value) => {
4961 const innerParams = privateProps.innerParams.get(instance);
4962 if (innerParams.showLoaderOnDeny) {
4963 showLoading(getDenyButton());
4964 }
4965 if (innerParams.preDeny) {
4966 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
4967 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
4968 preDenyPromise.then(preDenyValue => {
4969 if (preDenyValue === false) {
4970 instance.hideLoading();
4971 handleAwaitingPromise(instance);
4972 } else {
4973 instance.close(/** @type SweetAlertResult */{
4974 isDenied: true,
4975 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
4976 });
4977 }
4978 }).catch(error => rejectWith(instance, error));
4979 } else {
4980 instance.close(/** @type SweetAlertResult */{
4981 isDenied: true,
4982 value
4983 });
4984 }
4985 };
4986
4987 /**
4988 * @param {SweetAlert} instance
4989 * @param {*} value
4990 */
4991 const succeedWith = (instance, value) => {
4992 instance.close(/** @type SweetAlertResult */{
4993 isConfirmed: true,
4994 value
4995 });
4996 };
4997
4998 /**
4999 *
5000 * @param {SweetAlert} instance
5001 * @param {string} error
5002 */
5003 const rejectWith = (instance, error) => {
5004 instance.rejectPromise(error);
5005 };
5006
5007 /**
5008 *
5009 * @param {SweetAlert} instance
5010 * @param {*} value
5011 */
5012 const confirm = (instance, value) => {
5013 const innerParams = privateProps.innerParams.get(instance);
5014 if (innerParams.showLoaderOnConfirm) {
5015 showLoading();
5016 }
5017 if (innerParams.preConfirm) {
5018 instance.resetValidationMessage();
5019 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
5020 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
5021 preConfirmPromise.then(preConfirmValue => {
5022 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
5023 instance.hideLoading();
5024 handleAwaitingPromise(instance);
5025 } else {
5026 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
5027 }
5028 }).catch(error => rejectWith(instance, error));
5029 } else {
5030 succeedWith(instance, value);
5031 }
5032 };
5033
5034 /**
5035 * Hides loader and shows back the button which was hidden by .showLoading()
5036 * @this {SweetAlert}
5037 */
5038 function hideLoading() {
5039 // do nothing if popup is closed
5040 const innerParams = privateProps.innerParams.get(this);
5041 if (!innerParams) {
5042 return;
5043 }
5044 const domCache = privateProps.domCache.get(this);
5045 hide(domCache.loader);
5046 if (isToast()) {
5047 if (innerParams.icon) {
5048 show(getIcon());
5049 }
5050 } else {
5051 showRelatedButton(domCache);
5052 }
5053 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
5054 domCache.popup.removeAttribute('aria-busy');
5055 domCache.popup.removeAttribute('data-loading');
5056 this.enableButtons();
5057 }
5058
5059 /**
5060 * @param {DomCache} domCache
5061 */
5062 const showRelatedButton = domCache => {
5063 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
5064 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
5065 if (buttonToReplace.length) {
5066 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
5067 } else if (allButtonsAreHidden()) {
5068 hide(domCache.actions);
5069 }
5070 };
5071
5072 /**
5073 * Gets the input DOM node, this method works with input parameter.
5074 *
5075 * @returns {HTMLInputElement | null}
5076 * @this {SweetAlert}
5077 */
5078 function getInput() {
5079 const innerParams = privateProps.innerParams.get(this);
5080 const domCache = privateProps.domCache.get(this);
5081 if (!domCache) {
5082 return null;
5083 }
5084 return getInput$1(domCache.popup, innerParams.input);
5085 }
5086
5087 /**
5088 * @param {SweetAlert} instance
5089 * @param {string[]} buttons
5090 * @param {boolean} disabled
5091 */
5092 function setButtonsDisabled(instance, buttons, disabled) {
5093 const domCache = privateProps.domCache.get(instance);
5094 buttons.forEach(button => {
5095 domCache[button].disabled = disabled;
5096 });
5097 }
5098
5099 /**
5100 * @param {HTMLInputElement | null} input
5101 * @param {boolean} disabled
5102 */
5103 function setInputDisabled(input, disabled) {
5104 const popup = getPopup();
5105 if (!popup || !input) {
5106 return;
5107 }
5108 if (input.type === 'radio') {
5109 /** @type {NodeListOf<HTMLInputElement>} */
5110 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
5111 radios.forEach(radio => {
5112 radio.disabled = disabled;
5113 });
5114 } else {
5115 input.disabled = disabled;
5116 }
5117 }
5118
5119 /**
5120 * Enable all the buttons
5121 * @this {SweetAlert}
5122 */
5123 function enableButtons() {
5124 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
5125 const focusedElement = privateProps.focusedElement.get(this);
5126 if (focusedElement instanceof HTMLElement && document.activeElement === document.body) {
5127 focusedElement.focus();
5128 }
5129 privateProps.focusedElement.delete(this);
5130 }
5131
5132 /**
5133 * Disable all the buttons
5134 * @this {SweetAlert}
5135 */
5136 function disableButtons() {
5137 privateProps.focusedElement.set(this, document.activeElement);
5138 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
5139 }
5140
5141 /**
5142 * Enable the input field
5143 * @this {SweetAlert}
5144 */
5145 function enableInput() {
5146 setInputDisabled(this.getInput(), false);
5147 }
5148
5149 /**
5150 * Disable the input field
5151 * @this {SweetAlert}
5152 */
5153 function disableInput() {
5154 setInputDisabled(this.getInput(), true);
5155 }
5156
5157 /**
5158 * Show block with validation message
5159 *
5160 * @param {string} error
5161 * @this {SweetAlert}
5162 */
5163 function showValidationMessage(error) {
5164 const domCache = privateProps.domCache.get(this);
5165 const params = privateProps.innerParams.get(this);
5166 setInnerHtml(domCache.validationMessage, error);
5167 domCache.validationMessage.className = swalClasses['validation-message'];
5168 if (params.customClass && params.customClass.validationMessage) {
5169 addClass(domCache.validationMessage, params.customClass.validationMessage);
5170 }
5171 show(domCache.validationMessage);
5172 const input = this.getInput();
5173 if (input) {
5174 input.setAttribute('aria-invalid', 'true');
5175 input.setAttribute('aria-describedby', swalClasses['validation-message']);
5176 focusInput(input);
5177 addClass(input, swalClasses.inputerror);
5178 }
5179 }
5180
5181 /**
5182 * Hide block with validation message
5183 *
5184 * @this {SweetAlert}
5185 */
5186 function resetValidationMessage() {
5187 const domCache = privateProps.domCache.get(this);
5188 if (domCache.validationMessage) {
5189 hide(domCache.validationMessage);
5190 }
5191 const input = this.getInput();
5192 if (input) {
5193 input.removeAttribute('aria-invalid');
5194 input.removeAttribute('aria-describedby');
5195 removeClass(input, swalClasses.inputerror);
5196 }
5197 }
5198
5199 const defaultParams = {
5200 title: '',
5201 titleText: '',
5202 text: '',
5203 html: '',
5204 footer: '',
5205 icon: undefined,
5206 iconColor: undefined,
5207 iconHtml: undefined,
5208 template: undefined,
5209 toast: false,
5210 draggable: false,
5211 animation: true,
5212 theme: 'light',
5213 showClass: {
5214 popup: 'swal2-show',
5215 backdrop: 'swal2-backdrop-show',
5216 icon: 'swal2-icon-show'
5217 },
5218 hideClass: {
5219 popup: 'swal2-hide',
5220 backdrop: 'swal2-backdrop-hide',
5221 icon: 'swal2-icon-hide'
5222 },
5223 customClass: {},
5224 target: 'body',
5225 color: undefined,
5226 backdrop: true,
5227 heightAuto: true,
5228 allowOutsideClick: true,
5229 allowEscapeKey: true,
5230 allowEnterKey: true,
5231 stopKeydownPropagation: true,
5232 keydownListenerCapture: false,
5233 showConfirmButton: true,
5234 showDenyButton: false,
5235 showCancelButton: false,
5236 preConfirm: undefined,
5237 preDeny: undefined,
5238 confirmButtonText: 'OK',
5239 confirmButtonAriaLabel: '',
5240 confirmButtonColor: undefined,
5241 denyButtonText: 'No',
5242 denyButtonAriaLabel: '',
5243 denyButtonColor: undefined,
5244 cancelButtonText: 'Cancel',
5245 cancelButtonAriaLabel: '',
5246 cancelButtonColor: undefined,
5247 buttonsStyling: true,
5248 reverseButtons: false,
5249 focusConfirm: true,
5250 focusDeny: false,
5251 focusCancel: false,
5252 returnFocus: true,
5253 showCloseButton: false,
5254 closeButtonHtml: '&times;',
5255 closeButtonAriaLabel: 'Close this dialog',
5256 loaderHtml: '',
5257 showLoaderOnConfirm: false,
5258 showLoaderOnDeny: false,
5259 imageUrl: undefined,
5260 imageWidth: undefined,
5261 imageHeight: undefined,
5262 imageAlt: '',
5263 timer: undefined,
5264 timerProgressBar: false,
5265 width: undefined,
5266 padding: undefined,
5267 background: undefined,
5268 input: undefined,
5269 inputPlaceholder: '',
5270 inputLabel: '',
5271 inputValue: '',
5272 inputOptions: {},
5273 inputAutoFocus: true,
5274 inputAutoTrim: true,
5275 inputAttributes: {},
5276 inputValidator: undefined,
5277 returnInputValueOnDeny: false,
5278 validationMessage: undefined,
5279 grow: false,
5280 position: 'center',
5281 progressSteps: [],
5282 currentProgressStep: undefined,
5283 progressStepsDistance: undefined,
5284 willOpen: undefined,
5285 didOpen: undefined,
5286 didRender: undefined,
5287 willClose: undefined,
5288 didClose: undefined,
5289 didDestroy: undefined,
5290 scrollbarPadding: true,
5291 topLayer: false
5292 };
5293 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'];
5294
5295 /** @type {Record<string, string | undefined>} */
5296 const deprecatedParams = {
5297 allowEnterKey: undefined
5298 };
5299 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
5300
5301 /**
5302 * Is valid parameter
5303 *
5304 * @param {string} paramName
5305 * @returns {boolean}
5306 */
5307 const isValidParameter = paramName => {
5308 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
5309 };
5310
5311 /**
5312 * Is valid parameter for Swal.update() method
5313 *
5314 * @param {string} paramName
5315 * @returns {boolean}
5316 */
5317 const isUpdatableParameter = paramName => {
5318 return updatableParams.indexOf(paramName) !== -1;
5319 };
5320
5321 /**
5322 * Is deprecated parameter
5323 *
5324 * @param {string} paramName
5325 * @returns {string | undefined}
5326 */
5327 const isDeprecatedParameter = paramName => {
5328 return deprecatedParams[paramName];
5329 };
5330
5331 /**
5332 * @param {string} param
5333 */
5334 const checkIfParamIsValid = param => {
5335 if (!isValidParameter(param)) {
5336 warn(`Unknown parameter "${param}"`);
5337 }
5338 };
5339
5340 /**
5341 * @param {string} param
5342 */
5343 const checkIfToastParamIsValid = param => {
5344 if (toastIncompatibleParams.includes(param)) {
5345 warn(`The parameter "${param}" is incompatible with toasts`);
5346 }
5347 };
5348
5349 /**
5350 * @param {string} param
5351 */
5352 const checkIfParamIsDeprecated = param => {
5353 const isDeprecated = isDeprecatedParameter(param);
5354 if (isDeprecated) {
5355 warnAboutDeprecation(param, isDeprecated);
5356 }
5357 };
5358
5359 /**
5360 * Show relevant warnings for given params
5361 *
5362 * @param {SweetAlertOptions} params
5363 */
5364 const showWarningsForParams = params => {
5365 if (params.backdrop === false && params.allowOutsideClick) {
5366 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
5367 }
5368 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)) {
5369 warn(`Invalid theme "${params.theme}"`);
5370 }
5371 for (const param in params) {
5372 checkIfParamIsValid(param);
5373 if (params.toast) {
5374 checkIfToastParamIsValid(param);
5375 }
5376 checkIfParamIsDeprecated(param);
5377 }
5378 };
5379
5380 /**
5381 * Updates popup parameters.
5382 *
5383 * @this {any}
5384 * @param {SweetAlertOptions} params
5385 */
5386 function update(params) {
5387 const container = getContainer();
5388 const popup = getPopup();
5389 const innerParams = privateProps.innerParams.get(this);
5390 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
5391 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.`);
5392 return;
5393 }
5394 const validUpdatableParams = filterValidParams(params);
5395 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
5396 showWarningsForParams(updatedParams);
5397 if (container) {
5398 container.dataset['swal2Theme'] = updatedParams.theme;
5399 }
5400 render(this, updatedParams);
5401 privateProps.innerParams.set(this, updatedParams);
5402 Object.defineProperties(this, {
5403 params: {
5404 value: Object.assign({}, this.params, params),
5405 writable: false,
5406 enumerable: true
5407 }
5408 });
5409 }
5410
5411 /**
5412 * @param {SweetAlertOptions} params
5413 * @returns {SweetAlertOptions}
5414 */
5415 const filterValidParams = params => {
5416 /** @type {Record<string, any>} */
5417 const validUpdatableParams = {};
5418 Object.keys(params).forEach(param => {
5419 if (isUpdatableParameter(param)) {
5420 const typedParams = /** @type {Record<string, any>} */params;
5421 validUpdatableParams[param] = typedParams[param];
5422 } else {
5423 warn(`Invalid parameter to update: ${param}`);
5424 }
5425 });
5426 return validUpdatableParams;
5427 };
5428
5429 /**
5430 * Dispose the current SweetAlert2 instance
5431 * @this {SweetAlert}
5432 */
5433 function _destroy() {
5434 var _globalState$eventEmi;
5435 const domCache = privateProps.domCache.get(this);
5436 const innerParams = privateProps.innerParams.get(this);
5437 if (!innerParams) {
5438 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
5439 return; // This instance has already been destroyed
5440 }
5441
5442 // Check if there is another Swal closing
5443 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
5444 globalState.swalCloseEventFinishedCallback();
5445 delete globalState.swalCloseEventFinishedCallback;
5446 }
5447 if (typeof innerParams.didDestroy === 'function') {
5448 innerParams.didDestroy();
5449 }
5450 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
5451 disposeSwal(this);
5452 }
5453
5454 /**
5455 * @param {SweetAlert} instance
5456 */
5457 const disposeSwal = instance => {
5458 disposeWeakMaps(instance);
5459 // Unset this.params so GC will dispose it (#1569)
5460 // @ts-ignore
5461 delete instance.params;
5462 // Unset globalState props so GC will dispose globalState (#1569)
5463 delete globalState.keydownHandler;
5464 delete globalState.keydownTarget;
5465 // Unset currentInstance
5466 delete globalState.currentInstance;
5467 };
5468
5469 /**
5470 * @param {SweetAlert} instance
5471 */
5472 const disposeWeakMaps = instance => {
5473 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
5474 if (instance.isAwaitingPromise) {
5475 unsetWeakMaps(privateProps, instance);
5476 instance.isAwaitingPromise = true;
5477 } else {
5478 unsetWeakMaps(privateMethods, instance);
5479 unsetWeakMaps(privateProps, instance);
5480
5481 // @ts-ignore
5482 delete instance.isAwaitingPromise;
5483 // Unset instance methods
5484 // @ts-ignore
5485 delete instance.disableButtons;
5486 // @ts-ignore
5487 delete instance.enableButtons;
5488 // @ts-ignore
5489 delete instance.getInput;
5490 // @ts-ignore
5491 delete instance.disableInput;
5492 // @ts-ignore
5493 delete instance.enableInput;
5494 // @ts-ignore
5495 delete instance.hideLoading;
5496 // @ts-ignore
5497 delete instance.disableLoading;
5498 // @ts-ignore
5499 delete instance.showValidationMessage;
5500 // @ts-ignore
5501 delete instance.resetValidationMessage;
5502 // @ts-ignore
5503 delete instance.close;
5504 // @ts-ignore
5505 delete instance.closePopup;
5506 // @ts-ignore
5507 delete instance.closeModal;
5508 // @ts-ignore
5509 delete instance.closeToast;
5510 // @ts-ignore
5511 delete instance.rejectPromise;
5512 // @ts-ignore
5513 delete instance.update;
5514 // @ts-ignore
5515 delete instance._destroy;
5516 }
5517 };
5518
5519 /**
5520 * @param {Record<string, WeakMap<any, any>>} obj
5521 * @param {SweetAlert} instance
5522 */
5523 const unsetWeakMaps = (obj, instance) => {
5524 for (const i in obj) {
5525 obj[i].delete(instance);
5526 }
5527 };
5528
5529 var instanceMethods = /*#__PURE__*/Object.freeze({
5530 __proto__: null,
5531 _destroy: _destroy,
5532 close: close,
5533 closeModal: close,
5534 closePopup: close,
5535 closeToast: close,
5536 disableButtons: disableButtons,
5537 disableInput: disableInput,
5538 disableLoading: hideLoading,
5539 enableButtons: enableButtons,
5540 enableInput: enableInput,
5541 getInput: getInput,
5542 handleAwaitingPromise: handleAwaitingPromise,
5543 hideLoading: hideLoading,
5544 rejectPromise: rejectPromise,
5545 resetValidationMessage: resetValidationMessage,
5546 showValidationMessage: showValidationMessage,
5547 update: update
5548 });
5549
5550 /**
5551 * @param {SweetAlertOptions} innerParams
5552 * @param {DomCache} domCache
5553 * @param {(dismiss: DismissReason) => void} dismissWith
5554 */
5555 const handlePopupClick = (innerParams, domCache, dismissWith) => {
5556 if (innerParams.toast) {
5557 handleToastClick(innerParams, domCache, dismissWith);
5558 } else {
5559 // Ignore click events that had mousedown on the popup but mouseup on the container
5560 // This can happen when the user drags a slider
5561 handleModalMousedown(domCache);
5562
5563 // Ignore click events that had mousedown on the container but mouseup on the popup
5564 handleContainerMousedown(domCache);
5565 handleModalClick(innerParams, domCache, dismissWith);
5566 }
5567 };
5568
5569 /**
5570 * @param {SweetAlertOptions} innerParams
5571 * @param {DomCache} domCache
5572 * @param {(dismiss: DismissReason) => void} dismissWith
5573 */
5574 const handleToastClick = (innerParams, domCache, dismissWith) => {
5575 // Closing toast by internal click
5576 domCache.popup.onclick = () => {
5577 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
5578 return;
5579 }
5580 dismissWith(DismissReason.close);
5581 };
5582 };
5583
5584 /**
5585 * @param {SweetAlertOptions} innerParams
5586 * @returns {boolean}
5587 */
5588 const isAnyButtonShown = innerParams => {
5589 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
5590 };
5591 let ignoreOutsideClick = false;
5592
5593 /**
5594 * @param {DomCache} domCache
5595 */
5596 const handleModalMousedown = domCache => {
5597 domCache.popup.onmousedown = () => {
5598 domCache.container.onmouseup = function (e) {
5599 domCache.container.onmouseup = () => {};
5600 // We only check if the mouseup target is the container because usually it doesn't
5601 // have any other direct children aside of the popup
5602 if (e.target === domCache.container) {
5603 ignoreOutsideClick = true;
5604 }
5605 };
5606 };
5607 };
5608
5609 /**
5610 * @param {DomCache} domCache
5611 */
5612 const handleContainerMousedown = domCache => {
5613 domCache.container.onmousedown = e => {
5614 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
5615 if (e.target === domCache.container) {
5616 e.preventDefault();
5617 }
5618 domCache.popup.onmouseup = function (e) {
5619 domCache.popup.onmouseup = () => {};
5620 // We also need to check if the mouseup target is a child of the popup
5621 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
5622 ignoreOutsideClick = true;
5623 }
5624 };
5625 };
5626 };
5627
5628 /**
5629 * @param {SweetAlertOptions} innerParams
5630 * @param {DomCache} domCache
5631 * @param {(dismiss: DismissReason) => void} dismissWith
5632 */
5633 const handleModalClick = (innerParams, domCache, dismissWith) => {
5634 domCache.container.onclick = e => {
5635 if (ignoreOutsideClick) {
5636 ignoreOutsideClick = false;
5637 return;
5638 }
5639 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
5640 dismissWith(DismissReason.backdrop);
5641 }
5642 };
5643 };
5644
5645 /**
5646 * @param {unknown} elem
5647 * @returns {boolean}
5648 */
5649 const isJqueryElement = elem => typeof elem === 'object' && elem !== null && 'jquery' in elem;
5650
5651 /**
5652 * @param {unknown} elem
5653 * @returns {boolean}
5654 */
5655 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
5656
5657 /**
5658 * @param {ReadonlyArray<unknown>} args
5659 * @returns {SweetAlertOptions}
5660 */
5661 const argsToParams = args => {
5662 /** @type {Record<string, unknown>} */
5663 const params = {};
5664 if (typeof args[0] === 'object' && !isElement(args[0])) {
5665 Object.assign(params, args[0]);
5666 } else {
5667 ['title', 'html', 'icon'].forEach((name, index) => {
5668 const arg = args[index];
5669 if (typeof arg === 'string' || isElement(arg)) {
5670 params[name] = arg;
5671 } else if (arg !== undefined) {
5672 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
5673 }
5674 });
5675 }
5676 return /** @type {SweetAlertOptions} */params;
5677 };
5678
5679 /**
5680 * Main method to create a new SweetAlert2 popup
5681 *
5682 * @this {new (...args: any[]) => any}
5683 * @param {...SweetAlertOptions} args
5684 * @returns {Promise<SweetAlertResult>}
5685 */
5686 function fire(...args) {
5687 return new this(...args);
5688 }
5689
5690 /**
5691 * Returns an extended version of `Swal` containing `params` as defaults.
5692 * Useful for reusing Swal configuration.
5693 *
5694 * For example:
5695 *
5696 * Before:
5697 * const textPromptOptions = { input: 'text', showCancelButton: true }
5698 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
5699 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
5700 *
5701 * After:
5702 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
5703 * const {value: firstName} = await TextPrompt('What is your first name?')
5704 * const {value: lastName} = await TextPrompt('What is your last name?')
5705 *
5706 * @param {SweetAlertOptions} mixinParams
5707 * @returns {SweetAlert}
5708 * @this {typeof import('../SweetAlert.js').SweetAlert}
5709 */
5710 function mixin(mixinParams) {
5711 // @ts-ignore: 'this' refers to the SweetAlert constructor
5712 class MixinSwal extends this {
5713 /**
5714 * @param {any} params
5715 * @param {any} priorityMixinParams
5716 */
5717 _main(params, priorityMixinParams) {
5718 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
5719 }
5720 }
5721 // @ts-ignore
5722 return MixinSwal;
5723 }
5724
5725 /**
5726 * If `timer` parameter is set, returns number of milliseconds of timer remained.
5727 * Otherwise, returns undefined.
5728 *
5729 * @returns {number | undefined}
5730 */
5731 const getTimerLeft = () => {
5732 return globalState.timeout && globalState.timeout.getTimerLeft();
5733 };
5734
5735 /**
5736 * Stop timer. Returns number of milliseconds of timer remained.
5737 * If `timer` parameter isn't set, returns undefined.
5738 *
5739 * @returns {number | undefined}
5740 */
5741 const stopTimer = () => {
5742 if (globalState.timeout) {
5743 stopTimerProgressBar();
5744 return globalState.timeout.stop();
5745 }
5746 };
5747
5748 /**
5749 * Resume timer. Returns number of milliseconds of timer remained.
5750 * If `timer` parameter isn't set, returns undefined.
5751 *
5752 * @returns {number | undefined}
5753 */
5754 const resumeTimer = () => {
5755 if (globalState.timeout) {
5756 const remaining = globalState.timeout.start();
5757 animateTimerProgressBar(remaining);
5758 return remaining;
5759 }
5760 };
5761
5762 /**
5763 * Resume timer. Returns number of milliseconds of timer remained.
5764 * If `timer` parameter isn't set, returns undefined.
5765 *
5766 * @returns {number | undefined}
5767 */
5768 const toggleTimer = () => {
5769 const timer = globalState.timeout;
5770 return timer && (timer.running ? stopTimer() : resumeTimer());
5771 };
5772
5773 /**
5774 * Increase timer. Returns number of milliseconds of an updated timer.
5775 * If `timer` parameter isn't set, returns undefined.
5776 *
5777 * @param {number} ms
5778 * @returns {number | undefined}
5779 */
5780 const increaseTimer = ms => {
5781 if (globalState.timeout) {
5782 const remaining = globalState.timeout.increase(ms);
5783 animateTimerProgressBar(remaining, true);
5784 return remaining;
5785 }
5786 };
5787
5788 /**
5789 * Check if timer is running. Returns true if timer is running
5790 * or false if timer is paused or stopped.
5791 * If `timer` parameter isn't set, returns undefined
5792 *
5793 * @returns {boolean}
5794 */
5795 const isTimerRunning = () => {
5796 return Boolean(globalState.timeout && globalState.timeout.isRunning());
5797 };
5798
5799 let bodyClickListenerAdded = false;
5800 /** @type {Record<string, any>} */
5801 const clickHandlers = {};
5802
5803 /**
5804 * @this {any}
5805 * @param {string} attr
5806 */
5807 function bindClickHandler(attr = 'data-swal-template') {
5808 clickHandlers[attr] = this;
5809 if (!bodyClickListenerAdded) {
5810 document.body.addEventListener('click', bodyClickListener);
5811 bodyClickListenerAdded = true;
5812 }
5813 }
5814
5815 /**
5816 * @param {MouseEvent} event
5817 */
5818 const bodyClickListener = event => {
5819 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
5820 for (const attr in clickHandlers) {
5821 const template = el.getAttribute && el.getAttribute(attr);
5822 if (template) {
5823 clickHandlers[attr].fire({
5824 template
5825 });
5826 return;
5827 }
5828 }
5829 }
5830 };
5831
5832 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
5833
5834 class EventEmitter {
5835 constructor() {
5836 /** @type {Events} */
5837 this.events = {};
5838 }
5839
5840 /**
5841 * @param {string} eventName
5842 * @returns {EventHandlers}
5843 */
5844 _getHandlersByEventName(eventName) {
5845 if (typeof this.events[eventName] === 'undefined') {
5846 // not Set because we need to keep the FIFO order
5847 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
5848 this.events[eventName] = [];
5849 }
5850 return this.events[eventName];
5851 }
5852
5853 /**
5854 * @param {string} eventName
5855 * @param {EventHandler} eventHandler
5856 */
5857 on(eventName, eventHandler) {
5858 const currentHandlers = this._getHandlersByEventName(eventName);
5859 if (!currentHandlers.includes(eventHandler)) {
5860 currentHandlers.push(eventHandler);
5861 }
5862 }
5863
5864 /**
5865 * @param {string} eventName
5866 * @param {EventHandler} eventHandler
5867 */
5868 once(eventName, eventHandler) {
5869 /**
5870 * @param {...any} args
5871 */
5872 const onceFn = (...args) => {
5873 this.removeListener(eventName, onceFn);
5874 // @ts-ignore
5875 eventHandler.apply(this, args);
5876 };
5877 this.on(eventName, onceFn);
5878 }
5879
5880 /**
5881 * @param {string} eventName
5882 * @param {...any} args
5883 */
5884 emit(eventName, ...args) {
5885 this._getHandlersByEventName(eventName).forEach(
5886 /**
5887 * @param {EventHandler} eventHandler
5888 */
5889 eventHandler => {
5890 try {
5891 // @ts-ignore
5892 eventHandler.apply(this, args);
5893 } catch (error) {
5894 console.error(error);
5895 }
5896 });
5897 }
5898
5899 /**
5900 * @param {string} eventName
5901 * @param {EventHandler} eventHandler
5902 */
5903 removeListener(eventName, eventHandler) {
5904 const currentHandlers = this._getHandlersByEventName(eventName);
5905 const index = currentHandlers.indexOf(eventHandler);
5906 if (index > -1) {
5907 currentHandlers.splice(index, 1);
5908 }
5909 }
5910
5911 /**
5912 * @param {string} eventName
5913 */
5914 removeAllListeners(eventName) {
5915 if (this.events[eventName] !== undefined) {
5916 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
5917 this.events[eventName].length = 0;
5918 }
5919 }
5920 reset() {
5921 this.events = {};
5922 }
5923 }
5924
5925 globalState.eventEmitter = new EventEmitter();
5926
5927 /**
5928 * @param {string} eventName
5929 * @param {EventHandler} eventHandler
5930 */
5931 const on = (eventName, eventHandler) => {
5932 if (globalState.eventEmitter) {
5933 globalState.eventEmitter.on(eventName, eventHandler);
5934 }
5935 };
5936
5937 /**
5938 * @param {string} eventName
5939 * @param {EventHandler} eventHandler
5940 */
5941 const once = (eventName, eventHandler) => {
5942 if (globalState.eventEmitter) {
5943 globalState.eventEmitter.once(eventName, eventHandler);
5944 }
5945 };
5946
5947 /**
5948 * @param {string} [eventName]
5949 * @param {EventHandler} [eventHandler]
5950 */
5951 const off = (eventName, eventHandler) => {
5952 if (!globalState.eventEmitter) {
5953 return;
5954 }
5955
5956 // Remove all handlers for all events
5957 if (!eventName) {
5958 globalState.eventEmitter.reset();
5959 return;
5960 }
5961 if (eventHandler) {
5962 // Remove a specific handler
5963 globalState.eventEmitter.removeListener(eventName, eventHandler);
5964 } else {
5965 // Remove all handlers for a specific event
5966 globalState.eventEmitter.removeAllListeners(eventName);
5967 }
5968 };
5969
5970 var staticMethods = /*#__PURE__*/Object.freeze({
5971 __proto__: null,
5972 argsToParams: argsToParams,
5973 bindClickHandler: bindClickHandler,
5974 clickCancel: clickCancel,
5975 clickConfirm: clickConfirm,
5976 clickDeny: clickDeny,
5977 enableLoading: showLoading,
5978 fire: fire,
5979 getActions: getActions,
5980 getCancelButton: getCancelButton,
5981 getCloseButton: getCloseButton,
5982 getConfirmButton: getConfirmButton,
5983 getContainer: getContainer,
5984 getDenyButton: getDenyButton,
5985 getFocusableElements: getFocusableElements,
5986 getFooter: getFooter,
5987 getHtmlContainer: getHtmlContainer,
5988 getIcon: getIcon,
5989 getIconContent: getIconContent,
5990 getImage: getImage,
5991 getInputLabel: getInputLabel,
5992 getLoader: getLoader,
5993 getPopup: getPopup,
5994 getProgressSteps: getProgressSteps,
5995 getTimerLeft: getTimerLeft,
5996 getTimerProgressBar: getTimerProgressBar,
5997 getTitle: getTitle,
5998 getValidationMessage: getValidationMessage,
5999 increaseTimer: increaseTimer,
6000 isDeprecatedParameter: isDeprecatedParameter,
6001 isLoading: isLoading,
6002 isTimerRunning: isTimerRunning,
6003 isUpdatableParameter: isUpdatableParameter,
6004 isValidParameter: isValidParameter,
6005 isVisible: isVisible,
6006 mixin: mixin,
6007 off: off,
6008 on: on,
6009 once: once,
6010 resumeTimer: resumeTimer,
6011 showLoading: showLoading,
6012 stopTimer: stopTimer,
6013 toggleTimer: toggleTimer
6014 });
6015
6016 class Timer {
6017 /**
6018 * @param {() => void} callback
6019 * @param {number} delay
6020 */
6021 constructor(callback, delay) {
6022 this.callback = callback;
6023 this.remaining = delay;
6024 this.running = false;
6025 this.start();
6026 }
6027
6028 /**
6029 * @returns {number}
6030 */
6031 start() {
6032 if (!this.running) {
6033 this.running = true;
6034 this.started = new Date();
6035 this.id = setTimeout(this.callback, this.remaining);
6036 }
6037 return this.remaining;
6038 }
6039
6040 /**
6041 * @returns {number}
6042 */
6043 stop() {
6044 if (this.started && this.running) {
6045 this.running = false;
6046 clearTimeout(this.id);
6047 this.remaining -= new Date().getTime() - this.started.getTime();
6048 }
6049 return this.remaining;
6050 }
6051
6052 /**
6053 * @param {number} n
6054 * @returns {number}
6055 */
6056 increase(n) {
6057 const running = this.running;
6058 if (running) {
6059 this.stop();
6060 }
6061 this.remaining += n;
6062 if (running) {
6063 this.start();
6064 }
6065 return this.remaining;
6066 }
6067
6068 /**
6069 * @returns {number}
6070 */
6071 getTimerLeft() {
6072 if (this.running) {
6073 this.stop();
6074 this.start();
6075 }
6076 return this.remaining;
6077 }
6078
6079 /**
6080 * @returns {boolean}
6081 */
6082 isRunning() {
6083 return this.running;
6084 }
6085 }
6086
6087 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
6088
6089 /**
6090 * @param {SweetAlertOptions} params
6091 * @returns {SweetAlertOptions}
6092 */
6093 const getTemplateParams = params => {
6094 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
6095 if (!template) {
6096 return {};
6097 }
6098 /** @type {DocumentFragment} */
6099 const templateContent = template.content;
6100 showWarningsForElements(templateContent);
6101 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
6102 return result;
6103 };
6104
6105 /**
6106 * @param {DocumentFragment} templateContent
6107 * @returns {Record<string, string | boolean | number>}
6108 */
6109 const getSwalParams = templateContent => {
6110 /** @type {Record<string, string | boolean | number>} */
6111 const result = {};
6112 /** @type {HTMLElement[]} */
6113 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
6114 swalParams.forEach(param => {
6115 showWarningsForAttributes(param, ['name', 'value']);
6116 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6117 const value = param.getAttribute('value');
6118 if (!paramName || !value) {
6119 return;
6120 }
6121 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
6122 result[paramName] = value !== 'false';
6123 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
6124 result[paramName] = JSON.parse(value);
6125 } else {
6126 result[paramName] = value;
6127 }
6128 });
6129 return result;
6130 };
6131
6132 /**
6133 * @param {DocumentFragment} templateContent
6134 * @returns {Record<string, () => void>}
6135 */
6136 const getSwalFunctionParams = templateContent => {
6137 /** @type {Record<string, () => void>} */
6138 const result = {};
6139 /** @type {HTMLElement[]} */
6140 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
6141 swalFunctions.forEach(param => {
6142 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
6143 const value = param.getAttribute('value');
6144 if (!paramName || !value) {
6145 return;
6146 }
6147 result[paramName] = new Function(`return ${value}`)();
6148 });
6149 return result;
6150 };
6151
6152 /**
6153 * @param {DocumentFragment} templateContent
6154 * @returns {Record<string, string | boolean>}
6155 */
6156 const getSwalButtons = templateContent => {
6157 /** @type {Record<string, string | boolean>} */
6158 const result = {};
6159 /** @type {HTMLElement[]} */
6160 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
6161 swalButtons.forEach(button => {
6162 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
6163 const type = button.getAttribute('type');
6164 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
6165 return;
6166 }
6167 result[`${type}ButtonText`] = button.innerHTML;
6168 result[`show${capitalizeFirstLetter(type)}Button`] = true;
6169 const color = button.getAttribute('color');
6170 if (color !== null) {
6171 result[`${type}ButtonColor`] = color;
6172 }
6173 const ariaLabel = button.getAttribute('aria-label');
6174 if (ariaLabel !== null) {
6175 result[`${type}ButtonAriaLabel`] = ariaLabel;
6176 }
6177 });
6178 return result;
6179 };
6180
6181 /**
6182 * @param {DocumentFragment} templateContent
6183 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
6184 */
6185 const getSwalImage = templateContent => {
6186 const result = {};
6187 /** @type {HTMLElement | null} */
6188 const image = templateContent.querySelector('swal-image');
6189 if (image) {
6190 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
6191 // getAttribute returns null if attribute is absent; `|| undefined` converts empty string to undefined
6192 const src = image.getAttribute('src');
6193 if (src !== null) result.imageUrl = src || undefined;
6194 const width = image.getAttribute('width');
6195 if (width !== null) result.imageWidth = width || undefined;
6196 const height = image.getAttribute('height');
6197 if (height !== null) result.imageHeight = height || undefined;
6198 const alt = image.getAttribute('alt');
6199 if (alt !== null) result.imageAlt = alt || undefined;
6200 }
6201 return result;
6202 };
6203
6204 /**
6205 * @param {DocumentFragment} templateContent
6206 * @returns {object}
6207 */
6208 const getSwalIcon = templateContent => {
6209 const result = {};
6210 /** @type {HTMLElement | null} */
6211 const icon = templateContent.querySelector('swal-icon');
6212 if (icon) {
6213 showWarningsForAttributes(icon, ['type', 'color']);
6214 if (icon.hasAttribute('type')) {
6215 result.icon = icon.getAttribute('type');
6216 }
6217 if (icon.hasAttribute('color')) {
6218 result.iconColor = icon.getAttribute('color');
6219 }
6220 result.iconHtml = icon.innerHTML;
6221 }
6222 return result;
6223 };
6224
6225 /**
6226 * @param {DocumentFragment} templateContent
6227 * @returns {object}
6228 */
6229 const getSwalInput = templateContent => {
6230 /** @type {Record<string, any>} */
6231 const result = {};
6232 /** @type {HTMLElement | null} */
6233 const input = templateContent.querySelector('swal-input');
6234 if (input) {
6235 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
6236 result.input = input.getAttribute('type') || 'text';
6237 if (input.hasAttribute('label')) {
6238 result.inputLabel = input.getAttribute('label');
6239 }
6240 if (input.hasAttribute('placeholder')) {
6241 result.inputPlaceholder = input.getAttribute('placeholder');
6242 }
6243 if (input.hasAttribute('value')) {
6244 result.inputValue = input.getAttribute('value');
6245 }
6246 }
6247 /** @type {HTMLElement[]} */
6248 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
6249 if (inputOptions.length) {
6250 result.inputOptions = {};
6251 inputOptions.forEach(option => {
6252 showWarningsForAttributes(option, ['value']);
6253 const optionValue = option.getAttribute('value');
6254 if (!optionValue) {
6255 return;
6256 }
6257 const optionName = option.innerHTML;
6258 result.inputOptions[optionValue] = optionName;
6259 });
6260 }
6261 return result;
6262 };
6263
6264 /**
6265 * @param {DocumentFragment} templateContent
6266 * @param {string[]} paramNames
6267 * @returns {Record<string, string>}
6268 */
6269 const getSwalStringParams = (templateContent, paramNames) => {
6270 /** @type {Record<string, string>} */
6271 const result = {};
6272 for (const i in paramNames) {
6273 const paramName = paramNames[i];
6274 /** @type {HTMLElement | null} */
6275 const tag = templateContent.querySelector(paramName);
6276 if (tag) {
6277 showWarningsForAttributes(tag, []);
6278 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
6279 }
6280 }
6281 return result;
6282 };
6283
6284 /**
6285 * @param {DocumentFragment} templateContent
6286 */
6287 const showWarningsForElements = templateContent => {
6288 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
6289 Array.from(templateContent.children).forEach(el => {
6290 const tagName = el.tagName.toLowerCase();
6291 if (!allowedElements.includes(tagName)) {
6292 warn(`Unrecognized element <${tagName}>`);
6293 }
6294 });
6295 };
6296
6297 /**
6298 * @param {HTMLElement} el
6299 * @param {string[]} allowedAttributes
6300 */
6301 const showWarningsForAttributes = (el, allowedAttributes) => {
6302 Array.from(el.attributes).forEach(attribute => {
6303 if (allowedAttributes.indexOf(attribute.name) === -1) {
6304 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.'}`]);
6305 }
6306 });
6307 };
6308
6309 const SHOW_CLASS_TIMEOUT = 10;
6310
6311 /**
6312 * Open popup, add necessary classes and styles, fix scrollbar
6313 *
6314 * @param {SweetAlertOptions} params
6315 */
6316 const openPopup = params => {
6317 var _globalState$eventEmi, _globalState$eventEmi2;
6318 const container = getContainer();
6319 const popup = getPopup();
6320 if (!container || !popup) {
6321 return;
6322 }
6323 if (typeof params.willOpen === 'function') {
6324 params.willOpen(popup);
6325 }
6326 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
6327 const bodyStyles = window.getComputedStyle(document.body);
6328 const initialBodyOverflow = bodyStyles.overflowY;
6329 addClasses(container, popup, params);
6330
6331 // scrolling is 'hidden' until animation is done, after that 'auto'
6332 setTimeout(() => {
6333 setScrollingVisibility(container, popup);
6334 }, SHOW_CLASS_TIMEOUT);
6335 if (isModal()) {
6336 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
6337 setAriaHidden();
6338 }
6339
6340 // https://github.com/sweetalert2/sweetalert2/issues/2923
6341 if (isIOS && params.backdrop === false && popup.scrollHeight > container.clientHeight) {
6342 // remove pointer-events: none from container, it breaks scrolling tall popups in iOS
6343 container.style.pointerEvents = 'auto';
6344 }
6345 if (!isToast() && !globalState.previousActiveElement) {
6346 globalState.previousActiveElement = document.activeElement;
6347 }
6348 if (typeof params.didOpen === 'function') {
6349 const didOpen = params.didOpen;
6350 setTimeout(() => didOpen(popup));
6351 }
6352 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
6353 };
6354
6355 /**
6356 * @param {Event} event
6357 */
6358 const swalOpenAnimationFinished = event => {
6359 const popup = getPopup();
6360 if (!popup || event.target !== popup) {
6361 return;
6362 }
6363 const container = getContainer();
6364 if (!container) {
6365 return;
6366 }
6367 popup.removeEventListener('animationend', swalOpenAnimationFinished);
6368 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
6369 container.style.overflowY = 'auto';
6370
6371 // no-transition is added in init() in case one swal is opened right after another
6372 removeClass(container, swalClasses['no-transition']);
6373 };
6374
6375 /**
6376 * @param {HTMLElement} container
6377 * @param {HTMLElement} popup
6378 */
6379 const setScrollingVisibility = (container, popup) => {
6380 if (hasCssAnimation(popup)) {
6381 container.style.overflowY = 'hidden';
6382 popup.addEventListener('animationend', swalOpenAnimationFinished);
6383 popup.addEventListener('transitionend', swalOpenAnimationFinished);
6384 } else {
6385 container.style.overflowY = 'auto';
6386 }
6387 };
6388
6389 /**
6390 * @param {HTMLElement} container
6391 * @param {boolean} scrollbarPadding
6392 * @param {string} initialBodyOverflow
6393 */
6394 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
6395 iOSfix();
6396 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
6397 replaceScrollbarWithPadding(initialBodyOverflow);
6398 }
6399
6400 // sweetalert2/issues/1247
6401 setTimeout(() => {
6402 container.scrollTop = 0;
6403 });
6404 };
6405
6406 /**
6407 * @param {HTMLElement} container
6408 * @param {HTMLElement} popup
6409 * @param {SweetAlertOptions} params
6410 */
6411 const addClasses = (container, popup, params) => {
6412 var _params$showClass;
6413 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
6414 addClass(container, params.showClass.backdrop);
6415 }
6416 if (params.animation) {
6417 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
6418 popup.style.setProperty('opacity', '0', 'important');
6419 show(popup, 'grid');
6420 setTimeout(() => {
6421 var _params$showClass2;
6422 // Animate popup right after showing it
6423 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
6424 addClass(popup, params.showClass.popup);
6425 }
6426 // and remove the opacity workaround
6427 popup.style.removeProperty('opacity');
6428 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
6429 } else {
6430 show(popup, 'grid');
6431 }
6432 addClass([document.documentElement, document.body], swalClasses.shown);
6433 if (params.heightAuto && params.backdrop && !params.toast) {
6434 addClass([document.documentElement, document.body], swalClasses['height-auto']);
6435 }
6436 };
6437
6438 var defaultInputValidators = {
6439 /**
6440 * @param {string} string
6441 * @param {string} [validationMessage]
6442 * @returns {Promise<string | void>}
6443 */
6444 email: (string, validationMessage) => {
6445 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
6446 },
6447 /**
6448 * @param {string} string
6449 * @param {string} [validationMessage]
6450 * @returns {Promise<string | void>}
6451 */
6452 url: (string, validationMessage) => {
6453 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
6454 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');
6455 }
6456 };
6457
6458 /**
6459 * @param {SweetAlertOptions} params
6460 */
6461 function setDefaultInputValidators(params) {
6462 // Use default `inputValidator` for supported input types if not provided
6463 if (params.inputValidator) {
6464 return;
6465 }
6466 if (params.input === 'email') {
6467 params.inputValidator = defaultInputValidators['email'];
6468 }
6469 if (params.input === 'url') {
6470 params.inputValidator = defaultInputValidators['url'];
6471 }
6472 }
6473
6474 /**
6475 * @param {SweetAlertOptions} params
6476 */
6477 function validateCustomTargetElement(params) {
6478 // Determine if the custom target element is valid
6479 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
6480 warn('Target parameter is not valid, defaulting to "body"');
6481 params.target = 'body';
6482 }
6483 }
6484
6485 /**
6486 * Set type, text and actions on popup
6487 *
6488 * @param {SweetAlertOptions} params
6489 */
6490 function setParameters(params) {
6491 setDefaultInputValidators(params);
6492
6493 // showLoaderOnConfirm && preConfirm
6494 if (params.showLoaderOnConfirm && !params.preConfirm) {
6495 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');
6496 }
6497 validateCustomTargetElement(params);
6498
6499 // Replace newlines with <br> in title
6500 if (typeof params.title === 'string') {
6501 params.title = params.title.split('\n').join('<br />');
6502 }
6503 init(params);
6504 }
6505
6506 /** @type {SweetAlert} */
6507 let currentInstance;
6508 var _promise = /*#__PURE__*/new WeakMap();
6509 class SweetAlert {
6510 /**
6511 * @param {...(SweetAlertOptions | string)} args
6512 * @this {SweetAlert}
6513 */
6514 constructor(...args) {
6515 /**
6516 * @type {Promise<SweetAlertResult>}
6517 */
6518 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */
6519 Promise.resolve({
6520 isConfirmed: false,
6521 isDenied: false,
6522 isDismissed: true
6523 }));
6524 // Prevent run in Node env
6525 if (typeof window === 'undefined') {
6526 return;
6527 }
6528 currentInstance = this;
6529
6530 // @ts-ignore
6531 const outerParams = Object.freeze(this.constructor.argsToParams(args));
6532
6533 /** @type {Readonly<SweetAlertOptions>} */
6534 this.params = outerParams;
6535
6536 /** @type {boolean} */
6537 this.isAwaitingPromise = false;
6538 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
6539 }
6540
6541 /**
6542 * @param {any} userParams
6543 * @param {any} mixinParams
6544 */
6545 _main(userParams, mixinParams = {}) {
6546 showWarningsForParams(Object.assign({}, mixinParams, userParams));
6547 if (globalState.currentInstance) {
6548 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
6549 const {
6550 isAwaitingPromise
6551 } = globalState.currentInstance;
6552 globalState.currentInstance._destroy();
6553 if (!isAwaitingPromise) {
6554 swalPromiseResolve({
6555 isDismissed: true
6556 });
6557 }
6558 if (isModal()) {
6559 unsetAriaHidden();
6560 }
6561 }
6562 globalState.currentInstance = currentInstance;
6563 const innerParams = prepareParams(userParams, mixinParams);
6564 setParameters(innerParams);
6565 Object.freeze(innerParams);
6566
6567 // clear the previous timer
6568 if (globalState.timeout) {
6569 globalState.timeout.stop();
6570 delete globalState.timeout;
6571 }
6572
6573 // clear the restore focus timeout
6574 clearTimeout(globalState.restoreFocusTimeout);
6575 const domCache = populateDomCache(currentInstance);
6576 render(currentInstance, innerParams);
6577 privateProps.innerParams.set(currentInstance, innerParams);
6578 return swalPromise(currentInstance, domCache, innerParams);
6579 }
6580
6581 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
6582 /**
6583 * @param {any} onFulfilled
6584 */
6585 // oxlint-disable-next-line unicorn/no-thenable
6586 then(onFulfilled) {
6587 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
6588 }
6589
6590 /**
6591 * @param {any} onFinally
6592 */
6593 finally(onFinally) {
6594 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
6595 }
6596 }
6597
6598 /**
6599 * @param {SweetAlert} instance
6600 * @param {DomCache} domCache
6601 * @param {SweetAlertOptions} innerParams
6602 * @returns {Promise<SweetAlertResult>}
6603 */
6604 const swalPromise = (instance, domCache, innerParams) => {
6605 return new Promise((resolve, reject) => {
6606 // functions to handle all closings/dismissals
6607 /**
6608 * @param {DismissReason} dismiss
6609 */
6610 const dismissWith = dismiss => {
6611 instance.close({
6612 isDismissed: true,
6613 dismiss,
6614 isConfirmed: false,
6615 isDenied: false
6616 });
6617 };
6618 privateMethods.swalPromiseResolve.set(instance, resolve);
6619 privateMethods.swalPromiseReject.set(instance, reject);
6620 domCache.confirmButton.onclick = () => {
6621 handleConfirmButtonClick(instance);
6622 };
6623 domCache.denyButton.onclick = () => {
6624 handleDenyButtonClick(instance);
6625 };
6626 domCache.cancelButton.onclick = () => {
6627 handleCancelButtonClick(instance, dismissWith);
6628 };
6629 domCache.closeButton.onclick = () => {
6630 dismissWith(DismissReason.close);
6631 };
6632 handlePopupClick(innerParams, domCache, dismissWith);
6633 addKeydownHandler(globalState, innerParams, dismissWith);
6634 handleInputOptionsAndValue(instance, innerParams);
6635 openPopup(innerParams);
6636 setupTimer(globalState, innerParams, dismissWith);
6637 initFocus(domCache, innerParams);
6638
6639 // Scroll container to top on open (#1247, #1946)
6640 setTimeout(() => {
6641 domCache.container.scrollTop = 0;
6642 });
6643 });
6644 };
6645
6646 /**
6647 * @param {SweetAlertOptions} userParams
6648 * @param {SweetAlertOptions} mixinParams
6649 * @returns {SweetAlertOptions}
6650 */
6651 const prepareParams = (userParams, mixinParams) => {
6652 const templateParams = getTemplateParams(userParams);
6653 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
6654 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
6655 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
6656 if (params.animation === false) {
6657 params.showClass = {
6658 backdrop: 'swal2-noanimation'
6659 };
6660 params.hideClass = {};
6661 }
6662 return params;
6663 };
6664
6665 /**
6666 * @param {SweetAlert} instance
6667 * @returns {DomCache}
6668 */
6669 const populateDomCache = instance => {
6670 const domCache = /** @type {DomCache} */{
6671 popup: (/** @type {HTMLElement} */getPopup()),
6672 container: (/** @type {HTMLElement} */getContainer()),
6673 actions: (/** @type {HTMLElement} */getActions()),
6674 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
6675 denyButton: (/** @type {HTMLElement} */getDenyButton()),
6676 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
6677 loader: (/** @type {HTMLElement} */getLoader()),
6678 closeButton: (/** @type {HTMLElement} */getCloseButton()),
6679 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
6680 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
6681 };
6682 privateProps.domCache.set(instance, domCache);
6683 return domCache;
6684 };
6685
6686 /**
6687 * @param {GlobalState} globalState
6688 * @param {SweetAlertOptions} innerParams
6689 * @param {(dismiss: DismissReason) => void} dismissWith
6690 */
6691 const setupTimer = (globalState, innerParams, dismissWith) => {
6692 const timerProgressBar = getTimerProgressBar();
6693 hide(timerProgressBar);
6694 if (innerParams.timer) {
6695 globalState.timeout = new Timer(() => {
6696 dismissWith('timer');
6697 delete globalState.timeout;
6698 }, innerParams.timer);
6699 if (innerParams.timerProgressBar && timerProgressBar) {
6700 show(timerProgressBar);
6701 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
6702 setTimeout(() => {
6703 if (globalState.timeout && globalState.timeout.running) {
6704 // timer can be already stopped or unset at this point
6705 animateTimerProgressBar(/** @type {number} */innerParams.timer);
6706 }
6707 });
6708 }
6709 }
6710 };
6711
6712 /**
6713 * Initialize focus in the popup:
6714 *
6715 * 1. If `toast` is `true`, don't steal focus from the document.
6716 * 2. Else if there is an [autofocus] element, focus it.
6717 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
6718 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
6719 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
6720 * 6. Else focus the first focusable element in a popup (if any).
6721 *
6722 * @param {DomCache} domCache
6723 * @param {SweetAlertOptions} innerParams
6724 */
6725 const initFocus = (domCache, innerParams) => {
6726 if (innerParams.toast) {
6727 return;
6728 }
6729 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
6730 if (!callIfFunction(innerParams.allowEnterKey)) {
6731 warnAboutDeprecation('allowEnterKey', 'preConfirm: () => false');
6732 domCache.popup.focus();
6733 return;
6734 }
6735 if (focusAutofocus(domCache)) {
6736 return;
6737 }
6738 if (focusButton(domCache, innerParams)) {
6739 return;
6740 }
6741 setFocus(-1, 1);
6742 };
6743
6744 /**
6745 * @param {DomCache} domCache
6746 * @returns {boolean}
6747 */
6748 const focusAutofocus = domCache => {
6749 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
6750 for (const autofocusElement of autofocusElements) {
6751 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
6752 autofocusElement.focus();
6753 return true;
6754 }
6755 }
6756 return false;
6757 };
6758
6759 /**
6760 * @param {DomCache} domCache
6761 * @param {SweetAlertOptions} innerParams
6762 * @returns {boolean}
6763 */
6764 const focusButton = (domCache, innerParams) => {
6765 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
6766 domCache.denyButton.focus();
6767 return true;
6768 }
6769 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
6770 domCache.cancelButton.focus();
6771 return true;
6772 }
6773 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
6774 domCache.confirmButton.focus();
6775 return true;
6776 }
6777 return false;
6778 };
6779
6780 // Assign instance methods from src/instanceMethods/*.js to prototype
6781 SweetAlert.prototype.disableButtons = disableButtons;
6782 SweetAlert.prototype.enableButtons = enableButtons;
6783 SweetAlert.prototype.getInput = getInput;
6784 SweetAlert.prototype.disableInput = disableInput;
6785 SweetAlert.prototype.enableInput = enableInput;
6786 SweetAlert.prototype.hideLoading = hideLoading;
6787 SweetAlert.prototype.disableLoading = hideLoading;
6788 SweetAlert.prototype.showValidationMessage = showValidationMessage;
6789 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
6790 SweetAlert.prototype.close = close;
6791 SweetAlert.prototype.closePopup = close;
6792 SweetAlert.prototype.closeModal = close;
6793 SweetAlert.prototype.closeToast = close;
6794 SweetAlert.prototype.rejectPromise = rejectPromise;
6795 SweetAlert.prototype.update = update;
6796 SweetAlert.prototype._destroy = _destroy;
6797
6798 // Assign static methods from src/staticMethods/*.js to constructor
6799 Object.assign(SweetAlert, staticMethods);
6800
6801 // Proxy to instance methods to constructor, for now, for backwards compatibility
6802 Object.keys(instanceMethods).forEach(key => {
6803 /**
6804 * @param {...(SweetAlertOptions | string | undefined)} args
6805 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
6806 */
6807 // @ts-ignore: Dynamic property assignment for backwards compatibility
6808 SweetAlert[key] = function (...args) {
6809 // @ts-ignore
6810 if (currentInstance && currentInstance[key]) {
6811 // @ts-ignore
6812 return currentInstance[key](...args);
6813 }
6814 return undefined;
6815 };
6816 });
6817 SweetAlert.DismissReason = DismissReason;
6818 SweetAlert.version = '11.26.25';
6819
6820 const Swal = SweetAlert;
6821 // @ts-ignore
6822 Swal.default = Swal;
6823
6824 return Swal;
6825
6826 }));
6827 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
6828 "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:auto}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:auto}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}");
6829
6830 /***/ },
6831
6832 /***/ "./node_modules/toastify-js/src/toastify.js"
6833 /*!**************************************************!*\
6834 !*** ./node_modules/toastify-js/src/toastify.js ***!
6835 \**************************************************/
6836 (module) {
6837
6838 /*!
6839 * Toastify js 1.12.0
6840 * https://github.com/apvarun/toastify-js
6841 * @license MIT licensed
6842 *
6843 * Copyright (C) 2018 Varun A P
6844 */
6845 (function(root, factory) {
6846 if ( true && module.exports) {
6847 module.exports = factory();
6848 } else {
6849 root.Toastify = factory();
6850 }
6851 })(this, function(global) {
6852 // Object initialization
6853 var Toastify = function(options) {
6854 // Returning a new init object
6855 return new Toastify.lib.init(options);
6856 },
6857 // Library version
6858 version = "1.12.0";
6859
6860 // Set the default global options
6861 Toastify.defaults = {
6862 oldestFirst: true,
6863 text: "Toastify is awesome!",
6864 node: undefined,
6865 duration: 3000,
6866 selector: undefined,
6867 callback: function () {
6868 },
6869 destination: undefined,
6870 newWindow: false,
6871 close: false,
6872 gravity: "toastify-top",
6873 positionLeft: false,
6874 position: '',
6875 backgroundColor: '',
6876 avatar: "",
6877 className: "",
6878 stopOnFocus: true,
6879 onClick: function () {
6880 },
6881 offset: {x: 0, y: 0},
6882 escapeMarkup: true,
6883 ariaLive: 'polite',
6884 style: {background: ''}
6885 };
6886
6887 // Defining the prototype of the object
6888 Toastify.lib = Toastify.prototype = {
6889 toastify: version,
6890
6891 constructor: Toastify,
6892
6893 // Initializing the object with required parameters
6894 init: function(options) {
6895 // Verifying and validating the input object
6896 if (!options) {
6897 options = {};
6898 }
6899
6900 // Creating the options object
6901 this.options = {};
6902
6903 this.toastElement = null;
6904
6905 // Validating the options
6906 this.options.text = options.text || Toastify.defaults.text; // Display message
6907 this.options.node = options.node || Toastify.defaults.node; // Display content as node
6908 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
6909 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
6910 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
6911 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
6912 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
6913 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
6914 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
6915 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
6916 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
6917 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
6918 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
6919 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
6920 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
6921 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
6922 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
6923 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
6924 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
6925 this.options.style = options.style || Toastify.defaults.style;
6926 if(options.backgroundColor) {
6927 this.options.style.background = options.backgroundColor;
6928 }
6929
6930 // Returning the current object for chaining functions
6931 return this;
6932 },
6933
6934 // Building the DOM element
6935 buildToast: function() {
6936 // Validating if the options are defined
6937 if (!this.options) {
6938 throw "Toastify is not initialized";
6939 }
6940
6941 // Creating the DOM object
6942 var divElement = document.createElement("div");
6943 divElement.className = "toastify on " + this.options.className;
6944
6945 // Positioning toast to left or right or center
6946 if (!!this.options.position) {
6947 divElement.className += " toastify-" + this.options.position;
6948 } else {
6949 // To be depreciated in further versions
6950 if (this.options.positionLeft === true) {
6951 divElement.className += " toastify-left";
6952 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
6953 } else {
6954 // Default position
6955 divElement.className += " toastify-right";
6956 }
6957 }
6958
6959 // Assigning gravity of element
6960 divElement.className += " " + this.options.gravity;
6961
6962 if (this.options.backgroundColor) {
6963 // This is being deprecated in favor of using the style HTML DOM property
6964 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
6965 }
6966
6967 // Loop through our style object and apply styles to divElement
6968 for (var property in this.options.style) {
6969 divElement.style[property] = this.options.style[property];
6970 }
6971
6972 // Announce the toast to screen readers
6973 if (this.options.ariaLive) {
6974 divElement.setAttribute('aria-live', this.options.ariaLive)
6975 }
6976
6977 // Adding the toast message/node
6978 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
6979 // If we have a valid node, we insert it
6980 divElement.appendChild(this.options.node)
6981 } else {
6982 if (this.options.escapeMarkup) {
6983 divElement.innerText = this.options.text;
6984 } else {
6985 divElement.innerHTML = this.options.text;
6986 }
6987
6988 if (this.options.avatar !== "") {
6989 var avatarElement = document.createElement("img");
6990 avatarElement.src = this.options.avatar;
6991
6992 avatarElement.className = "toastify-avatar";
6993
6994 if (this.options.position == "left" || this.options.positionLeft === true) {
6995 // Adding close icon on the left of content
6996 divElement.appendChild(avatarElement);
6997 } else {
6998 // Adding close icon on the right of content
6999 divElement.insertAdjacentElement("afterbegin", avatarElement);
7000 }
7001 }
7002 }
7003
7004 // Adding a close icon to the toast
7005 if (this.options.close === true) {
7006 // Create a span for close element
7007 var closeElement = document.createElement("button");
7008 closeElement.type = "button";
7009 closeElement.setAttribute("aria-label", "Close");
7010 closeElement.className = "toast-close";
7011 closeElement.innerHTML = "&#10006;";
7012
7013 // Triggering the removal of toast from DOM on close click
7014 closeElement.addEventListener(
7015 "click",
7016 function(event) {
7017 event.stopPropagation();
7018 this.removeElement(this.toastElement);
7019 window.clearTimeout(this.toastElement.timeOutValue);
7020 }.bind(this)
7021 );
7022
7023 //Calculating screen width
7024 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7025
7026 // Adding the close icon to the toast element
7027 // Display on the right if screen width is less than or equal to 360px
7028 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
7029 // Adding close icon on the left of content
7030 divElement.insertAdjacentElement("afterbegin", closeElement);
7031 } else {
7032 // Adding close icon on the right of content
7033 divElement.appendChild(closeElement);
7034 }
7035 }
7036
7037 // Clear timeout while toast is focused
7038 if (this.options.stopOnFocus && this.options.duration > 0) {
7039 var self = this;
7040 // stop countdown
7041 divElement.addEventListener(
7042 "mouseover",
7043 function(event) {
7044 window.clearTimeout(divElement.timeOutValue);
7045 }
7046 )
7047 // add back the timeout
7048 divElement.addEventListener(
7049 "mouseleave",
7050 function() {
7051 divElement.timeOutValue = window.setTimeout(
7052 function() {
7053 // Remove the toast from DOM
7054 self.removeElement(divElement);
7055 },
7056 self.options.duration
7057 )
7058 }
7059 )
7060 }
7061
7062 // Adding an on-click destination path
7063 if (typeof this.options.destination !== "undefined") {
7064 divElement.addEventListener(
7065 "click",
7066 function(event) {
7067 event.stopPropagation();
7068 if (this.options.newWindow === true) {
7069 window.open(this.options.destination, "_blank");
7070 } else {
7071 window.location = this.options.destination;
7072 }
7073 }.bind(this)
7074 );
7075 }
7076
7077 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
7078 divElement.addEventListener(
7079 "click",
7080 function(event) {
7081 event.stopPropagation();
7082 this.options.onClick();
7083 }.bind(this)
7084 );
7085 }
7086
7087 // Adding offset
7088 if(typeof this.options.offset === "object") {
7089
7090 var x = getAxisOffsetAValue("x", this.options);
7091 var y = getAxisOffsetAValue("y", this.options);
7092
7093 var xOffset = this.options.position == "left" ? x : "-" + x;
7094 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
7095
7096 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
7097
7098 }
7099
7100 // Returning the generated element
7101 return divElement;
7102 },
7103
7104 // Displaying the toast
7105 showToast: function() {
7106 // Creating the DOM object for the toast
7107 this.toastElement = this.buildToast();
7108
7109 // Getting the root element to with the toast needs to be added
7110 var rootElement;
7111 if (typeof this.options.selector === "string") {
7112 rootElement = document.getElementById(this.options.selector);
7113 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
7114 rootElement = this.options.selector;
7115 } else {
7116 rootElement = document.body;
7117 }
7118
7119 // Validating if root element is present in DOM
7120 if (!rootElement) {
7121 throw "Root element is not defined";
7122 }
7123
7124 // Adding the DOM element
7125 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
7126 rootElement.insertBefore(this.toastElement, elementToInsert);
7127
7128 // Repositioning the toasts in case multiple toasts are present
7129 Toastify.reposition();
7130
7131 if (this.options.duration > 0) {
7132 this.toastElement.timeOutValue = window.setTimeout(
7133 function() {
7134 // Remove the toast from DOM
7135 this.removeElement(this.toastElement);
7136 }.bind(this),
7137 this.options.duration
7138 ); // Binding `this` for function invocation
7139 }
7140
7141 // Supporting function chaining
7142 return this;
7143 },
7144
7145 hideToast: function() {
7146 if (this.toastElement.timeOutValue) {
7147 clearTimeout(this.toastElement.timeOutValue);
7148 }
7149 this.removeElement(this.toastElement);
7150 },
7151
7152 // Removing the element from the DOM
7153 removeElement: function(toastElement) {
7154 // Hiding the element
7155 // toastElement.classList.remove("on");
7156 toastElement.className = toastElement.className.replace(" on", "");
7157
7158 // Removing the element from DOM after transition end
7159 window.setTimeout(
7160 function() {
7161 // remove options node if any
7162 if (this.options.node && this.options.node.parentNode) {
7163 this.options.node.parentNode.removeChild(this.options.node);
7164 }
7165
7166 // Remove the element from the DOM, only when the parent node was not removed before.
7167 if (toastElement.parentNode) {
7168 toastElement.parentNode.removeChild(toastElement);
7169 }
7170
7171 // Calling the callback function
7172 this.options.callback.call(toastElement);
7173
7174 // Repositioning the toasts again
7175 Toastify.reposition();
7176 }.bind(this),
7177 400
7178 ); // Binding `this` for function invocation
7179 },
7180 };
7181
7182 // Positioning the toasts on the DOM
7183 Toastify.reposition = function() {
7184
7185 // Top margins with gravity
7186 var topLeftOffsetSize = {
7187 top: 15,
7188 bottom: 15,
7189 };
7190 var topRightOffsetSize = {
7191 top: 15,
7192 bottom: 15,
7193 };
7194 var offsetSize = {
7195 top: 15,
7196 bottom: 15,
7197 };
7198
7199 // Get all toast messages on the DOM
7200 var allToasts = document.getElementsByClassName("toastify");
7201
7202 var classUsed;
7203
7204 // Modifying the position of each toast element
7205 for (var i = 0; i < allToasts.length; i++) {
7206 // Getting the applied gravity
7207 if (containsClass(allToasts[i], "toastify-top") === true) {
7208 classUsed = "toastify-top";
7209 } else {
7210 classUsed = "toastify-bottom";
7211 }
7212
7213 var height = allToasts[i].offsetHeight;
7214 classUsed = classUsed.substr(9, classUsed.length-1)
7215 // Spacing between toasts
7216 var offset = 15;
7217
7218 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
7219
7220 // Show toast in center if screen with less than or equal to 360px
7221 if (width <= 360) {
7222 // Setting the position
7223 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
7224
7225 offsetSize[classUsed] += height + offset;
7226 } else {
7227 if (containsClass(allToasts[i], "toastify-left") === true) {
7228 // Setting the position
7229 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
7230
7231 topLeftOffsetSize[classUsed] += height + offset;
7232 } else {
7233 // Setting the position
7234 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
7235
7236 topRightOffsetSize[classUsed] += height + offset;
7237 }
7238 }
7239 }
7240
7241 // Supporting function chaining
7242 return this;
7243 };
7244
7245 // Helper function to get offset.
7246 function getAxisOffsetAValue(axis, options) {
7247
7248 if(options.offset[axis]) {
7249 if(isNaN(options.offset[axis])) {
7250 return options.offset[axis];
7251 }
7252 else {
7253 return options.offset[axis] + 'px';
7254 }
7255 }
7256
7257 return '0px';
7258
7259 }
7260
7261 function containsClass(elem, yourClass) {
7262 if (!elem || typeof yourClass !== "string") {
7263 return false;
7264 } else if (
7265 elem.className &&
7266 elem.className
7267 .trim()
7268 .split(/\s+/gi)
7269 .indexOf(yourClass) > -1
7270 ) {
7271 return true;
7272 } else {
7273 return false;
7274 }
7275 }
7276
7277 // Setting up the prototype for the init object
7278 Toastify.lib.init.prototype = Toastify.lib;
7279
7280 // Returning the Toastify function to be assigned to the window object/module
7281 return Toastify;
7282 });
7283
7284
7285 /***/ },
7286
7287 /***/ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js"
7288 /*!**********************************************************!*\
7289 !*** ./node_modules/@orchidjs/sifter/dist/esm/sifter.js ***!
7290 \**********************************************************/
7291 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7292
7293 "use strict";
7294 __webpack_require__.r(__webpack_exports__);
7295 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7296 /* harmony export */ Sifter: () => (/* binding */ Sifter),
7297 /* harmony export */ cmp: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp),
7298 /* harmony export */ getAttr: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr),
7299 /* harmony export */ getAttrNesting: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting),
7300 /* harmony export */ getPattern: () => (/* reexport safe */ _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern),
7301 /* harmony export */ iterate: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate),
7302 /* harmony export */ propToArray: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray),
7303 /* harmony export */ scoreValue: () => (/* reexport safe */ _utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)
7304 /* harmony export */ });
7305 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/@orchidjs/sifter/dist/esm/utils.js");
7306 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7307 /* harmony import */ var _types_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./types.js */ "./node_modules/@orchidjs/sifter/dist/esm/types.js");
7308 /**
7309 * sifter.js
7310 * Copyright (c) 2013–2020 Brian Reavis & contributors
7311 *
7312 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
7313 * file except in compliance with the License. You may obtain a copy of the License at:
7314 * http://www.apache.org/licenses/LICENSE-2.0
7315 *
7316 * Unless required by applicable law or agreed to in writing, software distributed under
7317 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
7318 * ANY KIND, either express or implied. See the License for the specific language
7319 * governing permissions and limitations under the License.
7320 *
7321 * @author Brian Reavis <[email protected]>
7322 */
7323
7324
7325 class Sifter {
7326 items; // []|{};
7327 settings;
7328 /**
7329 * Textually searches arrays and hashes of objects
7330 * by property (or multiple properties). Designed
7331 * specifically for autocomplete.
7332 *
7333 */
7334 constructor(items, settings) {
7335 this.items = items;
7336 this.settings = settings || { diacritics: true };
7337 }
7338 ;
7339 /**
7340 * Splits a search string into an array of individual
7341 * regexps to be used to match results.
7342 *
7343 */
7344 tokenize(query, respect_word_boundaries, weights) {
7345 if (!query || !query.length)
7346 return [];
7347 const tokens = [];
7348 const words = query.split(/\s+/);
7349 var field_regex;
7350 if (weights) {
7351 field_regex = new RegExp('^(' + Object.keys(weights).map(_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex).join('|') + ')\:(.*)$');
7352 }
7353 words.forEach((word) => {
7354 let field_match;
7355 let field = null;
7356 let regex = null;
7357 // look for "field:query" tokens
7358 if (field_regex && (field_match = word.match(field_regex))) {
7359 field = field_match[1];
7360 word = field_match[2];
7361 }
7362 if (word.length > 0) {
7363 if (this.settings.diacritics) {
7364 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.getPattern)(word) || null;
7365 }
7366 else {
7367 regex = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_1__.escape_regex)(word);
7368 }
7369 if (regex && respect_word_boundaries)
7370 regex = "\\b" + regex;
7371 }
7372 tokens.push({
7373 string: word,
7374 regex: regex ? new RegExp(regex, 'iu') : null,
7375 field: field,
7376 });
7377 });
7378 return tokens;
7379 }
7380 ;
7381 /**
7382 * Returns a function to be used to score individual results.
7383 *
7384 * Good matches will have a higher score than poor matches.
7385 * If an item is not a match, 0 will be returned by the function.
7386 *
7387 * @returns {T.ScoreFn}
7388 */
7389 getScoreFunction(query, options) {
7390 var search = this.prepareSearch(query, options);
7391 return this._getScoreFunction(search);
7392 }
7393 /**
7394 * @returns {T.ScoreFn}
7395 *
7396 */
7397 _getScoreFunction(search) {
7398 const tokens = search.tokens, token_count = tokens.length;
7399 if (!token_count) {
7400 return function () { return 0; };
7401 }
7402 const fields = search.options.fields, weights = search.weights, field_count = fields.length, getAttrFn = search.getAttrFn;
7403 if (!field_count) {
7404 return function () { return 1; };
7405 }
7406 /**
7407 * Calculates the score of an object
7408 * against the search query.
7409 *
7410 */
7411 const scoreObject = (function () {
7412 if (field_count === 1) {
7413 return function (token, data) {
7414 const field = fields[0].field;
7415 return (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weights[field] || 1);
7416 };
7417 }
7418 return function (token, data) {
7419 var sum = 0;
7420 // is the token specific to a field?
7421 if (token.field) {
7422 const value = getAttrFn(data, token.field);
7423 if (!token.regex && value) {
7424 sum += (1 / field_count);
7425 }
7426 else {
7427 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(value, token, 1);
7428 }
7429 }
7430 else {
7431 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(weights, (weight, field) => {
7432 sum += (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.scoreValue)(getAttrFn(data, field), token, weight);
7433 });
7434 }
7435 return sum / field_count;
7436 };
7437 })();
7438 if (token_count === 1) {
7439 return function (data) {
7440 return scoreObject(tokens[0], data);
7441 };
7442 }
7443 if (search.options.conjunction === 'and') {
7444 return function (data) {
7445 var score, sum = 0;
7446 for (let token of tokens) {
7447 score = scoreObject(token, data);
7448 if (score <= 0)
7449 return 0;
7450 sum += score;
7451 }
7452 return sum / token_count;
7453 };
7454 }
7455 else {
7456 return function (data) {
7457 var sum = 0;
7458 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(tokens, (token) => {
7459 sum += scoreObject(token, data);
7460 });
7461 return sum / token_count;
7462 };
7463 }
7464 }
7465 ;
7466 /**
7467 * Returns a function that can be used to compare two
7468 * results, for sorting purposes. If no sorting should
7469 * be performed, `null` will be returned.
7470 *
7471 * @return function(a,b)
7472 */
7473 getSortFunction(query, options) {
7474 var search = this.prepareSearch(query, options);
7475 return this._getSortFunction(search);
7476 }
7477 _getSortFunction(search) {
7478 var implicit_score, sort_flds = [];
7479 const self = this, options = search.options, sort = (!search.query && options.sort_empty) ? options.sort_empty : options.sort;
7480 if (typeof sort == 'function') {
7481 return sort.bind(this);
7482 }
7483 /**
7484 * Fetches the specified sort field value
7485 * from a search result item.
7486 *
7487 */
7488 const get_field = function (name, result) {
7489 if (name === '$score')
7490 return result.score;
7491 return search.getAttrFn(self.items[result.id], name);
7492 };
7493 // parse options
7494 if (sort) {
7495 for (let s of sort) {
7496 if (search.query || s.field !== '$score') {
7497 sort_flds.push(s);
7498 }
7499 }
7500 }
7501 // the "$score" field is implied to be the primary
7502 // sort field, unless it's manually specified
7503 if (search.query) {
7504 implicit_score = true;
7505 for (let fld of sort_flds) {
7506 if (fld.field === '$score') {
7507 implicit_score = false;
7508 break;
7509 }
7510 }
7511 if (implicit_score) {
7512 sort_flds.unshift({ field: '$score', direction: 'desc' });
7513 }
7514 // without a search.query, all items will have the same score
7515 }
7516 else {
7517 sort_flds = sort_flds.filter((fld) => fld.field !== '$score');
7518 }
7519 // build function
7520 const sort_flds_count = sort_flds.length;
7521 if (!sort_flds_count) {
7522 return null;
7523 }
7524 return function (a, b) {
7525 var result, field;
7526 for (let sort_fld of sort_flds) {
7527 field = sort_fld.field;
7528 let multiplier = sort_fld.direction === 'desc' ? -1 : 1;
7529 result = multiplier * (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.cmp)(get_field(field, a), get_field(field, b));
7530 if (result)
7531 return result;
7532 }
7533 return 0;
7534 };
7535 }
7536 ;
7537 /**
7538 * Parses a search query and returns an object
7539 * with tokens and fields ready to be populated
7540 * with results.
7541 *
7542 */
7543 prepareSearch(query, optsUser) {
7544 const weights = {};
7545 var options = Object.assign({}, optsUser);
7546 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort');
7547 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'sort_empty');
7548 // convert fields to new format
7549 if (options.fields) {
7550 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.propToArray)(options, 'fields');
7551 const fields = [];
7552 options.fields.forEach((field) => {
7553 if (typeof field == 'string') {
7554 field = { field: field, weight: 1 };
7555 }
7556 fields.push(field);
7557 weights[field.field] = ('weight' in field) ? field.weight : 1;
7558 });
7559 options.fields = fields;
7560 }
7561 return {
7562 options: options,
7563 query: query.toLowerCase().trim(),
7564 tokens: this.tokenize(query, options.respect_word_boundaries, weights),
7565 total: 0,
7566 items: [],
7567 weights: weights,
7568 getAttrFn: (options.nesting) ? _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttrNesting : _utils_js__WEBPACK_IMPORTED_MODULE_0__.getAttr,
7569 };
7570 }
7571 ;
7572 /**
7573 * Searches through all items and returns a sorted array of matches.
7574 *
7575 */
7576 search(query, options) {
7577 var self = this, score, search;
7578 search = this.prepareSearch(query, options);
7579 options = search.options;
7580 query = search.query;
7581 // generate result scoring function
7582 const fn_score = options.score || self._getScoreFunction(search);
7583 // perform search and sort
7584 if (query.length) {
7585 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (item, id) => {
7586 score = fn_score(item);
7587 if (options.filter === false || score > 0) {
7588 search.items.push({ 'score': score, 'id': id });
7589 }
7590 });
7591 }
7592 else {
7593 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(self.items, (_, id) => {
7594 search.items.push({ 'score': 1, 'id': id });
7595 });
7596 }
7597 const fn_sort = self._getSortFunction(search);
7598 if (fn_sort)
7599 search.items.sort(fn_sort);
7600 // apply limits
7601 search.total = search.items.length;
7602 if (typeof options.limit === 'number') {
7603 search.items = search.items.slice(0, options.limit);
7604 }
7605 return search;
7606 }
7607 ;
7608 }
7609
7610
7611 //# sourceMappingURL=sifter.js.map
7612
7613 /***/ },
7614
7615 /***/ "./node_modules/@orchidjs/sifter/dist/esm/types.js"
7616 /*!*********************************************************!*\
7617 !*** ./node_modules/@orchidjs/sifter/dist/esm/types.js ***!
7618 \*********************************************************/
7619 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7620
7621 "use strict";
7622 __webpack_require__.r(__webpack_exports__);
7623
7624 //# sourceMappingURL=types.js.map
7625
7626 /***/ },
7627
7628 /***/ "./node_modules/@orchidjs/sifter/dist/esm/utils.js"
7629 /*!*********************************************************!*\
7630 !*** ./node_modules/@orchidjs/sifter/dist/esm/utils.js ***!
7631 \*********************************************************/
7632 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7633
7634 "use strict";
7635 __webpack_require__.r(__webpack_exports__);
7636 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7637 /* harmony export */ cmp: () => (/* binding */ cmp),
7638 /* harmony export */ getAttr: () => (/* binding */ getAttr),
7639 /* harmony export */ getAttrNesting: () => (/* binding */ getAttrNesting),
7640 /* harmony export */ iterate: () => (/* binding */ iterate),
7641 /* harmony export */ propToArray: () => (/* binding */ propToArray),
7642 /* harmony export */ scoreValue: () => (/* binding */ scoreValue)
7643 /* harmony export */ });
7644 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
7645
7646 /**
7647 * A property getter resolving dot-notation
7648 * @param {Object} obj The root object to fetch property on
7649 * @param {String} name The optionally dotted property name to fetch
7650 * @return {Object} The resolved property value
7651 */
7652 const getAttr = (obj, name) => {
7653 if (!obj)
7654 return;
7655 return obj[name];
7656 };
7657 /**
7658 * A property getter resolving dot-notation
7659 * @param {Object} obj The root object to fetch property on
7660 * @param {String} name The optionally dotted property name to fetch
7661 * @return {Object} The resolved property value
7662 */
7663 const getAttrNesting = (obj, name) => {
7664 if (!obj)
7665 return;
7666 var part, names = name.split(".");
7667 while ((part = names.shift()) && (obj = obj[part]))
7668 ;
7669 return obj;
7670 };
7671 /**
7672 * Calculates how close of a match the
7673 * given value is against a search token.
7674 *
7675 */
7676 const scoreValue = (value, token, weight) => {
7677 var score, pos;
7678 if (!value)
7679 return 0;
7680 value = value + '';
7681 if (token.regex == null)
7682 return 0;
7683 pos = value.search(token.regex);
7684 if (pos === -1)
7685 return 0;
7686 score = token.string.length / value.length;
7687 if (pos === 0)
7688 score += 0.5;
7689 return score * weight;
7690 };
7691 /**
7692 * Cast object property to an array if it exists and has a value
7693 *
7694 */
7695 const propToArray = (obj, key) => {
7696 var value = obj[key];
7697 if (typeof value == 'function')
7698 return value;
7699 if (value && !Array.isArray(value)) {
7700 obj[key] = [value];
7701 }
7702 };
7703 /**
7704 * Iterates over arrays and hashes.
7705 *
7706 * ```
7707 * iterate(this.items, function(item, id) {
7708 * // invoked for each item
7709 * });
7710 * ```
7711 *
7712 */
7713 const iterate = (object, callback) => {
7714 if (Array.isArray(object)) {
7715 object.forEach(callback);
7716 }
7717 else {
7718 for (var key in object) {
7719 if (object.hasOwnProperty(key)) {
7720 callback(object[key], key);
7721 }
7722 }
7723 }
7724 };
7725 const cmp = (a, b) => {
7726 if (typeof a === 'number' && typeof b === 'number') {
7727 return a > b ? 1 : (a < b ? -1 : 0);
7728 }
7729 a = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(a + '').toLowerCase();
7730 b = (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_0__.asciifold)(b + '').toLowerCase();
7731 if (a > b)
7732 return 1;
7733 if (b > a)
7734 return -1;
7735 return 0;
7736 };
7737 //# sourceMappingURL=utils.js.map
7738
7739 /***/ },
7740
7741 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js"
7742 /*!*******************************************************************!*\
7743 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/index.js ***!
7744 \*******************************************************************/
7745 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
7746
7747 "use strict";
7748 __webpack_require__.r(__webpack_exports__);
7749 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
7750 /* harmony export */ _asciifold: () => (/* binding */ _asciifold),
7751 /* harmony export */ asciifold: () => (/* binding */ asciifold),
7752 /* harmony export */ code_points: () => (/* binding */ code_points),
7753 /* harmony export */ escape_regex: () => (/* reexport safe */ _regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex),
7754 /* harmony export */ generateMap: () => (/* binding */ generateMap),
7755 /* harmony export */ generateSets: () => (/* binding */ generateSets),
7756 /* harmony export */ generator: () => (/* binding */ generator),
7757 /* harmony export */ getPattern: () => (/* binding */ getPattern),
7758 /* harmony export */ initialize: () => (/* binding */ initialize),
7759 /* harmony export */ mapSequence: () => (/* binding */ mapSequence),
7760 /* harmony export */ normalize: () => (/* binding */ normalize),
7761 /* harmony export */ substringsToPattern: () => (/* binding */ substringsToPattern),
7762 /* harmony export */ unicode_map: () => (/* binding */ unicode_map)
7763 /* harmony export */ });
7764 /* harmony import */ var _regex_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./regex.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js");
7765 /* harmony import */ var _strings_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./strings.js */ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js");
7766
7767
7768 const code_points = [[0, 65535]];
7769 const accent_pat = '[\u0300-\u036F\u{b7}\u{2be}\u{2bc}]';
7770 let unicode_map;
7771 let multi_char_reg;
7772 const max_char_length = 3;
7773 const latin_convert = {};
7774 const latin_condensed = {
7775 '/': '⁄∕',
7776 '0': '߀',
7777 "a": "ⱥɐɑ",
7778 "aa": "ꜳ",
7779 "ae": "æǽǣ",
7780 "ao": "ꜵ",
7781 "au": "ꜷ",
7782 "av": "ꜹꜻ",
7783 "ay": "ꜽ",
7784 "b": "ƀɓƃ",
7785 "c": "ꜿƈȼↄ",
7786 "d": "đɗɖᴅƌꮷԁɦ",
7787 "e": "ɛǝᴇɇ",
7788 "f": "ꝼƒ",
7789 "g": "ǥɠꞡᵹꝿɢ",
7790 "h": "ħⱨⱶɥ",
7791 "i": "ɨı",
7792 "j": "ɉȷ",
7793 "k": "ƙⱪꝁꝃꝅꞣ",
7794 "l": "łƚɫⱡꝉꝇꞁɭ",
7795 "m": "ɱɯϻ",
7796 "n": "ꞥƞɲꞑᴎлԉ",
7797 "o": "øǿɔɵꝋꝍᴑ",
7798 "oe": "œ",
7799 "oi": "ƣ",
7800 "oo": "ꝏ",
7801 "ou": "ȣ",
7802 "p": "ƥᵽꝑꝓꝕρ",
7803 "q": "ꝗꝙɋ",
7804 "r": "ɍɽꝛꞧꞃ",
7805 "s": "ßȿꞩꞅʂ",
7806 "t": "ŧƭʈⱦꞇ",
7807 "th": "þ",
7808 "tz": "ꜩ",
7809 "u": "ʉ",
7810 "v": "ʋꝟʌ",
7811 "vy": "ꝡ",
7812 "w": "ⱳ",
7813 "y": "ƴɏỿ",
7814 "z": "ƶȥɀⱬꝣ",
7815 "hv": "ƕ"
7816 };
7817 for (let latin in latin_condensed) {
7818 let unicode = latin_condensed[latin] || '';
7819 for (let i = 0; i < unicode.length; i++) {
7820 let char = unicode.substring(i, i + 1);
7821 latin_convert[char] = latin;
7822 }
7823 }
7824 const convert_pat = new RegExp(Object.keys(latin_convert).join('|') + '|' + accent_pat, 'gu');
7825 /**
7826 * Initialize the unicode_map from the give code point ranges
7827 */
7828 const initialize = (_code_points) => {
7829 if (unicode_map !== undefined)
7830 return;
7831 unicode_map = generateMap(_code_points || code_points);
7832 };
7833 /**
7834 * Helper method for normalize a string
7835 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize
7836 */
7837 const normalize = (str, form = 'NFKD') => str.normalize(form);
7838 /**
7839 * Remove accents without reordering string
7840 * calling str.normalize('NFKD') on \u{594}\u{595}\u{596} becomes \u{596}\u{594}\u{595}
7841 * via https://github.com/krisk/Fuse/issues/133#issuecomment-318692703
7842 */
7843 const asciifold = (str) => {
7844 return Array.from(str).reduce(
7845 /**
7846 * @param {string} result
7847 * @param {string} char
7848 */
7849 (result, char) => {
7850 return result + _asciifold(char);
7851 }, '');
7852 };
7853 const _asciifold = (str) => {
7854 str = normalize(str)
7855 .toLowerCase()
7856 .replace(convert_pat, (/** @type {string} */ char) => {
7857 return latin_convert[char] || '';
7858 });
7859 //return str;
7860 return normalize(str, 'NFC');
7861 };
7862 /**
7863 * Generate a list of unicode variants from the list of code points
7864 */
7865 function* generator(code_points) {
7866 for (const [code_point_min, code_point_max] of code_points) {
7867 for (let i = code_point_min; i <= code_point_max; i++) {
7868 let composed = String.fromCharCode(i);
7869 let folded = asciifold(composed);
7870 if (folded == composed.toLowerCase()) {
7871 continue;
7872 }
7873 // skip when folded is a string longer than 3 characters long
7874 // bc the resulting regex patterns will be long
7875 // eg:
7876 // folded صلى الله عليه وسلم length 18 code point 65018
7877 // folded جل جلاله length 8 code point 65019
7878 if (folded.length > max_char_length) {
7879 continue;
7880 }
7881 if (folded.length == 0) {
7882 continue;
7883 }
7884 yield { folded: folded, composed: composed, code_point: i };
7885 }
7886 }
7887 }
7888 /**
7889 * Generate a unicode map from the list of code points
7890 */
7891 const generateSets = (code_points) => {
7892 const unicode_sets = {};
7893 const addMatching = (folded, to_add) => {
7894 /** @type {Set<string>} */
7895 const folded_set = unicode_sets[folded] || new Set();
7896 const patt = new RegExp('^' + (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(folded_set) + '$', 'iu');
7897 if (to_add.match(patt)) {
7898 return;
7899 }
7900 folded_set.add((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(to_add));
7901 unicode_sets[folded] = folded_set;
7902 };
7903 for (let value of generator(code_points)) {
7904 addMatching(value.folded, value.folded);
7905 addMatching(value.folded, value.composed);
7906 }
7907 return unicode_sets;
7908 };
7909 /**
7910 * Generate a unicode map from the list of code points
7911 * ae => (?:(?:ae|Æ|Ǽ|Ǣ)|(?:A|Ⓐ|A...)(?:E|ɛ|Ⓔ...))
7912 */
7913 const generateMap = (code_points) => {
7914 const unicode_sets = generateSets(code_points);
7915 const unicode_map = {};
7916 let multi_char = [];
7917 for (let folded in unicode_sets) {
7918 let set = unicode_sets[folded];
7919 if (set) {
7920 unicode_map[folded] = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.setToPattern)(set);
7921 }
7922 if (folded.length > 1) {
7923 multi_char.push((0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.escape_regex)(folded));
7924 }
7925 }
7926 multi_char.sort((a, b) => b.length - a.length);
7927 const multi_char_patt = (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(multi_char);
7928 multi_char_reg = new RegExp('^' + multi_char_patt, 'u');
7929 return unicode_map;
7930 };
7931 /**
7932 * Map each element of an array from its folded value to all possible unicode matches
7933 */
7934 const mapSequence = (strings, min_replacement = 1) => {
7935 let chars_replaced = 0;
7936 strings = strings.map((str) => {
7937 if (unicode_map[str]) {
7938 chars_replaced += str.length;
7939 }
7940 return unicode_map[str] || str;
7941 });
7942 if (chars_replaced >= min_replacement) {
7943 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(strings);
7944 }
7945 return '';
7946 };
7947 /**
7948 * Convert a short string and split it into all possible patterns
7949 * Keep a pattern only if min_replacement is met
7950 *
7951 * 'abc'
7952 * => [['abc'],['ab','c'],['a','bc'],['a','b','c']]
7953 * => ['abc-pattern','ab-c-pattern'...]
7954 */
7955 const substringsToPattern = (str, min_replacement = 1) => {
7956 min_replacement = Math.max(min_replacement, str.length - 1);
7957 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)((0,_strings_js__WEBPACK_IMPORTED_MODULE_1__.allSubstrings)(str).map((sub_pat) => {
7958 return mapSequence(sub_pat, min_replacement);
7959 }));
7960 };
7961 /**
7962 * Convert an array of sequences into a pattern
7963 * [{start:0,end:3,length:3,substr:'iii'}...] => (?:iii...)
7964 */
7965 const sequencesToPattern = (sequences, all = true) => {
7966 let min_replacement = sequences.length > 1 ? 1 : 0;
7967 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.arrayToPattern)(sequences.map((sequence) => {
7968 let seq = [];
7969 const len = all ? sequence.length() : sequence.length() - 1;
7970 for (let j = 0; j < len; j++) {
7971 seq.push(substringsToPattern(sequence.substrs[j] || '', min_replacement));
7972 }
7973 return (0,_regex_js__WEBPACK_IMPORTED_MODULE_0__.sequencePattern)(seq);
7974 }));
7975 };
7976 /**
7977 * Return true if the sequence is already in the sequences
7978 */
7979 const inSequences = (needle_seq, sequences) => {
7980 for (const seq of sequences) {
7981 if (seq.start != needle_seq.start || seq.end != needle_seq.end) {
7982 continue;
7983 }
7984 if (seq.substrs.join('') !== needle_seq.substrs.join('')) {
7985 continue;
7986 }
7987 let needle_parts = needle_seq.parts;
7988 const filter = (part) => {
7989 for (const needle_part of needle_parts) {
7990 if (needle_part.start === part.start && needle_part.substr === part.substr) {
7991 return false;
7992 }
7993 if (part.length == 1 || needle_part.length == 1) {
7994 continue;
7995 }
7996 // check for overlapping parts
7997 // a = ['::=','==']
7998 // b = ['::','===']
7999 // a = ['r','sm']
8000 // b = ['rs','m']
8001 if (part.start < needle_part.start && part.end > needle_part.start) {
8002 return true;
8003 }
8004 if (needle_part.start < part.start && needle_part.end > part.start) {
8005 return true;
8006 }
8007 }
8008 return false;
8009 };
8010 let filtered = seq.parts.filter(filter);
8011 if (filtered.length > 0) {
8012 continue;
8013 }
8014 return true;
8015 }
8016 return false;
8017 };
8018 class Sequence {
8019 parts;
8020 substrs;
8021 start;
8022 end;
8023 constructor() {
8024 this.parts = [];
8025 this.substrs = [];
8026 this.start = 0;
8027 this.end = 0;
8028 }
8029 add(part) {
8030 if (part) {
8031 this.parts.push(part);
8032 this.substrs.push(part.substr);
8033 this.start = Math.min(part.start, this.start);
8034 this.end = Math.max(part.end, this.end);
8035 }
8036 }
8037 last() {
8038 return this.parts[this.parts.length - 1];
8039 }
8040 length() {
8041 return this.parts.length;
8042 }
8043 clone(position, last_piece) {
8044 let clone = new Sequence();
8045 let parts = JSON.parse(JSON.stringify(this.parts));
8046 let last_part = parts.pop();
8047 for (const part of parts) {
8048 clone.add(part);
8049 }
8050 let last_substr = last_piece.substr.substring(0, position - last_part.start);
8051 let clone_last_len = last_substr.length;
8052 clone.add({ start: last_part.start, end: last_part.start + clone_last_len, length: clone_last_len, substr: last_substr });
8053 return clone;
8054 }
8055 }
8056 /**
8057 * Expand a regular expression pattern to include unicode variants
8058 * eg /a/ becomes /aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑAⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ/
8059 *
8060 * Issue:
8061 * ﺊﺋ [ 'ﺊ = \\u{fe8a}', 'ﺋ = \\u{fe8b}' ]
8062 * becomes: ئئ [ 'ي = \\u{64a}', 'ٔ = \\u{654}', 'ي = \\u{64a}', 'ٔ = \\u{654}' ]
8063 *
8064 * İIJ = IIJ = ⅡJ
8065 *
8066 * 1/2/4
8067 */
8068 const getPattern = (str) => {
8069 initialize();
8070 str = asciifold(str);
8071 let pattern = '';
8072 let sequences = [new Sequence()];
8073 for (let i = 0; i < str.length; i++) {
8074 let substr = str.substring(i);
8075 let match = substr.match(multi_char_reg);
8076 const char = str.substring(i, i + 1);
8077 const match_str = match ? match[0] : null;
8078 // loop through sequences
8079 // add either the char or multi_match
8080 let overlapping = [];
8081 let added_types = new Set();
8082 for (const sequence of sequences) {
8083 const last_piece = sequence.last();
8084 if (!last_piece || last_piece.length == 1 || last_piece.end <= i) {
8085 // if we have a multi match
8086 if (match_str) {
8087 const len = match_str.length;
8088 sequence.add({ start: i, end: i + len, length: len, substr: match_str });
8089 added_types.add('1');
8090 }
8091 else {
8092 sequence.add({ start: i, end: i + 1, length: 1, substr: char });
8093 added_types.add('2');
8094 }
8095 }
8096 else if (match_str) {
8097 let clone = sequence.clone(i, last_piece);
8098 const len = match_str.length;
8099 clone.add({ start: i, end: i + len, length: len, substr: match_str });
8100 overlapping.push(clone);
8101 }
8102 else {
8103 // don't add char
8104 // adding would create invalid patterns: 234 => [2,34,4]
8105 added_types.add('3');
8106 }
8107 }
8108 // if we have overlapping
8109 if (overlapping.length > 0) {
8110 // ['ii','iii'] before ['i','i','iii']
8111 overlapping = overlapping.sort((a, b) => {
8112 return a.length() - b.length();
8113 });
8114 for (let clone of overlapping) {
8115 // don't add if we already have an equivalent sequence
8116 if (inSequences(clone, sequences)) {
8117 continue;
8118 }
8119 sequences.push(clone);
8120 }
8121 continue;
8122 }
8123 // if we haven't done anything unique
8124 // clean up the patterns
8125 // helps keep patterns smaller
8126 // if str = 'r₨㎧aarss', pattern will be 446 instead of 655
8127 if (i > 0 && added_types.size == 1 && !added_types.has('3')) {
8128 pattern += sequencesToPattern(sequences, false);
8129 let new_seq = new Sequence();
8130 const old_seq = sequences[0];
8131 if (old_seq) {
8132 new_seq.add(old_seq.last());
8133 }
8134 sequences = [new_seq];
8135 }
8136 }
8137 pattern += sequencesToPattern(sequences, true);
8138 return pattern;
8139 };
8140
8141 //# sourceMappingURL=index.js.map
8142
8143 /***/ },
8144
8145 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js"
8146 /*!*******************************************************************!*\
8147 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/regex.js ***!
8148 \*******************************************************************/
8149 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8150
8151 "use strict";
8152 __webpack_require__.r(__webpack_exports__);
8153 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8154 /* harmony export */ arrayToPattern: () => (/* binding */ arrayToPattern),
8155 /* harmony export */ escape_regex: () => (/* binding */ escape_regex),
8156 /* harmony export */ hasDuplicates: () => (/* binding */ hasDuplicates),
8157 /* harmony export */ maxValueLength: () => (/* binding */ maxValueLength),
8158 /* harmony export */ sequencePattern: () => (/* binding */ sequencePattern),
8159 /* harmony export */ setToPattern: () => (/* binding */ setToPattern),
8160 /* harmony export */ unicodeLength: () => (/* binding */ unicodeLength)
8161 /* harmony export */ });
8162 /**
8163 * Convert array of strings to a regular expression
8164 * ex ['ab','a'] => (?:ab|a)
8165 * ex ['a','b'] => [ab]
8166 */
8167 const arrayToPattern = (chars) => {
8168 chars = chars.filter(Boolean);
8169 if (chars.length < 2) {
8170 return chars[0] || '';
8171 }
8172 return (maxValueLength(chars) == 1) ? '[' + chars.join('') + ']' : '(?:' + chars.join('|') + ')';
8173 };
8174 const sequencePattern = (array) => {
8175 if (!hasDuplicates(array)) {
8176 return array.join('');
8177 }
8178 let pattern = '';
8179 let prev_char_count = 0;
8180 const prev_pattern = () => {
8181 if (prev_char_count > 1) {
8182 pattern += '{' + prev_char_count + '}';
8183 }
8184 };
8185 array.forEach((char, i) => {
8186 if (char === array[i - 1]) {
8187 prev_char_count++;
8188 return;
8189 }
8190 prev_pattern();
8191 pattern += char;
8192 prev_char_count = 1;
8193 });
8194 prev_pattern();
8195 return pattern;
8196 };
8197 /**
8198 * Convert array of strings to a regular expression
8199 * ex ['ab','a'] => (?:ab|a)
8200 * ex ['a','b'] => [ab]
8201 */
8202 const setToPattern = (chars) => {
8203 let array = Array.from(chars);
8204 return arrayToPattern(array);
8205 };
8206 /**
8207 * https://stackoverflow.com/questions/7376598/in-javascript-how-do-i-check-if-an-array-has-duplicate-values
8208 */
8209 const hasDuplicates = (array) => {
8210 return (new Set(array)).size !== array.length;
8211 };
8212 /**
8213 * https://stackoverflow.com/questions/63006601/why-does-u-throw-an-invalid-escape-error
8214 */
8215 const escape_regex = (str) => {
8216 return (str + '').replace(/([\$\(\)\*\+\.\?\[\]\^\{\|\}\\])/gu, '\\$1');
8217 };
8218 /**
8219 * Return the max length of array values
8220 */
8221 const maxValueLength = (array) => {
8222 return array.reduce((longest, value) => Math.max(longest, unicodeLength(value)), 0);
8223 };
8224 const unicodeLength = (str) => {
8225 return Array.from(str).length;
8226 };
8227 //# sourceMappingURL=regex.js.map
8228
8229 /***/ },
8230
8231 /***/ "./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js"
8232 /*!*********************************************************************!*\
8233 !*** ./node_modules/@orchidjs/unicode-variants/dist/esm/strings.js ***!
8234 \*********************************************************************/
8235 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8236
8237 "use strict";
8238 __webpack_require__.r(__webpack_exports__);
8239 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8240 /* harmony export */ allSubstrings: () => (/* binding */ allSubstrings)
8241 /* harmony export */ });
8242 /**
8243 * Get all possible combinations of substrings that add up to the given string
8244 * https://stackoverflow.com/questions/30169587/find-all-the-combination-of-substrings-that-add-up-to-the-given-string
8245 */
8246 const allSubstrings = (input) => {
8247 if (input.length === 1)
8248 return [[input]];
8249 let result = [];
8250 const start = input.substring(1);
8251 const suba = allSubstrings(start);
8252 suba.forEach(function (subresult) {
8253 let tmp = subresult.slice(0);
8254 tmp[0] = input.charAt(0) + tmp[0];
8255 result.push(tmp);
8256 tmp = subresult.slice(0);
8257 tmp.unshift(input.charAt(0));
8258 result.push(tmp);
8259 });
8260 return result;
8261 };
8262 //# sourceMappingURL=strings.js.map
8263
8264 /***/ },
8265
8266 /***/ "./node_modules/tom-select/dist/esm/constants.js"
8267 /*!*******************************************************!*\
8268 !*** ./node_modules/tom-select/dist/esm/constants.js ***!
8269 \*******************************************************/
8270 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8271
8272 "use strict";
8273 __webpack_require__.r(__webpack_exports__);
8274 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8275 /* harmony export */ IS_MAC: () => (/* binding */ IS_MAC),
8276 /* harmony export */ KEY_A: () => (/* binding */ KEY_A),
8277 /* harmony export */ KEY_BACKSPACE: () => (/* binding */ KEY_BACKSPACE),
8278 /* harmony export */ KEY_DELETE: () => (/* binding */ KEY_DELETE),
8279 /* harmony export */ KEY_DOWN: () => (/* binding */ KEY_DOWN),
8280 /* harmony export */ KEY_ESC: () => (/* binding */ KEY_ESC),
8281 /* harmony export */ KEY_LEFT: () => (/* binding */ KEY_LEFT),
8282 /* harmony export */ KEY_RETURN: () => (/* binding */ KEY_RETURN),
8283 /* harmony export */ KEY_RIGHT: () => (/* binding */ KEY_RIGHT),
8284 /* harmony export */ KEY_SHORTCUT: () => (/* binding */ KEY_SHORTCUT),
8285 /* harmony export */ KEY_TAB: () => (/* binding */ KEY_TAB),
8286 /* harmony export */ KEY_UP: () => (/* binding */ KEY_UP)
8287 /* harmony export */ });
8288 const KEY_A = 65;
8289 const KEY_RETURN = 13;
8290 const KEY_ESC = 27;
8291 const KEY_LEFT = 37;
8292 const KEY_UP = 38;
8293 const KEY_RIGHT = 39;
8294 const KEY_DOWN = 40;
8295 const KEY_BACKSPACE = 8;
8296 const KEY_DELETE = 46;
8297 const KEY_TAB = 9;
8298 const IS_MAC = typeof navigator === 'undefined' ? false : /Mac/.test(navigator.userAgent);
8299 const KEY_SHORTCUT = IS_MAC ? 'metaKey' : 'ctrlKey'; // ctrl key or apple key for ma
8300 //# sourceMappingURL=constants.js.map
8301
8302 /***/ },
8303
8304 /***/ "./node_modules/tom-select/dist/esm/contrib/highlight.js"
8305 /*!***************************************************************!*\
8306 !*** ./node_modules/tom-select/dist/esm/contrib/highlight.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 */ highlight: () => (/* binding */ highlight),
8314 /* harmony export */ removeHighlight: () => (/* binding */ removeHighlight)
8315 /* harmony export */ });
8316 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
8317 /**
8318 * highlight v3 | MIT license | Johann Burkard <[email protected]>
8319 * Highlights arbitrary terms in a node.
8320 *
8321 * - Modified by Marshal <[email protected]> 2011-6-24 (added regex)
8322 * - Modified by Brian Reavis <[email protected]> 2012-8-27 (cleanup)
8323 */
8324
8325 const highlight = (element, regex) => {
8326 if (regex === null)
8327 return;
8328 // convet string to regex
8329 if (typeof regex === 'string') {
8330 if (!regex.length)
8331 return;
8332 regex = new RegExp(regex, 'i');
8333 }
8334 // Wrap matching part of text node with highlighting <span>, e.g.
8335 // Soccer -> <span class="highlight">Soc</span>cer for regex = /soc/i
8336 const highlightText = (node) => {
8337 var match = node.data.match(regex);
8338 if (match && node.data.length > 0) {
8339 var spannode = document.createElement('span');
8340 spannode.className = 'highlight';
8341 var middlebit = node.splitText(match.index);
8342 middlebit.splitText(match[0].length);
8343 var middleclone = middlebit.cloneNode(true);
8344 spannode.appendChild(middleclone);
8345 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_0__.replaceNode)(middlebit, spannode);
8346 return 1;
8347 }
8348 return 0;
8349 };
8350 // Recurse element node, looking for child text nodes to highlight, unless element
8351 // is childless, <script>, <style>, or already highlighted: <span class="hightlight">
8352 const highlightChildren = (node) => {
8353 if (node.nodeType === 1 && node.childNodes && !/(script|style)/i.test(node.tagName) && (node.className !== 'highlight' || node.tagName !== 'SPAN')) {
8354 Array.from(node.childNodes).forEach(element => {
8355 highlightRecursive(element);
8356 });
8357 }
8358 };
8359 const highlightRecursive = (node) => {
8360 if (node.nodeType === 3) {
8361 return highlightText(node);
8362 }
8363 highlightChildren(node);
8364 return 0;
8365 };
8366 highlightRecursive(element);
8367 };
8368 /**
8369 * removeHighlight fn copied from highlight v5 and
8370 * edited to remove with(), pass js strict mode, and use without jquery
8371 */
8372 const removeHighlight = (el) => {
8373 var elements = el.querySelectorAll("span.highlight");
8374 Array.prototype.forEach.call(elements, function (el) {
8375 var parent = el.parentNode;
8376 parent.replaceChild(el.firstChild, el);
8377 parent.normalize();
8378 });
8379 };
8380 //# sourceMappingURL=highlight.js.map
8381
8382 /***/ },
8383
8384 /***/ "./node_modules/tom-select/dist/esm/contrib/microevent.js"
8385 /*!****************************************************************!*\
8386 !*** ./node_modules/tom-select/dist/esm/contrib/microevent.js ***!
8387 \****************************************************************/
8388 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8389
8390 "use strict";
8391 __webpack_require__.r(__webpack_exports__);
8392 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8393 /* harmony export */ "default": () => (/* binding */ MicroEvent)
8394 /* harmony export */ });
8395 /**
8396 * MicroEvent - to make any js object an event emitter
8397 *
8398 * - pure javascript - server compatible, browser compatible
8399 * - dont rely on the browser doms
8400 * - super simple - you get it immediatly, no mistery, no magic involved
8401 *
8402 * @author Jerome Etienne (https://github.com/jeromeetienne)
8403 */
8404 /**
8405 * Execute callback for each event in space separated list of event names
8406 *
8407 */
8408 function forEvents(events, callback) {
8409 events.split(/\s+/).forEach((event) => {
8410 callback(event);
8411 });
8412 }
8413 class MicroEvent {
8414 constructor() {
8415 this._events = {};
8416 }
8417 on(events, fct) {
8418 forEvents(events, (event) => {
8419 const event_array = this._events[event] || [];
8420 event_array.push(fct);
8421 this._events[event] = event_array;
8422 });
8423 }
8424 off(events, fct) {
8425 var n = arguments.length;
8426 if (n === 0) {
8427 this._events = {};
8428 return;
8429 }
8430 forEvents(events, (event) => {
8431 if (n === 1) {
8432 delete this._events[event];
8433 return;
8434 }
8435 const event_array = this._events[event];
8436 if (event_array === undefined)
8437 return;
8438 event_array.splice(event_array.indexOf(fct), 1);
8439 this._events[event] = event_array;
8440 });
8441 }
8442 trigger(events, ...args) {
8443 var self = this;
8444 forEvents(events, (event) => {
8445 const event_array = self._events[event];
8446 if (event_array === undefined)
8447 return;
8448 event_array.forEach(fct => {
8449 fct.apply(self, args);
8450 });
8451 });
8452 }
8453 }
8454 ;
8455 //# sourceMappingURL=microevent.js.map
8456
8457 /***/ },
8458
8459 /***/ "./node_modules/tom-select/dist/esm/contrib/microplugin.js"
8460 /*!*****************************************************************!*\
8461 !*** ./node_modules/tom-select/dist/esm/contrib/microplugin.js ***!
8462 \*****************************************************************/
8463 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8464
8465 "use strict";
8466 __webpack_require__.r(__webpack_exports__);
8467 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8468 /* harmony export */ "default": () => (/* binding */ MicroPlugin)
8469 /* harmony export */ });
8470 /**
8471 * microplugin.js
8472 * Copyright (c) 2013 Brian Reavis & contributors
8473 *
8474 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8475 * file except in compliance with the License. You may obtain a copy of the License at:
8476 * http://www.apache.org/licenses/LICENSE-2.0
8477 *
8478 * Unless required by applicable law or agreed to in writing, software distributed under
8479 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8480 * ANY KIND, either express or implied. See the License for the specific language
8481 * governing permissions and limitations under the License.
8482 *
8483 * @author Brian Reavis <[email protected]>
8484 */
8485 function MicroPlugin(Interface) {
8486 Interface.plugins = {};
8487 return class extends Interface {
8488 constructor() {
8489 super(...arguments);
8490 this.plugins = {
8491 names: [],
8492 settings: {},
8493 requested: {},
8494 loaded: {}
8495 };
8496 }
8497 /**
8498 * Registers a plugin.
8499 *
8500 * @param {function} fn
8501 */
8502 static define(name, fn) {
8503 Interface.plugins[name] = {
8504 'name': name,
8505 'fn': fn
8506 };
8507 }
8508 /**
8509 * Initializes the listed plugins (with options).
8510 * Acceptable formats:
8511 *
8512 * List (without options):
8513 * ['a', 'b', 'c']
8514 *
8515 * List (with options):
8516 * [{'name': 'a', options: {}}, {'name': 'b', options: {}}]
8517 *
8518 * Hash (with options):
8519 * {'a': { ... }, 'b': { ... }, 'c': { ... }}
8520 *
8521 * @param {array|object} plugins
8522 */
8523 initializePlugins(plugins) {
8524 var key, name;
8525 const self = this;
8526 const queue = [];
8527 if (Array.isArray(plugins)) {
8528 plugins.forEach((plugin) => {
8529 if (typeof plugin === 'string') {
8530 queue.push(plugin);
8531 }
8532 else {
8533 self.plugins.settings[plugin.name] = plugin.options;
8534 queue.push(plugin.name);
8535 }
8536 });
8537 }
8538 else if (plugins) {
8539 for (key in plugins) {
8540 if (plugins.hasOwnProperty(key)) {
8541 self.plugins.settings[key] = plugins[key];
8542 queue.push(key);
8543 }
8544 }
8545 }
8546 while (name = queue.shift()) {
8547 self.require(name);
8548 }
8549 }
8550 loadPlugin(name) {
8551 var self = this;
8552 var plugins = self.plugins;
8553 var plugin = Interface.plugins[name];
8554 if (!Interface.plugins.hasOwnProperty(name)) {
8555 throw new Error('Unable to find "' + name + '" plugin');
8556 }
8557 plugins.requested[name] = true;
8558 plugins.loaded[name] = plugin.fn.apply(self, [self.plugins.settings[name] || {}]);
8559 plugins.names.push(name);
8560 }
8561 /**
8562 * Initializes a plugin.
8563 *
8564 */
8565 require(name) {
8566 var self = this;
8567 var plugins = self.plugins;
8568 if (!self.plugins.loaded.hasOwnProperty(name)) {
8569 if (plugins.requested[name]) {
8570 throw new Error('Plugin has circular dependency ("' + name + '")');
8571 }
8572 self.loadPlugin(name);
8573 }
8574 return plugins.loaded[name];
8575 }
8576 };
8577 }
8578 //# sourceMappingURL=microplugin.js.map
8579
8580 /***/ },
8581
8582 /***/ "./node_modules/tom-select/dist/esm/defaults.js"
8583 /*!******************************************************!*\
8584 !*** ./node_modules/tom-select/dist/esm/defaults.js ***!
8585 \******************************************************/
8586 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8587
8588 "use strict";
8589 __webpack_require__.r(__webpack_exports__);
8590 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8591 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
8592 /* harmony export */ });
8593 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({
8594 options: [],
8595 optgroups: [],
8596 plugins: [],
8597 delimiter: ',',
8598 splitOn: null, // regexp or string for splitting up values from a paste command
8599 persist: true,
8600 diacritics: true,
8601 create: null,
8602 createOnBlur: false,
8603 createFilter: null,
8604 clearAfterSelect: false,
8605 highlight: true,
8606 openOnFocus: true,
8607 shouldOpen: null,
8608 maxOptions: 50,
8609 maxItems: null,
8610 hideSelected: null,
8611 duplicates: false,
8612 addPrecedence: false,
8613 selectOnTab: false,
8614 preload: null,
8615 allowEmptyOption: false,
8616 //closeAfterSelect: false,
8617 refreshThrottle: 300,
8618 loadThrottle: 300,
8619 loadingClass: 'loading',
8620 dataAttr: null, //'data-data',
8621 optgroupField: 'optgroup',
8622 valueField: 'value',
8623 labelField: 'text',
8624 disabledField: 'disabled',
8625 optgroupLabelField: 'label',
8626 optgroupValueField: 'value',
8627 lockOptgroupOrder: false,
8628 sortField: '$order',
8629 searchField: ['text'],
8630 searchConjunction: 'and',
8631 mode: null,
8632 wrapperClass: 'ts-wrapper',
8633 controlClass: 'ts-control',
8634 dropdownClass: 'ts-dropdown',
8635 dropdownContentClass: 'ts-dropdown-content',
8636 itemClass: 'item',
8637 optionClass: 'option',
8638 dropdownParent: null,
8639 controlInput: '<input type="text" autocomplete="off" size="1" />',
8640 copyClassesToDropdown: false,
8641 placeholder: null,
8642 hidePlaceholder: null,
8643 shouldLoad: function (query) {
8644 return query.length > 0;
8645 },
8646 /*
8647 load : null, // function(query, callback) { ... }
8648 score : null, // function(search) { ... }
8649 onInitialize : null, // function() { ... }
8650 onChange : null, // function(value) { ... }
8651 onItemAdd : null, // function(value, $item) { ... }
8652 onItemRemove : null, // function(value) { ... }
8653 onClear : null, // function() { ... }
8654 onOptionAdd : null, // function(value, data) { ... }
8655 onOptionRemove : null, // function(value) { ... }
8656 onOptionClear : null, // function() { ... }
8657 onOptionGroupAdd : null, // function(id, data) { ... }
8658 onOptionGroupRemove : null, // function(id) { ... }
8659 onOptionGroupClear : null, // function() { ... }
8660 onDropdownOpen : null, // function(dropdown) { ... }
8661 onDropdownClose : null, // function(dropdown) { ... }
8662 onType : null, // function(str) { ... }
8663 onDelete : null, // function(values) { ... }
8664 */
8665 render: {
8666 /*
8667 item: null,
8668 optgroup: null,
8669 optgroup_header: null,
8670 option: null,
8671 option_create: null
8672 */
8673 }
8674 });
8675 //# sourceMappingURL=defaults.js.map
8676
8677 /***/ },
8678
8679 /***/ "./node_modules/tom-select/dist/esm/getSettings.js"
8680 /*!*********************************************************!*\
8681 !*** ./node_modules/tom-select/dist/esm/getSettings.js ***!
8682 \*********************************************************/
8683 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8684
8685 "use strict";
8686 __webpack_require__.r(__webpack_exports__);
8687 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8688 /* harmony export */ "default": () => (/* binding */ getSettings)
8689 /* harmony export */ });
8690 /* harmony import */ var _defaults_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaults.js */ "./node_modules/tom-select/dist/esm/defaults.js");
8691 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
8692
8693
8694 function getSettings(input, settings_user) {
8695 var settings = Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_user);
8696 var attr_data = settings.dataAttr;
8697 var field_label = settings.labelField;
8698 var field_value = settings.valueField;
8699 var field_disabled = settings.disabledField;
8700 var field_optgroup = settings.optgroupField;
8701 var field_optgroup_label = settings.optgroupLabelField;
8702 var field_optgroup_value = settings.optgroupValueField;
8703 var tag_name = input.tagName.toLowerCase();
8704 var placeholder = input.getAttribute('placeholder') || input.getAttribute('data-placeholder');
8705 if (!placeholder && !settings.allowEmptyOption) {
8706 let option = input.querySelector('option[value=""]');
8707 if (option) {
8708 placeholder = option.textContent;
8709 }
8710 }
8711 var settings_element = {
8712 placeholder: placeholder,
8713 options: [],
8714 optgroups: [],
8715 items: [],
8716 maxItems: null,
8717 };
8718 /**
8719 * Initialize from a <select> element.
8720 *
8721 */
8722 var init_select = () => {
8723 var tagName;
8724 var options = settings_element.options;
8725 var optionsMap = {};
8726 var group_count = 1;
8727 let $order = 0;
8728 var readData = (el) => {
8729 var data = Object.assign({}, el.dataset); // get plain object from DOMStringMap
8730 var json = attr_data && data[attr_data];
8731 if (typeof json === 'string' && json.length) {
8732 data = Object.assign(data, JSON.parse(json));
8733 }
8734 return data;
8735 };
8736 var addOption = (option, group) => {
8737 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.hash_key)(option.value);
8738 if (value == null)
8739 return;
8740 if (!value && !settings.allowEmptyOption)
8741 return;
8742 // if the option already exists, it's probably been
8743 // duplicated in another optgroup. in this case, push
8744 // the current group to the "optgroup" property on the
8745 // existing option so that it's rendered in both places.
8746 if (optionsMap.hasOwnProperty(value)) {
8747 if (group) {
8748 var arr = optionsMap[value][field_optgroup];
8749 if (!arr) {
8750 optionsMap[value][field_optgroup] = group;
8751 }
8752 else if (!Array.isArray(arr)) {
8753 optionsMap[value][field_optgroup] = [arr, group];
8754 }
8755 else {
8756 arr.push(group);
8757 }
8758 }
8759 }
8760 else {
8761 var option_data = readData(option);
8762 option_data[field_label] = option_data[field_label] || option.textContent;
8763 option_data[field_value] = option_data[field_value] || value;
8764 option_data[field_disabled] = option_data[field_disabled] || option.disabled;
8765 option_data[field_optgroup] = option_data[field_optgroup] || group;
8766 option_data.$option = option;
8767 option_data.$order = option_data.$order || ++$order;
8768 optionsMap[value] = option_data;
8769 options.push(option_data);
8770 }
8771 if (option.selected) {
8772 settings_element.items.push(value);
8773 }
8774 };
8775 var addGroup = (optgroup) => {
8776 var id, optgroup_data;
8777 optgroup_data = readData(optgroup);
8778 optgroup_data[field_optgroup_label] = optgroup_data[field_optgroup_label] || optgroup.getAttribute('label') || '';
8779 optgroup_data[field_optgroup_value] = optgroup_data[field_optgroup_value] || group_count++;
8780 optgroup_data[field_disabled] = optgroup_data[field_disabled] || optgroup.disabled;
8781 optgroup_data.$order = optgroup_data.$order || ++$order;
8782 settings_element.optgroups.push(optgroup_data);
8783 id = optgroup_data[field_optgroup_value];
8784 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(optgroup.children, (option) => {
8785 addOption(option, id);
8786 });
8787 };
8788 settings_element.maxItems = input.hasAttribute('multiple') ? null : 1;
8789 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(input.children, (child) => {
8790 tagName = child.tagName.toLowerCase();
8791 if (tagName === 'optgroup') {
8792 addGroup(child);
8793 }
8794 else if (tagName === 'option') {
8795 addOption(child);
8796 }
8797 });
8798 };
8799 /**
8800 * Initialize from a <input type="text"> element.
8801 *
8802 */
8803 var init_textbox = () => {
8804 var _a, _b;
8805 const data_raw = input.getAttribute(attr_data);
8806 if (!data_raw) {
8807 var value = (_b = (_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
8808 if (!settings.allowEmptyOption && !value.length)
8809 return;
8810 const values = value.split(settings.delimiter);
8811 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(values, (value) => {
8812 const option = {};
8813 option[field_label] = value;
8814 option[field_value] = value;
8815 settings_element.options.push(option);
8816 });
8817 settings_element.items = values;
8818 }
8819 else {
8820 settings_element.options = JSON.parse(data_raw);
8821 (0,_utils_js__WEBPACK_IMPORTED_MODULE_1__.iterate)(settings_element.options, (opt) => {
8822 settings_element.items.push(opt[field_value]);
8823 });
8824 }
8825 };
8826 if (tag_name === 'select') {
8827 init_select();
8828 }
8829 else {
8830 init_textbox();
8831 }
8832 return Object.assign({}, _defaults_js__WEBPACK_IMPORTED_MODULE_0__["default"], settings_element, settings_user);
8833 }
8834 ;
8835 //# sourceMappingURL=getSettings.js.map
8836
8837 /***/ },
8838
8839 /***/ "./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js"
8840 /*!***************************************************************************!*\
8841 !*** ./node_modules/tom-select/dist/esm/plugins/caret_position/plugin.js ***!
8842 \***************************************************************************/
8843 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
8844
8845 "use strict";
8846 __webpack_require__.r(__webpack_exports__);
8847 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
8848 /* harmony export */ "default": () => (/* binding */ plugin)
8849 /* harmony export */ });
8850 /**
8851 * Tom Select v2.6.2
8852 * Licensed under the Apache License, Version 2.0 (the "License");
8853 */
8854
8855 /**
8856 * Converts a scalar to its best string representation
8857 * for hash keys and HTML attribute values.
8858 *
8859 * Transformations:
8860 * 'str' -> 'str'
8861 * null -> ''
8862 * undefined -> ''
8863 * true -> '1'
8864 * false -> '0'
8865 * 0 -> '0'
8866 * 1 -> '1'
8867 *
8868 */
8869
8870 /**
8871 * Iterates over arrays and hashes.
8872 *
8873 * ```
8874 * iterate(this.items, function(item, id) {
8875 * // invoked for each item
8876 * });
8877 * ```
8878 *
8879 */
8880 const iterate = (object, callback) => {
8881 if (Array.isArray(object)) {
8882 object.forEach(callback);
8883 } else {
8884 for (var key in object) {
8885 if (object.hasOwnProperty(key)) {
8886 callback(object[key], key);
8887 }
8888 }
8889 }
8890 };
8891
8892 /**
8893 * Remove css classes
8894 *
8895 */
8896 const removeClasses = (elmts, ...classes) => {
8897 var norm_classes = classesArray(classes);
8898 elmts = castAsArray(elmts);
8899 elmts.map(el => {
8900 norm_classes.map(cls => {
8901 el.classList.remove(cls);
8902 });
8903 });
8904 };
8905
8906 /**
8907 * Return arguments
8908 *
8909 */
8910 const classesArray = args => {
8911 var classes = [];
8912 iterate(args, _classes => {
8913 if (typeof _classes === 'string') {
8914 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
8915 }
8916 if (Array.isArray(_classes)) {
8917 classes = classes.concat(_classes);
8918 }
8919 });
8920 return classes.filter(Boolean);
8921 };
8922
8923 /**
8924 * Create an array from arg if it's not already an array
8925 *
8926 */
8927 const castAsArray = arg => {
8928 if (!Array.isArray(arg)) {
8929 arg = [arg];
8930 }
8931 return arg;
8932 };
8933
8934 /**
8935 * Get the index of an element amongst sibling nodes of the same type
8936 *
8937 */
8938 const nodeIndex = (el, amongst) => {
8939 if (!el) return -1;
8940 amongst = amongst || el.nodeName;
8941 var i = 0;
8942 while (el = el.previousElementSibling) {
8943 if (el.matches(amongst)) {
8944 i++;
8945 }
8946 }
8947 return i;
8948 };
8949
8950 /**
8951 * Plugin: "dropdown_input" (Tom Select)
8952 * Copyright (c) contributors
8953 *
8954 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
8955 * file except in compliance with the License. You may obtain a copy of the License at:
8956 * http://www.apache.org/licenses/LICENSE-2.0
8957 *
8958 * Unless required by applicable law or agreed to in writing, software distributed under
8959 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
8960 * ANY KIND, either express or implied. See the License for the specific language
8961 * governing permissions and limitations under the License.
8962 *
8963 */
8964
8965 function plugin () {
8966 var self = this;
8967
8968 /**
8969 * Moves the caret to the specified index.
8970 *
8971 * The input must be moved by leaving it in place and moving the
8972 * siblings, due to the fact that focus cannot be restored once lost
8973 * on mobile webkit devices
8974 *
8975 */
8976 self.hook('instead', 'setCaret', new_pos => {
8977 if (self.settings.mode === 'single' || !self.control.contains(self.control_input)) {
8978 new_pos = self.items.length;
8979 } else {
8980 new_pos = Math.max(0, Math.min(self.items.length, new_pos));
8981 if (new_pos != self.caretPos && !self.isPending) {
8982 self.controlChildren().forEach((child, j) => {
8983 if (j < new_pos) {
8984 self.control_input.insertAdjacentElement('beforebegin', child);
8985 } else {
8986 self.control.appendChild(child);
8987 }
8988 });
8989 }
8990 }
8991 self.caretPos = new_pos;
8992 });
8993 self.hook('instead', 'moveCaret', direction => {
8994 if (!self.isFocused) return;
8995
8996 // move caret before or after selected items
8997 const last_active = self.getLastActive(direction);
8998 if (last_active) {
8999 const idx = nodeIndex(last_active);
9000 self.setCaret(direction > 0 ? idx + 1 : idx);
9001 self.setActiveItem();
9002 removeClasses(last_active, 'last-active');
9003
9004 // move caret left or right of current position
9005 } else {
9006 self.setCaret(self.caretPos + direction);
9007 }
9008 });
9009 }
9010
9011
9012 //# sourceMappingURL=plugin.js.map
9013
9014
9015 /***/ },
9016
9017 /***/ "./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js"
9018 /*!****************************************************************************!*\
9019 !*** ./node_modules/tom-select/dist/esm/plugins/change_listener/plugin.js ***!
9020 \****************************************************************************/
9021 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9022
9023 "use strict";
9024 __webpack_require__.r(__webpack_exports__);
9025 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9026 /* harmony export */ "default": () => (/* binding */ plugin)
9027 /* harmony export */ });
9028 /**
9029 * Tom Select v2.6.2
9030 * Licensed under the Apache License, Version 2.0 (the "License");
9031 */
9032
9033 /**
9034 * Converts a scalar to its best string representation
9035 * for hash keys and HTML attribute values.
9036 *
9037 * Transformations:
9038 * 'str' -> 'str'
9039 * null -> ''
9040 * undefined -> ''
9041 * true -> '1'
9042 * false -> '0'
9043 * 0 -> '0'
9044 * 1 -> '1'
9045 *
9046 */
9047
9048 /**
9049 * Add event helper
9050 *
9051 */
9052 const addEvent = (target, type, callback, options) => {
9053 target.addEventListener(type, callback, options);
9054 };
9055
9056 /**
9057 * Plugin: "change_listener" (Tom Select)
9058 * Copyright (c) contributors
9059 *
9060 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9061 * file except in compliance with the License. You may obtain a copy of the License at:
9062 * http://www.apache.org/licenses/LICENSE-2.0
9063 *
9064 * Unless required by applicable law or agreed to in writing, software distributed under
9065 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9066 * ANY KIND, either express or implied. See the License for the specific language
9067 * governing permissions and limitations under the License.
9068 *
9069 */
9070
9071 function plugin () {
9072 addEvent(this.input, 'change', () => {
9073 this.sync();
9074 });
9075 }
9076
9077
9078 //# sourceMappingURL=plugin.js.map
9079
9080
9081 /***/ },
9082
9083 /***/ "./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js"
9084 /*!*****************************************************************************!*\
9085 !*** ./node_modules/tom-select/dist/esm/plugins/checkbox_options/plugin.js ***!
9086 \*****************************************************************************/
9087 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9088
9089 "use strict";
9090 __webpack_require__.r(__webpack_exports__);
9091 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9092 /* harmony export */ "default": () => (/* binding */ plugin)
9093 /* harmony export */ });
9094 /**
9095 * Tom Select v2.6.2
9096 * Licensed under the Apache License, Version 2.0 (the "License");
9097 */
9098
9099 /**
9100 * Converts a scalar to its best string representation
9101 * for hash keys and HTML attribute values.
9102 *
9103 * Transformations:
9104 * 'str' -> 'str'
9105 * null -> ''
9106 * undefined -> ''
9107 * true -> '1'
9108 * false -> '0'
9109 * 0 -> '0'
9110 * 1 -> '1'
9111 *
9112 */
9113 const hash_key = value => {
9114 if (typeof value === 'undefined' || value === null) return null;
9115 return get_hash(value);
9116 };
9117 const get_hash = value => {
9118 if (typeof value === 'boolean') return value ? '1' : '0';
9119 return value + '';
9120 };
9121
9122 /**
9123 * Prevent default
9124 *
9125 */
9126 const preventDefault = (evt, stop = false) => {
9127 if (evt) {
9128 evt.preventDefault();
9129 if (stop) {
9130 evt.stopPropagation();
9131 }
9132 }
9133 };
9134
9135 /**
9136 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9137 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9138 *
9139 * param query should be {}
9140 */
9141 const getDom = query => {
9142 if (query.jquery) {
9143 return query[0];
9144 }
9145 if (query instanceof HTMLElement) {
9146 return query;
9147 }
9148 if (isHtmlString(query)) {
9149 var tpl = document.createElement('template');
9150 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9151 return tpl.content.firstChild;
9152 }
9153 return document.querySelector(query);
9154 };
9155 const isHtmlString = arg => {
9156 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9157 return true;
9158 }
9159 return false;
9160 };
9161
9162 /**
9163 * Plugin: "checkbox_options" (Tom Select)
9164 * Copyright (c) contributors
9165 *
9166 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9167 * file except in compliance with the License. You may obtain a copy of the License at:
9168 * http://www.apache.org/licenses/LICENSE-2.0
9169 *
9170 * Unless required by applicable law or agreed to in writing, software distributed under
9171 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9172 * ANY KIND, either express or implied. See the License for the specific language
9173 * governing permissions and limitations under the License.
9174 *
9175 */
9176
9177 function plugin (userOptions) {
9178 var self = this;
9179 var orig_onOptionSelect = self.onOptionSelect;
9180 self.settings.hideSelected = false;
9181 const cbOptions = Object.assign({
9182 // so that the user may add different ones as well
9183 className: "tomselect-checkbox",
9184 // the following default to the historic plugin's values
9185 checkedClassNames: undefined,
9186 uncheckedClassNames: undefined
9187 }, userOptions);
9188 var UpdateChecked = function UpdateChecked(checkbox, toCheck) {
9189 if (toCheck) {
9190 checkbox.checked = true;
9191 if (cbOptions.uncheckedClassNames) {
9192 checkbox.classList.remove(...cbOptions.uncheckedClassNames);
9193 }
9194 if (cbOptions.checkedClassNames) {
9195 checkbox.classList.add(...cbOptions.checkedClassNames);
9196 }
9197 } else {
9198 checkbox.checked = false;
9199 if (cbOptions.checkedClassNames) {
9200 checkbox.classList.remove(...cbOptions.checkedClassNames);
9201 }
9202 if (cbOptions.uncheckedClassNames) {
9203 checkbox.classList.add(...cbOptions.uncheckedClassNames);
9204 }
9205 }
9206 };
9207
9208 // update the checkbox for an option
9209 var UpdateCheckbox = function UpdateCheckbox(option) {
9210 setTimeout(() => {
9211 var checkbox = option.querySelector('input.' + cbOptions.className);
9212 if (checkbox instanceof HTMLInputElement) {
9213 UpdateChecked(checkbox, option.classList.contains('selected'));
9214 }
9215 }, 1);
9216 };
9217
9218 // add checkbox to option template
9219 self.hook('after', 'setupTemplates', () => {
9220 var orig_render_option = self.settings.render.option;
9221 self.settings.render.option = (data, escape_html) => {
9222 var rendered = getDom(orig_render_option.call(self, data, escape_html));
9223 var checkbox = document.createElement('input');
9224 if (cbOptions.className) {
9225 checkbox.classList.add(cbOptions.className);
9226 }
9227 checkbox.addEventListener('click', function (evt) {
9228 preventDefault(evt);
9229 });
9230 checkbox.type = 'checkbox';
9231 const hashed = hash_key(data[self.settings.valueField]);
9232 UpdateChecked(checkbox, !!(hashed && self.items.indexOf(hashed) > -1));
9233 rendered.prepend(checkbox);
9234 return rendered;
9235 };
9236 });
9237
9238 // uncheck when item removed
9239 self.on('item_remove', value => {
9240 var option = self.getOption(value);
9241 if (option) {
9242 // if dropdown hasn't been opened yet, the option won't exist
9243 option.classList.remove('selected'); // selected class won't be removed yet
9244 UpdateCheckbox(option);
9245 }
9246 });
9247
9248 // check when item added
9249 self.on('item_add', value => {
9250 var option = self.getOption(value);
9251 if (option) {
9252 // if dropdown hasn't been opened yet, the option won't exist
9253 UpdateCheckbox(option);
9254 }
9255 });
9256
9257 // remove items when selected option is clicked
9258 self.hook('instead', 'onOptionSelect', (evt, option) => {
9259 if (option.classList.contains('selected')) {
9260 option.classList.remove('selected');
9261 self.removeItem(option.dataset.value);
9262 self.refreshOptions();
9263 preventDefault(evt, true);
9264 return;
9265 }
9266 orig_onOptionSelect.call(self, evt, option);
9267 UpdateCheckbox(option);
9268 });
9269 }
9270
9271
9272 //# sourceMappingURL=plugin.js.map
9273
9274
9275 /***/ },
9276
9277 /***/ "./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js"
9278 /*!*************************************************************************!*\
9279 !*** ./node_modules/tom-select/dist/esm/plugins/clear_button/plugin.js ***!
9280 \*************************************************************************/
9281 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9282
9283 "use strict";
9284 __webpack_require__.r(__webpack_exports__);
9285 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9286 /* harmony export */ "default": () => (/* binding */ plugin)
9287 /* harmony export */ });
9288 /**
9289 * Tom Select v2.6.2
9290 * Licensed under the Apache License, Version 2.0 (the "License");
9291 */
9292
9293 /**
9294 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9295 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9296 *
9297 * param query should be {}
9298 */
9299 const getDom = query => {
9300 if (query.jquery) {
9301 return query[0];
9302 }
9303 if (query instanceof HTMLElement) {
9304 return query;
9305 }
9306 if (isHtmlString(query)) {
9307 var tpl = document.createElement('template');
9308 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9309 return tpl.content.firstChild;
9310 }
9311 return document.querySelector(query);
9312 };
9313 const isHtmlString = arg => {
9314 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9315 return true;
9316 }
9317 return false;
9318 };
9319
9320 /**
9321 * Plugin: "dropdown_header" (Tom Select)
9322 * Copyright (c) contributors
9323 *
9324 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9325 * file except in compliance with the License. You may obtain a copy of the License at:
9326 * http://www.apache.org/licenses/LICENSE-2.0
9327 *
9328 * Unless required by applicable law or agreed to in writing, software distributed under
9329 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9330 * ANY KIND, either express or implied. See the License for the specific language
9331 * governing permissions and limitations under the License.
9332 *
9333 */
9334
9335 function plugin (userOptions) {
9336 const self = this;
9337 const options = Object.assign({
9338 className: 'clear-button',
9339 title: 'Clear All',
9340 role: 'button',
9341 tabindex: 0,
9342 html: data => {
9343 return `<div class="${data.className}" title="${data.title}" role="${data.role}" tabindex="${data.tabindex}">&times;</div>`;
9344 }
9345 }, userOptions);
9346 self.on('initialize', () => {
9347 var button = getDom(options.html(options));
9348 button.addEventListener('click', evt => {
9349 if (self.isLocked) return;
9350 self.clear();
9351 if (self.settings.mode === 'single' && self.settings.allowEmptyOption) {
9352 self.addItem('');
9353 }
9354 self.refreshOptions(false);
9355 evt.preventDefault();
9356 evt.stopPropagation();
9357 });
9358 self.control.appendChild(button);
9359 });
9360 }
9361
9362
9363 //# sourceMappingURL=plugin.js.map
9364
9365
9366 /***/ },
9367
9368 /***/ "./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js"
9369 /*!**********************************************************************!*\
9370 !*** ./node_modules/tom-select/dist/esm/plugins/drag_drop/plugin.js ***!
9371 \**********************************************************************/
9372 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9373
9374 "use strict";
9375 __webpack_require__.r(__webpack_exports__);
9376 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9377 /* harmony export */ "default": () => (/* binding */ plugin)
9378 /* harmony export */ });
9379 /**
9380 * Tom Select v2.6.2
9381 * Licensed under the Apache License, Version 2.0 (the "License");
9382 */
9383
9384 /**
9385 * Converts a scalar to its best string representation
9386 * for hash keys and HTML attribute values.
9387 *
9388 * Transformations:
9389 * 'str' -> 'str'
9390 * null -> ''
9391 * undefined -> ''
9392 * true -> '1'
9393 * false -> '0'
9394 * 0 -> '0'
9395 * 1 -> '1'
9396 *
9397 */
9398
9399 /**
9400 * Prevent default
9401 *
9402 */
9403 const preventDefault = (evt, stop = false) => {
9404 if (evt) {
9405 evt.preventDefault();
9406 if (stop) {
9407 evt.stopPropagation();
9408 }
9409 }
9410 };
9411
9412 /**
9413 * Add event helper
9414 *
9415 */
9416 const addEvent = (target, type, callback, options) => {
9417 target.addEventListener(type, callback, options);
9418 };
9419
9420 /**
9421 * Iterates over arrays and hashes.
9422 *
9423 * ```
9424 * iterate(this.items, function(item, id) {
9425 * // invoked for each item
9426 * });
9427 * ```
9428 *
9429 */
9430 const iterate = (object, callback) => {
9431 if (Array.isArray(object)) {
9432 object.forEach(callback);
9433 } else {
9434 for (var key in object) {
9435 if (object.hasOwnProperty(key)) {
9436 callback(object[key], key);
9437 }
9438 }
9439 }
9440 };
9441
9442 /**
9443 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9444 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9445 *
9446 * param query should be {}
9447 */
9448 const getDom = query => {
9449 if (query.jquery) {
9450 return query[0];
9451 }
9452 if (query instanceof HTMLElement) {
9453 return query;
9454 }
9455 if (isHtmlString(query)) {
9456 var tpl = document.createElement('template');
9457 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9458 return tpl.content.firstChild;
9459 }
9460 return document.querySelector(query);
9461 };
9462 const isHtmlString = arg => {
9463 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9464 return true;
9465 }
9466 return false;
9467 };
9468
9469 /**
9470 * Set attributes of an element
9471 *
9472 */
9473 const setAttr = (el, attrs) => {
9474 iterate(attrs, (val, attr) => {
9475 if (val == null) {
9476 el.removeAttribute(attr);
9477 } else {
9478 el.setAttribute(attr, '' + val);
9479 }
9480 });
9481 };
9482
9483 /**
9484 * Plugin: "drag_drop" (Tom Select)
9485 * Copyright (c) contributors
9486 *
9487 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9488 * file except in compliance with the License. You may obtain a copy of the License at:
9489 * http://www.apache.org/licenses/LICENSE-2.0
9490 *
9491 * Unless required by applicable law or agreed to in writing, software distributed under
9492 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9493 * ANY KIND, either express or implied. See the License for the specific language
9494 * governing permissions and limitations under the License.
9495 *
9496 */
9497
9498 const insertAfter = (referenceNode, newNode) => {
9499 var _referenceNode$parent;
9500 (_referenceNode$parent = referenceNode.parentNode) == null || _referenceNode$parent.insertBefore(newNode, referenceNode.nextSibling);
9501 };
9502 const insertBefore = (referenceNode, newNode) => {
9503 var _referenceNode$parent2;
9504 (_referenceNode$parent2 = referenceNode.parentNode) == null || _referenceNode$parent2.insertBefore(newNode, referenceNode);
9505 };
9506 const isBefore = (referenceNode, newNode) => {
9507 do {
9508 var _newNode;
9509 newNode = (_newNode = newNode) == null ? void 0 : _newNode.previousElementSibling;
9510 if (referenceNode == newNode) {
9511 return true;
9512 }
9513 } while (newNode && newNode.previousElementSibling);
9514 return false;
9515 };
9516 function plugin () {
9517 var self = this;
9518 if (self.settings.mode !== 'multi') return;
9519 var orig_lock = self.lock;
9520 var orig_unlock = self.unlock;
9521 let sortable = true;
9522 let drag_item;
9523
9524 /**
9525 * Add draggable attribute to item
9526 */
9527 self.hook('after', 'setupTemplates', () => {
9528 var orig_render_item = self.settings.render.item;
9529 self.settings.render.item = (data, escape) => {
9530 const item = getDom(orig_render_item.call(self, data, escape));
9531 setAttr(item, {
9532 'draggable': 'true'
9533 });
9534
9535 // prevent doc_mousedown (see tom-select.ts)
9536 const mousedown = evt => {
9537 if (!sortable) preventDefault(evt);
9538 evt.stopPropagation();
9539 };
9540 const dragStart = evt => {
9541 drag_item = item;
9542 setTimeout(() => {
9543 item.classList.add('ts-dragging');
9544 }, 0);
9545 };
9546 const dragOver = evt => {
9547 evt.preventDefault();
9548 item.classList.add('ts-drag-over');
9549 moveitem(item, drag_item);
9550 };
9551 const dragLeave = () => {
9552 item.classList.remove('ts-drag-over');
9553 };
9554 const moveitem = (targetitem, dragitem) => {
9555 if (dragitem === undefined) return;
9556 if (isBefore(dragitem, item)) {
9557 insertAfter(targetitem, dragitem);
9558 } else {
9559 insertBefore(targetitem, dragitem);
9560 }
9561 };
9562 const dragend = () => {
9563 var _drag_item;
9564 document.querySelectorAll('.ts-drag-over').forEach(el => el.classList.remove('ts-drag-over'));
9565 (_drag_item = drag_item) == null || _drag_item.classList.remove('ts-dragging');
9566 drag_item = undefined;
9567 var values = [];
9568 self.control.querySelectorAll(`[data-value]`).forEach(el => {
9569 if (el.dataset.value) {
9570 let value = el.dataset.value;
9571 if (value) {
9572 values.push(value);
9573 }
9574 }
9575 });
9576 self.setValue(values);
9577 };
9578 addEvent(item, 'mousedown', mousedown);
9579 addEvent(item, 'dragstart', dragStart);
9580 addEvent(item, 'dragenter', dragOver);
9581 addEvent(item, 'dragover', dragOver);
9582 addEvent(item, 'dragleave', dragLeave);
9583 addEvent(item, 'dragend', dragend);
9584 return item;
9585 };
9586 });
9587 self.hook('instead', 'lock', () => {
9588 sortable = false;
9589 return orig_lock.call(self);
9590 });
9591 self.hook('instead', 'unlock', () => {
9592 sortable = true;
9593 return orig_unlock.call(self);
9594 });
9595 }
9596
9597
9598 //# sourceMappingURL=plugin.js.map
9599
9600
9601 /***/ },
9602
9603 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js"
9604 /*!****************************************************************************!*\
9605 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_header/plugin.js ***!
9606 \****************************************************************************/
9607 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9608
9609 "use strict";
9610 __webpack_require__.r(__webpack_exports__);
9611 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9612 /* harmony export */ "default": () => (/* binding */ plugin)
9613 /* harmony export */ });
9614 /**
9615 * Tom Select v2.6.2
9616 * Licensed under the Apache License, Version 2.0 (the "License");
9617 */
9618
9619 /**
9620 * Converts a scalar to its best string representation
9621 * for hash keys and HTML attribute values.
9622 *
9623 * Transformations:
9624 * 'str' -> 'str'
9625 * null -> ''
9626 * undefined -> ''
9627 * true -> '1'
9628 * false -> '0'
9629 * 0 -> '0'
9630 * 1 -> '1'
9631 *
9632 */
9633
9634 /**
9635 * Prevent default
9636 *
9637 */
9638 const preventDefault = (evt, stop = false) => {
9639 if (evt) {
9640 evt.preventDefault();
9641 if (stop) {
9642 evt.stopPropagation();
9643 }
9644 }
9645 };
9646
9647 /**
9648 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9649 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9650 *
9651 * param query should be {}
9652 */
9653 const getDom = query => {
9654 if (query.jquery) {
9655 return query[0];
9656 }
9657 if (query instanceof HTMLElement) {
9658 return query;
9659 }
9660 if (isHtmlString(query)) {
9661 var tpl = document.createElement('template');
9662 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9663 return tpl.content.firstChild;
9664 }
9665 return document.querySelector(query);
9666 };
9667 const isHtmlString = arg => {
9668 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9669 return true;
9670 }
9671 return false;
9672 };
9673
9674 /**
9675 * Plugin: "dropdown_header" (Tom Select)
9676 * Copyright (c) contributors
9677 *
9678 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9679 * file except in compliance with the License. You may obtain a copy of the License at:
9680 * http://www.apache.org/licenses/LICENSE-2.0
9681 *
9682 * Unless required by applicable law or agreed to in writing, software distributed under
9683 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9684 * ANY KIND, either express or implied. See the License for the specific language
9685 * governing permissions and limitations under the License.
9686 *
9687 */
9688
9689 function plugin (userOptions) {
9690 const self = this;
9691 const options = Object.assign({
9692 title: 'Untitled',
9693 headerClass: 'dropdown-header',
9694 titleRowClass: 'dropdown-header-title',
9695 labelClass: 'dropdown-header-label',
9696 closeClass: 'dropdown-header-close',
9697 html: data => {
9698 return '<div class="' + data.headerClass + '">' + '<div class="' + data.titleRowClass + '">' + '<span class="' + data.labelClass + '">' + data.title + '</span>' + '<a class="' + data.closeClass + '">&times;</a>' + '</div>' + '</div>';
9699 }
9700 }, userOptions);
9701 self.on('initialize', () => {
9702 var header = getDom(options.html(options));
9703 var close_link = header.querySelector('.' + options.closeClass);
9704 if (close_link) {
9705 close_link.addEventListener('click', evt => {
9706 preventDefault(evt, true);
9707 self.close();
9708 });
9709 }
9710 self.dropdown.insertBefore(header, self.dropdown.firstChild);
9711 });
9712 }
9713
9714
9715 //# sourceMappingURL=plugin.js.map
9716
9717
9718 /***/ },
9719
9720 /***/ "./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js"
9721 /*!***************************************************************************!*\
9722 !*** ./node_modules/tom-select/dist/esm/plugins/dropdown_input/plugin.js ***!
9723 \***************************************************************************/
9724 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9725
9726 "use strict";
9727 __webpack_require__.r(__webpack_exports__);
9728 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9729 /* harmony export */ "default": () => (/* binding */ plugin)
9730 /* harmony export */ });
9731 /**
9732 * Tom Select v2.6.2
9733 * Licensed under the Apache License, Version 2.0 (the "License");
9734 */
9735
9736 const KEY_ESC = 27;
9737 const KEY_TAB = 9;
9738 // ctrl key or apple key for ma
9739
9740 /**
9741 * Converts a scalar to its best string representation
9742 * for hash keys and HTML attribute values.
9743 *
9744 * Transformations:
9745 * 'str' -> 'str'
9746 * null -> ''
9747 * undefined -> ''
9748 * true -> '1'
9749 * false -> '0'
9750 * 0 -> '0'
9751 * 1 -> '1'
9752 *
9753 */
9754
9755 /**
9756 * Prevent default
9757 *
9758 */
9759 const preventDefault = (evt, stop = false) => {
9760 if (evt) {
9761 evt.preventDefault();
9762 if (stop) {
9763 evt.stopPropagation();
9764 }
9765 }
9766 };
9767
9768 /**
9769 * Add event helper
9770 *
9771 */
9772 const addEvent = (target, type, callback, options) => {
9773 target.addEventListener(type, callback, options);
9774 };
9775
9776 /**
9777 * Iterates over arrays and hashes.
9778 *
9779 * ```
9780 * iterate(this.items, function(item, id) {
9781 * // invoked for each item
9782 * });
9783 * ```
9784 *
9785 */
9786 const iterate = (object, callback) => {
9787 if (Array.isArray(object)) {
9788 object.forEach(callback);
9789 } else {
9790 for (var key in object) {
9791 if (object.hasOwnProperty(key)) {
9792 callback(object[key], key);
9793 }
9794 }
9795 }
9796 };
9797
9798 /**
9799 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
9800 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
9801 *
9802 * param query should be {}
9803 */
9804 const getDom = query => {
9805 if (query.jquery) {
9806 return query[0];
9807 }
9808 if (query instanceof HTMLElement) {
9809 return query;
9810 }
9811 if (isHtmlString(query)) {
9812 var tpl = document.createElement('template');
9813 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
9814 return tpl.content.firstChild;
9815 }
9816 return document.querySelector(query);
9817 };
9818 const isHtmlString = arg => {
9819 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
9820 return true;
9821 }
9822 return false;
9823 };
9824
9825 /**
9826 * Add css classes
9827 *
9828 */
9829 const addClasses = (elmts, ...classes) => {
9830 var norm_classes = classesArray(classes);
9831 elmts = castAsArray(elmts);
9832 elmts.map(el => {
9833 norm_classes.map(cls => {
9834 el.classList.add(cls);
9835 });
9836 });
9837 };
9838
9839 /**
9840 * Return arguments
9841 *
9842 */
9843 const classesArray = args => {
9844 var classes = [];
9845 iterate(args, _classes => {
9846 if (typeof _classes === 'string') {
9847 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
9848 }
9849 if (Array.isArray(_classes)) {
9850 classes = classes.concat(_classes);
9851 }
9852 });
9853 return classes.filter(Boolean);
9854 };
9855
9856 /**
9857 * Create an array from arg if it's not already an array
9858 *
9859 */
9860 const castAsArray = arg => {
9861 if (!Array.isArray(arg)) {
9862 arg = [arg];
9863 }
9864 return arg;
9865 };
9866
9867 /**
9868 * Plugin: "dropdown_input" (Tom Select)
9869 * Copyright (c) contributors
9870 *
9871 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
9872 * file except in compliance with the License. You may obtain a copy of the License at:
9873 * http://www.apache.org/licenses/LICENSE-2.0
9874 *
9875 * Unless required by applicable law or agreed to in writing, software distributed under
9876 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
9877 * ANY KIND, either express or implied. See the License for the specific language
9878 * governing permissions and limitations under the License.
9879 *
9880 */
9881
9882 function plugin () {
9883 const self = this;
9884 self.settings.shouldOpen = true; // make sure the input is shown even if there are no options to display in the dropdown
9885
9886 self.hook('before', 'setup', () => {
9887 var _self$input;
9888 self.focus_node = self.control;
9889 addClasses(self.control_input, 'dropdown-input');
9890 const div = getDom('<div class="dropdown-input-wrap">');
9891 div.append(self.control_input);
9892 self.dropdown.insertBefore(div, self.dropdown.firstChild);
9893
9894 // set a placeholder in the select control
9895 const placeholder = getDom('<input class="items-placeholder" tabindex="-1" />');
9896 placeholder.placeholder = self.settings.placeholder || '';
9897 self.control.append(placeholder);
9898 /**
9899 * TomSelect renders a custom control with a focusable <input class="items-placeholder">.
9900 * The source <select>'s aria-label is not automatically propagated to that input,
9901 * which triggers "Missing form label" accessibility warnings.
9902 * This helper copies the label from the <select> onto the generated input.
9903 */
9904 const label = (_self$input = self.input) == null ? void 0 : _self$input.getAttribute('aria-label');
9905 if (!label) return;
9906 placeholder.setAttribute('aria-label', label);
9907 });
9908 self.on('initialize', () => {
9909 // set tabIndex on control to -1, otherwise [shift+tab] will put focus right back on control_input
9910 self.control_input.addEventListener('keydown', evt => {
9911 //addEvent(self.control_input,'keydown' as const,(evt:KeyboardEvent) =>{
9912 switch (evt.keyCode) {
9913 case KEY_ESC:
9914 if (self.isOpen) {
9915 preventDefault(evt, true);
9916 self.close();
9917 }
9918 self.clearActiveItems();
9919 return;
9920 case KEY_TAB:
9921 self.focus_node.tabIndex = -1;
9922 break;
9923 }
9924 return self.onKeyDown.call(self, evt);
9925 });
9926 self.on('blur', () => {
9927 self.focus_node.tabIndex = self.isDisabled ? -1 : self.tabIndex;
9928 });
9929
9930 // give the control_input focus when the dropdown is open
9931 self.on('dropdown_open', () => {
9932 self.control_input.focus();
9933 });
9934
9935 // prevent onBlur from closing when focus is on the control_input
9936 const orig_onBlur = self.onBlur;
9937 self.hook('instead', 'onBlur', evt => {
9938 if (evt && evt.relatedTarget == self.control_input) return;
9939 return orig_onBlur.call(self);
9940 });
9941 addEvent(self.control_input, 'blur', () => self.onBlur());
9942
9943 // return focus to control to allow further keyboard input
9944 self.hook('before', 'close', () => {
9945 if (!self.isOpen) return;
9946 self.focus_node.focus({
9947 preventScroll: true
9948 });
9949 });
9950 });
9951 }
9952
9953
9954 //# sourceMappingURL=plugin.js.map
9955
9956
9957 /***/ },
9958
9959 /***/ "./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js"
9960 /*!***************************************************************************!*\
9961 !*** ./node_modules/tom-select/dist/esm/plugins/input_autogrow/plugin.js ***!
9962 \***************************************************************************/
9963 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
9964
9965 "use strict";
9966 __webpack_require__.r(__webpack_exports__);
9967 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
9968 /* harmony export */ "default": () => (/* binding */ plugin)
9969 /* harmony export */ });
9970 /**
9971 * Tom Select v2.6.2
9972 * Licensed under the Apache License, Version 2.0 (the "License");
9973 */
9974
9975 /**
9976 * Converts a scalar to its best string representation
9977 * for hash keys and HTML attribute values.
9978 *
9979 * Transformations:
9980 * 'str' -> 'str'
9981 * null -> ''
9982 * undefined -> ''
9983 * true -> '1'
9984 * false -> '0'
9985 * 0 -> '0'
9986 * 1 -> '1'
9987 *
9988 */
9989
9990 /**
9991 * Add event helper
9992 *
9993 */
9994 const addEvent = (target, type, callback, options) => {
9995 target.addEventListener(type, callback, options);
9996 };
9997
9998 /**
9999 * Plugin: "input_autogrow" (Tom Select)
10000 *
10001 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10002 * file except in compliance with the License. You may obtain a copy of the License at:
10003 * http://www.apache.org/licenses/LICENSE-2.0
10004 *
10005 * Unless required by applicable law or agreed to in writing, software distributed under
10006 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10007 * ANY KIND, either express or implied. See the License for the specific language
10008 * governing permissions and limitations under the License.
10009 *
10010 */
10011
10012 function plugin () {
10013 var self = this;
10014 self.on('initialize', () => {
10015 var test_input = document.createElement('span');
10016 var control = self.control_input;
10017 test_input.style.cssText = 'position:absolute; top:-99999px; left:-99999px; width:auto; padding:0; white-space:pre; ';
10018 self.wrapper.appendChild(test_input);
10019 var transfer_styles = ['letterSpacing', 'fontSize', 'fontFamily', 'fontWeight', 'textTransform'];
10020 for (const style_name of transfer_styles) {
10021 // @ts-ignore TS7015 https://stackoverflow.com/a/50506154/697576
10022 test_input.style[style_name] = control.style[style_name];
10023 }
10024
10025 /**
10026 * Set the control width
10027 *
10028 */
10029 var resize = () => {
10030 test_input.textContent = control.value;
10031 control.style.width = test_input.clientWidth + 'px';
10032 };
10033 resize();
10034 self.on('update item_add item_remove', resize);
10035 addEvent(control, 'input', resize);
10036 addEvent(control, 'keyup', resize);
10037 addEvent(control, 'blur', resize);
10038 addEvent(control, 'update', resize);
10039 });
10040 }
10041
10042
10043 //# sourceMappingURL=plugin.js.map
10044
10045
10046 /***/ },
10047
10048 /***/ "./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js"
10049 /*!****************************************************************************!*\
10050 !*** ./node_modules/tom-select/dist/esm/plugins/no_active_items/plugin.js ***!
10051 \****************************************************************************/
10052 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10053
10054 "use strict";
10055 __webpack_require__.r(__webpack_exports__);
10056 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10057 /* harmony export */ "default": () => (/* binding */ plugin)
10058 /* harmony export */ });
10059 /**
10060 * Tom Select v2.6.2
10061 * Licensed under the Apache License, Version 2.0 (the "License");
10062 */
10063
10064 /**
10065 * Plugin: "no_active_items" (Tom Select)
10066 *
10067 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10068 * file except in compliance with the License. You may obtain a copy of the License at:
10069 * http://www.apache.org/licenses/LICENSE-2.0
10070 *
10071 * Unless required by applicable law or agreed to in writing, software distributed under
10072 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10073 * ANY KIND, either express or implied. See the License for the specific language
10074 * governing permissions and limitations under the License.
10075 *
10076 */
10077
10078 function plugin () {
10079 this.hook('instead', 'setActiveItem', () => {});
10080 this.hook('instead', 'selectAll', () => {});
10081 }
10082
10083
10084 //# sourceMappingURL=plugin.js.map
10085
10086
10087 /***/ },
10088
10089 /***/ "./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js"
10090 /*!********************************************************************************!*\
10091 !*** ./node_modules/tom-select/dist/esm/plugins/no_backspace_delete/plugin.js ***!
10092 \********************************************************************************/
10093 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10094
10095 "use strict";
10096 __webpack_require__.r(__webpack_exports__);
10097 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10098 /* harmony export */ "default": () => (/* binding */ plugin)
10099 /* harmony export */ });
10100 /**
10101 * Tom Select v2.6.2
10102 * Licensed under the Apache License, Version 2.0 (the "License");
10103 */
10104
10105 /**
10106 * Plugin: "input_autogrow" (Tom Select)
10107 *
10108 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10109 * file except in compliance with the License. You may obtain a copy of the License at:
10110 * http://www.apache.org/licenses/LICENSE-2.0
10111 *
10112 * Unless required by applicable law or agreed to in writing, software distributed under
10113 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10114 * ANY KIND, either express or implied. See the License for the specific language
10115 * governing permissions and limitations under the License.
10116 *
10117 */
10118
10119 function plugin () {
10120 var self = this;
10121 var orig_deleteSelection = self.deleteSelection;
10122 this.hook('instead', 'deleteSelection', evt => {
10123 if (self.activeItems.length) {
10124 return orig_deleteSelection.call(self, evt);
10125 }
10126 return false;
10127 });
10128 }
10129
10130
10131 //# sourceMappingURL=plugin.js.map
10132
10133
10134 /***/ },
10135
10136 /***/ "./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js"
10137 /*!*****************************************************************************!*\
10138 !*** ./node_modules/tom-select/dist/esm/plugins/optgroup_columns/plugin.js ***!
10139 \*****************************************************************************/
10140 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10141
10142 "use strict";
10143 __webpack_require__.r(__webpack_exports__);
10144 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10145 /* harmony export */ "default": () => (/* binding */ plugin)
10146 /* harmony export */ });
10147 /**
10148 * Tom Select v2.6.2
10149 * Licensed under the Apache License, Version 2.0 (the "License");
10150 */
10151
10152 const KEY_LEFT = 37;
10153 const KEY_RIGHT = 39;
10154 // ctrl key or apple key for ma
10155
10156 /**
10157 * Get the closest node to the evt.target matching the selector
10158 * Stops at wrapper
10159 *
10160 */
10161 const parentMatch = (target, selector, wrapper) => {
10162 while (target && target.matches) {
10163 if (target.matches(selector)) {
10164 return target;
10165 }
10166 target = target.parentNode;
10167 }
10168 };
10169
10170 /**
10171 * Get the index of an element amongst sibling nodes of the same type
10172 *
10173 */
10174 const nodeIndex = (el, amongst) => {
10175 if (!el) return -1;
10176 amongst = amongst || el.nodeName;
10177 var i = 0;
10178 while (el = el.previousElementSibling) {
10179 if (el.matches(amongst)) {
10180 i++;
10181 }
10182 }
10183 return i;
10184 };
10185
10186 /**
10187 * Plugin: "optgroup_columns" (Tom Select.js)
10188 * Copyright (c) contributors
10189 *
10190 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10191 * file except in compliance with the License. You may obtain a copy of the License at:
10192 * http://www.apache.org/licenses/LICENSE-2.0
10193 *
10194 * Unless required by applicable law or agreed to in writing, software distributed under
10195 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10196 * ANY KIND, either express or implied. See the License for the specific language
10197 * governing permissions and limitations under the License.
10198 *
10199 */
10200
10201 function plugin () {
10202 var self = this;
10203 var orig_keydown = self.onKeyDown;
10204 self.hook('instead', 'onKeyDown', evt => {
10205 var index, option, options, optgroup;
10206 if (!self.isOpen || !(evt.keyCode === KEY_LEFT || evt.keyCode === KEY_RIGHT)) {
10207 return orig_keydown.call(self, evt);
10208 }
10209 self.ignoreHover = true;
10210 optgroup = parentMatch(self.activeOption, '[data-group]');
10211 index = nodeIndex(self.activeOption, '[data-selectable]');
10212 if (!optgroup) {
10213 return;
10214 }
10215 if (evt.keyCode === KEY_LEFT) {
10216 optgroup = optgroup.previousSibling;
10217 } else {
10218 optgroup = optgroup.nextSibling;
10219 }
10220 if (!optgroup) {
10221 return;
10222 }
10223 options = optgroup.querySelectorAll('[data-selectable]');
10224 option = options[Math.min(options.length - 1, index)];
10225 if (option) {
10226 self.setActiveOption(option);
10227 }
10228 });
10229 }
10230
10231
10232 //# sourceMappingURL=plugin.js.map
10233
10234
10235 /***/ },
10236
10237 /***/ "./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js"
10238 /*!**************************************************************************!*\
10239 !*** ./node_modules/tom-select/dist/esm/plugins/remove_button/plugin.js ***!
10240 \**************************************************************************/
10241 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10242
10243 "use strict";
10244 __webpack_require__.r(__webpack_exports__);
10245 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10246 /* harmony export */ "default": () => (/* binding */ plugin)
10247 /* harmony export */ });
10248 /**
10249 * Tom Select v2.6.2
10250 * Licensed under the Apache License, Version 2.0 (the "License");
10251 */
10252
10253 /**
10254 * Converts a scalar to its best string representation
10255 * for hash keys and HTML attribute values.
10256 *
10257 * Transformations:
10258 * 'str' -> 'str'
10259 * null -> ''
10260 * undefined -> ''
10261 * true -> '1'
10262 * false -> '0'
10263 * 0 -> '0'
10264 * 1 -> '1'
10265 *
10266 */
10267
10268 /**
10269 * Prevent default
10270 *
10271 */
10272 const preventDefault = (evt, stop = false) => {
10273 if (evt) {
10274 evt.preventDefault();
10275 if (stop) {
10276 evt.stopPropagation();
10277 }
10278 }
10279 };
10280
10281 /**
10282 * Add event helper
10283 *
10284 */
10285 const addEvent = (target, type, callback, options) => {
10286 target.addEventListener(type, callback, options);
10287 };
10288
10289 /**
10290 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
10291 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
10292 *
10293 * param query should be {}
10294 */
10295 const getDom = query => {
10296 if (query.jquery) {
10297 return query[0];
10298 }
10299 if (query instanceof HTMLElement) {
10300 return query;
10301 }
10302 if (isHtmlString(query)) {
10303 var tpl = document.createElement('template');
10304 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
10305 return tpl.content.firstChild;
10306 }
10307 return document.querySelector(query);
10308 };
10309 const isHtmlString = arg => {
10310 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
10311 return true;
10312 }
10313 return false;
10314 };
10315
10316 /**
10317 * Plugin: "remove_button" (Tom Select)
10318 * Copyright (c) contributors
10319 *
10320 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10321 * file except in compliance with the License. You may obtain a copy of the License at:
10322 * http://www.apache.org/licenses/LICENSE-2.0
10323 *
10324 * Unless required by applicable law or agreed to in writing, software distributed under
10325 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10326 * ANY KIND, either express or implied. See the License for the specific language
10327 * governing permissions and limitations under the License.
10328 *
10329 */
10330
10331 function plugin (userOptions) {
10332 const self = this;
10333 const options = Object.assign({
10334 label: '×',
10335 title: 'Remove',
10336 className: 'remove',
10337 tabindex: -1,
10338 role: 'button',
10339 html: data => {
10340 var _data$tabindex;
10341 const el = document.createElement('div');
10342 el.className = data.className || '';
10343 el.title = data.title || '';
10344 el.setAttribute('role', data.role || 'button');
10345 el.tabIndex = (_data$tabindex = data.tabindex) != null ? _data$tabindex : -1;
10346 el.textContent = data.label || '';
10347 return el;
10348 }
10349 }, userOptions);
10350 self.hook('after', 'setupTemplates', () => {
10351 var orig_render_item = self.settings.render.item;
10352 self.settings.render.item = (data, escape) => {
10353 var item = getDom(orig_render_item.call(self, data, escape));
10354 var close_button = getDom(options.html(options));
10355 item.appendChild(close_button);
10356 addEvent(close_button, 'mousedown', evt => {
10357 preventDefault(evt, true);
10358 });
10359 addEvent(close_button, 'click', evt => {
10360 if (self.isLocked) return;
10361
10362 // propagating will trigger the dropdown to show for single mode
10363 preventDefault(evt, true);
10364 if (self.isLocked) return;
10365 if (!self.shouldDelete([item], evt)) return;
10366 self.removeItem(item);
10367 self.refreshOptions(false);
10368 self.inputState();
10369 });
10370 return item;
10371 };
10372 });
10373 }
10374
10375
10376 //# sourceMappingURL=plugin.js.map
10377
10378
10379 /***/ },
10380
10381 /***/ "./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js"
10382 /*!*********************************************************************************!*\
10383 !*** ./node_modules/tom-select/dist/esm/plugins/restore_on_backspace/plugin.js ***!
10384 \*********************************************************************************/
10385 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10386
10387 "use strict";
10388 __webpack_require__.r(__webpack_exports__);
10389 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10390 /* harmony export */ "default": () => (/* binding */ plugin)
10391 /* harmony export */ });
10392 /**
10393 * Tom Select v2.6.2
10394 * Licensed under the Apache License, Version 2.0 (the "License");
10395 */
10396
10397 /**
10398 * Plugin: "restore_on_backspace" (Tom Select)
10399 * Copyright (c) contributors
10400 *
10401 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10402 * file except in compliance with the License. You may obtain a copy of the License at:
10403 * http://www.apache.org/licenses/LICENSE-2.0
10404 *
10405 * Unless required by applicable law or agreed to in writing, software distributed under
10406 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10407 * ANY KIND, either express or implied. See the License for the specific language
10408 * governing permissions and limitations under the License.
10409 *
10410 */
10411
10412 function plugin (userOptions) {
10413 const self = this;
10414 const options = Object.assign({
10415 text: option => {
10416 return option[self.settings.labelField];
10417 }
10418 }, userOptions);
10419 self.on('item_remove', function (value) {
10420 if (!self.isFocused) {
10421 return;
10422 }
10423 if (self.control_input.value.trim() === '') {
10424 var option = self.options[value];
10425 if (option) {
10426 self.setTextboxValue(options.text.call(self, option));
10427 }
10428 }
10429 });
10430 }
10431
10432
10433 //# sourceMappingURL=plugin.js.map
10434
10435
10436 /***/ },
10437
10438 /***/ "./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js"
10439 /*!***************************************************************************!*\
10440 !*** ./node_modules/tom-select/dist/esm/plugins/virtual_scroll/plugin.js ***!
10441 \***************************************************************************/
10442 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10443
10444 "use strict";
10445 __webpack_require__.r(__webpack_exports__);
10446 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10447 /* harmony export */ "default": () => (/* binding */ plugin)
10448 /* harmony export */ });
10449 /**
10450 * Tom Select v2.6.2
10451 * Licensed under the Apache License, Version 2.0 (the "License");
10452 */
10453
10454 /**
10455 * Converts a scalar to its best string representation
10456 * for hash keys and HTML attribute values.
10457 *
10458 * Transformations:
10459 * 'str' -> 'str'
10460 * null -> ''
10461 * undefined -> ''
10462 * true -> '1'
10463 * false -> '0'
10464 * 0 -> '0'
10465 * 1 -> '1'
10466 *
10467 */
10468
10469 /**
10470 * Iterates over arrays and hashes.
10471 *
10472 * ```
10473 * iterate(this.items, function(item, id) {
10474 * // invoked for each item
10475 * });
10476 * ```
10477 *
10478 */
10479 const iterate = (object, callback) => {
10480 if (Array.isArray(object)) {
10481 object.forEach(callback);
10482 } else {
10483 for (var key in object) {
10484 if (object.hasOwnProperty(key)) {
10485 callback(object[key], key);
10486 }
10487 }
10488 }
10489 };
10490
10491 /**
10492 * Add css classes
10493 *
10494 */
10495 const addClasses = (elmts, ...classes) => {
10496 var norm_classes = classesArray(classes);
10497 elmts = castAsArray(elmts);
10498 elmts.map(el => {
10499 norm_classes.map(cls => {
10500 el.classList.add(cls);
10501 });
10502 });
10503 };
10504
10505 /**
10506 * Return arguments
10507 *
10508 */
10509 const classesArray = args => {
10510 var classes = [];
10511 iterate(args, _classes => {
10512 if (typeof _classes === 'string') {
10513 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
10514 }
10515 if (Array.isArray(_classes)) {
10516 classes = classes.concat(_classes);
10517 }
10518 });
10519 return classes.filter(Boolean);
10520 };
10521
10522 /**
10523 * Create an array from arg if it's not already an array
10524 *
10525 */
10526 const castAsArray = arg => {
10527 if (!Array.isArray(arg)) {
10528 arg = [arg];
10529 }
10530 return arg;
10531 };
10532
10533 /**
10534 * Plugin: "virtual_scroll" (Tom Select)
10535 * Copyright (c) contributors
10536 *
10537 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
10538 * file except in compliance with the License. You may obtain a copy of the License at:
10539 * http://www.apache.org/licenses/LICENSE-2.0
10540 *
10541 * Unless required by applicable law or agreed to in writing, software distributed under
10542 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
10543 * ANY KIND, either express or implied. See the License for the specific language
10544 * governing permissions and limitations under the License.
10545 *
10546 */
10547
10548 function plugin () {
10549 const self = this;
10550 const orig_canLoad = self.canLoad;
10551 const orig_clearActiveOption = self.clearActiveOption;
10552 const orig_loadCallback = self.loadCallback;
10553 var pagination = {};
10554 var dropdown_content;
10555 var loading_more = false;
10556 var load_more_opt;
10557 var default_values = [];
10558 var default_values_loaded = false;
10559 var default_pagination;
10560 var default_options = [];
10561 var html_values = [];
10562 if (!self.settings.shouldLoadMore) {
10563 // return true if additional results should be loaded
10564 self.settings.shouldLoadMore = () => {
10565 const scroll_percent = dropdown_content.clientHeight / (dropdown_content.scrollHeight - dropdown_content.scrollTop);
10566 if (scroll_percent > 0.9) {
10567 return true;
10568 }
10569 if (self.activeOption) {
10570 var selectable = self.selectable();
10571 var index = Array.from(selectable).indexOf(self.activeOption);
10572 if (index >= selectable.length - 2) {
10573 return true;
10574 }
10575 }
10576 return false;
10577 };
10578 }
10579 if (!self.settings.firstUrl) {
10580 throw 'virtual_scroll plugin requires a firstUrl() method';
10581 }
10582
10583 // in order for virtual scrolling to work,
10584 // options need to be ordered the same way they're returned from the remote data source
10585 self.settings.sortField = [{
10586 field: '$order'
10587 }, {
10588 field: '$score'
10589 }];
10590
10591 // can we load more results for given query?
10592 const canLoadMore = query => {
10593 if (self.settings.maxOptions !== null && typeof self.settings.maxOptions === 'number' && dropdown_content.children.length >= self.settings.maxOptions) {
10594 return false;
10595 }
10596 if (query in pagination && pagination[query]) {
10597 return true;
10598 }
10599 return false;
10600 };
10601 const clearFilter = (option, value) => {
10602 if (self.items.indexOf(value) >= 0 || default_values.indexOf(value) >= 0) {
10603 return true;
10604 }
10605 return false;
10606 };
10607
10608 // set the next url that will be
10609 self.setNextUrl = (value, next_url) => {
10610 pagination[value] = next_url;
10611 };
10612
10613 // getUrl() to be used in settings.load()
10614 self.getUrl = query => {
10615 if (query in pagination) {
10616 const next_url = pagination[query];
10617 pagination[query] = false;
10618 return next_url;
10619 }
10620
10621 // if the user goes back to a previous query
10622 // we need to load the first page again
10623 self.clearPagination();
10624 return self.settings.firstUrl.call(self, query);
10625 };
10626
10627 // clear pagination
10628 self.clearPagination = () => {
10629 pagination = {};
10630 };
10631
10632 // don't clear the active option (and cause unwanted dropdown scroll)
10633 // while loading more results
10634 self.hook('instead', 'clearActiveOption', () => {
10635 if (loading_more) {
10636 return;
10637 }
10638 return orig_clearActiveOption.call(self);
10639 });
10640
10641 // override the canLoad method
10642 self.hook('instead', 'canLoad', query => {
10643 // first time the query has been seen
10644 if (!(query in pagination)) {
10645 return orig_canLoad.call(self, query);
10646 }
10647 return canLoadMore(query);
10648 });
10649
10650 // wrap the load
10651 self.hook('instead', 'loadCallback', (options, optgroups) => {
10652 if (!loading_more) {
10653 // When searching (non-empty query), keep selected items and HTML default options,
10654 // but remove preloaded remote options so they don't bleed into search results.
10655 // For empty query, use clearFilter (keeps default_values + items).
10656 const activeFilter = self.lastValue !== '' ? (_option, value) => self.items.indexOf(value) >= 0 || html_values.indexOf(value) >= 0 : clearFilter;
10657 self.clearOptions(activeFilter);
10658 } else if (load_more_opt) {
10659 const first_option = options[0];
10660 if (first_option !== undefined) {
10661 load_more_opt.dataset.value = first_option[self.settings.valueField];
10662 }
10663 }
10664 orig_loadCallback.call(self, options, optgroups);
10665
10666 // After the initial preload (empty query), snapshot default_values and option objects
10667 // so they can be restored when the user clears their search.
10668 if (!loading_more && !default_values_loaded) {
10669 default_values_loaded = true;
10670 if (self.lastValue === '') {
10671 default_values = Object.keys(self.options);
10672 default_pagination = pagination[''];
10673 default_options = Object.values(self.options);
10674 }
10675 }
10676 loading_more = false;
10677 });
10678
10679 // as the “loading_more” element will be removed from the dropdown,
10680 // we activate the previous option if needed
10681 // to avoid the dropdown being scrolled back to the first one
10682 self.hook('before', 'refreshOptions', () => {
10683 if (self.activeOption && "option" !== self.activeOption.getAttribute("role")) {
10684 self.setActiveOption(self.activeOption.previousElementSibling);
10685 }
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 // Restore preloaded options and pagination when clearing search
10714 const restoreDefaults = () => {
10715 if (!default_values_loaded) {
10716 return;
10717 }
10718 // Re-add preloaded option objects (clearOptions can only remove, not restore)
10719 self.addOptions(default_options);
10720 // Remove any search results that are not part of the preloaded defaults
10721 self.clearOptions(clearFilter);
10722 if (default_pagination) {
10723 pagination[''] = default_pagination;
10724 }
10725 };
10726 self.on('type', query => {
10727 if (query === '') {
10728 restoreDefaults();
10729 self.refreshOptions(false);
10730 }
10731 });
10732 self.on('dropdown_close', restoreDefaults);
10733
10734 // add scroll listener and default templates
10735 self.on('initialize', () => {
10736 html_values = Object.keys(self.options);
10737 default_values = Object.keys(self.options);
10738 dropdown_content = self.dropdown_content;
10739
10740 // default templates
10741 self.settings.render = Object.assign({}, {
10742 loading_more: () => {
10743 return `<div class="loading-more-results">Loading more results ... </div>`;
10744 },
10745 no_more_results: () => {
10746 return `<div class="no-more-results">No more results</div>`;
10747 }
10748 }, self.settings.render);
10749
10750 // watch dropdown content scroll position
10751 dropdown_content.addEventListener('scroll', () => {
10752 if (!self.settings.shouldLoadMore.call(self)) {
10753 return;
10754 }
10755
10756 // !important: this will get checked again in load() but we still need to check here otherwise loading_more will be set to true
10757 if (!canLoadMore(self.lastValue)) {
10758 return;
10759 }
10760
10761 // don't call load() too much
10762 if (loading_more) return;
10763 loading_more = true;
10764 self.load.call(self, self.lastValue);
10765 });
10766 });
10767 }
10768
10769
10770 //# sourceMappingURL=plugin.js.map
10771
10772
10773 /***/ },
10774
10775 /***/ "./node_modules/tom-select/dist/esm/tom-select.complete.js"
10776 /*!*****************************************************************!*\
10777 !*** ./node_modules/tom-select/dist/esm/tom-select.complete.js ***!
10778 \*****************************************************************/
10779 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10780
10781 "use strict";
10782 __webpack_require__.r(__webpack_exports__);
10783 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10784 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
10785 /* harmony export */ });
10786 /* harmony import */ var _tom_select_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tom-select.js */ "./node_modules/tom-select/dist/esm/tom-select.js");
10787 /* 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");
10788 /* 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");
10789 /* 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");
10790 /* 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");
10791 /* 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");
10792 /* 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");
10793 /* 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");
10794 /* 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");
10795 /* 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");
10796 /* 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");
10797 /* 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");
10798 /* 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");
10799 /* 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");
10800 /* 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");
10801
10802
10803
10804
10805
10806
10807
10808
10809
10810
10811
10812
10813
10814
10815
10816 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('change_listener', _plugins_change_listener_plugin_js__WEBPACK_IMPORTED_MODULE_1__["default"]);
10817 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('checkbox_options', _plugins_checkbox_options_plugin_js__WEBPACK_IMPORTED_MODULE_2__["default"]);
10818 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('clear_button', _plugins_clear_button_plugin_js__WEBPACK_IMPORTED_MODULE_3__["default"]);
10819 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('drag_drop', _plugins_drag_drop_plugin_js__WEBPACK_IMPORTED_MODULE_4__["default"]);
10820 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_header', _plugins_dropdown_header_plugin_js__WEBPACK_IMPORTED_MODULE_5__["default"]);
10821 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('caret_position', _plugins_caret_position_plugin_js__WEBPACK_IMPORTED_MODULE_6__["default"]);
10822 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('dropdown_input', _plugins_dropdown_input_plugin_js__WEBPACK_IMPORTED_MODULE_7__["default"]);
10823 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('input_autogrow', _plugins_input_autogrow_plugin_js__WEBPACK_IMPORTED_MODULE_8__["default"]);
10824 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_backspace_delete', _plugins_no_backspace_delete_plugin_js__WEBPACK_IMPORTED_MODULE_9__["default"]);
10825 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('no_active_items', _plugins_no_active_items_plugin_js__WEBPACK_IMPORTED_MODULE_10__["default"]);
10826 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('optgroup_columns', _plugins_optgroup_columns_plugin_js__WEBPACK_IMPORTED_MODULE_11__["default"]);
10827 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('remove_button', _plugins_remove_button_plugin_js__WEBPACK_IMPORTED_MODULE_12__["default"]);
10828 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('restore_on_backspace', _plugins_restore_on_backspace_plugin_js__WEBPACK_IMPORTED_MODULE_13__["default"]);
10829 _tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"].define('virtual_scroll', _plugins_virtual_scroll_plugin_js__WEBPACK_IMPORTED_MODULE_14__["default"]);
10830 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_tom_select_js__WEBPACK_IMPORTED_MODULE_0__["default"]);
10831 //# sourceMappingURL=tom-select.complete.js.map
10832
10833 /***/ },
10834
10835 /***/ "./node_modules/tom-select/dist/esm/tom-select.js"
10836 /*!********************************************************!*\
10837 !*** ./node_modules/tom-select/dist/esm/tom-select.js ***!
10838 \********************************************************/
10839 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
10840
10841 "use strict";
10842 __webpack_require__.r(__webpack_exports__);
10843 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
10844 /* harmony export */ "default": () => (/* binding */ TomSelect)
10845 /* harmony export */ });
10846 /* harmony import */ var _contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./contrib/microevent.js */ "./node_modules/tom-select/dist/esm/contrib/microevent.js");
10847 /* harmony import */ var _contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./contrib/microplugin.js */ "./node_modules/tom-select/dist/esm/contrib/microplugin.js");
10848 /* harmony import */ var _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @orchidjs/sifter */ "./node_modules/@orchidjs/sifter/dist/esm/sifter.js");
10849 /* harmony import */ var _orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @orchidjs/unicode-variants */ "./node_modules/@orchidjs/unicode-variants/dist/esm/index.js");
10850 /* harmony import */ var _contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./contrib/highlight.js */ "./node_modules/tom-select/dist/esm/contrib/highlight.js");
10851 /* harmony import */ var _constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants.js */ "./node_modules/tom-select/dist/esm/constants.js");
10852 /* harmony import */ var _getSettings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./getSettings.js */ "./node_modules/tom-select/dist/esm/getSettings.js");
10853 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
10854 /* harmony import */ var _vanilla_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./vanilla.js */ "./node_modules/tom-select/dist/esm/vanilla.js");
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864 var instance_i = 0;
10865 class TomSelect extends (0,_contrib_microplugin_js__WEBPACK_IMPORTED_MODULE_1__["default"])(_contrib_microevent_js__WEBPACK_IMPORTED_MODULE_0__["default"]) {
10866 constructor(input_arg, user_settings) {
10867 super();
10868 this.order = 0;
10869 this.isOpen = false;
10870 this.isDisabled = false;
10871 this.isReadOnly = false;
10872 this.isInvalid = false; // @deprecated 1.8
10873 this.isValid = true;
10874 this.isLocked = false;
10875 this.isFocused = false;
10876 this.isInputHidden = false;
10877 this.isSetup = false;
10878 this.isDropdownContentStale = true;
10879 this.ignoreFocus = false;
10880 this.ignoreHover = false;
10881 this.hasOptions = false;
10882 this.lastValue = '';
10883 this.caretPos = 0;
10884 this.loading = 0;
10885 this.loadedSearches = {};
10886 this.activeOption = null;
10887 this.activeItems = [];
10888 this.optgroups = {};
10889 this.options = {};
10890 this.userOptions = {};
10891 this.items = [];
10892 this.refreshTimeout = null;
10893 instance_i++;
10894 var dir;
10895 var input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(input_arg);
10896 if (input.tomselect) {
10897 throw new Error('Tom Select already initialized on this element');
10898 }
10899 input.tomselect = this;
10900 // detect rtl environment
10901 var computedStyle = window.getComputedStyle && window.getComputedStyle(input, null);
10902 dir = computedStyle.getPropertyValue('direction');
10903 // setup default state
10904 const settings = (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(input, user_settings);
10905 this.settings = settings;
10906 this.input = input;
10907 this.tabIndex = input.tabIndex || 0;
10908 this.is_select_tag = input.tagName.toLowerCase() === 'select';
10909 this.rtl = /rtl/i.test(dir);
10910 this.inputId = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(input, 'tomselect-' + instance_i);
10911 this.isRequired = input.required;
10912 // search system
10913 this.sifter = new _orchidjs_sifter__WEBPACK_IMPORTED_MODULE_2__.Sifter(this.options, { diacritics: settings.diacritics });
10914 // option-dependent defaults
10915 settings.mode = settings.mode || (settings.maxItems === 1 ? 'single' : 'multi');
10916 if (typeof settings.hideSelected !== 'boolean') {
10917 settings.hideSelected = settings.mode === 'multi';
10918 }
10919 if (typeof settings.hidePlaceholder !== 'boolean') {
10920 settings.hidePlaceholder = settings.mode !== 'multi';
10921 }
10922 // set up createFilter callback
10923 var filter = settings.createFilter;
10924 if (typeof filter !== 'function') {
10925 if (typeof filter === 'string') {
10926 filter = new RegExp(filter);
10927 }
10928 if (filter instanceof RegExp) {
10929 settings.createFilter = (input) => filter.test(input);
10930 }
10931 else {
10932 settings.createFilter = (value) => {
10933 return this.settings.duplicates || !this.options[value];
10934 };
10935 }
10936 }
10937 this.initializePlugins(settings.plugins);
10938 this.setupCallbacks();
10939 this.setupTemplates();
10940 // Create all elements
10941 const wrapper = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10942 const control = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<div>');
10943 const dropdown = this._render('dropdown');
10944 const dropdown_content = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(`<div role="listbox" tabindex="-1">`);
10945 const classes = this.input.getAttribute('class') || '';
10946 const inputMode = settings.mode;
10947 var control_input;
10948 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(wrapper, settings.wrapperClass, classes, inputMode);
10949 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(control, settings.controlClass);
10950 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(wrapper, control);
10951 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, settings.dropdownClass, inputMode);
10952 if (settings.copyClassesToDropdown) {
10953 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown, classes);
10954 }
10955 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(dropdown_content, settings.dropdownContentClass);
10956 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown, dropdown_content);
10957 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.dropdownParent || wrapper).appendChild(dropdown);
10958 // default controlInput
10959 if ((0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isHtmlString)(settings.controlInput)) {
10960 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10961 // set attributes
10962 var attrs = ['autocorrect', 'autocapitalize', 'autocomplete', 'spellcheck', 'aria-label'];
10963 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(attrs, (attr) => {
10964 if (input.getAttribute(attr)) {
10965 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { [attr]: input.getAttribute(attr) });
10966 }
10967 });
10968 control_input.tabIndex = -1;
10969 control.appendChild(control_input);
10970 this.focus_node = control_input;
10971 // dom element
10972 }
10973 else if (settings.controlInput) {
10974 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(settings.controlInput);
10975 this.focus_node = control_input;
10976 }
10977 else {
10978 control_input = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)('<input/>');
10979 this.focus_node = control;
10980 }
10981 this.wrapper = wrapper;
10982 this.dropdown = dropdown;
10983 this.dropdown_content = dropdown_content;
10984 this.control = control;
10985 this.control_input = control_input;
10986 this.setup();
10987 }
10988 /**
10989 * set up event bindings.
10990 *
10991 */
10992 setup() {
10993 const self = this;
10994 const settings = self.settings;
10995 const control_input = self.control_input;
10996 const dropdown = self.dropdown;
10997 const dropdown_content = self.dropdown_content;
10998 const wrapper = self.wrapper;
10999 const control = self.control;
11000 const input = self.input;
11001 const focus_node = self.focus_node;
11002 const passive_event = { passive: true };
11003 const listboxId = self.inputId + '-ts-dropdown';
11004 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, {
11005 id: listboxId
11006 });
11007 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, {
11008 role: 'combobox',
11009 'aria-haspopup': 'listbox',
11010 'aria-expanded': 'false',
11011 'aria-controls': listboxId
11012 });
11013 const control_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(focus_node, self.inputId + '-ts-control');
11014 const query = "label[for='" + (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.escapeQuery)(self.inputId) + "']";
11015 const label = document.querySelector(query);
11016 const label_click = self.focus.bind(self);
11017 if (label) {
11018 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(label, 'click', label_click);
11019 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(label, { for: control_id });
11020 const label_id = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getId)(label, self.inputId + '-ts-label');
11021 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(focus_node, { 'aria-labelledby': label_id });
11022 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(dropdown_content, { 'aria-labelledby': label_id });
11023 }
11024 wrapper.style.width = input.style.width;
11025 wrapper.style.minWidth = input.style.minWidth;
11026 wrapper.style.maxWidth = input.style.maxWidth;
11027 if (self.plugins.names.length) {
11028 const classes_plugins = 'plugin-' + self.plugins.names.join(' plugin-');
11029 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)([wrapper, dropdown], classes_plugins);
11030 }
11031 if ((settings.maxItems === null || settings.maxItems > 1) && self.is_select_tag) {
11032 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(input, { multiple: 'multiple' });
11033 }
11034 if (settings.placeholder) {
11035 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(control_input, { placeholder: settings.placeholder });
11036 }
11037 // if splitOn was not passed in, construct it from the delimiter to allow pasting universally
11038 if (!settings.splitOn && settings.delimiter) {
11039 settings.splitOn = new RegExp('\\s*' + (0,_orchidjs_unicode_variants__WEBPACK_IMPORTED_MODULE_3__.escape_regex)(settings.delimiter) + '+\\s*');
11040 }
11041 // debounce user defined load() if loadThrottle > 0
11042 // after initializePlugins() so plugins can create/modify user defined loaders
11043 if (settings.load && settings.loadThrottle) {
11044 settings.load = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.loadDebounce)(settings.load, settings.loadThrottle);
11045 }
11046 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mousemove', () => {
11047 self.ignoreHover = false;
11048 });
11049 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'mouseenter', (e) => {
11050 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(e.target, '[data-selectable]', dropdown);
11051 if (target_match)
11052 self.onOptionHover(e, target_match);
11053 }, { capture: true });
11054 // clicking on an option should select it
11055 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(dropdown, 'click', (evt) => {
11056 const option = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-selectable]');
11057 if (option) {
11058 self.onOptionSelect(evt, option);
11059 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11060 }
11061 });
11062 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control, 'click', (evt) => {
11063 var target_match = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.parentMatch)(evt.target, '[data-ts-item]', control);
11064 if (target_match && self.onItemSelect(evt, target_match)) {
11065 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11066 return;
11067 }
11068 // retain focus (see control_input mousedown)
11069 if (control_input.value != '') {
11070 return;
11071 }
11072 self.onClick();
11073 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11074 });
11075 // keydown on focus_node for arrow_down/arrow_up
11076 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'keydown', (e) => self.onKeyDown(e));
11077 // keypress and input/keyup
11078 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'keypress', (e) => self.onKeyPress(e));
11079 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'input', (e) => self.onInput(e));
11080 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'blur', (e) => self.onBlur(e));
11081 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(focus_node, 'focus', (e) => self.onFocus(e));
11082 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(control_input, 'paste', (e) => self.onPaste(e));
11083 const doc_mousedown = (evt) => {
11084 // blur if target is outside of this instance
11085 // dropdown is not always inside wrapper
11086 const target = evt.composedPath()[0];
11087 if (!wrapper.contains(target) && !dropdown.contains(target)) {
11088 if (self.isFocused) {
11089 self.blur();
11090 }
11091 self.inputState();
11092 return;
11093 }
11094 // retain focus by preventing native handling. if the
11095 // event target is the input it should not be modified.
11096 // otherwise, text selection within the input won't work.
11097 // Fixes bug #212 which is no covered by tests
11098 if (target == control_input && self.isOpen) {
11099 evt.stopPropagation();
11100 // clicking anywhere in the control should not blur the control_input (which would close the dropdown)
11101 }
11102 else {
11103 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt, true);
11104 }
11105 };
11106 const win_scroll = () => {
11107 if (self.isOpen) {
11108 self.positionDropdown();
11109 }
11110 };
11111 const input_invalid = () => {
11112 if (self.isValid) {
11113 self.isValid = false;
11114 self.isInvalid = true;
11115 self.refreshState();
11116 }
11117 };
11118 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(input, 'invalid', input_invalid);
11119 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(document, 'mousedown', doc_mousedown);
11120 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'scroll', win_scroll, passive_event);
11121 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addEvent)(window, 'resize', win_scroll, passive_event);
11122 this._destroy = () => {
11123 input.removeEventListener('invalid', input_invalid);
11124 document.removeEventListener('mousedown', doc_mousedown);
11125 window.removeEventListener('scroll', win_scroll);
11126 window.removeEventListener('resize', win_scroll);
11127 if (label)
11128 label.removeEventListener('click', label_click);
11129 };
11130 // store original html and tab index so that they can be
11131 // restored when the destroy() method is called.
11132 this.revertSettings = {
11133 innerHTML: input.innerHTML,
11134 tabIndex: input.tabIndex
11135 };
11136 input.tabIndex = -1;
11137 input.insertAdjacentElement('afterend', self.wrapper);
11138 self.sync(false);
11139 settings.items = [];
11140 delete settings.optgroups;
11141 delete settings.options;
11142 self.refreshItems();
11143 self.close(false);
11144 self.inputState();
11145 self.isSetup = true;
11146 self.on('change', this.onChange);
11147 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(input, 'tomselected', 'ts-hidden-accessible');
11148 self.trigger('initialize');
11149 // preload options
11150 if (settings.preload === true) {
11151 self.preload();
11152 }
11153 }
11154 /**
11155 * Register options and optgroups
11156 *
11157 */
11158 setupOptions(options = [], optgroups = []) {
11159 // build options table
11160 this.addOptions(options);
11161 // build optgroup table
11162 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(optgroups, (optgroup) => {
11163 this.registerOptionGroup(optgroup);
11164 });
11165 }
11166 /**
11167 * Sets up default rendering functions.
11168 */
11169 setupTemplates() {
11170 var self = this;
11171 var field_label = self.settings.labelField;
11172 var field_optgroup = self.settings.optgroupLabelField;
11173 var templates = {
11174 'optgroup': (data) => {
11175 let optgroup = document.createElement('div');
11176 optgroup.className = 'optgroup';
11177 optgroup.appendChild(data.options);
11178 return optgroup;
11179 },
11180 'optgroup_header': (data, escape) => {
11181 return '<div class="optgroup-header">' + escape(data[field_optgroup]) + '</div>';
11182 },
11183 'option': (data, escape) => {
11184 return '<div>' + escape(data[field_label]) + '</div>';
11185 },
11186 'item': (data, escape) => {
11187 return '<div>' + escape(data[field_label]) + '</div>';
11188 },
11189 'option_create': (data, escape) => {
11190 return '<div class="create">Add <strong>' + escape(data.input) + '</strong>&hellip;</div>';
11191 },
11192 'no_results': () => {
11193 return '<div class="no-results">No results found</div>';
11194 },
11195 'loading': () => {
11196 return '<div class="spinner"></div>';
11197 },
11198 'not_loading': () => { },
11199 'dropdown': () => {
11200 return '<div></div>';
11201 }
11202 };
11203 self.settings.render = Object.assign({}, templates, self.settings.render);
11204 }
11205 /**
11206 * Maps fired events to callbacks provided
11207 * in the settings used when creating the control.
11208 */
11209 setupCallbacks() {
11210 var key, fn;
11211 var callbacks = {
11212 'initialize': 'onInitialize',
11213 'change': 'onChange',
11214 'item_add': 'onItemAdd',
11215 'item_remove': 'onItemRemove',
11216 'item_select': 'onItemSelect',
11217 'clear': 'onClear',
11218 'option_add': 'onOptionAdd',
11219 'option_remove': 'onOptionRemove',
11220 'option_clear': 'onOptionClear',
11221 'optgroup_add': 'onOptionGroupAdd',
11222 'optgroup_remove': 'onOptionGroupRemove',
11223 'optgroup_clear': 'onOptionGroupClear',
11224 'dropdown_open': 'onDropdownOpen',
11225 'dropdown_close': 'onDropdownClose',
11226 'type': 'onType',
11227 'load': 'onLoad',
11228 'focus': 'onFocus',
11229 'blur': 'onBlur'
11230 };
11231 for (key in callbacks) {
11232 fn = this.settings[callbacks[key]];
11233 if (fn)
11234 this.on(key, fn);
11235 }
11236 }
11237 /**
11238 * Sync the Tom Select instance with the original input or select
11239 *
11240 */
11241 sync(get_settings = true) {
11242 const self = this;
11243 const settings = get_settings ? (0,_getSettings_js__WEBPACK_IMPORTED_MODULE_6__["default"])(self.input, { delimiter: self.settings.delimiter, allowEmptyOption: self.settings.allowEmptyOption }) : self.settings;
11244 self.setupOptions(settings.options, settings.optgroups);
11245 self.setValue(settings.items || [], true); // silent prevents recursion
11246 if (self.input.disabled) {
11247 self.disable();
11248 }
11249 else if (self.input.readOnly) {
11250 self.setReadOnly(true);
11251 }
11252 else {
11253 self.enable(); //sets tabIndex
11254 }
11255 self.lastQuery = null; // so updated options will be displayed in dropdown
11256 }
11257 /**
11258 * Triggered when the main control element
11259 * has a click event.
11260 *
11261 */
11262 onClick() {
11263 var self = this;
11264 if (self.activeItems.length > 0) {
11265 self.clearActiveItems();
11266 self.focus();
11267 return;
11268 }
11269 if (self.isFocused && self.isOpen) {
11270 self.blur();
11271 }
11272 else {
11273 self.focus();
11274 }
11275 }
11276 /**
11277 * @deprecated v1.7
11278 *
11279 */
11280 onMouseDown() { }
11281 /**
11282 * Triggered when the value of the control has been changed.
11283 * This should propagate the event to the original DOM
11284 * input / select element.
11285 */
11286 onChange() {
11287 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'input');
11288 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(this.input, 'change');
11289 }
11290 /**
11291 * Triggered on <input> paste.
11292 *
11293 */
11294 onPaste(e) {
11295 var self = this;
11296 if (self.isInputHidden || self.isLocked) {
11297 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11298 return;
11299 }
11300 // If a regex or string is included, this will split the pasted
11301 // input and create Items for each separate value
11302 if (!self.settings.splitOn) {
11303 return;
11304 }
11305 // Wait for pasted text to be recognized in value
11306 setTimeout(() => {
11307 var pastedText = self.inputValue();
11308 if (!pastedText.match(self.settings.splitOn)) {
11309 return;
11310 }
11311 var splitInput = pastedText.trim().split(self.settings.splitOn);
11312 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(splitInput, (piece) => {
11313 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(piece);
11314 if (hash) {
11315 if (this.options[piece]) {
11316 self.addItem(piece);
11317 }
11318 else {
11319 self.createItem(piece);
11320 }
11321 }
11322 });
11323 }, 0);
11324 }
11325 /**
11326 * Triggered on <input> keypress.
11327 *
11328 */
11329 onKeyPress(e) {
11330 var self = this;
11331 if (self.isLocked) {
11332 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11333 return;
11334 }
11335 var character = String.fromCharCode(e.keyCode || e.which);
11336 if (self.settings.create && self.settings.mode === 'multi' && character === self.settings.delimiter) {
11337 self.createItem();
11338 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11339 return;
11340 }
11341 }
11342 /**
11343 * Triggered on <input> keydown.
11344 *
11345 */
11346 onKeyDown(e) {
11347 var self = this;
11348 self.ignoreHover = true;
11349 if (self.isLocked) {
11350 if (e.keyCode !== _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB) {
11351 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11352 }
11353 return;
11354 }
11355 switch (e.keyCode) {
11356 // ctrl+A: select all
11357 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_A:
11358 if ((0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11359 if (self.control_input.value == '') {
11360 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11361 self.selectAll();
11362 return;
11363 }
11364 }
11365 break;
11366 // esc: close dropdown
11367 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_ESC:
11368 if (self.isOpen) {
11369 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
11370 self.close();
11371 }
11372 self.clearActiveItems();
11373 return;
11374 // down: open dropdown or move selection down
11375 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DOWN:
11376 if (!self.isOpen && self.hasOptions) {
11377 self.open();
11378 }
11379 else if (self.activeOption) {
11380 let next = self.getAdjacent(self.activeOption, 1);
11381 if (next)
11382 self.setActiveOption(next);
11383 }
11384 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11385 return;
11386 // up: move selection up
11387 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_UP:
11388 if (self.activeOption) {
11389 let prev = self.getAdjacent(self.activeOption, -1);
11390 if (prev)
11391 self.setActiveOption(prev);
11392 }
11393 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11394 return;
11395 // return: select active option
11396 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RETURN:
11397 if (self.canSelect(self.activeOption)) {
11398 self.onOptionSelect(e, self.activeOption);
11399 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11400 // if the option_create=null, the dropdown might be closed
11401 }
11402 else if (self.settings.create && self.createItem()) {
11403 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11404 // don't submit form when searching for a value
11405 }
11406 else if (document.activeElement == self.control_input && self.isOpen) {
11407 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11408 }
11409 return;
11410 // left: modifiy item selection to the left
11411 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_LEFT:
11412 self.advanceSelection(-1, e);
11413 return;
11414 // right: modifiy item selection to the right
11415 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_RIGHT:
11416 self.advanceSelection(1, e);
11417 return;
11418 // tab: select active option and/or create item
11419 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_TAB:
11420 if (self.settings.selectOnTab) {
11421 if (self.canSelect(self.activeOption)) {
11422 self.onOptionSelect(e, self.activeOption);
11423 // prevent default [tab] behaviour of jump to the next field
11424 // if select isFull, then the dropdown won't be open and [tab] will work normally
11425 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11426 }
11427 else if (self.settings.create && self.createItem()) {
11428 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11429 }
11430 }
11431 return;
11432 // delete|backspace: delete items
11433 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE:
11434 case _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_DELETE:
11435 self.deleteSelection(e);
11436 return;
11437 }
11438 // don't enter text in the control_input when active items are selected
11439 if (self.isInputHidden && !(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)(_constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_SHORTCUT, e)) {
11440 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11441 }
11442 }
11443 /**
11444 * Triggered on <input> keyup.
11445 *
11446 */
11447 onInput(e) {
11448 if (this.isLocked) {
11449 return;
11450 }
11451 const value = this.inputValue();
11452 if (this.lastValue === value)
11453 return;
11454 this.lastValue = value;
11455 if (value == '') {
11456 this._onInput();
11457 return;
11458 }
11459 if (this.refreshTimeout) {
11460 window.clearTimeout(this.refreshTimeout);
11461 }
11462 this.refreshTimeout = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.timeout)(() => {
11463 this.refreshTimeout = null;
11464 this._onInput();
11465 }, this.settings.refreshThrottle);
11466 }
11467 _onInput() {
11468 const value = this.lastValue;
11469 if (this.settings.shouldLoad.call(this, value)) {
11470 this.load(value);
11471 }
11472 this.refreshOptions();
11473 this.trigger('type', value);
11474 }
11475 /**
11476 * Triggered when the user rolls over
11477 * an option in the autocomplete dropdown menu.
11478 *
11479 */
11480 onOptionHover(evt, option) {
11481 if (this.ignoreHover)
11482 return;
11483 this.setActiveOption(option, false);
11484 }
11485 /**
11486 * Triggered on <input> focus.
11487 *
11488 */
11489 onFocus(e) {
11490 var self = this;
11491 var wasFocused = self.isFocused;
11492 if (self.isDisabled || self.isReadOnly) {
11493 self.blur();
11494 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11495 return;
11496 }
11497 if (self.ignoreFocus)
11498 return;
11499 self.isFocused = true;
11500 if (self.settings.preload === 'focus')
11501 self.preload();
11502 if (!wasFocused)
11503 self.trigger('focus');
11504 if (!self.activeItems.length) {
11505 self.inputState();
11506 self.refreshOptions(!!self.settings.openOnFocus);
11507 }
11508 self.refreshState();
11509 }
11510 /**
11511 * Triggered on <input> blur.
11512 *
11513 */
11514 onBlur(e) {
11515 if (document.hasFocus() === false)
11516 return;
11517 var self = this;
11518 if (!self.isFocused)
11519 return;
11520 self.isFocused = false;
11521 self.ignoreFocus = false;
11522 var deactivate = () => {
11523 self.close();
11524 self.setActiveItem();
11525 self.setCaret(self.items.length);
11526 self.trigger('blur');
11527 };
11528 if (self.settings.create && self.settings.createOnBlur) {
11529 self.createItem(null, deactivate);
11530 }
11531 else {
11532 deactivate();
11533 }
11534 }
11535 /**
11536 * Triggered when the user clicks on an option
11537 * in the autocomplete dropdown menu.
11538 *
11539 */
11540 onOptionSelect(evt, option) {
11541 var value, self = this;
11542 // should not be possible to trigger a option under a disabled optgroup
11543 if (option.parentElement && option.parentElement.matches('[data-disabled]')) {
11544 return;
11545 }
11546 if (option.classList.contains('create')) {
11547 self.createItem(null, () => {
11548 if (self.settings.closeAfterSelect) {
11549 self.close();
11550 }
11551 else if (self.settings.clearAfterSelect) {
11552 self.setTextboxValue();
11553 }
11554 });
11555 }
11556 else {
11557 value = option.dataset.value;
11558 if (typeof value !== 'undefined') {
11559 self.isDropdownContentStale = self.settings.hideSelected;
11560 self.addItem(value);
11561 if (self.settings.closeAfterSelect) {
11562 self.close();
11563 }
11564 else if (self.settings.clearAfterSelect) {
11565 self.setTextboxValue();
11566 }
11567 if (!self.settings.hideSelected && evt.type && /click/.test(evt.type)) {
11568 self.setActiveOption(option);
11569 }
11570 }
11571 }
11572 }
11573 /**
11574 * Return true if the given option can be selected
11575 *
11576 */
11577 canSelect(option) {
11578 if (this.isOpen && option && this.dropdown_content.contains(option)) {
11579 return true;
11580 }
11581 return false;
11582 }
11583 /**
11584 * Triggered when the user clicks on an item
11585 * that has been selected.
11586 *
11587 */
11588 onItemSelect(evt, item) {
11589 var self = this;
11590 if (!self.isLocked && self.settings.mode === 'multi') {
11591 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(evt);
11592 self.setActiveItem(item, evt);
11593 return true;
11594 }
11595 return false;
11596 }
11597 /**
11598 * Determines whether or not to invoke
11599 * the user-provided option provider / loader
11600 *
11601 * Note, there is a subtle difference between
11602 * this.canLoad() and this.settings.shouldLoad();
11603 *
11604 * - settings.shouldLoad() is a user-input validator.
11605 * When false is returned, the not_loading template
11606 * will be added to the dropdown
11607 *
11608 * - canLoad() is lower level validator that checks
11609 * the Tom Select instance. There is no inherent user
11610 * feedback when canLoad returns false
11611 *
11612 */
11613 canLoad(value) {
11614 if (!this.settings.load)
11615 return false;
11616 if (this.loadedSearches.hasOwnProperty(value))
11617 return false;
11618 return true;
11619 }
11620 /**
11621 * Invokes the user-provided option provider / loader.
11622 *
11623 */
11624 load(value) {
11625 const self = this;
11626 if (!self.canLoad(value))
11627 return;
11628 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(self.wrapper, self.settings.loadingClass);
11629 self.loading++;
11630 const callback = self.loadCallback.bind(self);
11631 self.settings.load.call(self, value, callback);
11632 }
11633 /**
11634 * Invoked by the user-provided option provider
11635 *
11636 */
11637 loadCallback(options, optgroups) {
11638 const self = this;
11639 self.loading = Math.max(self.loading - 1, 0);
11640 self.isDropdownContentStale = true;
11641 self.clearActiveOption(); // when new results load, focus should be on first option
11642 self.setupOptions(options, optgroups);
11643 self.refreshOptions(self.isFocused && !self.isInputHidden);
11644 if (!self.loading) {
11645 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.wrapper, self.settings.loadingClass);
11646 }
11647 self.trigger('load', options, optgroups);
11648 }
11649 preload() {
11650 var classList = this.wrapper.classList;
11651 if (classList.contains('preloaded'))
11652 return;
11653 classList.add('preloaded');
11654 this.load('');
11655 }
11656 /**
11657 * Sets the input field of the control to the specified value.
11658 *
11659 */
11660 setTextboxValue(value = '') {
11661 var input = this.control_input;
11662 var changed = input.value !== value;
11663 if (changed) {
11664 input.value = value;
11665 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.triggerEvent)(input, 'update');
11666 this.lastValue = value;
11667 }
11668 }
11669 /**
11670 * Returns the value of the control. If multiple items
11671 * can be selected (e.g. <select multiple>), this returns
11672 * an array. If only one item can be selected, this
11673 * returns a string.
11674 *
11675 */
11676 getValue() {
11677 if (this.is_select_tag && this.input.hasAttribute('multiple')) {
11678 return this.items;
11679 }
11680 return this.items.join(this.settings.delimiter);
11681 }
11682 /**
11683 * Resets the selected items to the given value.
11684 *
11685 */
11686 setValue(value, silent) {
11687 var events = silent ? [] : ['change'];
11688 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
11689 this.clear(silent);
11690 this.addItems(value, silent);
11691 });
11692 }
11693 /**
11694 * Resets the number of max items to the given value
11695 *
11696 */
11697 setMaxItems(value) {
11698 if (value === 0)
11699 value = null; //reset to unlimited items.
11700 this.settings.maxItems = value;
11701 this.refreshState();
11702 }
11703 /**
11704 * Sets the selected item.
11705 *
11706 */
11707 setActiveItem(item, e) {
11708 var self = this;
11709 var eventName;
11710 var i, begin, end, swap;
11711 var last;
11712 if (self.settings.mode === 'single')
11713 return;
11714 // clear the active selection
11715 if (!item) {
11716 self.clearActiveItems();
11717 if (self.isFocused) {
11718 self.inputState();
11719 }
11720 return;
11721 }
11722 // modify selection
11723 eventName = e && e.type.toLowerCase();
11724 if (eventName === 'click' && (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.isKeyDown)('shiftKey', e) && self.activeItems.length) {
11725 last = self.getLastActive();
11726 begin = Array.prototype.indexOf.call(self.control.children, last);
11727 end = Array.prototype.indexOf.call(self.control.children, item);
11728 if (begin > end) {
11729 swap = begin;
11730 begin = end;
11731 end = swap;
11732 }
11733 for (i = begin; i <= end; i++) {
11734 item = self.control.children[i];
11735 if (self.activeItems.indexOf(item) === -1) {
11736 self.setActiveItemClass(item);
11737 }
11738 }
11739 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e);
11740 }
11741 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))) {
11742 if (item.classList.contains('active')) {
11743 self.removeActiveItem(item);
11744 }
11745 else {
11746 self.setActiveItemClass(item);
11747 }
11748 }
11749 else {
11750 self.clearActiveItems();
11751 self.setActiveItemClass(item);
11752 }
11753 // ensure control has focus
11754 self.inputState();
11755 if (!self.isFocused) {
11756 self.focus();
11757 }
11758 }
11759 /**
11760 * Set the active and last-active classes
11761 *
11762 */
11763 setActiveItemClass(item) {
11764 const self = this;
11765 const last_active = self.control.querySelector('.last-active');
11766 if (last_active)
11767 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(last_active, 'last-active');
11768 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item, 'active last-active');
11769 self.trigger('item_select', item);
11770 if (self.activeItems.indexOf(item) == -1) {
11771 self.activeItems.push(item);
11772 }
11773 }
11774 /**
11775 * Remove active item
11776 *
11777 */
11778 removeActiveItem(item) {
11779 var idx = this.activeItems.indexOf(item);
11780 this.activeItems.splice(idx, 1);
11781 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
11782 }
11783 /**
11784 * Clears all the active items
11785 *
11786 */
11787 clearActiveItems() {
11788 ;(0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeItems, 'active');
11789 this.activeItems = [];
11790 }
11791 /**
11792 * Sets the selected item in the dropdown menu
11793 * of available options.
11794 *
11795 */
11796 setActiveOption(option, scroll = true) {
11797 if (option === this.activeOption) {
11798 return;
11799 }
11800 this.clearActiveOption();
11801 if (!option)
11802 return;
11803 this.activeOption = option;
11804 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': option.getAttribute('id') });
11805 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option, { 'aria-selected': 'true' });
11806 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(option, 'active');
11807 if (scroll)
11808 this.scrollToOption(option);
11809 }
11810 /**
11811 * Sets the dropdown_content scrollTop to display the option
11812 *
11813 */
11814 scrollToOption(option, behavior) {
11815 if (!option)
11816 return;
11817 const content = this.dropdown_content;
11818 const height_menu = content.clientHeight;
11819 const scrollTop = content.scrollTop || 0;
11820 const height_item = option.offsetHeight;
11821 const y = option.getBoundingClientRect().top - content.getBoundingClientRect().top + scrollTop;
11822 if (y + height_item > height_menu + scrollTop) {
11823 this.scroll(y - height_menu + height_item, behavior);
11824 }
11825 else if (y < scrollTop) {
11826 this.scroll(y, behavior);
11827 }
11828 }
11829 /**
11830 * Scroll the dropdown to the given position
11831 *
11832 */
11833 scroll(scrollTop, behavior) {
11834 const content = this.dropdown_content;
11835 if (behavior) {
11836 content.style.scrollBehavior = behavior;
11837 }
11838 content.scrollTop = scrollTop;
11839 content.style.scrollBehavior = '';
11840 }
11841 /**
11842 * Clears the active option
11843 *
11844 */
11845 clearActiveOption() {
11846 if (this.activeOption) {
11847 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(this.activeOption, 'active');
11848 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.activeOption, { 'aria-selected': null });
11849 }
11850 this.activeOption = null;
11851 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(this.focus_node, { 'aria-activedescendant': null });
11852 }
11853 /**
11854 * Selects all items (CTRL + A).
11855 */
11856 selectAll() {
11857 const self = this;
11858 if (self.settings.mode === 'single')
11859 return;
11860 const activeItems = self.controlChildren();
11861 if (!activeItems.length)
11862 return;
11863 self.inputState();
11864 self.close();
11865 self.activeItems = activeItems;
11866 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(activeItems, (item) => {
11867 self.setActiveItemClass(item);
11868 });
11869 }
11870 /**
11871 * Determines if the control_input should be in a hidden or visible state
11872 *
11873 */
11874 inputState() {
11875 var self = this;
11876 if (!self.control.contains(self.control_input))
11877 return;
11878 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: self.settings.placeholder });
11879 if (self.activeItems.length > 0 || (!self.isFocused && self.settings.hidePlaceholder && self.items.length > 0)) {
11880 self.setTextboxValue();
11881 self.isInputHidden = true;
11882 }
11883 else {
11884 if (self.settings.hidePlaceholder && self.items.length > 0) {
11885 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.control_input, { placeholder: '' });
11886 }
11887 self.isInputHidden = false;
11888 }
11889 self.wrapper.classList.toggle('input-hidden', self.isInputHidden);
11890 }
11891 /**
11892 * Get the input value
11893 */
11894 inputValue() {
11895 return this.control_input.value.trim();
11896 }
11897 /**
11898 * Gives the control focus.
11899 */
11900 focus() {
11901 var self = this;
11902 if (self.isDisabled || self.isReadOnly)
11903 return;
11904 self.ignoreFocus = true;
11905 const focusTarget = this.control_input.offsetWidth ? this.control_input : this.focus_node;
11906 focusTarget.focus();
11907 setTimeout(() => {
11908 self.ignoreFocus = false;
11909 // Fix https://github.com/orchidjs/tom-select/issues/806
11910 // Only proceed if this instance's element is still the active element. If Edge autofill
11911 // (or anything else) has moved focus to a different element in the interim, calling
11912 // onFocus() here would steal focus back and restart the cascade loop.
11913 const root = focusTarget.getRootNode();
11914 if (root.activeElement !== focusTarget) {
11915 return;
11916 }
11917 this.onFocus();
11918 }, 0);
11919 }
11920 /**
11921 * Forces the control out of focus.
11922 *
11923 */
11924 blur() {
11925 this.focus_node.blur();
11926 this.onBlur();
11927 }
11928 /**
11929 * Returns a function that scores an object
11930 * to show how good of a match it is to the
11931 * provided query.
11932 *
11933 * @return {function}
11934 */
11935 getScoreFunction(query) {
11936 return this.sifter.getScoreFunction(query, this.getSearchOptions());
11937 }
11938 /**
11939 * Returns search options for sifter (the system
11940 * for scoring and sorting results).
11941 *
11942 * @see https://github.com/orchidjs/sifter.js
11943 * @return {object}
11944 */
11945 getSearchOptions() {
11946 var settings = this.settings;
11947 var sort = settings.sortField;
11948 if (typeof settings.sortField === 'string') {
11949 sort = [{ field: settings.sortField }];
11950 }
11951 return {
11952 fields: settings.searchField,
11953 conjunction: settings.searchConjunction,
11954 sort: sort,
11955 nesting: settings.nesting
11956 };
11957 }
11958 /**
11959 * Searches through available options and returns
11960 * a sorted array of matches.
11961 *
11962 */
11963 search(query) {
11964 var result, calculateScore;
11965 var self = this;
11966 var options = this.getSearchOptions();
11967 // validate user-provided result scoring function
11968 if (self.settings.score) {
11969 calculateScore = self.settings.score.call(self, query);
11970 if (typeof calculateScore !== 'function') {
11971 throw new Error('Tom Select "score" setting must be a function that returns a function');
11972 }
11973 }
11974 // perform search
11975 if (self.isDropdownContentStale || query !== self.lastQuery) {
11976 self.lastQuery = query;
11977 // temp fix for https://github.com/orchidjs/tom-select/issues/987
11978 // UI crashed when more than 30 same chars in a row, prevent search and return empt result
11979 if (/(.)\1{15,}/.test(query)) {
11980 query = '';
11981 }
11982 result = self.sifter.search(query, Object.assign(options, { score: calculateScore }));
11983 self.currentResults = result;
11984 }
11985 else {
11986 result = Object.assign({}, self.currentResults);
11987 }
11988 // filter out selected items
11989 if (self.settings.hideSelected) {
11990 result.items = result.items.filter((item) => {
11991 let hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item.id);
11992 return !(hashed !== null && self.items.indexOf(hashed) !== -1);
11993 });
11994 }
11995 return result;
11996 }
11997 /**
11998 * Refreshes the list of available options shown
11999 * in the autocomplete dropdown menu.
12000 *
12001 */
12002 refreshOptions(triggerDropdown = true) {
12003 var i, j, k, n, optgroup, optgroups, html, has_create_option, active_group;
12004 var create;
12005 const groups = {};
12006 const groups_order = [];
12007 var self = this;
12008 var query = self.inputValue();
12009 const same_query = query === self.lastQuery || (query == '' && self.lastQuery == null);
12010 var results = self.search(query);
12011 var active_option = null;
12012 var show_dropdown = self.settings.shouldOpen || false;
12013 var dropdown_content = self.dropdown_content;
12014 if (same_query) {
12015 active_option = self.activeOption;
12016 if (active_option) {
12017 active_group = active_option.closest('[data-group]');
12018 }
12019 }
12020 // build markup
12021 n = results.items.length;
12022 if (typeof self.settings.maxOptions === 'number') {
12023 n = Math.min(n, self.settings.maxOptions);
12024 }
12025 if (n > 0) {
12026 show_dropdown = true;
12027 }
12028 // get fragment for group and the position of the group in group_order
12029 const getGroupFragment = (optgroup, order) => {
12030 let group_order_i = groups[optgroup];
12031 if (group_order_i !== undefined) {
12032 let order_group = groups_order[group_order_i];
12033 if (order_group !== undefined) {
12034 return [group_order_i, order_group.fragment];
12035 }
12036 }
12037 let group_fragment = document.createDocumentFragment();
12038 group_order_i = groups_order.length;
12039 groups_order.push({ fragment: group_fragment, order, optgroup });
12040 return [group_order_i, group_fragment];
12041 };
12042 // render and group available options individually
12043 for (i = 0; i < n; i++) {
12044 // get option dom element
12045 let item = results.items[i];
12046 if (!item)
12047 continue;
12048 let opt_value = item.id;
12049 let option = self.options[opt_value];
12050 if (option === undefined)
12051 continue;
12052 let opt_hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(opt_value);
12053 let option_el = self.getOption(opt_hash, true);
12054 // toggle 'selected' class
12055 if (!self.settings.hideSelected) {
12056 option_el.classList.toggle('selected', self.items.includes(opt_hash));
12057 }
12058 optgroup = option[self.settings.optgroupField] || '';
12059 optgroups = Array.isArray(optgroup) ? optgroup : [optgroup];
12060 for (j = 0, k = optgroups && optgroups.length; j < k; j++) {
12061 optgroup = optgroups[j];
12062 let order = option.$order;
12063 let self_optgroup = self.optgroups[optgroup];
12064 if (self_optgroup === undefined && typeof self.settings.optionGroupRegister === 'function') {
12065 var regGroup;
12066 if (regGroup = self.settings.optionGroupRegister.apply(self, [optgroup])) {
12067 self.registerOptionGroup(regGroup);
12068 }
12069 }
12070 self_optgroup = self.optgroups[optgroup];
12071 if (self_optgroup === undefined) {
12072 optgroup = '';
12073 }
12074 else {
12075 order = self_optgroup.$order;
12076 }
12077 const [group_order_i, group_fragment] = getGroupFragment(optgroup, order);
12078 // nodes can only have one parent, so if the option is in mutple groups, we need a clone
12079 if (j > 0) {
12080 option_el = option_el.cloneNode(true);
12081 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(option_el, { id: option.$id + '-clone-' + j, 'aria-selected': null });
12082 option_el.classList.add('ts-cloned');
12083 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(option_el, 'active');
12084 // make sure we keep the activeOption in the same group
12085 if (self.activeOption && self.activeOption.dataset.value == opt_value) {
12086 if (active_group && active_group.dataset.group === optgroup.toString()) {
12087 active_option = option_el;
12088 }
12089 }
12090 }
12091 group_fragment.appendChild(option_el);
12092 if (optgroup != '') {
12093 groups[optgroup] = group_order_i;
12094 }
12095 }
12096 }
12097 // sort optgroups
12098 if (self.settings.lockOptgroupOrder) {
12099 groups_order.sort((a, b) => {
12100 return a.order - b.order;
12101 });
12102 }
12103 // render optgroup headers & join groups
12104 html = document.createDocumentFragment();
12105 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(groups_order, (group_order) => {
12106 let group_fragment = group_order.fragment;
12107 let optgroup = group_order.optgroup;
12108 if (!group_fragment || !group_fragment.children.length)
12109 return;
12110 let group_heading = self.optgroups[optgroup];
12111 if (group_heading !== undefined) {
12112 let group_options = document.createDocumentFragment();
12113 let header = self.render('optgroup_header', group_heading);
12114 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, header);
12115 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(group_options, group_fragment);
12116 let group_html = self.render('optgroup', { group: group_heading, options: group_options });
12117 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_html);
12118 }
12119 else {
12120 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(html, group_fragment);
12121 }
12122 });
12123 dropdown_content.innerHTML = '';
12124 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.append)(dropdown_content, html);
12125 self.isDropdownContentStale = false;
12126 // highlight matching terms inline
12127 if (self.settings.highlight) {
12128 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.removeHighlight)(dropdown_content);
12129 if (results.query.length && results.tokens.length) {
12130 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(results.tokens, (tok) => {
12131 (0,_contrib_highlight_js__WEBPACK_IMPORTED_MODULE_4__.highlight)(dropdown_content, tok.regex);
12132 });
12133 }
12134 }
12135 // helper method for adding templates to dropdown
12136 var add_template = (template) => {
12137 let content = self.render(template, { input: query });
12138 if (content) {
12139 show_dropdown = true;
12140 dropdown_content.insertBefore(content, dropdown_content.firstChild);
12141 }
12142 return content;
12143 };
12144 // add loading message
12145 if (self.loading) {
12146 add_template('loading');
12147 // invalid query
12148 }
12149 else if (!self.settings.shouldLoad.call(self, query)) {
12150 add_template('not_loading');
12151 // add no_results message
12152 }
12153 else if (results.items.length === 0) {
12154 add_template('no_results');
12155 }
12156 // add create option
12157 has_create_option = self.canCreate(query);
12158 if (has_create_option) {
12159 create = add_template('option_create');
12160 }
12161 // activate
12162 self.hasOptions = results.items.length > 0 || has_create_option;
12163 if (show_dropdown) {
12164 if (results.items.length > 0) {
12165 if (!active_option && self.settings.mode === 'single' && self.items[0] != undefined) {
12166 active_option = self.getOption(self.items[0]);
12167 }
12168 if (!dropdown_content.contains(active_option)) {
12169 let active_index = 0;
12170 if (create && !self.settings.addPrecedence) {
12171 active_index = 1;
12172 }
12173 active_option = self.selectable()[active_index];
12174 }
12175 }
12176 else if (create) {
12177 active_option = create;
12178 }
12179 if (triggerDropdown && !self.isOpen) {
12180 self.open();
12181 self.scrollToOption(active_option, 'auto');
12182 }
12183 self.setActiveOption(active_option);
12184 }
12185 else {
12186 self.clearActiveOption();
12187 if (triggerDropdown && self.isOpen) {
12188 self.close(false); // if create_option=null, we want the dropdown to close but not reset the textbox value
12189 }
12190 }
12191 }
12192 /**
12193 * Return list of selectable options
12194 *
12195 */
12196 selectable() {
12197 return this.dropdown_content.querySelectorAll('[data-selectable]');
12198 }
12199 /**
12200 * Adds an available option. If it already exists,
12201 * nothing will happen. Note: this does not refresh
12202 * the options list dropdown (use `refreshOptions`
12203 * for that).
12204 *
12205 * Usage:
12206 *
12207 * this.addOption(data)
12208 *
12209 */
12210 addOption(data, user_created = false) {
12211 const self = this;
12212 // @deprecated 1.7.7
12213 // use addOptions( array, user_created ) for adding multiple options
12214 if (Array.isArray(data)) {
12215 self.addOptions(data, user_created);
12216 return false;
12217 }
12218 const key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12219 if (key === null || self.options.hasOwnProperty(key)) {
12220 self.updateOption(data[self.settings.valueField], data);
12221 return false;
12222 }
12223 data.$order = data.$order || ++self.order;
12224 data.$id = self.inputId + '-opt-' + data.$order;
12225 self.options[key] = data;
12226 self.isDropdownContentStale = true;
12227 if (user_created) {
12228 self.userOptions[key] = user_created;
12229 self.trigger('option_add', key, data);
12230 }
12231 return key;
12232 }
12233 /**
12234 * Add multiple options
12235 *
12236 */
12237 addOptions(data, user_created = false) {
12238 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(data, (dat) => {
12239 this.addOption(dat, user_created);
12240 });
12241 }
12242 /**
12243 * @deprecated 1.7.7
12244 */
12245 registerOption(data) {
12246 return this.addOption(data);
12247 }
12248 /**
12249 * Registers an option group to the pool of option groups.
12250 *
12251 * @return {boolean|string}
12252 */
12253 registerOptionGroup(data) {
12254 var key = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[this.settings.optgroupValueField]);
12255 if (key === null)
12256 return false;
12257 data.$order = data.$order || ++this.order;
12258 this.optgroups[key] = data;
12259 return key;
12260 }
12261 /**
12262 * Registers a new optgroup for options
12263 * to be bucketed into.
12264 *
12265 */
12266 addOptionGroup(id, data) {
12267 var hashed_id;
12268 data[this.settings.optgroupValueField] = id;
12269 if (hashed_id = this.registerOptionGroup(data)) {
12270 this.trigger('optgroup_add', hashed_id, data);
12271 }
12272 }
12273 /**
12274 * Removes an existing option group.
12275 *
12276 */
12277 removeOptionGroup(id) {
12278 if (this.optgroups.hasOwnProperty(id)) {
12279 delete this.optgroups[id];
12280 this.clearCache();
12281 this.trigger('optgroup_remove', id);
12282 }
12283 }
12284 /**
12285 * Clears all existing option groups.
12286 */
12287 clearOptionGroups() {
12288 this.optgroups = {};
12289 this.clearCache();
12290 this.trigger('optgroup_clear');
12291 }
12292 /**
12293 * Updates an option available for selection. If
12294 * it is visible in the selected items or options
12295 * dropdown, it will be re-rendered automatically.
12296 *
12297 */
12298 updateOption(value, data) {
12299 const self = this;
12300 var item_new;
12301 var index_item;
12302 const value_old = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12303 const value_new = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12304 // sanity checks
12305 if (value_old === null)
12306 return;
12307 const data_old = self.options[value_old];
12308 if (data_old == undefined)
12309 return;
12310 if (typeof value_new !== 'string')
12311 throw new Error('Value must be set in option data');
12312 const option = self.getOption(value_old);
12313 const item = self.getItem(value_old);
12314 data.$order = data.$order || data_old.$order;
12315 delete self.options[value_old];
12316 // invalidate render cache
12317 // don't remove existing node yet, we'll remove it after replacing it
12318 self.uncacheValue(value_new);
12319 self.options[value_new] = data;
12320 // update the option if it's in the dropdown
12321 if (option) {
12322 if (self.dropdown_content.contains(option)) {
12323 const option_new = self._render('option', data);
12324 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(option, option_new);
12325 if (self.activeOption === option) {
12326 self.setActiveOption(option_new);
12327 }
12328 }
12329 option.remove();
12330 }
12331 // update the item if we have one
12332 if (item) {
12333 index_item = self.items.indexOf(value_old);
12334 if (index_item !== -1) {
12335 self.items.splice(index_item, 1, value_new);
12336 }
12337 item_new = self._render('item', data);
12338 if (item.classList.contains('active'))
12339 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(item_new, 'active');
12340 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.replaceNode)(item, item_new);
12341 }
12342 // we might have updated the sortField
12343 self.isDropdownContentStale = true;
12344 }
12345 /**
12346 * Removes a single option.
12347 *
12348 */
12349 removeOption(value, silent) {
12350 const self = this;
12351 value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(value);
12352 self.uncacheValue(value);
12353 delete self.userOptions[value];
12354 delete self.options[value];
12355 self.isDropdownContentStale = true;
12356 self.trigger('option_remove', value);
12357 self.removeItem(value, silent);
12358 }
12359 /**
12360 * Clears all options.
12361 */
12362 clearOptions(filter) {
12363 const boundFilter = (filter || this.clearFilter).bind(this);
12364 this.loadedSearches = {};
12365 this.userOptions = {};
12366 this.clearCache();
12367 const selected = {};
12368 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option, key) => {
12369 if (boundFilter(option, key)) {
12370 selected[key] = option;
12371 }
12372 });
12373 this.options = this.sifter.items = selected;
12374 this.isDropdownContentStale = true;
12375 this.trigger('option_clear');
12376 }
12377 /**
12378 * Used by clearOptions() to decide whether or not an option should be removed
12379 * Return true to keep an option, false to remove
12380 *
12381 */
12382 clearFilter(option, value) {
12383 if (this.items.indexOf(value) >= 0) {
12384 return true;
12385 }
12386 return false;
12387 }
12388 /**
12389 * Returns the dom element of the option
12390 * matching the given value.
12391 *
12392 */
12393 getOption(value, create = false) {
12394 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12395 if (hashed === null)
12396 return null;
12397 const option = this.options[hashed];
12398 if (option != undefined) {
12399 if (option.$div) {
12400 return option.$div;
12401 }
12402 if (create) {
12403 return this._render('option', option);
12404 }
12405 }
12406 return null;
12407 }
12408 /**
12409 * Returns the dom element of the next or previous dom element of the same type
12410 * Note: adjacent options may not be adjacent DOM elements (optgroups)
12411 *
12412 */
12413 getAdjacent(option, direction, type = 'option') {
12414 var self = this, all;
12415 if (!option) {
12416 return null;
12417 }
12418 if (type == 'item') {
12419 all = self.controlChildren();
12420 }
12421 else {
12422 all = self.dropdown_content.querySelectorAll('[data-selectable]');
12423 }
12424 for (let i = 0; i < all.length; i++) {
12425 if (all[i] != option) {
12426 continue;
12427 }
12428 if (direction > 0) {
12429 return all[i + 1];
12430 }
12431 return all[i - 1];
12432 }
12433 return null;
12434 }
12435 /**
12436 * Returns the dom element of the item
12437 * matching the given value.
12438 *
12439 */
12440 getItem(item) {
12441 if (typeof item == 'object') {
12442 return item;
12443 }
12444 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(item);
12445 return value !== null
12446 ? this.control.querySelector(`[data-value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]`)
12447 : null;
12448 }
12449 /**
12450 * "Selects" multiple items at once. Adds them to the list
12451 * at the current caret position.
12452 *
12453 */
12454 addItems(values, silent) {
12455 var self = this;
12456 var items = Array.isArray(values) ? values : [values];
12457 items = items.filter(x => self.items.indexOf(x) === -1);
12458 const last_item = items[items.length - 1];
12459 items.forEach(item => {
12460 self.isPending = (item !== last_item);
12461 self.addItem(item, silent);
12462 });
12463 }
12464 /**
12465 * "Selects" an item. Adds it to the list
12466 * at the current caret position.
12467 *
12468 */
12469 addItem(value, silent) {
12470 var events = silent ? [] : ['change', 'dropdown_close'];
12471 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.debounce_events)(this, events, () => {
12472 var item, wasFull;
12473 const self = this;
12474 const inputMode = self.settings.mode;
12475 const hashed = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(value);
12476 if (hashed && self.items.indexOf(hashed) !== -1) {
12477 if (inputMode === 'single') {
12478 self.close();
12479 }
12480 if (inputMode === 'single' || !self.settings.duplicates) {
12481 return;
12482 }
12483 }
12484 if (hashed === null || !self.options.hasOwnProperty(hashed))
12485 return;
12486 if (inputMode === 'single')
12487 self.clear(silent);
12488 if (inputMode === 'multi' && self.isFull())
12489 return;
12490 item = self._render('item', self.options[hashed]);
12491 if (self.control.contains(item)) { // duplicates
12492 item = item.cloneNode(true);
12493 }
12494 wasFull = self.isFull();
12495 self.items.splice(self.caretPos, 0, hashed);
12496 self.insertAtCaret(item);
12497 if (self.isSetup) {
12498 // update menu / remove the option (if this is not one item being added as part of series)
12499 if (!self.isPending && self.settings.hideSelected) {
12500 let option = self.getOption(hashed);
12501 let next = self.getAdjacent(option, 1);
12502 if (next) {
12503 self.setActiveOption(next);
12504 }
12505 }
12506 //remove input value when enabled
12507 if (self.settings.clearAfterSelect) {
12508 self.setTextboxValue();
12509 }
12510 // refreshOptions after setActiveOption(),
12511 // otherwise setActiveOption() will be called by refreshOptions() with the wrong value
12512 if (!self.isPending && !self.settings.closeAfterSelect) {
12513 self.refreshOptions(self.isFocused && inputMode !== 'single');
12514 }
12515 // hide the menu if the maximum number of items have been selected or no options are left
12516 if (self.settings.closeAfterSelect != false && self.isFull()) {
12517 self.close();
12518 }
12519 else if (!self.isPending) {
12520 self.positionDropdown();
12521 }
12522 self.trigger('item_add', hashed, item);
12523 if (!self.isPending) {
12524 self.updateOriginalInput({ silent: silent });
12525 }
12526 }
12527 if (!self.isPending || (!wasFull && self.isFull())) {
12528 self.inputState();
12529 self.refreshState();
12530 }
12531 });
12532 }
12533 /**
12534 * Removes the selected item matching
12535 * the provided value.
12536 *
12537 */
12538 removeItem(item = null, silent) {
12539 const self = this;
12540 item = self.getItem(item);
12541 if (!item)
12542 return;
12543 var i, idx;
12544 const value = item.dataset.value;
12545 i = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(item);
12546 item.remove();
12547 if (item.classList.contains('active')) {
12548 idx = self.activeItems.indexOf(item);
12549 self.activeItems.splice(idx, 1);
12550 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(item, 'active');
12551 }
12552 self.items.splice(i, 1);
12553 self.isDropdownContentStale = true;
12554 if (!self.settings.persist && self.userOptions.hasOwnProperty(value)) {
12555 self.removeOption(value, silent);
12556 }
12557 if (i < self.caretPos) {
12558 self.setCaret(self.caretPos - 1);
12559 }
12560 self.updateOriginalInput({ silent: silent });
12561 self.refreshState();
12562 self.positionDropdown();
12563 self.trigger('item_remove', value, item);
12564 }
12565 /**
12566 * Invokes the `create` method provided in the
12567 * TomSelect options that should provide the data
12568 * for the new item, given the user input.
12569 *
12570 * Once this completes, it will be added
12571 * to the item list.
12572 *
12573 */
12574 createItem(input = null, callback = () => { }) {
12575 // triggerDropdown parameter @deprecated 2.1.1
12576 if (arguments.length === 3) {
12577 callback = arguments[2];
12578 }
12579 if (typeof callback != 'function') {
12580 callback = () => { };
12581 }
12582 var self = this;
12583 var caret = self.caretPos;
12584 var output;
12585 input = input || self.inputValue();
12586 if (!self.canCreate(input)) {
12587 const hash = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(input);
12588 if (hash) {
12589 if (this.options[input]) {
12590 self.addItem(input);
12591 }
12592 }
12593 callback();
12594 return false;
12595 }
12596 self.lock();
12597 var created = false;
12598 var create = (data) => {
12599 self.unlock();
12600 if (!data || typeof data !== 'object')
12601 return callback();
12602 var value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.hash_key)(data[self.settings.valueField]);
12603 if (typeof value !== 'string') {
12604 return callback();
12605 }
12606 self.setTextboxValue();
12607 self.addOption(data, true);
12608 self.setCaret(caret);
12609 self.addItem(value);
12610 callback(data);
12611 created = true;
12612 };
12613 if (typeof self.settings.create === 'function') {
12614 output = self.settings.create.call(this, input, create);
12615 }
12616 else {
12617 output = {
12618 [self.settings.labelField]: input,
12619 [self.settings.valueField]: input,
12620 };
12621 }
12622 if (!created) {
12623 create(output);
12624 }
12625 return true;
12626 }
12627 /**
12628 * Re-renders the selected item lists.
12629 */
12630 refreshItems() {
12631 var self = this;
12632 self.isDropdownContentStale = true;
12633 if (self.isSetup) {
12634 self.addItems(self.items);
12635 }
12636 self.updateOriginalInput();
12637 self.refreshState();
12638 }
12639 /**
12640 * Updates all state-dependent attributes
12641 * and CSS classes.
12642 */
12643 refreshState() {
12644 const self = this;
12645 self.refreshValidityState();
12646 const isFull = self.isFull();
12647 const isLocked = self.isLocked;
12648 self.wrapper.classList.toggle('rtl', self.rtl);
12649 const wrap_classList = self.wrapper.classList;
12650 wrap_classList.toggle('focus', self.isFocused);
12651 wrap_classList.toggle('disabled', self.isDisabled);
12652 wrap_classList.toggle('readonly', self.isReadOnly);
12653 wrap_classList.toggle('required', self.isRequired);
12654 wrap_classList.toggle('invalid', !self.isValid);
12655 wrap_classList.toggle('locked', isLocked);
12656 wrap_classList.toggle('full', isFull);
12657 wrap_classList.toggle('input-active', self.isFocused && !self.isInputHidden);
12658 wrap_classList.toggle('dropdown-active', self.isOpen);
12659 wrap_classList.toggle('has-options', (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.isEmptyObject)(self.options));
12660 wrap_classList.toggle('has-items', self.items.length > 0);
12661 }
12662 /**
12663 * Update the `required` attribute of both input and control input.
12664 *
12665 * The `required` property needs to be activated on the control input
12666 * for the error to be displayed at the right place. `required` also
12667 * needs to be temporarily deactivated on the input since the input is
12668 * hidden and can't show errors.
12669 */
12670 refreshValidityState() {
12671 var self = this;
12672 if (!self.input.validity) {
12673 return;
12674 }
12675 self.isValid = self.input.validity.valid;
12676 self.isInvalid = !self.isValid;
12677 }
12678 /**
12679 * Determines whether or not more items can be added
12680 * to the control without exceeding the user-defined maximum.
12681 *
12682 * @returns {boolean}
12683 */
12684 isFull() {
12685 return this.settings.maxItems !== null && this.items.length >= this.settings.maxItems;
12686 }
12687 /**
12688 * Refreshes the original <select> or <input>
12689 * element to reflect the current state.
12690 *
12691 */
12692 updateOriginalInput(opts = {}) {
12693 const self = this;
12694 var option, label;
12695 const empty_option = self.input.querySelector('option[value=""]');
12696 if (self.is_select_tag) {
12697 const selected = [];
12698 const has_selected = self.input.querySelectorAll('option:checked').length;
12699 function AddSelected(option_el, value, label) {
12700 if (!option_el) {
12701 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>');
12702 }
12703 // don't move empty option from top of list
12704 // fixes bug in firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1725293
12705 if (option_el != empty_option) {
12706 self.input.append(option_el);
12707 }
12708 selected.push(option_el);
12709 // marking empty option as selected can break validation
12710 // fixes https://github.com/orchidjs/tom-select/issues/303
12711 if (option_el != empty_option || has_selected > 0 || self.settings.mode == 'multi') {
12712 option_el.selected = true;
12713 }
12714 return option_el;
12715 }
12716 // unselect all selected options
12717 self.input.querySelectorAll('option:checked').forEach((option_el) => {
12718 option_el.selected = false;
12719 });
12720 // nothing selected?
12721 if (self.items.length == 0 && self.settings.mode == 'single') {
12722 AddSelected(empty_option, "", "");
12723 // order selected <option> tags for values in self.items
12724 }
12725 else {
12726 self.items.forEach((value) => {
12727 option = self.options[value];
12728 label = option[self.settings.labelField] || '';
12729 if (selected.includes(option.$option)) {
12730 const reuse_opt = self.input.querySelector(`option[value="${(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.addSlashes)(value)}"]:not(:checked)`);
12731 AddSelected(reuse_opt, value, label);
12732 }
12733 else {
12734 option.$option = AddSelected(option.$option, value, label);
12735 }
12736 });
12737 }
12738 }
12739 else {
12740 self.input.value = self.getValue();
12741 }
12742 if (self.isSetup) {
12743 if (!opts.silent) {
12744 self.trigger('change', self.getValue());
12745 }
12746 }
12747 }
12748 /**
12749 * Shows the autocomplete dropdown containing
12750 * the available options.
12751 */
12752 open() {
12753 var self = this;
12754 if (self.isLocked || self.isOpen || (self.settings.mode === 'multi' && self.isFull()))
12755 return;
12756 self.isOpen = true;
12757 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'true' });
12758 self.refreshState();
12759 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'hidden', display: 'block' });
12760 self.positionDropdown();
12761 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { visibility: 'visible', display: 'block' });
12762 self.focus();
12763 self.trigger('dropdown_open', self.dropdown);
12764 }
12765 /**
12766 * Closes the autocomplete dropdown menu.
12767 */
12768 close(setTextboxValue = true) {
12769 var self = this;
12770 var trigger = self.isOpen;
12771 if (setTextboxValue) {
12772 // before blur() to prevent form onchange event
12773 self.setTextboxValue();
12774 if (self.settings.mode === 'single' && self.items.length) {
12775 self.inputState();
12776 }
12777 }
12778 self.isOpen = false;
12779 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(self.focus_node, { 'aria-expanded': 'false' });
12780 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(self.dropdown, { display: 'none' });
12781 if (self.settings.hideSelected) {
12782 self.clearActiveOption();
12783 }
12784 self.refreshState();
12785 if (trigger)
12786 self.trigger('dropdown_close', self.dropdown);
12787 }
12788 /**
12789 * Calculates and applies the appropriate
12790 * position of the dropdown if dropdownParent = 'body'.
12791 * Otherwise, position is determined by css
12792 */
12793 positionDropdown() {
12794 if (this.settings.dropdownParent !== 'body') {
12795 return;
12796 }
12797 var context = this.control;
12798 var rect = context.getBoundingClientRect();
12799 var top = context.offsetHeight + rect.top + window.scrollY;
12800 var left = rect.left + window.scrollX;
12801 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.applyCSS)(this.dropdown, {
12802 width: rect.width + 'px',
12803 top: top + 'px',
12804 left: left + 'px'
12805 });
12806 }
12807 /**
12808 * Resets / clears all selected items
12809 * from the control.
12810 *
12811 */
12812 clear(silent) {
12813 var self = this;
12814 if (!self.items.length)
12815 return;
12816 var items = self.controlChildren();
12817 (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(items, (item) => {
12818 self.removeItem(item, true);
12819 });
12820 self.inputState();
12821 if (!silent)
12822 self.updateOriginalInput();
12823 self.trigger('clear');
12824 }
12825 /**
12826 * A helper method for inserting an element
12827 * at the current caret position.
12828 *
12829 */
12830 insertAtCaret(el) {
12831 const self = this;
12832 const caret = self.caretPos;
12833 const target = self.control;
12834 target.insertBefore(el, target.children[caret] || null);
12835 self.setCaret(caret + 1);
12836 }
12837 /**
12838 * Removes the current selected item(s).
12839 *
12840 */
12841 deleteSelection(e) {
12842 var direction, selection, caret, tail;
12843 var self = this;
12844 direction = (e && e.keyCode === _constants_js__WEBPACK_IMPORTED_MODULE_5__.KEY_BACKSPACE) ? -1 : 1;
12845 selection = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.getSelection)(self.control_input);
12846 // determine items that will be removed
12847 const rm_items = [];
12848 if (self.activeItems.length) {
12849 tail = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(self.activeItems, direction);
12850 caret = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.nodeIndex)(tail);
12851 if (direction > 0) {
12852 caret++;
12853 }
12854 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(self.activeItems, (item) => rm_items.push(item));
12855 }
12856 else if ((self.isFocused || self.settings.mode === 'single') && self.items.length) {
12857 const items = self.controlChildren();
12858 let rm_item;
12859 if (direction < 0 && selection.start === 0 && selection.length === 0) {
12860 rm_item = items[self.caretPos - 1];
12861 }
12862 else if (direction > 0 && selection.start === self.inputValue().length) {
12863 rm_item = items[self.caretPos];
12864 }
12865 if (rm_item !== undefined) {
12866 rm_items.push(rm_item);
12867 }
12868 }
12869 if (!self.shouldDelete(rm_items, e)) {
12870 return false;
12871 }
12872 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.preventDefault)(e, true);
12873 // perform removal
12874 if (typeof caret !== 'undefined') {
12875 self.setCaret(caret);
12876 }
12877 while (rm_items.length) {
12878 self.removeItem(rm_items.pop());
12879 }
12880 self.inputState();
12881 self.positionDropdown();
12882 self.refreshOptions(false);
12883 return true;
12884 }
12885 /**
12886 * Return true if the items should be deleted
12887 */
12888 shouldDelete(items, evt) {
12889 const values = items.map(item => item.dataset.value);
12890 // allow the callback to abort
12891 if (!values.length || (typeof this.settings.onDelete === 'function' && this.settings.onDelete.call(this, values, evt) === false)) {
12892 return false;
12893 }
12894 return true;
12895 }
12896 /**
12897 * Selects the previous / next item (depending on the `direction` argument).
12898 *
12899 * > 0 - right
12900 * < 0 - left
12901 *
12902 */
12903 advanceSelection(direction, e) {
12904 var last_active, adjacent, self = this;
12905 if (self.rtl)
12906 direction *= -1;
12907 if (self.inputValue().length)
12908 return;
12909 // add or remove to active items
12910 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)) {
12911 last_active = self.getLastActive(direction);
12912 if (last_active) {
12913 if (!last_active.classList.contains('active')) {
12914 adjacent = last_active;
12915 }
12916 else {
12917 adjacent = self.getAdjacent(last_active, direction, 'item');
12918 }
12919 // if no active item, get items adjacent to the control input
12920 }
12921 else if (direction > 0) {
12922 adjacent = self.control_input.nextElementSibling;
12923 }
12924 else {
12925 adjacent = self.control_input.previousElementSibling;
12926 }
12927 if (adjacent) {
12928 if (adjacent.classList.contains('active')) {
12929 self.removeActiveItem(last_active);
12930 }
12931 self.setActiveItemClass(adjacent); // mark as last_active !! after removeActiveItem() on last_active
12932 }
12933 // move caret to the left or right
12934 }
12935 else {
12936 self.moveCaret(direction);
12937 }
12938 }
12939 moveCaret(direction) { }
12940 /**
12941 * Get the last active item
12942 *
12943 */
12944 getLastActive(direction) {
12945 let last_active = this.control.querySelector('.last-active');
12946 if (last_active) {
12947 return last_active;
12948 }
12949 var result = this.control.querySelectorAll('.active');
12950 if (result) {
12951 return (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getTail)(result, direction);
12952 }
12953 }
12954 /**
12955 * Moves the caret to the specified index.
12956 *
12957 * The input must be moved by leaving it in place and moving the
12958 * siblings, due to the fact that focus cannot be restored once lost
12959 * on mobile webkit devices
12960 *
12961 */
12962 setCaret(new_pos) {
12963 this.caretPos = this.items.length;
12964 }
12965 /**
12966 * Return list of item dom elements
12967 *
12968 */
12969 controlChildren() {
12970 return Array.from(this.control.querySelectorAll('[data-ts-item]'));
12971 }
12972 /**
12973 * Disables user input on the control. Used while
12974 * items are being asynchronously created.
12975 */
12976 lock() {
12977 this.setLocked(true);
12978 }
12979 /**
12980 * Re-enables user input on the control.
12981 */
12982 unlock() {
12983 this.setLocked(false);
12984 }
12985 /**
12986 * Disable or enable user input on the control
12987 */
12988 setLocked(lock = this.isReadOnly || this.isDisabled) {
12989 this.isLocked = lock;
12990 this.refreshState();
12991 }
12992 /**
12993 * Disables user input on the control completely.
12994 * While disabled, it cannot receive focus.
12995 */
12996 disable() {
12997 this.setDisabled(true);
12998 this.close();
12999 }
13000 /**
13001 * Enables the control so that it can respond
13002 * to focus and user input.
13003 */
13004 enable() {
13005 this.setDisabled(false);
13006 }
13007 setDisabled(disabled) {
13008 this.focus_node.tabIndex = disabled ? -1 : this.tabIndex;
13009 this.isDisabled = disabled;
13010 this.input.disabled = disabled;
13011 this.control_input.disabled = disabled;
13012 this.setLocked();
13013 }
13014 setReadOnly(isReadOnly) {
13015 this.isReadOnly = isReadOnly;
13016 this.input.readOnly = isReadOnly;
13017 this.control_input.readOnly = isReadOnly;
13018 this.setLocked();
13019 }
13020 /**
13021 * Completely destroys the control and
13022 * unbinds all event listeners so that it can
13023 * be garbage collected.
13024 */
13025 destroy() {
13026 var self = this;
13027 var revertSettings = self.revertSettings;
13028 self.trigger('destroy');
13029 self.off();
13030 self.wrapper.remove();
13031 self.dropdown.remove();
13032 self.input.innerHTML = revertSettings.innerHTML;
13033 self.input.tabIndex = revertSettings.tabIndex;
13034 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.removeClasses)(self.input, 'tomselected', 'ts-hidden-accessible');
13035 self._destroy();
13036 delete self.input.tomselect;
13037 }
13038 /**
13039 * A helper method for rendering "item" and
13040 * "option" templates, given the data.
13041 *
13042 */
13043 render(templateName, data) {
13044 var id, html;
13045 const self = this;
13046 if (typeof this.settings.render[templateName] !== 'function') {
13047 return null;
13048 }
13049 // render markup
13050 html = self.settings.render[templateName].call(this, data, _utils_js__WEBPACK_IMPORTED_MODULE_7__.escape_html);
13051 if (!html) {
13052 return null;
13053 }
13054 html = (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.getDom)(html);
13055 // add mandatory attributes
13056 if (templateName === 'option' || templateName === 'option_create') {
13057 if (data[self.settings.disabledField]) {
13058 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'aria-disabled': 'true' });
13059 }
13060 else {
13061 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-selectable': '' });
13062 }
13063 }
13064 else if (templateName === 'optgroup') {
13065 id = data.group[self.settings.optgroupValueField];
13066 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-group': id });
13067 if (data.group[self.settings.disabledField]) {
13068 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-disabled': '' });
13069 }
13070 }
13071 if (templateName === 'option' || templateName === 'item') {
13072 const value = (0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.get_hash)(data[self.settings.valueField]);
13073 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-value': value });
13074 // make sure we have some classes if a template is overwritten
13075 if (templateName === 'item') {
13076 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.itemClass);
13077 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, { 'data-ts-item': '' });
13078 }
13079 else {
13080 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.addClasses)(html, self.settings.optionClass);
13081 (0,_vanilla_js__WEBPACK_IMPORTED_MODULE_8__.setAttr)(html, {
13082 role: 'option',
13083 id: data.$id
13084 });
13085 // update cache
13086 data.$div = html;
13087 self.options[value] = data;
13088 }
13089 }
13090 return html;
13091 }
13092 /**
13093 * Type guarded rendering
13094 *
13095 */
13096 _render(templateName, data) {
13097 const html = this.render(templateName, data);
13098 if (html == null) {
13099 throw 'HTMLElement expected';
13100 }
13101 return html;
13102 }
13103 /**
13104 * Clears the render cache for a template. If
13105 * no template is given, clears all render
13106 * caches.
13107 *
13108 */
13109 clearCache() {
13110 ;(0,_utils_js__WEBPACK_IMPORTED_MODULE_7__.iterate)(this.options, (option) => {
13111 if (option.$div) {
13112 option.$div.remove();
13113 delete option.$div;
13114 }
13115 });
13116 }
13117 /**
13118 * Removes a value from item and option caches
13119 *
13120 */
13121 uncacheValue(value) {
13122 const option_el = this.getOption(value);
13123 if (option_el)
13124 option_el.remove();
13125 }
13126 /**
13127 * Determines whether or not to display the
13128 * create item prompt, given a user input.
13129 *
13130 */
13131 canCreate(input) {
13132 return this.settings.create && (input.length > 0) && this.settings.createFilter.call(this, input);
13133 }
13134 /**
13135 * Wraps this.`method` so that `new_fn` can be invoked 'before', 'after', or 'instead' of the original method
13136 *
13137 * this.hook('instead','onKeyDown',function( arg1, arg2 ...){
13138 *
13139 * });
13140 */
13141 hook(when, method, new_fn) {
13142 var self = this;
13143 var orig_method = self[method];
13144 self[method] = function () {
13145 var result, result_new;
13146 if (when === 'after') {
13147 result = orig_method.apply(self, arguments);
13148 }
13149 result_new = new_fn.apply(self, arguments);
13150 if (when === 'instead') {
13151 return result_new;
13152 }
13153 if (when === 'before') {
13154 result = orig_method.apply(self, arguments);
13155 }
13156 return result;
13157 };
13158 }
13159 }
13160 ;
13161 //# sourceMappingURL=tom-select.js.map
13162
13163 /***/ },
13164
13165 /***/ "./node_modules/tom-select/dist/esm/utils.js"
13166 /*!***************************************************!*\
13167 !*** ./node_modules/tom-select/dist/esm/utils.js ***!
13168 \***************************************************/
13169 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13170
13171 "use strict";
13172 __webpack_require__.r(__webpack_exports__);
13173 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13174 /* harmony export */ addEvent: () => (/* binding */ addEvent),
13175 /* harmony export */ addSlashes: () => (/* binding */ addSlashes),
13176 /* harmony export */ append: () => (/* binding */ append),
13177 /* harmony export */ debounce_events: () => (/* binding */ debounce_events),
13178 /* harmony export */ escape_html: () => (/* binding */ escape_html),
13179 /* harmony export */ getId: () => (/* binding */ getId),
13180 /* harmony export */ getSelection: () => (/* binding */ getSelection),
13181 /* harmony export */ get_hash: () => (/* binding */ get_hash),
13182 /* harmony export */ hash_key: () => (/* binding */ hash_key),
13183 /* harmony export */ isKeyDown: () => (/* binding */ isKeyDown),
13184 /* harmony export */ iterate: () => (/* binding */ iterate),
13185 /* harmony export */ loadDebounce: () => (/* binding */ loadDebounce),
13186 /* harmony export */ preventDefault: () => (/* binding */ preventDefault),
13187 /* harmony export */ timeout: () => (/* binding */ timeout)
13188 /* harmony export */ });
13189 /**
13190 * Converts a scalar to its best string representation
13191 * for hash keys and HTML attribute values.
13192 *
13193 * Transformations:
13194 * 'str' -> 'str'
13195 * null -> ''
13196 * undefined -> ''
13197 * true -> '1'
13198 * false -> '0'
13199 * 0 -> '0'
13200 * 1 -> '1'
13201 *
13202 */
13203 const hash_key = (value) => {
13204 if (typeof value === 'undefined' || value === null)
13205 return null;
13206 return get_hash(value);
13207 };
13208 const get_hash = (value) => {
13209 if (typeof value === 'boolean')
13210 return value ? '1' : '0';
13211 return value + '';
13212 };
13213 /**
13214 * Escapes a string for use within HTML.
13215 *
13216 */
13217 const escape_html = (str) => {
13218 return (str + '')
13219 .replace(/&/g, '&amp;')
13220 .replace(/</g, '&lt;')
13221 .replace(/>/g, '&gt;')
13222 .replace(/"/g, '&quot;');
13223 };
13224 /**
13225 * use setTimeout if timeout > 0
13226 */
13227 const timeout = (fn, timeout) => {
13228 if (timeout > 0) {
13229 return window.setTimeout(fn, timeout);
13230 }
13231 fn.call(null);
13232 return null;
13233 };
13234 /**
13235 * Debounce the user provided load function
13236 *
13237 */
13238 const loadDebounce = (fn, delay) => {
13239 var timeout;
13240 return function (value, callback) {
13241 var self = this;
13242 if (timeout) {
13243 self.loading = Math.max(self.loading - 1, 0);
13244 clearTimeout(timeout);
13245 }
13246 timeout = setTimeout(function () {
13247 timeout = null;
13248 self.loadedSearches[value] = true;
13249 fn.call(self, value, callback);
13250 }, delay);
13251 };
13252 };
13253 /**
13254 * Debounce all fired events types listed in `types`
13255 * while executing the provided `fn`.
13256 *
13257 */
13258 const debounce_events = (self, types, fn) => {
13259 var type;
13260 var trigger = self.trigger;
13261 var event_args = {};
13262 // override trigger method
13263 self.trigger = function () {
13264 var type = arguments[0];
13265 if (types.indexOf(type) !== -1) {
13266 event_args[type] = arguments;
13267 }
13268 else {
13269 return trigger.apply(self, arguments);
13270 }
13271 };
13272 // invoke provided function
13273 fn.apply(self, []);
13274 self.trigger = trigger;
13275 // trigger queued events
13276 for (type of types) {
13277 if (type in event_args) {
13278 trigger.apply(self, event_args[type]);
13279 }
13280 }
13281 };
13282 /**
13283 * Determines the current selection within a text input control.
13284 * Returns an object containing:
13285 * - start
13286 * - length
13287 *
13288 * Note: "selectionStart, selectionEnd ... apply only to inputs of types text, search, URL, tel and password"
13289 * - https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
13290 */
13291 const getSelection = (input) => {
13292 return {
13293 start: input.selectionStart || 0,
13294 length: (input.selectionEnd || 0) - (input.selectionStart || 0),
13295 };
13296 };
13297 /**
13298 * Prevent default
13299 *
13300 */
13301 const preventDefault = (evt, stop = false) => {
13302 if (evt) {
13303 evt.preventDefault();
13304 if (stop) {
13305 evt.stopPropagation();
13306 }
13307 }
13308 };
13309 /**
13310 * Add event helper
13311 *
13312 */
13313 const addEvent = (target, type, callback, options) => {
13314 target.addEventListener(type, callback, options);
13315 };
13316 /**
13317 * Return true if the requested key is down
13318 * Will return false if more than one control character is pressed ( when [ctrl+shift+a] != [ctrl+a] )
13319 * The current evt may not always set ( eg calling advanceSelection() )
13320 *
13321 */
13322 const isKeyDown = (key_name, evt) => {
13323 if (!evt) {
13324 return false;
13325 }
13326 if (!evt[key_name]) {
13327 return false;
13328 }
13329 var count = (evt.altKey ? 1 : 0) + (evt.ctrlKey ? 1 : 0) + (evt.shiftKey ? 1 : 0) + (evt.metaKey ? 1 : 0);
13330 if (count === 1) {
13331 return true;
13332 }
13333 return false;
13334 };
13335 /**
13336 * Get the id of an element
13337 * If the id attribute is not set, set the attribute with the given id
13338 *
13339 */
13340 const getId = (el, id) => {
13341 const existing_id = el.getAttribute('id');
13342 if (existing_id) {
13343 return existing_id;
13344 }
13345 el.setAttribute('id', id);
13346 return id;
13347 };
13348 /**
13349 * Returns a string with backslashes added before characters that need to be escaped.
13350 */
13351 const addSlashes = (str) => {
13352 return str.replace(/[\\"']/g, '\\$&');
13353 };
13354 /**
13355 *
13356 */
13357 const append = (parent, node) => {
13358 if (node)
13359 parent.append(node);
13360 };
13361 /**
13362 * Iterates over arrays and hashes.
13363 *
13364 * ```
13365 * iterate(this.items, function(item, id) {
13366 * // invoked for each item
13367 * });
13368 * ```
13369 *
13370 */
13371 const iterate = (object, callback) => {
13372 if (Array.isArray(object)) {
13373 object.forEach(callback);
13374 }
13375 else {
13376 for (var key in object) {
13377 if (object.hasOwnProperty(key)) {
13378 callback(object[key], key);
13379 }
13380 }
13381 }
13382 };
13383 //# sourceMappingURL=utils.js.map
13384
13385 /***/ },
13386
13387 /***/ "./node_modules/tom-select/dist/esm/vanilla.js"
13388 /*!*****************************************************!*\
13389 !*** ./node_modules/tom-select/dist/esm/vanilla.js ***!
13390 \*****************************************************/
13391 (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
13392
13393 "use strict";
13394 __webpack_require__.r(__webpack_exports__);
13395 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13396 /* harmony export */ addClasses: () => (/* binding */ addClasses),
13397 /* harmony export */ applyCSS: () => (/* binding */ applyCSS),
13398 /* harmony export */ castAsArray: () => (/* binding */ castAsArray),
13399 /* harmony export */ classesArray: () => (/* binding */ classesArray),
13400 /* harmony export */ escapeQuery: () => (/* binding */ escapeQuery),
13401 /* harmony export */ getDom: () => (/* binding */ getDom),
13402 /* harmony export */ getTail: () => (/* binding */ getTail),
13403 /* harmony export */ isEmptyObject: () => (/* binding */ isEmptyObject),
13404 /* harmony export */ isHtmlString: () => (/* binding */ isHtmlString),
13405 /* harmony export */ nodeIndex: () => (/* binding */ nodeIndex),
13406 /* harmony export */ parentMatch: () => (/* binding */ parentMatch),
13407 /* harmony export */ removeClasses: () => (/* binding */ removeClasses),
13408 /* harmony export */ replaceNode: () => (/* binding */ replaceNode),
13409 /* harmony export */ setAttr: () => (/* binding */ setAttr),
13410 /* harmony export */ triggerEvent: () => (/* binding */ triggerEvent)
13411 /* harmony export */ });
13412 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./utils.js */ "./node_modules/tom-select/dist/esm/utils.js");
13413
13414 /**
13415 * Return a dom element from either a dom query string, jQuery object, a dom element or html string
13416 * https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
13417 *
13418 * param query should be {}
13419 */
13420 const getDom = (query) => {
13421 if (query.jquery) {
13422 return query[0];
13423 }
13424 if (query instanceof HTMLElement) {
13425 return query;
13426 }
13427 if (isHtmlString(query)) {
13428 var tpl = document.createElement('template');
13429 tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
13430 return tpl.content.firstChild;
13431 }
13432 return document.querySelector(query);
13433 };
13434 const isHtmlString = (arg) => {
13435 if (typeof arg === 'string' && arg.indexOf('<') > -1) {
13436 return true;
13437 }
13438 return false;
13439 };
13440 const escapeQuery = (query) => {
13441 return query.replace(/['"\\]/g, '\\$&');
13442 };
13443 /**
13444 * Dispatch an event
13445 *
13446 */
13447 const triggerEvent = (dom_el, event_name) => {
13448 var event = document.createEvent('HTMLEvents');
13449 event.initEvent(event_name, true, false);
13450 dom_el.dispatchEvent(event);
13451 };
13452 /**
13453 * Apply CSS rules to a dom element
13454 *
13455 */
13456 const applyCSS = (dom_el, css) => {
13457 Object.assign(dom_el.style, css);
13458 };
13459 /**
13460 * Add css classes
13461 *
13462 */
13463 const addClasses = (elmts, ...classes) => {
13464 var norm_classes = classesArray(classes);
13465 elmts = castAsArray(elmts);
13466 elmts.map(el => {
13467 norm_classes.map(cls => {
13468 el.classList.add(cls);
13469 });
13470 });
13471 };
13472 /**
13473 * Remove css classes
13474 *
13475 */
13476 const removeClasses = (elmts, ...classes) => {
13477 var norm_classes = classesArray(classes);
13478 elmts = castAsArray(elmts);
13479 elmts.map(el => {
13480 norm_classes.map(cls => {
13481 el.classList.remove(cls);
13482 });
13483 });
13484 };
13485 /**
13486 * Return arguments
13487 *
13488 */
13489 const classesArray = (args) => {
13490 var classes = [];
13491 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(args, (_classes) => {
13492 if (typeof _classes === 'string') {
13493 _classes = _classes.trim().split(/[\t\n\f\r\s]/);
13494 }
13495 if (Array.isArray(_classes)) {
13496 classes = classes.concat(_classes);
13497 }
13498 });
13499 return classes.filter(Boolean);
13500 };
13501 /**
13502 * Create an array from arg if it's not already an array
13503 *
13504 */
13505 const castAsArray = (arg) => {
13506 if (!Array.isArray(arg)) {
13507 arg = [arg];
13508 }
13509 return arg;
13510 };
13511 /**
13512 * Get the closest node to the evt.target matching the selector
13513 * Stops at wrapper
13514 *
13515 */
13516 const parentMatch = (target, selector, wrapper) => {
13517 if (wrapper && !wrapper.contains(target)) {
13518 return;
13519 }
13520 while (target && target.matches) {
13521 if (target.matches(selector)) {
13522 return target;
13523 }
13524 target = target.parentNode;
13525 }
13526 };
13527 /**
13528 * Get the first or last item from an array
13529 *
13530 * > 0 - right (last)
13531 * <= 0 - left (first)
13532 *
13533 */
13534 const getTail = (list, direction = 0) => {
13535 if (direction > 0) {
13536 return list[list.length - 1];
13537 }
13538 return list[0];
13539 };
13540 /**
13541 * Return true if an object is empty
13542 *
13543 */
13544 const isEmptyObject = (obj) => {
13545 return (Object.keys(obj).length === 0);
13546 };
13547 /**
13548 * Get the index of an element amongst sibling nodes of the same type
13549 *
13550 */
13551 const nodeIndex = (el, amongst) => {
13552 if (!el)
13553 return -1;
13554 amongst = amongst || el.nodeName;
13555 var i = 0;
13556 while (el = el.previousElementSibling) {
13557 if (el.matches(amongst)) {
13558 i++;
13559 }
13560 }
13561 return i;
13562 };
13563 /**
13564 * Set attributes of an element
13565 *
13566 */
13567 const setAttr = (el, attrs) => {
13568 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.iterate)(attrs, (val, attr) => {
13569 if (val == null) {
13570 el.removeAttribute(attr);
13571 }
13572 else {
13573 el.setAttribute(attr, '' + val);
13574 }
13575 });
13576 };
13577 /**
13578 * Replace a node
13579 */
13580 const replaceNode = (existing, replacement) => {
13581 if (existing.parentNode)
13582 existing.parentNode.replaceChild(replacement, existing);
13583 };
13584 //# sourceMappingURL=vanilla.js.map
13585
13586 /***/ }
13587
13588 /******/ });
13589 /************************************************************************/
13590 /******/ // The module cache
13591 /******/ const __webpack_module_cache__ = {};
13592 /******/
13593 /******/ // The require function
13594 /******/ function __webpack_require__(moduleId) {
13595 /******/ // Check if module is in cache
13596 /******/ const cachedModule = __webpack_module_cache__[moduleId];
13597 /******/ if (cachedModule !== undefined) {
13598 /******/ return cachedModule.exports;
13599 /******/ }
13600 /******/ // Create a new module (and put it into the cache)
13601 /******/ const module = __webpack_module_cache__[moduleId] = {
13602 /******/ id: moduleId,
13603 /******/ // no module.loaded needed
13604 /******/ exports: {}
13605 /******/ };
13606 /******/
13607 /******/ // Execute the module function
13608 /******/ if (!(moduleId in __webpack_modules__)) {
13609 /******/ delete __webpack_module_cache__[moduleId];
13610 /******/ const e = new Error("Cannot find module '" + moduleId + "'");
13611 /******/ e.code = 'MODULE_NOT_FOUND';
13612 /******/ throw e;
13613 /******/ }
13614 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
13615 /******/
13616 /******/ // Return the exports of the module
13617 /******/ return module.exports;
13618 /******/ }
13619 /******/
13620 /************************************************************************/
13621 /******/ /* webpack/runtime/compat get default export */
13622 /******/ (() => {
13623 /******/ // getDefaultExport function for compatibility with non-harmony modules
13624 /******/ __webpack_require__.n = (module) => {
13625 /******/ const getter = module && module.__esModule ?
13626 /******/ () => (module['default']) :
13627 /******/ () => (module);
13628 /******/ __webpack_require__.d(getter, { a: getter });
13629 /******/ return getter;
13630 /******/ };
13631 /******/ })();
13632 /******/
13633 /******/ /* webpack/runtime/define property getters */
13634 /******/ (() => {
13635 /******/ // define getter/value functions for harmony exports
13636 /******/ __webpack_require__.d = (exports, definition) => {
13637 /******/ if(Array.isArray(definition)) {
13638 /******/ var i = 0;
13639 /******/ while(i < definition.length) {
13640 /******/ var key = definition[i++];
13641 /******/ var binding = definition[i++];
13642 /******/ if(!__webpack_require__.o(exports, key)) {
13643 /******/ if(binding === 0) {
13644 /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
13645 /******/ } else {
13646 /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
13647 /******/ }
13648 /******/ } else if(binding === 0) { i++; }
13649 /******/ }
13650 /******/ } else {
13651 /******/ for(var key in definition) {
13652 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13653 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
13654 /******/ }
13655 /******/ }
13656 /******/ }
13657 /******/ };
13658 /******/ })();
13659 /******/
13660 /******/ /* webpack/runtime/hasOwnProperty shorthand */
13661 /******/ (() => {
13662 /******/ __webpack_require__.o = (obj, prop) => (Object.hasOwn(obj, prop))
13663 /******/ })();
13664 /******/
13665 /******/ /* webpack/runtime/make namespace object */
13666 /******/ (() => {
13667 /******/ // define __esModule on exports
13668 /******/ __webpack_require__.r = (exports) => {
13669 /******/ if(Symbol.toStringTag) {
13670 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
13671 /******/ }
13672 /******/ Object.defineProperty(exports, '__esModule', { value: true });
13673 /******/ };
13674 /******/ })();
13675 /******/
13676 /******/ /* webpack/runtime/nonce */
13677 /******/ (() => {
13678 /******/ __webpack_require__.nc = undefined;
13679 /******/ })();
13680 /******/
13681 /************************************************************************/
13682 let __webpack_exports__ = {};
13683 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
13684 (() => {
13685 "use strict";
13686 /*!********************************************!*\
13687 !*** ./assets/src/js/admin/admin-order.js ***!
13688 \********************************************/
13689 __webpack_require__.r(__webpack_exports__);
13690 /* harmony import */ var _order_export_invoice__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./order/export_invoice */ "./assets/src/js/admin/order/export_invoice.js");
13691 /* 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");
13692 /* harmony import */ var _order_refund_order__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./order/refund-order */ "./assets/src/js/admin/order/refund-order.js");
13693
13694
13695 //import modalSearchCourses from './order/modal-search-courses';
13696
13697
13698 (0,_order_export_invoice__WEBPACK_IMPORTED_MODULE_0__["default"])();
13699 (0,_order_add_courses_to_order__WEBPACK_IMPORTED_MODULE_1__["default"])();
13700 (0,_order_refund_order__WEBPACK_IMPORTED_MODULE_2__["default"])();
13701 })();
13702
13703 /******/ })()
13704 ;
13705 //# sourceMappingURL=admin-order.js.map