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

profile.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.3.9, at assets/js/dist/frontend/profile.js

11,219 lines 404.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/courses/view-students-modal.js"
5 /*!************************************************************!*\
6 !*** ./assets/src/js/admin/courses/view-students-modal.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 */ ViewStudentsModal: () => (/* binding */ ViewStudentsModal)
14 /* harmony export */ });
15 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! sweetalert2 */ "./node_modules/sweetalert2/dist/sweetalert2.all.js");
16 /* harmony import */ var sweetalert2__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(sweetalert2__WEBPACK_IMPORTED_MODULE_0__);
17 /* harmony import */ var lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lpAssetsJsPath/utils.js */ "./assets/src/js/utils.js");
18
19
20 class ViewStudentsModal {
21 constructor() {
22 this.isRequesting = false;
23 this.activeCourseId = 0;
24 this.init();
25 }
26 static selectors = {
27 wrap: '#lp-modal-enrolled-wrap',
28 form: '#lp-modal-enrolled-form',
29 toolbarTemplate: '#lp-tmpl-enrolled-students-toolbar-modal',
30 targetTemplate: '#lp-tmpl-enrolled-students-target-modal',
31 toolbar: '.lp-enrolled-students-table-toolbar--modal',
32 courseTrigger: '.lp-btn-view-students',
33 searchInput: '#lp-modal-enrolled-search-input',
34 startDateInput: '#lp-modal-enrolled-filter-start-date',
35 endDateInput: '#lp-modal-enrolled-filter-end-date',
36 searchBtn: '.lp-enrolled-btn-search-modal',
37 clearBtn: '.lp-enrolled-btn-clear-modal',
38 modalSearchFields: '#lp-modal-enrolled-search-input, #lp-modal-enrolled-filter-start-date, #lp-modal-enrolled-filter-end-date'
39 };
40 setButtonLoadingState(btn, isLoading) {
41 if (!btn) {
42 return;
43 }
44 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.lpSetLoadingEl(btn, isLoading ? 1 : 0);
45 btn.disabled = !!isLoading;
46 }
47 init() {
48 if (ViewStudentsModal._loadedEvents) {
49 return;
50 }
51 ViewStudentsModal._loadedEvents = true;
52 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('click', [{
53 selector: ViewStudentsModal.selectors.courseTrigger,
54 class: this,
55 callBack: this.handleOpenModal.name
56 }, {
57 selector: ViewStudentsModal.selectors.searchBtn,
58 class: this,
59 callBack: this.handleModalSearch.name
60 }, {
61 selector: ViewStudentsModal.selectors.clearBtn,
62 class: this,
63 callBack: this.handleModalClear.name
64 }]);
65 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('keydown', [{
66 selector: ViewStudentsModal.selectors.modalSearchFields,
67 class: this,
68 callBack: this.handleModalSearchOnEnter.name,
69 checkIsEventEnter: true
70 }]);
71 lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.eventHandlers('change', [{
72 selector: ViewStudentsModal.selectors.startDateInput,
73 class: this,
74 callBack: this.checkDatesRange.name
75 }, {
76 selector: ViewStudentsModal.selectors.endDateInput,
77 class: this,
78 callBack: this.checkDatesRange.name
79 }]);
80 }
81 handleOpenModal(args) {
82 const btn = args?.target?.closest(ViewStudentsModal.selectors.courseTrigger);
83 if (!btn || this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
84 return;
85 }
86 const courseId = parseInt(btn.dataset.courseId, 10) || 0;
87 if (!courseId) {
88 return;
89 }
90 const courseTitle = btn.dataset.courseTitle || '';
91 this.activeCourseId = courseId;
92 this.setButtonLoadingState(btn, true);
93 this.openModal(courseId, courseTitle, btn);
94 }
95 handleModalSearch(args) {
96 const btn = args?.target?.closest(ViewStudentsModal.selectors.searchBtn);
97 if (!btn || !this.activeCourseId) {
98 return;
99 }
100 if (args?.e) {
101 args.e.preventDefault();
102 }
103 if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
104 return;
105 }
106 this.setButtonLoadingState(btn, true);
107 this.loadEnrolledStudents(this.activeCourseId, 1, btn);
108 }
109 handleModalSearchOnEnter(args) {
110 if (args?.e) {
111 args.e.preventDefault();
112 }
113 const form = this.getModalForm();
114 if (!form) {
115 return;
116 }
117 const btn = form.querySelector(ViewStudentsModal.selectors.searchBtn);
118 if (!btn) {
119 return;
120 }
121 this.handleModalSearch({
122 ...args,
123 target: btn
124 });
125 }
126 handleModalClear(args) {
127 const btn = args?.target?.closest(ViewStudentsModal.selectors.clearBtn);
128 const form = this.getModalForm();
129 if (!btn || !form || !this.activeCourseId) {
130 return;
131 }
132 if (args?.e) {
133 args.e.preventDefault();
134 }
135 if (this.isRequesting || btn.classList.contains('loading') || btn.disabled) {
136 return;
137 }
138 form.reset();
139 this.setButtonLoadingState(btn, true);
140 this.loadEnrolledStudents(this.activeCourseId, 1, btn);
141 }
142 getModalPopup() {
143 return (sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().getPopup) ? sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().getPopup() : null;
144 }
145 getModalToolbarHtml() {
146 const template = document.querySelector(ViewStudentsModal.selectors.toolbarTemplate);
147 return template ? template.innerHTML : '';
148 }
149 getModalTargetHtml() {
150 const template = document.querySelector(ViewStudentsModal.selectors.targetTemplate);
151 return template ? template.innerHTML : '';
152 }
153 getAjaxHandle() {
154 const ajaxHandle = window.lpAJAXG;
155 if (!ajaxHandle || typeof ajaxHandle.getDataSetCurrent !== 'function' || typeof ajaxHandle.setDataSetCurrent !== 'function' || typeof ajaxHandle.showHideLoading !== 'function' || typeof ajaxHandle.fetchAJAX !== 'function') {
156 return null;
157 }
158 return ajaxHandle;
159 }
160 getModalForm() {
161 const popup = this.getModalPopup();
162 if (!popup) {
163 return null;
164 }
165 return popup.querySelector(ViewStudentsModal.selectors.form);
166 }
167 getModalFilterArgs(dataArgs = {}) {
168 const form = this.getModalForm();
169 if (!form) {
170 return dataArgs;
171 }
172 return lpAssetsJsPath_utils_js__WEBPACK_IMPORTED_MODULE_1__.mergeDataWithDatForm(form, dataArgs);
173 }
174 loadEnrolledStudents(courseId, paged, elLoading = null) {
175 const wrap = document.querySelector(ViewStudentsModal.selectors.wrap);
176 const elTarget = wrap?.querySelector('.lp-target');
177 const ajaxHandle = this.getAjaxHandle();
178 if (!wrap || !elTarget || !ajaxHandle || this.isRequesting) {
179 return;
180 }
181 this.isRequesting = true;
182 if (elLoading) {
183 this.setButtonLoadingState(elLoading, true);
184 }
185 const dataSend = ajaxHandle.getDataSetCurrent(elTarget);
186 dataSend.args = this.getModalFilterArgs(dataSend.args || {});
187 dataSend.args.course_id = parseInt(courseId, 10) || 0;
188 dataSend.args.paged = paged;
189 ajaxHandle.setDataSetCurrent(elTarget, dataSend);
190 ajaxHandle.showHideLoading(elTarget, 1);
191 const callBack = {
192 success: response => {
193 elTarget.innerHTML = response.data.content;
194 },
195 error: err => {
196 console.error(err);
197 },
198 completed: () => {
199 this.isRequesting = false;
200 ajaxHandle.showHideLoading(elTarget, 0);
201 if (elLoading) {
202 this.setButtonLoadingState(elLoading, false);
203 }
204 }
205 };
206 ajaxHandle.fetchAJAX(dataSend, callBack);
207 }
208 openModal(courseId, courseTitle, elTrigger = null) {
209 const modalToolbarHtml = this.getModalToolbarHtml();
210 const modalTargetHtml = this.getModalTargetHtml();
211 if (!modalToolbarHtml || !modalTargetHtml) {
212 if (elTrigger) {
213 this.setButtonLoadingState(elTrigger, false);
214 }
215 return;
216 }
217 this.activeCourseId = parseInt(courseId, 10) || 0;
218 sweetalert2__WEBPACK_IMPORTED_MODULE_0___default().fire({
219 title: `${courseTitle}`,
220 html: modalToolbarHtml + modalTargetHtml,
221 width: '80%',
222 showConfirmButton: false,
223 showCloseButton: true,
224 didOpen: () => {
225 this.loadEnrolledStudents(this.activeCourseId, 1, elTrigger);
226 },
227 didClose: () => {
228 this.activeCourseId = 0;
229 if (elTrigger) {
230 this.setButtonLoadingState(elTrigger, false);
231 }
232 }
233 });
234 }
235
236 // Ensure start date is not after end date and vice versa. If invalid, adjust the other date to match.
237 checkDatesRange(args) {
238 const {
239 e
240 } = args;
241 const elInput = e?.target;
242 if (!elInput) {
243 return;
244 }
245 const elForm = elInput.closest(ViewStudentsModal.selectors.form);
246 if (!elForm) {
247 return;
248 }
249 const startDateInput = elForm.querySelector(ViewStudentsModal.selectors.startDateInput);
250 const endDateInput = elForm.querySelector(ViewStudentsModal.selectors.endDateInput);
251 if (elInput === startDateInput) {
252 if (startDateInput.value) {
253 endDateInput.min = startDateInput.value;
254 if (endDateInput.value && endDateInput.value < startDateInput.value) {
255 endDateInput.value = startDateInput.value;
256 }
257 } else {
258 endDateInput.min = '';
259 }
260 } else if (elInput === endDateInput) {
261 if (endDateInput.value) {
262 startDateInput.max = endDateInput.value;
263 if (startDateInput.value && startDateInput.value > endDateInput.value) {
264 startDateInput.value = endDateInput.value;
265 }
266 } else {
267 startDateInput.max = '';
268 }
269 }
270 }
271 }
272
273 /***/ },
274
275 /***/ "./assets/src/js/api.js"
276 /*!******************************!*\
277 !*** ./assets/src/js/api.js ***!
278 \******************************/
279 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
280
281 "use strict";
282 __webpack_require__.r(__webpack_exports__);
283 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
284 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
285 /* harmony export */ });
286 /**
287 * List API on backend
288 *
289 * @since 4.2.6
290 * @version 1.0.2
291 */
292
293 const lplistAPI = {};
294 let lp_rest_url;
295 if ('undefined' !== typeof lpDataAdmin) {
296 lp_rest_url = lpDataAdmin.lp_rest_url;
297 lplistAPI.admin = {
298 apiAdminNotice: lp_rest_url + 'lp/v1/admin/tools/admin-notices',
299 apiAddons: lp_rest_url + 'lp/v1/addon/all',
300 apiAddonAction: lp_rest_url + 'lp/v1/addon/action-n',
301 apiAddonsPurchase: lp_rest_url + 'lp/v1/addon/info-addons-purchase',
302 apiSearchCourses: lp_rest_url + 'lp/v1/admin/tools/search-course',
303 apiSearchUsers: lp_rest_url + 'lp/v1/admin/tools/search-user',
304 apiAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/assign-user-course',
305 apiUnAssignUserCourse: lp_rest_url + 'lp/v1/admin/tools/unassign-user-course'
306 };
307 }
308 if ('undefined' !== typeof lpData) {
309 lp_rest_url = lpData.lp_rest_url;
310 lplistAPI.frontend = {
311 apiWidgets: lp_rest_url + 'lp/v1/widgets/api',
312 apiCourses: lp_rest_url + 'lp/v1/courses/archive-course',
313 // Deprecated API, don't load from v4.3.7
314 apiAJAX: lp_rest_url + 'lp/v1/load_content_via_ajax/',
315 // Deprecated since 4.3.0
316 apiProfileCoverImage: lp_rest_url + 'lp/v1/profile/cover-image'
317 };
318 }
319 if (lp_rest_url) {
320 lplistAPI.apiCourses = lp_rest_url + 'lp/v1/courses/';
321 lplistAPI.apiEditCoursesArchiveBlock = lp_rest_url + 'lp/v1/courses/edit-archive-block';
322 lplistAPI.apiCoursesSuggest = lp_rest_url + 'lp/v1/courses/courses-suggest';
323 }
324 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (lplistAPI);
325
326 /***/ },
327
328 /***/ "./assets/src/js/frontend/profile/avatar.js"
329 /*!**************************************************!*\
330 !*** ./assets/src/js/frontend/profile/avatar.js ***!
331 \**************************************************/
332 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
333
334 "use strict";
335 __webpack_require__.r(__webpack_exports__);
336 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
337 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
338 /* harmony export */ });
339 /* harmony import */ var cropperjs_dist_cropper_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cropperjs/dist/cropper.css */ "./node_modules/cropperjs/dist/cropper.css");
340 /* harmony import */ var cropperjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! cropperjs */ "./node_modules/cropperjs/dist/cropper.js");
341 /* harmony import */ var cropperjs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(cropperjs__WEBPACK_IMPORTED_MODULE_1__);
342 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils.js */ "./assets/src/js/utils.js");
343 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
344 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_3__);
345 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
346
347
348
349 // import API from '../../api.js';
350
351
352 const profileAvatarImage = () => {
353 const lpAvatarWrapper = document.querySelector('#learnpress-avatar-upload');
354 if (!lpAvatarWrapper) {
355 return;
356 }
357 let cropper, avatarPreviewSrc, imgUrlOriginal;
358 let avatarForm = lpAvatarWrapper.querySelector('.lp_avatar__form');
359 const btnRemove = lpAvatarWrapper.querySelector('.lp-btn-remove-avatar'),
360 btnReplace = lpAvatarWrapper.querySelector('.lp-btn-choose-avatar'),
361 btnSave = lpAvatarWrapper.querySelector('.lp-btn-save-avatar'),
362 btnCancel = lpAvatarWrapper.querySelector('.lp-btn-cancel-avatar'),
363 avatarPreviewImage = lpAvatarWrapper.querySelector('.lp-avatar-image'),
364 avatarInputFile = lpAvatarWrapper.querySelector('#avatar-file'),
365 profileAvatar = document.querySelector('.wrapper-profile-header .user-avatar img');
366 const avatarRatio = parseFloat((lpProfileSettings.avatar_dimensions.width / lpProfileSettings.avatar_dimensions.height).toFixed(2));
367 lpAvatarWrapper.addEventListener('click', e => {
368 const target = e.target;
369 if (target === btnReplace) {
370 e.preventDefault();
371 avatarInputFile.click();
372 } else if (target === btnSave) {
373 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(btnSave, 1);
374 btnSave.disabled = true;
375 if (undefined !== cropper) {
376 const canvas = cropper.getCroppedCanvas({
377 width: lpProfileSettings.avatar_dimensions.width,
378 height: lpProfileSettings.avatar_dimensions.height
379 });
380 const newCropSrc = canvas.toDataURL('image/png');
381 if (profileAvatar) {
382 profileAvatar.src = newCropSrc;
383 }
384 avatarPreviewImage.src = newCropSrc;
385 const formData = new FormData();
386 formData.append('file', newCropSrc);
387 uploadAvatar(formData);
388 }
389 } else if (target === btnCancel) {
390 e.preventDefault();
391 cropper.destroy();
392 avatarPreviewImage.src = imgUrlOriginal;
393 if (imgUrlOriginal === window.location.href) {
394 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarForm, 1);
395 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnReplace, 0);
396 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarPreviewImage, 0);
397 } else {
398 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnRemove, 1);
399 }
400 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnSave, 0);
401 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnCancel, 0);
402 } else if (target === btnRemove) {
403 btnRemove.disabled = true;
404 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(btnRemove, 1);
405 removeAvatar();
406 }
407 });
408 lpAvatarWrapper.addEventListener('change', e => {
409 const target = e.target;
410 if (target === avatarInputFile) {
411 const file = avatarInputFile.files[0];
412 if (!file) {
413 return;
414 }
415 const allowType = ['image/png', 'image/jpeg', 'image/webp'];
416 if (allowType.indexOf(file.type) < 0) {
417 return;
418 }
419 const reader = new FileReader();
420 reader.onload = function (e) {
421 avatarPreviewImage.src = e.target.result;
422 // Destroy previous cropper instance if any
423 if (cropper) {
424 cropper.destroy();
425 }
426 // Initialize cropper
427 cropper = new (cropperjs__WEBPACK_IMPORTED_MODULE_1___default())(avatarPreviewImage, {
428 aspectRatio: avatarRatio,
429 viewMode: 1,
430 zoomOnWheel: false
431 });
432 };
433 reader.readAsDataURL(file);
434 if (!avatarPreviewImage.classList.contains('lp-hidden')) {
435 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarPreviewImage, 1);
436 }
437 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarForm, 0);
438 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnSave, 1);
439 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnReplace, 1);
440 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnCancel, 1);
441 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnRemove, 0);
442 }
443 });
444 const uploadAvatar = formData => {
445 fetch(`${lpData.lp_rest_url}lp/v1/profile/upload-avatar`, {
446 method: 'POST',
447 headers: {
448 'X-WP-Nonce': lpData.nonce
449 },
450 body: formData
451 }) // wrapped
452 .then(res => res.json()).then(res => {
453 if (res.status === 'error') {
454 throw new Error(res.message);
455 }
456 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarPreviewImage, 1);
457 showMessage('success', res.message);
458 if (undefined !== cropper) {
459 cropper.destroy();
460 }
461 imgUrlOriginal = avatarPreviewImage.src;
462 }).finally(() => {
463 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnSave, 0);
464 btnSave.disabled = false;
465 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(btnSave, 0);
466 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnCancel, 0);
467 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnRemove, 1);
468 }).catch(err => console.log(err));
469 };
470 const removeAvatar = () => {
471 fetch(`${lpData.lp_rest_url}lp/v1/profile/remove-avatar`, {
472 method: 'POST',
473 headers: {
474 'X-WP-Nonce': lpData.nonce
475 }
476 }) // wrapped
477 .then(res => res.json()).then(res => {
478 if (res.status === 'error') {
479 throw new Error(res.message);
480 }
481 showMessage('success', res.message);
482 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarPreviewImage, 0);
483 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(avatarForm, 1);
484 imgUrlOriginal = avatarPreviewSrc = '';
485 profileAvatar.src = lpProfileSettings.default_avatar;
486 // window.location.href = window.location.href;
487 }).finally(() => {
488 btnRemove.disabled = false;
489 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnRemove, 0);
490 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(btnRemove, 0);
491 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(btnReplace, 0);
492 }).catch(err => console.log(err));
493 };
494 const showMessage = (status, message) => {
495 toastify_js__WEBPACK_IMPORTED_MODULE_3___default()({
496 text: message,
497 gravity: lpData.toast.gravity,
498 // `top` or `bottom`
499 position: lpData.toast.position,
500 // `left`, `center` or `right`
501 className: `${lpData.toast.classPrefix} ${status}`,
502 close: lpData.toast.close == 1,
503 stopOnFocus: lpData.toast.stopOnFocus == 1,
504 duration: lpData.toast.duration
505 }).showToast();
506 };
507 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpOnElementReady('.lp-avatar-image', () => {
508 imgUrlOriginal = avatarPreviewImage.src;
509 });
510 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpOnElementReady('#learnpress-avatar-upload', e => {
511 e.scrollIntoView({
512 behavior: 'smooth',
513 block: 'center'
514 });
515 });
516 };
517 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (profileAvatarImage);
518
519 /***/ },
520
521 /***/ "./assets/src/js/frontend/profile/course-tab.js"
522 /*!******************************************************!*\
523 !*** ./assets/src/js/frontend/profile/course-tab.js ***!
524 \******************************************************/
525 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
526
527 "use strict";
528 __webpack_require__.r(__webpack_exports__);
529 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
530 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
531 /* harmony export */ });
532 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils.js */ "./assets/src/js/utils.js");
533
534
535 // Rest API load content course enrolled, created - Nhamdv.
536 const courseTab = () => {
537 const elements = document.querySelectorAll('.learn-press-course-tab__filter__content');
538 const getResponse = (ele, dataset, append = false, viewMoreEle = false) => {
539 let url = lpData.lp_rest_url + 'lp/v1/profile/course-tab';
540 url = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(url, dataset);
541 const callBack = {
542 success: response => {
543 const skeleton = ele.querySelector('.lp-skeleton-animation');
544 skeleton && skeleton.remove();
545 if (response.status === 'success' && response.data) {
546 if (append) {
547 ele.innerHTML += response.data;
548 } else {
549 ele.innerHTML = response.data;
550 }
551 } else if (append) {
552 ele.innerHTML += `<div class="lp-ajax-message" style="display:block">${response.message && response.message}</div>`;
553 } else {
554 ele.innerHTML = `<div class="lp-ajax-message" style="display:block">${response.message && response.message}</div>`;
555 }
556 if (viewMoreEle) {
557 viewMoreEle.classList.remove('loading');
558 const paged = parseInt(viewMoreEle.dataset.paged);
559 const numberPage = parseInt(viewMoreEle.dataset.number);
560 if (numberPage <= paged) {
561 viewMoreEle.remove();
562 }
563 viewMoreEle.dataset.paged = paged + 1;
564 }
565 viewMore(ele, dataset);
566 },
567 error: error => {
568 console.log(error);
569 },
570 completed: () => {}
571 };
572 let paramsFetch = {};
573 if (0 !== parseInt(lpData.user_id)) {
574 paramsFetch = {
575 headers: {
576 'X-WP-Nonce': lpData.nonce
577 }
578 };
579 }
580 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI)(url, paramsFetch, callBack);
581 };
582 if ('IntersectionObserver' in window) {
583 const eleObserver = new IntersectionObserver((entries, observer) => {
584 entries.forEach(entry => {
585 if (entry.isIntersecting) {
586 const ele = entry.target;
587 const params = ele.parentNode.querySelector('.lp_profile_tab_input_param');
588 const data = {
589 ...JSON.parse(params.value),
590 status: ele.dataset.tab || ''
591 };
592 getResponse(ele, data);
593 eleObserver.unobserve(ele);
594 }
595 });
596 });
597 [...elements].map(ele => {
598 if (ele.dataset.tab !== 'all') {
599 eleObserver.observe(ele);
600 } else {
601 const params = ele.parentNode.querySelector('.lp_profile_tab_input_param');
602 const data = {
603 ...JSON.parse(params.value),
604 status: ele.dataset.tab === 'all' ? '' : ele.dataset.tab || ''
605 };
606 getResponse(ele, data);
607 }
608 });
609 }
610 const changeFilter = () => {
611 const tabs = document.querySelectorAll('.learn-press-course-tab-filters');
612 tabs.forEach(tab => {
613 const filters = tab.querySelectorAll('.learn-press-filters a');
614 filters.forEach(filter => {
615 filter.addEventListener('click', e => {
616 e.preventDefault();
617 const tabName = filter.dataset.tab;
618 [...filters].map(ele => {
619 ele.classList.remove('active');
620 });
621 filter.classList.add('active');
622 [...tab.querySelectorAll('.learn-press-course-tab__filter__content')].map(ele => {
623 ele.style.display = 'none';
624 if (ele.dataset.tab === tabName) {
625 ele.style.display = '';
626 }
627 });
628 });
629 });
630 });
631 };
632 changeFilter();
633 const viewMore = (ele, dataset) => {
634 const viewMoreEle = ele.querySelector('button[data-paged]');
635 if (viewMoreEle) {
636 viewMoreEle.addEventListener('click', e => {
637 e.preventDefault();
638 const paged = viewMoreEle && viewMoreEle.dataset.paged;
639 viewMoreEle.classList.add('loading');
640 const element = dataset.layout === 'list' ? '.lp_profile_course_progress' : '.learn-press-courses';
641 getResponse(ele.querySelector(element), {
642 ...dataset,
643 ...{
644 paged
645 }
646 }, true, viewMoreEle);
647 });
648 }
649 };
650 };
651 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (courseTab);
652
653 /***/ },
654
655 /***/ "./assets/src/js/frontend/profile/cover-image.js"
656 /*!*******************************************************!*\
657 !*** ./assets/src/js/frontend/profile/cover-image.js ***!
658 \*******************************************************/
659 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
660
661 "use strict";
662 __webpack_require__.r(__webpack_exports__);
663 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
664 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
665 /* harmony export */ });
666 /* harmony import */ var cropperjs_dist_cropper_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! cropperjs/dist/cropper.css */ "./node_modules/cropperjs/dist/cropper.css");
667 /* harmony import */ var cropperjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! cropperjs */ "./node_modules/cropperjs/dist/cropper.js");
668 /* harmony import */ var cropperjs__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(cropperjs__WEBPACK_IMPORTED_MODULE_1__);
669 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../utils.js */ "./assets/src/js/utils.js");
670 /* harmony import */ var _api_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../api.js */ "./assets/src/js/api.js");
671 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
672 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_4__);
673 /* harmony import */ var toastify_js_src_toastify_css__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! toastify-js/src/toastify.css */ "./node_modules/toastify-js/src/toastify.css");
674
675
676
677
678
679
680 const profileCoverImage = () => {
681 const lpSet = new Set();
682 let cropper;
683 let elBtnSave, elBtnRemove, elBtnChoose, elBtnCancel, elImagePreview, elCoverImageBackground, elImgCoverImageBackground, elImageEmpty, formCoverImage, elInputFile, elAction, imgUrlOriginal;
684 const className = {
685 formCoverImage: 'lp-user-cover-image',
686 BtnChooseCoverImage: 'lp-btn-choose-cover-image',
687 BtnSaveCoverImage: 'lp-btn-save-cover-image',
688 BtnRemoveCoverImage: 'lp-btn-remove-cover-image',
689 BtnCancelCoverImage: 'lp-btn-cancel-cover-image',
690 BtnToEditCoverImage: 'lp-btn-to-edit-cover-image',
691 CoverImagePreview: 'lp-cover-image-preview',
692 CoverImageEmpty: 'lp-cover-image-empty',
693 CoverImageBackground: 'lp-user-cover-image_background',
694 InputFile: 'lp-cover-image-file',
695 loading: 'loading',
696 hidden: 'lp-hidden'
697 };
698
699 /**
700 * Get elements to use.
701 */
702 const getElements = () => {
703 elBtnSave = formCoverImage.querySelector(`.${className.BtnSaveCoverImage}`);
704 elBtnChoose = formCoverImage.querySelector(`.${className.BtnChooseCoverImage}`);
705 elBtnRemove = formCoverImage.querySelector(`.${className.BtnRemoveCoverImage}`);
706 elBtnCancel = formCoverImage.querySelector(`.${className.BtnCancelCoverImage}`);
707 elImagePreview = formCoverImage.querySelector(`.${className.CoverImagePreview}`);
708 elCoverImageBackground = document.querySelector(`.${className.CoverImageBackground}`);
709 elImgCoverImageBackground = elCoverImageBackground.querySelector(`img`);
710 elImageEmpty = formCoverImage.querySelector(`.${className.CoverImageEmpty}`);
711 elAction = formCoverImage.querySelector('input[name=action]');
712 elInputFile = formCoverImage.querySelector('input[name=lp-cover-image-file]');
713 if (!lpSet.has('everClick')) {
714 imgUrlOriginal = elImagePreview.src;
715 lpSet.add('everClick');
716 }
717 };
718 const fetchAPI = formData => {
719 const callBack = {
720 success: response => {
721 const {
722 status,
723 message,
724 data
725 } = response;
726 toastify_js__WEBPACK_IMPORTED_MODULE_4___default()({
727 text: message,
728 gravity: lpData.toast.gravity,
729 // `top` or `bottom`
730 position: lpData.toast.position,
731 // `left`, `center` or `right`
732 className: `${lpData.toast.classPrefix} ${status}`,
733 close: lpData.toast.close == 1,
734 stopOnFocus: lpData.toast.stopOnFocus == 1,
735 duration: lpData.toast.duration
736 }).showToast();
737 if ('remove' === data.action) {
738 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnRemove, 0);
739 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnChoose, 0);
740 elImagePreview.src = '';
741 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImagePreview, 0);
742 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImageEmpty, 1);
743 if (elCoverImageBackground) {
744 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elCoverImageBackground, 0);
745 }
746 } else if ('upload' === data.action) {
747 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImagePreview, 1);
748 elImagePreview.src = data.url;
749 imgUrlOriginal = data.url;
750 cropper.destroy();
751 }
752 imgUrlOriginal = elImagePreview.src;
753 },
754 error: error => {
755 console.log(error);
756 },
757 completed: () => {
758 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnSave, 0);
759 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(elBtnSave, 0);
760 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(elBtnRemove, 0);
761 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnCancel, 0);
762 if (!elImagePreview.src || elImagePreview.src === window.location.href) {
763 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnRemove, 0);
764 } else {
765 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnRemove, 1);
766 }
767 }
768 };
769 const url = _api_js__WEBPACK_IMPORTED_MODULE_3__["default"].frontend.apiProfileCoverImage;
770 const option = {
771 headers: {}
772 };
773 if (0 !== parseInt(lpData.user_id)) {
774 option.headers['X-WP-Nonce'] = lpData.nonce;
775 }
776 option.method = 'POST';
777 option.body = formData;
778 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpFetchAPI(url, option, callBack);
779 };
780
781 // Events
782 document.addEventListener('click', e => {
783 const target = e.target;
784 if (target.classList.contains(className.BtnToEditCoverImage)) {
785 formCoverImage = document.querySelector(`.${className.formCoverImage}`);
786 if (!formCoverImage) {
787 return;
788 }
789 const isCorrectSection = target.dataset.sectionCorrect == 1;
790 if (isCorrectSection) {
791 e.preventDefault();
792 formCoverImage.scrollIntoView({
793 behavior: 'smooth',
794 block: 'center'
795 });
796 }
797 }
798 formCoverImage = target.closest(`.${className.formCoverImage}`);
799 if (!formCoverImage) {
800 return;
801 }
802 getElements();
803 if (target.classList.contains(className.BtnChooseCoverImage)) {
804 e.preventDefault();
805 elInputFile.click();
806 }
807 if (target.classList.contains(className.BtnSaveCoverImage)) {
808 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpSetLoadingEl(elBtnSave, 1);
809 }
810 if (target.classList.contains(className.BtnCancelCoverImage)) {
811 e.preventDefault();
812 cropper.destroy();
813 elImagePreview.src = imgUrlOriginal;
814 if (imgUrlOriginal === window.location.href) {
815 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImageEmpty, 1);
816 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnChoose, 0);
817 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImagePreview, 0);
818 } else {
819 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnRemove, 1);
820 }
821 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnSave, 0);
822 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnCancel, 0);
823 }
824 if (target.classList.contains(className.BtnRemoveCoverImage)) {
825 e.preventDefault();
826 target.classList.add('loading');
827 if (cropper) {
828 cropper.destroy();
829 cropper = undefined;
830 }
831 elAction.value = 'remove';
832 elBtnSave.click();
833 }
834 if (target.classList.contains(className.CoverImageEmpty)) {
835 e.preventDefault();
836 elInputFile.click();
837 }
838 });
839 document.addEventListener('change', e => {
840 const target = e.target;
841 formCoverImage = target.closest(`.${className.formCoverImage}`);
842 if (!formCoverImage) {
843 return;
844 }
845 getElements();
846 if (target.classList.contains(className.InputFile)) {
847 e.preventDefault();
848 const file = target.files[0];
849 if (!file) {
850 return;
851 }
852 const allowType = ['image/png', 'image/jpeg', 'image/webp'];
853 if (allowType.indexOf(file.type) < 0) {
854 return;
855 }
856 elAction.value = 'upload';
857 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImagePreview, 1);
858 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elImageEmpty, 0);
859 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnRemove, 0);
860 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnSave, 1);
861 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnChoose, 1);
862 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elBtnCancel, 1);
863 const reader = new FileReader();
864 reader.onload = function (e) {
865 elImagePreview.src = e.target.result;
866 // Destroy previous cropper instance if any
867 if (cropper) {
868 cropper.destroy();
869 }
870 // Initialize cropper
871 cropper = new (cropperjs__WEBPACK_IMPORTED_MODULE_1___default())(elImagePreview, {
872 aspectRatio: lpData.coverImageRatio,
873 viewMode: 1,
874 zoomOnWheel: false
875 });
876 };
877 reader.readAsDataURL(file);
878 }
879 });
880 document.addEventListener('submit', e => {
881 const target = e.target;
882 if (target.classList.contains(className.formCoverImage)) {
883 e.preventDefault();
884 const formData = new FormData(target);
885 if (undefined !== cropper) {
886 const canvas = cropper.getCroppedCanvas({});
887 if (elCoverImageBackground) {
888 const dataUrl = canvas.toDataURL('image/png');
889 elCoverImageBackground.style.backgroundImage = `url(${dataUrl})`;
890 elImgCoverImageBackground.src = dataUrl;
891 _utils_js__WEBPACK_IMPORTED_MODULE_2__.lpShowHideEl(elCoverImageBackground, 1);
892 }
893 canvas.toBlob(blob => {
894 formData.append('image', blob, 'cover.png');
895 fetchAPI(formData);
896 }, 'image/png');
897 } else {
898 fetchAPI(formData);
899 }
900 }
901 });
902 document.addEventListener('DOMContentLoaded', e => {
903 const elBtnToEditCoverImage = document.querySelector(`.${className.BtnToEditCoverImage}`);
904 const formCoverImage = document.querySelector(`.${className.formCoverImage}`);
905 if (elBtnToEditCoverImage && formCoverImage) {
906 const isCorrectSection = elBtnToEditCoverImage.dataset.sectionCorrect == 1;
907 if (isCorrectSection) {
908 formCoverImage.scrollIntoView({
909 behavior: 'smooth',
910 block: 'center'
911 });
912 }
913 }
914 });
915 };
916 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (profileCoverImage);
917
918 /***/ },
919
920 /***/ "./assets/src/js/frontend/profile/order-recover.js"
921 /*!*********************************************************!*\
922 !*** ./assets/src/js/frontend/profile/order-recover.js ***!
923 \*********************************************************/
924 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
925
926 "use strict";
927 __webpack_require__.r(__webpack_exports__);
928 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
929 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
930 /* harmony export */ });
931 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils.js */ "./assets/src/js/utils.js");
932 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! toastify-js */ "./node_modules/toastify-js/src/toastify.js");
933 /* harmony import */ var toastify_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(toastify_js__WEBPACK_IMPORTED_MODULE_1__);
934
935
936
937 /**
938 * JS Recover order
939 *
940 * @since 4.0.0
941 * @version 1.0.1
942 */
943 const recoverOrder = () => {
944 const toastify = toastify_js__WEBPACK_IMPORTED_MODULE_1___default()({
945 gravity: lpData.toast.gravity,
946 // `top` or `bottom`
947 position: lpData.toast.position,
948 // `left`, `center` or `right`
949 close: lpData.toast.close == 1,
950 className: `${lpData.toast.classPrefix}`,
951 stopOnFocus: lpData.toast.stopOnFocus == 1,
952 duration: lpData.toast.duration
953 });
954
955 // Events
956 document.addEventListener('submit', e => {
957 const target = e.target;
958 if (target.classList.contains('lp-order-recover')) {
959 e.preventDefault();
960 ajaxRecover(target);
961 }
962 });
963 const ajaxRecover = form => {
964 const status = 'error';
965 const btnSubmit = form.querySelector('.button-recover-order');
966 if (!btnSubmit) {
967 return;
968 }
969 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl)(btnSubmit, 1);
970 const url = new URL(window.location.href);
971 fetch(url, {
972 method: 'POST',
973 body: new FormData(form)
974 }).then(response => {
975 return response.json();
976 }).then(res => {
977 const {
978 status,
979 data: {
980 redirect
981 },
982 message
983 } = res;
984 if (status === 'success') {
985 toastify.options.text = message;
986 toastify.options.className += ` ${status}`;
987 toastify.showToast();
988 if (redirect) {
989 window.location.href = redirect;
990 }
991 btnSubmit.remove();
992 } else {
993 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpSetLoadingEl)(btnSubmit, 0);
994 throw new Error(message);
995 }
996 }).finally(() => {}).catch(err => {
997 toastify.options.text = err.message;
998 toastify.options.className += ` ${status}`;
999 toastify.showToast();
1000 });
1001 };
1002 };
1003 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (recoverOrder);
1004
1005 /***/ },
1006
1007 /***/ "./assets/src/js/frontend/profile/quiz.js"
1008 /*!************************************************!*\
1009 !*** ./assets/src/js/frontend/profile/quiz.js ***!
1010 \************************************************/
1011 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1012
1013 "use strict";
1014 __webpack_require__.r(__webpack_exports__);
1015 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1016 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1017 /* harmony export */ });
1018 /**
1019 * Handle click tab call API
1020 *
1021 * @since 4.2.8.2
1022 * @version 1.0.0
1023 */
1024 const profileQuizTab = () => {
1025 const handleClickTab = (e, target) => {
1026 if (target.closest('span')) {
1027 const elParent = target.closest('#profile-content-quizzes');
1028 if (!elParent) {
1029 return;
1030 }
1031 const elLPTarget = target.closest('.lp-target');
1032 if (!elLPTarget) {
1033 return;
1034 }
1035 window.lpAJAXG.showHideLoading(elLPTarget, 1);
1036 const dataSendJson = elLPTarget?.dataset?.send || {};
1037 const dataSend = JSON.parse(dataSendJson);
1038 const elTabChoice = target?.dataset?.filter || 'all';
1039 const liActive = elParent.querySelector('li.active');
1040 if (liActive.classList.contains(elTabChoice)) {
1041 return;
1042 }
1043 liActive.classList.remove('active');
1044 const liTarget = target.closest('li');
1045 liTarget.classList.add('active');
1046 dataSend.args.type = elTabChoice;
1047
1048 // Load list courses by AJAX.
1049 const callBack = {
1050 success: response => {
1051 const {
1052 data,
1053 message,
1054 status
1055 } = response;
1056 if ('success' === status) {
1057 elLPTarget.innerHTML = data.content || '';
1058 }
1059 },
1060 error: error => {
1061 console.log(error);
1062 },
1063 completed: () => {
1064 window.lpAJAXG.showHideLoading(elLPTarget, 0);
1065 }
1066 };
1067 window.lpAJAXG.fetchAJAX(dataSend, callBack);
1068 }
1069 };
1070 document.addEventListener('click', e => {
1071 const target = e.target;
1072 handleClickTab(e, target);
1073 });
1074 };
1075 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (profileQuizTab);
1076
1077 /***/ },
1078
1079 /***/ "./assets/src/js/frontend/profile/statistic.js"
1080 /*!*****************************************************!*\
1081 !*** ./assets/src/js/frontend/profile/statistic.js ***!
1082 \*****************************************************/
1083 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1084
1085 "use strict";
1086 __webpack_require__.r(__webpack_exports__);
1087 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1088 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
1089 /* harmony export */ });
1090 /* harmony import */ var _utils_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../utils.js */ "./assets/src/js/utils.js");
1091
1092
1093 // Rest API load content course progress - Nhamdv.
1094 const courseStatistics = () => {
1095 const loadAPICourseStatistic = elCourseStatistic => {
1096 let apiUrl = 'lp/v1/profile/student/statistic';
1097 const tabActive = document.querySelector('.lp-profile-nav-tabs li.active');
1098 if (!tabActive) {
1099 return;
1100 }
1101 if (tabActive.classList.contains('courses')) {
1102 apiUrl = 'lp/v1/profile/instructor/statistic';
1103 }
1104 const elArgStatistic = elCourseStatistic.querySelector('[name="args_query_user_courses_statistic"]');
1105 if (!elArgStatistic) {
1106 return;
1107 }
1108 const data = JSON.parse(elArgStatistic.value);
1109 const callBack = {
1110 success: response => {
1111 if (response.status === 'success' && response.data) {
1112 elCourseStatistic.innerHTML = response.data;
1113 } else {
1114 elCourseStatistic.innerHTML = `<div class="lp-ajax-message error" style="display:block">${response.message && response.message}</div>`;
1115 }
1116 },
1117 error: error => {
1118 console.log(error);
1119 },
1120 completed: () => {}
1121 };
1122 apiUrl = (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpAddQueryArgs)(lpData.lp_rest_url + apiUrl, data);
1123 if (0 !== parseInt(lpData.user_id)) {
1124 data.headers = {
1125 'X-WP-Nonce': lpData.nonce
1126 };
1127 }
1128 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpFetchAPI)(apiUrl, data, callBack);
1129 };
1130 (0,_utils_js__WEBPACK_IMPORTED_MODULE_0__.lpOnElementReady)('.learn-press-profile-course__statistic', elCourseStatistic => {
1131 loadAPICourseStatistic(elCourseStatistic);
1132 });
1133 };
1134 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (courseStatistics);
1135
1136 /***/ },
1137
1138 /***/ "./assets/src/js/utils.js"
1139 /*!********************************!*\
1140 !*** ./assets/src/js/utils.js ***!
1141 \********************************/
1142 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1143
1144 "use strict";
1145 __webpack_require__.r(__webpack_exports__);
1146 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1147 /* harmony export */ debounce: () => (/* binding */ debounce),
1148 /* harmony export */ eventHandlers: () => (/* binding */ eventHandlers),
1149 /* harmony export */ getDataOfForm: () => (/* binding */ getDataOfForm),
1150 /* harmony export */ getFieldKeysOfForm: () => (/* binding */ getFieldKeysOfForm),
1151 /* harmony export */ listenElementCreated: () => (/* binding */ listenElementCreated),
1152 /* harmony export */ listenElementViewed: () => (/* binding */ listenElementViewed),
1153 /* harmony export */ lpAddQueryArgs: () => (/* binding */ lpAddQueryArgs),
1154 /* harmony export */ lpAjaxParseJsonOld: () => (/* binding */ lpAjaxParseJsonOld),
1155 /* harmony export */ lpClassName: () => (/* binding */ lpClassName),
1156 /* harmony export */ lpFetchAPI: () => (/* binding */ lpFetchAPI),
1157 /* harmony export */ lpGetCurrentURLNoParam: () => (/* binding */ lpGetCurrentURLNoParam),
1158 /* harmony export */ lpOnElementReady: () => (/* binding */ lpOnElementReady),
1159 /* harmony export */ lpSetLoadingEl: () => (/* binding */ lpSetLoadingEl),
1160 /* harmony export */ lpShowHideEl: () => (/* binding */ lpShowHideEl),
1161 /* harmony export */ mergeDataWithDatForm: () => (/* binding */ mergeDataWithDatForm),
1162 /* harmony export */ toggleCollapse: () => (/* binding */ toggleCollapse)
1163 /* harmony export */ });
1164 /**
1165 * Utils functions
1166 *
1167 * @param url
1168 * @param data
1169 * @param functions
1170 * @since 4.2.5.1
1171 * @version 1.0.6
1172 */
1173 const lpClassName = {
1174 hidden: 'lp-hidden',
1175 loading: 'loading',
1176 elCollapse: 'lp-collapse',
1177 elSectionToggle: '.lp-section-toggle',
1178 elTriggerToggle: '.lp-trigger-toggle'
1179 };
1180 const lpFetchAPI = (url, data = {}, functions = {}) => {
1181 if ('function' === typeof functions.before) {
1182 functions.before();
1183 }
1184 fetch(url, {
1185 method: 'GET',
1186 ...data
1187 }).then(response => response.json()).then(response => {
1188 if ('function' === typeof functions.success) {
1189 functions.success(response);
1190 }
1191 }).catch(err => {
1192 if ('function' === typeof functions.error) {
1193 functions.error(err);
1194 }
1195 }).finally(() => {
1196 if ('function' === typeof functions.completed) {
1197 functions.completed();
1198 }
1199 });
1200 };
1201
1202 /**
1203 * Get current URL without params.
1204 *
1205 * @since 4.2.5.1
1206 */
1207 const lpGetCurrentURLNoParam = () => {
1208 let currentUrl = window.location.href;
1209 const hasParams = currentUrl.includes('?');
1210 if (hasParams) {
1211 currentUrl = currentUrl.split('?')[0];
1212 }
1213 return currentUrl;
1214 };
1215 const lpAddQueryArgs = (endpoint, args) => {
1216 const url = new URL(endpoint);
1217 Object.keys(args).forEach(arg => {
1218 url.searchParams.set(arg, args[arg]);
1219 });
1220 return url;
1221 };
1222
1223 /**
1224 * Listen element viewed.
1225 *
1226 * @param el
1227 * @param callback
1228 * @since 4.2.5.8
1229 */
1230 const listenElementViewed = (el, callback) => {
1231 const observerSeeItem = new IntersectionObserver(function (entries) {
1232 for (const entry of entries) {
1233 if (entry.isIntersecting) {
1234 callback(entry);
1235 }
1236 }
1237 });
1238 observerSeeItem.observe(el);
1239 };
1240
1241 /**
1242 * Listen element created.
1243 *
1244 * @param callback
1245 * @since 4.2.5.8
1246 */
1247 const listenElementCreated = callback => {
1248 const observerCreateItem = new MutationObserver(function (mutations) {
1249 mutations.forEach(function (mutation) {
1250 if (mutation.addedNodes) {
1251 mutation.addedNodes.forEach(function (node) {
1252 if (node.nodeType === 1) {
1253 callback(node);
1254 }
1255 });
1256 }
1257 });
1258 });
1259 observerCreateItem.observe(document, {
1260 childList: true,
1261 subtree: true
1262 });
1263 // End.
1264 };
1265
1266 /**
1267 * Listen element created.
1268 *
1269 * @param selector
1270 * @param callback
1271 * @since 4.2.7.1
1272 */
1273 const lpOnElementReady = (selector, callback) => {
1274 const element = document.querySelector(selector);
1275 if (element) {
1276 callback(element);
1277 return;
1278 }
1279 const observer = new MutationObserver((mutations, obs) => {
1280 const element = document.querySelector(selector);
1281 if (element) {
1282 obs.disconnect();
1283 callback(element);
1284 }
1285 });
1286 observer.observe(document.documentElement, {
1287 childList: true,
1288 subtree: true
1289 });
1290 };
1291
1292 // Parse JSON from string with content include LP_AJAX_START.
1293 const lpAjaxParseJsonOld = data => {
1294 if (typeof data !== 'string') {
1295 return data;
1296 }
1297 const m = String.raw({
1298 raw: data
1299 }).match(/<-- LP_AJAX_START -->(.*)<-- LP_AJAX_END -->/s);
1300 try {
1301 if (m) {
1302 data = JSON.parse(m[1].replace(/(?:\r\n|\r|\n)/g, ''));
1303 } else {
1304 data = JSON.parse(data);
1305 }
1306 } catch (e) {
1307 data = {};
1308 }
1309 return data;
1310 };
1311
1312 // status 0: hide, 1: show
1313 const lpShowHideEl = (el, status = 0) => {
1314 if (!el) {
1315 return;
1316 }
1317 if (!status) {
1318 el.classList.add(lpClassName.hidden);
1319 } else {
1320 el.classList.remove(lpClassName.hidden);
1321 }
1322 };
1323
1324 // status 0: hide, 1: show
1325 const lpSetLoadingEl = (el, status) => {
1326 if (!el) {
1327 return;
1328 }
1329 if (!status) {
1330 el.classList.remove(lpClassName.loading);
1331 } else {
1332 el.classList.add(lpClassName.loading);
1333 }
1334 };
1335
1336 // Toggle collapse section
1337 const toggleCollapse = (e, target, elTriggerClassName = '', elsExclude = [], callback) => {
1338 if (!elTriggerClassName) {
1339 elTriggerClassName = lpClassName.elTriggerToggle;
1340 }
1341
1342 // Exclude elements, which should not trigger the collapse toggle
1343 if (elsExclude && elsExclude.length > 0) {
1344 for (const elExclude of elsExclude) {
1345 if (target.closest(elExclude)) {
1346 return;
1347 }
1348 }
1349 }
1350 const elTrigger = target.closest(elTriggerClassName);
1351 if (!elTrigger) {
1352 return;
1353 }
1354
1355 //console.log( 'elTrigger', elTrigger );
1356
1357 const elSectionToggle = elTrigger.closest(`${lpClassName.elSectionToggle}`);
1358 if (!elSectionToggle) {
1359 return;
1360 }
1361 elSectionToggle.classList.toggle(`${lpClassName.elCollapse}`);
1362 if ('function' === typeof callback) {
1363 callback(elSectionToggle);
1364 }
1365 };
1366
1367 // Get data of form
1368 const getDataOfForm = form => {
1369 const dataSend = {};
1370 const formData = new FormData(form);
1371 for (const pair of formData.entries()) {
1372 const key = pair[0];
1373 const value = formData.getAll(key);
1374 if (!dataSend.hasOwnProperty(key)) {
1375 // Convert value array to string.
1376 dataSend[key] = value.join(',');
1377 }
1378 }
1379 return dataSend;
1380 };
1381
1382 // Get field keys of form
1383 const getFieldKeysOfForm = form => {
1384 const keys = [];
1385 const elements = form.elements;
1386 for (let i = 0; i < elements.length; i++) {
1387 const name = elements[i].name;
1388 if (name && !keys.includes(name)) {
1389 keys.push(name);
1390 }
1391 }
1392 return keys;
1393 };
1394
1395 // Merge data handle with data form.
1396 const mergeDataWithDatForm = (elForm, dataHandle) => {
1397 const dataForm = getDataOfForm(elForm);
1398 const keys = getFieldKeysOfForm(elForm);
1399 keys.forEach(key => {
1400 if (!dataForm.hasOwnProperty(key)) {
1401 delete dataHandle[key];
1402 } else if (dataForm[key][0] === '') {
1403 delete dataForm[key];
1404 delete dataHandle[key];
1405 }
1406 });
1407 dataHandle = {
1408 ...dataHandle,
1409 ...dataForm
1410 };
1411 return dataHandle;
1412 };
1413
1414 /**
1415 * Event trigger
1416 * For each list of event handlers, listen event on document.
1417 *
1418 * eventName: 'click', 'change', ...
1419 * eventHandlers = [ { selector: '.lp-button', callBack: function(){}, class: object } ]
1420 *
1421 * @param eventName
1422 * @param eventHandlers
1423 */
1424 const eventHandlers = (eventName, eventHandlers) => {
1425 document.addEventListener(eventName, e => {
1426 const target = e.target;
1427 let args = {
1428 e,
1429 target
1430 };
1431 eventHandlers.forEach(eventHandler => {
1432 args = {
1433 ...args,
1434 ...eventHandler
1435 };
1436
1437 //console.log( args );
1438
1439 // Check condition before call back
1440 if (eventHandler.conditionBeforeCallBack) {
1441 if (eventHandler.conditionBeforeCallBack(args) !== true) {
1442 return;
1443 }
1444 }
1445
1446 // Special check for keydown event with checkIsEventEnter = true
1447 if (eventName === 'keydown' && eventHandler.checkIsEventEnter) {
1448 if (e.key !== 'Enter') {
1449 return;
1450 }
1451 }
1452 if (target.closest(eventHandler.selector)) {
1453 if (eventHandler.class) {
1454 // Call method of class, function callBack will understand exactly {this} is class object.
1455 eventHandler.class[eventHandler.callBack](args);
1456 } else {
1457 // For send args is objected, {this} is eventHandler object, not class object.
1458 eventHandler.callBack(args);
1459 }
1460 }
1461 });
1462 });
1463 };
1464
1465 /**
1466 * Debounce - delays function execution until after `wait` ms of inactivity.
1467 *
1468 * Each call resets the timer. Only the last call in a burst executes.
1469 *
1470 * USE CASES:
1471 * - Search inputs, form validation, window resize
1472 * - Multiple elements need independent timers
1473 * - When you need to call with different arguments
1474 *
1475 * EXAMPLES:
1476 * const debouncedSearch = debounce( (query) => fetchResults(query), 300 );
1477 * searchInput.addEventListener('input', (e) => debouncedSearch(e.target.value));
1478 *
1479 * const debouncedResize = debounce( recalculateLayout, 250 );
1480 * window.addEventListener('resize', debouncedResize);
1481 *
1482 * ⚠️ Create ONCE outside event handlers, not inside.
1483 *
1484 * @param {Function} func - Function to debounce (can be anonymous)
1485 * @param {number} wait - Milliseconds to wait (default: 500)
1486 * @return {Function} Debounced wrapper function
1487 * @since 4.3.7
1488 * @version 1.0.0
1489 */
1490 const debounce = (func, wait = 500) => {
1491 let timer;
1492 return args => {
1493 clearTimeout(timer);
1494 timer = setTimeout(() => func(args), wait);
1495 };
1496 };
1497
1498 /***/ },
1499
1500 /***/ "./node_modules/cropperjs/dist/cropper.js"
1501 /*!************************************************!*\
1502 !*** ./node_modules/cropperjs/dist/cropper.js ***!
1503 \************************************************/
1504 (module) {
1505
1506 /*!
1507 * Cropper.js v1.6.2
1508 * https://fengyuanchen.github.io/cropperjs
1509 *
1510 * Copyright 2015-present Chen Fengyuan
1511 * Released under the MIT license
1512 *
1513 * Date: 2024-04-21T07:43:05.335Z
1514 */
1515
1516 (function (global, factory) {
1517 true ? module.exports = factory() :
1518 0;
1519 })(this, (function () { 'use strict';
1520
1521 function ownKeys(e, r) {
1522 var t = Object.keys(e);
1523 if (Object.getOwnPropertySymbols) {
1524 var o = Object.getOwnPropertySymbols(e);
1525 r && (o = o.filter(function (r) {
1526 return Object.getOwnPropertyDescriptor(e, r).enumerable;
1527 })), t.push.apply(t, o);
1528 }
1529 return t;
1530 }
1531 function _objectSpread2(e) {
1532 for (var r = 1; r < arguments.length; r++) {
1533 var t = null != arguments[r] ? arguments[r] : {};
1534 r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
1535 _defineProperty(e, r, t[r]);
1536 }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
1537 Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1538 });
1539 }
1540 return e;
1541 }
1542 function _toPrimitive(t, r) {
1543 if ("object" != typeof t || !t) return t;
1544 var e = t[Symbol.toPrimitive];
1545 if (void 0 !== e) {
1546 var i = e.call(t, r || "default");
1547 if ("object" != typeof i) return i;
1548 throw new TypeError("@@toPrimitive must return a primitive value.");
1549 }
1550 return ("string" === r ? String : Number)(t);
1551 }
1552 function _toPropertyKey(t) {
1553 var i = _toPrimitive(t, "string");
1554 return "symbol" == typeof i ? i : i + "";
1555 }
1556 function _typeof(o) {
1557 "@babel/helpers - typeof";
1558
1559 return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
1560 return typeof o;
1561 } : function (o) {
1562 return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1563 }, _typeof(o);
1564 }
1565 function _classCallCheck(instance, Constructor) {
1566 if (!(instance instanceof Constructor)) {
1567 throw new TypeError("Cannot call a class as a function");
1568 }
1569 }
1570 function _defineProperties(target, props) {
1571 for (var i = 0; i < props.length; i++) {
1572 var descriptor = props[i];
1573 descriptor.enumerable = descriptor.enumerable || false;
1574 descriptor.configurable = true;
1575 if ("value" in descriptor) descriptor.writable = true;
1576 Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
1577 }
1578 }
1579 function _createClass(Constructor, protoProps, staticProps) {
1580 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
1581 if (staticProps) _defineProperties(Constructor, staticProps);
1582 Object.defineProperty(Constructor, "prototype", {
1583 writable: false
1584 });
1585 return Constructor;
1586 }
1587 function _defineProperty(obj, key, value) {
1588 key = _toPropertyKey(key);
1589 if (key in obj) {
1590 Object.defineProperty(obj, key, {
1591 value: value,
1592 enumerable: true,
1593 configurable: true,
1594 writable: true
1595 });
1596 } else {
1597 obj[key] = value;
1598 }
1599 return obj;
1600 }
1601 function _toConsumableArray(arr) {
1602 return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
1603 }
1604 function _arrayWithoutHoles(arr) {
1605 if (Array.isArray(arr)) return _arrayLikeToArray(arr);
1606 }
1607 function _iterableToArray(iter) {
1608 if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1609 }
1610 function _unsupportedIterableToArray(o, minLen) {
1611 if (!o) return;
1612 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
1613 var n = Object.prototype.toString.call(o).slice(8, -1);
1614 if (n === "Object" && o.constructor) n = o.constructor.name;
1615 if (n === "Map" || n === "Set") return Array.from(o);
1616 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
1617 }
1618 function _arrayLikeToArray(arr, len) {
1619 if (len == null || len > arr.length) len = arr.length;
1620 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
1621 return arr2;
1622 }
1623 function _nonIterableSpread() {
1624 throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
1625 }
1626
1627 var IS_BROWSER = typeof window !== 'undefined' && typeof window.document !== 'undefined';
1628 var WINDOW = IS_BROWSER ? window : {};
1629 var IS_TOUCH_DEVICE = IS_BROWSER && WINDOW.document.documentElement ? 'ontouchstart' in WINDOW.document.documentElement : false;
1630 var HAS_POINTER_EVENT = IS_BROWSER ? 'PointerEvent' in WINDOW : false;
1631 var NAMESPACE = 'cropper';
1632
1633 // Actions
1634 var ACTION_ALL = 'all';
1635 var ACTION_CROP = 'crop';
1636 var ACTION_MOVE = 'move';
1637 var ACTION_ZOOM = 'zoom';
1638 var ACTION_EAST = 'e';
1639 var ACTION_WEST = 'w';
1640 var ACTION_SOUTH = 's';
1641 var ACTION_NORTH = 'n';
1642 var ACTION_NORTH_EAST = 'ne';
1643 var ACTION_NORTH_WEST = 'nw';
1644 var ACTION_SOUTH_EAST = 'se';
1645 var ACTION_SOUTH_WEST = 'sw';
1646
1647 // Classes
1648 var CLASS_CROP = "".concat(NAMESPACE, "-crop");
1649 var CLASS_DISABLED = "".concat(NAMESPACE, "-disabled");
1650 var CLASS_HIDDEN = "".concat(NAMESPACE, "-hidden");
1651 var CLASS_HIDE = "".concat(NAMESPACE, "-hide");
1652 var CLASS_INVISIBLE = "".concat(NAMESPACE, "-invisible");
1653 var CLASS_MODAL = "".concat(NAMESPACE, "-modal");
1654 var CLASS_MOVE = "".concat(NAMESPACE, "-move");
1655
1656 // Data keys
1657 var DATA_ACTION = "".concat(NAMESPACE, "Action");
1658 var DATA_PREVIEW = "".concat(NAMESPACE, "Preview");
1659
1660 // Drag modes
1661 var DRAG_MODE_CROP = 'crop';
1662 var DRAG_MODE_MOVE = 'move';
1663 var DRAG_MODE_NONE = 'none';
1664
1665 // Events
1666 var EVENT_CROP = 'crop';
1667 var EVENT_CROP_END = 'cropend';
1668 var EVENT_CROP_MOVE = 'cropmove';
1669 var EVENT_CROP_START = 'cropstart';
1670 var EVENT_DBLCLICK = 'dblclick';
1671 var EVENT_TOUCH_START = IS_TOUCH_DEVICE ? 'touchstart' : 'mousedown';
1672 var EVENT_TOUCH_MOVE = IS_TOUCH_DEVICE ? 'touchmove' : 'mousemove';
1673 var EVENT_TOUCH_END = IS_TOUCH_DEVICE ? 'touchend touchcancel' : 'mouseup';
1674 var EVENT_POINTER_DOWN = HAS_POINTER_EVENT ? 'pointerdown' : EVENT_TOUCH_START;
1675 var EVENT_POINTER_MOVE = HAS_POINTER_EVENT ? 'pointermove' : EVENT_TOUCH_MOVE;
1676 var EVENT_POINTER_UP = HAS_POINTER_EVENT ? 'pointerup pointercancel' : EVENT_TOUCH_END;
1677 var EVENT_READY = 'ready';
1678 var EVENT_RESIZE = 'resize';
1679 var EVENT_WHEEL = 'wheel';
1680 var EVENT_ZOOM = 'zoom';
1681
1682 // Mime types
1683 var MIME_TYPE_JPEG = 'image/jpeg';
1684
1685 // RegExps
1686 var REGEXP_ACTIONS = /^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/;
1687 var REGEXP_DATA_URL = /^data:/;
1688 var REGEXP_DATA_URL_JPEG = /^data:image\/jpeg;base64,/;
1689 var REGEXP_TAG_NAME = /^img|canvas$/i;
1690
1691 // Misc
1692 // Inspired by the default width and height of a canvas element.
1693 var MIN_CONTAINER_WIDTH = 200;
1694 var MIN_CONTAINER_HEIGHT = 100;
1695
1696 var DEFAULTS = {
1697 // Define the view mode of the cropper
1698 viewMode: 0,
1699 // 0, 1, 2, 3
1700
1701 // Define the dragging mode of the cropper
1702 dragMode: DRAG_MODE_CROP,
1703 // 'crop', 'move' or 'none'
1704
1705 // Define the initial aspect ratio of the crop box
1706 initialAspectRatio: NaN,
1707 // Define the aspect ratio of the crop box
1708 aspectRatio: NaN,
1709 // An object with the previous cropping result data
1710 data: null,
1711 // A selector for adding extra containers to preview
1712 preview: '',
1713 // Re-render the cropper when resize the window
1714 responsive: true,
1715 // Restore the cropped area after resize the window
1716 restore: true,
1717 // Check if the current image is a cross-origin image
1718 checkCrossOrigin: true,
1719 // Check the current image's Exif Orientation information
1720 checkOrientation: true,
1721 // Show the black modal
1722 modal: true,
1723 // Show the dashed lines for guiding
1724 guides: true,
1725 // Show the center indicator for guiding
1726 center: true,
1727 // Show the white modal to highlight the crop box
1728 highlight: true,
1729 // Show the grid background
1730 background: true,
1731 // Enable to crop the image automatically when initialize
1732 autoCrop: true,
1733 // Define the percentage of automatic cropping area when initializes
1734 autoCropArea: 0.8,
1735 // Enable to move the image
1736 movable: true,
1737 // Enable to rotate the image
1738 rotatable: true,
1739 // Enable to scale the image
1740 scalable: true,
1741 // Enable to zoom the image
1742 zoomable: true,
1743 // Enable to zoom the image by dragging touch
1744 zoomOnTouch: true,
1745 // Enable to zoom the image by wheeling mouse
1746 zoomOnWheel: true,
1747 // Define zoom ratio when zoom the image by wheeling mouse
1748 wheelZoomRatio: 0.1,
1749 // Enable to move the crop box
1750 cropBoxMovable: true,
1751 // Enable to resize the crop box
1752 cropBoxResizable: true,
1753 // Toggle drag mode between "crop" and "move" when click twice on the cropper
1754 toggleDragModeOnDblclick: true,
1755 // Size limitation
1756 minCanvasWidth: 0,
1757 minCanvasHeight: 0,
1758 minCropBoxWidth: 0,
1759 minCropBoxHeight: 0,
1760 minContainerWidth: MIN_CONTAINER_WIDTH,
1761 minContainerHeight: MIN_CONTAINER_HEIGHT,
1762 // Shortcuts of events
1763 ready: null,
1764 cropstart: null,
1765 cropmove: null,
1766 cropend: null,
1767 crop: null,
1768 zoom: null
1769 };
1770
1771 var TEMPLATE = '<div class="cropper-container" touch-action="none">' + '<div class="cropper-wrap-box">' + '<div class="cropper-canvas"></div>' + '</div>' + '<div class="cropper-drag-box"></div>' + '<div class="cropper-crop-box">' + '<span class="cropper-view-box"></span>' + '<span class="cropper-dashed dashed-h"></span>' + '<span class="cropper-dashed dashed-v"></span>' + '<span class="cropper-center"></span>' + '<span class="cropper-face"></span>' + '<span class="cropper-line line-e" data-cropper-action="e"></span>' + '<span class="cropper-line line-n" data-cropper-action="n"></span>' + '<span class="cropper-line line-w" data-cropper-action="w"></span>' + '<span class="cropper-line line-s" data-cropper-action="s"></span>' + '<span class="cropper-point point-e" data-cropper-action="e"></span>' + '<span class="cropper-point point-n" data-cropper-action="n"></span>' + '<span class="cropper-point point-w" data-cropper-action="w"></span>' + '<span class="cropper-point point-s" data-cropper-action="s"></span>' + '<span class="cropper-point point-ne" data-cropper-action="ne"></span>' + '<span class="cropper-point point-nw" data-cropper-action="nw"></span>' + '<span class="cropper-point point-sw" data-cropper-action="sw"></span>' + '<span class="cropper-point point-se" data-cropper-action="se"></span>' + '</div>' + '</div>';
1772
1773 /**
1774 * Check if the given value is not a number.
1775 */
1776 var isNaN = Number.isNaN || WINDOW.isNaN;
1777
1778 /**
1779 * Check if the given value is a number.
1780 * @param {*} value - The value to check.
1781 * @returns {boolean} Returns `true` if the given value is a number, else `false`.
1782 */
1783 function isNumber(value) {
1784 return typeof value === 'number' && !isNaN(value);
1785 }
1786
1787 /**
1788 * Check if the given value is a positive number.
1789 * @param {*} value - The value to check.
1790 * @returns {boolean} Returns `true` if the given value is a positive number, else `false`.
1791 */
1792 var isPositiveNumber = function isPositiveNumber(value) {
1793 return value > 0 && value < Infinity;
1794 };
1795
1796 /**
1797 * Check if the given value is undefined.
1798 * @param {*} value - The value to check.
1799 * @returns {boolean} Returns `true` if the given value is undefined, else `false`.
1800 */
1801 function isUndefined(value) {
1802 return typeof value === 'undefined';
1803 }
1804
1805 /**
1806 * Check if the given value is an object.
1807 * @param {*} value - The value to check.
1808 * @returns {boolean} Returns `true` if the given value is an object, else `false`.
1809 */
1810 function isObject(value) {
1811 return _typeof(value) === 'object' && value !== null;
1812 }
1813 var hasOwnProperty = Object.prototype.hasOwnProperty;
1814
1815 /**
1816 * Check if the given value is a plain object.
1817 * @param {*} value - The value to check.
1818 * @returns {boolean} Returns `true` if the given value is a plain object, else `false`.
1819 */
1820 function isPlainObject(value) {
1821 if (!isObject(value)) {
1822 return false;
1823 }
1824 try {
1825 var _constructor = value.constructor;
1826 var prototype = _constructor.prototype;
1827 return _constructor && prototype && hasOwnProperty.call(prototype, 'isPrototypeOf');
1828 } catch (error) {
1829 return false;
1830 }
1831 }
1832
1833 /**
1834 * Check if the given value is a function.
1835 * @param {*} value - The value to check.
1836 * @returns {boolean} Returns `true` if the given value is a function, else `false`.
1837 */
1838 function isFunction(value) {
1839 return typeof value === 'function';
1840 }
1841 var slice = Array.prototype.slice;
1842
1843 /**
1844 * Convert array-like or iterable object to an array.
1845 * @param {*} value - The value to convert.
1846 * @returns {Array} Returns a new array.
1847 */
1848 function toArray(value) {
1849 return Array.from ? Array.from(value) : slice.call(value);
1850 }
1851
1852 /**
1853 * Iterate the given data.
1854 * @param {*} data - The data to iterate.
1855 * @param {Function} callback - The process function for each element.
1856 * @returns {*} The original data.
1857 */
1858 function forEach(data, callback) {
1859 if (data && isFunction(callback)) {
1860 if (Array.isArray(data) || isNumber(data.length) /* array-like */) {
1861 toArray(data).forEach(function (value, key) {
1862 callback.call(data, value, key, data);
1863 });
1864 } else if (isObject(data)) {
1865 Object.keys(data).forEach(function (key) {
1866 callback.call(data, data[key], key, data);
1867 });
1868 }
1869 }
1870 return data;
1871 }
1872
1873 /**
1874 * Extend the given object.
1875 * @param {*} target - The target object to extend.
1876 * @param {*} args - The rest objects for merging to the target object.
1877 * @returns {Object} The extended object.
1878 */
1879 var assign = Object.assign || function assign(target) {
1880 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1881 args[_key - 1] = arguments[_key];
1882 }
1883 if (isObject(target) && args.length > 0) {
1884 args.forEach(function (arg) {
1885 if (isObject(arg)) {
1886 Object.keys(arg).forEach(function (key) {
1887 target[key] = arg[key];
1888 });
1889 }
1890 });
1891 }
1892 return target;
1893 };
1894 var REGEXP_DECIMALS = /\.\d*(?:0|9){12}\d*$/;
1895
1896 /**
1897 * Normalize decimal number.
1898 * Check out {@link https://0.30000000000000004.com/}
1899 * @param {number} value - The value to normalize.
1900 * @param {number} [times=100000000000] - The times for normalizing.
1901 * @returns {number} Returns the normalized number.
1902 */
1903 function normalizeDecimalNumber(value) {
1904 var times = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100000000000;
1905 return REGEXP_DECIMALS.test(value) ? Math.round(value * times) / times : value;
1906 }
1907 var REGEXP_SUFFIX = /^width|height|left|top|marginLeft|marginTop$/;
1908
1909 /**
1910 * Apply styles to the given element.
1911 * @param {Element} element - The target element.
1912 * @param {Object} styles - The styles for applying.
1913 */
1914 function setStyle(element, styles) {
1915 var style = element.style;
1916 forEach(styles, function (value, property) {
1917 if (REGEXP_SUFFIX.test(property) && isNumber(value)) {
1918 value = "".concat(value, "px");
1919 }
1920 style[property] = value;
1921 });
1922 }
1923
1924 /**
1925 * Check if the given element has a special class.
1926 * @param {Element} element - The element to check.
1927 * @param {string} value - The class to search.
1928 * @returns {boolean} Returns `true` if the special class was found.
1929 */
1930 function hasClass(element, value) {
1931 return element.classList ? element.classList.contains(value) : element.className.indexOf(value) > -1;
1932 }
1933
1934 /**
1935 * Add classes to the given element.
1936 * @param {Element} element - The target element.
1937 * @param {string} value - The classes to be added.
1938 */
1939 function addClass(element, value) {
1940 if (!value) {
1941 return;
1942 }
1943 if (isNumber(element.length)) {
1944 forEach(element, function (elem) {
1945 addClass(elem, value);
1946 });
1947 return;
1948 }
1949 if (element.classList) {
1950 element.classList.add(value);
1951 return;
1952 }
1953 var className = element.className.trim();
1954 if (!className) {
1955 element.className = value;
1956 } else if (className.indexOf(value) < 0) {
1957 element.className = "".concat(className, " ").concat(value);
1958 }
1959 }
1960
1961 /**
1962 * Remove classes from the given element.
1963 * @param {Element} element - The target element.
1964 * @param {string} value - The classes to be removed.
1965 */
1966 function removeClass(element, value) {
1967 if (!value) {
1968 return;
1969 }
1970 if (isNumber(element.length)) {
1971 forEach(element, function (elem) {
1972 removeClass(elem, value);
1973 });
1974 return;
1975 }
1976 if (element.classList) {
1977 element.classList.remove(value);
1978 return;
1979 }
1980 if (element.className.indexOf(value) >= 0) {
1981 element.className = element.className.replace(value, '');
1982 }
1983 }
1984
1985 /**
1986 * Add or remove classes from the given element.
1987 * @param {Element} element - The target element.
1988 * @param {string} value - The classes to be toggled.
1989 * @param {boolean} added - Add only.
1990 */
1991 function toggleClass(element, value, added) {
1992 if (!value) {
1993 return;
1994 }
1995 if (isNumber(element.length)) {
1996 forEach(element, function (elem) {
1997 toggleClass(elem, value, added);
1998 });
1999 return;
2000 }
2001
2002 // IE10-11 doesn't support the second parameter of `classList.toggle`
2003 if (added) {
2004 addClass(element, value);
2005 } else {
2006 removeClass(element, value);
2007 }
2008 }
2009 var REGEXP_CAMEL_CASE = /([a-z\d])([A-Z])/g;
2010
2011 /**
2012 * Transform the given string from camelCase to kebab-case
2013 * @param {string} value - The value to transform.
2014 * @returns {string} The transformed value.
2015 */
2016 function toParamCase(value) {
2017 return value.replace(REGEXP_CAMEL_CASE, '$1-$2').toLowerCase();
2018 }
2019
2020 /**
2021 * Get data from the given element.
2022 * @param {Element} element - The target element.
2023 * @param {string} name - The data key to get.
2024 * @returns {string} The data value.
2025 */
2026 function getData(element, name) {
2027 if (isObject(element[name])) {
2028 return element[name];
2029 }
2030 if (element.dataset) {
2031 return element.dataset[name];
2032 }
2033 return element.getAttribute("data-".concat(toParamCase(name)));
2034 }
2035
2036 /**
2037 * Set data to the given element.
2038 * @param {Element} element - The target element.
2039 * @param {string} name - The data key to set.
2040 * @param {string} data - The data value.
2041 */
2042 function setData(element, name, data) {
2043 if (isObject(data)) {
2044 element[name] = data;
2045 } else if (element.dataset) {
2046 element.dataset[name] = data;
2047 } else {
2048 element.setAttribute("data-".concat(toParamCase(name)), data);
2049 }
2050 }
2051
2052 /**
2053 * Remove data from the given element.
2054 * @param {Element} element - The target element.
2055 * @param {string} name - The data key to remove.
2056 */
2057 function removeData(element, name) {
2058 if (isObject(element[name])) {
2059 try {
2060 delete element[name];
2061 } catch (error) {
2062 element[name] = undefined;
2063 }
2064 } else if (element.dataset) {
2065 // #128 Safari not allows to delete dataset property
2066 try {
2067 delete element.dataset[name];
2068 } catch (error) {
2069 element.dataset[name] = undefined;
2070 }
2071 } else {
2072 element.removeAttribute("data-".concat(toParamCase(name)));
2073 }
2074 }
2075 var REGEXP_SPACES = /\s\s*/;
2076 var onceSupported = function () {
2077 var supported = false;
2078 if (IS_BROWSER) {
2079 var once = false;
2080 var listener = function listener() {};
2081 var options = Object.defineProperty({}, 'once', {
2082 get: function get() {
2083 supported = true;
2084 return once;
2085 },
2086 /**
2087 * This setter can fix a `TypeError` in strict mode
2088 * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Getter_only}
2089 * @param {boolean} value - The value to set
2090 */
2091 set: function set(value) {
2092 once = value;
2093 }
2094 });
2095 WINDOW.addEventListener('test', listener, options);
2096 WINDOW.removeEventListener('test', listener, options);
2097 }
2098 return supported;
2099 }();
2100
2101 /**
2102 * Remove event listener from the target element.
2103 * @param {Element} element - The event target.
2104 * @param {string} type - The event type(s).
2105 * @param {Function} listener - The event listener.
2106 * @param {Object} options - The event options.
2107 */
2108 function removeListener(element, type, listener) {
2109 var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2110 var handler = listener;
2111 type.trim().split(REGEXP_SPACES).forEach(function (event) {
2112 if (!onceSupported) {
2113 var listeners = element.listeners;
2114 if (listeners && listeners[event] && listeners[event][listener]) {
2115 handler = listeners[event][listener];
2116 delete listeners[event][listener];
2117 if (Object.keys(listeners[event]).length === 0) {
2118 delete listeners[event];
2119 }
2120 if (Object.keys(listeners).length === 0) {
2121 delete element.listeners;
2122 }
2123 }
2124 }
2125 element.removeEventListener(event, handler, options);
2126 });
2127 }
2128
2129 /**
2130 * Add event listener to the target element.
2131 * @param {Element} element - The event target.
2132 * @param {string} type - The event type(s).
2133 * @param {Function} listener - The event listener.
2134 * @param {Object} options - The event options.
2135 */
2136 function addListener(element, type, listener) {
2137 var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2138 var _handler = listener;
2139 type.trim().split(REGEXP_SPACES).forEach(function (event) {
2140 if (options.once && !onceSupported) {
2141 var _element$listeners = element.listeners,
2142 listeners = _element$listeners === void 0 ? {} : _element$listeners;
2143 _handler = function handler() {
2144 delete listeners[event][listener];
2145 element.removeEventListener(event, _handler, options);
2146 for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
2147 args[_key2] = arguments[_key2];
2148 }
2149 listener.apply(element, args);
2150 };
2151 if (!listeners[event]) {
2152 listeners[event] = {};
2153 }
2154 if (listeners[event][listener]) {
2155 element.removeEventListener(event, listeners[event][listener], options);
2156 }
2157 listeners[event][listener] = _handler;
2158 element.listeners = listeners;
2159 }
2160 element.addEventListener(event, _handler, options);
2161 });
2162 }
2163
2164 /**
2165 * Dispatch event on the target element.
2166 * @param {Element} element - The event target.
2167 * @param {string} type - The event type(s).
2168 * @param {Object} data - The additional event data.
2169 * @returns {boolean} Indicate if the event is default prevented or not.
2170 */
2171 function dispatchEvent(element, type, data) {
2172 var event;
2173
2174 // Event and CustomEvent on IE9-11 are global objects, not constructors
2175 if (isFunction(Event) && isFunction(CustomEvent)) {
2176 event = new CustomEvent(type, {
2177 detail: data,
2178 bubbles: true,
2179 cancelable: true
2180 });
2181 } else {
2182 event = document.createEvent('CustomEvent');
2183 event.initCustomEvent(type, true, true, data);
2184 }
2185 return element.dispatchEvent(event);
2186 }
2187
2188 /**
2189 * Get the offset base on the document.
2190 * @param {Element} element - The target element.
2191 * @returns {Object} The offset data.
2192 */
2193 function getOffset(element) {
2194 var box = element.getBoundingClientRect();
2195 return {
2196 left: box.left + (window.pageXOffset - document.documentElement.clientLeft),
2197 top: box.top + (window.pageYOffset - document.documentElement.clientTop)
2198 };
2199 }
2200 var location = WINDOW.location;
2201 var REGEXP_ORIGINS = /^(\w+:)\/\/([^:/?#]*):?(\d*)/i;
2202
2203 /**
2204 * Check if the given URL is a cross origin URL.
2205 * @param {string} url - The target URL.
2206 * @returns {boolean} Returns `true` if the given URL is a cross origin URL, else `false`.
2207 */
2208 function isCrossOriginURL(url) {
2209 var parts = url.match(REGEXP_ORIGINS);
2210 return parts !== null && (parts[1] !== location.protocol || parts[2] !== location.hostname || parts[3] !== location.port);
2211 }
2212
2213 /**
2214 * Add timestamp to the given URL.
2215 * @param {string} url - The target URL.
2216 * @returns {string} The result URL.
2217 */
2218 function addTimestamp(url) {
2219 var timestamp = "timestamp=".concat(new Date().getTime());
2220 return url + (url.indexOf('?') === -1 ? '?' : '&') + timestamp;
2221 }
2222
2223 /**
2224 * Get transforms base on the given object.
2225 * @param {Object} obj - The target object.
2226 * @returns {string} A string contains transform values.
2227 */
2228 function getTransforms(_ref) {
2229 var rotate = _ref.rotate,
2230 scaleX = _ref.scaleX,
2231 scaleY = _ref.scaleY,
2232 translateX = _ref.translateX,
2233 translateY = _ref.translateY;
2234 var values = [];
2235 if (isNumber(translateX) && translateX !== 0) {
2236 values.push("translateX(".concat(translateX, "px)"));
2237 }
2238 if (isNumber(translateY) && translateY !== 0) {
2239 values.push("translateY(".concat(translateY, "px)"));
2240 }
2241
2242 // Rotate should come first before scale to match orientation transform
2243 if (isNumber(rotate) && rotate !== 0) {
2244 values.push("rotate(".concat(rotate, "deg)"));
2245 }
2246 if (isNumber(scaleX) && scaleX !== 1) {
2247 values.push("scaleX(".concat(scaleX, ")"));
2248 }
2249 if (isNumber(scaleY) && scaleY !== 1) {
2250 values.push("scaleY(".concat(scaleY, ")"));
2251 }
2252 var transform = values.length ? values.join(' ') : 'none';
2253 return {
2254 WebkitTransform: transform,
2255 msTransform: transform,
2256 transform: transform
2257 };
2258 }
2259
2260 /**
2261 * Get the max ratio of a group of pointers.
2262 * @param {string} pointers - The target pointers.
2263 * @returns {number} The result ratio.
2264 */
2265 function getMaxZoomRatio(pointers) {
2266 var pointers2 = _objectSpread2({}, pointers);
2267 var maxRatio = 0;
2268 forEach(pointers, function (pointer, pointerId) {
2269 delete pointers2[pointerId];
2270 forEach(pointers2, function (pointer2) {
2271 var x1 = Math.abs(pointer.startX - pointer2.startX);
2272 var y1 = Math.abs(pointer.startY - pointer2.startY);
2273 var x2 = Math.abs(pointer.endX - pointer2.endX);
2274 var y2 = Math.abs(pointer.endY - pointer2.endY);
2275 var z1 = Math.sqrt(x1 * x1 + y1 * y1);
2276 var z2 = Math.sqrt(x2 * x2 + y2 * y2);
2277 var ratio = (z2 - z1) / z1;
2278 if (Math.abs(ratio) > Math.abs(maxRatio)) {
2279 maxRatio = ratio;
2280 }
2281 });
2282 });
2283 return maxRatio;
2284 }
2285
2286 /**
2287 * Get a pointer from an event object.
2288 * @param {Object} event - The target event object.
2289 * @param {boolean} endOnly - Indicates if only returns the end point coordinate or not.
2290 * @returns {Object} The result pointer contains start and/or end point coordinates.
2291 */
2292 function getPointer(_ref2, endOnly) {
2293 var pageX = _ref2.pageX,
2294 pageY = _ref2.pageY;
2295 var end = {
2296 endX: pageX,
2297 endY: pageY
2298 };
2299 return endOnly ? end : _objectSpread2({
2300 startX: pageX,
2301 startY: pageY
2302 }, end);
2303 }
2304
2305 /**
2306 * Get the center point coordinate of a group of pointers.
2307 * @param {Object} pointers - The target pointers.
2308 * @returns {Object} The center point coordinate.
2309 */
2310 function getPointersCenter(pointers) {
2311 var pageX = 0;
2312 var pageY = 0;
2313 var count = 0;
2314 forEach(pointers, function (_ref3) {
2315 var startX = _ref3.startX,
2316 startY = _ref3.startY;
2317 pageX += startX;
2318 pageY += startY;
2319 count += 1;
2320 });
2321 pageX /= count;
2322 pageY /= count;
2323 return {
2324 pageX: pageX,
2325 pageY: pageY
2326 };
2327 }
2328
2329 /**
2330 * Get the max sizes in a rectangle under the given aspect ratio.
2331 * @param {Object} data - The original sizes.
2332 * @param {string} [type='contain'] - The adjust type.
2333 * @returns {Object} The result sizes.
2334 */
2335 function getAdjustedSizes(_ref4) {
2336 var aspectRatio = _ref4.aspectRatio,
2337 height = _ref4.height,
2338 width = _ref4.width;
2339 var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'contain';
2340 var isValidWidth = isPositiveNumber(width);
2341 var isValidHeight = isPositiveNumber(height);
2342 if (isValidWidth && isValidHeight) {
2343 var adjustedWidth = height * aspectRatio;
2344 if (type === 'contain' && adjustedWidth > width || type === 'cover' && adjustedWidth < width) {
2345 height = width / aspectRatio;
2346 } else {
2347 width = height * aspectRatio;
2348 }
2349 } else if (isValidWidth) {
2350 height = width / aspectRatio;
2351 } else if (isValidHeight) {
2352 width = height * aspectRatio;
2353 }
2354 return {
2355 width: width,
2356 height: height
2357 };
2358 }
2359
2360 /**
2361 * Get the new sizes of a rectangle after rotated.
2362 * @param {Object} data - The original sizes.
2363 * @returns {Object} The result sizes.
2364 */
2365 function getRotatedSizes(_ref5) {
2366 var width = _ref5.width,
2367 height = _ref5.height,
2368 degree = _ref5.degree;
2369 degree = Math.abs(degree) % 180;
2370 if (degree === 90) {
2371 return {
2372 width: height,
2373 height: width
2374 };
2375 }
2376 var arc = degree % 90 * Math.PI / 180;
2377 var sinArc = Math.sin(arc);
2378 var cosArc = Math.cos(arc);
2379 var newWidth = width * cosArc + height * sinArc;
2380 var newHeight = width * sinArc + height * cosArc;
2381 return degree > 90 ? {
2382 width: newHeight,
2383 height: newWidth
2384 } : {
2385 width: newWidth,
2386 height: newHeight
2387 };
2388 }
2389
2390 /**
2391 * Get a canvas which drew the given image.
2392 * @param {HTMLImageElement} image - The image for drawing.
2393 * @param {Object} imageData - The image data.
2394 * @param {Object} canvasData - The canvas data.
2395 * @param {Object} options - The options.
2396 * @returns {HTMLCanvasElement} The result canvas.
2397 */
2398 function getSourceCanvas(image, _ref6, _ref7, _ref8) {
2399 var imageAspectRatio = _ref6.aspectRatio,
2400 imageNaturalWidth = _ref6.naturalWidth,
2401 imageNaturalHeight = _ref6.naturalHeight,
2402 _ref6$rotate = _ref6.rotate,
2403 rotate = _ref6$rotate === void 0 ? 0 : _ref6$rotate,
2404 _ref6$scaleX = _ref6.scaleX,
2405 scaleX = _ref6$scaleX === void 0 ? 1 : _ref6$scaleX,
2406 _ref6$scaleY = _ref6.scaleY,
2407 scaleY = _ref6$scaleY === void 0 ? 1 : _ref6$scaleY;
2408 var aspectRatio = _ref7.aspectRatio,
2409 naturalWidth = _ref7.naturalWidth,
2410 naturalHeight = _ref7.naturalHeight;
2411 var _ref8$fillColor = _ref8.fillColor,
2412 fillColor = _ref8$fillColor === void 0 ? 'transparent' : _ref8$fillColor,
2413 _ref8$imageSmoothingE = _ref8.imageSmoothingEnabled,
2414 imageSmoothingEnabled = _ref8$imageSmoothingE === void 0 ? true : _ref8$imageSmoothingE,
2415 _ref8$imageSmoothingQ = _ref8.imageSmoothingQuality,
2416 imageSmoothingQuality = _ref8$imageSmoothingQ === void 0 ? 'low' : _ref8$imageSmoothingQ,
2417 _ref8$maxWidth = _ref8.maxWidth,
2418 maxWidth = _ref8$maxWidth === void 0 ? Infinity : _ref8$maxWidth,
2419 _ref8$maxHeight = _ref8.maxHeight,
2420 maxHeight = _ref8$maxHeight === void 0 ? Infinity : _ref8$maxHeight,
2421 _ref8$minWidth = _ref8.minWidth,
2422 minWidth = _ref8$minWidth === void 0 ? 0 : _ref8$minWidth,
2423 _ref8$minHeight = _ref8.minHeight,
2424 minHeight = _ref8$minHeight === void 0 ? 0 : _ref8$minHeight;
2425 var canvas = document.createElement('canvas');
2426 var context = canvas.getContext('2d');
2427 var maxSizes = getAdjustedSizes({
2428 aspectRatio: aspectRatio,
2429 width: maxWidth,
2430 height: maxHeight
2431 });
2432 var minSizes = getAdjustedSizes({
2433 aspectRatio: aspectRatio,
2434 width: minWidth,
2435 height: minHeight
2436 }, 'cover');
2437 var width = Math.min(maxSizes.width, Math.max(minSizes.width, naturalWidth));
2438 var height = Math.min(maxSizes.height, Math.max(minSizes.height, naturalHeight));
2439
2440 // Note: should always use image's natural sizes for drawing as
2441 // imageData.naturalWidth === canvasData.naturalHeight when rotate % 180 === 90
2442 var destMaxSizes = getAdjustedSizes({
2443 aspectRatio: imageAspectRatio,
2444 width: maxWidth,
2445 height: maxHeight
2446 });
2447 var destMinSizes = getAdjustedSizes({
2448 aspectRatio: imageAspectRatio,
2449 width: minWidth,
2450 height: minHeight
2451 }, 'cover');
2452 var destWidth = Math.min(destMaxSizes.width, Math.max(destMinSizes.width, imageNaturalWidth));
2453 var destHeight = Math.min(destMaxSizes.height, Math.max(destMinSizes.height, imageNaturalHeight));
2454 var params = [-destWidth / 2, -destHeight / 2, destWidth, destHeight];
2455 canvas.width = normalizeDecimalNumber(width);
2456 canvas.height = normalizeDecimalNumber(height);
2457 context.fillStyle = fillColor;
2458 context.fillRect(0, 0, width, height);
2459 context.save();
2460 context.translate(width / 2, height / 2);
2461 context.rotate(rotate * Math.PI / 180);
2462 context.scale(scaleX, scaleY);
2463 context.imageSmoothingEnabled = imageSmoothingEnabled;
2464 context.imageSmoothingQuality = imageSmoothingQuality;
2465 context.drawImage.apply(context, [image].concat(_toConsumableArray(params.map(function (param) {
2466 return Math.floor(normalizeDecimalNumber(param));
2467 }))));
2468 context.restore();
2469 return canvas;
2470 }
2471 var fromCharCode = String.fromCharCode;
2472
2473 /**
2474 * Get string from char code in data view.
2475 * @param {DataView} dataView - The data view for read.
2476 * @param {number} start - The start index.
2477 * @param {number} length - The read length.
2478 * @returns {string} The read result.
2479 */
2480 function getStringFromCharCode(dataView, start, length) {
2481 var str = '';
2482 length += start;
2483 for (var i = start; i < length; i += 1) {
2484 str += fromCharCode(dataView.getUint8(i));
2485 }
2486 return str;
2487 }
2488 var REGEXP_DATA_URL_HEAD = /^data:.*,/;
2489
2490 /**
2491 * Transform Data URL to array buffer.
2492 * @param {string} dataURL - The Data URL to transform.
2493 * @returns {ArrayBuffer} The result array buffer.
2494 */
2495 function dataURLToArrayBuffer(dataURL) {
2496 var base64 = dataURL.replace(REGEXP_DATA_URL_HEAD, '');
2497 var binary = atob(base64);
2498 var arrayBuffer = new ArrayBuffer(binary.length);
2499 var uint8 = new Uint8Array(arrayBuffer);
2500 forEach(uint8, function (value, i) {
2501 uint8[i] = binary.charCodeAt(i);
2502 });
2503 return arrayBuffer;
2504 }
2505
2506 /**
2507 * Transform array buffer to Data URL.
2508 * @param {ArrayBuffer} arrayBuffer - The array buffer to transform.
2509 * @param {string} mimeType - The mime type of the Data URL.
2510 * @returns {string} The result Data URL.
2511 */
2512 function arrayBufferToDataURL(arrayBuffer, mimeType) {
2513 var chunks = [];
2514
2515 // Chunk Typed Array for better performance (#435)
2516 var chunkSize = 8192;
2517 var uint8 = new Uint8Array(arrayBuffer);
2518 while (uint8.length > 0) {
2519 // XXX: Babel's `toConsumableArray` helper will throw error in IE or Safari 9
2520 // eslint-disable-next-line prefer-spread
2521 chunks.push(fromCharCode.apply(null, toArray(uint8.subarray(0, chunkSize))));
2522 uint8 = uint8.subarray(chunkSize);
2523 }
2524 return "data:".concat(mimeType, ";base64,").concat(btoa(chunks.join('')));
2525 }
2526
2527 /**
2528 * Get orientation value from given array buffer.
2529 * @param {ArrayBuffer} arrayBuffer - The array buffer to read.
2530 * @returns {number} The read orientation value.
2531 */
2532 function resetAndGetOrientation(arrayBuffer) {
2533 var dataView = new DataView(arrayBuffer);
2534 var orientation;
2535
2536 // Ignores range error when the image does not have correct Exif information
2537 try {
2538 var littleEndian;
2539 var app1Start;
2540 var ifdStart;
2541
2542 // Only handle JPEG image (start by 0xFFD8)
2543 if (dataView.getUint8(0) === 0xFF && dataView.getUint8(1) === 0xD8) {
2544 var length = dataView.byteLength;
2545 var offset = 2;
2546 while (offset + 1 < length) {
2547 if (dataView.getUint8(offset) === 0xFF && dataView.getUint8(offset + 1) === 0xE1) {
2548 app1Start = offset;
2549 break;
2550 }
2551 offset += 1;
2552 }
2553 }
2554 if (app1Start) {
2555 var exifIDCode = app1Start + 4;
2556 var tiffOffset = app1Start + 10;
2557 if (getStringFromCharCode(dataView, exifIDCode, 4) === 'Exif') {
2558 var endianness = dataView.getUint16(tiffOffset);
2559 littleEndian = endianness === 0x4949;
2560 if (littleEndian || endianness === 0x4D4D /* bigEndian */) {
2561 if (dataView.getUint16(tiffOffset + 2, littleEndian) === 0x002A) {
2562 var firstIFDOffset = dataView.getUint32(tiffOffset + 4, littleEndian);
2563 if (firstIFDOffset >= 0x00000008) {
2564 ifdStart = tiffOffset + firstIFDOffset;
2565 }
2566 }
2567 }
2568 }
2569 }
2570 if (ifdStart) {
2571 var _length = dataView.getUint16(ifdStart, littleEndian);
2572 var _offset;
2573 var i;
2574 for (i = 0; i < _length; i += 1) {
2575 _offset = ifdStart + i * 12 + 2;
2576 if (dataView.getUint16(_offset, littleEndian) === 0x0112 /* Orientation */) {
2577 // 8 is the offset of the current tag's value
2578 _offset += 8;
2579
2580 // Get the original orientation value
2581 orientation = dataView.getUint16(_offset, littleEndian);
2582
2583 // Override the orientation with its default value
2584 dataView.setUint16(_offset, 1, littleEndian);
2585 break;
2586 }
2587 }
2588 }
2589 } catch (error) {
2590 orientation = 1;
2591 }
2592 return orientation;
2593 }
2594
2595 /**
2596 * Parse Exif Orientation value.
2597 * @param {number} orientation - The orientation to parse.
2598 * @returns {Object} The parsed result.
2599 */
2600 function parseOrientation(orientation) {
2601 var rotate = 0;
2602 var scaleX = 1;
2603 var scaleY = 1;
2604 switch (orientation) {
2605 // Flip horizontal
2606 case 2:
2607 scaleX = -1;
2608 break;
2609
2610 // Rotate left 180°
2611 case 3:
2612 rotate = -180;
2613 break;
2614
2615 // Flip vertical
2616 case 4:
2617 scaleY = -1;
2618 break;
2619
2620 // Flip vertical and rotate right 90°
2621 case 5:
2622 rotate = 90;
2623 scaleY = -1;
2624 break;
2625
2626 // Rotate right 90°
2627 case 6:
2628 rotate = 90;
2629 break;
2630
2631 // Flip horizontal and rotate right 90°
2632 case 7:
2633 rotate = 90;
2634 scaleX = -1;
2635 break;
2636
2637 // Rotate left 90°
2638 case 8:
2639 rotate = -90;
2640 break;
2641 }
2642 return {
2643 rotate: rotate,
2644 scaleX: scaleX,
2645 scaleY: scaleY
2646 };
2647 }
2648
2649 var render = {
2650 render: function render() {
2651 this.initContainer();
2652 this.initCanvas();
2653 this.initCropBox();
2654 this.renderCanvas();
2655 if (this.cropped) {
2656 this.renderCropBox();
2657 }
2658 },
2659 initContainer: function initContainer() {
2660 var element = this.element,
2661 options = this.options,
2662 container = this.container,
2663 cropper = this.cropper;
2664 var minWidth = Number(options.minContainerWidth);
2665 var minHeight = Number(options.minContainerHeight);
2666 addClass(cropper, CLASS_HIDDEN);
2667 removeClass(element, CLASS_HIDDEN);
2668 var containerData = {
2669 width: Math.max(container.offsetWidth, minWidth >= 0 ? minWidth : MIN_CONTAINER_WIDTH),
2670 height: Math.max(container.offsetHeight, minHeight >= 0 ? minHeight : MIN_CONTAINER_HEIGHT)
2671 };
2672 this.containerData = containerData;
2673 setStyle(cropper, {
2674 width: containerData.width,
2675 height: containerData.height
2676 });
2677 addClass(element, CLASS_HIDDEN);
2678 removeClass(cropper, CLASS_HIDDEN);
2679 },
2680 // Canvas (image wrapper)
2681 initCanvas: function initCanvas() {
2682 var containerData = this.containerData,
2683 imageData = this.imageData;
2684 var viewMode = this.options.viewMode;
2685 var rotated = Math.abs(imageData.rotate) % 180 === 90;
2686 var naturalWidth = rotated ? imageData.naturalHeight : imageData.naturalWidth;
2687 var naturalHeight = rotated ? imageData.naturalWidth : imageData.naturalHeight;
2688 var aspectRatio = naturalWidth / naturalHeight;
2689 var canvasWidth = containerData.width;
2690 var canvasHeight = containerData.height;
2691 if (containerData.height * aspectRatio > containerData.width) {
2692 if (viewMode === 3) {
2693 canvasWidth = containerData.height * aspectRatio;
2694 } else {
2695 canvasHeight = containerData.width / aspectRatio;
2696 }
2697 } else if (viewMode === 3) {
2698 canvasHeight = containerData.width / aspectRatio;
2699 } else {
2700 canvasWidth = containerData.height * aspectRatio;
2701 }
2702 var canvasData = {
2703 aspectRatio: aspectRatio,
2704 naturalWidth: naturalWidth,
2705 naturalHeight: naturalHeight,
2706 width: canvasWidth,
2707 height: canvasHeight
2708 };
2709 this.canvasData = canvasData;
2710 this.limited = viewMode === 1 || viewMode === 2;
2711 this.limitCanvas(true, true);
2712 canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
2713 canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
2714 canvasData.left = (containerData.width - canvasData.width) / 2;
2715 canvasData.top = (containerData.height - canvasData.height) / 2;
2716 canvasData.oldLeft = canvasData.left;
2717 canvasData.oldTop = canvasData.top;
2718 this.initialCanvasData = assign({}, canvasData);
2719 },
2720 limitCanvas: function limitCanvas(sizeLimited, positionLimited) {
2721 var options = this.options,
2722 containerData = this.containerData,
2723 canvasData = this.canvasData,
2724 cropBoxData = this.cropBoxData;
2725 var viewMode = options.viewMode;
2726 var aspectRatio = canvasData.aspectRatio;
2727 var cropped = this.cropped && cropBoxData;
2728 if (sizeLimited) {
2729 var minCanvasWidth = Number(options.minCanvasWidth) || 0;
2730 var minCanvasHeight = Number(options.minCanvasHeight) || 0;
2731 if (viewMode > 1) {
2732 minCanvasWidth = Math.max(minCanvasWidth, containerData.width);
2733 minCanvasHeight = Math.max(minCanvasHeight, containerData.height);
2734 if (viewMode === 3) {
2735 if (minCanvasHeight * aspectRatio > minCanvasWidth) {
2736 minCanvasWidth = minCanvasHeight * aspectRatio;
2737 } else {
2738 minCanvasHeight = minCanvasWidth / aspectRatio;
2739 }
2740 }
2741 } else if (viewMode > 0) {
2742 if (minCanvasWidth) {
2743 minCanvasWidth = Math.max(minCanvasWidth, cropped ? cropBoxData.width : 0);
2744 } else if (minCanvasHeight) {
2745 minCanvasHeight = Math.max(minCanvasHeight, cropped ? cropBoxData.height : 0);
2746 } else if (cropped) {
2747 minCanvasWidth = cropBoxData.width;
2748 minCanvasHeight = cropBoxData.height;
2749 if (minCanvasHeight * aspectRatio > minCanvasWidth) {
2750 minCanvasWidth = minCanvasHeight * aspectRatio;
2751 } else {
2752 minCanvasHeight = minCanvasWidth / aspectRatio;
2753 }
2754 }
2755 }
2756 var _getAdjustedSizes = getAdjustedSizes({
2757 aspectRatio: aspectRatio,
2758 width: minCanvasWidth,
2759 height: minCanvasHeight
2760 });
2761 minCanvasWidth = _getAdjustedSizes.width;
2762 minCanvasHeight = _getAdjustedSizes.height;
2763 canvasData.minWidth = minCanvasWidth;
2764 canvasData.minHeight = minCanvasHeight;
2765 canvasData.maxWidth = Infinity;
2766 canvasData.maxHeight = Infinity;
2767 }
2768 if (positionLimited) {
2769 if (viewMode > (cropped ? 0 : 1)) {
2770 var newCanvasLeft = containerData.width - canvasData.width;
2771 var newCanvasTop = containerData.height - canvasData.height;
2772 canvasData.minLeft = Math.min(0, newCanvasLeft);
2773 canvasData.minTop = Math.min(0, newCanvasTop);
2774 canvasData.maxLeft = Math.max(0, newCanvasLeft);
2775 canvasData.maxTop = Math.max(0, newCanvasTop);
2776 if (cropped && this.limited) {
2777 canvasData.minLeft = Math.min(cropBoxData.left, cropBoxData.left + (cropBoxData.width - canvasData.width));
2778 canvasData.minTop = Math.min(cropBoxData.top, cropBoxData.top + (cropBoxData.height - canvasData.height));
2779 canvasData.maxLeft = cropBoxData.left;
2780 canvasData.maxTop = cropBoxData.top;
2781 if (viewMode === 2) {
2782 if (canvasData.width >= containerData.width) {
2783 canvasData.minLeft = Math.min(0, newCanvasLeft);
2784 canvasData.maxLeft = Math.max(0, newCanvasLeft);
2785 }
2786 if (canvasData.height >= containerData.height) {
2787 canvasData.minTop = Math.min(0, newCanvasTop);
2788 canvasData.maxTop = Math.max(0, newCanvasTop);
2789 }
2790 }
2791 }
2792 } else {
2793 canvasData.minLeft = -canvasData.width;
2794 canvasData.minTop = -canvasData.height;
2795 canvasData.maxLeft = containerData.width;
2796 canvasData.maxTop = containerData.height;
2797 }
2798 }
2799 },
2800 renderCanvas: function renderCanvas(changed, transformed) {
2801 var canvasData = this.canvasData,
2802 imageData = this.imageData;
2803 if (transformed) {
2804 var _getRotatedSizes = getRotatedSizes({
2805 width: imageData.naturalWidth * Math.abs(imageData.scaleX || 1),
2806 height: imageData.naturalHeight * Math.abs(imageData.scaleY || 1),
2807 degree: imageData.rotate || 0
2808 }),
2809 naturalWidth = _getRotatedSizes.width,
2810 naturalHeight = _getRotatedSizes.height;
2811 var width = canvasData.width * (naturalWidth / canvasData.naturalWidth);
2812 var height = canvasData.height * (naturalHeight / canvasData.naturalHeight);
2813 canvasData.left -= (width - canvasData.width) / 2;
2814 canvasData.top -= (height - canvasData.height) / 2;
2815 canvasData.width = width;
2816 canvasData.height = height;
2817 canvasData.aspectRatio = naturalWidth / naturalHeight;
2818 canvasData.naturalWidth = naturalWidth;
2819 canvasData.naturalHeight = naturalHeight;
2820 this.limitCanvas(true, false);
2821 }
2822 if (canvasData.width > canvasData.maxWidth || canvasData.width < canvasData.minWidth) {
2823 canvasData.left = canvasData.oldLeft;
2824 }
2825 if (canvasData.height > canvasData.maxHeight || canvasData.height < canvasData.minHeight) {
2826 canvasData.top = canvasData.oldTop;
2827 }
2828 canvasData.width = Math.min(Math.max(canvasData.width, canvasData.minWidth), canvasData.maxWidth);
2829 canvasData.height = Math.min(Math.max(canvasData.height, canvasData.minHeight), canvasData.maxHeight);
2830 this.limitCanvas(false, true);
2831 canvasData.left = Math.min(Math.max(canvasData.left, canvasData.minLeft), canvasData.maxLeft);
2832 canvasData.top = Math.min(Math.max(canvasData.top, canvasData.minTop), canvasData.maxTop);
2833 canvasData.oldLeft = canvasData.left;
2834 canvasData.oldTop = canvasData.top;
2835 setStyle(this.canvas, assign({
2836 width: canvasData.width,
2837 height: canvasData.height
2838 }, getTransforms({
2839 translateX: canvasData.left,
2840 translateY: canvasData.top
2841 })));
2842 this.renderImage(changed);
2843 if (this.cropped && this.limited) {
2844 this.limitCropBox(true, true);
2845 }
2846 },
2847 renderImage: function renderImage(changed) {
2848 var canvasData = this.canvasData,
2849 imageData = this.imageData;
2850 var width = imageData.naturalWidth * (canvasData.width / canvasData.naturalWidth);
2851 var height = imageData.naturalHeight * (canvasData.height / canvasData.naturalHeight);
2852 assign(imageData, {
2853 width: width,
2854 height: height,
2855 left: (canvasData.width - width) / 2,
2856 top: (canvasData.height - height) / 2
2857 });
2858 setStyle(this.image, assign({
2859 width: imageData.width,
2860 height: imageData.height
2861 }, getTransforms(assign({
2862 translateX: imageData.left,
2863 translateY: imageData.top
2864 }, imageData))));
2865 if (changed) {
2866 this.output();
2867 }
2868 },
2869 initCropBox: function initCropBox() {
2870 var options = this.options,
2871 canvasData = this.canvasData;
2872 var aspectRatio = options.aspectRatio || options.initialAspectRatio;
2873 var autoCropArea = Number(options.autoCropArea) || 0.8;
2874 var cropBoxData = {
2875 width: canvasData.width,
2876 height: canvasData.height
2877 };
2878 if (aspectRatio) {
2879 if (canvasData.height * aspectRatio > canvasData.width) {
2880 cropBoxData.height = cropBoxData.width / aspectRatio;
2881 } else {
2882 cropBoxData.width = cropBoxData.height * aspectRatio;
2883 }
2884 }
2885 this.cropBoxData = cropBoxData;
2886 this.limitCropBox(true, true);
2887
2888 // Initialize auto crop area
2889 cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth);
2890 cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight);
2891
2892 // The width/height of auto crop area must large than "minWidth/Height"
2893 cropBoxData.width = Math.max(cropBoxData.minWidth, cropBoxData.width * autoCropArea);
2894 cropBoxData.height = Math.max(cropBoxData.minHeight, cropBoxData.height * autoCropArea);
2895 cropBoxData.left = canvasData.left + (canvasData.width - cropBoxData.width) / 2;
2896 cropBoxData.top = canvasData.top + (canvasData.height - cropBoxData.height) / 2;
2897 cropBoxData.oldLeft = cropBoxData.left;
2898 cropBoxData.oldTop = cropBoxData.top;
2899 this.initialCropBoxData = assign({}, cropBoxData);
2900 },
2901 limitCropBox: function limitCropBox(sizeLimited, positionLimited) {
2902 var options = this.options,
2903 containerData = this.containerData,
2904 canvasData = this.canvasData,
2905 cropBoxData = this.cropBoxData,
2906 limited = this.limited;
2907 var aspectRatio = options.aspectRatio;
2908 if (sizeLimited) {
2909 var minCropBoxWidth = Number(options.minCropBoxWidth) || 0;
2910 var minCropBoxHeight = Number(options.minCropBoxHeight) || 0;
2911 var maxCropBoxWidth = limited ? Math.min(containerData.width, canvasData.width, canvasData.width + canvasData.left, containerData.width - canvasData.left) : containerData.width;
2912 var maxCropBoxHeight = limited ? Math.min(containerData.height, canvasData.height, canvasData.height + canvasData.top, containerData.height - canvasData.top) : containerData.height;
2913
2914 // The min/maxCropBoxWidth/Height must be less than container's width/height
2915 minCropBoxWidth = Math.min(minCropBoxWidth, containerData.width);
2916 minCropBoxHeight = Math.min(minCropBoxHeight, containerData.height);
2917 if (aspectRatio) {
2918 if (minCropBoxWidth && minCropBoxHeight) {
2919 if (minCropBoxHeight * aspectRatio > minCropBoxWidth) {
2920 minCropBoxHeight = minCropBoxWidth / aspectRatio;
2921 } else {
2922 minCropBoxWidth = minCropBoxHeight * aspectRatio;
2923 }
2924 } else if (minCropBoxWidth) {
2925 minCropBoxHeight = minCropBoxWidth / aspectRatio;
2926 } else if (minCropBoxHeight) {
2927 minCropBoxWidth = minCropBoxHeight * aspectRatio;
2928 }
2929 if (maxCropBoxHeight * aspectRatio > maxCropBoxWidth) {
2930 maxCropBoxHeight = maxCropBoxWidth / aspectRatio;
2931 } else {
2932 maxCropBoxWidth = maxCropBoxHeight * aspectRatio;
2933 }
2934 }
2935
2936 // The minWidth/Height must be less than maxWidth/Height
2937 cropBoxData.minWidth = Math.min(minCropBoxWidth, maxCropBoxWidth);
2938 cropBoxData.minHeight = Math.min(minCropBoxHeight, maxCropBoxHeight);
2939 cropBoxData.maxWidth = maxCropBoxWidth;
2940 cropBoxData.maxHeight = maxCropBoxHeight;
2941 }
2942 if (positionLimited) {
2943 if (limited) {
2944 cropBoxData.minLeft = Math.max(0, canvasData.left);
2945 cropBoxData.minTop = Math.max(0, canvasData.top);
2946 cropBoxData.maxLeft = Math.min(containerData.width, canvasData.left + canvasData.width) - cropBoxData.width;
2947 cropBoxData.maxTop = Math.min(containerData.height, canvasData.top + canvasData.height) - cropBoxData.height;
2948 } else {
2949 cropBoxData.minLeft = 0;
2950 cropBoxData.minTop = 0;
2951 cropBoxData.maxLeft = containerData.width - cropBoxData.width;
2952 cropBoxData.maxTop = containerData.height - cropBoxData.height;
2953 }
2954 }
2955 },
2956 renderCropBox: function renderCropBox() {
2957 var options = this.options,
2958 containerData = this.containerData,
2959 cropBoxData = this.cropBoxData;
2960 if (cropBoxData.width > cropBoxData.maxWidth || cropBoxData.width < cropBoxData.minWidth) {
2961 cropBoxData.left = cropBoxData.oldLeft;
2962 }
2963 if (cropBoxData.height > cropBoxData.maxHeight || cropBoxData.height < cropBoxData.minHeight) {
2964 cropBoxData.top = cropBoxData.oldTop;
2965 }
2966 cropBoxData.width = Math.min(Math.max(cropBoxData.width, cropBoxData.minWidth), cropBoxData.maxWidth);
2967 cropBoxData.height = Math.min(Math.max(cropBoxData.height, cropBoxData.minHeight), cropBoxData.maxHeight);
2968 this.limitCropBox(false, true);
2969 cropBoxData.left = Math.min(Math.max(cropBoxData.left, cropBoxData.minLeft), cropBoxData.maxLeft);
2970 cropBoxData.top = Math.min(Math.max(cropBoxData.top, cropBoxData.minTop), cropBoxData.maxTop);
2971 cropBoxData.oldLeft = cropBoxData.left;
2972 cropBoxData.oldTop = cropBoxData.top;
2973 if (options.movable && options.cropBoxMovable) {
2974 // Turn to move the canvas when the crop box is equal to the container
2975 setData(this.face, DATA_ACTION, cropBoxData.width >= containerData.width && cropBoxData.height >= containerData.height ? ACTION_MOVE : ACTION_ALL);
2976 }
2977 setStyle(this.cropBox, assign({
2978 width: cropBoxData.width,
2979 height: cropBoxData.height
2980 }, getTransforms({
2981 translateX: cropBoxData.left,
2982 translateY: cropBoxData.top
2983 })));
2984 if (this.cropped && this.limited) {
2985 this.limitCanvas(true, true);
2986 }
2987 if (!this.disabled) {
2988 this.output();
2989 }
2990 },
2991 output: function output() {
2992 this.preview();
2993 dispatchEvent(this.element, EVENT_CROP, this.getData());
2994 }
2995 };
2996
2997 var preview = {
2998 initPreview: function initPreview() {
2999 var element = this.element,
3000 crossOrigin = this.crossOrigin;
3001 var preview = this.options.preview;
3002 var url = crossOrigin ? this.crossOriginUrl : this.url;
3003 var alt = element.alt || 'The image to preview';
3004 var image = document.createElement('img');
3005 if (crossOrigin) {
3006 image.crossOrigin = crossOrigin;
3007 }
3008 image.src = url;
3009 image.alt = alt;
3010 this.viewBox.appendChild(image);
3011 this.viewBoxImage = image;
3012 if (!preview) {
3013 return;
3014 }
3015 var previews = preview;
3016 if (typeof preview === 'string') {
3017 previews = element.ownerDocument.querySelectorAll(preview);
3018 } else if (preview.querySelector) {
3019 previews = [preview];
3020 }
3021 this.previews = previews;
3022 forEach(previews, function (el) {
3023 var img = document.createElement('img');
3024
3025 // Save the original size for recover
3026 setData(el, DATA_PREVIEW, {
3027 width: el.offsetWidth,
3028 height: el.offsetHeight,
3029 html: el.innerHTML
3030 });
3031 if (crossOrigin) {
3032 img.crossOrigin = crossOrigin;
3033 }
3034 img.src = url;
3035 img.alt = alt;
3036
3037 /**
3038 * Override img element styles
3039 * Add `display:block` to avoid margin top issue
3040 * Add `height:auto` to override `height` attribute on IE8
3041 * (Occur only when margin-top <= -height)
3042 */
3043 img.style.cssText = 'display:block;' + 'width:100%;' + 'height:auto;' + 'min-width:0!important;' + 'min-height:0!important;' + 'max-width:none!important;' + 'max-height:none!important;' + 'image-orientation:0deg!important;"';
3044 el.innerHTML = '';
3045 el.appendChild(img);
3046 });
3047 },
3048 resetPreview: function resetPreview() {
3049 forEach(this.previews, function (element) {
3050 var data = getData(element, DATA_PREVIEW);
3051 setStyle(element, {
3052 width: data.width,
3053 height: data.height
3054 });
3055 element.innerHTML = data.html;
3056 removeData(element, DATA_PREVIEW);
3057 });
3058 },
3059 preview: function preview() {
3060 var imageData = this.imageData,
3061 canvasData = this.canvasData,
3062 cropBoxData = this.cropBoxData;
3063 var cropBoxWidth = cropBoxData.width,
3064 cropBoxHeight = cropBoxData.height;
3065 var width = imageData.width,
3066 height = imageData.height;
3067 var left = cropBoxData.left - canvasData.left - imageData.left;
3068 var top = cropBoxData.top - canvasData.top - imageData.top;
3069 if (!this.cropped || this.disabled) {
3070 return;
3071 }
3072 setStyle(this.viewBoxImage, assign({
3073 width: width,
3074 height: height
3075 }, getTransforms(assign({
3076 translateX: -left,
3077 translateY: -top
3078 }, imageData))));
3079 forEach(this.previews, function (element) {
3080 var data = getData(element, DATA_PREVIEW);
3081 var originalWidth = data.width;
3082 var originalHeight = data.height;
3083 var newWidth = originalWidth;
3084 var newHeight = originalHeight;
3085 var ratio = 1;
3086 if (cropBoxWidth) {
3087 ratio = originalWidth / cropBoxWidth;
3088 newHeight = cropBoxHeight * ratio;
3089 }
3090 if (cropBoxHeight && newHeight > originalHeight) {
3091 ratio = originalHeight / cropBoxHeight;
3092 newWidth = cropBoxWidth * ratio;
3093 newHeight = originalHeight;
3094 }
3095 setStyle(element, {
3096 width: newWidth,
3097 height: newHeight
3098 });
3099 setStyle(element.getElementsByTagName('img')[0], assign({
3100 width: width * ratio,
3101 height: height * ratio
3102 }, getTransforms(assign({
3103 translateX: -left * ratio,
3104 translateY: -top * ratio
3105 }, imageData))));
3106 });
3107 }
3108 };
3109
3110 var events = {
3111 bind: function bind() {
3112 var element = this.element,
3113 options = this.options,
3114 cropper = this.cropper;
3115 if (isFunction(options.cropstart)) {
3116 addListener(element, EVENT_CROP_START, options.cropstart);
3117 }
3118 if (isFunction(options.cropmove)) {
3119 addListener(element, EVENT_CROP_MOVE, options.cropmove);
3120 }
3121 if (isFunction(options.cropend)) {
3122 addListener(element, EVENT_CROP_END, options.cropend);
3123 }
3124 if (isFunction(options.crop)) {
3125 addListener(element, EVENT_CROP, options.crop);
3126 }
3127 if (isFunction(options.zoom)) {
3128 addListener(element, EVENT_ZOOM, options.zoom);
3129 }
3130 addListener(cropper, EVENT_POINTER_DOWN, this.onCropStart = this.cropStart.bind(this));
3131 if (options.zoomable && options.zoomOnWheel) {
3132 addListener(cropper, EVENT_WHEEL, this.onWheel = this.wheel.bind(this), {
3133 passive: false,
3134 capture: true
3135 });
3136 }
3137 if (options.toggleDragModeOnDblclick) {
3138 addListener(cropper, EVENT_DBLCLICK, this.onDblclick = this.dblclick.bind(this));
3139 }
3140 addListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove = this.cropMove.bind(this));
3141 addListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd = this.cropEnd.bind(this));
3142 if (options.responsive) {
3143 addListener(window, EVENT_RESIZE, this.onResize = this.resize.bind(this));
3144 }
3145 },
3146 unbind: function unbind() {
3147 var element = this.element,
3148 options = this.options,
3149 cropper = this.cropper;
3150 if (isFunction(options.cropstart)) {
3151 removeListener(element, EVENT_CROP_START, options.cropstart);
3152 }
3153 if (isFunction(options.cropmove)) {
3154 removeListener(element, EVENT_CROP_MOVE, options.cropmove);
3155 }
3156 if (isFunction(options.cropend)) {
3157 removeListener(element, EVENT_CROP_END, options.cropend);
3158 }
3159 if (isFunction(options.crop)) {
3160 removeListener(element, EVENT_CROP, options.crop);
3161 }
3162 if (isFunction(options.zoom)) {
3163 removeListener(element, EVENT_ZOOM, options.zoom);
3164 }
3165 removeListener(cropper, EVENT_POINTER_DOWN, this.onCropStart);
3166 if (options.zoomable && options.zoomOnWheel) {
3167 removeListener(cropper, EVENT_WHEEL, this.onWheel, {
3168 passive: false,
3169 capture: true
3170 });
3171 }
3172 if (options.toggleDragModeOnDblclick) {
3173 removeListener(cropper, EVENT_DBLCLICK, this.onDblclick);
3174 }
3175 removeListener(element.ownerDocument, EVENT_POINTER_MOVE, this.onCropMove);
3176 removeListener(element.ownerDocument, EVENT_POINTER_UP, this.onCropEnd);
3177 if (options.responsive) {
3178 removeListener(window, EVENT_RESIZE, this.onResize);
3179 }
3180 }
3181 };
3182
3183 var handlers = {
3184 resize: function resize() {
3185 if (this.disabled) {
3186 return;
3187 }
3188 var options = this.options,
3189 container = this.container,
3190 containerData = this.containerData;
3191 var ratioX = container.offsetWidth / containerData.width;
3192 var ratioY = container.offsetHeight / containerData.height;
3193 var ratio = Math.abs(ratioX - 1) > Math.abs(ratioY - 1) ? ratioX : ratioY;
3194
3195 // Resize when width changed or height changed
3196 if (ratio !== 1) {
3197 var canvasData;
3198 var cropBoxData;
3199 if (options.restore) {
3200 canvasData = this.getCanvasData();
3201 cropBoxData = this.getCropBoxData();
3202 }
3203 this.render();
3204 if (options.restore) {
3205 this.setCanvasData(forEach(canvasData, function (n, i) {
3206 canvasData[i] = n * ratio;
3207 }));
3208 this.setCropBoxData(forEach(cropBoxData, function (n, i) {
3209 cropBoxData[i] = n * ratio;
3210 }));
3211 }
3212 }
3213 },
3214 dblclick: function dblclick() {
3215 if (this.disabled || this.options.dragMode === DRAG_MODE_NONE) {
3216 return;
3217 }
3218 this.setDragMode(hasClass(this.dragBox, CLASS_CROP) ? DRAG_MODE_MOVE : DRAG_MODE_CROP);
3219 },
3220 wheel: function wheel(event) {
3221 var _this = this;
3222 var ratio = Number(this.options.wheelZoomRatio) || 0.1;
3223 var delta = 1;
3224 if (this.disabled) {
3225 return;
3226 }
3227 event.preventDefault();
3228
3229 // Limit wheel speed to prevent zoom too fast (#21)
3230 if (this.wheeling) {
3231 return;
3232 }
3233 this.wheeling = true;
3234 setTimeout(function () {
3235 _this.wheeling = false;
3236 }, 50);
3237 if (event.deltaY) {
3238 delta = event.deltaY > 0 ? 1 : -1;
3239 } else if (event.wheelDelta) {
3240 delta = -event.wheelDelta / 120;
3241 } else if (event.detail) {
3242 delta = event.detail > 0 ? 1 : -1;
3243 }
3244 this.zoom(-delta * ratio, event);
3245 },
3246 cropStart: function cropStart(event) {
3247 var buttons = event.buttons,
3248 button = event.button;
3249 if (this.disabled
3250
3251 // Handle mouse event and pointer event and ignore touch event
3252 || (event.type === 'mousedown' || event.type === 'pointerdown' && event.pointerType === 'mouse') && (
3253 // No primary button (Usually the left button)
3254 isNumber(buttons) && buttons !== 1 || isNumber(button) && button !== 0
3255
3256 // Open context menu
3257 || event.ctrlKey)) {
3258 return;
3259 }
3260 var options = this.options,
3261 pointers = this.pointers;
3262 var action;
3263 if (event.changedTouches) {
3264 // Handle touch event
3265 forEach(event.changedTouches, function (touch) {
3266 pointers[touch.identifier] = getPointer(touch);
3267 });
3268 } else {
3269 // Handle mouse event and pointer event
3270 pointers[event.pointerId || 0] = getPointer(event);
3271 }
3272 if (Object.keys(pointers).length > 1 && options.zoomable && options.zoomOnTouch) {
3273 action = ACTION_ZOOM;
3274 } else {
3275 action = getData(event.target, DATA_ACTION);
3276 }
3277 if (!REGEXP_ACTIONS.test(action)) {
3278 return;
3279 }
3280 if (dispatchEvent(this.element, EVENT_CROP_START, {
3281 originalEvent: event,
3282 action: action
3283 }) === false) {
3284 return;
3285 }
3286
3287 // This line is required for preventing page zooming in iOS browsers
3288 event.preventDefault();
3289 this.action = action;
3290 this.cropping = false;
3291 if (action === ACTION_CROP) {
3292 this.cropping = true;
3293 addClass(this.dragBox, CLASS_MODAL);
3294 }
3295 },
3296 cropMove: function cropMove(event) {
3297 var action = this.action;
3298 if (this.disabled || !action) {
3299 return;
3300 }
3301 var pointers = this.pointers;
3302 event.preventDefault();
3303 if (dispatchEvent(this.element, EVENT_CROP_MOVE, {
3304 originalEvent: event,
3305 action: action
3306 }) === false) {
3307 return;
3308 }
3309 if (event.changedTouches) {
3310 forEach(event.changedTouches, function (touch) {
3311 // The first parameter should not be undefined (#432)
3312 assign(pointers[touch.identifier] || {}, getPointer(touch, true));
3313 });
3314 } else {
3315 assign(pointers[event.pointerId || 0] || {}, getPointer(event, true));
3316 }
3317 this.change(event);
3318 },
3319 cropEnd: function cropEnd(event) {
3320 if (this.disabled) {
3321 return;
3322 }
3323 var action = this.action,
3324 pointers = this.pointers;
3325 if (event.changedTouches) {
3326 forEach(event.changedTouches, function (touch) {
3327 delete pointers[touch.identifier];
3328 });
3329 } else {
3330 delete pointers[event.pointerId || 0];
3331 }
3332 if (!action) {
3333 return;
3334 }
3335 event.preventDefault();
3336 if (!Object.keys(pointers).length) {
3337 this.action = '';
3338 }
3339 if (this.cropping) {
3340 this.cropping = false;
3341 toggleClass(this.dragBox, CLASS_MODAL, this.cropped && this.options.modal);
3342 }
3343 dispatchEvent(this.element, EVENT_CROP_END, {
3344 originalEvent: event,
3345 action: action
3346 });
3347 }
3348 };
3349
3350 var change = {
3351 change: function change(event) {
3352 var options = this.options,
3353 canvasData = this.canvasData,
3354 containerData = this.containerData,
3355 cropBoxData = this.cropBoxData,
3356 pointers = this.pointers;
3357 var action = this.action;
3358 var aspectRatio = options.aspectRatio;
3359 var left = cropBoxData.left,
3360 top = cropBoxData.top,
3361 width = cropBoxData.width,
3362 height = cropBoxData.height;
3363 var right = left + width;
3364 var bottom = top + height;
3365 var minLeft = 0;
3366 var minTop = 0;
3367 var maxWidth = containerData.width;
3368 var maxHeight = containerData.height;
3369 var renderable = true;
3370 var offset;
3371
3372 // Locking aspect ratio in "free mode" by holding shift key
3373 if (!aspectRatio && event.shiftKey) {
3374 aspectRatio = width && height ? width / height : 1;
3375 }
3376 if (this.limited) {
3377 minLeft = cropBoxData.minLeft;
3378 minTop = cropBoxData.minTop;
3379 maxWidth = minLeft + Math.min(containerData.width, canvasData.width, canvasData.left + canvasData.width);
3380 maxHeight = minTop + Math.min(containerData.height, canvasData.height, canvasData.top + canvasData.height);
3381 }
3382 var pointer = pointers[Object.keys(pointers)[0]];
3383 var range = {
3384 x: pointer.endX - pointer.startX,
3385 y: pointer.endY - pointer.startY
3386 };
3387 var check = function check(side) {
3388 switch (side) {
3389 case ACTION_EAST:
3390 if (right + range.x > maxWidth) {
3391 range.x = maxWidth - right;
3392 }
3393 break;
3394 case ACTION_WEST:
3395 if (left + range.x < minLeft) {
3396 range.x = minLeft - left;
3397 }
3398 break;
3399 case ACTION_NORTH:
3400 if (top + range.y < minTop) {
3401 range.y = minTop - top;
3402 }
3403 break;
3404 case ACTION_SOUTH:
3405 if (bottom + range.y > maxHeight) {
3406 range.y = maxHeight - bottom;
3407 }
3408 break;
3409 }
3410 };
3411 switch (action) {
3412 // Move crop box
3413 case ACTION_ALL:
3414 left += range.x;
3415 top += range.y;
3416 break;
3417
3418 // Resize crop box
3419 case ACTION_EAST:
3420 if (range.x >= 0 && (right >= maxWidth || aspectRatio && (top <= minTop || bottom >= maxHeight))) {
3421 renderable = false;
3422 break;
3423 }
3424 check(ACTION_EAST);
3425 width += range.x;
3426 if (width < 0) {
3427 action = ACTION_WEST;
3428 width = -width;
3429 left -= width;
3430 }
3431 if (aspectRatio) {
3432 height = width / aspectRatio;
3433 top += (cropBoxData.height - height) / 2;
3434 }
3435 break;
3436 case ACTION_NORTH:
3437 if (range.y <= 0 && (top <= minTop || aspectRatio && (left <= minLeft || right >= maxWidth))) {
3438 renderable = false;
3439 break;
3440 }
3441 check(ACTION_NORTH);
3442 height -= range.y;
3443 top += range.y;
3444 if (height < 0) {
3445 action = ACTION_SOUTH;
3446 height = -height;
3447 top -= height;
3448 }
3449 if (aspectRatio) {
3450 width = height * aspectRatio;
3451 left += (cropBoxData.width - width) / 2;
3452 }
3453 break;
3454 case ACTION_WEST:
3455 if (range.x <= 0 && (left <= minLeft || aspectRatio && (top <= minTop || bottom >= maxHeight))) {
3456 renderable = false;
3457 break;
3458 }
3459 check(ACTION_WEST);
3460 width -= range.x;
3461 left += range.x;
3462 if (width < 0) {
3463 action = ACTION_EAST;
3464 width = -width;
3465 left -= width;
3466 }
3467 if (aspectRatio) {
3468 height = width / aspectRatio;
3469 top += (cropBoxData.height - height) / 2;
3470 }
3471 break;
3472 case ACTION_SOUTH:
3473 if (range.y >= 0 && (bottom >= maxHeight || aspectRatio && (left <= minLeft || right >= maxWidth))) {
3474 renderable = false;
3475 break;
3476 }
3477 check(ACTION_SOUTH);
3478 height += range.y;
3479 if (height < 0) {
3480 action = ACTION_NORTH;
3481 height = -height;
3482 top -= height;
3483 }
3484 if (aspectRatio) {
3485 width = height * aspectRatio;
3486 left += (cropBoxData.width - width) / 2;
3487 }
3488 break;
3489 case ACTION_NORTH_EAST:
3490 if (aspectRatio) {
3491 if (range.y <= 0 && (top <= minTop || right >= maxWidth)) {
3492 renderable = false;
3493 break;
3494 }
3495 check(ACTION_NORTH);
3496 height -= range.y;
3497 top += range.y;
3498 width = height * aspectRatio;
3499 } else {
3500 check(ACTION_NORTH);
3501 check(ACTION_EAST);
3502 if (range.x >= 0) {
3503 if (right < maxWidth) {
3504 width += range.x;
3505 } else if (range.y <= 0 && top <= minTop) {
3506 renderable = false;
3507 }
3508 } else {
3509 width += range.x;
3510 }
3511 if (range.y <= 0) {
3512 if (top > minTop) {
3513 height -= range.y;
3514 top += range.y;
3515 }
3516 } else {
3517 height -= range.y;
3518 top += range.y;
3519 }
3520 }
3521 if (width < 0 && height < 0) {
3522 action = ACTION_SOUTH_WEST;
3523 height = -height;
3524 width = -width;
3525 top -= height;
3526 left -= width;
3527 } else if (width < 0) {
3528 action = ACTION_NORTH_WEST;
3529 width = -width;
3530 left -= width;
3531 } else if (height < 0) {
3532 action = ACTION_SOUTH_EAST;
3533 height = -height;
3534 top -= height;
3535 }
3536 break;
3537 case ACTION_NORTH_WEST:
3538 if (aspectRatio) {
3539 if (range.y <= 0 && (top <= minTop || left <= minLeft)) {
3540 renderable = false;
3541 break;
3542 }
3543 check(ACTION_NORTH);
3544 height -= range.y;
3545 top += range.y;
3546 width = height * aspectRatio;
3547 left += cropBoxData.width - width;
3548 } else {
3549 check(ACTION_NORTH);
3550 check(ACTION_WEST);
3551 if (range.x <= 0) {
3552 if (left > minLeft) {
3553 width -= range.x;
3554 left += range.x;
3555 } else if (range.y <= 0 && top <= minTop) {
3556 renderable = false;
3557 }
3558 } else {
3559 width -= range.x;
3560 left += range.x;
3561 }
3562 if (range.y <= 0) {
3563 if (top > minTop) {
3564 height -= range.y;
3565 top += range.y;
3566 }
3567 } else {
3568 height -= range.y;
3569 top += range.y;
3570 }
3571 }
3572 if (width < 0 && height < 0) {
3573 action = ACTION_SOUTH_EAST;
3574 height = -height;
3575 width = -width;
3576 top -= height;
3577 left -= width;
3578 } else if (width < 0) {
3579 action = ACTION_NORTH_EAST;
3580 width = -width;
3581 left -= width;
3582 } else if (height < 0) {
3583 action = ACTION_SOUTH_WEST;
3584 height = -height;
3585 top -= height;
3586 }
3587 break;
3588 case ACTION_SOUTH_WEST:
3589 if (aspectRatio) {
3590 if (range.x <= 0 && (left <= minLeft || bottom >= maxHeight)) {
3591 renderable = false;
3592 break;
3593 }
3594 check(ACTION_WEST);
3595 width -= range.x;
3596 left += range.x;
3597 height = width / aspectRatio;
3598 } else {
3599 check(ACTION_SOUTH);
3600 check(ACTION_WEST);
3601 if (range.x <= 0) {
3602 if (left > minLeft) {
3603 width -= range.x;
3604 left += range.x;
3605 } else if (range.y >= 0 && bottom >= maxHeight) {
3606 renderable = false;
3607 }
3608 } else {
3609 width -= range.x;
3610 left += range.x;
3611 }
3612 if (range.y >= 0) {
3613 if (bottom < maxHeight) {
3614 height += range.y;
3615 }
3616 } else {
3617 height += range.y;
3618 }
3619 }
3620 if (width < 0 && height < 0) {
3621 action = ACTION_NORTH_EAST;
3622 height = -height;
3623 width = -width;
3624 top -= height;
3625 left -= width;
3626 } else if (width < 0) {
3627 action = ACTION_SOUTH_EAST;
3628 width = -width;
3629 left -= width;
3630 } else if (height < 0) {
3631 action = ACTION_NORTH_WEST;
3632 height = -height;
3633 top -= height;
3634 }
3635 break;
3636 case ACTION_SOUTH_EAST:
3637 if (aspectRatio) {
3638 if (range.x >= 0 && (right >= maxWidth || bottom >= maxHeight)) {
3639 renderable = false;
3640 break;
3641 }
3642 check(ACTION_EAST);
3643 width += range.x;
3644 height = width / aspectRatio;
3645 } else {
3646 check(ACTION_SOUTH);
3647 check(ACTION_EAST);
3648 if (range.x >= 0) {
3649 if (right < maxWidth) {
3650 width += range.x;
3651 } else if (range.y >= 0 && bottom >= maxHeight) {
3652 renderable = false;
3653 }
3654 } else {
3655 width += range.x;
3656 }
3657 if (range.y >= 0) {
3658 if (bottom < maxHeight) {
3659 height += range.y;
3660 }
3661 } else {
3662 height += range.y;
3663 }
3664 }
3665 if (width < 0 && height < 0) {
3666 action = ACTION_NORTH_WEST;
3667 height = -height;
3668 width = -width;
3669 top -= height;
3670 left -= width;
3671 } else if (width < 0) {
3672 action = ACTION_SOUTH_WEST;
3673 width = -width;
3674 left -= width;
3675 } else if (height < 0) {
3676 action = ACTION_NORTH_EAST;
3677 height = -height;
3678 top -= height;
3679 }
3680 break;
3681
3682 // Move canvas
3683 case ACTION_MOVE:
3684 this.move(range.x, range.y);
3685 renderable = false;
3686 break;
3687
3688 // Zoom canvas
3689 case ACTION_ZOOM:
3690 this.zoom(getMaxZoomRatio(pointers), event);
3691 renderable = false;
3692 break;
3693
3694 // Create crop box
3695 case ACTION_CROP:
3696 if (!range.x || !range.y) {
3697 renderable = false;
3698 break;
3699 }
3700 offset = getOffset(this.cropper);
3701 left = pointer.startX - offset.left;
3702 top = pointer.startY - offset.top;
3703 width = cropBoxData.minWidth;
3704 height = cropBoxData.minHeight;
3705 if (range.x > 0) {
3706 action = range.y > 0 ? ACTION_SOUTH_EAST : ACTION_NORTH_EAST;
3707 } else if (range.x < 0) {
3708 left -= width;
3709 action = range.y > 0 ? ACTION_SOUTH_WEST : ACTION_NORTH_WEST;
3710 }
3711 if (range.y < 0) {
3712 top -= height;
3713 }
3714
3715 // Show the crop box if is hidden
3716 if (!this.cropped) {
3717 removeClass(this.cropBox, CLASS_HIDDEN);
3718 this.cropped = true;
3719 if (this.limited) {
3720 this.limitCropBox(true, true);
3721 }
3722 }
3723 break;
3724 }
3725 if (renderable) {
3726 cropBoxData.width = width;
3727 cropBoxData.height = height;
3728 cropBoxData.left = left;
3729 cropBoxData.top = top;
3730 this.action = action;
3731 this.renderCropBox();
3732 }
3733
3734 // Override
3735 forEach(pointers, function (p) {
3736 p.startX = p.endX;
3737 p.startY = p.endY;
3738 });
3739 }
3740 };
3741
3742 var methods = {
3743 // Show the crop box manually
3744 crop: function crop() {
3745 if (this.ready && !this.cropped && !this.disabled) {
3746 this.cropped = true;
3747 this.limitCropBox(true, true);
3748 if (this.options.modal) {
3749 addClass(this.dragBox, CLASS_MODAL);
3750 }
3751 removeClass(this.cropBox, CLASS_HIDDEN);
3752 this.setCropBoxData(this.initialCropBoxData);
3753 }
3754 return this;
3755 },
3756 // Reset the image and crop box to their initial states
3757 reset: function reset() {
3758 if (this.ready && !this.disabled) {
3759 this.imageData = assign({}, this.initialImageData);
3760 this.canvasData = assign({}, this.initialCanvasData);
3761 this.cropBoxData = assign({}, this.initialCropBoxData);
3762 this.renderCanvas();
3763 if (this.cropped) {
3764 this.renderCropBox();
3765 }
3766 }
3767 return this;
3768 },
3769 // Clear the crop box
3770 clear: function clear() {
3771 if (this.cropped && !this.disabled) {
3772 assign(this.cropBoxData, {
3773 left: 0,
3774 top: 0,
3775 width: 0,
3776 height: 0
3777 });
3778 this.cropped = false;
3779 this.renderCropBox();
3780 this.limitCanvas(true, true);
3781
3782 // Render canvas after crop box rendered
3783 this.renderCanvas();
3784 removeClass(this.dragBox, CLASS_MODAL);
3785 addClass(this.cropBox, CLASS_HIDDEN);
3786 }
3787 return this;
3788 },
3789 /**
3790 * Replace the image's src and rebuild the cropper
3791 * @param {string} url - The new URL.
3792 * @param {boolean} [hasSameSize] - Indicate if the new image has the same size as the old one.
3793 * @returns {Cropper} this
3794 */
3795 replace: function replace(url) {
3796 var hasSameSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3797 if (!this.disabled && url) {
3798 if (this.isImg) {
3799 this.element.src = url;
3800 }
3801 if (hasSameSize) {
3802 this.url = url;
3803 this.image.src = url;
3804 if (this.ready) {
3805 this.viewBoxImage.src = url;
3806 forEach(this.previews, function (element) {
3807 element.getElementsByTagName('img')[0].src = url;
3808 });
3809 }
3810 } else {
3811 if (this.isImg) {
3812 this.replaced = true;
3813 }
3814 this.options.data = null;
3815 this.uncreate();
3816 this.load(url);
3817 }
3818 }
3819 return this;
3820 },
3821 // Enable (unfreeze) the cropper
3822 enable: function enable() {
3823 if (this.ready && this.disabled) {
3824 this.disabled = false;
3825 removeClass(this.cropper, CLASS_DISABLED);
3826 }
3827 return this;
3828 },
3829 // Disable (freeze) the cropper
3830 disable: function disable() {
3831 if (this.ready && !this.disabled) {
3832 this.disabled = true;
3833 addClass(this.cropper, CLASS_DISABLED);
3834 }
3835 return this;
3836 },
3837 /**
3838 * Destroy the cropper and remove the instance from the image
3839 * @returns {Cropper} this
3840 */
3841 destroy: function destroy() {
3842 var element = this.element;
3843 if (!element[NAMESPACE]) {
3844 return this;
3845 }
3846 element[NAMESPACE] = undefined;
3847 if (this.isImg && this.replaced) {
3848 element.src = this.originalUrl;
3849 }
3850 this.uncreate();
3851 return this;
3852 },
3853 /**
3854 * Move the canvas with relative offsets
3855 * @param {number} offsetX - The relative offset distance on the x-axis.
3856 * @param {number} [offsetY=offsetX] - The relative offset distance on the y-axis.
3857 * @returns {Cropper} this
3858 */
3859 move: function move(offsetX) {
3860 var offsetY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : offsetX;
3861 var _this$canvasData = this.canvasData,
3862 left = _this$canvasData.left,
3863 top = _this$canvasData.top;
3864 return this.moveTo(isUndefined(offsetX) ? offsetX : left + Number(offsetX), isUndefined(offsetY) ? offsetY : top + Number(offsetY));
3865 },
3866 /**
3867 * Move the canvas to an absolute point
3868 * @param {number} x - The x-axis coordinate.
3869 * @param {number} [y=x] - The y-axis coordinate.
3870 * @returns {Cropper} this
3871 */
3872 moveTo: function moveTo(x) {
3873 var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
3874 var canvasData = this.canvasData;
3875 var changed = false;
3876 x = Number(x);
3877 y = Number(y);
3878 if (this.ready && !this.disabled && this.options.movable) {
3879 if (isNumber(x)) {
3880 canvasData.left = x;
3881 changed = true;
3882 }
3883 if (isNumber(y)) {
3884 canvasData.top = y;
3885 changed = true;
3886 }
3887 if (changed) {
3888 this.renderCanvas(true);
3889 }
3890 }
3891 return this;
3892 },
3893 /**
3894 * Zoom the canvas with a relative ratio
3895 * @param {number} ratio - The target ratio.
3896 * @param {Event} _originalEvent - The original event if any.
3897 * @returns {Cropper} this
3898 */
3899 zoom: function zoom(ratio, _originalEvent) {
3900 var canvasData = this.canvasData;
3901 ratio = Number(ratio);
3902 if (ratio < 0) {
3903 ratio = 1 / (1 - ratio);
3904 } else {
3905 ratio = 1 + ratio;
3906 }
3907 return this.zoomTo(canvasData.width * ratio / canvasData.naturalWidth, null, _originalEvent);
3908 },
3909 /**
3910 * Zoom the canvas to an absolute ratio
3911 * @param {number} ratio - The target ratio.
3912 * @param {Object} pivot - The zoom pivot point coordinate.
3913 * @param {Event} _originalEvent - The original event if any.
3914 * @returns {Cropper} this
3915 */
3916 zoomTo: function zoomTo(ratio, pivot, _originalEvent) {
3917 var options = this.options,
3918 canvasData = this.canvasData;
3919 var width = canvasData.width,
3920 height = canvasData.height,
3921 naturalWidth = canvasData.naturalWidth,
3922 naturalHeight = canvasData.naturalHeight;
3923 ratio = Number(ratio);
3924 if (ratio >= 0 && this.ready && !this.disabled && options.zoomable) {
3925 var newWidth = naturalWidth * ratio;
3926 var newHeight = naturalHeight * ratio;
3927 if (dispatchEvent(this.element, EVENT_ZOOM, {
3928 ratio: ratio,
3929 oldRatio: width / naturalWidth,
3930 originalEvent: _originalEvent
3931 }) === false) {
3932 return this;
3933 }
3934 if (_originalEvent) {
3935 var pointers = this.pointers;
3936 var offset = getOffset(this.cropper);
3937 var center = pointers && Object.keys(pointers).length ? getPointersCenter(pointers) : {
3938 pageX: _originalEvent.pageX,
3939 pageY: _originalEvent.pageY
3940 };
3941
3942 // Zoom from the triggering point of the event
3943 canvasData.left -= (newWidth - width) * ((center.pageX - offset.left - canvasData.left) / width);
3944 canvasData.top -= (newHeight - height) * ((center.pageY - offset.top - canvasData.top) / height);
3945 } else if (isPlainObject(pivot) && isNumber(pivot.x) && isNumber(pivot.y)) {
3946 canvasData.left -= (newWidth - width) * ((pivot.x - canvasData.left) / width);
3947 canvasData.top -= (newHeight - height) * ((pivot.y - canvasData.top) / height);
3948 } else {
3949 // Zoom from the center of the canvas
3950 canvasData.left -= (newWidth - width) / 2;
3951 canvasData.top -= (newHeight - height) / 2;
3952 }
3953 canvasData.width = newWidth;
3954 canvasData.height = newHeight;
3955 this.renderCanvas(true);
3956 }
3957 return this;
3958 },
3959 /**
3960 * Rotate the canvas with a relative degree
3961 * @param {number} degree - The rotate degree.
3962 * @returns {Cropper} this
3963 */
3964 rotate: function rotate(degree) {
3965 return this.rotateTo((this.imageData.rotate || 0) + Number(degree));
3966 },
3967 /**
3968 * Rotate the canvas to an absolute degree
3969 * @param {number} degree - The rotate degree.
3970 * @returns {Cropper} this
3971 */
3972 rotateTo: function rotateTo(degree) {
3973 degree = Number(degree);
3974 if (isNumber(degree) && this.ready && !this.disabled && this.options.rotatable) {
3975 this.imageData.rotate = degree % 360;
3976 this.renderCanvas(true, true);
3977 }
3978 return this;
3979 },
3980 /**
3981 * Scale the image on the x-axis.
3982 * @param {number} scaleX - The scale ratio on the x-axis.
3983 * @returns {Cropper} this
3984 */
3985 scaleX: function scaleX(_scaleX) {
3986 var scaleY = this.imageData.scaleY;
3987 return this.scale(_scaleX, isNumber(scaleY) ? scaleY : 1);
3988 },
3989 /**
3990 * Scale the image on the y-axis.
3991 * @param {number} scaleY - The scale ratio on the y-axis.
3992 * @returns {Cropper} this
3993 */
3994 scaleY: function scaleY(_scaleY) {
3995 var scaleX = this.imageData.scaleX;
3996 return this.scale(isNumber(scaleX) ? scaleX : 1, _scaleY);
3997 },
3998 /**
3999 * Scale the image
4000 * @param {number} scaleX - The scale ratio on the x-axis.
4001 * @param {number} [scaleY=scaleX] - The scale ratio on the y-axis.
4002 * @returns {Cropper} this
4003 */
4004 scale: function scale(scaleX) {
4005 var scaleY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : scaleX;
4006 var imageData = this.imageData;
4007 var transformed = false;
4008 scaleX = Number(scaleX);
4009 scaleY = Number(scaleY);
4010 if (this.ready && !this.disabled && this.options.scalable) {
4011 if (isNumber(scaleX)) {
4012 imageData.scaleX = scaleX;
4013 transformed = true;
4014 }
4015 if (isNumber(scaleY)) {
4016 imageData.scaleY = scaleY;
4017 transformed = true;
4018 }
4019 if (transformed) {
4020 this.renderCanvas(true, true);
4021 }
4022 }
4023 return this;
4024 },
4025 /**
4026 * Get the cropped area position and size data (base on the original image)
4027 * @param {boolean} [rounded=false] - Indicate if round the data values or not.
4028 * @returns {Object} The result cropped data.
4029 */
4030 getData: function getData() {
4031 var rounded = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
4032 var options = this.options,
4033 imageData = this.imageData,
4034 canvasData = this.canvasData,
4035 cropBoxData = this.cropBoxData;
4036 var data;
4037 if (this.ready && this.cropped) {
4038 data = {
4039 x: cropBoxData.left - canvasData.left,
4040 y: cropBoxData.top - canvasData.top,
4041 width: cropBoxData.width,
4042 height: cropBoxData.height
4043 };
4044 var ratio = imageData.width / imageData.naturalWidth;
4045 forEach(data, function (n, i) {
4046 data[i] = n / ratio;
4047 });
4048 if (rounded) {
4049 // In case rounding off leads to extra 1px in right or bottom border
4050 // we should round the top-left corner and the dimension (#343).
4051 var bottom = Math.round(data.y + data.height);
4052 var right = Math.round(data.x + data.width);
4053 data.x = Math.round(data.x);
4054 data.y = Math.round(data.y);
4055 data.width = right - data.x;
4056 data.height = bottom - data.y;
4057 }
4058 } else {
4059 data = {
4060 x: 0,
4061 y: 0,
4062 width: 0,
4063 height: 0
4064 };
4065 }
4066 if (options.rotatable) {
4067 data.rotate = imageData.rotate || 0;
4068 }
4069 if (options.scalable) {
4070 data.scaleX = imageData.scaleX || 1;
4071 data.scaleY = imageData.scaleY || 1;
4072 }
4073 return data;
4074 },
4075 /**
4076 * Set the cropped area position and size with new data
4077 * @param {Object} data - The new data.
4078 * @returns {Cropper} this
4079 */
4080 setData: function setData(data) {
4081 var options = this.options,
4082 imageData = this.imageData,
4083 canvasData = this.canvasData;
4084 var cropBoxData = {};
4085 if (this.ready && !this.disabled && isPlainObject(data)) {
4086 var transformed = false;
4087 if (options.rotatable) {
4088 if (isNumber(data.rotate) && data.rotate !== imageData.rotate) {
4089 imageData.rotate = data.rotate;
4090 transformed = true;
4091 }
4092 }
4093 if (options.scalable) {
4094 if (isNumber(data.scaleX) && data.scaleX !== imageData.scaleX) {
4095 imageData.scaleX = data.scaleX;
4096 transformed = true;
4097 }
4098 if (isNumber(data.scaleY) && data.scaleY !== imageData.scaleY) {
4099 imageData.scaleY = data.scaleY;
4100 transformed = true;
4101 }
4102 }
4103 if (transformed) {
4104 this.renderCanvas(true, true);
4105 }
4106 var ratio = imageData.width / imageData.naturalWidth;
4107 if (isNumber(data.x)) {
4108 cropBoxData.left = data.x * ratio + canvasData.left;
4109 }
4110 if (isNumber(data.y)) {
4111 cropBoxData.top = data.y * ratio + canvasData.top;
4112 }
4113 if (isNumber(data.width)) {
4114 cropBoxData.width = data.width * ratio;
4115 }
4116 if (isNumber(data.height)) {
4117 cropBoxData.height = data.height * ratio;
4118 }
4119 this.setCropBoxData(cropBoxData);
4120 }
4121 return this;
4122 },
4123 /**
4124 * Get the container size data.
4125 * @returns {Object} The result container data.
4126 */
4127 getContainerData: function getContainerData() {
4128 return this.ready ? assign({}, this.containerData) : {};
4129 },
4130 /**
4131 * Get the image position and size data.
4132 * @returns {Object} The result image data.
4133 */
4134 getImageData: function getImageData() {
4135 return this.sized ? assign({}, this.imageData) : {};
4136 },
4137 /**
4138 * Get the canvas position and size data.
4139 * @returns {Object} The result canvas data.
4140 */
4141 getCanvasData: function getCanvasData() {
4142 var canvasData = this.canvasData;
4143 var data = {};
4144 if (this.ready) {
4145 forEach(['left', 'top', 'width', 'height', 'naturalWidth', 'naturalHeight'], function (n) {
4146 data[n] = canvasData[n];
4147 });
4148 }
4149 return data;
4150 },
4151 /**
4152 * Set the canvas position and size with new data.
4153 * @param {Object} data - The new canvas data.
4154 * @returns {Cropper} this
4155 */
4156 setCanvasData: function setCanvasData(data) {
4157 var canvasData = this.canvasData;
4158 var aspectRatio = canvasData.aspectRatio;
4159 if (this.ready && !this.disabled && isPlainObject(data)) {
4160 if (isNumber(data.left)) {
4161 canvasData.left = data.left;
4162 }
4163 if (isNumber(data.top)) {
4164 canvasData.top = data.top;
4165 }
4166 if (isNumber(data.width)) {
4167 canvasData.width = data.width;
4168 canvasData.height = data.width / aspectRatio;
4169 } else if (isNumber(data.height)) {
4170 canvasData.height = data.height;
4171 canvasData.width = data.height * aspectRatio;
4172 }
4173 this.renderCanvas(true);
4174 }
4175 return this;
4176 },
4177 /**
4178 * Get the crop box position and size data.
4179 * @returns {Object} The result crop box data.
4180 */
4181 getCropBoxData: function getCropBoxData() {
4182 var cropBoxData = this.cropBoxData;
4183 var data;
4184 if (this.ready && this.cropped) {
4185 data = {
4186 left: cropBoxData.left,
4187 top: cropBoxData.top,
4188 width: cropBoxData.width,
4189 height: cropBoxData.height
4190 };
4191 }
4192 return data || {};
4193 },
4194 /**
4195 * Set the crop box position and size with new data.
4196 * @param {Object} data - The new crop box data.
4197 * @returns {Cropper} this
4198 */
4199 setCropBoxData: function setCropBoxData(data) {
4200 var cropBoxData = this.cropBoxData;
4201 var aspectRatio = this.options.aspectRatio;
4202 var widthChanged;
4203 var heightChanged;
4204 if (this.ready && this.cropped && !this.disabled && isPlainObject(data)) {
4205 if (isNumber(data.left)) {
4206 cropBoxData.left = data.left;
4207 }
4208 if (isNumber(data.top)) {
4209 cropBoxData.top = data.top;
4210 }
4211 if (isNumber(data.width) && data.width !== cropBoxData.width) {
4212 widthChanged = true;
4213 cropBoxData.width = data.width;
4214 }
4215 if (isNumber(data.height) && data.height !== cropBoxData.height) {
4216 heightChanged = true;
4217 cropBoxData.height = data.height;
4218 }
4219 if (aspectRatio) {
4220 if (widthChanged) {
4221 cropBoxData.height = cropBoxData.width / aspectRatio;
4222 } else if (heightChanged) {
4223 cropBoxData.width = cropBoxData.height * aspectRatio;
4224 }
4225 }
4226 this.renderCropBox();
4227 }
4228 return this;
4229 },
4230 /**
4231 * Get a canvas drawn the cropped image.
4232 * @param {Object} [options={}] - The config options.
4233 * @returns {HTMLCanvasElement} - The result canvas.
4234 */
4235 getCroppedCanvas: function getCroppedCanvas() {
4236 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4237 if (!this.ready || !window.HTMLCanvasElement) {
4238 return null;
4239 }
4240 var canvasData = this.canvasData;
4241 var source = getSourceCanvas(this.image, this.imageData, canvasData, options);
4242
4243 // Returns the source canvas if it is not cropped.
4244 if (!this.cropped) {
4245 return source;
4246 }
4247 var _this$getData = this.getData(options.rounded),
4248 initialX = _this$getData.x,
4249 initialY = _this$getData.y,
4250 initialWidth = _this$getData.width,
4251 initialHeight = _this$getData.height;
4252 var ratio = source.width / Math.floor(canvasData.naturalWidth);
4253 if (ratio !== 1) {
4254 initialX *= ratio;
4255 initialY *= ratio;
4256 initialWidth *= ratio;
4257 initialHeight *= ratio;
4258 }
4259 var aspectRatio = initialWidth / initialHeight;
4260 var maxSizes = getAdjustedSizes({
4261 aspectRatio: aspectRatio,
4262 width: options.maxWidth || Infinity,
4263 height: options.maxHeight || Infinity
4264 });
4265 var minSizes = getAdjustedSizes({
4266 aspectRatio: aspectRatio,
4267 width: options.minWidth || 0,
4268 height: options.minHeight || 0
4269 }, 'cover');
4270 var _getAdjustedSizes = getAdjustedSizes({
4271 aspectRatio: aspectRatio,
4272 width: options.width || (ratio !== 1 ? source.width : initialWidth),
4273 height: options.height || (ratio !== 1 ? source.height : initialHeight)
4274 }),
4275 width = _getAdjustedSizes.width,
4276 height = _getAdjustedSizes.height;
4277 width = Math.min(maxSizes.width, Math.max(minSizes.width, width));
4278 height = Math.min(maxSizes.height, Math.max(minSizes.height, height));
4279 var canvas = document.createElement('canvas');
4280 var context = canvas.getContext('2d');
4281 canvas.width = normalizeDecimalNumber(width);
4282 canvas.height = normalizeDecimalNumber(height);
4283 context.fillStyle = options.fillColor || 'transparent';
4284 context.fillRect(0, 0, width, height);
4285 var _options$imageSmoothi = options.imageSmoothingEnabled,
4286 imageSmoothingEnabled = _options$imageSmoothi === void 0 ? true : _options$imageSmoothi,
4287 imageSmoothingQuality = options.imageSmoothingQuality;
4288 context.imageSmoothingEnabled = imageSmoothingEnabled;
4289 if (imageSmoothingQuality) {
4290 context.imageSmoothingQuality = imageSmoothingQuality;
4291 }
4292
4293 // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D.drawImage
4294 var sourceWidth = source.width;
4295 var sourceHeight = source.height;
4296
4297 // Source canvas parameters
4298 var srcX = initialX;
4299 var srcY = initialY;
4300 var srcWidth;
4301 var srcHeight;
4302
4303 // Destination canvas parameters
4304 var dstX;
4305 var dstY;
4306 var dstWidth;
4307 var dstHeight;
4308 if (srcX <= -initialWidth || srcX > sourceWidth) {
4309 srcX = 0;
4310 srcWidth = 0;
4311 dstX = 0;
4312 dstWidth = 0;
4313 } else if (srcX <= 0) {
4314 dstX = -srcX;
4315 srcX = 0;
4316 srcWidth = Math.min(sourceWidth, initialWidth + srcX);
4317 dstWidth = srcWidth;
4318 } else if (srcX <= sourceWidth) {
4319 dstX = 0;
4320 srcWidth = Math.min(initialWidth, sourceWidth - srcX);
4321 dstWidth = srcWidth;
4322 }
4323 if (srcWidth <= 0 || srcY <= -initialHeight || srcY > sourceHeight) {
4324 srcY = 0;
4325 srcHeight = 0;
4326 dstY = 0;
4327 dstHeight = 0;
4328 } else if (srcY <= 0) {
4329 dstY = -srcY;
4330 srcY = 0;
4331 srcHeight = Math.min(sourceHeight, initialHeight + srcY);
4332 dstHeight = srcHeight;
4333 } else if (srcY <= sourceHeight) {
4334 dstY = 0;
4335 srcHeight = Math.min(initialHeight, sourceHeight - srcY);
4336 dstHeight = srcHeight;
4337 }
4338 var params = [srcX, srcY, srcWidth, srcHeight];
4339
4340 // Avoid "IndexSizeError"
4341 if (dstWidth > 0 && dstHeight > 0) {
4342 var scale = width / initialWidth;
4343 params.push(dstX * scale, dstY * scale, dstWidth * scale, dstHeight * scale);
4344 }
4345
4346 // All the numerical parameters should be integer for `drawImage`
4347 // https://github.com/fengyuanchen/cropper/issues/476
4348 context.drawImage.apply(context, [source].concat(_toConsumableArray(params.map(function (param) {
4349 return Math.floor(normalizeDecimalNumber(param));
4350 }))));
4351 return canvas;
4352 },
4353 /**
4354 * Change the aspect ratio of the crop box.
4355 * @param {number} aspectRatio - The new aspect ratio.
4356 * @returns {Cropper} this
4357 */
4358 setAspectRatio: function setAspectRatio(aspectRatio) {
4359 var options = this.options;
4360 if (!this.disabled && !isUndefined(aspectRatio)) {
4361 // 0 -> NaN
4362 options.aspectRatio = Math.max(0, aspectRatio) || NaN;
4363 if (this.ready) {
4364 this.initCropBox();
4365 if (this.cropped) {
4366 this.renderCropBox();
4367 }
4368 }
4369 }
4370 return this;
4371 },
4372 /**
4373 * Change the drag mode.
4374 * @param {string} mode - The new drag mode.
4375 * @returns {Cropper} this
4376 */
4377 setDragMode: function setDragMode(mode) {
4378 var options = this.options,
4379 dragBox = this.dragBox,
4380 face = this.face;
4381 if (this.ready && !this.disabled) {
4382 var croppable = mode === DRAG_MODE_CROP;
4383 var movable = options.movable && mode === DRAG_MODE_MOVE;
4384 mode = croppable || movable ? mode : DRAG_MODE_NONE;
4385 options.dragMode = mode;
4386 setData(dragBox, DATA_ACTION, mode);
4387 toggleClass(dragBox, CLASS_CROP, croppable);
4388 toggleClass(dragBox, CLASS_MOVE, movable);
4389 if (!options.cropBoxMovable) {
4390 // Sync drag mode to crop box when it is not movable
4391 setData(face, DATA_ACTION, mode);
4392 toggleClass(face, CLASS_CROP, croppable);
4393 toggleClass(face, CLASS_MOVE, movable);
4394 }
4395 }
4396 return this;
4397 }
4398 };
4399
4400 var AnotherCropper = WINDOW.Cropper;
4401 var Cropper = /*#__PURE__*/function () {
4402 /**
4403 * Create a new Cropper.
4404 * @param {Element} element - The target element for cropping.
4405 * @param {Object} [options={}] - The configuration options.
4406 */
4407 function Cropper(element) {
4408 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4409 _classCallCheck(this, Cropper);
4410 if (!element || !REGEXP_TAG_NAME.test(element.tagName)) {
4411 throw new Error('The first argument is required and must be an <img> or <canvas> element.');
4412 }
4413 this.element = element;
4414 this.options = assign({}, DEFAULTS, isPlainObject(options) && options);
4415 this.cropped = false;
4416 this.disabled = false;
4417 this.pointers = {};
4418 this.ready = false;
4419 this.reloading = false;
4420 this.replaced = false;
4421 this.sized = false;
4422 this.sizing = false;
4423 this.init();
4424 }
4425 return _createClass(Cropper, [{
4426 key: "init",
4427 value: function init() {
4428 var element = this.element;
4429 var tagName = element.tagName.toLowerCase();
4430 var url;
4431 if (element[NAMESPACE]) {
4432 return;
4433 }
4434 element[NAMESPACE] = this;
4435 if (tagName === 'img') {
4436 this.isImg = true;
4437
4438 // e.g.: "img/picture.jpg"
4439 url = element.getAttribute('src') || '';
4440 this.originalUrl = url;
4441
4442 // Stop when it's a blank image
4443 if (!url) {
4444 return;
4445 }
4446
4447 // e.g.: "https://example.com/img/picture.jpg"
4448 url = element.src;
4449 } else if (tagName === 'canvas' && window.HTMLCanvasElement) {
4450 url = element.toDataURL();
4451 }
4452 this.load(url);
4453 }
4454 }, {
4455 key: "load",
4456 value: function load(url) {
4457 var _this = this;
4458 if (!url) {
4459 return;
4460 }
4461 this.url = url;
4462 this.imageData = {};
4463 var element = this.element,
4464 options = this.options;
4465 if (!options.rotatable && !options.scalable) {
4466 options.checkOrientation = false;
4467 }
4468
4469 // Only IE10+ supports Typed Arrays
4470 if (!options.checkOrientation || !window.ArrayBuffer) {
4471 this.clone();
4472 return;
4473 }
4474
4475 // Detect the mime type of the image directly if it is a Data URL
4476 if (REGEXP_DATA_URL.test(url)) {
4477 // Read ArrayBuffer from Data URL of JPEG images directly for better performance
4478 if (REGEXP_DATA_URL_JPEG.test(url)) {
4479 this.read(dataURLToArrayBuffer(url));
4480 } else {
4481 // Only a JPEG image may contains Exif Orientation information,
4482 // the rest types of Data URLs are not necessary to check orientation at all.
4483 this.clone();
4484 }
4485 return;
4486 }
4487
4488 // 1. Detect the mime type of the image by a XMLHttpRequest.
4489 // 2. Load the image as ArrayBuffer for reading orientation if its a JPEG image.
4490 var xhr = new XMLHttpRequest();
4491 var clone = this.clone.bind(this);
4492 this.reloading = true;
4493 this.xhr = xhr;
4494
4495 // 1. Cross origin requests are only supported for protocol schemes:
4496 // http, https, data, chrome, chrome-extension.
4497 // 2. Access to XMLHttpRequest from a Data URL will be blocked by CORS policy
4498 // in some browsers as IE11 and Safari.
4499 xhr.onabort = clone;
4500 xhr.onerror = clone;
4501 xhr.ontimeout = clone;
4502 xhr.onprogress = function () {
4503 // Abort the request directly if it not a JPEG image for better performance
4504 if (xhr.getResponseHeader('content-type') !== MIME_TYPE_JPEG) {
4505 xhr.abort();
4506 }
4507 };
4508 xhr.onload = function () {
4509 _this.read(xhr.response);
4510 };
4511 xhr.onloadend = function () {
4512 _this.reloading = false;
4513 _this.xhr = null;
4514 };
4515
4516 // Bust cache when there is a "crossOrigin" property to avoid browser cache error
4517 if (options.checkCrossOrigin && isCrossOriginURL(url) && element.crossOrigin) {
4518 url = addTimestamp(url);
4519 }
4520
4521 // The third parameter is required for avoiding side-effect (#682)
4522 xhr.open('GET', url, true);
4523 xhr.responseType = 'arraybuffer';
4524 xhr.withCredentials = element.crossOrigin === 'use-credentials';
4525 xhr.send();
4526 }
4527 }, {
4528 key: "read",
4529 value: function read(arrayBuffer) {
4530 var options = this.options,
4531 imageData = this.imageData;
4532
4533 // Reset the orientation value to its default value 1
4534 // as some iOS browsers will render image with its orientation
4535 var orientation = resetAndGetOrientation(arrayBuffer);
4536 var rotate = 0;
4537 var scaleX = 1;
4538 var scaleY = 1;
4539 if (orientation > 1) {
4540 // Generate a new URL which has the default orientation value
4541 this.url = arrayBufferToDataURL(arrayBuffer, MIME_TYPE_JPEG);
4542 var _parseOrientation = parseOrientation(orientation);
4543 rotate = _parseOrientation.rotate;
4544 scaleX = _parseOrientation.scaleX;
4545 scaleY = _parseOrientation.scaleY;
4546 }
4547 if (options.rotatable) {
4548 imageData.rotate = rotate;
4549 }
4550 if (options.scalable) {
4551 imageData.scaleX = scaleX;
4552 imageData.scaleY = scaleY;
4553 }
4554 this.clone();
4555 }
4556 }, {
4557 key: "clone",
4558 value: function clone() {
4559 var element = this.element,
4560 url = this.url;
4561 var crossOrigin = element.crossOrigin;
4562 var crossOriginUrl = url;
4563 if (this.options.checkCrossOrigin && isCrossOriginURL(url)) {
4564 if (!crossOrigin) {
4565 crossOrigin = 'anonymous';
4566 }
4567
4568 // Bust cache when there is not a "crossOrigin" property (#519)
4569 crossOriginUrl = addTimestamp(url);
4570 }
4571 this.crossOrigin = crossOrigin;
4572 this.crossOriginUrl = crossOriginUrl;
4573 var image = document.createElement('img');
4574 if (crossOrigin) {
4575 image.crossOrigin = crossOrigin;
4576 }
4577 image.src = crossOriginUrl || url;
4578 image.alt = element.alt || 'The image to crop';
4579 this.image = image;
4580 image.onload = this.start.bind(this);
4581 image.onerror = this.stop.bind(this);
4582 addClass(image, CLASS_HIDE);
4583 element.parentNode.insertBefore(image, element.nextSibling);
4584 }
4585 }, {
4586 key: "start",
4587 value: function start() {
4588 var _this2 = this;
4589 var image = this.image;
4590 image.onload = null;
4591 image.onerror = null;
4592 this.sizing = true;
4593
4594 // Match all browsers that use WebKit as the layout engine in iOS devices,
4595 // such as Safari for iOS, Chrome for iOS, and in-app browsers.
4596 var isIOSWebKit = WINDOW.navigator && /(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(WINDOW.navigator.userAgent);
4597 var done = function done(naturalWidth, naturalHeight) {
4598 assign(_this2.imageData, {
4599 naturalWidth: naturalWidth,
4600 naturalHeight: naturalHeight,
4601 aspectRatio: naturalWidth / naturalHeight
4602 });
4603 _this2.initialImageData = assign({}, _this2.imageData);
4604 _this2.sizing = false;
4605 _this2.sized = true;
4606 _this2.build();
4607 };
4608
4609 // Most modern browsers (excepts iOS WebKit)
4610 if (image.naturalWidth && !isIOSWebKit) {
4611 done(image.naturalWidth, image.naturalHeight);
4612 return;
4613 }
4614 var sizingImage = document.createElement('img');
4615 var body = document.body || document.documentElement;
4616 this.sizingImage = sizingImage;
4617 sizingImage.onload = function () {
4618 done(sizingImage.width, sizingImage.height);
4619 if (!isIOSWebKit) {
4620 body.removeChild(sizingImage);
4621 }
4622 };
4623 sizingImage.src = image.src;
4624
4625 // iOS WebKit will convert the image automatically
4626 // with its orientation once append it into DOM (#279)
4627 if (!isIOSWebKit) {
4628 sizingImage.style.cssText = 'left:0;' + 'max-height:none!important;' + 'max-width:none!important;' + 'min-height:0!important;' + 'min-width:0!important;' + 'opacity:0;' + 'position:absolute;' + 'top:0;' + 'z-index:-1;';
4629 body.appendChild(sizingImage);
4630 }
4631 }
4632 }, {
4633 key: "stop",
4634 value: function stop() {
4635 var image = this.image;
4636 image.onload = null;
4637 image.onerror = null;
4638 image.parentNode.removeChild(image);
4639 this.image = null;
4640 }
4641 }, {
4642 key: "build",
4643 value: function build() {
4644 if (!this.sized || this.ready) {
4645 return;
4646 }
4647 var element = this.element,
4648 options = this.options,
4649 image = this.image;
4650
4651 // Create cropper elements
4652 var container = element.parentNode;
4653 var template = document.createElement('div');
4654 template.innerHTML = TEMPLATE;
4655 var cropper = template.querySelector(".".concat(NAMESPACE, "-container"));
4656 var canvas = cropper.querySelector(".".concat(NAMESPACE, "-canvas"));
4657 var dragBox = cropper.querySelector(".".concat(NAMESPACE, "-drag-box"));
4658 var cropBox = cropper.querySelector(".".concat(NAMESPACE, "-crop-box"));
4659 var face = cropBox.querySelector(".".concat(NAMESPACE, "-face"));
4660 this.container = container;
4661 this.cropper = cropper;
4662 this.canvas = canvas;
4663 this.dragBox = dragBox;
4664 this.cropBox = cropBox;
4665 this.viewBox = cropper.querySelector(".".concat(NAMESPACE, "-view-box"));
4666 this.face = face;
4667 canvas.appendChild(image);
4668
4669 // Hide the original image
4670 addClass(element, CLASS_HIDDEN);
4671
4672 // Inserts the cropper after to the current image
4673 container.insertBefore(cropper, element.nextSibling);
4674
4675 // Show the hidden image
4676 removeClass(image, CLASS_HIDE);
4677 this.initPreview();
4678 this.bind();
4679 options.initialAspectRatio = Math.max(0, options.initialAspectRatio) || NaN;
4680 options.aspectRatio = Math.max(0, options.aspectRatio) || NaN;
4681 options.viewMode = Math.max(0, Math.min(3, Math.round(options.viewMode))) || 0;
4682 addClass(cropBox, CLASS_HIDDEN);
4683 if (!options.guides) {
4684 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-dashed")), CLASS_HIDDEN);
4685 }
4686 if (!options.center) {
4687 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-center")), CLASS_HIDDEN);
4688 }
4689 if (options.background) {
4690 addClass(cropper, "".concat(NAMESPACE, "-bg"));
4691 }
4692 if (!options.highlight) {
4693 addClass(face, CLASS_INVISIBLE);
4694 }
4695 if (options.cropBoxMovable) {
4696 addClass(face, CLASS_MOVE);
4697 setData(face, DATA_ACTION, ACTION_ALL);
4698 }
4699 if (!options.cropBoxResizable) {
4700 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-line")), CLASS_HIDDEN);
4701 addClass(cropBox.getElementsByClassName("".concat(NAMESPACE, "-point")), CLASS_HIDDEN);
4702 }
4703 this.render();
4704 this.ready = true;
4705 this.setDragMode(options.dragMode);
4706 if (options.autoCrop) {
4707 this.crop();
4708 }
4709 this.setData(options.data);
4710 if (isFunction(options.ready)) {
4711 addListener(element, EVENT_READY, options.ready, {
4712 once: true
4713 });
4714 }
4715 dispatchEvent(element, EVENT_READY);
4716 }
4717 }, {
4718 key: "unbuild",
4719 value: function unbuild() {
4720 if (!this.ready) {
4721 return;
4722 }
4723 this.ready = false;
4724 this.unbind();
4725 this.resetPreview();
4726 var parentNode = this.cropper.parentNode;
4727 if (parentNode) {
4728 parentNode.removeChild(this.cropper);
4729 }
4730 removeClass(this.element, CLASS_HIDDEN);
4731 }
4732 }, {
4733 key: "uncreate",
4734 value: function uncreate() {
4735 if (this.ready) {
4736 this.unbuild();
4737 this.ready = false;
4738 this.cropped = false;
4739 } else if (this.sizing) {
4740 this.sizingImage.onload = null;
4741 this.sizing = false;
4742 this.sized = false;
4743 } else if (this.reloading) {
4744 this.xhr.onabort = null;
4745 this.xhr.abort();
4746 } else if (this.image) {
4747 this.stop();
4748 }
4749 }
4750
4751 /**
4752 * Get the no conflict cropper class.
4753 * @returns {Cropper} The cropper class.
4754 */
4755 }], [{
4756 key: "noConflict",
4757 value: function noConflict() {
4758 window.Cropper = AnotherCropper;
4759 return Cropper;
4760 }
4761
4762 /**
4763 * Change the default options.
4764 * @param {Object} options - The new default options.
4765 */
4766 }, {
4767 key: "setDefaults",
4768 value: function setDefaults(options) {
4769 assign(DEFAULTS, isPlainObject(options) && options);
4770 }
4771 }]);
4772 }();
4773 assign(Cropper.prototype, render, preview, events, handlers, change, methods);
4774
4775 return Cropper;
4776
4777 }));
4778
4779
4780 /***/ },
4781
4782 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/cropperjs/dist/cropper.css"
4783 /*!***************************************************************************************!*\
4784 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/cropperjs/dist/cropper.css ***!
4785 \***************************************************************************************/
4786 (module, __webpack_exports__, __webpack_require__) {
4787
4788 "use strict";
4789 __webpack_require__.r(__webpack_exports__);
4790 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4791 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
4792 /* harmony export */ });
4793 /* 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");
4794 /* 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__);
4795 /* 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");
4796 /* 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__);
4797 /* harmony import */ var _css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../css-loader/dist/runtime/getUrl.js */ "./node_modules/css-loader/dist/runtime/getUrl.js");
4798 /* harmony import */ var _css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__);
4799 // Imports
4800
4801
4802
4803 var ___CSS_LOADER_URL_IMPORT_0___ = new URL(/* asset import */ __webpack_require__(/*! data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC */ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC"), __webpack_require__.b);
4804 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()));
4805 var ___CSS_LOADER_URL_REPLACEMENT_0___ = _css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(___CSS_LOADER_URL_IMPORT_0___);
4806 // Module
4807 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
4808 * Cropper.js v1.6.2
4809 * https://fengyuanchen.github.io/cropperjs
4810 *
4811 * Copyright 2015-present Chen Fengyuan
4812 * Released under the MIT license
4813 *
4814 * Date: 2024-04-21T07:43:02.731Z
4815 */
4816
4817 .cropper-container {
4818 direction: ltr;
4819 font-size: 0;
4820 line-height: 0;
4821 position: relative;
4822 -ms-touch-action: none;
4823 touch-action: none;
4824 -webkit-touch-callout: none;
4825 -webkit-user-select: none;
4826 -moz-user-select: none;
4827 -ms-user-select: none;
4828 user-select: none;
4829 }
4830
4831 .cropper-container img {
4832 backface-visibility: hidden;
4833 display: block;
4834 height: 100%;
4835 image-orientation: 0deg;
4836 max-height: none !important;
4837 max-width: none !important;
4838 min-height: 0 !important;
4839 min-width: 0 !important;
4840 width: 100%;
4841 }
4842
4843 .cropper-wrap-box,
4844 .cropper-canvas,
4845 .cropper-drag-box,
4846 .cropper-crop-box,
4847 .cropper-modal {
4848 bottom: 0;
4849 left: 0;
4850 position: absolute;
4851 right: 0;
4852 top: 0;
4853 }
4854
4855 .cropper-wrap-box,
4856 .cropper-canvas {
4857 overflow: hidden;
4858 }
4859
4860 .cropper-drag-box {
4861 background-color: #fff;
4862 opacity: 0;
4863 }
4864
4865 .cropper-modal {
4866 background-color: #000;
4867 opacity: 0.5;
4868 }
4869
4870 .cropper-view-box {
4871 display: block;
4872 height: 100%;
4873 outline: 1px solid #39f;
4874 outline-color: rgba(51, 153, 255, 0.75);
4875 overflow: hidden;
4876 width: 100%;
4877 }
4878
4879 .cropper-dashed {
4880 border: 0 dashed #eee;
4881 display: block;
4882 opacity: 0.5;
4883 position: absolute;
4884 }
4885
4886 .cropper-dashed.dashed-h {
4887 border-bottom-width: 1px;
4888 border-top-width: 1px;
4889 height: calc(100% / 3);
4890 left: 0;
4891 top: calc(100% / 3);
4892 width: 100%;
4893 }
4894
4895 .cropper-dashed.dashed-v {
4896 border-left-width: 1px;
4897 border-right-width: 1px;
4898 height: 100%;
4899 left: calc(100% / 3);
4900 top: 0;
4901 width: calc(100% / 3);
4902 }
4903
4904 .cropper-center {
4905 display: block;
4906 height: 0;
4907 left: 50%;
4908 opacity: 0.75;
4909 position: absolute;
4910 top: 50%;
4911 width: 0;
4912 }
4913
4914 .cropper-center::before,
4915 .cropper-center::after {
4916 background-color: #eee;
4917 content: ' ';
4918 display: block;
4919 position: absolute;
4920 }
4921
4922 .cropper-center::before {
4923 height: 1px;
4924 left: -3px;
4925 top: 0;
4926 width: 7px;
4927 }
4928
4929 .cropper-center::after {
4930 height: 7px;
4931 left: 0;
4932 top: -3px;
4933 width: 1px;
4934 }
4935
4936 .cropper-face,
4937 .cropper-line,
4938 .cropper-point {
4939 display: block;
4940 height: 100%;
4941 opacity: 0.1;
4942 position: absolute;
4943 width: 100%;
4944 }
4945
4946 .cropper-face {
4947 background-color: #fff;
4948 left: 0;
4949 top: 0;
4950 }
4951
4952 .cropper-line {
4953 background-color: #39f;
4954 }
4955
4956 .cropper-line.line-e {
4957 cursor: ew-resize;
4958 right: -3px;
4959 top: 0;
4960 width: 5px;
4961 }
4962
4963 .cropper-line.line-n {
4964 cursor: ns-resize;
4965 height: 5px;
4966 left: 0;
4967 top: -3px;
4968 }
4969
4970 .cropper-line.line-w {
4971 cursor: ew-resize;
4972 left: -3px;
4973 top: 0;
4974 width: 5px;
4975 }
4976
4977 .cropper-line.line-s {
4978 bottom: -3px;
4979 cursor: ns-resize;
4980 height: 5px;
4981 left: 0;
4982 }
4983
4984 .cropper-point {
4985 background-color: #39f;
4986 height: 5px;
4987 opacity: 0.75;
4988 width: 5px;
4989 }
4990
4991 .cropper-point.point-e {
4992 cursor: ew-resize;
4993 margin-top: -3px;
4994 right: -3px;
4995 top: 50%;
4996 }
4997
4998 .cropper-point.point-n {
4999 cursor: ns-resize;
5000 left: 50%;
5001 margin-left: -3px;
5002 top: -3px;
5003 }
5004
5005 .cropper-point.point-w {
5006 cursor: ew-resize;
5007 left: -3px;
5008 margin-top: -3px;
5009 top: 50%;
5010 }
5011
5012 .cropper-point.point-s {
5013 bottom: -3px;
5014 cursor: s-resize;
5015 left: 50%;
5016 margin-left: -3px;
5017 }
5018
5019 .cropper-point.point-ne {
5020 cursor: nesw-resize;
5021 right: -3px;
5022 top: -3px;
5023 }
5024
5025 .cropper-point.point-nw {
5026 cursor: nwse-resize;
5027 left: -3px;
5028 top: -3px;
5029 }
5030
5031 .cropper-point.point-sw {
5032 bottom: -3px;
5033 cursor: nesw-resize;
5034 left: -3px;
5035 }
5036
5037 .cropper-point.point-se {
5038 bottom: -3px;
5039 cursor: nwse-resize;
5040 height: 20px;
5041 opacity: 1;
5042 right: -3px;
5043 width: 20px;
5044 }
5045
5046 @media (min-width: 768px) {
5047
5048 .cropper-point.point-se {
5049 height: 15px;
5050 width: 15px;
5051 }
5052 }
5053
5054 @media (min-width: 992px) {
5055
5056 .cropper-point.point-se {
5057 height: 10px;
5058 width: 10px;
5059 }
5060 }
5061
5062 @media (min-width: 1200px) {
5063
5064 .cropper-point.point-se {
5065 height: 5px;
5066 opacity: 0.75;
5067 width: 5px;
5068 }
5069 }
5070
5071 .cropper-point.point-se::before {
5072 background-color: #39f;
5073 bottom: -50%;
5074 content: ' ';
5075 display: block;
5076 height: 200%;
5077 opacity: 0;
5078 position: absolute;
5079 right: -50%;
5080 width: 200%;
5081 }
5082
5083 .cropper-invisible {
5084 opacity: 0;
5085 }
5086
5087 .cropper-bg {
5088 background-image: url(${___CSS_LOADER_URL_REPLACEMENT_0___});
5089 }
5090
5091 .cropper-hide {
5092 display: block;
5093 height: 0;
5094 position: absolute;
5095 width: 0;
5096 }
5097
5098 .cropper-hidden {
5099 display: none !important;
5100 }
5101
5102 .cropper-move {
5103 cursor: move;
5104 }
5105
5106 .cropper-crop {
5107 cursor: crosshair;
5108 }
5109
5110 .cropper-disabled .cropper-drag-box,
5111 .cropper-disabled .cropper-face,
5112 .cropper-disabled .cropper-line,
5113 .cropper-disabled .cropper-point {
5114 cursor: not-allowed;
5115 }
5116 `, "",{"version":3,"sources":["webpack://./node_modules/cropperjs/dist/cropper.css"],"names":[],"mappings":"AAAA;;;;;;;;EAQE;;AAEF;EACE,cAAc;EACd,YAAY;EACZ,cAAc;EACd,kBAAkB;EAClB,sBAAsB;MAClB,kBAAkB;EACtB,2BAA2B;EAC3B,yBAAyB;KACtB,sBAAsB;MACrB,qBAAqB;UACjB,iBAAiB;AAC3B;;AAEA;IACI,2BAA2B;IAC3B,cAAc;IACd,YAAY;IACZ,uBAAuB;IACvB,2BAA2B;IAC3B,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,WAAW;EACb;;AAEF;;;;;EAKE,SAAS;EACT,OAAO;EACP,kBAAkB;EAClB,QAAQ;EACR,MAAM;AACR;;AAEA;;EAEE,gBAAgB;AAClB;;AAEA;EACE,sBAAsB;EACtB,UAAU;AACZ;;AAEA;EACE,sBAAsB;EACtB,YAAY;AACd;;AAEA;EACE,cAAc;EACd,YAAY;EACZ,uBAAuB;EACvB,uCAAuC;EACvC,gBAAgB;EAChB,WAAW;AACb;;AAEA;EACE,qBAAqB;EACrB,cAAc;EACd,YAAY;EACZ,kBAAkB;AACpB;;AAEA;IACI,wBAAwB;IACxB,qBAAqB;IACrB,sBAAsB;IACtB,OAAO;IACP,mBAAmB;IACnB,WAAW;EACb;;AAEF;IACI,sBAAsB;IACtB,uBAAuB;IACvB,YAAY;IACZ,oBAAoB;IACpB,MAAM;IACN,qBAAqB;EACvB;;AAEF;EACE,cAAc;EACd,SAAS;EACT,SAAS;EACT,aAAa;EACb,kBAAkB;EAClB,QAAQ;EACR,QAAQ;AACV;;AAEA;;IAEI,sBAAsB;IACtB,YAAY;IACZ,cAAc;IACd,kBAAkB;EACpB;;AAEF;IACI,WAAW;IACX,UAAU;IACV,MAAM;IACN,UAAU;EACZ;;AAEF;IACI,WAAW;IACX,OAAO;IACP,SAAS;IACT,UAAU;EACZ;;AAEF;;;EAGE,cAAc;EACd,YAAY;EACZ,YAAY;EACZ,kBAAkB;EAClB,WAAW;AACb;;AAEA;EACE,sBAAsB;EACtB,OAAO;EACP,MAAM;AACR;;AAEA;EACE,sBAAsB;AACxB;;AAEA;IACI,iBAAiB;IACjB,WAAW;IACX,MAAM;IACN,UAAU;EACZ;;AAEF;IACI,iBAAiB;IACjB,WAAW;IACX,OAAO;IACP,SAAS;EACX;;AAEF;IACI,iBAAiB;IACjB,UAAU;IACV,MAAM;IACN,UAAU;EACZ;;AAEF;IACI,YAAY;IACZ,iBAAiB;IACjB,WAAW;IACX,OAAO;EACT;;AAEF;EACE,sBAAsB;EACtB,WAAW;EACX,aAAa;EACb,UAAU;AACZ;;AAEA;IACI,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;IACX,QAAQ;EACV;;AAEF;IACI,iBAAiB;IACjB,SAAS;IACT,iBAAiB;IACjB,SAAS;EACX;;AAEF;IACI,iBAAiB;IACjB,UAAU;IACV,gBAAgB;IAChB,QAAQ;EACV;;AAEF;IACI,YAAY;IACZ,gBAAgB;IAChB,SAAS;IACT,iBAAiB;EACnB;;AAEF;IACI,mBAAmB;IACnB,WAAW;IACX,SAAS;EACX;;AAEF;IACI,mBAAmB;IACnB,UAAU;IACV,SAAS;EACX;;AAEF;IACI,YAAY;IACZ,mBAAmB;IACnB,UAAU;EACZ;;AAEF;IACI,YAAY;IACZ,mBAAmB;IACnB,YAAY;IACZ,UAAU;IACV,WAAW;IACX,WAAW;EACb;;AAEF;;AAEA;MACM,YAAY;MACZ,WAAW;EACf;IACE;;AAEJ;;AAEA;MACM,YAAY;MACZ,WAAW;EACf;IACE;;AAEJ;;AAEA;MACM,WAAW;MACX,aAAa;MACb,UAAU;EACd;IACE;;AAEJ;IACI,sBAAsB;IACtB,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,YAAY;IACZ,UAAU;IACV,kBAAkB;IAClB,WAAW;IACX,WAAW;EACb;;AAEF;EACE,UAAU;AACZ;;AAEA;EACE,yDAA+Q;AACjR;;AAEA;EACE,cAAc;EACd,SAAS;EACT,kBAAkB;EAClB,QAAQ;AACV;;AAEA;EACE,wBAAwB;AAC1B;;AAEA;EACE,YAAY;AACd;;AAEA;EACE,iBAAiB;AACnB;;AAEA;;;;EAIE,mBAAmB;AACrB","sourcesContent":["/*!\n * Cropper.js v1.6.2\n * https://fengyuanchen.github.io/cropperjs\n *\n * Copyright 2015-present Chen Fengyuan\n * Released under the MIT license\n *\n * Date: 2024-04-21T07:43:02.731Z\n */\n\n.cropper-container {\n direction: ltr;\n font-size: 0;\n line-height: 0;\n position: relative;\n -ms-touch-action: none;\n touch-action: none;\n -webkit-touch-callout: none;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.cropper-container img {\n backface-visibility: hidden;\n display: block;\n height: 100%;\n image-orientation: 0deg;\n max-height: none !important;\n max-width: none !important;\n min-height: 0 !important;\n min-width: 0 !important;\n width: 100%;\n }\n\n.cropper-wrap-box,\n.cropper-canvas,\n.cropper-drag-box,\n.cropper-crop-box,\n.cropper-modal {\n bottom: 0;\n left: 0;\n position: absolute;\n right: 0;\n top: 0;\n}\n\n.cropper-wrap-box,\n.cropper-canvas {\n overflow: hidden;\n}\n\n.cropper-drag-box {\n background-color: #fff;\n opacity: 0;\n}\n\n.cropper-modal {\n background-color: #000;\n opacity: 0.5;\n}\n\n.cropper-view-box {\n display: block;\n height: 100%;\n outline: 1px solid #39f;\n outline-color: rgba(51, 153, 255, 0.75);\n overflow: hidden;\n width: 100%;\n}\n\n.cropper-dashed {\n border: 0 dashed #eee;\n display: block;\n opacity: 0.5;\n position: absolute;\n}\n\n.cropper-dashed.dashed-h {\n border-bottom-width: 1px;\n border-top-width: 1px;\n height: calc(100% / 3);\n left: 0;\n top: calc(100% / 3);\n width: 100%;\n }\n\n.cropper-dashed.dashed-v {\n border-left-width: 1px;\n border-right-width: 1px;\n height: 100%;\n left: calc(100% / 3);\n top: 0;\n width: calc(100% / 3);\n }\n\n.cropper-center {\n display: block;\n height: 0;\n left: 50%;\n opacity: 0.75;\n position: absolute;\n top: 50%;\n width: 0;\n}\n\n.cropper-center::before,\n .cropper-center::after {\n background-color: #eee;\n content: ' ';\n display: block;\n position: absolute;\n }\n\n.cropper-center::before {\n height: 1px;\n left: -3px;\n top: 0;\n width: 7px;\n }\n\n.cropper-center::after {\n height: 7px;\n left: 0;\n top: -3px;\n width: 1px;\n }\n\n.cropper-face,\n.cropper-line,\n.cropper-point {\n display: block;\n height: 100%;\n opacity: 0.1;\n position: absolute;\n width: 100%;\n}\n\n.cropper-face {\n background-color: #fff;\n left: 0;\n top: 0;\n}\n\n.cropper-line {\n background-color: #39f;\n}\n\n.cropper-line.line-e {\n cursor: ew-resize;\n right: -3px;\n top: 0;\n width: 5px;\n }\n\n.cropper-line.line-n {\n cursor: ns-resize;\n height: 5px;\n left: 0;\n top: -3px;\n }\n\n.cropper-line.line-w {\n cursor: ew-resize;\n left: -3px;\n top: 0;\n width: 5px;\n }\n\n.cropper-line.line-s {\n bottom: -3px;\n cursor: ns-resize;\n height: 5px;\n left: 0;\n }\n\n.cropper-point {\n background-color: #39f;\n height: 5px;\n opacity: 0.75;\n width: 5px;\n}\n\n.cropper-point.point-e {\n cursor: ew-resize;\n margin-top: -3px;\n right: -3px;\n top: 50%;\n }\n\n.cropper-point.point-n {\n cursor: ns-resize;\n left: 50%;\n margin-left: -3px;\n top: -3px;\n }\n\n.cropper-point.point-w {\n cursor: ew-resize;\n left: -3px;\n margin-top: -3px;\n top: 50%;\n }\n\n.cropper-point.point-s {\n bottom: -3px;\n cursor: s-resize;\n left: 50%;\n margin-left: -3px;\n }\n\n.cropper-point.point-ne {\n cursor: nesw-resize;\n right: -3px;\n top: -3px;\n }\n\n.cropper-point.point-nw {\n cursor: nwse-resize;\n left: -3px;\n top: -3px;\n }\n\n.cropper-point.point-sw {\n bottom: -3px;\n cursor: nesw-resize;\n left: -3px;\n }\n\n.cropper-point.point-se {\n bottom: -3px;\n cursor: nwse-resize;\n height: 20px;\n opacity: 1;\n right: -3px;\n width: 20px;\n }\n\n@media (min-width: 768px) {\n\n.cropper-point.point-se {\n height: 15px;\n width: 15px;\n }\n }\n\n@media (min-width: 992px) {\n\n.cropper-point.point-se {\n height: 10px;\n width: 10px;\n }\n }\n\n@media (min-width: 1200px) {\n\n.cropper-point.point-se {\n height: 5px;\n opacity: 0.75;\n width: 5px;\n }\n }\n\n.cropper-point.point-se::before {\n background-color: #39f;\n bottom: -50%;\n content: ' ';\n display: block;\n height: 200%;\n opacity: 0;\n position: absolute;\n right: -50%;\n width: 200%;\n }\n\n.cropper-invisible {\n opacity: 0;\n}\n\n.cropper-bg {\n background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC');\n}\n\n.cropper-hide {\n display: block;\n height: 0;\n position: absolute;\n width: 0;\n}\n\n.cropper-hidden {\n display: none !important;\n}\n\n.cropper-move {\n cursor: move;\n}\n\n.cropper-crop {\n cursor: crosshair;\n}\n\n.cropper-disabled .cropper-drag-box,\n.cropper-disabled .cropper-face,\n.cropper-disabled .cropper-line,\n.cropper-disabled .cropper-point {\n cursor: not-allowed;\n}\n"],"sourceRoot":""}]);
5117 // Exports
5118 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
5119
5120
5121 /***/ },
5122
5123 /***/ "./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css"
5124 /*!*****************************************************************************************!*\
5125 !*** ./node_modules/css-loader/dist/cjs.js!./node_modules/toastify-js/src/toastify.css ***!
5126 \*****************************************************************************************/
5127 (module, __webpack_exports__, __webpack_require__) {
5128
5129 "use strict";
5130 __webpack_require__.r(__webpack_exports__);
5131 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5132 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5133 /* harmony export */ });
5134 /* 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");
5135 /* 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__);
5136 /* 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");
5137 /* 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__);
5138 // Imports
5139
5140
5141 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()));
5142 // Module
5143 ___CSS_LOADER_EXPORT___.push([module.id, `/*!
5144 * Toastify js 1.12.0
5145 * https://github.com/apvarun/toastify-js
5146 * @license MIT licensed
5147 *
5148 * Copyright (C) 2018 Varun A P
5149 */
5150
5151 .toastify {
5152 padding: 12px 20px;
5153 color: #ffffff;
5154 display: inline-block;
5155 box-shadow: 0 3px 6px -1px rgba(0, 0, 0, 0.12), 0 10px 36px -4px rgba(77, 96, 232, 0.3);
5156 background: -webkit-linear-gradient(315deg, #73a5ff, #5477f5);
5157 background: linear-gradient(135deg, #73a5ff, #5477f5);
5158 position: fixed;
5159 opacity: 0;
5160 transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
5161 border-radius: 2px;
5162 cursor: pointer;
5163 text-decoration: none;
5164 max-width: calc(50% - 20px);
5165 z-index: 2147483647;
5166 }
5167
5168 .toastify.on {
5169 opacity: 1;
5170 }
5171
5172 .toast-close {
5173 background: transparent;
5174 border: 0;
5175 color: white;
5176 cursor: pointer;
5177 font-family: inherit;
5178 font-size: 1em;
5179 opacity: 0.4;
5180 padding: 0 5px;
5181 }
5182
5183 .toastify-right {
5184 right: 15px;
5185 }
5186
5187 .toastify-left {
5188 left: 15px;
5189 }
5190
5191 .toastify-top {
5192 top: -150px;
5193 }
5194
5195 .toastify-bottom {
5196 bottom: -150px;
5197 }
5198
5199 .toastify-rounded {
5200 border-radius: 25px;
5201 }
5202
5203 .toastify-avatar {
5204 width: 1.5em;
5205 height: 1.5em;
5206 margin: -7px 5px;
5207 border-radius: 2px;
5208 }
5209
5210 .toastify-center {
5211 margin-left: auto;
5212 margin-right: auto;
5213 left: 0;
5214 right: 0;
5215 max-width: fit-content;
5216 max-width: -moz-fit-content;
5217 }
5218
5219 @media only screen and (max-width: 360px) {
5220 .toastify-right, .toastify-left {
5221 margin-left: auto;
5222 margin-right: auto;
5223 left: 0;
5224 right: 0;
5225 max-width: fit-content;
5226 }
5227 }
5228 `, "",{"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":""}]);
5229 // Exports
5230 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___);
5231
5232
5233 /***/ },
5234
5235 /***/ "./node_modules/css-loader/dist/runtime/api.js"
5236 /*!*****************************************************!*\
5237 !*** ./node_modules/css-loader/dist/runtime/api.js ***!
5238 \*****************************************************/
5239 (module) {
5240
5241 "use strict";
5242
5243
5244 /*
5245 MIT License http://www.opensource.org/licenses/mit-license.php
5246 Author Tobias Koppers @sokra
5247 */
5248 module.exports = function (cssWithMappingToString) {
5249 var list = [];
5250
5251 // return the list of modules as css string
5252 list.toString = function toString() {
5253 return this.map(function (item) {
5254 var content = "";
5255 var needLayer = typeof item[5] !== "undefined";
5256 if (item[4]) {
5257 content += "@supports (".concat(item[4], ") {");
5258 }
5259 if (item[2]) {
5260 content += "@media ".concat(item[2], " {");
5261 }
5262 if (needLayer) {
5263 content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
5264 }
5265 content += cssWithMappingToString(item);
5266 if (needLayer) {
5267 content += "}";
5268 }
5269 if (item[2]) {
5270 content += "}";
5271 }
5272 if (item[4]) {
5273 content += "}";
5274 }
5275 return content;
5276 }).join("");
5277 };
5278
5279 // import a list of modules into the list
5280 list.i = function i(modules, media, dedupe, supports, layer) {
5281 if (typeof modules === "string") {
5282 modules = [[null, modules, undefined]];
5283 }
5284 var alreadyImportedModules = {};
5285 if (dedupe) {
5286 for (var k = 0; k < this.length; k++) {
5287 var id = this[k][0];
5288 if (id != null) {
5289 alreadyImportedModules[id] = true;
5290 }
5291 }
5292 }
5293 for (var _k = 0; _k < modules.length; _k++) {
5294 var item = [].concat(modules[_k]);
5295 if (dedupe && alreadyImportedModules[item[0]]) {
5296 continue;
5297 }
5298 if (typeof layer !== "undefined") {
5299 if (typeof item[5] === "undefined") {
5300 item[5] = layer;
5301 } else {
5302 item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
5303 item[5] = layer;
5304 }
5305 }
5306 if (media) {
5307 if (!item[2]) {
5308 item[2] = media;
5309 } else {
5310 item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
5311 item[2] = media;
5312 }
5313 }
5314 if (supports) {
5315 if (!item[4]) {
5316 item[4] = "".concat(supports);
5317 } else {
5318 item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
5319 item[4] = supports;
5320 }
5321 }
5322 list.push(item);
5323 }
5324 };
5325 return list;
5326 };
5327
5328 /***/ },
5329
5330 /***/ "./node_modules/css-loader/dist/runtime/getUrl.js"
5331 /*!********************************************************!*\
5332 !*** ./node_modules/css-loader/dist/runtime/getUrl.js ***!
5333 \********************************************************/
5334 (module) {
5335
5336 "use strict";
5337
5338
5339 module.exports = function (url, options) {
5340 if (!options) {
5341 options = {};
5342 }
5343 if (!url) {
5344 return url;
5345 }
5346 url = String(url.__esModule ? url.default : url);
5347
5348 // If url is already wrapped in quotes, remove them
5349 if (/^['"].*['"]$/.test(url)) {
5350 url = url.slice(1, -1);
5351 }
5352 if (options.hash) {
5353 url += options.hash;
5354 }
5355
5356 // Should url be wrapped?
5357 // See https://drafts.csswg.org/css-values-3/#urls
5358 if (/["'() \t\n]|(%20)/.test(url) || options.needQuotes) {
5359 return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), "\"");
5360 }
5361 return url;
5362 };
5363
5364 /***/ },
5365
5366 /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js"
5367 /*!************************************************************!*\
5368 !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
5369 \************************************************************/
5370 (module) {
5371
5372 "use strict";
5373
5374
5375 module.exports = function (item) {
5376 var content = item[1];
5377 var cssMapping = item[3];
5378 if (!cssMapping) {
5379 return content;
5380 }
5381 if (typeof btoa === "function") {
5382 var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
5383 var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
5384 var sourceMapping = "/*# ".concat(data, " */");
5385 return [content].concat([sourceMapping]).join("\n");
5386 }
5387 return [content].join("\n");
5388 };
5389
5390 /***/ },
5391
5392 /***/ "./node_modules/cropperjs/dist/cropper.css"
5393 /*!*************************************************!*\
5394 !*** ./node_modules/cropperjs/dist/cropper.css ***!
5395 \*************************************************/
5396 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5397
5398 "use strict";
5399 __webpack_require__.r(__webpack_exports__);
5400 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5401 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5402 /* harmony export */ });
5403 /* 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");
5404 /* 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__);
5405 /* 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");
5406 /* 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__);
5407 /* 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");
5408 /* 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__);
5409 /* 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");
5410 /* 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__);
5411 /* 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");
5412 /* 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__);
5413 /* 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");
5414 /* 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__);
5415 /* harmony import */ var _css_loader_dist_cjs_js_cropper_css__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! !!../../css-loader/dist/cjs.js!./cropper.css */ "./node_modules/css-loader/dist/cjs.js!./node_modules/cropperjs/dist/cropper.css");
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427 var options = {};
5428
5429 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
5430 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
5431
5432 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
5433
5434 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
5435 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
5436
5437 var update = _style_loader_dist_runtime_injectStylesIntoStyleTag_js__WEBPACK_IMPORTED_MODULE_0___default()(_css_loader_dist_cjs_js_cropper_css__WEBPACK_IMPORTED_MODULE_6__["default"], options);
5438
5439
5440
5441
5442 /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_css_loader_dist_cjs_js_cropper_css__WEBPACK_IMPORTED_MODULE_6__["default"] && _css_loader_dist_cjs_js_cropper_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals ? _css_loader_dist_cjs_js_cropper_css__WEBPACK_IMPORTED_MODULE_6__["default"].locals : undefined);
5443
5444
5445 /***/ },
5446
5447 /***/ "./node_modules/toastify-js/src/toastify.css"
5448 /*!***************************************************!*\
5449 !*** ./node_modules/toastify-js/src/toastify.css ***!
5450 \***************************************************/
5451 (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
5452
5453 "use strict";
5454 __webpack_require__.r(__webpack_exports__);
5455 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5456 /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
5457 /* harmony export */ });
5458 /* 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");
5459 /* 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__);
5460 /* 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");
5461 /* 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__);
5462 /* 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");
5463 /* 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__);
5464 /* 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");
5465 /* 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__);
5466 /* 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");
5467 /* 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__);
5468 /* 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");
5469 /* 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__);
5470 /* 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");
5471
5472
5473
5474
5475
5476
5477
5478
5479
5480
5481
5482 var options = {};
5483
5484 options.styleTagTransform = (_style_loader_dist_runtime_styleTagTransform_js__WEBPACK_IMPORTED_MODULE_5___default());
5485 options.setAttributes = (_style_loader_dist_runtime_setAttributesWithoutAttributes_js__WEBPACK_IMPORTED_MODULE_3___default());
5486
5487 options.insert = _style_loader_dist_runtime_insertBySelector_js__WEBPACK_IMPORTED_MODULE_2___default().bind(null, "head");
5488
5489 options.domAPI = (_style_loader_dist_runtime_styleDomAPI_js__WEBPACK_IMPORTED_MODULE_1___default());
5490 options.insertStyleElement = (_style_loader_dist_runtime_insertStyleElement_js__WEBPACK_IMPORTED_MODULE_4___default());
5491
5492 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);
5493
5494
5495
5496
5497 /* 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);
5498
5499
5500 /***/ },
5501
5502 /***/ "./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js"
5503 /*!****************************************************************************!*\
5504 !*** ./node_modules/style-loader/dist/runtime/injectStylesIntoStyleTag.js ***!
5505 \****************************************************************************/
5506 (module) {
5507
5508 "use strict";
5509
5510
5511 var stylesInDOM = [];
5512 function getIndexByIdentifier(identifier) {
5513 var result = -1;
5514 for (var i = 0; i < stylesInDOM.length; i++) {
5515 if (stylesInDOM[i].identifier === identifier) {
5516 result = i;
5517 break;
5518 }
5519 }
5520 return result;
5521 }
5522 function modulesToDom(list, options) {
5523 var idCountMap = {};
5524 var identifiers = [];
5525 for (var i = 0; i < list.length; i++) {
5526 var item = list[i];
5527 var id = options.base ? item[0] + options.base : item[0];
5528 var count = idCountMap[id] || 0;
5529 var identifier = "".concat(id, " ").concat(count);
5530 idCountMap[id] = count + 1;
5531 var indexByIdentifier = getIndexByIdentifier(identifier);
5532 var obj = {
5533 css: item[1],
5534 media: item[2],
5535 sourceMap: item[3],
5536 supports: item[4],
5537 layer: item[5]
5538 };
5539 if (indexByIdentifier !== -1) {
5540 stylesInDOM[indexByIdentifier].references++;
5541 stylesInDOM[indexByIdentifier].updater(obj);
5542 } else {
5543 var updater = addElementStyle(obj, options);
5544 options.byIndex = i;
5545 stylesInDOM.splice(i, 0, {
5546 identifier: identifier,
5547 updater: updater,
5548 references: 1
5549 });
5550 }
5551 identifiers.push(identifier);
5552 }
5553 return identifiers;
5554 }
5555 function addElementStyle(obj, options) {
5556 var api = options.domAPI(options);
5557 api.update(obj);
5558 var updater = function updater(newObj) {
5559 if (newObj) {
5560 if (newObj.css === obj.css && newObj.media === obj.media && newObj.sourceMap === obj.sourceMap && newObj.supports === obj.supports && newObj.layer === obj.layer) {
5561 return;
5562 }
5563 api.update(obj = newObj);
5564 } else {
5565 api.remove();
5566 }
5567 };
5568 return updater;
5569 }
5570 module.exports = function (list, options) {
5571 options = options || {};
5572 list = list || [];
5573 var lastIdentifiers = modulesToDom(list, options);
5574 return function update(newList) {
5575 newList = newList || [];
5576 for (var i = 0; i < lastIdentifiers.length; i++) {
5577 var identifier = lastIdentifiers[i];
5578 var index = getIndexByIdentifier(identifier);
5579 stylesInDOM[index].references--;
5580 }
5581 var newLastIdentifiers = modulesToDom(newList, options);
5582 for (var _i = 0; _i < lastIdentifiers.length; _i++) {
5583 var _identifier = lastIdentifiers[_i];
5584 var _index = getIndexByIdentifier(_identifier);
5585 if (stylesInDOM[_index].references === 0) {
5586 stylesInDOM[_index].updater();
5587 stylesInDOM.splice(_index, 1);
5588 }
5589 }
5590 lastIdentifiers = newLastIdentifiers;
5591 };
5592 };
5593
5594 /***/ },
5595
5596 /***/ "./node_modules/style-loader/dist/runtime/insertBySelector.js"
5597 /*!********************************************************************!*\
5598 !*** ./node_modules/style-loader/dist/runtime/insertBySelector.js ***!
5599 \********************************************************************/
5600 (module) {
5601
5602 "use strict";
5603
5604
5605 var memo = {};
5606
5607 /* istanbul ignore next */
5608 function getTarget(target) {
5609 if (typeof memo[target] === "undefined") {
5610 var styleTarget = document.querySelector(target);
5611
5612 // Special case to return head of iframe instead of iframe itself
5613 if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
5614 try {
5615 // This will throw an exception if access to iframe is blocked
5616 // due to cross-origin restrictions
5617 styleTarget = styleTarget.contentDocument.head;
5618 } catch (e) {
5619 // istanbul ignore next
5620 styleTarget = null;
5621 }
5622 }
5623 memo[target] = styleTarget;
5624 }
5625 return memo[target];
5626 }
5627
5628 /* istanbul ignore next */
5629 function insertBySelector(insert, style) {
5630 var target = getTarget(insert);
5631 if (!target) {
5632 throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
5633 }
5634 target.appendChild(style);
5635 }
5636 module.exports = insertBySelector;
5637
5638 /***/ },
5639
5640 /***/ "./node_modules/style-loader/dist/runtime/insertStyleElement.js"
5641 /*!**********************************************************************!*\
5642 !*** ./node_modules/style-loader/dist/runtime/insertStyleElement.js ***!
5643 \**********************************************************************/
5644 (module) {
5645
5646 "use strict";
5647
5648
5649 /* istanbul ignore next */
5650 function insertStyleElement(options) {
5651 var element = document.createElement("style");
5652 options.setAttributes(element, options.attributes);
5653 options.insert(element, options.options);
5654 return element;
5655 }
5656 module.exports = insertStyleElement;
5657
5658 /***/ },
5659
5660 /***/ "./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js"
5661 /*!**********************************************************************************!*\
5662 !*** ./node_modules/style-loader/dist/runtime/setAttributesWithoutAttributes.js ***!
5663 \**********************************************************************************/
5664 (module, __unused_webpack_exports, __webpack_require__) {
5665
5666 "use strict";
5667
5668
5669 /* istanbul ignore next */
5670 function setAttributesWithoutAttributes(styleElement) {
5671 var nonce = true ? __webpack_require__.nc : 0;
5672 if (nonce) {
5673 styleElement.setAttribute("nonce", nonce);
5674 }
5675 }
5676 module.exports = setAttributesWithoutAttributes;
5677
5678 /***/ },
5679
5680 /***/ "./node_modules/style-loader/dist/runtime/styleDomAPI.js"
5681 /*!***************************************************************!*\
5682 !*** ./node_modules/style-loader/dist/runtime/styleDomAPI.js ***!
5683 \***************************************************************/
5684 (module) {
5685
5686 "use strict";
5687
5688
5689 /* istanbul ignore next */
5690 function apply(styleElement, options, obj) {
5691 var css = "";
5692 if (obj.supports) {
5693 css += "@supports (".concat(obj.supports, ") {");
5694 }
5695 if (obj.media) {
5696 css += "@media ".concat(obj.media, " {");
5697 }
5698 var needLayer = typeof obj.layer !== "undefined";
5699 if (needLayer) {
5700 css += "@layer".concat(obj.layer.length > 0 ? " ".concat(obj.layer) : "", " {");
5701 }
5702 css += obj.css;
5703 if (needLayer) {
5704 css += "}";
5705 }
5706 if (obj.media) {
5707 css += "}";
5708 }
5709 if (obj.supports) {
5710 css += "}";
5711 }
5712 var sourceMap = obj.sourceMap;
5713 if (sourceMap && typeof btoa !== "undefined") {
5714 css += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))), " */");
5715 }
5716
5717 // For old IE
5718 /* istanbul ignore if */
5719 options.styleTagTransform(css, styleElement, options.options);
5720 }
5721 function removeStyleElement(styleElement) {
5722 // istanbul ignore if
5723 if (styleElement.parentNode === null) {
5724 return false;
5725 }
5726 styleElement.parentNode.removeChild(styleElement);
5727 }
5728
5729 /* istanbul ignore next */
5730 function domAPI(options) {
5731 if (typeof document === "undefined") {
5732 return {
5733 update: function update() {},
5734 remove: function remove() {}
5735 };
5736 }
5737 var styleElement = options.insertStyleElement(options);
5738 return {
5739 update: function update(obj) {
5740 apply(styleElement, options, obj);
5741 },
5742 remove: function remove() {
5743 removeStyleElement(styleElement);
5744 }
5745 };
5746 }
5747 module.exports = domAPI;
5748
5749 /***/ },
5750
5751 /***/ "./node_modules/style-loader/dist/runtime/styleTagTransform.js"
5752 /*!*********************************************************************!*\
5753 !*** ./node_modules/style-loader/dist/runtime/styleTagTransform.js ***!
5754 \*********************************************************************/
5755 (module) {
5756
5757 "use strict";
5758
5759
5760 /* istanbul ignore next */
5761 function styleTagTransform(css, styleElement) {
5762 if (styleElement.styleSheet) {
5763 styleElement.styleSheet.cssText = css;
5764 } else {
5765 while (styleElement.firstChild) {
5766 styleElement.removeChild(styleElement.firstChild);
5767 }
5768 styleElement.appendChild(document.createTextNode(css));
5769 }
5770 }
5771 module.exports = styleTagTransform;
5772
5773 /***/ },
5774
5775 /***/ "./node_modules/sweetalert2/dist/sweetalert2.all.js"
5776 /*!**********************************************************!*\
5777 !*** ./node_modules/sweetalert2/dist/sweetalert2.all.js ***!
5778 \**********************************************************/
5779 (module) {
5780
5781 /*!
5782 * sweetalert2 v11.26.17
5783 * Released under the MIT License.
5784 */
5785 (function (global, factory) {
5786 true ? module.exports = factory() :
5787 0;
5788 })(this, (function () { 'use strict';
5789
5790 function _assertClassBrand(e, t, n) {
5791 if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
5792 throw new TypeError("Private element is not present on this object");
5793 }
5794 function _checkPrivateRedeclaration(e, t) {
5795 if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
5796 }
5797 function _classPrivateFieldGet2(s, a) {
5798 return s.get(_assertClassBrand(s, a));
5799 }
5800 function _classPrivateFieldInitSpec(e, t, a) {
5801 _checkPrivateRedeclaration(e, t), t.set(e, a);
5802 }
5803 function _classPrivateFieldSet2(s, a, r) {
5804 return s.set(_assertClassBrand(s, a), r), r;
5805 }
5806
5807 const RESTORE_FOCUS_TIMEOUT = 100;
5808
5809 /** @type {GlobalState} */
5810 const globalState = {};
5811 const focusPreviousActiveElement = () => {
5812 if (globalState.previousActiveElement instanceof HTMLElement) {
5813 globalState.previousActiveElement.focus();
5814 globalState.previousActiveElement = null;
5815 } else if (document.body) {
5816 document.body.focus();
5817 }
5818 };
5819
5820 /**
5821 * Restore previous active (focused) element
5822 *
5823 * @param {boolean} returnFocus
5824 * @returns {Promise<void>}
5825 */
5826 const restoreActiveElement = returnFocus => {
5827 return new Promise(resolve => {
5828 if (!returnFocus) {
5829 return resolve();
5830 }
5831 const x = window.scrollX;
5832 const y = window.scrollY;
5833 globalState.restoreFocusTimeout = setTimeout(() => {
5834 focusPreviousActiveElement();
5835 resolve();
5836 }, RESTORE_FOCUS_TIMEOUT); // issues/900
5837
5838 window.scrollTo(x, y);
5839 });
5840 };
5841
5842 const swalPrefix = 'swal2-';
5843
5844 /**
5845 * @typedef {Record<SwalClass, string>} SwalClasses
5846 */
5847
5848 /**
5849 * @typedef {'success' | 'warning' | 'info' | 'question' | 'error'} SwalIcon
5850 * @typedef {Record<SwalIcon, string>} SwalIcons
5851 */
5852
5853 /** @type {SwalClass[]} */
5854 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'];
5855 const swalClasses = classNames.reduce((acc, className) => {
5856 acc[className] = swalPrefix + className;
5857 return acc;
5858 }, /** @type {SwalClasses} */{});
5859
5860 /** @type {SwalIcon[]} */
5861 const icons = ['success', 'warning', 'info', 'question', 'error'];
5862 const iconTypes = icons.reduce((acc, icon) => {
5863 acc[icon] = swalPrefix + icon;
5864 return acc;
5865 }, /** @type {SwalIcons} */{});
5866
5867 const consolePrefix = 'SweetAlert2:';
5868
5869 /**
5870 * Capitalize the first letter of a string
5871 *
5872 * @param {string} str
5873 * @returns {string}
5874 */
5875 const capitalizeFirstLetter = str => str.charAt(0).toUpperCase() + str.slice(1);
5876
5877 /**
5878 * Standardize console warnings
5879 *
5880 * @param {string | string[]} message
5881 */
5882 const warn = message => {
5883 console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`);
5884 };
5885
5886 /**
5887 * Standardize console errors
5888 *
5889 * @param {string} message
5890 */
5891 const error = message => {
5892 console.error(`${consolePrefix} ${message}`);
5893 };
5894
5895 /**
5896 * Private global state for `warnOnce`
5897 *
5898 * @type {string[]}
5899 * @private
5900 */
5901 const previousWarnOnceMessages = [];
5902
5903 /**
5904 * Show a console warning, but only if it hasn't already been shown
5905 *
5906 * @param {string} message
5907 */
5908 const warnOnce = message => {
5909 if (!previousWarnOnceMessages.includes(message)) {
5910 previousWarnOnceMessages.push(message);
5911 warn(message);
5912 }
5913 };
5914
5915 /**
5916 * Show a one-time console warning about deprecated params/methods
5917 *
5918 * @param {string} deprecatedParam
5919 * @param {string?} useInstead
5920 */
5921 const warnAboutDeprecation = (deprecatedParam, useInstead = null) => {
5922 warnOnce(`"${deprecatedParam}" is deprecated and will be removed in the next major release.${useInstead ? ` Use "${useInstead}" instead.` : ''}`);
5923 };
5924
5925 /**
5926 * If `arg` is a function, call it (with no arguments or context) and return the result.
5927 * Otherwise, just pass the value through
5928 *
5929 * @param {(() => *) | *} arg
5930 * @returns {*}
5931 */
5932 const callIfFunction = arg => typeof arg === 'function' ? arg() : arg;
5933
5934 /**
5935 * @param {*} arg
5936 * @returns {boolean}
5937 */
5938 const hasToPromiseFn = arg => arg && typeof arg.toPromise === 'function';
5939
5940 /**
5941 * @param {*} arg
5942 * @returns {Promise<*>}
5943 */
5944 const asPromise = arg => hasToPromiseFn(arg) ? arg.toPromise() : Promise.resolve(arg);
5945
5946 /**
5947 * @param {*} arg
5948 * @returns {boolean}
5949 */
5950 const isPromise = arg => arg && Promise.resolve(arg) === arg;
5951
5952 /**
5953 * Gets the popup container which contains the backdrop and the popup itself.
5954 *
5955 * @returns {HTMLElement | null}
5956 */
5957 const getContainer = () => document.body.querySelector(`.${swalClasses.container}`);
5958
5959 /**
5960 * @param {string} selectorString
5961 * @returns {HTMLElement | null}
5962 */
5963 const elementBySelector = selectorString => {
5964 const container = getContainer();
5965 return container ? container.querySelector(selectorString) : null;
5966 };
5967
5968 /**
5969 * @param {string} className
5970 * @returns {HTMLElement | null}
5971 */
5972 const elementByClass = className => {
5973 return elementBySelector(`.${className}`);
5974 };
5975
5976 /**
5977 * @returns {HTMLElement | null}
5978 */
5979 const getPopup = () => elementByClass(swalClasses.popup);
5980
5981 /**
5982 * @returns {HTMLElement | null}
5983 */
5984 const getIcon = () => elementByClass(swalClasses.icon);
5985
5986 /**
5987 * @returns {HTMLElement | null}
5988 */
5989 const getIconContent = () => elementByClass(swalClasses['icon-content']);
5990
5991 /**
5992 * @returns {HTMLElement | null}
5993 */
5994 const getTitle = () => elementByClass(swalClasses.title);
5995
5996 /**
5997 * @returns {HTMLElement | null}
5998 */
5999 const getHtmlContainer = () => elementByClass(swalClasses['html-container']);
6000
6001 /**
6002 * @returns {HTMLElement | null}
6003 */
6004 const getImage = () => elementByClass(swalClasses.image);
6005
6006 /**
6007 * @returns {HTMLElement | null}
6008 */
6009 const getProgressSteps = () => elementByClass(swalClasses['progress-steps']);
6010
6011 /**
6012 * @returns {HTMLElement | null}
6013 */
6014 const getValidationMessage = () => elementByClass(swalClasses['validation-message']);
6015
6016 /**
6017 * @returns {HTMLButtonElement | null}
6018 */
6019 const getConfirmButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.confirm}`));
6020
6021 /**
6022 * @returns {HTMLButtonElement | null}
6023 */
6024 const getCancelButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.cancel}`));
6025
6026 /**
6027 * @returns {HTMLButtonElement | null}
6028 */
6029 const getDenyButton = () => (/** @type {HTMLButtonElement} */elementBySelector(`.${swalClasses.actions} .${swalClasses.deny}`));
6030
6031 /**
6032 * @returns {HTMLElement | null}
6033 */
6034 const getInputLabel = () => elementByClass(swalClasses['input-label']);
6035
6036 /**
6037 * @returns {HTMLElement | null}
6038 */
6039 const getLoader = () => elementBySelector(`.${swalClasses.loader}`);
6040
6041 /**
6042 * @returns {HTMLElement | null}
6043 */
6044 const getActions = () => elementByClass(swalClasses.actions);
6045
6046 /**
6047 * @returns {HTMLElement | null}
6048 */
6049 const getFooter = () => elementByClass(swalClasses.footer);
6050
6051 /**
6052 * @returns {HTMLElement | null}
6053 */
6054 const getTimerProgressBar = () => elementByClass(swalClasses['timer-progress-bar']);
6055
6056 /**
6057 * @returns {HTMLElement | null}
6058 */
6059 const getCloseButton = () => elementByClass(swalClasses.close);
6060
6061 // https://github.com/jkup/focusable/blob/master/index.js
6062 const focusable = `
6063 a[href],
6064 area[href],
6065 input:not([disabled]),
6066 select:not([disabled]),
6067 textarea:not([disabled]),
6068 button:not([disabled]),
6069 iframe,
6070 object,
6071 embed,
6072 [tabindex="0"],
6073 [contenteditable],
6074 audio[controls],
6075 video[controls],
6076 summary
6077 `;
6078 /**
6079 * @returns {HTMLElement[]}
6080 */
6081 const getFocusableElements = () => {
6082 const popup = getPopup();
6083 if (!popup) {
6084 return [];
6085 }
6086 /** @type {NodeListOf<HTMLElement>} */
6087 const focusableElementsWithTabindex = popup.querySelectorAll('[tabindex]:not([tabindex="-1"]):not([tabindex="0"])');
6088 const focusableElementsWithTabindexSorted = Array.from(focusableElementsWithTabindex)
6089 // sort according to tabindex
6090 .sort((a, b) => {
6091 const tabindexA = parseInt(a.getAttribute('tabindex') || '0');
6092 const tabindexB = parseInt(b.getAttribute('tabindex') || '0');
6093 if (tabindexA > tabindexB) {
6094 return 1;
6095 } else if (tabindexA < tabindexB) {
6096 return -1;
6097 }
6098 return 0;
6099 });
6100
6101 /** @type {NodeListOf<HTMLElement>} */
6102 const otherFocusableElements = popup.querySelectorAll(focusable);
6103 const otherFocusableElementsFiltered = Array.from(otherFocusableElements).filter(el => el.getAttribute('tabindex') !== '-1');
6104 return [...new Set(focusableElementsWithTabindexSorted.concat(otherFocusableElementsFiltered))].filter(el => isVisible$1(el));
6105 };
6106
6107 /**
6108 * @returns {boolean}
6109 */
6110 const isModal = () => {
6111 return hasClass(document.body, swalClasses.shown) && !hasClass(document.body, swalClasses['toast-shown']) && !hasClass(document.body, swalClasses['no-backdrop']);
6112 };
6113
6114 /**
6115 * @returns {boolean}
6116 */
6117 const isToast = () => {
6118 const popup = getPopup();
6119 if (!popup) {
6120 return false;
6121 }
6122 return hasClass(popup, swalClasses.toast);
6123 };
6124
6125 /**
6126 * @returns {boolean}
6127 */
6128 const isLoading = () => {
6129 const popup = getPopup();
6130 if (!popup) {
6131 return false;
6132 }
6133 return popup.hasAttribute('data-loading');
6134 };
6135
6136 /**
6137 * Securely set innerHTML of an element
6138 * https://github.com/sweetalert2/sweetalert2/issues/1926
6139 *
6140 * @param {HTMLElement} elem
6141 * @param {string} html
6142 */
6143 const setInnerHtml = (elem, html) => {
6144 elem.textContent = '';
6145 if (html) {
6146 const parser = new DOMParser();
6147 const parsed = parser.parseFromString(html, `text/html`);
6148 const head = parsed.querySelector('head');
6149 if (head) {
6150 Array.from(head.childNodes).forEach(child => {
6151 elem.appendChild(child);
6152 });
6153 }
6154 const body = parsed.querySelector('body');
6155 if (body) {
6156 Array.from(body.childNodes).forEach(child => {
6157 if (child instanceof HTMLVideoElement || child instanceof HTMLAudioElement) {
6158 elem.appendChild(child.cloneNode(true)); // https://github.com/sweetalert2/sweetalert2/issues/2507
6159 } else {
6160 elem.appendChild(child);
6161 }
6162 });
6163 }
6164 }
6165 };
6166
6167 /**
6168 * @param {HTMLElement} elem
6169 * @param {string} className
6170 * @returns {boolean}
6171 */
6172 const hasClass = (elem, className) => {
6173 if (!className) {
6174 return false;
6175 }
6176 const classList = className.split(/\s+/);
6177 for (let i = 0; i < classList.length; i++) {
6178 if (!elem.classList.contains(classList[i])) {
6179 return false;
6180 }
6181 }
6182 return true;
6183 };
6184
6185 /**
6186 * @param {HTMLElement} elem
6187 * @param {SweetAlertOptions} params
6188 */
6189 const removeCustomClasses = (elem, params) => {
6190 Array.from(elem.classList).forEach(className => {
6191 if (!Object.values(swalClasses).includes(className) && !Object.values(iconTypes).includes(className) && !Object.values(params.showClass || {}).includes(className)) {
6192 elem.classList.remove(className);
6193 }
6194 });
6195 };
6196
6197 /**
6198 * @param {HTMLElement} elem
6199 * @param {SweetAlertOptions} params
6200 * @param {string} className
6201 */
6202 const applyCustomClass = (elem, params, className) => {
6203 removeCustomClasses(elem, params);
6204 if (!params.customClass) {
6205 return;
6206 }
6207 const customClass = params.customClass[(/** @type {keyof SweetAlertCustomClass} */className)];
6208 if (!customClass) {
6209 return;
6210 }
6211 if (typeof customClass !== 'string' && !customClass.forEach) {
6212 warn(`Invalid type of customClass.${className}! Expected string or iterable object, got "${typeof customClass}"`);
6213 return;
6214 }
6215 addClass(elem, customClass);
6216 };
6217
6218 /**
6219 * @param {HTMLElement} popup
6220 * @param {import('./renderers/renderInput').InputClass | SweetAlertInput} inputClass
6221 * @returns {HTMLInputElement | null}
6222 */
6223 const getInput$1 = (popup, inputClass) => {
6224 if (!inputClass) {
6225 return null;
6226 }
6227 switch (inputClass) {
6228 case 'select':
6229 case 'textarea':
6230 case 'file':
6231 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses[inputClass]}`);
6232 case 'checkbox':
6233 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.checkbox} input`);
6234 case 'radio':
6235 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:checked`) || popup.querySelector(`.${swalClasses.popup} > .${swalClasses.radio} input:first-child`);
6236 case 'range':
6237 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.range} input`);
6238 default:
6239 return popup.querySelector(`.${swalClasses.popup} > .${swalClasses.input}`);
6240 }
6241 };
6242
6243 /**
6244 * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
6245 */
6246 const focusInput = input => {
6247 input.focus();
6248
6249 // place cursor at end of text in text input
6250 if (input.type !== 'file') {
6251 // http://stackoverflow.com/a/2345915
6252 const val = input.value;
6253 input.value = '';
6254 input.value = val;
6255 }
6256 };
6257
6258 /**
6259 * @param {HTMLElement | HTMLElement[] | null} target
6260 * @param {string | string[] | readonly string[] | undefined} classList
6261 * @param {boolean} condition
6262 */
6263 const toggleClass = (target, classList, condition) => {
6264 if (!target || !classList) {
6265 return;
6266 }
6267 if (typeof classList === 'string') {
6268 classList = classList.split(/\s+/).filter(Boolean);
6269 }
6270 classList.forEach(className => {
6271 if (Array.isArray(target)) {
6272 target.forEach(elem => {
6273 if (condition) {
6274 elem.classList.add(className);
6275 } else {
6276 elem.classList.remove(className);
6277 }
6278 });
6279 } else {
6280 if (condition) {
6281 target.classList.add(className);
6282 } else {
6283 target.classList.remove(className);
6284 }
6285 }
6286 });
6287 };
6288
6289 /**
6290 * @param {HTMLElement | HTMLElement[] | null} target
6291 * @param {string | string[] | readonly string[] | undefined} classList
6292 */
6293 const addClass = (target, classList) => {
6294 toggleClass(target, classList, true);
6295 };
6296
6297 /**
6298 * @param {HTMLElement | HTMLElement[] | null} target
6299 * @param {string | string[] | readonly string[] | undefined} classList
6300 */
6301 const removeClass = (target, classList) => {
6302 toggleClass(target, classList, false);
6303 };
6304
6305 /**
6306 * Get direct child of an element by class name
6307 *
6308 * @param {HTMLElement} elem
6309 * @param {string} className
6310 * @returns {HTMLElement | undefined}
6311 */
6312 const getDirectChildByClass = (elem, className) => {
6313 const children = Array.from(elem.children);
6314 for (let i = 0; i < children.length; i++) {
6315 const child = children[i];
6316 if (child instanceof HTMLElement && hasClass(child, className)) {
6317 return child;
6318 }
6319 }
6320 };
6321
6322 /**
6323 * @param {HTMLElement} elem
6324 * @param {string} property
6325 * @param {string | number | null | undefined} value
6326 */
6327 const applyNumericalStyle = (elem, property, value) => {
6328 if (value === `${parseInt(`${value}`)}`) {
6329 value = parseInt(value);
6330 }
6331 if (value || parseInt(`${value}`) === 0) {
6332 elem.style.setProperty(property, typeof value === 'number' ? `${value}px` : (/** @type {string} */value));
6333 } else {
6334 elem.style.removeProperty(property);
6335 }
6336 };
6337
6338 /**
6339 * @param {HTMLElement | null} elem
6340 * @param {string} display
6341 */
6342 const show = (elem, display = 'flex') => {
6343 if (!elem) {
6344 return;
6345 }
6346 elem.style.display = display;
6347 };
6348
6349 /**
6350 * @param {HTMLElement | null} elem
6351 */
6352 const hide = elem => {
6353 if (!elem) {
6354 return;
6355 }
6356 elem.style.display = 'none';
6357 };
6358
6359 /**
6360 * @param {HTMLElement | null} elem
6361 * @param {string} display
6362 */
6363 const showWhenInnerHtmlPresent = (elem, display = 'block') => {
6364 if (!elem) {
6365 return;
6366 }
6367 new MutationObserver(() => {
6368 toggle(elem, elem.innerHTML, display);
6369 }).observe(elem, {
6370 childList: true,
6371 subtree: true
6372 });
6373 };
6374
6375 /**
6376 * @param {HTMLElement} parent
6377 * @param {string} selector
6378 * @param {string} property
6379 * @param {string} value
6380 */
6381 const setStyle = (parent, selector, property, value) => {
6382 /** @type {HTMLElement | null} */
6383 const el = parent.querySelector(selector);
6384 if (el) {
6385 el.style.setProperty(property, value);
6386 }
6387 };
6388
6389 /**
6390 * @param {HTMLElement} elem
6391 * @param {boolean | string | null | undefined} condition
6392 * @param {string} display
6393 */
6394 const toggle = (elem, condition, display = 'flex') => {
6395 if (condition) {
6396 show(elem, display);
6397 } else {
6398 hide(elem);
6399 }
6400 };
6401
6402 /**
6403 * borrowed from jquery $(elem).is(':visible') implementation
6404 *
6405 * @param {HTMLElement | null} elem
6406 * @returns {boolean}
6407 */
6408 const isVisible$1 = elem => Boolean(elem && (elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length));
6409
6410 /**
6411 * @returns {boolean}
6412 */
6413 const allButtonsAreHidden = () => !isVisible$1(getConfirmButton()) && !isVisible$1(getDenyButton()) && !isVisible$1(getCancelButton());
6414
6415 /**
6416 * @param {HTMLElement} elem
6417 * @returns {boolean}
6418 */
6419 const isScrollable = elem => Boolean(elem.scrollHeight > elem.clientHeight);
6420
6421 /**
6422 * @param {HTMLElement} element
6423 * @param {HTMLElement} stopElement
6424 * @returns {boolean}
6425 */
6426 const selfOrParentIsScrollable = (element, stopElement) => {
6427 let parent = /** @type {HTMLElement | null} */element;
6428 while (parent && parent !== stopElement) {
6429 if (isScrollable(parent)) {
6430 return true;
6431 }
6432 parent = parent.parentElement;
6433 }
6434 return false;
6435 };
6436
6437 /**
6438 * borrowed from https://stackoverflow.com/a/46352119
6439 *
6440 * @param {HTMLElement} elem
6441 * @returns {boolean}
6442 */
6443 const hasCssAnimation = elem => {
6444 const style = window.getComputedStyle(elem);
6445 const animDuration = parseFloat(style.getPropertyValue('animation-duration') || '0');
6446 const transDuration = parseFloat(style.getPropertyValue('transition-duration') || '0');
6447 return animDuration > 0 || transDuration > 0;
6448 };
6449
6450 /**
6451 * @param {number} timer
6452 * @param {boolean} reset
6453 */
6454 const animateTimerProgressBar = (timer, reset = false) => {
6455 const timerProgressBar = getTimerProgressBar();
6456 if (!timerProgressBar) {
6457 return;
6458 }
6459 if (isVisible$1(timerProgressBar)) {
6460 if (reset) {
6461 timerProgressBar.style.transition = 'none';
6462 timerProgressBar.style.width = '100%';
6463 }
6464 setTimeout(() => {
6465 timerProgressBar.style.transition = `width ${timer / 1000}s linear`;
6466 timerProgressBar.style.width = '0%';
6467 }, 10);
6468 }
6469 };
6470 const stopTimerProgressBar = () => {
6471 const timerProgressBar = getTimerProgressBar();
6472 if (!timerProgressBar) {
6473 return;
6474 }
6475 const timerProgressBarWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
6476 timerProgressBar.style.removeProperty('transition');
6477 timerProgressBar.style.width = '100%';
6478 const timerProgressBarFullWidth = parseInt(window.getComputedStyle(timerProgressBar).width);
6479 const timerProgressBarPercent = timerProgressBarWidth / timerProgressBarFullWidth * 100;
6480 timerProgressBar.style.width = `${timerProgressBarPercent}%`;
6481 };
6482
6483 /**
6484 * Detect Node env
6485 *
6486 * @returns {boolean}
6487 */
6488 const isNodeEnv = () => typeof window === 'undefined' || typeof document === 'undefined';
6489
6490 const sweetHTML = `
6491 <div aria-labelledby="${swalClasses.title}" aria-describedby="${swalClasses['html-container']}" class="${swalClasses.popup}" tabindex="-1">
6492 <button type="button" class="${swalClasses.close}"></button>
6493 <ul class="${swalClasses['progress-steps']}"></ul>
6494 <div class="${swalClasses.icon}"></div>
6495 <img class="${swalClasses.image}" />
6496 <h2 class="${swalClasses.title}" id="${swalClasses.title}"></h2>
6497 <div class="${swalClasses['html-container']}" id="${swalClasses['html-container']}"></div>
6498 <input class="${swalClasses.input}" id="${swalClasses.input}" />
6499 <input type="file" class="${swalClasses.file}" />
6500 <div class="${swalClasses.range}">
6501 <input type="range" />
6502 <output></output>
6503 </div>
6504 <select class="${swalClasses.select}" id="${swalClasses.select}"></select>
6505 <div class="${swalClasses.radio}"></div>
6506 <label class="${swalClasses.checkbox}">
6507 <input type="checkbox" id="${swalClasses.checkbox}" />
6508 <span class="${swalClasses.label}"></span>
6509 </label>
6510 <textarea class="${swalClasses.textarea}" id="${swalClasses.textarea}"></textarea>
6511 <div class="${swalClasses['validation-message']}" id="${swalClasses['validation-message']}"></div>
6512 <div class="${swalClasses.actions}">
6513 <div class="${swalClasses.loader}"></div>
6514 <button type="button" class="${swalClasses.confirm}"></button>
6515 <button type="button" class="${swalClasses.deny}"></button>
6516 <button type="button" class="${swalClasses.cancel}"></button>
6517 </div>
6518 <div class="${swalClasses.footer}"></div>
6519 <div class="${swalClasses['timer-progress-bar-container']}">
6520 <div class="${swalClasses['timer-progress-bar']}"></div>
6521 </div>
6522 </div>
6523 `.replace(/(^|\n)\s*/g, '');
6524
6525 /**
6526 * @returns {boolean}
6527 */
6528 const resetOldContainer = () => {
6529 const oldContainer = getContainer();
6530 if (!oldContainer) {
6531 return false;
6532 }
6533 oldContainer.remove();
6534 removeClass([document.documentElement, document.body], [swalClasses['no-backdrop'], swalClasses['toast-shown'],
6535 // @ts-ignore: 'has-column' is not defined in swalClasses but may be set dynamically
6536 swalClasses['has-column']]);
6537 return true;
6538 };
6539 const resetValidationMessage$1 = () => {
6540 if (globalState.currentInstance) {
6541 globalState.currentInstance.resetValidationMessage();
6542 }
6543 };
6544 const addInputChangeListeners = () => {
6545 const popup = getPopup();
6546 if (!popup) {
6547 return;
6548 }
6549 const input = getDirectChildByClass(popup, swalClasses.input);
6550 const file = getDirectChildByClass(popup, swalClasses.file);
6551 /** @type {HTMLInputElement | null} */
6552 const range = popup.querySelector(`.${swalClasses.range} input`);
6553 /** @type {HTMLOutputElement | null} */
6554 const rangeOutput = popup.querySelector(`.${swalClasses.range} output`);
6555 const select = getDirectChildByClass(popup, swalClasses.select);
6556 /** @type {HTMLInputElement | null} */
6557 const checkbox = popup.querySelector(`.${swalClasses.checkbox} input`);
6558 const textarea = getDirectChildByClass(popup, swalClasses.textarea);
6559 if (input) {
6560 input.oninput = resetValidationMessage$1;
6561 }
6562 if (file) {
6563 file.onchange = resetValidationMessage$1;
6564 }
6565 if (select) {
6566 select.onchange = resetValidationMessage$1;
6567 }
6568 if (checkbox) {
6569 checkbox.onchange = resetValidationMessage$1;
6570 }
6571 if (textarea) {
6572 textarea.oninput = resetValidationMessage$1;
6573 }
6574 if (range && rangeOutput) {
6575 range.oninput = () => {
6576 resetValidationMessage$1();
6577 rangeOutput.value = range.value;
6578 };
6579 range.onchange = () => {
6580 resetValidationMessage$1();
6581 rangeOutput.value = range.value;
6582 };
6583 }
6584 };
6585
6586 /**
6587 * @param {string | HTMLElement} target
6588 * @returns {HTMLElement}
6589 */
6590 const getTarget = target => {
6591 if (typeof target === 'string') {
6592 const element = document.querySelector(target);
6593 if (!element) {
6594 throw new Error(`Target element "${target}" not found`);
6595 }
6596 return /** @type {HTMLElement} */element;
6597 }
6598 return target;
6599 };
6600
6601 /**
6602 * @param {SweetAlertOptions} params
6603 */
6604 const setupAccessibility = params => {
6605 const popup = getPopup();
6606 if (!popup) {
6607 return;
6608 }
6609 popup.setAttribute('role', params.toast ? 'alert' : 'dialog');
6610 popup.setAttribute('aria-live', params.toast ? 'polite' : 'assertive');
6611 if (!params.toast) {
6612 popup.setAttribute('aria-modal', 'true');
6613 }
6614 };
6615
6616 /**
6617 * @param {HTMLElement} targetElement
6618 */
6619 const setupRTL = targetElement => {
6620 if (window.getComputedStyle(targetElement).direction === 'rtl') {
6621 addClass(getContainer(), swalClasses.rtl);
6622 globalState.isRTL = true;
6623 }
6624 };
6625
6626 /**
6627 * Add modal + backdrop to DOM
6628 *
6629 * @param {SweetAlertOptions} params
6630 */
6631 const init = params => {
6632 // Clean up the old popup container if it exists
6633 const oldContainerExisted = resetOldContainer();
6634 if (isNodeEnv()) {
6635 error('SweetAlert2 requires document to initialize');
6636 return;
6637 }
6638 const container = document.createElement('div');
6639 container.className = swalClasses.container;
6640 if (oldContainerExisted) {
6641 addClass(container, swalClasses['no-transition']);
6642 }
6643 setInnerHtml(container, sweetHTML);
6644 container.dataset['swal2Theme'] = params.theme;
6645 const targetElement = getTarget(params.target || 'body');
6646 targetElement.appendChild(container);
6647 if (params.topLayer) {
6648 container.setAttribute('popover', '');
6649 container.showPopover();
6650 }
6651 setupAccessibility(params);
6652 setupRTL(targetElement);
6653 addInputChangeListeners();
6654 };
6655
6656 /**
6657 * @param {HTMLElement | object | string} param
6658 * @param {HTMLElement} target
6659 */
6660 const parseHtmlToContainer = (param, target) => {
6661 // DOM element
6662 if (param instanceof HTMLElement) {
6663 target.appendChild(param);
6664 }
6665
6666 // Object
6667 else if (typeof param === 'object') {
6668 handleObject(param, target);
6669 }
6670
6671 // Plain string
6672 else if (param) {
6673 setInnerHtml(target, param);
6674 }
6675 };
6676
6677 /**
6678 * @param {object} param
6679 * @param {HTMLElement} target
6680 */
6681 const handleObject = (param, target) => {
6682 // JQuery element(s)
6683 if ('jquery' in param) {
6684 handleJqueryElem(target, param);
6685 }
6686
6687 // For other objects use their string representation
6688 else {
6689 setInnerHtml(target, param.toString());
6690 }
6691 };
6692
6693 /**
6694 * @param {HTMLElement} target
6695 * @param {any} elem
6696 */
6697 const handleJqueryElem = (target, elem) => {
6698 target.textContent = '';
6699 if (0 in elem) {
6700 for (let i = 0; i in elem; i++) {
6701 target.appendChild(elem[i].cloneNode(true));
6702 }
6703 } else {
6704 target.appendChild(elem.cloneNode(true));
6705 }
6706 };
6707
6708 /**
6709 * @param {SweetAlert} instance
6710 * @param {SweetAlertOptions} params
6711 */
6712 const renderActions = (instance, params) => {
6713 const actions = getActions();
6714 const loader = getLoader();
6715 if (!actions || !loader) {
6716 return;
6717 }
6718
6719 // Actions (buttons) wrapper
6720 if (!params.showConfirmButton && !params.showDenyButton && !params.showCancelButton) {
6721 hide(actions);
6722 } else {
6723 show(actions);
6724 }
6725
6726 // Custom class
6727 applyCustomClass(actions, params, 'actions');
6728
6729 // Render all the buttons
6730 renderButtons(actions, loader, params);
6731
6732 // Loader
6733 setInnerHtml(loader, params.loaderHtml || '');
6734 applyCustomClass(loader, params, 'loader');
6735 };
6736
6737 /**
6738 * @param {HTMLElement} actions
6739 * @param {HTMLElement} loader
6740 * @param {SweetAlertOptions} params
6741 */
6742 function renderButtons(actions, loader, params) {
6743 const confirmButton = getConfirmButton();
6744 const denyButton = getDenyButton();
6745 const cancelButton = getCancelButton();
6746 if (!confirmButton || !denyButton || !cancelButton) {
6747 return;
6748 }
6749
6750 // Render buttons
6751 renderButton(confirmButton, 'confirm', params);
6752 renderButton(denyButton, 'deny', params);
6753 renderButton(cancelButton, 'cancel', params);
6754 handleButtonsStyling(confirmButton, denyButton, cancelButton, params);
6755 if (params.reverseButtons) {
6756 if (params.toast) {
6757 actions.insertBefore(cancelButton, confirmButton);
6758 actions.insertBefore(denyButton, confirmButton);
6759 } else {
6760 actions.insertBefore(cancelButton, loader);
6761 actions.insertBefore(denyButton, loader);
6762 actions.insertBefore(confirmButton, loader);
6763 }
6764 }
6765 }
6766
6767 /**
6768 * @param {HTMLElement} confirmButton
6769 * @param {HTMLElement} denyButton
6770 * @param {HTMLElement} cancelButton
6771 * @param {SweetAlertOptions} params
6772 */
6773 function handleButtonsStyling(confirmButton, denyButton, cancelButton, params) {
6774 if (!params.buttonsStyling) {
6775 removeClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
6776 return;
6777 }
6778 addClass([confirmButton, denyButton, cancelButton], swalClasses.styled);
6779
6780 // Apply custom background colors to action buttons
6781 if (params.confirmButtonColor) {
6782 confirmButton.style.setProperty('--swal2-confirm-button-background-color', params.confirmButtonColor);
6783 }
6784 if (params.denyButtonColor) {
6785 denyButton.style.setProperty('--swal2-deny-button-background-color', params.denyButtonColor);
6786 }
6787 if (params.cancelButtonColor) {
6788 cancelButton.style.setProperty('--swal2-cancel-button-background-color', params.cancelButtonColor);
6789 }
6790
6791 // Apply the outline color to action buttons
6792 applyOutlineColor(confirmButton);
6793 applyOutlineColor(denyButton);
6794 applyOutlineColor(cancelButton);
6795 }
6796
6797 /**
6798 * @param {HTMLElement} button
6799 */
6800 function applyOutlineColor(button) {
6801 const buttonStyle = window.getComputedStyle(button);
6802 if (buttonStyle.getPropertyValue('--swal2-action-button-focus-box-shadow')) {
6803 // If the button already has a custom outline color, no need to change it
6804 return;
6805 }
6806 const outlineColor = buttonStyle.backgroundColor.replace(/rgba?\((\d+), (\d+), (\d+).*/, 'rgba($1, $2, $3, 0.5)');
6807 button.style.setProperty('--swal2-action-button-focus-box-shadow', buttonStyle.getPropertyValue('--swal2-outline').replace(/ rgba\(.*/, ` ${outlineColor}`));
6808 }
6809
6810 /**
6811 * @param {HTMLElement} button
6812 * @param {'confirm' | 'deny' | 'cancel'} buttonType
6813 * @param {SweetAlertOptions} params
6814 */
6815 function renderButton(button, buttonType, params) {
6816 const buttonName = /** @type {'Confirm' | 'Deny' | 'Cancel'} */capitalizeFirstLetter(buttonType);
6817 toggle(button, params[`show${buttonName}Button`], 'inline-block');
6818 setInnerHtml(button, params[`${buttonType}ButtonText`] || ''); // Set caption text
6819 button.setAttribute('aria-label', params[`${buttonType}ButtonAriaLabel`] || ''); // ARIA label
6820
6821 // Add buttons custom classes
6822 button.className = swalClasses[buttonType];
6823 applyCustomClass(button, params, `${buttonType}Button`);
6824 }
6825
6826 /**
6827 * @param {SweetAlert} instance
6828 * @param {SweetAlertOptions} params
6829 */
6830 const renderCloseButton = (instance, params) => {
6831 const closeButton = getCloseButton();
6832 if (!closeButton) {
6833 return;
6834 }
6835 setInnerHtml(closeButton, params.closeButtonHtml || '');
6836
6837 // Custom class
6838 applyCustomClass(closeButton, params, 'closeButton');
6839 toggle(closeButton, params.showCloseButton);
6840 closeButton.setAttribute('aria-label', params.closeButtonAriaLabel || '');
6841 };
6842
6843 /**
6844 * @param {SweetAlert} instance
6845 * @param {SweetAlertOptions} params
6846 */
6847 const renderContainer = (instance, params) => {
6848 const container = getContainer();
6849 if (!container) {
6850 return;
6851 }
6852 handleBackdropParam(container, params.backdrop);
6853 handlePositionParam(container, params.position);
6854 handleGrowParam(container, params.grow);
6855
6856 // Custom class
6857 applyCustomClass(container, params, 'container');
6858 };
6859
6860 /**
6861 * @param {HTMLElement} container
6862 * @param {SweetAlertOptions['backdrop']} backdrop
6863 */
6864 function handleBackdropParam(container, backdrop) {
6865 if (typeof backdrop === 'string') {
6866 container.style.background = backdrop;
6867 } else if (!backdrop) {
6868 addClass([document.documentElement, document.body], swalClasses['no-backdrop']);
6869 }
6870 }
6871
6872 /**
6873 * @param {HTMLElement} container
6874 * @param {SweetAlertOptions['position']} position
6875 */
6876 function handlePositionParam(container, position) {
6877 if (!position) {
6878 return;
6879 }
6880 if (position in swalClasses) {
6881 addClass(container, swalClasses[position]);
6882 } else {
6883 warn('The "position" parameter is not valid, defaulting to "center"');
6884 addClass(container, swalClasses.center);
6885 }
6886 }
6887
6888 /**
6889 * @param {HTMLElement} container
6890 * @param {SweetAlertOptions['grow']} grow
6891 */
6892 function handleGrowParam(container, grow) {
6893 if (!grow) {
6894 return;
6895 }
6896 addClass(container, swalClasses[`grow-${grow}`]);
6897 }
6898
6899 /**
6900 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
6901 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
6902 * This is the approach that Babel will probably take to implement private methods/fields
6903 * https://github.com/tc39/proposal-private-methods
6904 * https://github.com/babel/babel/pull/7555
6905 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
6906 * then we can use that language feature.
6907 */
6908
6909 var privateProps = {
6910 innerParams: new WeakMap(),
6911 domCache: new WeakMap()
6912 };
6913
6914 /// <reference path="../../../../sweetalert2.d.ts"/>
6915
6916
6917 /** @type {InputClass[]} */
6918 const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
6919
6920 /**
6921 * @param {SweetAlert} instance
6922 * @param {SweetAlertOptions} params
6923 */
6924 const renderInput = (instance, params) => {
6925 const popup = getPopup();
6926 if (!popup) {
6927 return;
6928 }
6929 const innerParams = privateProps.innerParams.get(instance);
6930 const rerender = !innerParams || params.input !== innerParams.input;
6931 inputClasses.forEach(inputClass => {
6932 const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]);
6933 if (!inputContainer) {
6934 return;
6935 }
6936
6937 // set attributes
6938 setAttributes(inputClass, params.inputAttributes);
6939
6940 // set class
6941 inputContainer.className = swalClasses[inputClass];
6942 if (rerender) {
6943 hide(inputContainer);
6944 }
6945 });
6946 if (params.input) {
6947 if (rerender) {
6948 showInput(params);
6949 }
6950 // set custom class
6951 setCustomClass(params);
6952 }
6953 };
6954
6955 /**
6956 * @param {SweetAlertOptions} params
6957 */
6958 const showInput = params => {
6959 if (!params.input) {
6960 return;
6961 }
6962 if (!renderInputType[params.input]) {
6963 error(`Unexpected type of input! Expected ${Object.keys(renderInputType).join(' | ')}, got "${params.input}"`);
6964 return;
6965 }
6966 const inputContainer = getInputContainer(params.input);
6967 if (!inputContainer) {
6968 return;
6969 }
6970 const input = renderInputType[params.input](inputContainer, params);
6971 show(inputContainer);
6972
6973 // input autofocus
6974 if (params.inputAutoFocus) {
6975 setTimeout(() => {
6976 focusInput(input);
6977 });
6978 }
6979 };
6980
6981 /**
6982 * @param {HTMLInputElement} input
6983 */
6984 const removeAttributes = input => {
6985 for (let i = 0; i < input.attributes.length; i++) {
6986 const attrName = input.attributes[i].name;
6987 if (!['id', 'type', 'value', 'style'].includes(attrName)) {
6988 input.removeAttribute(attrName);
6989 }
6990 }
6991 };
6992
6993 /**
6994 * @param {InputClass} inputClass
6995 * @param {SweetAlertOptions['inputAttributes']} inputAttributes
6996 */
6997 const setAttributes = (inputClass, inputAttributes) => {
6998 const popup = getPopup();
6999 if (!popup) {
7000 return;
7001 }
7002 const input = getInput$1(popup, inputClass);
7003 if (!input) {
7004 return;
7005 }
7006 removeAttributes(input);
7007 for (const attr in inputAttributes) {
7008 input.setAttribute(attr, inputAttributes[attr]);
7009 }
7010 };
7011
7012 /**
7013 * @param {SweetAlertOptions} params
7014 */
7015 const setCustomClass = params => {
7016 if (!params.input) {
7017 return;
7018 }
7019 const inputContainer = getInputContainer(params.input);
7020 if (inputContainer) {
7021 applyCustomClass(inputContainer, params, 'input');
7022 }
7023 };
7024
7025 /**
7026 * @param {HTMLInputElement | HTMLTextAreaElement} input
7027 * @param {SweetAlertOptions} params
7028 */
7029 const setInputPlaceholder = (input, params) => {
7030 if (!input.placeholder && params.inputPlaceholder) {
7031 input.placeholder = params.inputPlaceholder;
7032 }
7033 };
7034
7035 /**
7036 * @param {Input} input
7037 * @param {Input} prependTo
7038 * @param {SweetAlertOptions} params
7039 */
7040 const setInputLabel = (input, prependTo, params) => {
7041 if (params.inputLabel) {
7042 const label = document.createElement('label');
7043 const labelClass = swalClasses['input-label'];
7044 label.setAttribute('for', input.id);
7045 label.className = labelClass;
7046 if (typeof params.customClass === 'object') {
7047 addClass(label, params.customClass.inputLabel);
7048 }
7049 label.innerText = params.inputLabel;
7050 prependTo.insertAdjacentElement('beforebegin', label);
7051 }
7052 };
7053
7054 /**
7055 * @param {SweetAlertInput} inputType
7056 * @returns {HTMLElement | undefined}
7057 */
7058 const getInputContainer = inputType => {
7059 const popup = getPopup();
7060 if (!popup) {
7061 return;
7062 }
7063 return getDirectChildByClass(popup, swalClasses[(/** @type {SwalClass} */inputType)] || swalClasses.input);
7064 };
7065
7066 /**
7067 * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
7068 * @param {SweetAlertOptions['inputValue']} inputValue
7069 */
7070 const checkAndSetInputValue = (input, inputValue) => {
7071 if (['string', 'number'].includes(typeof inputValue)) {
7072 input.value = `${inputValue}`;
7073 } else if (!isPromise(inputValue)) {
7074 warn(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof inputValue}"`);
7075 }
7076 };
7077
7078 /** @type {Record<SweetAlertInput, (input: Input | HTMLElement, params: SweetAlertOptions) => Input>} */
7079 const renderInputType = {};
7080
7081 /**
7082 * @param {Input | HTMLElement} input
7083 * @param {SweetAlertOptions} params
7084 * @returns {Input}
7085 */
7086 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} */
7087 (input, params) => {
7088 const inputElement = /** @type {HTMLInputElement} */input;
7089 checkAndSetInputValue(inputElement, params.inputValue);
7090 setInputLabel(inputElement, inputElement, params);
7091 setInputPlaceholder(inputElement, params);
7092 inputElement.type = /** @type {string} */params.input;
7093 return inputElement;
7094 };
7095
7096 /**
7097 * @param {Input | HTMLElement} input
7098 * @param {SweetAlertOptions} params
7099 * @returns {Input}
7100 */
7101 renderInputType.file = (input, params) => {
7102 const inputElement = /** @type {HTMLInputElement} */input;
7103 setInputLabel(inputElement, inputElement, params);
7104 setInputPlaceholder(inputElement, params);
7105 return inputElement;
7106 };
7107
7108 /**
7109 * @param {Input | HTMLElement} range
7110 * @param {SweetAlertOptions} params
7111 * @returns {Input}
7112 */
7113 renderInputType.range = (range, params) => {
7114 const rangeContainer = /** @type {HTMLElement} */range;
7115 const rangeInput = rangeContainer.querySelector('input');
7116 const rangeOutput = rangeContainer.querySelector('output');
7117 if (rangeInput) {
7118 checkAndSetInputValue(rangeInput, params.inputValue);
7119 rangeInput.type = /** @type {string} */params.input;
7120 setInputLabel(rangeInput, /** @type {Input} */range, params);
7121 }
7122 if (rangeOutput) {
7123 checkAndSetInputValue(rangeOutput, params.inputValue);
7124 }
7125 return /** @type {Input} */range;
7126 };
7127
7128 /**
7129 * @param {Input | HTMLElement} select
7130 * @param {SweetAlertOptions} params
7131 * @returns {Input}
7132 */
7133 renderInputType.select = (select, params) => {
7134 const selectElement = /** @type {HTMLSelectElement} */select;
7135 selectElement.textContent = '';
7136 if (params.inputPlaceholder) {
7137 const placeholder = document.createElement('option');
7138 setInnerHtml(placeholder, params.inputPlaceholder);
7139 placeholder.value = '';
7140 placeholder.disabled = true;
7141 placeholder.selected = true;
7142 selectElement.appendChild(placeholder);
7143 }
7144 setInputLabel(selectElement, selectElement, params);
7145 return selectElement;
7146 };
7147
7148 /**
7149 * @param {Input | HTMLElement} radio
7150 * @returns {Input}
7151 */
7152 renderInputType.radio = radio => {
7153 const radioElement = /** @type {HTMLElement} */radio;
7154 radioElement.textContent = '';
7155 return /** @type {Input} */radio;
7156 };
7157
7158 /**
7159 * @param {Input | HTMLElement} checkboxContainer
7160 * @param {SweetAlertOptions} params
7161 * @returns {Input}
7162 */
7163 renderInputType.checkbox = (checkboxContainer, params) => {
7164 const popup = getPopup();
7165 if (!popup) {
7166 throw new Error('Popup not found');
7167 }
7168 const checkbox = getInput$1(popup, 'checkbox');
7169 if (!checkbox) {
7170 throw new Error('Checkbox input not found');
7171 }
7172 checkbox.value = '1';
7173 checkbox.checked = Boolean(params.inputValue);
7174 const containerElement = /** @type {HTMLElement} */checkboxContainer;
7175 const label = containerElement.querySelector('span');
7176 if (label) {
7177 const placeholderOrLabel = params.inputPlaceholder || params.inputLabel;
7178 if (placeholderOrLabel) {
7179 setInnerHtml(label, placeholderOrLabel);
7180 }
7181 }
7182 return checkbox;
7183 };
7184
7185 /**
7186 * @param {Input | HTMLElement} textarea
7187 * @param {SweetAlertOptions} params
7188 * @returns {Input}
7189 */
7190 renderInputType.textarea = (textarea, params) => {
7191 const textareaElement = /** @type {HTMLTextAreaElement} */textarea;
7192 checkAndSetInputValue(textareaElement, params.inputValue);
7193 setInputPlaceholder(textareaElement, params);
7194 setInputLabel(textareaElement, textareaElement, params);
7195
7196 /**
7197 * @param {HTMLElement} el
7198 * @returns {number}
7199 */
7200 const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight);
7201
7202 // https://github.com/sweetalert2/sweetalert2/issues/2291
7203 setTimeout(() => {
7204 // https://github.com/sweetalert2/sweetalert2/issues/1699
7205 if ('MutationObserver' in window) {
7206 const popup = getPopup();
7207 if (!popup) {
7208 return;
7209 }
7210 const initialPopupWidth = parseInt(window.getComputedStyle(popup).width);
7211 const textareaResizeHandler = () => {
7212 // check if texarea is still in document (i.e. popup wasn't closed in the meantime)
7213 if (!document.body.contains(textareaElement)) {
7214 return;
7215 }
7216 const textareaWidth = textareaElement.offsetWidth + getMargin(textareaElement);
7217 const popupElement = getPopup();
7218 if (popupElement) {
7219 if (textareaWidth > initialPopupWidth) {
7220 popupElement.style.width = `${textareaWidth}px`;
7221 } else {
7222 applyNumericalStyle(popupElement, 'width', params.width);
7223 }
7224 }
7225 };
7226 new MutationObserver(textareaResizeHandler).observe(textareaElement, {
7227 attributes: true,
7228 attributeFilter: ['style']
7229 });
7230 }
7231 });
7232 return textareaElement;
7233 };
7234
7235 /**
7236 * @param {SweetAlert} instance
7237 * @param {SweetAlertOptions} params
7238 */
7239 const renderContent = (instance, params) => {
7240 const htmlContainer = getHtmlContainer();
7241 if (!htmlContainer) {
7242 return;
7243 }
7244 showWhenInnerHtmlPresent(htmlContainer);
7245 applyCustomClass(htmlContainer, params, 'htmlContainer');
7246
7247 // Content as HTML
7248 if (params.html) {
7249 parseHtmlToContainer(params.html, htmlContainer);
7250 show(htmlContainer, 'block');
7251 }
7252
7253 // Content as plain text
7254 else if (params.text) {
7255 htmlContainer.textContent = params.text;
7256 show(htmlContainer, 'block');
7257 }
7258
7259 // No content
7260 else {
7261 hide(htmlContainer);
7262 }
7263 renderInput(instance, params);
7264 };
7265
7266 /**
7267 * @param {SweetAlert} instance
7268 * @param {SweetAlertOptions} params
7269 */
7270 const renderFooter = (instance, params) => {
7271 const footer = getFooter();
7272 if (!footer) {
7273 return;
7274 }
7275 showWhenInnerHtmlPresent(footer);
7276 toggle(footer, Boolean(params.footer), 'block');
7277 if (params.footer) {
7278 parseHtmlToContainer(params.footer, footer);
7279 }
7280
7281 // Custom class
7282 applyCustomClass(footer, params, 'footer');
7283 };
7284
7285 /**
7286 * @param {SweetAlert} instance
7287 * @param {SweetAlertOptions} params
7288 */
7289 const renderIcon = (instance, params) => {
7290 const innerParams = privateProps.innerParams.get(instance);
7291 const icon = getIcon();
7292 if (!icon) {
7293 return;
7294 }
7295
7296 // if the given icon already rendered, apply the styling without re-rendering the icon
7297 if (innerParams && params.icon === innerParams.icon) {
7298 // Custom or default content
7299 setContent(icon, params);
7300 applyStyles(icon, params);
7301 return;
7302 }
7303 if (!params.icon && !params.iconHtml) {
7304 hide(icon);
7305 return;
7306 }
7307 if (params.icon && Object.keys(iconTypes).indexOf(params.icon) === -1) {
7308 error(`Unknown icon! Expected "success", "error", "warning", "info" or "question", got "${params.icon}"`);
7309 hide(icon);
7310 return;
7311 }
7312 show(icon);
7313
7314 // Custom or default content
7315 setContent(icon, params);
7316 applyStyles(icon, params);
7317
7318 // Animate icon
7319 addClass(icon, params.showClass && params.showClass.icon);
7320
7321 // Re-adjust the success icon on system theme change
7322 const colorSchemeQueryList = window.matchMedia('(prefers-color-scheme: dark)');
7323 colorSchemeQueryList.addEventListener('change', adjustSuccessIconBackgroundColor);
7324 };
7325
7326 /**
7327 * @param {HTMLElement} icon
7328 * @param {SweetAlertOptions} params
7329 */
7330 const applyStyles = (icon, params) => {
7331 for (const [iconType, iconClassName] of Object.entries(iconTypes)) {
7332 if (params.icon !== iconType) {
7333 removeClass(icon, iconClassName);
7334 }
7335 }
7336 addClass(icon, params.icon && iconTypes[params.icon]);
7337
7338 // Icon color
7339 setColor(icon, params);
7340
7341 // Success icon background color
7342 adjustSuccessIconBackgroundColor();
7343
7344 // Custom class
7345 applyCustomClass(icon, params, 'icon');
7346 };
7347
7348 // Adjust success icon background color to match the popup background color
7349 const adjustSuccessIconBackgroundColor = () => {
7350 const popup = getPopup();
7351 if (!popup) {
7352 return;
7353 }
7354 const popupBackgroundColor = window.getComputedStyle(popup).getPropertyValue('background-color');
7355 /** @type {NodeListOf<HTMLElement>} */
7356 const successIconParts = popup.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix');
7357 for (let i = 0; i < successIconParts.length; i++) {
7358 successIconParts[i].style.backgroundColor = popupBackgroundColor;
7359 }
7360 };
7361
7362 /**
7363 *
7364 * @param {SweetAlertOptions} params
7365 * @returns {string}
7366 */
7367 const successIconHtml = params => `
7368 ${params.animation ? '<div class="swal2-success-circular-line-left"></div>' : ''}
7369 <span class="swal2-success-line-tip"></span> <span class="swal2-success-line-long"></span>
7370 <div class="swal2-success-ring"></div>
7371 ${params.animation ? '<div class="swal2-success-fix"></div>' : ''}
7372 ${params.animation ? '<div class="swal2-success-circular-line-right"></div>' : ''}
7373 `;
7374 const errorIconHtml = `
7375 <span class="swal2-x-mark">
7376 <span class="swal2-x-mark-line-left"></span>
7377 <span class="swal2-x-mark-line-right"></span>
7378 </span>
7379 `;
7380
7381 /**
7382 * @param {HTMLElement} icon
7383 * @param {SweetAlertOptions} params
7384 */
7385 const setContent = (icon, params) => {
7386 if (!params.icon && !params.iconHtml) {
7387 return;
7388 }
7389 let oldContent = icon.innerHTML;
7390 let newContent = '';
7391 if (params.iconHtml) {
7392 newContent = iconContent(params.iconHtml);
7393 } else if (params.icon === 'success') {
7394 newContent = successIconHtml(params);
7395 oldContent = oldContent.replace(/ style=".*?"/g, ''); // undo adjustSuccessIconBackgroundColor()
7396 } else if (params.icon === 'error') {
7397 newContent = errorIconHtml;
7398 } else if (params.icon) {
7399 const defaultIconHtml = {
7400 question: '?',
7401 warning: '!',
7402 info: 'i'
7403 };
7404 newContent = iconContent(defaultIconHtml[params.icon]);
7405 }
7406 if (oldContent.trim() !== newContent.trim()) {
7407 setInnerHtml(icon, newContent);
7408 }
7409 };
7410
7411 /**
7412 * @param {HTMLElement} icon
7413 * @param {SweetAlertOptions} params
7414 */
7415 const setColor = (icon, params) => {
7416 if (!params.iconColor) {
7417 return;
7418 }
7419 icon.style.color = params.iconColor;
7420 icon.style.borderColor = params.iconColor;
7421 for (const sel of ['.swal2-success-line-tip', '.swal2-success-line-long', '.swal2-x-mark-line-left', '.swal2-x-mark-line-right']) {
7422 setStyle(icon, sel, 'background-color', params.iconColor);
7423 }
7424 setStyle(icon, '.swal2-success-ring', 'border-color', params.iconColor);
7425 };
7426
7427 /**
7428 * @param {string} content
7429 * @returns {string}
7430 */
7431 const iconContent = content => `<div class="${swalClasses['icon-content']}">${content}</div>`;
7432
7433 /**
7434 * @param {SweetAlert} instance
7435 * @param {SweetAlertOptions} params
7436 */
7437 const renderImage = (instance, params) => {
7438 const image = getImage();
7439 if (!image) {
7440 return;
7441 }
7442 if (!params.imageUrl) {
7443 hide(image);
7444 return;
7445 }
7446 show(image, '');
7447
7448 // Src, alt
7449 image.setAttribute('src', params.imageUrl);
7450 image.setAttribute('alt', params.imageAlt || '');
7451
7452 // Width, height
7453 applyNumericalStyle(image, 'width', params.imageWidth);
7454 applyNumericalStyle(image, 'height', params.imageHeight);
7455
7456 // Class
7457 image.className = swalClasses.image;
7458 applyCustomClass(image, params, 'image');
7459 };
7460
7461 let dragging = false;
7462 let mousedownX = 0;
7463 let mousedownY = 0;
7464 let initialX = 0;
7465 let initialY = 0;
7466
7467 /**
7468 * @param {HTMLElement} popup
7469 */
7470 const addDraggableListeners = popup => {
7471 popup.addEventListener('mousedown', down);
7472 document.body.addEventListener('mousemove', move);
7473 popup.addEventListener('mouseup', up);
7474 popup.addEventListener('touchstart', down);
7475 document.body.addEventListener('touchmove', move);
7476 popup.addEventListener('touchend', up);
7477 };
7478
7479 /**
7480 * @param {HTMLElement} popup
7481 */
7482 const removeDraggableListeners = popup => {
7483 popup.removeEventListener('mousedown', down);
7484 document.body.removeEventListener('mousemove', move);
7485 popup.removeEventListener('mouseup', up);
7486 popup.removeEventListener('touchstart', down);
7487 document.body.removeEventListener('touchmove', move);
7488 popup.removeEventListener('touchend', up);
7489 };
7490
7491 /**
7492 * @param {MouseEvent | TouchEvent} event
7493 */
7494 const down = event => {
7495 const popup = getPopup();
7496 if (!popup) {
7497 return;
7498 }
7499 const icon = getIcon();
7500 if (event.target === popup || icon && icon.contains(/** @type {HTMLElement} */event.target)) {
7501 dragging = true;
7502 const clientXY = getClientXY(event);
7503 mousedownX = clientXY.clientX;
7504 mousedownY = clientXY.clientY;
7505 initialX = parseInt(popup.style.insetInlineStart) || 0;
7506 initialY = parseInt(popup.style.insetBlockStart) || 0;
7507 addClass(popup, 'swal2-dragging');
7508 }
7509 };
7510
7511 /**
7512 * @param {MouseEvent | TouchEvent} event
7513 */
7514 const move = event => {
7515 const popup = getPopup();
7516 if (!popup) {
7517 return;
7518 }
7519 if (dragging) {
7520 let {
7521 clientX,
7522 clientY
7523 } = getClientXY(event);
7524 const deltaX = clientX - mousedownX;
7525 // In RTL mode, negate the horizontal delta since insetInlineStart refers to the right edge
7526 popup.style.insetInlineStart = `${initialX + (globalState.isRTL ? -deltaX : deltaX)}px`;
7527 popup.style.insetBlockStart = `${initialY + (clientY - mousedownY)}px`;
7528 }
7529 };
7530 const up = () => {
7531 const popup = getPopup();
7532 dragging = false;
7533 removeClass(popup, 'swal2-dragging');
7534 };
7535
7536 /**
7537 * @param {MouseEvent | TouchEvent} event
7538 * @returns {{ clientX: number, clientY: number }}
7539 */
7540 const getClientXY = event => {
7541 let clientX = 0,
7542 clientY = 0;
7543 if (event.type.startsWith('mouse')) {
7544 clientX = /** @type {MouseEvent} */event.clientX;
7545 clientY = /** @type {MouseEvent} */event.clientY;
7546 } else if (event.type.startsWith('touch')) {
7547 clientX = /** @type {TouchEvent} */event.touches[0].clientX;
7548 clientY = /** @type {TouchEvent} */event.touches[0].clientY;
7549 }
7550 return {
7551 clientX,
7552 clientY
7553 };
7554 };
7555
7556 /**
7557 * @param {SweetAlert} instance
7558 * @param {SweetAlertOptions} params
7559 */
7560 const renderPopup = (instance, params) => {
7561 const container = getContainer();
7562 const popup = getPopup();
7563 if (!container || !popup) {
7564 return;
7565 }
7566
7567 // Width
7568 // https://github.com/sweetalert2/sweetalert2/issues/2170
7569 if (params.toast) {
7570 applyNumericalStyle(container, 'width', params.width);
7571 popup.style.width = '100%';
7572 const loader = getLoader();
7573 if (loader) {
7574 popup.insertBefore(loader, getIcon());
7575 }
7576 } else {
7577 applyNumericalStyle(popup, 'width', params.width);
7578 }
7579
7580 // Padding
7581 applyNumericalStyle(popup, 'padding', params.padding);
7582
7583 // Color
7584 if (params.color) {
7585 popup.style.color = params.color;
7586 }
7587
7588 // Background
7589 if (params.background) {
7590 popup.style.background = params.background;
7591 }
7592 hide(getValidationMessage());
7593
7594 // Classes
7595 addClasses$1(popup, params);
7596 if (params.draggable && !params.toast) {
7597 addClass(popup, swalClasses.draggable);
7598 addDraggableListeners(popup);
7599 } else {
7600 removeClass(popup, swalClasses.draggable);
7601 removeDraggableListeners(popup);
7602 }
7603 };
7604
7605 /**
7606 * @param {HTMLElement} popup
7607 * @param {SweetAlertOptions} params
7608 */
7609 const addClasses$1 = (popup, params) => {
7610 const showClass = params.showClass || {};
7611 // Default Class + showClass when updating Swal.update({})
7612 popup.className = `${swalClasses.popup} ${isVisible$1(popup) ? showClass.popup : ''}`;
7613 if (params.toast) {
7614 addClass([document.documentElement, document.body], swalClasses['toast-shown']);
7615 addClass(popup, swalClasses.toast);
7616 } else {
7617 addClass(popup, swalClasses.modal);
7618 }
7619
7620 // Custom class
7621 applyCustomClass(popup, params, 'popup');
7622 // TODO: remove in the next major
7623 if (typeof params.customClass === 'string') {
7624 addClass(popup, params.customClass);
7625 }
7626
7627 // Icon class (#1842)
7628 if (params.icon) {
7629 addClass(popup, swalClasses[`icon-${params.icon}`]);
7630 }
7631 };
7632
7633 /**
7634 * @param {SweetAlert} instance
7635 * @param {SweetAlertOptions} params
7636 */
7637 const renderProgressSteps = (instance, params) => {
7638 const progressStepsContainer = getProgressSteps();
7639 if (!progressStepsContainer) {
7640 return;
7641 }
7642 const {
7643 progressSteps,
7644 currentProgressStep
7645 } = params;
7646 if (!progressSteps || progressSteps.length === 0 || currentProgressStep === undefined) {
7647 hide(progressStepsContainer);
7648 return;
7649 }
7650 show(progressStepsContainer);
7651 progressStepsContainer.textContent = '';
7652 if (currentProgressStep >= progressSteps.length) {
7653 warn('Invalid currentProgressStep parameter, it should be less than progressSteps.length ' + '(currentProgressStep like JS arrays starts from 0)');
7654 }
7655 progressSteps.forEach((step, index) => {
7656 const stepEl = createStepElement(step);
7657 progressStepsContainer.appendChild(stepEl);
7658 if (index === currentProgressStep) {
7659 addClass(stepEl, swalClasses['active-progress-step']);
7660 }
7661 if (index !== progressSteps.length - 1) {
7662 const lineEl = createLineElement(params);
7663 progressStepsContainer.appendChild(lineEl);
7664 }
7665 });
7666 };
7667
7668 /**
7669 * @param {string} step
7670 * @returns {HTMLLIElement}
7671 */
7672 const createStepElement = step => {
7673 const stepEl = document.createElement('li');
7674 addClass(stepEl, swalClasses['progress-step']);
7675 setInnerHtml(stepEl, step);
7676 return stepEl;
7677 };
7678
7679 /**
7680 * @param {SweetAlertOptions} params
7681 * @returns {HTMLLIElement}
7682 */
7683 const createLineElement = params => {
7684 const lineEl = document.createElement('li');
7685 addClass(lineEl, swalClasses['progress-step-line']);
7686 if (params.progressStepsDistance) {
7687 applyNumericalStyle(lineEl, 'width', params.progressStepsDistance);
7688 }
7689 return lineEl;
7690 };
7691
7692 /**
7693 * @param {SweetAlert} instance
7694 * @param {SweetAlertOptions} params
7695 */
7696 const renderTitle = (instance, params) => {
7697 const title = getTitle();
7698 if (!title) {
7699 return;
7700 }
7701 showWhenInnerHtmlPresent(title);
7702 toggle(title, Boolean(params.title || params.titleText), 'block');
7703 if (params.title) {
7704 parseHtmlToContainer(params.title, title);
7705 }
7706 if (params.titleText) {
7707 title.innerText = params.titleText;
7708 }
7709
7710 // Custom class
7711 applyCustomClass(title, params, 'title');
7712 };
7713
7714 /**
7715 * @param {SweetAlert} instance
7716 * @param {SweetAlertOptions} params
7717 */
7718 const render = (instance, params) => {
7719 var _globalState$eventEmi;
7720 renderPopup(instance, params);
7721 renderContainer(instance, params);
7722 renderProgressSteps(instance, params);
7723 renderIcon(instance, params);
7724 renderImage(instance, params);
7725 renderTitle(instance, params);
7726 renderCloseButton(instance, params);
7727 renderContent(instance, params);
7728 renderActions(instance, params);
7729 renderFooter(instance, params);
7730 const popup = getPopup();
7731 if (typeof params.didRender === 'function' && popup) {
7732 params.didRender(popup);
7733 }
7734 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didRender', popup);
7735 };
7736
7737 /*
7738 * Global function to determine if SweetAlert2 popup is shown
7739 */
7740 const isVisible = () => {
7741 return isVisible$1(getPopup());
7742 };
7743
7744 /*
7745 * Global function to click 'Confirm' button
7746 */
7747 const clickConfirm = () => {
7748 var _dom$getConfirmButton;
7749 return (_dom$getConfirmButton = getConfirmButton()) === null || _dom$getConfirmButton === void 0 ? void 0 : _dom$getConfirmButton.click();
7750 };
7751
7752 /*
7753 * Global function to click 'Deny' button
7754 */
7755 const clickDeny = () => {
7756 var _dom$getDenyButton;
7757 return (_dom$getDenyButton = getDenyButton()) === null || _dom$getDenyButton === void 0 ? void 0 : _dom$getDenyButton.click();
7758 };
7759
7760 /*
7761 * Global function to click 'Cancel' button
7762 */
7763 const clickCancel = () => {
7764 var _dom$getCancelButton;
7765 return (_dom$getCancelButton = getCancelButton()) === null || _dom$getCancelButton === void 0 ? void 0 : _dom$getCancelButton.click();
7766 };
7767
7768 /** @type {Record<DismissReason, DismissReason>} */
7769 const DismissReason = Object.freeze({
7770 cancel: 'cancel',
7771 backdrop: 'backdrop',
7772 close: 'close',
7773 esc: 'esc',
7774 timer: 'timer'
7775 });
7776
7777 /**
7778 * @param {GlobalState} globalState
7779 */
7780 const removeKeydownHandler = globalState => {
7781 if (globalState.keydownTarget && globalState.keydownHandlerAdded && globalState.keydownHandler) {
7782 const handler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */globalState.keydownHandler;
7783 globalState.keydownTarget.removeEventListener('keydown', handler, {
7784 capture: globalState.keydownListenerCapture
7785 });
7786 globalState.keydownHandlerAdded = false;
7787 }
7788 };
7789
7790 /**
7791 * @param {GlobalState} globalState
7792 * @param {SweetAlertOptions} innerParams
7793 * @param {(dismiss: DismissReason) => void} dismissWith
7794 */
7795 const addKeydownHandler = (globalState, innerParams, dismissWith) => {
7796 removeKeydownHandler(globalState);
7797 if (!innerParams.toast) {
7798 /** @type {(this: HTMLElement, event: KeyboardEvent) => void} */
7799 const handler = e => keydownHandler(innerParams, e, dismissWith);
7800 globalState.keydownHandler = handler;
7801 const target = innerParams.keydownListenerCapture ? window : getPopup();
7802 if (target) {
7803 globalState.keydownTarget = target;
7804 globalState.keydownListenerCapture = innerParams.keydownListenerCapture;
7805 const eventHandler = /** @type {EventListenerOrEventListenerObject} */ /** @type {unknown} */handler;
7806 globalState.keydownTarget.addEventListener('keydown', eventHandler, {
7807 capture: globalState.keydownListenerCapture
7808 });
7809 globalState.keydownHandlerAdded = true;
7810 }
7811 }
7812 };
7813
7814 /**
7815 * @param {number} index
7816 * @param {number} increment
7817 */
7818 const setFocus = (index, increment) => {
7819 var _dom$getPopup;
7820 const focusableElements = getFocusableElements();
7821 // search for visible elements and select the next possible match
7822 if (focusableElements.length) {
7823 index = index + increment;
7824
7825 // shift + tab when .swal2-popup is focused
7826 if (index === -2) {
7827 index = focusableElements.length - 1;
7828 }
7829
7830 // rollover to first item
7831 if (index === focusableElements.length) {
7832 index = 0;
7833
7834 // go to last item
7835 } else if (index === -1) {
7836 index = focusableElements.length - 1;
7837 }
7838 focusableElements[index].focus();
7839 return;
7840 }
7841 // no visible focusable elements, focus the popup
7842 (_dom$getPopup = getPopup()) === null || _dom$getPopup === void 0 || _dom$getPopup.focus();
7843 };
7844 const arrowKeysNextButton = ['ArrowRight', 'ArrowDown'];
7845 const arrowKeysPreviousButton = ['ArrowLeft', 'ArrowUp'];
7846
7847 /**
7848 * @param {SweetAlertOptions} innerParams
7849 * @param {KeyboardEvent} event
7850 * @param {(dismiss: DismissReason) => void} dismissWith
7851 */
7852 const keydownHandler = (innerParams, event, dismissWith) => {
7853 if (!innerParams) {
7854 return; // This instance has already been destroyed
7855 }
7856
7857 // Ignore keydown during IME composition
7858 // https://developer.mozilla.org/en-US/docs/Web/API/Document/keydown_event#ignoring_keydown_during_ime_composition
7859 // https://github.com/sweetalert2/sweetalert2/issues/720
7860 // https://github.com/sweetalert2/sweetalert2/issues/2406
7861 if (event.isComposing || event.keyCode === 229) {
7862 return;
7863 }
7864 if (innerParams.stopKeydownPropagation) {
7865 event.stopPropagation();
7866 }
7867
7868 // ENTER
7869 if (event.key === 'Enter') {
7870 handleEnter(event, innerParams);
7871 }
7872
7873 // TAB
7874 else if (event.key === 'Tab') {
7875 handleTab(event);
7876 }
7877
7878 // ARROWS - switch focus between buttons
7879 else if ([...arrowKeysNextButton, ...arrowKeysPreviousButton].includes(event.key)) {
7880 handleArrows(event.key);
7881 }
7882
7883 // ESC
7884 else if (event.key === 'Escape') {
7885 handleEsc(event, innerParams, dismissWith);
7886 }
7887 };
7888
7889 /**
7890 * @param {KeyboardEvent} event
7891 * @param {SweetAlertOptions} innerParams
7892 */
7893 const handleEnter = (event, innerParams) => {
7894 // https://github.com/sweetalert2/sweetalert2/issues/2386
7895 if (!callIfFunction(innerParams.allowEnterKey)) {
7896 return;
7897 }
7898 const popup = getPopup();
7899 if (!popup || !innerParams.input) {
7900 return;
7901 }
7902 const input = getInput$1(popup, innerParams.input);
7903 if (event.target && input && event.target instanceof HTMLElement && event.target.outerHTML === input.outerHTML) {
7904 if (['textarea', 'file'].includes(innerParams.input)) {
7905 return; // do not submit
7906 }
7907 clickConfirm();
7908 event.preventDefault();
7909 }
7910 };
7911
7912 /**
7913 * @param {KeyboardEvent} event
7914 */
7915 const handleTab = event => {
7916 const targetElement = event.target;
7917 const focusableElements = getFocusableElements();
7918 let btnIndex = -1;
7919 for (let i = 0; i < focusableElements.length; i++) {
7920 if (targetElement === focusableElements[i]) {
7921 btnIndex = i;
7922 break;
7923 }
7924 }
7925
7926 // Cycle to the next button
7927 if (!event.shiftKey) {
7928 setFocus(btnIndex, 1);
7929 }
7930
7931 // Cycle to the prev button
7932 else {
7933 setFocus(btnIndex, -1);
7934 }
7935 event.stopPropagation();
7936 event.preventDefault();
7937 };
7938
7939 /**
7940 * @param {string} key
7941 */
7942 const handleArrows = key => {
7943 const actions = getActions();
7944 const confirmButton = getConfirmButton();
7945 const denyButton = getDenyButton();
7946 const cancelButton = getCancelButton();
7947 if (!actions || !confirmButton || !denyButton || !cancelButton) {
7948 return;
7949 }
7950 /** @type HTMLElement[] */
7951 const buttons = [confirmButton, denyButton, cancelButton];
7952 if (document.activeElement instanceof HTMLElement && !buttons.includes(document.activeElement)) {
7953 return;
7954 }
7955 const sibling = arrowKeysNextButton.includes(key) ? 'nextElementSibling' : 'previousElementSibling';
7956 let buttonToFocus = document.activeElement;
7957 if (!buttonToFocus) {
7958 return;
7959 }
7960 for (let i = 0; i < actions.children.length; i++) {
7961 buttonToFocus = buttonToFocus[sibling];
7962 if (!buttonToFocus) {
7963 return;
7964 }
7965 if (buttonToFocus instanceof HTMLButtonElement && isVisible$1(buttonToFocus)) {
7966 break;
7967 }
7968 }
7969 if (buttonToFocus instanceof HTMLButtonElement) {
7970 buttonToFocus.focus();
7971 }
7972 };
7973
7974 /**
7975 * @param {KeyboardEvent} event
7976 * @param {SweetAlertOptions} innerParams
7977 * @param {(dismiss: DismissReason) => void} dismissWith
7978 */
7979 const handleEsc = (event, innerParams, dismissWith) => {
7980 event.preventDefault();
7981 if (callIfFunction(innerParams.allowEscapeKey)) {
7982 dismissWith(DismissReason.esc);
7983 }
7984 };
7985
7986 /**
7987 * This module contains `WeakMap`s for each effectively-"private property" that a `Swal` has.
7988 * For example, to set the private property "foo" of `this` to "bar", you can `privateProps.foo.set(this, 'bar')`
7989 * This is the approach that Babel will probably take to implement private methods/fields
7990 * https://github.com/tc39/proposal-private-methods
7991 * https://github.com/babel/babel/pull/7555
7992 * Once we have the changes from that PR in Babel, and our core class fits reasonable in *one module*
7993 * then we can use that language feature.
7994 */
7995
7996 var privateMethods = {
7997 swalPromiseResolve: new WeakMap(),
7998 swalPromiseReject: new WeakMap()
7999 };
8000
8001 // From https://developer.paciellogroup.com/blog/2018/06/the-current-state-of-modal-dialog-accessibility/
8002 // Adding aria-hidden="true" to elements outside of the active modal dialog ensures that
8003 // elements not within the active modal dialog will not be surfaced if a user opens a screen
8004 // reader’s list of elements (headings, form controls, landmarks, etc.) in the document.
8005
8006 const setAriaHidden = () => {
8007 const container = getContainer();
8008 const bodyChildren = Array.from(document.body.children);
8009 bodyChildren.forEach(el => {
8010 if (el.contains(container)) {
8011 return;
8012 }
8013 if (el.hasAttribute('aria-hidden')) {
8014 el.setAttribute('data-previous-aria-hidden', el.getAttribute('aria-hidden') || '');
8015 }
8016 el.setAttribute('aria-hidden', 'true');
8017 });
8018 };
8019 const unsetAriaHidden = () => {
8020 const bodyChildren = Array.from(document.body.children);
8021 bodyChildren.forEach(el => {
8022 if (el.hasAttribute('data-previous-aria-hidden')) {
8023 el.setAttribute('aria-hidden', el.getAttribute('data-previous-aria-hidden') || '');
8024 el.removeAttribute('data-previous-aria-hidden');
8025 } else {
8026 el.removeAttribute('aria-hidden');
8027 }
8028 });
8029 };
8030
8031 // @ts-ignore
8032 const isSafariOrIOS = typeof window !== 'undefined' && Boolean(window.GestureEvent); // true for Safari desktop + all iOS browsers https://stackoverflow.com/a/70585394
8033
8034 /**
8035 * Fix iOS scrolling
8036 * http://stackoverflow.com/q/39626302
8037 */
8038 const iOSfix = () => {
8039 if (isSafariOrIOS && !hasClass(document.body, swalClasses.iosfix)) {
8040 const offset = document.body.scrollTop;
8041 document.body.style.top = `${offset * -1}px`;
8042 addClass(document.body, swalClasses.iosfix);
8043 lockBodyScroll();
8044 }
8045 };
8046
8047 /**
8048 * https://github.com/sweetalert2/sweetalert2/issues/1246
8049 */
8050 const lockBodyScroll = () => {
8051 const container = getContainer();
8052 if (!container) {
8053 return;
8054 }
8055 /** @type {boolean} */
8056 let preventTouchMove;
8057 /**
8058 * @param {TouchEvent} event
8059 */
8060 container.ontouchstart = event => {
8061 preventTouchMove = shouldPreventTouchMove(event);
8062 };
8063 /**
8064 * @param {TouchEvent} event
8065 */
8066 container.ontouchmove = event => {
8067 if (preventTouchMove) {
8068 event.preventDefault();
8069 event.stopPropagation();
8070 }
8071 };
8072 };
8073
8074 /**
8075 * @param {TouchEvent} event
8076 * @returns {boolean}
8077 */
8078 const shouldPreventTouchMove = event => {
8079 const target = event.target;
8080 const container = getContainer();
8081 const htmlContainer = getHtmlContainer();
8082 if (!container || !htmlContainer) {
8083 return false;
8084 }
8085 if (isStylus(event) || isZoom(event)) {
8086 return false;
8087 }
8088 if (target === container) {
8089 return true;
8090 }
8091 if (!isScrollable(container) && target instanceof HTMLElement && !selfOrParentIsScrollable(target, htmlContainer) &&
8092 // #2823
8093 target.tagName !== 'INPUT' &&
8094 // #1603
8095 target.tagName !== 'TEXTAREA' &&
8096 // #2266
8097 !(isScrollable(htmlContainer) &&
8098 // #1944
8099 htmlContainer.contains(target))) {
8100 return true;
8101 }
8102 return false;
8103 };
8104
8105 /**
8106 * https://github.com/sweetalert2/sweetalert2/issues/1786
8107 *
8108 * @param {TouchEvent} event
8109 * @returns {boolean}
8110 */
8111 const isStylus = event => {
8112 return Boolean(event.touches && event.touches.length &&
8113 // @ts-ignore - touchType is not a standard property
8114 event.touches[0].touchType === 'stylus');
8115 };
8116
8117 /**
8118 * https://github.com/sweetalert2/sweetalert2/issues/1891
8119 *
8120 * @param {TouchEvent} event
8121 * @returns {boolean}
8122 */
8123 const isZoom = event => {
8124 return event.touches && event.touches.length > 1;
8125 };
8126 const undoIOSfix = () => {
8127 if (hasClass(document.body, swalClasses.iosfix)) {
8128 const offset = parseInt(document.body.style.top, 10);
8129 removeClass(document.body, swalClasses.iosfix);
8130 document.body.style.top = '';
8131 document.body.scrollTop = offset * -1;
8132 }
8133 };
8134
8135 /**
8136 * Measure scrollbar width for padding body during modal show/hide
8137 * https://github.com/twbs/bootstrap/blob/master/js/src/modal.js
8138 *
8139 * @returns {number}
8140 */
8141 const measureScrollbar = () => {
8142 const scrollDiv = document.createElement('div');
8143 scrollDiv.className = swalClasses['scrollbar-measure'];
8144 document.body.appendChild(scrollDiv);
8145 const scrollbarWidth = scrollDiv.getBoundingClientRect().width - scrollDiv.clientWidth;
8146 document.body.removeChild(scrollDiv);
8147 return scrollbarWidth;
8148 };
8149
8150 /**
8151 * Remember state in cases where opening and handling a modal will fiddle with it.
8152 * @type {number | null}
8153 */
8154 let previousBodyPadding = null;
8155
8156 /**
8157 * @param {string} initialBodyOverflow
8158 */
8159 const replaceScrollbarWithPadding = initialBodyOverflow => {
8160 // for queues, do not do this more than once
8161 if (previousBodyPadding !== null) {
8162 return;
8163 }
8164 // if the body has overflow
8165 if (document.body.scrollHeight > window.innerHeight || initialBodyOverflow === 'scroll' // https://github.com/sweetalert2/sweetalert2/issues/2663
8166 ) {
8167 // add padding so the content doesn't shift after removal of scrollbar
8168 previousBodyPadding = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'));
8169 document.body.style.paddingRight = `${previousBodyPadding + measureScrollbar()}px`;
8170 }
8171 };
8172 const undoReplaceScrollbarWithPadding = () => {
8173 if (previousBodyPadding !== null) {
8174 document.body.style.paddingRight = `${previousBodyPadding}px`;
8175 previousBodyPadding = null;
8176 }
8177 };
8178
8179 /**
8180 * @param {SweetAlert} instance
8181 * @param {HTMLElement} container
8182 * @param {boolean} returnFocus
8183 * @param {(() => void) | undefined} didClose
8184 */
8185 function removePopupAndResetState(instance, container, returnFocus, didClose) {
8186 if (isToast()) {
8187 triggerDidCloseAndDispose(instance, didClose);
8188 } else {
8189 restoreActiveElement(returnFocus).then(() => triggerDidCloseAndDispose(instance, didClose));
8190 removeKeydownHandler(globalState);
8191 }
8192
8193 // workaround for https://github.com/sweetalert2/sweetalert2/issues/2088
8194 // for some reason removing the container in Safari will scroll the document to bottom
8195 if (isSafariOrIOS) {
8196 container.setAttribute('style', 'display:none !important');
8197 container.removeAttribute('class');
8198 container.innerHTML = '';
8199 } else {
8200 container.remove();
8201 }
8202 if (isModal()) {
8203 undoReplaceScrollbarWithPadding();
8204 undoIOSfix();
8205 unsetAriaHidden();
8206 }
8207 removeBodyClasses();
8208 }
8209
8210 /**
8211 * Remove SweetAlert2 classes from body
8212 */
8213 function removeBodyClasses() {
8214 removeClass([document.documentElement, document.body], [swalClasses.shown, swalClasses['height-auto'], swalClasses['no-backdrop'], swalClasses['toast-shown']]);
8215 }
8216
8217 /**
8218 * Instance method to close sweetAlert
8219 *
8220 * @param {SweetAlertResult | undefined} resolveValue
8221 * @this {SweetAlert}
8222 */
8223 function close(resolveValue) {
8224 resolveValue = prepareResolveValue(resolveValue);
8225 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(this);
8226 const didClose = triggerClosePopup(this);
8227 if (this.isAwaitingPromise) {
8228 // A swal awaiting for a promise (after a click on Confirm or Deny) cannot be dismissed anymore #2335
8229 if (!resolveValue.isDismissed) {
8230 handleAwaitingPromise(this);
8231 swalPromiseResolve(resolveValue);
8232 }
8233 } else if (didClose) {
8234 // Resolve Swal promise
8235 swalPromiseResolve(resolveValue);
8236 }
8237 }
8238
8239 /**
8240 * @param {SweetAlert} instance
8241 * @returns {boolean}
8242 */
8243 const triggerClosePopup = instance => {
8244 const popup = getPopup();
8245 if (!popup) {
8246 return false;
8247 }
8248 const innerParams = privateProps.innerParams.get(instance);
8249 if (!innerParams || hasClass(popup, innerParams.hideClass.popup)) {
8250 return false;
8251 }
8252 removeClass(popup, innerParams.showClass.popup);
8253 addClass(popup, innerParams.hideClass.popup);
8254 const backdrop = getContainer();
8255 removeClass(backdrop, innerParams.showClass.backdrop);
8256 addClass(backdrop, innerParams.hideClass.backdrop);
8257 handlePopupAnimation(instance, popup, innerParams);
8258 return true;
8259 };
8260
8261 /**
8262 * @param {Error | string} error
8263 * @this {SweetAlert}
8264 */
8265 function rejectPromise(error) {
8266 const rejectPromise = privateMethods.swalPromiseReject.get(this);
8267 handleAwaitingPromise(this);
8268 if (rejectPromise) {
8269 // Reject Swal promise
8270 rejectPromise(error);
8271 }
8272 }
8273
8274 /**
8275 * @param {SweetAlert} instance
8276 */
8277 const handleAwaitingPromise = instance => {
8278 if (instance.isAwaitingPromise) {
8279 // @ts-ignore
8280 delete instance.isAwaitingPromise;
8281 // The instance might have been previously partly destroyed, we must resume the destroy process in this case #2335
8282 if (!privateProps.innerParams.get(instance)) {
8283 instance._destroy();
8284 }
8285 }
8286 };
8287
8288 /**
8289 * @param {SweetAlertResult | undefined} resolveValue
8290 * @returns {SweetAlertResult}
8291 */
8292 const prepareResolveValue = resolveValue => {
8293 // When user calls Swal.close()
8294 if (typeof resolveValue === 'undefined') {
8295 return {
8296 isConfirmed: false,
8297 isDenied: false,
8298 isDismissed: true
8299 };
8300 }
8301 return Object.assign({
8302 isConfirmed: false,
8303 isDenied: false,
8304 isDismissed: false
8305 }, resolveValue);
8306 };
8307
8308 /**
8309 * @param {SweetAlert} instance
8310 * @param {HTMLElement} popup
8311 * @param {SweetAlertOptions} innerParams
8312 */
8313 const handlePopupAnimation = (instance, popup, innerParams) => {
8314 var _globalState$eventEmi;
8315 const container = getContainer();
8316 // If animation is supported, animate
8317 const animationIsSupported = hasCssAnimation(popup);
8318 if (typeof innerParams.willClose === 'function') {
8319 innerParams.willClose(popup);
8320 }
8321 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willClose', popup);
8322 if (animationIsSupported && container) {
8323 animatePopup(instance, popup, container, Boolean(innerParams.returnFocus), innerParams.didClose);
8324 } else if (container) {
8325 // Otherwise, remove immediately
8326 removePopupAndResetState(instance, container, Boolean(innerParams.returnFocus), innerParams.didClose);
8327 }
8328 };
8329
8330 /**
8331 * @param {SweetAlert} instance
8332 * @param {HTMLElement} popup
8333 * @param {HTMLElement} container
8334 * @param {boolean} returnFocus
8335 * @param {(() => void) | undefined} didClose
8336 */
8337 const animatePopup = (instance, popup, container, returnFocus, didClose) => {
8338 globalState.swalCloseEventFinishedCallback = removePopupAndResetState.bind(null, instance, container, returnFocus, didClose);
8339 /**
8340 * @param {AnimationEvent | TransitionEvent} e
8341 */
8342 const swalCloseAnimationFinished = function (e) {
8343 if (e.target === popup) {
8344 var _globalState$swalClos;
8345 (_globalState$swalClos = globalState.swalCloseEventFinishedCallback) === null || _globalState$swalClos === void 0 || _globalState$swalClos.call(globalState);
8346 delete globalState.swalCloseEventFinishedCallback;
8347 popup.removeEventListener('animationend', swalCloseAnimationFinished);
8348 popup.removeEventListener('transitionend', swalCloseAnimationFinished);
8349 }
8350 };
8351 popup.addEventListener('animationend', swalCloseAnimationFinished);
8352 popup.addEventListener('transitionend', swalCloseAnimationFinished);
8353 };
8354
8355 /**
8356 * @param {SweetAlert} instance
8357 * @param {(() => void) | undefined} didClose
8358 */
8359 const triggerDidCloseAndDispose = (instance, didClose) => {
8360 setTimeout(() => {
8361 var _globalState$eventEmi2;
8362 if (typeof didClose === 'function') {
8363 didClose.bind(instance.params)();
8364 }
8365 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didClose');
8366 // instance might have been destroyed already
8367 if (instance._destroy) {
8368 instance._destroy();
8369 }
8370 });
8371 };
8372
8373 /**
8374 * Shows loader (spinner), this is useful with AJAX requests.
8375 * By default the loader be shown instead of the "Confirm" button.
8376 *
8377 * @param {HTMLButtonElement | null} [buttonToReplace]
8378 */
8379 const showLoading = buttonToReplace => {
8380 let popup = getPopup();
8381 if (!popup) {
8382 new Swal();
8383 }
8384 popup = getPopup();
8385 if (!popup) {
8386 return;
8387 }
8388 const loader = getLoader();
8389 if (isToast()) {
8390 hide(getIcon());
8391 } else {
8392 replaceButton(popup, buttonToReplace);
8393 }
8394 show(loader);
8395 popup.setAttribute('data-loading', 'true');
8396 popup.setAttribute('aria-busy', 'true');
8397 popup.focus();
8398 };
8399
8400 /**
8401 * @param {HTMLElement} popup
8402 * @param {HTMLButtonElement | null} [buttonToReplace]
8403 */
8404 const replaceButton = (popup, buttonToReplace) => {
8405 const actions = getActions();
8406 const loader = getLoader();
8407 if (!actions || !loader) {
8408 return;
8409 }
8410 if (!buttonToReplace && isVisible$1(getConfirmButton())) {
8411 buttonToReplace = getConfirmButton();
8412 }
8413 show(actions);
8414 if (buttonToReplace) {
8415 hide(buttonToReplace);
8416 loader.setAttribute('data-button-to-replace', buttonToReplace.className);
8417 actions.insertBefore(loader, buttonToReplace);
8418 }
8419 addClass([popup, actions], swalClasses.loading);
8420 };
8421
8422 /**
8423 * @param {SweetAlert} instance
8424 * @param {SweetAlertOptions} params
8425 */
8426 const handleInputOptionsAndValue = (instance, params) => {
8427 if (params.input === 'select' || params.input === 'radio') {
8428 handleInputOptions(instance, params);
8429 } else if (['text', 'email', 'number', 'tel', 'textarea'].some(i => i === params.input) && (hasToPromiseFn(params.inputValue) || isPromise(params.inputValue))) {
8430 showLoading(getConfirmButton());
8431 handleInputValue(instance, params);
8432 }
8433 };
8434
8435 /**
8436 * @param {SweetAlert} instance
8437 * @param {SweetAlertOptions} innerParams
8438 * @returns {SweetAlertInputValue}
8439 */
8440 const getInputValue = (instance, innerParams) => {
8441 const input = instance.getInput();
8442 if (!input) {
8443 return null;
8444 }
8445 switch (innerParams.input) {
8446 case 'checkbox':
8447 return getCheckboxValue(input);
8448 case 'radio':
8449 return getRadioValue(input);
8450 case 'file':
8451 return getFileValue(input);
8452 default:
8453 return innerParams.inputAutoTrim ? input.value.trim() : input.value;
8454 }
8455 };
8456
8457 /**
8458 * @param {HTMLInputElement} input
8459 * @returns {number}
8460 */
8461 const getCheckboxValue = input => input.checked ? 1 : 0;
8462
8463 /**
8464 * @param {HTMLInputElement} input
8465 * @returns {string | null}
8466 */
8467 const getRadioValue = input => input.checked ? input.value : null;
8468
8469 /**
8470 * @param {HTMLInputElement} input
8471 * @returns {FileList | File | null}
8472 */
8473 const getFileValue = input => input.files && input.files.length ? input.getAttribute('multiple') !== null ? input.files : input.files[0] : null;
8474
8475 /**
8476 * @param {SweetAlert} instance
8477 * @param {SweetAlertOptions} params
8478 */
8479 const handleInputOptions = (instance, params) => {
8480 const popup = getPopup();
8481 if (!popup) {
8482 return;
8483 }
8484 /**
8485 * @param {*} inputOptions
8486 */
8487 const processInputOptions = inputOptions => {
8488 if (params.input === 'select') {
8489 populateSelectOptions(popup, formatInputOptions(inputOptions), params);
8490 } else if (params.input === 'radio') {
8491 populateRadioOptions(popup, formatInputOptions(inputOptions), params);
8492 }
8493 };
8494 if (hasToPromiseFn(params.inputOptions) || isPromise(params.inputOptions)) {
8495 showLoading(getConfirmButton());
8496 asPromise(params.inputOptions).then(inputOptions => {
8497 instance.hideLoading();
8498 processInputOptions(inputOptions);
8499 });
8500 } else if (typeof params.inputOptions === 'object') {
8501 processInputOptions(params.inputOptions);
8502 } else {
8503 error(`Unexpected type of inputOptions! Expected object, Map or Promise, got ${typeof params.inputOptions}`);
8504 }
8505 };
8506
8507 /**
8508 * @param {SweetAlert} instance
8509 * @param {SweetAlertOptions} params
8510 */
8511 const handleInputValue = (instance, params) => {
8512 const input = instance.getInput();
8513 if (!input) {
8514 return;
8515 }
8516 hide(input);
8517 asPromise(params.inputValue).then(inputValue => {
8518 input.value = params.input === 'number' ? `${parseFloat(inputValue) || 0}` : `${inputValue}`;
8519 show(input);
8520 input.focus();
8521 instance.hideLoading();
8522 }).catch(err => {
8523 error(`Error in inputValue promise: ${err}`);
8524 input.value = '';
8525 show(input);
8526 input.focus();
8527 instance.hideLoading();
8528 });
8529 };
8530
8531 /**
8532 * @param {HTMLElement} popup
8533 * @param {InputOptionFlattened[]} inputOptions
8534 * @param {SweetAlertOptions} params
8535 */
8536 function populateSelectOptions(popup, inputOptions, params) {
8537 const select = getDirectChildByClass(popup, swalClasses.select);
8538 if (!select) {
8539 return;
8540 }
8541 /**
8542 * @param {HTMLElement} parent
8543 * @param {string} optionLabel
8544 * @param {string} optionValue
8545 */
8546 const renderOption = (parent, optionLabel, optionValue) => {
8547 const option = document.createElement('option');
8548 option.value = optionValue;
8549 setInnerHtml(option, optionLabel);
8550 option.selected = isSelected(optionValue, params.inputValue);
8551 parent.appendChild(option);
8552 };
8553 inputOptions.forEach(inputOption => {
8554 const optionValue = inputOption[0];
8555 const optionLabel = inputOption[1];
8556 // <optgroup> spec:
8557 // https://www.w3.org/TR/html401/interact/forms.html#h-17.6
8558 // "...all OPTGROUP elements must be specified directly within a SELECT element (i.e., groups may not be nested)..."
8559 // check whether this is a <optgroup>
8560 if (Array.isArray(optionLabel)) {
8561 // if it is an array, then it is an <optgroup>
8562 const optgroup = document.createElement('optgroup');
8563 optgroup.label = optionValue;
8564 optgroup.disabled = false; // not configurable for now
8565 select.appendChild(optgroup);
8566 optionLabel.forEach(o => renderOption(optgroup, o[1], o[0]));
8567 } else {
8568 // case of <option>
8569 renderOption(select, optionLabel, optionValue);
8570 }
8571 });
8572 select.focus();
8573 }
8574
8575 /**
8576 * @param {HTMLElement} popup
8577 * @param {InputOptionFlattened[]} inputOptions
8578 * @param {SweetAlertOptions} params
8579 */
8580 function populateRadioOptions(popup, inputOptions, params) {
8581 const radio = getDirectChildByClass(popup, swalClasses.radio);
8582 if (!radio) {
8583 return;
8584 }
8585 inputOptions.forEach(inputOption => {
8586 const radioValue = inputOption[0];
8587 const radioLabel = inputOption[1];
8588 const radioInput = document.createElement('input');
8589 const radioLabelElement = document.createElement('label');
8590 radioInput.type = 'radio';
8591 radioInput.name = swalClasses.radio;
8592 radioInput.value = radioValue;
8593 if (isSelected(radioValue, params.inputValue)) {
8594 radioInput.checked = true;
8595 }
8596 const label = document.createElement('span');
8597 setInnerHtml(label, radioLabel);
8598 label.className = swalClasses.label;
8599 radioLabelElement.appendChild(radioInput);
8600 radioLabelElement.appendChild(label);
8601 radio.appendChild(radioLabelElement);
8602 });
8603 const radios = radio.querySelectorAll('input');
8604 if (radios.length) {
8605 radios[0].focus();
8606 }
8607 }
8608
8609 /**
8610 * Converts `inputOptions` into an array of `[value, label]`s
8611 *
8612 * @param {*} inputOptions
8613 * @typedef {string[]} InputOptionFlattened
8614 * @returns {InputOptionFlattened[]}
8615 */
8616 const formatInputOptions = inputOptions => {
8617 /** @type {InputOptionFlattened[]} */
8618 const result = [];
8619 if (inputOptions instanceof Map) {
8620 inputOptions.forEach((value, key) => {
8621 let valueFormatted = value;
8622 if (typeof valueFormatted === 'object') {
8623 // case of <optgroup>
8624 valueFormatted = formatInputOptions(valueFormatted);
8625 }
8626 result.push([key, valueFormatted]);
8627 });
8628 } else {
8629 Object.keys(inputOptions).forEach(key => {
8630 let valueFormatted = inputOptions[key];
8631 if (typeof valueFormatted === 'object') {
8632 // case of <optgroup>
8633 valueFormatted = formatInputOptions(valueFormatted);
8634 }
8635 result.push([key, valueFormatted]);
8636 });
8637 }
8638 return result;
8639 };
8640
8641 /**
8642 * @param {string} optionValue
8643 * @param {SweetAlertInputValue} inputValue
8644 * @returns {boolean}
8645 */
8646 const isSelected = (optionValue, inputValue) => {
8647 return Boolean(inputValue) && inputValue !== null && inputValue !== undefined && inputValue.toString() === optionValue.toString();
8648 };
8649
8650 /**
8651 * @param {SweetAlert} instance
8652 */
8653 const handleConfirmButtonClick = instance => {
8654 const innerParams = privateProps.innerParams.get(instance);
8655 instance.disableButtons();
8656 if (innerParams.input) {
8657 handleConfirmOrDenyWithInput(instance, 'confirm');
8658 } else {
8659 confirm(instance, true);
8660 }
8661 };
8662
8663 /**
8664 * @param {SweetAlert} instance
8665 */
8666 const handleDenyButtonClick = instance => {
8667 const innerParams = privateProps.innerParams.get(instance);
8668 instance.disableButtons();
8669 if (innerParams.returnInputValueOnDeny) {
8670 handleConfirmOrDenyWithInput(instance, 'deny');
8671 } else {
8672 deny(instance, false);
8673 }
8674 };
8675
8676 /**
8677 * @param {SweetAlert} instance
8678 * @param {(dismiss: DismissReason) => void} dismissWith
8679 */
8680 const handleCancelButtonClick = (instance, dismissWith) => {
8681 instance.disableButtons();
8682 dismissWith(DismissReason.cancel);
8683 };
8684
8685 /**
8686 * @param {SweetAlert} instance
8687 * @param {'confirm' | 'deny'} type
8688 */
8689 const handleConfirmOrDenyWithInput = (instance, type) => {
8690 const innerParams = privateProps.innerParams.get(instance);
8691 if (!innerParams.input) {
8692 error(`The "input" parameter is needed to be set when using returnInputValueOn${capitalizeFirstLetter(type)}`);
8693 return;
8694 }
8695 const input = instance.getInput();
8696 const inputValue = getInputValue(instance, innerParams);
8697 if (innerParams.inputValidator) {
8698 handleInputValidator(instance, inputValue, type);
8699 } else if (input && !input.checkValidity()) {
8700 instance.enableButtons();
8701 instance.showValidationMessage(innerParams.validationMessage || input.validationMessage);
8702 } else if (type === 'deny') {
8703 deny(instance, inputValue);
8704 } else {
8705 confirm(instance, inputValue);
8706 }
8707 };
8708
8709 /**
8710 * @param {SweetAlert} instance
8711 * @param {SweetAlertInputValue} inputValue
8712 * @param {'confirm' | 'deny'} type
8713 */
8714 const handleInputValidator = (instance, inputValue, type) => {
8715 const innerParams = privateProps.innerParams.get(instance);
8716 instance.disableInput();
8717 const validationPromise = Promise.resolve().then(() => asPromise(innerParams.inputValidator(inputValue, innerParams.validationMessage)));
8718 validationPromise.then(validationMessage => {
8719 instance.enableButtons();
8720 instance.enableInput();
8721 if (validationMessage) {
8722 instance.showValidationMessage(validationMessage);
8723 } else if (type === 'deny') {
8724 deny(instance, inputValue);
8725 } else {
8726 confirm(instance, inputValue);
8727 }
8728 });
8729 };
8730
8731 /**
8732 * @param {SweetAlert} instance
8733 * @param {*} value
8734 */
8735 const deny = (instance, value) => {
8736 const innerParams = privateProps.innerParams.get(instance);
8737 if (innerParams.showLoaderOnDeny) {
8738 showLoading(getDenyButton());
8739 }
8740 if (innerParams.preDeny) {
8741 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
8742 const preDenyPromise = Promise.resolve().then(() => asPromise(innerParams.preDeny(value, innerParams.validationMessage)));
8743 preDenyPromise.then(preDenyValue => {
8744 if (preDenyValue === false) {
8745 instance.hideLoading();
8746 handleAwaitingPromise(instance);
8747 } else {
8748 instance.close(/** @type SweetAlertResult */{
8749 isDenied: true,
8750 value: typeof preDenyValue === 'undefined' ? value : preDenyValue
8751 });
8752 }
8753 }).catch(error => rejectWith(instance, error));
8754 } else {
8755 instance.close(/** @type SweetAlertResult */{
8756 isDenied: true,
8757 value
8758 });
8759 }
8760 };
8761
8762 /**
8763 * @param {SweetAlert} instance
8764 * @param {*} value
8765 */
8766 const succeedWith = (instance, value) => {
8767 instance.close(/** @type SweetAlertResult */{
8768 isConfirmed: true,
8769 value
8770 });
8771 };
8772
8773 /**
8774 *
8775 * @param {SweetAlert} instance
8776 * @param {string} error
8777 */
8778 const rejectWith = (instance, error) => {
8779 instance.rejectPromise(error);
8780 };
8781
8782 /**
8783 *
8784 * @param {SweetAlert} instance
8785 * @param {*} value
8786 */
8787 const confirm = (instance, value) => {
8788 const innerParams = privateProps.innerParams.get(instance);
8789 if (innerParams.showLoaderOnConfirm) {
8790 showLoading();
8791 }
8792 if (innerParams.preConfirm) {
8793 instance.resetValidationMessage();
8794 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
8795 const preConfirmPromise = Promise.resolve().then(() => asPromise(innerParams.preConfirm(value, innerParams.validationMessage)));
8796 preConfirmPromise.then(preConfirmValue => {
8797 if (isVisible$1(getValidationMessage()) || preConfirmValue === false) {
8798 instance.hideLoading();
8799 handleAwaitingPromise(instance);
8800 } else {
8801 succeedWith(instance, typeof preConfirmValue === 'undefined' ? value : preConfirmValue);
8802 }
8803 }).catch(error => rejectWith(instance, error));
8804 } else {
8805 succeedWith(instance, value);
8806 }
8807 };
8808
8809 /**
8810 * Hides loader and shows back the button which was hidden by .showLoading()
8811 * @this {SweetAlert}
8812 */
8813 function hideLoading() {
8814 // do nothing if popup is closed
8815 const innerParams = privateProps.innerParams.get(this);
8816 if (!innerParams) {
8817 return;
8818 }
8819 const domCache = privateProps.domCache.get(this);
8820 hide(domCache.loader);
8821 if (isToast()) {
8822 if (innerParams.icon) {
8823 show(getIcon());
8824 }
8825 } else {
8826 showRelatedButton(domCache);
8827 }
8828 removeClass([domCache.popup, domCache.actions], swalClasses.loading);
8829 domCache.popup.removeAttribute('aria-busy');
8830 domCache.popup.removeAttribute('data-loading');
8831 domCache.confirmButton.disabled = false;
8832 domCache.denyButton.disabled = false;
8833 domCache.cancelButton.disabled = false;
8834 }
8835
8836 /**
8837 * @param {DomCache} domCache
8838 */
8839 const showRelatedButton = domCache => {
8840 const dataButtonToReplace = domCache.loader.getAttribute('data-button-to-replace');
8841 const buttonToReplace = dataButtonToReplace ? domCache.popup.getElementsByClassName(dataButtonToReplace) : [];
8842 if (buttonToReplace.length) {
8843 show(/** @type {HTMLElement} */buttonToReplace[0], 'inline-block');
8844 } else if (allButtonsAreHidden()) {
8845 hide(domCache.actions);
8846 }
8847 };
8848
8849 /**
8850 * Gets the input DOM node, this method works with input parameter.
8851 *
8852 * @returns {HTMLInputElement | null}
8853 * @this {SweetAlert}
8854 */
8855 function getInput() {
8856 const innerParams = privateProps.innerParams.get(this);
8857 const domCache = privateProps.domCache.get(this);
8858 if (!domCache) {
8859 return null;
8860 }
8861 return getInput$1(domCache.popup, innerParams.input);
8862 }
8863
8864 /**
8865 * @param {SweetAlert} instance
8866 * @param {string[]} buttons
8867 * @param {boolean} disabled
8868 */
8869 function setButtonsDisabled(instance, buttons, disabled) {
8870 const domCache = privateProps.domCache.get(instance);
8871 buttons.forEach(button => {
8872 domCache[button].disabled = disabled;
8873 });
8874 }
8875
8876 /**
8877 * @param {HTMLInputElement | null} input
8878 * @param {boolean} disabled
8879 */
8880 function setInputDisabled(input, disabled) {
8881 const popup = getPopup();
8882 if (!popup || !input) {
8883 return;
8884 }
8885 if (input.type === 'radio') {
8886 /** @type {NodeListOf<HTMLInputElement>} */
8887 const radios = popup.querySelectorAll(`[name="${swalClasses.radio}"]`);
8888 for (let i = 0; i < radios.length; i++) {
8889 radios[i].disabled = disabled;
8890 }
8891 } else {
8892 input.disabled = disabled;
8893 }
8894 }
8895
8896 /**
8897 * Enable all the buttons
8898 * @this {SweetAlert}
8899 */
8900 function enableButtons() {
8901 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], false);
8902 }
8903
8904 /**
8905 * Disable all the buttons
8906 * @this {SweetAlert}
8907 */
8908 function disableButtons() {
8909 setButtonsDisabled(this, ['confirmButton', 'denyButton', 'cancelButton'], true);
8910 }
8911
8912 /**
8913 * Enable the input field
8914 * @this {SweetAlert}
8915 */
8916 function enableInput() {
8917 setInputDisabled(this.getInput(), false);
8918 }
8919
8920 /**
8921 * Disable the input field
8922 * @this {SweetAlert}
8923 */
8924 function disableInput() {
8925 setInputDisabled(this.getInput(), true);
8926 }
8927
8928 /**
8929 * Show block with validation message
8930 *
8931 * @param {string} error
8932 * @this {SweetAlert}
8933 */
8934 function showValidationMessage(error) {
8935 const domCache = privateProps.domCache.get(this);
8936 const params = privateProps.innerParams.get(this);
8937 setInnerHtml(domCache.validationMessage, error);
8938 domCache.validationMessage.className = swalClasses['validation-message'];
8939 if (params.customClass && params.customClass.validationMessage) {
8940 addClass(domCache.validationMessage, params.customClass.validationMessage);
8941 }
8942 show(domCache.validationMessage);
8943 const input = this.getInput();
8944 if (input) {
8945 input.setAttribute('aria-invalid', 'true');
8946 input.setAttribute('aria-describedby', swalClasses['validation-message']);
8947 focusInput(input);
8948 addClass(input, swalClasses.inputerror);
8949 }
8950 }
8951
8952 /**
8953 * Hide block with validation message
8954 *
8955 * @this {SweetAlert}
8956 */
8957 function resetValidationMessage() {
8958 const domCache = privateProps.domCache.get(this);
8959 if (domCache.validationMessage) {
8960 hide(domCache.validationMessage);
8961 }
8962 const input = this.getInput();
8963 if (input) {
8964 input.removeAttribute('aria-invalid');
8965 input.removeAttribute('aria-describedby');
8966 removeClass(input, swalClasses.inputerror);
8967 }
8968 }
8969
8970 const defaultParams = {
8971 title: '',
8972 titleText: '',
8973 text: '',
8974 html: '',
8975 footer: '',
8976 icon: undefined,
8977 iconColor: undefined,
8978 iconHtml: undefined,
8979 template: undefined,
8980 toast: false,
8981 draggable: false,
8982 animation: true,
8983 theme: 'light',
8984 showClass: {
8985 popup: 'swal2-show',
8986 backdrop: 'swal2-backdrop-show',
8987 icon: 'swal2-icon-show'
8988 },
8989 hideClass: {
8990 popup: 'swal2-hide',
8991 backdrop: 'swal2-backdrop-hide',
8992 icon: 'swal2-icon-hide'
8993 },
8994 customClass: {},
8995 target: 'body',
8996 color: undefined,
8997 backdrop: true,
8998 heightAuto: true,
8999 allowOutsideClick: true,
9000 allowEscapeKey: true,
9001 allowEnterKey: true,
9002 stopKeydownPropagation: true,
9003 keydownListenerCapture: false,
9004 showConfirmButton: true,
9005 showDenyButton: false,
9006 showCancelButton: false,
9007 preConfirm: undefined,
9008 preDeny: undefined,
9009 confirmButtonText: 'OK',
9010 confirmButtonAriaLabel: '',
9011 confirmButtonColor: undefined,
9012 denyButtonText: 'No',
9013 denyButtonAriaLabel: '',
9014 denyButtonColor: undefined,
9015 cancelButtonText: 'Cancel',
9016 cancelButtonAriaLabel: '',
9017 cancelButtonColor: undefined,
9018 buttonsStyling: true,
9019 reverseButtons: false,
9020 focusConfirm: true,
9021 focusDeny: false,
9022 focusCancel: false,
9023 returnFocus: true,
9024 showCloseButton: false,
9025 closeButtonHtml: '&times;',
9026 closeButtonAriaLabel: 'Close this dialog',
9027 loaderHtml: '',
9028 showLoaderOnConfirm: false,
9029 showLoaderOnDeny: false,
9030 imageUrl: undefined,
9031 imageWidth: undefined,
9032 imageHeight: undefined,
9033 imageAlt: '',
9034 timer: undefined,
9035 timerProgressBar: false,
9036 width: undefined,
9037 padding: undefined,
9038 background: undefined,
9039 input: undefined,
9040 inputPlaceholder: '',
9041 inputLabel: '',
9042 inputValue: '',
9043 inputOptions: {},
9044 inputAutoFocus: true,
9045 inputAutoTrim: true,
9046 inputAttributes: {},
9047 inputValidator: undefined,
9048 returnInputValueOnDeny: false,
9049 validationMessage: undefined,
9050 grow: false,
9051 position: 'center',
9052 progressSteps: [],
9053 currentProgressStep: undefined,
9054 progressStepsDistance: undefined,
9055 willOpen: undefined,
9056 didOpen: undefined,
9057 didRender: undefined,
9058 willClose: undefined,
9059 didClose: undefined,
9060 didDestroy: undefined,
9061 scrollbarPadding: true,
9062 topLayer: false
9063 };
9064 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'];
9065
9066 /** @type {Record<string, string | undefined>} */
9067 const deprecatedParams = {
9068 allowEnterKey: undefined
9069 };
9070 const toastIncompatibleParams = ['allowOutsideClick', 'allowEnterKey', 'backdrop', 'draggable', 'focusConfirm', 'focusDeny', 'focusCancel', 'returnFocus', 'heightAuto', 'keydownListenerCapture'];
9071
9072 /**
9073 * Is valid parameter
9074 *
9075 * @param {string} paramName
9076 * @returns {boolean}
9077 */
9078 const isValidParameter = paramName => {
9079 return Object.prototype.hasOwnProperty.call(defaultParams, paramName);
9080 };
9081
9082 /**
9083 * Is valid parameter for Swal.update() method
9084 *
9085 * @param {string} paramName
9086 * @returns {boolean}
9087 */
9088 const isUpdatableParameter = paramName => {
9089 return updatableParams.indexOf(paramName) !== -1;
9090 };
9091
9092 /**
9093 * Is deprecated parameter
9094 *
9095 * @param {string} paramName
9096 * @returns {string | undefined}
9097 */
9098 const isDeprecatedParameter = paramName => {
9099 return deprecatedParams[paramName];
9100 };
9101
9102 /**
9103 * @param {string} param
9104 */
9105 const checkIfParamIsValid = param => {
9106 if (!isValidParameter(param)) {
9107 warn(`Unknown parameter "${param}"`);
9108 }
9109 };
9110
9111 /**
9112 * @param {string} param
9113 */
9114 const checkIfToastParamIsValid = param => {
9115 if (toastIncompatibleParams.includes(param)) {
9116 warn(`The parameter "${param}" is incompatible with toasts`);
9117 }
9118 };
9119
9120 /**
9121 * @param {string} param
9122 */
9123 const checkIfParamIsDeprecated = param => {
9124 const isDeprecated = isDeprecatedParameter(param);
9125 if (isDeprecated) {
9126 warnAboutDeprecation(param, isDeprecated);
9127 }
9128 };
9129
9130 /**
9131 * Show relevant warnings for given params
9132 *
9133 * @param {SweetAlertOptions} params
9134 */
9135 const showWarningsForParams = params => {
9136 if (params.backdrop === false && params.allowOutsideClick) {
9137 warn('"allowOutsideClick" parameter requires `backdrop` parameter to be set to `true`');
9138 }
9139 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)) {
9140 warn(`Invalid theme "${params.theme}"`);
9141 }
9142 for (const param in params) {
9143 checkIfParamIsValid(param);
9144 if (params.toast) {
9145 checkIfToastParamIsValid(param);
9146 }
9147 checkIfParamIsDeprecated(param);
9148 }
9149 };
9150
9151 /**
9152 * Updates popup parameters.
9153 *
9154 * @this {any}
9155 * @param {SweetAlertOptions} params
9156 */
9157 function update(params) {
9158 const container = getContainer();
9159 const popup = getPopup();
9160 const innerParams = privateProps.innerParams.get(this);
9161 if (!popup || hasClass(popup, innerParams.hideClass.popup)) {
9162 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.`);
9163 return;
9164 }
9165 const validUpdatableParams = filterValidParams(params);
9166 const updatedParams = Object.assign({}, innerParams, validUpdatableParams);
9167 showWarningsForParams(updatedParams);
9168 if (container) {
9169 container.dataset['swal2Theme'] = updatedParams.theme;
9170 }
9171 render(this, updatedParams);
9172 privateProps.innerParams.set(this, updatedParams);
9173 Object.defineProperties(this, {
9174 params: {
9175 value: Object.assign({}, this.params, params),
9176 writable: false,
9177 enumerable: true
9178 }
9179 });
9180 }
9181
9182 /**
9183 * @param {SweetAlertOptions} params
9184 * @returns {SweetAlertOptions}
9185 */
9186 const filterValidParams = params => {
9187 /** @type {Record<string, any>} */
9188 const validUpdatableParams = {};
9189 Object.keys(params).forEach(param => {
9190 if (isUpdatableParameter(param)) {
9191 const typedParams = /** @type {Record<string, any>} */params;
9192 validUpdatableParams[param] = typedParams[param];
9193 } else {
9194 warn(`Invalid parameter to update: ${param}`);
9195 }
9196 });
9197 return validUpdatableParams;
9198 };
9199
9200 /**
9201 * Dispose the current SweetAlert2 instance
9202 * @this {SweetAlert}
9203 */
9204 function _destroy() {
9205 var _globalState$eventEmi;
9206 const domCache = privateProps.domCache.get(this);
9207 const innerParams = privateProps.innerParams.get(this);
9208 if (!innerParams) {
9209 disposeWeakMaps(this); // The WeakMaps might have been partly destroyed, we must recall it to dispose any remaining WeakMaps #2335
9210 return; // This instance has already been destroyed
9211 }
9212
9213 // Check if there is another Swal closing
9214 if (domCache.popup && globalState.swalCloseEventFinishedCallback) {
9215 globalState.swalCloseEventFinishedCallback();
9216 delete globalState.swalCloseEventFinishedCallback;
9217 }
9218 if (typeof innerParams.didDestroy === 'function') {
9219 innerParams.didDestroy();
9220 }
9221 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('didDestroy');
9222 disposeSwal(this);
9223 }
9224
9225 /**
9226 * @param {SweetAlert} instance
9227 */
9228 const disposeSwal = instance => {
9229 disposeWeakMaps(instance);
9230 // Unset this.params so GC will dispose it (#1569)
9231 // @ts-ignore
9232 delete instance.params;
9233 // Unset globalState props so GC will dispose globalState (#1569)
9234 delete globalState.keydownHandler;
9235 delete globalState.keydownTarget;
9236 // Unset currentInstance
9237 delete globalState.currentInstance;
9238 };
9239
9240 /**
9241 * @param {SweetAlert} instance
9242 */
9243 const disposeWeakMaps = instance => {
9244 // If the current instance is awaiting a promise result, we keep the privateMethods to call them once the promise result is retrieved #2335
9245 if (instance.isAwaitingPromise) {
9246 unsetWeakMaps(privateProps, instance);
9247 instance.isAwaitingPromise = true;
9248 } else {
9249 unsetWeakMaps(privateMethods, instance);
9250 unsetWeakMaps(privateProps, instance);
9251
9252 // @ts-ignore
9253 delete instance.isAwaitingPromise;
9254 // Unset instance methods
9255 // @ts-ignore
9256 delete instance.disableButtons;
9257 // @ts-ignore
9258 delete instance.enableButtons;
9259 // @ts-ignore
9260 delete instance.getInput;
9261 // @ts-ignore
9262 delete instance.disableInput;
9263 // @ts-ignore
9264 delete instance.enableInput;
9265 // @ts-ignore
9266 delete instance.hideLoading;
9267 // @ts-ignore
9268 delete instance.disableLoading;
9269 // @ts-ignore
9270 delete instance.showValidationMessage;
9271 // @ts-ignore
9272 delete instance.resetValidationMessage;
9273 // @ts-ignore
9274 delete instance.close;
9275 // @ts-ignore
9276 delete instance.closePopup;
9277 // @ts-ignore
9278 delete instance.closeModal;
9279 // @ts-ignore
9280 delete instance.closeToast;
9281 // @ts-ignore
9282 delete instance.rejectPromise;
9283 // @ts-ignore
9284 delete instance.update;
9285 // @ts-ignore
9286 delete instance._destroy;
9287 }
9288 };
9289
9290 /**
9291 * @param {Record<string, WeakMap<any, any>>} obj
9292 * @param {SweetAlert} instance
9293 */
9294 const unsetWeakMaps = (obj, instance) => {
9295 for (const i in obj) {
9296 obj[i].delete(instance);
9297 }
9298 };
9299
9300 var instanceMethods = /*#__PURE__*/Object.freeze({
9301 __proto__: null,
9302 _destroy: _destroy,
9303 close: close,
9304 closeModal: close,
9305 closePopup: close,
9306 closeToast: close,
9307 disableButtons: disableButtons,
9308 disableInput: disableInput,
9309 disableLoading: hideLoading,
9310 enableButtons: enableButtons,
9311 enableInput: enableInput,
9312 getInput: getInput,
9313 handleAwaitingPromise: handleAwaitingPromise,
9314 hideLoading: hideLoading,
9315 rejectPromise: rejectPromise,
9316 resetValidationMessage: resetValidationMessage,
9317 showValidationMessage: showValidationMessage,
9318 update: update
9319 });
9320
9321 /**
9322 * @param {SweetAlertOptions} innerParams
9323 * @param {DomCache} domCache
9324 * @param {(dismiss: DismissReason) => void} dismissWith
9325 */
9326 const handlePopupClick = (innerParams, domCache, dismissWith) => {
9327 if (innerParams.toast) {
9328 handleToastClick(innerParams, domCache, dismissWith);
9329 } else {
9330 // Ignore click events that had mousedown on the popup but mouseup on the container
9331 // This can happen when the user drags a slider
9332 handleModalMousedown(domCache);
9333
9334 // Ignore click events that had mousedown on the container but mouseup on the popup
9335 handleContainerMousedown(domCache);
9336 handleModalClick(innerParams, domCache, dismissWith);
9337 }
9338 };
9339
9340 /**
9341 * @param {SweetAlertOptions} innerParams
9342 * @param {DomCache} domCache
9343 * @param {(dismiss: DismissReason) => void} dismissWith
9344 */
9345 const handleToastClick = (innerParams, domCache, dismissWith) => {
9346 // Closing toast by internal click
9347 domCache.popup.onclick = () => {
9348 if (innerParams && (isAnyButtonShown(innerParams) || innerParams.timer || innerParams.input)) {
9349 return;
9350 }
9351 dismissWith(DismissReason.close);
9352 };
9353 };
9354
9355 /**
9356 * @param {SweetAlertOptions} innerParams
9357 * @returns {boolean}
9358 */
9359 const isAnyButtonShown = innerParams => {
9360 return Boolean(innerParams.showConfirmButton || innerParams.showDenyButton || innerParams.showCancelButton || innerParams.showCloseButton);
9361 };
9362 let ignoreOutsideClick = false;
9363
9364 /**
9365 * @param {DomCache} domCache
9366 */
9367 const handleModalMousedown = domCache => {
9368 domCache.popup.onmousedown = () => {
9369 domCache.container.onmouseup = function (e) {
9370 domCache.container.onmouseup = () => {};
9371 // We only check if the mouseup target is the container because usually it doesn't
9372 // have any other direct children aside of the popup
9373 if (e.target === domCache.container) {
9374 ignoreOutsideClick = true;
9375 }
9376 };
9377 };
9378 };
9379
9380 /**
9381 * @param {DomCache} domCache
9382 */
9383 const handleContainerMousedown = domCache => {
9384 domCache.container.onmousedown = e => {
9385 // prevent the modal text from being selected on double click on the container (allowOutsideClick: false)
9386 if (e.target === domCache.container) {
9387 e.preventDefault();
9388 }
9389 domCache.popup.onmouseup = function (e) {
9390 domCache.popup.onmouseup = () => {};
9391 // We also need to check if the mouseup target is a child of the popup
9392 if (e.target === domCache.popup || e.target instanceof HTMLElement && domCache.popup.contains(e.target)) {
9393 ignoreOutsideClick = true;
9394 }
9395 };
9396 };
9397 };
9398
9399 /**
9400 * @param {SweetAlertOptions} innerParams
9401 * @param {DomCache} domCache
9402 * @param {(dismiss: DismissReason) => void} dismissWith
9403 */
9404 const handleModalClick = (innerParams, domCache, dismissWith) => {
9405 domCache.container.onclick = e => {
9406 if (ignoreOutsideClick) {
9407 ignoreOutsideClick = false;
9408 return;
9409 }
9410 if (e.target === domCache.container && callIfFunction(innerParams.allowOutsideClick)) {
9411 dismissWith(DismissReason.backdrop);
9412 }
9413 };
9414 };
9415
9416 /**
9417 * @param {any} elem
9418 * @returns {boolean}
9419 */
9420 const isJqueryElement = elem => typeof elem === 'object' && elem.jquery;
9421
9422 /**
9423 * @param {any} elem
9424 * @returns {boolean}
9425 */
9426 const isElement = elem => elem instanceof Element || isJqueryElement(elem);
9427
9428 /**
9429 * @param {any[]} args
9430 * @returns {SweetAlertOptions}
9431 */
9432 const argsToParams = args => {
9433 /** @type {Record<string, any>} */
9434 const params = {};
9435 if (typeof args[0] === 'object' && !isElement(args[0])) {
9436 Object.assign(params, args[0]);
9437 } else {
9438 ['title', 'html', 'icon'].forEach((name, index) => {
9439 const arg = args[index];
9440 if (typeof arg === 'string' || isElement(arg)) {
9441 params[name] = arg;
9442 } else if (arg !== undefined) {
9443 error(`Unexpected type of ${name}! Expected "string" or "Element", got ${typeof arg}`);
9444 }
9445 });
9446 }
9447 return params;
9448 };
9449
9450 /**
9451 * Main method to create a new SweetAlert2 popup
9452 *
9453 * @this {new (...args: any[]) => any}
9454 * @param {...SweetAlertOptions} args
9455 * @returns {Promise<SweetAlertResult>}
9456 */
9457 function fire(...args) {
9458 return new this(...args);
9459 }
9460
9461 /**
9462 * Returns an extended version of `Swal` containing `params` as defaults.
9463 * Useful for reusing Swal configuration.
9464 *
9465 * For example:
9466 *
9467 * Before:
9468 * const textPromptOptions = { input: 'text', showCancelButton: true }
9469 * const {value: firstName} = await Swal.fire({ ...textPromptOptions, title: 'What is your first name?' })
9470 * const {value: lastName} = await Swal.fire({ ...textPromptOptions, title: 'What is your last name?' })
9471 *
9472 * After:
9473 * const TextPrompt = Swal.mixin({ input: 'text', showCancelButton: true })
9474 * const {value: firstName} = await TextPrompt('What is your first name?')
9475 * const {value: lastName} = await TextPrompt('What is your last name?')
9476 *
9477 * @param {SweetAlertOptions} mixinParams
9478 * @returns {SweetAlert}
9479 * @this {typeof import('../SweetAlert.js').SweetAlert}
9480 */
9481 function mixin(mixinParams) {
9482 // @ts-ignore: 'this' refers to the SweetAlert constructor
9483 class MixinSwal extends this {
9484 /**
9485 * @param {any} params
9486 * @param {any} priorityMixinParams
9487 */
9488 _main(params, priorityMixinParams) {
9489 return super._main(params, Object.assign({}, mixinParams, priorityMixinParams));
9490 }
9491 }
9492 // @ts-ignore
9493 return MixinSwal;
9494 }
9495
9496 /**
9497 * If `timer` parameter is set, returns number of milliseconds of timer remained.
9498 * Otherwise, returns undefined.
9499 *
9500 * @returns {number | undefined}
9501 */
9502 const getTimerLeft = () => {
9503 return globalState.timeout && globalState.timeout.getTimerLeft();
9504 };
9505
9506 /**
9507 * Stop timer. Returns number of milliseconds of timer remained.
9508 * If `timer` parameter isn't set, returns undefined.
9509 *
9510 * @returns {number | undefined}
9511 */
9512 const stopTimer = () => {
9513 if (globalState.timeout) {
9514 stopTimerProgressBar();
9515 return globalState.timeout.stop();
9516 }
9517 };
9518
9519 /**
9520 * Resume timer. Returns number of milliseconds of timer remained.
9521 * If `timer` parameter isn't set, returns undefined.
9522 *
9523 * @returns {number | undefined}
9524 */
9525 const resumeTimer = () => {
9526 if (globalState.timeout) {
9527 const remaining = globalState.timeout.start();
9528 animateTimerProgressBar(remaining);
9529 return remaining;
9530 }
9531 };
9532
9533 /**
9534 * Resume timer. Returns number of milliseconds of timer remained.
9535 * If `timer` parameter isn't set, returns undefined.
9536 *
9537 * @returns {number | undefined}
9538 */
9539 const toggleTimer = () => {
9540 const timer = globalState.timeout;
9541 return timer && (timer.running ? stopTimer() : resumeTimer());
9542 };
9543
9544 /**
9545 * Increase timer. Returns number of milliseconds of an updated timer.
9546 * If `timer` parameter isn't set, returns undefined.
9547 *
9548 * @param {number} ms
9549 * @returns {number | undefined}
9550 */
9551 const increaseTimer = ms => {
9552 if (globalState.timeout) {
9553 const remaining = globalState.timeout.increase(ms);
9554 animateTimerProgressBar(remaining, true);
9555 return remaining;
9556 }
9557 };
9558
9559 /**
9560 * Check if timer is running. Returns true if timer is running
9561 * or false if timer is paused or stopped.
9562 * If `timer` parameter isn't set, returns undefined
9563 *
9564 * @returns {boolean}
9565 */
9566 const isTimerRunning = () => {
9567 return Boolean(globalState.timeout && globalState.timeout.isRunning());
9568 };
9569
9570 let bodyClickListenerAdded = false;
9571 /** @type {Record<string, any>} */
9572 const clickHandlers = {};
9573
9574 /**
9575 * @this {any}
9576 * @param {string} attr
9577 */
9578 function bindClickHandler(attr = 'data-swal-template') {
9579 clickHandlers[attr] = this;
9580 if (!bodyClickListenerAdded) {
9581 document.body.addEventListener('click', bodyClickListener);
9582 bodyClickListenerAdded = true;
9583 }
9584 }
9585
9586 /**
9587 * @param {MouseEvent} event
9588 */
9589 const bodyClickListener = event => {
9590 for (let el = /** @type {any} */event.target; el && el !== document; el = el.parentNode) {
9591 for (const attr in clickHandlers) {
9592 const template = el.getAttribute && el.getAttribute(attr);
9593 if (template) {
9594 clickHandlers[attr].fire({
9595 template
9596 });
9597 return;
9598 }
9599 }
9600 }
9601 };
9602
9603 // Source: https://gist.github.com/mudge/5830382?permalink_comment_id=2691957#gistcomment-2691957
9604
9605 class EventEmitter {
9606 constructor() {
9607 /** @type {Events} */
9608 this.events = {};
9609 }
9610
9611 /**
9612 * @param {string} eventName
9613 * @returns {EventHandlers}
9614 */
9615 _getHandlersByEventName(eventName) {
9616 if (typeof this.events[eventName] === 'undefined') {
9617 // not Set because we need to keep the FIFO order
9618 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1748990334
9619 this.events[eventName] = [];
9620 }
9621 return this.events[eventName];
9622 }
9623
9624 /**
9625 * @param {string} eventName
9626 * @param {EventHandler} eventHandler
9627 */
9628 on(eventName, eventHandler) {
9629 const currentHandlers = this._getHandlersByEventName(eventName);
9630 if (!currentHandlers.includes(eventHandler)) {
9631 currentHandlers.push(eventHandler);
9632 }
9633 }
9634
9635 /**
9636 * @param {string} eventName
9637 * @param {EventHandler} eventHandler
9638 */
9639 once(eventName, eventHandler) {
9640 /**
9641 * @param {...any} args
9642 */
9643 const onceFn = (...args) => {
9644 this.removeListener(eventName, onceFn);
9645 // @ts-ignore
9646 eventHandler.apply(this, args);
9647 };
9648 this.on(eventName, onceFn);
9649 }
9650
9651 /**
9652 * @param {string} eventName
9653 * @param {...any} args
9654 */
9655 emit(eventName, ...args) {
9656 this._getHandlersByEventName(eventName).forEach(
9657 /**
9658 * @param {EventHandler} eventHandler
9659 */
9660 eventHandler => {
9661 try {
9662 // @ts-ignore
9663 eventHandler.apply(this, args);
9664 } catch (error) {
9665 console.error(error);
9666 }
9667 });
9668 }
9669
9670 /**
9671 * @param {string} eventName
9672 * @param {EventHandler} eventHandler
9673 */
9674 removeListener(eventName, eventHandler) {
9675 const currentHandlers = this._getHandlersByEventName(eventName);
9676 const index = currentHandlers.indexOf(eventHandler);
9677 if (index > -1) {
9678 currentHandlers.splice(index, 1);
9679 }
9680 }
9681
9682 /**
9683 * @param {string} eventName
9684 */
9685 removeAllListeners(eventName) {
9686 if (this.events[eventName] !== undefined) {
9687 // https://github.com/sweetalert2/sweetalert2/pull/2763#discussion_r1749239222
9688 this.events[eventName].length = 0;
9689 }
9690 }
9691 reset() {
9692 this.events = {};
9693 }
9694 }
9695
9696 globalState.eventEmitter = new EventEmitter();
9697
9698 /**
9699 * @param {string} eventName
9700 * @param {EventHandler} eventHandler
9701 */
9702 const on = (eventName, eventHandler) => {
9703 if (globalState.eventEmitter) {
9704 globalState.eventEmitter.on(eventName, eventHandler);
9705 }
9706 };
9707
9708 /**
9709 * @param {string} eventName
9710 * @param {EventHandler} eventHandler
9711 */
9712 const once = (eventName, eventHandler) => {
9713 if (globalState.eventEmitter) {
9714 globalState.eventEmitter.once(eventName, eventHandler);
9715 }
9716 };
9717
9718 /**
9719 * @param {string} [eventName]
9720 * @param {EventHandler} [eventHandler]
9721 */
9722 const off = (eventName, eventHandler) => {
9723 if (!globalState.eventEmitter) {
9724 return;
9725 }
9726
9727 // Remove all handlers for all events
9728 if (!eventName) {
9729 globalState.eventEmitter.reset();
9730 return;
9731 }
9732 if (eventHandler) {
9733 // Remove a specific handler
9734 globalState.eventEmitter.removeListener(eventName, eventHandler);
9735 } else {
9736 // Remove all handlers for a specific event
9737 globalState.eventEmitter.removeAllListeners(eventName);
9738 }
9739 };
9740
9741 var staticMethods = /*#__PURE__*/Object.freeze({
9742 __proto__: null,
9743 argsToParams: argsToParams,
9744 bindClickHandler: bindClickHandler,
9745 clickCancel: clickCancel,
9746 clickConfirm: clickConfirm,
9747 clickDeny: clickDeny,
9748 enableLoading: showLoading,
9749 fire: fire,
9750 getActions: getActions,
9751 getCancelButton: getCancelButton,
9752 getCloseButton: getCloseButton,
9753 getConfirmButton: getConfirmButton,
9754 getContainer: getContainer,
9755 getDenyButton: getDenyButton,
9756 getFocusableElements: getFocusableElements,
9757 getFooter: getFooter,
9758 getHtmlContainer: getHtmlContainer,
9759 getIcon: getIcon,
9760 getIconContent: getIconContent,
9761 getImage: getImage,
9762 getInputLabel: getInputLabel,
9763 getLoader: getLoader,
9764 getPopup: getPopup,
9765 getProgressSteps: getProgressSteps,
9766 getTimerLeft: getTimerLeft,
9767 getTimerProgressBar: getTimerProgressBar,
9768 getTitle: getTitle,
9769 getValidationMessage: getValidationMessage,
9770 increaseTimer: increaseTimer,
9771 isDeprecatedParameter: isDeprecatedParameter,
9772 isLoading: isLoading,
9773 isTimerRunning: isTimerRunning,
9774 isUpdatableParameter: isUpdatableParameter,
9775 isValidParameter: isValidParameter,
9776 isVisible: isVisible,
9777 mixin: mixin,
9778 off: off,
9779 on: on,
9780 once: once,
9781 resumeTimer: resumeTimer,
9782 showLoading: showLoading,
9783 stopTimer: stopTimer,
9784 toggleTimer: toggleTimer
9785 });
9786
9787 class Timer {
9788 /**
9789 * @param {() => void} callback
9790 * @param {number} delay
9791 */
9792 constructor(callback, delay) {
9793 this.callback = callback;
9794 this.remaining = delay;
9795 this.running = false;
9796 this.start();
9797 }
9798
9799 /**
9800 * @returns {number}
9801 */
9802 start() {
9803 if (!this.running) {
9804 this.running = true;
9805 this.started = new Date();
9806 this.id = setTimeout(this.callback, this.remaining);
9807 }
9808 return this.remaining;
9809 }
9810
9811 /**
9812 * @returns {number}
9813 */
9814 stop() {
9815 if (this.started && this.running) {
9816 this.running = false;
9817 clearTimeout(this.id);
9818 this.remaining -= new Date().getTime() - this.started.getTime();
9819 }
9820 return this.remaining;
9821 }
9822
9823 /**
9824 * @param {number} n
9825 * @returns {number}
9826 */
9827 increase(n) {
9828 const running = this.running;
9829 if (running) {
9830 this.stop();
9831 }
9832 this.remaining += n;
9833 if (running) {
9834 this.start();
9835 }
9836 return this.remaining;
9837 }
9838
9839 /**
9840 * @returns {number}
9841 */
9842 getTimerLeft() {
9843 if (this.running) {
9844 this.stop();
9845 this.start();
9846 }
9847 return this.remaining;
9848 }
9849
9850 /**
9851 * @returns {boolean}
9852 */
9853 isRunning() {
9854 return this.running;
9855 }
9856 }
9857
9858 const swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
9859
9860 /**
9861 * @param {SweetAlertOptions} params
9862 * @returns {SweetAlertOptions}
9863 */
9864 const getTemplateParams = params => {
9865 const template = typeof params.template === 'string' ? (/** @type {HTMLTemplateElement} */document.querySelector(params.template)) : params.template;
9866 if (!template) {
9867 return {};
9868 }
9869 /** @type {DocumentFragment} */
9870 const templateContent = template.content;
9871 showWarningsForElements(templateContent);
9872 const result = Object.assign(getSwalParams(templateContent), getSwalFunctionParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
9873 return result;
9874 };
9875
9876 /**
9877 * @param {DocumentFragment} templateContent
9878 * @returns {Record<string, string | boolean | number>}
9879 */
9880 const getSwalParams = templateContent => {
9881 /** @type {Record<string, string | boolean | number>} */
9882 const result = {};
9883 /** @type {HTMLElement[]} */
9884 const swalParams = Array.from(templateContent.querySelectorAll('swal-param'));
9885 swalParams.forEach(param => {
9886 showWarningsForAttributes(param, ['name', 'value']);
9887 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
9888 const value = param.getAttribute('value');
9889 if (!paramName || !value) {
9890 return;
9891 }
9892 if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'boolean') {
9893 result[paramName] = value !== 'false';
9894 } else if (paramName in defaultParams && typeof defaultParams[(/** @type {keyof typeof defaultParams} */paramName)] === 'object') {
9895 result[paramName] = JSON.parse(value);
9896 } else {
9897 result[paramName] = value;
9898 }
9899 });
9900 return result;
9901 };
9902
9903 /**
9904 * @param {DocumentFragment} templateContent
9905 * @returns {Record<string, () => void>}
9906 */
9907 const getSwalFunctionParams = templateContent => {
9908 /** @type {Record<string, () => void>} */
9909 const result = {};
9910 /** @type {HTMLElement[]} */
9911 const swalFunctions = Array.from(templateContent.querySelectorAll('swal-function-param'));
9912 swalFunctions.forEach(param => {
9913 const paramName = /** @type {keyof SweetAlertOptions} */param.getAttribute('name');
9914 const value = param.getAttribute('value');
9915 if (!paramName || !value) {
9916 return;
9917 }
9918 result[paramName] = new Function(`return ${value}`)();
9919 });
9920 return result;
9921 };
9922
9923 /**
9924 * @param {DocumentFragment} templateContent
9925 * @returns {Record<string, string | boolean>}
9926 */
9927 const getSwalButtons = templateContent => {
9928 /** @type {Record<string, string | boolean>} */
9929 const result = {};
9930 /** @type {HTMLElement[]} */
9931 const swalButtons = Array.from(templateContent.querySelectorAll('swal-button'));
9932 swalButtons.forEach(button => {
9933 showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
9934 const type = button.getAttribute('type');
9935 if (!type || !['confirm', 'cancel', 'deny'].includes(type)) {
9936 return;
9937 }
9938 result[`${type}ButtonText`] = button.innerHTML;
9939 result[`show${capitalizeFirstLetter(type)}Button`] = true;
9940 if (button.hasAttribute('color')) {
9941 const color = button.getAttribute('color');
9942 if (color !== null) {
9943 result[`${type}ButtonColor`] = color;
9944 }
9945 }
9946 if (button.hasAttribute('aria-label')) {
9947 const ariaLabel = button.getAttribute('aria-label');
9948 if (ariaLabel !== null) {
9949 result[`${type}ButtonAriaLabel`] = ariaLabel;
9950 }
9951 }
9952 });
9953 return result;
9954 };
9955
9956 /**
9957 * @param {DocumentFragment} templateContent
9958 * @returns {Pick<SweetAlertOptions, 'imageUrl' | 'imageWidth' | 'imageHeight' | 'imageAlt'>}
9959 */
9960 const getSwalImage = templateContent => {
9961 const result = {};
9962 /** @type {HTMLElement | null} */
9963 const image = templateContent.querySelector('swal-image');
9964 if (image) {
9965 showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
9966 if (image.hasAttribute('src')) {
9967 result.imageUrl = image.getAttribute('src') || undefined;
9968 }
9969 if (image.hasAttribute('width')) {
9970 result.imageWidth = image.getAttribute('width') || undefined;
9971 }
9972 if (image.hasAttribute('height')) {
9973 result.imageHeight = image.getAttribute('height') || undefined;
9974 }
9975 if (image.hasAttribute('alt')) {
9976 result.imageAlt = image.getAttribute('alt') || undefined;
9977 }
9978 }
9979 return result;
9980 };
9981
9982 /**
9983 * @param {DocumentFragment} templateContent
9984 * @returns {object}
9985 */
9986 const getSwalIcon = templateContent => {
9987 const result = {};
9988 /** @type {HTMLElement | null} */
9989 const icon = templateContent.querySelector('swal-icon');
9990 if (icon) {
9991 showWarningsForAttributes(icon, ['type', 'color']);
9992 if (icon.hasAttribute('type')) {
9993 result.icon = icon.getAttribute('type');
9994 }
9995 if (icon.hasAttribute('color')) {
9996 result.iconColor = icon.getAttribute('color');
9997 }
9998 result.iconHtml = icon.innerHTML;
9999 }
10000 return result;
10001 };
10002
10003 /**
10004 * @param {DocumentFragment} templateContent
10005 * @returns {object}
10006 */
10007 const getSwalInput = templateContent => {
10008 /** @type {Record<string, any>} */
10009 const result = {};
10010 /** @type {HTMLElement | null} */
10011 const input = templateContent.querySelector('swal-input');
10012 if (input) {
10013 showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
10014 result.input = input.getAttribute('type') || 'text';
10015 if (input.hasAttribute('label')) {
10016 result.inputLabel = input.getAttribute('label');
10017 }
10018 if (input.hasAttribute('placeholder')) {
10019 result.inputPlaceholder = input.getAttribute('placeholder');
10020 }
10021 if (input.hasAttribute('value')) {
10022 result.inputValue = input.getAttribute('value');
10023 }
10024 }
10025 /** @type {HTMLElement[]} */
10026 const inputOptions = Array.from(templateContent.querySelectorAll('swal-input-option'));
10027 if (inputOptions.length) {
10028 result.inputOptions = {};
10029 inputOptions.forEach(option => {
10030 showWarningsForAttributes(option, ['value']);
10031 const optionValue = option.getAttribute('value');
10032 if (!optionValue) {
10033 return;
10034 }
10035 const optionName = option.innerHTML;
10036 result.inputOptions[optionValue] = optionName;
10037 });
10038 }
10039 return result;
10040 };
10041
10042 /**
10043 * @param {DocumentFragment} templateContent
10044 * @param {string[]} paramNames
10045 * @returns {Record<string, string>}
10046 */
10047 const getSwalStringParams = (templateContent, paramNames) => {
10048 /** @type {Record<string, string>} */
10049 const result = {};
10050 for (const i in paramNames) {
10051 const paramName = paramNames[i];
10052 /** @type {HTMLElement | null} */
10053 const tag = templateContent.querySelector(paramName);
10054 if (tag) {
10055 showWarningsForAttributes(tag, []);
10056 result[paramName.replace(/^swal-/, '')] = tag.innerHTML.trim();
10057 }
10058 }
10059 return result;
10060 };
10061
10062 /**
10063 * @param {DocumentFragment} templateContent
10064 */
10065 const showWarningsForElements = templateContent => {
10066 const allowedElements = swalStringParams.concat(['swal-param', 'swal-function-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
10067 Array.from(templateContent.children).forEach(el => {
10068 const tagName = el.tagName.toLowerCase();
10069 if (!allowedElements.includes(tagName)) {
10070 warn(`Unrecognized element <${tagName}>`);
10071 }
10072 });
10073 };
10074
10075 /**
10076 * @param {HTMLElement} el
10077 * @param {string[]} allowedAttributes
10078 */
10079 const showWarningsForAttributes = (el, allowedAttributes) => {
10080 Array.from(el.attributes).forEach(attribute => {
10081 if (allowedAttributes.indexOf(attribute.name) === -1) {
10082 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.'}`]);
10083 }
10084 });
10085 };
10086
10087 const SHOW_CLASS_TIMEOUT = 10;
10088
10089 /**
10090 * Open popup, add necessary classes and styles, fix scrollbar
10091 *
10092 * @param {SweetAlertOptions} params
10093 */
10094 const openPopup = params => {
10095 var _globalState$eventEmi, _globalState$eventEmi2;
10096 const container = getContainer();
10097 const popup = getPopup();
10098 if (!container || !popup) {
10099 return;
10100 }
10101 if (typeof params.willOpen === 'function') {
10102 params.willOpen(popup);
10103 }
10104 (_globalState$eventEmi = globalState.eventEmitter) === null || _globalState$eventEmi === void 0 || _globalState$eventEmi.emit('willOpen', popup);
10105 const bodyStyles = window.getComputedStyle(document.body);
10106 const initialBodyOverflow = bodyStyles.overflowY;
10107 addClasses(container, popup, params);
10108
10109 // scrolling is 'hidden' until animation is done, after that 'auto'
10110 setTimeout(() => {
10111 setScrollingVisibility(container, popup);
10112 }, SHOW_CLASS_TIMEOUT);
10113 if (isModal()) {
10114 // Using ternary instead of ?? operator for Webpack 4 compatibility
10115 fixScrollContainer(container, params.scrollbarPadding !== undefined ? params.scrollbarPadding : false, initialBodyOverflow);
10116 setAriaHidden();
10117 }
10118 if (!isToast() && !globalState.previousActiveElement) {
10119 globalState.previousActiveElement = document.activeElement;
10120 }
10121 if (typeof params.didOpen === 'function') {
10122 const didOpen = params.didOpen;
10123 setTimeout(() => didOpen(popup));
10124 }
10125 (_globalState$eventEmi2 = globalState.eventEmitter) === null || _globalState$eventEmi2 === void 0 || _globalState$eventEmi2.emit('didOpen', popup);
10126 };
10127
10128 /**
10129 * @param {Event} event
10130 */
10131 const swalOpenAnimationFinished = event => {
10132 const popup = getPopup();
10133 if (!popup || event.target !== popup) {
10134 return;
10135 }
10136 const container = getContainer();
10137 if (!container) {
10138 return;
10139 }
10140 popup.removeEventListener('animationend', swalOpenAnimationFinished);
10141 popup.removeEventListener('transitionend', swalOpenAnimationFinished);
10142 container.style.overflowY = 'auto';
10143
10144 // no-transition is added in init() in case one swal is opened right after another
10145 removeClass(container, swalClasses['no-transition']);
10146 };
10147
10148 /**
10149 * @param {HTMLElement} container
10150 * @param {HTMLElement} popup
10151 */
10152 const setScrollingVisibility = (container, popup) => {
10153 if (hasCssAnimation(popup)) {
10154 container.style.overflowY = 'hidden';
10155 popup.addEventListener('animationend', swalOpenAnimationFinished);
10156 popup.addEventListener('transitionend', swalOpenAnimationFinished);
10157 } else {
10158 container.style.overflowY = 'auto';
10159 }
10160 };
10161
10162 /**
10163 * @param {HTMLElement} container
10164 * @param {boolean} scrollbarPadding
10165 * @param {string} initialBodyOverflow
10166 */
10167 const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) => {
10168 iOSfix();
10169 if (scrollbarPadding && initialBodyOverflow !== 'hidden') {
10170 replaceScrollbarWithPadding(initialBodyOverflow);
10171 }
10172
10173 // sweetalert2/issues/1247
10174 setTimeout(() => {
10175 container.scrollTop = 0;
10176 });
10177 };
10178
10179 /**
10180 * @param {HTMLElement} container
10181 * @param {HTMLElement} popup
10182 * @param {SweetAlertOptions} params
10183 */
10184 const addClasses = (container, popup, params) => {
10185 var _params$showClass;
10186 if ((_params$showClass = params.showClass) !== null && _params$showClass !== void 0 && _params$showClass.backdrop) {
10187 addClass(container, params.showClass.backdrop);
10188 }
10189 if (params.animation) {
10190 // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
10191 popup.style.setProperty('opacity', '0', 'important');
10192 show(popup, 'grid');
10193 setTimeout(() => {
10194 var _params$showClass2;
10195 // Animate popup right after showing it
10196 if ((_params$showClass2 = params.showClass) !== null && _params$showClass2 !== void 0 && _params$showClass2.popup) {
10197 addClass(popup, params.showClass.popup);
10198 }
10199 // and remove the opacity workaround
10200 popup.style.removeProperty('opacity');
10201 }, SHOW_CLASS_TIMEOUT); // 10ms in order to fix #2062
10202 } else {
10203 show(popup, 'grid');
10204 }
10205 addClass([document.documentElement, document.body], swalClasses.shown);
10206 if (params.heightAuto && params.backdrop && !params.toast) {
10207 addClass([document.documentElement, document.body], swalClasses['height-auto']);
10208 }
10209 };
10210
10211 var defaultInputValidators = {
10212 /**
10213 * @param {string} string
10214 * @param {string} [validationMessage]
10215 * @returns {Promise<string | void>}
10216 */
10217 email: (string, validationMessage) => {
10218 return /^[a-zA-Z0-9.+_'-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9-]+$/.test(string) ? Promise.resolve() : Promise.resolve(validationMessage || 'Invalid email address');
10219 },
10220 /**
10221 * @param {string} string
10222 * @param {string} [validationMessage]
10223 * @returns {Promise<string | void>}
10224 */
10225 url: (string, validationMessage) => {
10226 // taken from https://stackoverflow.com/a/3809435 with a small change from #1306 and #2013
10227 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');
10228 }
10229 };
10230
10231 /**
10232 * @param {SweetAlertOptions} params
10233 */
10234 function setDefaultInputValidators(params) {
10235 // Use default `inputValidator` for supported input types if not provided
10236 if (params.inputValidator) {
10237 return;
10238 }
10239 if (params.input === 'email') {
10240 params.inputValidator = defaultInputValidators['email'];
10241 }
10242 if (params.input === 'url') {
10243 params.inputValidator = defaultInputValidators['url'];
10244 }
10245 }
10246
10247 /**
10248 * @param {SweetAlertOptions} params
10249 */
10250 function validateCustomTargetElement(params) {
10251 // Determine if the custom target element is valid
10252 if (!params.target || typeof params.target === 'string' && !document.querySelector(params.target) || typeof params.target !== 'string' && !params.target.appendChild) {
10253 warn('Target parameter is not valid, defaulting to "body"');
10254 params.target = 'body';
10255 }
10256 }
10257
10258 /**
10259 * Set type, text and actions on popup
10260 *
10261 * @param {SweetAlertOptions} params
10262 */
10263 function setParameters(params) {
10264 setDefaultInputValidators(params);
10265
10266 // showLoaderOnConfirm && preConfirm
10267 if (params.showLoaderOnConfirm && !params.preConfirm) {
10268 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');
10269 }
10270 validateCustomTargetElement(params);
10271
10272 // Replace newlines with <br> in title
10273 if (typeof params.title === 'string') {
10274 params.title = params.title.split('\n').join('<br />');
10275 }
10276 init(params);
10277 }
10278
10279 /** @type {SweetAlert} */
10280 let currentInstance;
10281 var _promise = /*#__PURE__*/new WeakMap();
10282 class SweetAlert {
10283 /**
10284 * @param {...(SweetAlertOptions | string)} args
10285 * @this {SweetAlert}
10286 */
10287 constructor(...args) {
10288 /**
10289 * @type {Promise<SweetAlertResult>}
10290 */
10291 _classPrivateFieldInitSpec(this, _promise, /** @type {Promise<SweetAlertResult>} */Promise.resolve({
10292 isConfirmed: false,
10293 isDenied: false,
10294 isDismissed: true
10295 }));
10296 // Prevent run in Node env
10297 if (typeof window === 'undefined') {
10298 return;
10299 }
10300 currentInstance = this;
10301
10302 // @ts-ignore
10303 const outerParams = Object.freeze(this.constructor.argsToParams(args));
10304
10305 /** @type {Readonly<SweetAlertOptions>} */
10306 this.params = outerParams;
10307
10308 /** @type {boolean} */
10309 this.isAwaitingPromise = false;
10310 _classPrivateFieldSet2(_promise, this, this._main(currentInstance.params));
10311 }
10312
10313 /**
10314 * @param {any} userParams
10315 * @param {any} mixinParams
10316 */
10317 _main(userParams, mixinParams = {}) {
10318 showWarningsForParams(Object.assign({}, mixinParams, userParams));
10319 if (globalState.currentInstance) {
10320 const swalPromiseResolve = privateMethods.swalPromiseResolve.get(globalState.currentInstance);
10321 const {
10322 isAwaitingPromise
10323 } = globalState.currentInstance;
10324 globalState.currentInstance._destroy();
10325 if (!isAwaitingPromise) {
10326 swalPromiseResolve({
10327 isDismissed: true
10328 });
10329 }
10330 if (isModal()) {
10331 unsetAriaHidden();
10332 }
10333 }
10334 globalState.currentInstance = currentInstance;
10335 const innerParams = prepareParams(userParams, mixinParams);
10336 setParameters(innerParams);
10337 Object.freeze(innerParams);
10338
10339 // clear the previous timer
10340 if (globalState.timeout) {
10341 globalState.timeout.stop();
10342 delete globalState.timeout;
10343 }
10344
10345 // clear the restore focus timeout
10346 clearTimeout(globalState.restoreFocusTimeout);
10347 const domCache = populateDomCache(currentInstance);
10348 render(currentInstance, innerParams);
10349 privateProps.innerParams.set(currentInstance, innerParams);
10350 return swalPromise(currentInstance, domCache, innerParams);
10351 }
10352
10353 // `catch` cannot be the name of a module export, so we define our thenable methods here instead
10354 /**
10355 * @param {any} onFulfilled
10356 */
10357 then(onFulfilled) {
10358 return _classPrivateFieldGet2(_promise, this).then(onFulfilled);
10359 }
10360
10361 /**
10362 * @param {any} onFinally
10363 */
10364 finally(onFinally) {
10365 return _classPrivateFieldGet2(_promise, this).finally(onFinally);
10366 }
10367 }
10368
10369 /**
10370 * @param {SweetAlert} instance
10371 * @param {DomCache} domCache
10372 * @param {SweetAlertOptions} innerParams
10373 * @returns {Promise<SweetAlertResult>}
10374 */
10375 const swalPromise = (instance, domCache, innerParams) => {
10376 return new Promise((resolve, reject) => {
10377 // functions to handle all closings/dismissals
10378 /**
10379 * @param {DismissReason} dismiss
10380 */
10381 const dismissWith = dismiss => {
10382 instance.close({
10383 isDismissed: true,
10384 dismiss,
10385 isConfirmed: false,
10386 isDenied: false
10387 });
10388 };
10389 privateMethods.swalPromiseResolve.set(instance, resolve);
10390 privateMethods.swalPromiseReject.set(instance, reject);
10391 domCache.confirmButton.onclick = () => {
10392 handleConfirmButtonClick(instance);
10393 };
10394 domCache.denyButton.onclick = () => {
10395 handleDenyButtonClick(instance);
10396 };
10397 domCache.cancelButton.onclick = () => {
10398 handleCancelButtonClick(instance, dismissWith);
10399 };
10400 domCache.closeButton.onclick = () => {
10401 dismissWith(DismissReason.close);
10402 };
10403 handlePopupClick(innerParams, domCache, dismissWith);
10404 addKeydownHandler(globalState, innerParams, dismissWith);
10405 handleInputOptionsAndValue(instance, innerParams);
10406 openPopup(innerParams);
10407 setupTimer(globalState, innerParams, dismissWith);
10408 initFocus(domCache, innerParams);
10409
10410 // Scroll container to top on open (#1247, #1946)
10411 setTimeout(() => {
10412 domCache.container.scrollTop = 0;
10413 });
10414 });
10415 };
10416
10417 /**
10418 * @param {SweetAlertOptions} userParams
10419 * @param {SweetAlertOptions} mixinParams
10420 * @returns {SweetAlertOptions}
10421 */
10422 const prepareParams = (userParams, mixinParams) => {
10423 const templateParams = getTemplateParams(userParams);
10424 const params = Object.assign({}, defaultParams, mixinParams, templateParams, userParams); // precedence is described in #2131
10425 params.showClass = Object.assign({}, defaultParams.showClass, params.showClass);
10426 params.hideClass = Object.assign({}, defaultParams.hideClass, params.hideClass);
10427 if (params.animation === false) {
10428 params.showClass = {
10429 backdrop: 'swal2-noanimation'
10430 };
10431 params.hideClass = {};
10432 }
10433 return params;
10434 };
10435
10436 /**
10437 * @param {SweetAlert} instance
10438 * @returns {DomCache}
10439 */
10440 const populateDomCache = instance => {
10441 const domCache = /** @type {DomCache} */{
10442 popup: (/** @type {HTMLElement} */getPopup()),
10443 container: (/** @type {HTMLElement} */getContainer()),
10444 actions: (/** @type {HTMLElement} */getActions()),
10445 confirmButton: (/** @type {HTMLElement} */getConfirmButton()),
10446 denyButton: (/** @type {HTMLElement} */getDenyButton()),
10447 cancelButton: (/** @type {HTMLElement} */getCancelButton()),
10448 loader: (/** @type {HTMLElement} */getLoader()),
10449 closeButton: (/** @type {HTMLElement} */getCloseButton()),
10450 validationMessage: (/** @type {HTMLElement} */getValidationMessage()),
10451 progressSteps: (/** @type {HTMLElement} */getProgressSteps())
10452 };
10453 privateProps.domCache.set(instance, domCache);
10454 return domCache;
10455 };
10456
10457 /**
10458 * @param {GlobalState} globalState
10459 * @param {SweetAlertOptions} innerParams
10460 * @param {(dismiss: DismissReason) => void} dismissWith
10461 */
10462 const setupTimer = (globalState, innerParams, dismissWith) => {
10463 const timerProgressBar = getTimerProgressBar();
10464 hide(timerProgressBar);
10465 if (innerParams.timer) {
10466 globalState.timeout = new Timer(() => {
10467 dismissWith('timer');
10468 delete globalState.timeout;
10469 }, innerParams.timer);
10470 if (innerParams.timerProgressBar && timerProgressBar) {
10471 show(timerProgressBar);
10472 applyCustomClass(timerProgressBar, innerParams, 'timerProgressBar');
10473 setTimeout(() => {
10474 if (globalState.timeout && globalState.timeout.running) {
10475 // timer can be already stopped or unset at this point
10476 animateTimerProgressBar(/** @type {number} */innerParams.timer);
10477 }
10478 });
10479 }
10480 }
10481 };
10482
10483 /**
10484 * Initialize focus in the popup:
10485 *
10486 * 1. If `toast` is `true`, don't steal focus from the document.
10487 * 2. Else if there is an [autofocus] element, focus it.
10488 * 3. Else if `focusConfirm` is `true` and confirm button is visible, focus it.
10489 * 4. Else if `focusDeny` is `true` and deny button is visible, focus it.
10490 * 5. Else if `focusCancel` is `true` and cancel button is visible, focus it.
10491 * 6. Else focus the first focusable element in a popup (if any).
10492 *
10493 * @param {DomCache} domCache
10494 * @param {SweetAlertOptions} innerParams
10495 */
10496 const initFocus = (domCache, innerParams) => {
10497 if (innerParams.toast) {
10498 return;
10499 }
10500 // TODO: this is dumb, remove `allowEnterKey` param in the next major version
10501 if (!callIfFunction(innerParams.allowEnterKey)) {
10502 warnAboutDeprecation('allowEnterKey');
10503 blurActiveElement();
10504 return;
10505 }
10506 if (focusAutofocus(domCache)) {
10507 return;
10508 }
10509 if (focusButton(domCache, innerParams)) {
10510 return;
10511 }
10512 setFocus(-1, 1);
10513 };
10514
10515 /**
10516 * @param {DomCache} domCache
10517 * @returns {boolean}
10518 */
10519 const focusAutofocus = domCache => {
10520 const autofocusElements = Array.from(domCache.popup.querySelectorAll('[autofocus]'));
10521 for (const autofocusElement of autofocusElements) {
10522 if (autofocusElement instanceof HTMLElement && isVisible$1(autofocusElement)) {
10523 autofocusElement.focus();
10524 return true;
10525 }
10526 }
10527 return false;
10528 };
10529
10530 /**
10531 * @param {DomCache} domCache
10532 * @param {SweetAlertOptions} innerParams
10533 * @returns {boolean}
10534 */
10535 const focusButton = (domCache, innerParams) => {
10536 if (innerParams.focusDeny && isVisible$1(domCache.denyButton)) {
10537 domCache.denyButton.focus();
10538 return true;
10539 }
10540 if (innerParams.focusCancel && isVisible$1(domCache.cancelButton)) {
10541 domCache.cancelButton.focus();
10542 return true;
10543 }
10544 if (innerParams.focusConfirm && isVisible$1(domCache.confirmButton)) {
10545 domCache.confirmButton.focus();
10546 return true;
10547 }
10548 return false;
10549 };
10550 const blurActiveElement = () => {
10551 if (document.activeElement instanceof HTMLElement && typeof document.activeElement.blur === 'function') {
10552 document.activeElement.blur();
10553 }
10554 };
10555
10556 // Assign instance methods from src/instanceMethods/*.js to prototype
10557 SweetAlert.prototype.disableButtons = disableButtons;
10558 SweetAlert.prototype.enableButtons = enableButtons;
10559 SweetAlert.prototype.getInput = getInput;
10560 SweetAlert.prototype.disableInput = disableInput;
10561 SweetAlert.prototype.enableInput = enableInput;
10562 SweetAlert.prototype.hideLoading = hideLoading;
10563 SweetAlert.prototype.disableLoading = hideLoading;
10564 SweetAlert.prototype.showValidationMessage = showValidationMessage;
10565 SweetAlert.prototype.resetValidationMessage = resetValidationMessage;
10566 SweetAlert.prototype.close = close;
10567 SweetAlert.prototype.closePopup = close;
10568 SweetAlert.prototype.closeModal = close;
10569 SweetAlert.prototype.closeToast = close;
10570 SweetAlert.prototype.rejectPromise = rejectPromise;
10571 SweetAlert.prototype.update = update;
10572 SweetAlert.prototype._destroy = _destroy;
10573
10574 // Assign static methods from src/staticMethods/*.js to constructor
10575 Object.assign(SweetAlert, staticMethods);
10576
10577 // Proxy to instance methods to constructor, for now, for backwards compatibility
10578 Object.keys(instanceMethods).forEach(key => {
10579 /**
10580 * @param {...(SweetAlertOptions | string | undefined)} args
10581 * @returns {SweetAlertResult | Promise<SweetAlertResult> | undefined}
10582 */
10583 // @ts-ignore: Dynamic property assignment for backwards compatibility
10584 SweetAlert[key] = function (...args) {
10585 // @ts-ignore
10586 if (currentInstance && currentInstance[key]) {
10587 // @ts-ignore
10588 return currentInstance[key](...args);
10589 }
10590 return undefined;
10591 };
10592 });
10593 SweetAlert.DismissReason = DismissReason;
10594 SweetAlert.version = '11.26.17';
10595
10596 const Swal = SweetAlert;
10597 // @ts-ignore
10598 Swal.default = Swal;
10599
10600 return Swal;
10601
10602 }));
10603 if (typeof this !== 'undefined' && this.Sweetalert2){this.swal = this.sweetAlert = this.Swal = this.SweetAlert = this.Sweetalert2}
10604 "undefined"!=typeof document&&function(e,t){var n=e.createElement("style");if(e.getElementsByTagName("head")[0].appendChild(n),n.styleSheet)n.styleSheet.disabled||(n.styleSheet.cssText=t);else try{n.innerHTML=t}catch(e){n.innerText=t}}(document,":root{--swal2-outline: 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-container-padding: 0.625em;--swal2-backdrop: rgba(0, 0, 0, 0.4);--swal2-backdrop-transition: background-color 0.15s;--swal2-width: 32em;--swal2-padding: 0 0 1.25em;--swal2-border: none;--swal2-border-radius: 0.3125rem;--swal2-background: white;--swal2-color: #545454;--swal2-show-animation: swal2-show 0.3s;--swal2-hide-animation: swal2-hide 0.15s forwards;--swal2-icon-zoom: 1;--swal2-icon-animations: true;--swal2-title-padding: 0.8em 1em 0;--swal2-html-container-padding: 1em 1.6em 0.3em;--swal2-input-border: 1px solid #d9d9d9;--swal2-input-border-radius: 0.1875em;--swal2-input-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-background: transparent;--swal2-input-transition: border-color 0.2s, box-shadow 0.2s;--swal2-input-hover-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px transparent;--swal2-input-focus-border: 1px solid #b4dbed;--swal2-input-focus-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.06), 0 0 0 3px rgba(100, 150, 200, 0.5);--swal2-progress-step-background: #add8e6;--swal2-validation-message-background: #f0f0f0;--swal2-validation-message-color: #666;--swal2-footer-border-color: #eee;--swal2-footer-background: transparent;--swal2-footer-color: inherit;--swal2-timer-progress-bar-background: rgba(0, 0, 0, 0.3);--swal2-close-button-position: initial;--swal2-close-button-inset: auto;--swal2-close-button-font-size: 2.5em;--swal2-close-button-color: #ccc;--swal2-close-button-transition: color 0.2s, box-shadow 0.2s;--swal2-close-button-outline: initial;--swal2-close-button-box-shadow: inset 0 0 0 3px transparent;--swal2-close-button-focus-box-shadow: inset var(--swal2-outline);--swal2-close-button-hover-transform: none;--swal2-actions-justify-content: center;--swal2-actions-width: auto;--swal2-actions-margin: 1.25em auto 0;--swal2-actions-padding: 0;--swal2-actions-border-radius: 0;--swal2-actions-background: transparent;--swal2-action-button-transition: background-color 0.2s, box-shadow 0.2s;--swal2-action-button-hover: black 10%;--swal2-action-button-active: black 10%;--swal2-confirm-button-box-shadow: none;--swal2-confirm-button-border-radius: 0.25em;--swal2-confirm-button-background-color: #7066e0;--swal2-confirm-button-color: #fff;--swal2-deny-button-box-shadow: none;--swal2-deny-button-border-radius: 0.25em;--swal2-deny-button-background-color: #dc3741;--swal2-deny-button-color: #fff;--swal2-cancel-button-box-shadow: none;--swal2-cancel-button-border-radius: 0.25em;--swal2-cancel-button-background-color: #6e7881;--swal2-cancel-button-color: #fff;--swal2-toast-show-animation: swal2-toast-show 0.5s;--swal2-toast-hide-animation: swal2-toast-hide 0.1s forwards;--swal2-toast-border: none;--swal2-toast-box-shadow: 0 0 1px hsl(0deg 0% 0% / 0.075), 0 1px 2px hsl(0deg 0% 0% / 0.075), 1px 2px 4px hsl(0deg 0% 0% / 0.075), 1px 3px 8px hsl(0deg 0% 0% / 0.075), 2px 4px 16px hsl(0deg 0% 0% / 0.075)}[data-swal2-theme=dark]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}@media(prefers-color-scheme: dark){[data-swal2-theme=auto]{--swal2-dark-theme-black: #19191a;--swal2-dark-theme-white: #e1e1e1;--swal2-background: var(--swal2-dark-theme-black);--swal2-color: var(--swal2-dark-theme-white);--swal2-footer-border-color: #555;--swal2-input-background: color-mix(in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10%);--swal2-validation-message-background: color-mix( in srgb, var(--swal2-dark-theme-black), var(--swal2-dark-theme-white) 10% );--swal2-validation-message-color: var(--swal2-dark-theme-white);--swal2-timer-progress-bar-background: rgba(255, 255, 255, 0.7)}}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow:hidden}body.swal2-height-auto{height:auto !important}body.swal2-no-backdrop .swal2-container{background-color:rgba(0,0,0,0) !important;pointer-events:none}body.swal2-no-backdrop .swal2-container .swal2-popup{pointer-events:all}body.swal2-no-backdrop .swal2-container .swal2-modal{box-shadow:0 0 10px var(--swal2-backdrop)}body.swal2-toast-shown .swal2-container{box-sizing:border-box;width:360px;max-width:100%;background-color:rgba(0,0,0,0);pointer-events:none}body.swal2-toast-shown .swal2-container.swal2-top{inset:0 auto auto 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-top-end,body.swal2-toast-shown .swal2-container.swal2-top-right{inset:0 0 auto auto}body.swal2-toast-shown .swal2-container.swal2-top-start,body.swal2-toast-shown .swal2-container.swal2-top-left{inset:0 auto auto 0}body.swal2-toast-shown .swal2-container.swal2-center-start,body.swal2-toast-shown .swal2-container.swal2-center-left{inset:50% auto auto 0;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-center{inset:50% auto auto 50%;transform:translate(-50%, -50%)}body.swal2-toast-shown .swal2-container.swal2-center-end,body.swal2-toast-shown .swal2-container.swal2-center-right{inset:50% 0 auto auto;transform:translateY(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-start,body.swal2-toast-shown .swal2-container.swal2-bottom-left{inset:auto auto 0 0}body.swal2-toast-shown .swal2-container.swal2-bottom{inset:auto auto 0 50%;transform:translateX(-50%)}body.swal2-toast-shown .swal2-container.swal2-bottom-end,body.swal2-toast-shown .swal2-container.swal2-bottom-right{inset:auto 0 0 auto}@media print{body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown){overflow-y:scroll !important}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown)>[aria-hidden=true]{display:none}body.swal2-shown:not(.swal2-no-backdrop,.swal2-toast-shown) .swal2-container{position:static !important}}div:where(.swal2-container){display:grid;position:fixed;z-index:1060;inset:0;box-sizing:border-box;grid-template-areas:\"top-start top top-end\" \"center-start center center-end\" \"bottom-start bottom-center bottom-end\";grid-template-rows:minmax(min-content, auto) minmax(min-content, auto) minmax(min-content, auto);height:100%;padding:var(--swal2-container-padding);overflow-x:hidden;transition:var(--swal2-backdrop-transition);-webkit-overflow-scrolling:touch}div:where(.swal2-container).swal2-backdrop-show,div:where(.swal2-container).swal2-noanimation{background:var(--swal2-backdrop)}div:where(.swal2-container).swal2-backdrop-hide{background:rgba(0,0,0,0) !important}div:where(.swal2-container).swal2-top-start,div:where(.swal2-container).swal2-center-start,div:where(.swal2-container).swal2-bottom-start{grid-template-columns:minmax(0, 1fr) auto auto}div:where(.swal2-container).swal2-top,div:where(.swal2-container).swal2-center,div:where(.swal2-container).swal2-bottom{grid-template-columns:auto minmax(0, 1fr) auto}div:where(.swal2-container).swal2-top-end,div:where(.swal2-container).swal2-center-end,div:where(.swal2-container).swal2-bottom-end{grid-template-columns:auto auto minmax(0, 1fr)}div:where(.swal2-container).swal2-top-start>.swal2-popup{align-self:start}div:where(.swal2-container).swal2-top>.swal2-popup{grid-column:2;place-self:start center}div:where(.swal2-container).swal2-top-end>.swal2-popup,div:where(.swal2-container).swal2-top-right>.swal2-popup{grid-column:3;place-self:start end}div:where(.swal2-container).swal2-center-start>.swal2-popup,div:where(.swal2-container).swal2-center-left>.swal2-popup{grid-row:2;align-self:center}div:where(.swal2-container).swal2-center>.swal2-popup{grid-column:2;grid-row:2;place-self:center center}div:where(.swal2-container).swal2-center-end>.swal2-popup,div:where(.swal2-container).swal2-center-right>.swal2-popup{grid-column:3;grid-row:2;place-self:center end}div:where(.swal2-container).swal2-bottom-start>.swal2-popup,div:where(.swal2-container).swal2-bottom-left>.swal2-popup{grid-column:1;grid-row:3;align-self:end}div:where(.swal2-container).swal2-bottom>.swal2-popup{grid-column:2;grid-row:3;place-self:end center}div:where(.swal2-container).swal2-bottom-end>.swal2-popup,div:where(.swal2-container).swal2-bottom-right>.swal2-popup{grid-column:3;grid-row:3;place-self:end end}div:where(.swal2-container).swal2-grow-row>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-column:1/4;width:100%}div:where(.swal2-container).swal2-grow-column>.swal2-popup,div:where(.swal2-container).swal2-grow-fullscreen>.swal2-popup{grid-row:1/4;align-self:stretch}div:where(.swal2-container).swal2-no-transition{transition:none !important}div:where(.swal2-container)[popover]{width:auto;border:0}div:where(.swal2-container) div:where(.swal2-popup){display:none;position:relative;box-sizing:border-box;grid-template-columns:minmax(0, 100%);width:var(--swal2-width);max-width:100%;padding:var(--swal2-padding);border:var(--swal2-border);border-radius:var(--swal2-border-radius);background:var(--swal2-background);color:var(--swal2-color);font-family:inherit;font-size:1rem;container-name:swal2-popup}div:where(.swal2-container) div:where(.swal2-popup):focus{outline:none}div:where(.swal2-container) div:where(.swal2-popup).swal2-loading{overflow-y:hidden}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable{cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-draggable div:where(.swal2-icon){cursor:grab}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging{cursor:grabbing}div:where(.swal2-container) div:where(.swal2-popup).swal2-dragging div:where(.swal2-icon){cursor:grabbing}div:where(.swal2-container) h2:where(.swal2-title){position:relative;max-width:100%;margin:0;padding:var(--swal2-title-padding);color:inherit;font-size:1.875em;font-weight:600;text-align:center;text-transform:none;overflow-wrap:break-word;cursor:initial}div:where(.swal2-container) div:where(.swal2-actions){display:flex;z-index:1;box-sizing:border-box;flex-wrap:wrap;align-items:center;justify-content:var(--swal2-actions-justify-content);width:var(--swal2-actions-width);margin:var(--swal2-actions-margin);padding:var(--swal2-actions-padding);border-radius:var(--swal2-actions-border-radius);background:var(--swal2-actions-background)}div:where(.swal2-container) div:where(.swal2-loader){display:none;align-items:center;justify-content:center;width:2.2em;height:2.2em;margin:0 1.875em;animation:swal2-rotate-loading 1.5s linear 0s infinite normal;border-width:.25em;border-style:solid;border-radius:100%;border-color:#2778c4 rgba(0,0,0,0) #2778c4 rgba(0,0,0,0)}div:where(.swal2-container) button:where(.swal2-styled){margin:.3125em;padding:.625em 1.1em;transition:var(--swal2-action-button-transition);border:none;box-shadow:0 0 0 3px rgba(0,0,0,0);font-weight:500}div:where(.swal2-container) button:where(.swal2-styled):not([disabled]){cursor:pointer}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm){border-radius:var(--swal2-confirm-button-border-radius);background:initial;background-color:var(--swal2-confirm-button-background-color);box-shadow:var(--swal2-confirm-button-box-shadow);color:var(--swal2-confirm-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):hover{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-confirm):active{background-color:color-mix(in srgb, var(--swal2-confirm-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny){border-radius:var(--swal2-deny-button-border-radius);background:initial;background-color:var(--swal2-deny-button-background-color);box-shadow:var(--swal2-deny-button-box-shadow);color:var(--swal2-deny-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):hover{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-deny):active{background-color:color-mix(in srgb, var(--swal2-deny-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel){border-radius:var(--swal2-cancel-button-border-radius);background:initial;background-color:var(--swal2-cancel-button-background-color);box-shadow:var(--swal2-cancel-button-box-shadow);color:var(--swal2-cancel-button-color);font-size:1em}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):hover{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-hover))}div:where(.swal2-container) button:where(.swal2-styled):where(.swal2-cancel):active{background-color:color-mix(in srgb, var(--swal2-cancel-button-background-color), var(--swal2-action-button-active))}div:where(.swal2-container) button:where(.swal2-styled):focus-visible{outline:none;box-shadow:var(--swal2-action-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-styled)[disabled]:not(.swal2-loading){opacity:.4}div:where(.swal2-container) button:where(.swal2-styled)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-footer){margin:1em 0 0;padding:1em 1em 0;border-top:1px solid var(--swal2-footer-border-color);background:var(--swal2-footer-background);color:var(--swal2-footer-color);font-size:1em;text-align:center;cursor:initial}div:where(.swal2-container) .swal2-timer-progress-bar-container{position:absolute;right:0;bottom:0;left:0;grid-column:auto !important;overflow:hidden;border-bottom-right-radius:var(--swal2-border-radius);border-bottom-left-radius:var(--swal2-border-radius)}div:where(.swal2-container) div:where(.swal2-timer-progress-bar){width:100%;height:.25em;background:var(--swal2-timer-progress-bar-background)}div:where(.swal2-container) img:where(.swal2-image){max-width:100%;margin:2em auto 1em;cursor:initial}div:where(.swal2-container) button:where(.swal2-close){position:var(--swal2-close-button-position);inset:var(--swal2-close-button-inset);z-index:2;align-items:center;justify-content:center;width:1.2em;height:1.2em;margin-top:0;margin-right:0;margin-bottom:-1.2em;padding:0;overflow:hidden;transition:var(--swal2-close-button-transition);border:none;border-radius:var(--swal2-border-radius);outline:var(--swal2-close-button-outline);background:rgba(0,0,0,0);color:var(--swal2-close-button-color);font-family:monospace;font-size:var(--swal2-close-button-font-size);cursor:pointer;justify-self:end}div:where(.swal2-container) button:where(.swal2-close):hover{transform:var(--swal2-close-button-hover-transform);background:rgba(0,0,0,0);color:#f27474}div:where(.swal2-container) button:where(.swal2-close):focus-visible{outline:none;box-shadow:var(--swal2-close-button-focus-box-shadow)}div:where(.swal2-container) button:where(.swal2-close)::-moz-focus-inner{border:0}div:where(.swal2-container) div:where(.swal2-html-container){z-index:1;justify-content:center;margin:0;padding:var(--swal2-html-container-padding);overflow:auto;color:inherit;font-size:1.125em;font-weight:normal;line-height:normal;text-align:center;overflow-wrap:break-word;word-break:break-word;cursor:initial}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea),div:where(.swal2-container) select:where(.swal2-select),div:where(.swal2-container) div:where(.swal2-radio),div:where(.swal2-container) label:where(.swal2-checkbox){margin:1em 2em 3px}div:where(.swal2-container) input:where(.swal2-input),div:where(.swal2-container) input:where(.swal2-file),div:where(.swal2-container) textarea:where(.swal2-textarea){box-sizing:border-box;width:auto;transition:var(--swal2-input-transition);border:var(--swal2-input-border);border-radius:var(--swal2-input-border-radius);background:var(--swal2-input-background);box-shadow:var(--swal2-input-box-shadow);color:inherit;font-size:1.125em}div:where(.swal2-container) input:where(.swal2-input).swal2-inputerror,div:where(.swal2-container) input:where(.swal2-file).swal2-inputerror,div:where(.swal2-container) textarea:where(.swal2-textarea).swal2-inputerror{border-color:#f27474 !important;box-shadow:0 0 2px #f27474 !important}div:where(.swal2-container) input:where(.swal2-input):hover,div:where(.swal2-container) input:where(.swal2-file):hover,div:where(.swal2-container) textarea:where(.swal2-textarea):hover{box-shadow:var(--swal2-input-hover-box-shadow)}div:where(.swal2-container) input:where(.swal2-input):focus,div:where(.swal2-container) input:where(.swal2-file):focus,div:where(.swal2-container) textarea:where(.swal2-textarea):focus{border:var(--swal2-input-focus-border);outline:none;box-shadow:var(--swal2-input-focus-box-shadow)}div:where(.swal2-container) input:where(.swal2-input)::placeholder,div:where(.swal2-container) input:where(.swal2-file)::placeholder,div:where(.swal2-container) textarea:where(.swal2-textarea)::placeholder{color:#ccc}div:where(.swal2-container) .swal2-range{margin:1em 2em 3px;background:var(--swal2-background)}div:where(.swal2-container) .swal2-range input{width:80%}div:where(.swal2-container) .swal2-range output{width:20%;color:inherit;font-weight:600;text-align:center}div:where(.swal2-container) .swal2-range input,div:where(.swal2-container) .swal2-range output{height:2.625em;padding:0;font-size:1.125em;line-height:2.625em}div:where(.swal2-container) .swal2-input{height:2.625em;padding:0 .75em}div:where(.swal2-container) .swal2-file{width:75%;margin-right:auto;margin-left:auto;background:var(--swal2-input-background);font-size:1.125em}div:where(.swal2-container) .swal2-textarea{height:6.75em;padding:.75em}div:where(.swal2-container) .swal2-select{min-width:50%;max-width:100%;padding:.375em .625em;background:var(--swal2-input-background);color:inherit;font-size:1.125em}div:where(.swal2-container) .swal2-radio,div:where(.swal2-container) .swal2-checkbox{align-items:center;justify-content:center;background:var(--swal2-background);color:inherit}div:where(.swal2-container) .swal2-radio label,div:where(.swal2-container) .swal2-checkbox label{margin:0 .6em;font-size:1.125em}div:where(.swal2-container) .swal2-radio input,div:where(.swal2-container) .swal2-checkbox input{flex-shrink:0;margin:0 .4em}div:where(.swal2-container) label:where(.swal2-input-label){display:flex;justify-content:center;margin:1em auto 0}div:where(.swal2-container) div:where(.swal2-validation-message){align-items:center;justify-content:center;margin:1em 0 0;padding:.625em;overflow:hidden;background:var(--swal2-validation-message-background);color:var(--swal2-validation-message-color);font-size:1em;font-weight:300}div:where(.swal2-container) div:where(.swal2-validation-message)::before{content:\"!\";display:inline-block;width:1.5em;min-width:1.5em;height:1.5em;margin:0 .625em;border-radius:50%;background-color:#f27474;color:#fff;font-weight:600;line-height:1.5em;text-align:center}div:where(.swal2-container) .swal2-progress-steps{flex-wrap:wrap;align-items:center;max-width:100%;margin:1.25em auto;padding:0;background:rgba(0,0,0,0);font-weight:600}div:where(.swal2-container) .swal2-progress-steps li{display:inline-block;position:relative}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step{z-index:20;flex-shrink:0;width:2em;height:2em;border-radius:2em;background:#2778c4;color:#fff;line-height:2em;text-align:center}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step{background:#2778c4}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step{background:var(--swal2-progress-step-background);color:#fff}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step.swal2-active-progress-step~.swal2-progress-step-line{background:var(--swal2-progress-step-background)}div:where(.swal2-container) .swal2-progress-steps .swal2-progress-step-line{z-index:10;flex-shrink:0;width:2.5em;height:.4em;margin:0 -1px;background:#2778c4}div:where(.swal2-icon){position:relative;box-sizing:content-box;justify-content:center;width:5em;height:5em;margin:2.5em auto .6em;zoom:var(--swal2-icon-zoom);border:.25em solid rgba(0,0,0,0);border-radius:50%;border-color:#000;font-family:inherit;line-height:5em;cursor:default;user-select:none}div:where(.swal2-icon) .swal2-icon-content{display:flex;align-items:center;font-size:3.75em}div:where(.swal2-icon).swal2-error{border-color:#f27474;color:#f27474}div:where(.swal2-icon).swal2-error .swal2-x-mark{position:relative;flex-grow:1}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line]{display:block;position:absolute;top:2.3125em;width:2.9375em;height:.3125em;border-radius:.125em;background-color:#f27474}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=left]{left:1.0625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-error [class^=swal2-x-mark-line][class$=right]{right:1em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-error.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-error.swal2-icon-show .swal2-x-mark{animation:swal2-animate-error-x-mark .5s}}div:where(.swal2-icon).swal2-warning{border-color:#f8bb86;color:#f8bb86}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-warning.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-warning.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .5s}}div:where(.swal2-icon).swal2-info{border-color:#3fc3ee;color:#3fc3ee}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-info.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-info.swal2-icon-show .swal2-icon-content{animation:swal2-animate-i-mark .8s}}div:where(.swal2-icon).swal2-question{border-color:#87adbd;color:#87adbd}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-question.swal2-icon-show{animation:swal2-animate-error-icon .5s}div:where(.swal2-icon).swal2-question.swal2-icon-show .swal2-icon-content{animation:swal2-animate-question-mark .8s}}div:where(.swal2-icon).swal2-success{border-color:#a5dc86;color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line]{position:absolute;width:3.75em;height:7.5em;border-radius:50%}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.4375em;left:-2.0635em;transform:rotate(-45deg);transform-origin:3.75em 3.75em;border-radius:7.5em 0 0 7.5em}div:where(.swal2-icon).swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.6875em;left:1.875em;transform:rotate(-45deg);transform-origin:0 3.75em;border-radius:0 7.5em 7.5em 0}div:where(.swal2-icon).swal2-success .swal2-success-ring{position:absolute;z-index:2;top:-0.25em;left:-0.25em;box-sizing:content-box;width:100%;height:100%;border:.25em solid rgba(165,220,134,.3);border-radius:50%}div:where(.swal2-icon).swal2-success .swal2-success-fix{position:absolute;z-index:1;top:.5em;left:1.625em;width:.4375em;height:5.625em;transform:rotate(-45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line]{display:block;position:absolute;z-index:2;height:.3125em;border-radius:.125em;background-color:#a5dc86}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=tip]{top:2.875em;left:.8125em;width:1.5625em;transform:rotate(45deg)}div:where(.swal2-icon).swal2-success [class^=swal2-success-line][class$=long]{top:2.375em;right:.5em;width:2.9375em;transform:rotate(-45deg)}@container swal2-popup style(--swal2-icon-animations:true){div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-animate-success-line-tip .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-animate-success-line-long .75s}div:where(.swal2-icon).swal2-success.swal2-icon-show .swal2-success-circular-line-right{animation:swal2-rotate-success-circular-line 4.25s ease-in}}[class^=swal2]{-webkit-tap-highlight-color:rgba(0,0,0,0)}.swal2-show{animation:var(--swal2-show-animation)}.swal2-hide{animation:var(--swal2-hide-animation)}.swal2-noanimation{transition:none}.swal2-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}.swal2-rtl .swal2-close{margin-right:initial;margin-left:0}.swal2-rtl .swal2-timer-progress-bar{right:0;left:auto}.swal2-toast{box-sizing:border-box;grid-column:1/4 !important;grid-row:1/4 !important;grid-template-columns:min-content auto min-content;padding:1em;overflow-y:hidden;border:var(--swal2-toast-border);background:var(--swal2-background);box-shadow:var(--swal2-toast-box-shadow);pointer-events:all}.swal2-toast>*{grid-column:2}.swal2-toast h2:where(.swal2-title){margin:.5em 1em;padding:0;font-size:1em;text-align:initial}.swal2-toast .swal2-loading{justify-content:center}.swal2-toast input:where(.swal2-input){height:2em;margin:.5em;font-size:1em}.swal2-toast .swal2-validation-message{font-size:1em}.swal2-toast div:where(.swal2-footer){margin:.5em 0 0;padding:.5em 0 0;font-size:.8em}.swal2-toast button:where(.swal2-close){grid-column:3/3;grid-row:1/99;align-self:center;width:.8em;height:.8em;margin:0;font-size:2em}.swal2-toast div:where(.swal2-html-container){margin:.5em 1em;padding:0;overflow:initial;font-size:1em;text-align:initial}.swal2-toast div:where(.swal2-html-container):empty{padding:0}.swal2-toast .swal2-loader{grid-column:1;grid-row:1/99;align-self:center;width:2em;height:2em;margin:.25em}.swal2-toast .swal2-icon{grid-column:1;grid-row:1/99;align-self:center;width:2em;min-width:2em;height:2em;margin:0 .5em 0 0}.swal2-toast .swal2-icon .swal2-icon-content{display:flex;align-items:center;font-size:1.8em;font-weight:bold}.swal2-toast .swal2-icon.swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line]{top:.875em;width:1.375em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=left]{left:.3125em}.swal2-toast .swal2-icon.swal2-error [class^=swal2-x-mark-line][class$=right]{right:.3125em}.swal2-toast div:where(.swal2-actions){justify-content:flex-start;height:auto;margin:0;margin-top:.5em;padding:0 .5em}.swal2-toast button:where(.swal2-styled){margin:.25em .5em;padding:.4em .6em;font-size:1em}.swal2-toast .swal2-success{border-color:#a5dc86}.swal2-toast .swal2-success [class^=swal2-success-circular-line]{position:absolute;width:1.6em;height:3em;border-radius:50%}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=left]{top:-0.8em;left:-0.5em;transform:rotate(-45deg);transform-origin:2em 2em;border-radius:4em 0 0 4em}.swal2-toast .swal2-success [class^=swal2-success-circular-line][class$=right]{top:-0.25em;left:.9375em;transform-origin:0 1.5em;border-radius:0 4em 4em 0}.swal2-toast .swal2-success .swal2-success-ring{width:2em;height:2em}.swal2-toast .swal2-success .swal2-success-fix{top:0;left:.4375em;width:.4375em;height:2.6875em}.swal2-toast .swal2-success [class^=swal2-success-line]{height:.3125em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=tip]{top:1.125em;left:.1875em;width:.75em}.swal2-toast .swal2-success [class^=swal2-success-line][class$=long]{top:.9375em;right:.1875em;width:1.375em}@container swal2-popup style(--swal2-icon-animations:true){.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-tip{animation:swal2-toast-animate-success-line-tip .75s}.swal2-toast .swal2-success.swal2-icon-show .swal2-success-line-long{animation:swal2-toast-animate-success-line-long .75s}}.swal2-toast.swal2-show{animation:var(--swal2-toast-show-animation)}.swal2-toast.swal2-hide{animation:var(--swal2-toast-hide-animation)}@keyframes swal2-show{0%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}100%{transform:translate3d(0, 0, 0) scale(1);opacity:1}}@keyframes swal2-hide{0%{transform:translate3d(0, 0, 0) scale(1);opacity:1}100%{transform:translate3d(0, -50px, 0) scale(0.9);opacity:0}}@keyframes swal2-animate-success-line-tip{0%{top:1.1875em;left:.0625em;width:0}54%{top:1.0625em;left:.125em;width:0}70%{top:2.1875em;left:-0.375em;width:3.125em}84%{top:3em;left:1.3125em;width:1.0625em}100%{top:2.8125em;left:.8125em;width:1.5625em}}@keyframes swal2-animate-success-line-long{0%{top:3.375em;right:2.875em;width:0}65%{top:3.375em;right:2.875em;width:0}84%{top:2.1875em;right:0;width:3.4375em}100%{top:2.375em;right:.5em;width:2.9375em}}@keyframes swal2-rotate-success-circular-line{0%{transform:rotate(-45deg)}5%{transform:rotate(-45deg)}12%{transform:rotate(-405deg)}100%{transform:rotate(-405deg)}}@keyframes swal2-animate-error-x-mark{0%{margin-top:1.625em;transform:scale(0.4);opacity:0}50%{margin-top:1.625em;transform:scale(0.4);opacity:0}80%{margin-top:-0.375em;transform:scale(1.15)}100%{margin-top:0;transform:scale(1);opacity:1}}@keyframes swal2-animate-error-icon{0%{transform:rotateX(100deg);opacity:0}100%{transform:rotateX(0deg);opacity:1}}@keyframes swal2-rotate-loading{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}@keyframes swal2-animate-question-mark{0%{transform:rotateY(-360deg)}100%{transform:rotateY(0)}}@keyframes swal2-animate-i-mark{0%{transform:rotateZ(45deg);opacity:0}25%{transform:rotateZ(-25deg);opacity:.4}50%{transform:rotateZ(15deg);opacity:.8}75%{transform:rotateZ(-5deg);opacity:1}100%{transform:rotateX(0);opacity:1}}@keyframes swal2-toast-show{0%{transform:translateY(-0.625em) rotateZ(2deg)}33%{transform:translateY(0) rotateZ(-2deg)}66%{transform:translateY(0.3125em) rotateZ(2deg)}100%{transform:translateY(0) rotateZ(0deg)}}@keyframes swal2-toast-hide{100%{transform:rotateZ(1deg);opacity:0}}@keyframes swal2-toast-animate-success-line-tip{0%{top:.5625em;left:.0625em;width:0}54%{top:.125em;left:.125em;width:0}70%{top:.625em;left:-0.25em;width:1.625em}84%{top:1.0625em;left:.75em;width:.5em}100%{top:1.125em;left:.1875em;width:.75em}}@keyframes swal2-toast-animate-success-line-long{0%{top:1.625em;right:1.375em;width:0}65%{top:1.25em;right:.9375em;width:0}84%{top:.9375em;right:0;width:1.125em}100%{top:.9375em;right:.1875em;width:1.375em}}");
10605
10606 /***/ },
10607
10608 /***/ "./node_modules/toastify-js/src/toastify.js"
10609 /*!**************************************************!*\
10610 !*** ./node_modules/toastify-js/src/toastify.js ***!
10611 \**************************************************/
10612 (module) {
10613
10614 /*!
10615 * Toastify js 1.12.0
10616 * https://github.com/apvarun/toastify-js
10617 * @license MIT licensed
10618 *
10619 * Copyright (C) 2018 Varun A P
10620 */
10621 (function(root, factory) {
10622 if ( true && module.exports) {
10623 module.exports = factory();
10624 } else {
10625 root.Toastify = factory();
10626 }
10627 })(this, function(global) {
10628 // Object initialization
10629 var Toastify = function(options) {
10630 // Returning a new init object
10631 return new Toastify.lib.init(options);
10632 },
10633 // Library version
10634 version = "1.12.0";
10635
10636 // Set the default global options
10637 Toastify.defaults = {
10638 oldestFirst: true,
10639 text: "Toastify is awesome!",
10640 node: undefined,
10641 duration: 3000,
10642 selector: undefined,
10643 callback: function () {
10644 },
10645 destination: undefined,
10646 newWindow: false,
10647 close: false,
10648 gravity: "toastify-top",
10649 positionLeft: false,
10650 position: '',
10651 backgroundColor: '',
10652 avatar: "",
10653 className: "",
10654 stopOnFocus: true,
10655 onClick: function () {
10656 },
10657 offset: {x: 0, y: 0},
10658 escapeMarkup: true,
10659 ariaLive: 'polite',
10660 style: {background: ''}
10661 };
10662
10663 // Defining the prototype of the object
10664 Toastify.lib = Toastify.prototype = {
10665 toastify: version,
10666
10667 constructor: Toastify,
10668
10669 // Initializing the object with required parameters
10670 init: function(options) {
10671 // Verifying and validating the input object
10672 if (!options) {
10673 options = {};
10674 }
10675
10676 // Creating the options object
10677 this.options = {};
10678
10679 this.toastElement = null;
10680
10681 // Validating the options
10682 this.options.text = options.text || Toastify.defaults.text; // Display message
10683 this.options.node = options.node || Toastify.defaults.node; // Display content as node
10684 this.options.duration = options.duration === 0 ? 0 : options.duration || Toastify.defaults.duration; // Display duration
10685 this.options.selector = options.selector || Toastify.defaults.selector; // Parent selector
10686 this.options.callback = options.callback || Toastify.defaults.callback; // Callback after display
10687 this.options.destination = options.destination || Toastify.defaults.destination; // On-click destination
10688 this.options.newWindow = options.newWindow || Toastify.defaults.newWindow; // Open destination in new window
10689 this.options.close = options.close || Toastify.defaults.close; // Show toast close icon
10690 this.options.gravity = options.gravity === "bottom" ? "toastify-bottom" : Toastify.defaults.gravity; // toast position - top or bottom
10691 this.options.positionLeft = options.positionLeft || Toastify.defaults.positionLeft; // toast position - left or right
10692 this.options.position = options.position || Toastify.defaults.position; // toast position - left or right
10693 this.options.backgroundColor = options.backgroundColor || Toastify.defaults.backgroundColor; // toast background color
10694 this.options.avatar = options.avatar || Toastify.defaults.avatar; // img element src - url or a path
10695 this.options.className = options.className || Toastify.defaults.className; // additional class names for the toast
10696 this.options.stopOnFocus = options.stopOnFocus === undefined ? Toastify.defaults.stopOnFocus : options.stopOnFocus; // stop timeout on focus
10697 this.options.onClick = options.onClick || Toastify.defaults.onClick; // Callback after click
10698 this.options.offset = options.offset || Toastify.defaults.offset; // toast offset
10699 this.options.escapeMarkup = options.escapeMarkup !== undefined ? options.escapeMarkup : Toastify.defaults.escapeMarkup;
10700 this.options.ariaLive = options.ariaLive || Toastify.defaults.ariaLive;
10701 this.options.style = options.style || Toastify.defaults.style;
10702 if(options.backgroundColor) {
10703 this.options.style.background = options.backgroundColor;
10704 }
10705
10706 // Returning the current object for chaining functions
10707 return this;
10708 },
10709
10710 // Building the DOM element
10711 buildToast: function() {
10712 // Validating if the options are defined
10713 if (!this.options) {
10714 throw "Toastify is not initialized";
10715 }
10716
10717 // Creating the DOM object
10718 var divElement = document.createElement("div");
10719 divElement.className = "toastify on " + this.options.className;
10720
10721 // Positioning toast to left or right or center
10722 if (!!this.options.position) {
10723 divElement.className += " toastify-" + this.options.position;
10724 } else {
10725 // To be depreciated in further versions
10726 if (this.options.positionLeft === true) {
10727 divElement.className += " toastify-left";
10728 console.warn('Property `positionLeft` will be depreciated in further versions. Please use `position` instead.')
10729 } else {
10730 // Default position
10731 divElement.className += " toastify-right";
10732 }
10733 }
10734
10735 // Assigning gravity of element
10736 divElement.className += " " + this.options.gravity;
10737
10738 if (this.options.backgroundColor) {
10739 // This is being deprecated in favor of using the style HTML DOM property
10740 console.warn('DEPRECATION NOTICE: "backgroundColor" is being deprecated. Please use the "style.background" property.');
10741 }
10742
10743 // Loop through our style object and apply styles to divElement
10744 for (var property in this.options.style) {
10745 divElement.style[property] = this.options.style[property];
10746 }
10747
10748 // Announce the toast to screen readers
10749 if (this.options.ariaLive) {
10750 divElement.setAttribute('aria-live', this.options.ariaLive)
10751 }
10752
10753 // Adding the toast message/node
10754 if (this.options.node && this.options.node.nodeType === Node.ELEMENT_NODE) {
10755 // If we have a valid node, we insert it
10756 divElement.appendChild(this.options.node)
10757 } else {
10758 if (this.options.escapeMarkup) {
10759 divElement.innerText = this.options.text;
10760 } else {
10761 divElement.innerHTML = this.options.text;
10762 }
10763
10764 if (this.options.avatar !== "") {
10765 var avatarElement = document.createElement("img");
10766 avatarElement.src = this.options.avatar;
10767
10768 avatarElement.className = "toastify-avatar";
10769
10770 if (this.options.position == "left" || this.options.positionLeft === true) {
10771 // Adding close icon on the left of content
10772 divElement.appendChild(avatarElement);
10773 } else {
10774 // Adding close icon on the right of content
10775 divElement.insertAdjacentElement("afterbegin", avatarElement);
10776 }
10777 }
10778 }
10779
10780 // Adding a close icon to the toast
10781 if (this.options.close === true) {
10782 // Create a span for close element
10783 var closeElement = document.createElement("button");
10784 closeElement.type = "button";
10785 closeElement.setAttribute("aria-label", "Close");
10786 closeElement.className = "toast-close";
10787 closeElement.innerHTML = "&#10006;";
10788
10789 // Triggering the removal of toast from DOM on close click
10790 closeElement.addEventListener(
10791 "click",
10792 function(event) {
10793 event.stopPropagation();
10794 this.removeElement(this.toastElement);
10795 window.clearTimeout(this.toastElement.timeOutValue);
10796 }.bind(this)
10797 );
10798
10799 //Calculating screen width
10800 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
10801
10802 // Adding the close icon to the toast element
10803 // Display on the right if screen width is less than or equal to 360px
10804 if ((this.options.position == "left" || this.options.positionLeft === true) && width > 360) {
10805 // Adding close icon on the left of content
10806 divElement.insertAdjacentElement("afterbegin", closeElement);
10807 } else {
10808 // Adding close icon on the right of content
10809 divElement.appendChild(closeElement);
10810 }
10811 }
10812
10813 // Clear timeout while toast is focused
10814 if (this.options.stopOnFocus && this.options.duration > 0) {
10815 var self = this;
10816 // stop countdown
10817 divElement.addEventListener(
10818 "mouseover",
10819 function(event) {
10820 window.clearTimeout(divElement.timeOutValue);
10821 }
10822 )
10823 // add back the timeout
10824 divElement.addEventListener(
10825 "mouseleave",
10826 function() {
10827 divElement.timeOutValue = window.setTimeout(
10828 function() {
10829 // Remove the toast from DOM
10830 self.removeElement(divElement);
10831 },
10832 self.options.duration
10833 )
10834 }
10835 )
10836 }
10837
10838 // Adding an on-click destination path
10839 if (typeof this.options.destination !== "undefined") {
10840 divElement.addEventListener(
10841 "click",
10842 function(event) {
10843 event.stopPropagation();
10844 if (this.options.newWindow === true) {
10845 window.open(this.options.destination, "_blank");
10846 } else {
10847 window.location = this.options.destination;
10848 }
10849 }.bind(this)
10850 );
10851 }
10852
10853 if (typeof this.options.onClick === "function" && typeof this.options.destination === "undefined") {
10854 divElement.addEventListener(
10855 "click",
10856 function(event) {
10857 event.stopPropagation();
10858 this.options.onClick();
10859 }.bind(this)
10860 );
10861 }
10862
10863 // Adding offset
10864 if(typeof this.options.offset === "object") {
10865
10866 var x = getAxisOffsetAValue("x", this.options);
10867 var y = getAxisOffsetAValue("y", this.options);
10868
10869 var xOffset = this.options.position == "left" ? x : "-" + x;
10870 var yOffset = this.options.gravity == "toastify-top" ? y : "-" + y;
10871
10872 divElement.style.transform = "translate(" + xOffset + "," + yOffset + ")";
10873
10874 }
10875
10876 // Returning the generated element
10877 return divElement;
10878 },
10879
10880 // Displaying the toast
10881 showToast: function() {
10882 // Creating the DOM object for the toast
10883 this.toastElement = this.buildToast();
10884
10885 // Getting the root element to with the toast needs to be added
10886 var rootElement;
10887 if (typeof this.options.selector === "string") {
10888 rootElement = document.getElementById(this.options.selector);
10889 } else if (this.options.selector instanceof HTMLElement || (typeof ShadowRoot !== 'undefined' && this.options.selector instanceof ShadowRoot)) {
10890 rootElement = this.options.selector;
10891 } else {
10892 rootElement = document.body;
10893 }
10894
10895 // Validating if root element is present in DOM
10896 if (!rootElement) {
10897 throw "Root element is not defined";
10898 }
10899
10900 // Adding the DOM element
10901 var elementToInsert = Toastify.defaults.oldestFirst ? rootElement.firstChild : rootElement.lastChild;
10902 rootElement.insertBefore(this.toastElement, elementToInsert);
10903
10904 // Repositioning the toasts in case multiple toasts are present
10905 Toastify.reposition();
10906
10907 if (this.options.duration > 0) {
10908 this.toastElement.timeOutValue = window.setTimeout(
10909 function() {
10910 // Remove the toast from DOM
10911 this.removeElement(this.toastElement);
10912 }.bind(this),
10913 this.options.duration
10914 ); // Binding `this` for function invocation
10915 }
10916
10917 // Supporting function chaining
10918 return this;
10919 },
10920
10921 hideToast: function() {
10922 if (this.toastElement.timeOutValue) {
10923 clearTimeout(this.toastElement.timeOutValue);
10924 }
10925 this.removeElement(this.toastElement);
10926 },
10927
10928 // Removing the element from the DOM
10929 removeElement: function(toastElement) {
10930 // Hiding the element
10931 // toastElement.classList.remove("on");
10932 toastElement.className = toastElement.className.replace(" on", "");
10933
10934 // Removing the element from DOM after transition end
10935 window.setTimeout(
10936 function() {
10937 // remove options node if any
10938 if (this.options.node && this.options.node.parentNode) {
10939 this.options.node.parentNode.removeChild(this.options.node);
10940 }
10941
10942 // Remove the element from the DOM, only when the parent node was not removed before.
10943 if (toastElement.parentNode) {
10944 toastElement.parentNode.removeChild(toastElement);
10945 }
10946
10947 // Calling the callback function
10948 this.options.callback.call(toastElement);
10949
10950 // Repositioning the toasts again
10951 Toastify.reposition();
10952 }.bind(this),
10953 400
10954 ); // Binding `this` for function invocation
10955 },
10956 };
10957
10958 // Positioning the toasts on the DOM
10959 Toastify.reposition = function() {
10960
10961 // Top margins with gravity
10962 var topLeftOffsetSize = {
10963 top: 15,
10964 bottom: 15,
10965 };
10966 var topRightOffsetSize = {
10967 top: 15,
10968 bottom: 15,
10969 };
10970 var offsetSize = {
10971 top: 15,
10972 bottom: 15,
10973 };
10974
10975 // Get all toast messages on the DOM
10976 var allToasts = document.getElementsByClassName("toastify");
10977
10978 var classUsed;
10979
10980 // Modifying the position of each toast element
10981 for (var i = 0; i < allToasts.length; i++) {
10982 // Getting the applied gravity
10983 if (containsClass(allToasts[i], "toastify-top") === true) {
10984 classUsed = "toastify-top";
10985 } else {
10986 classUsed = "toastify-bottom";
10987 }
10988
10989 var height = allToasts[i].offsetHeight;
10990 classUsed = classUsed.substr(9, classUsed.length-1)
10991 // Spacing between toasts
10992 var offset = 15;
10993
10994 var width = window.innerWidth > 0 ? window.innerWidth : screen.width;
10995
10996 // Show toast in center if screen with less than or equal to 360px
10997 if (width <= 360) {
10998 // Setting the position
10999 allToasts[i].style[classUsed] = offsetSize[classUsed] + "px";
11000
11001 offsetSize[classUsed] += height + offset;
11002 } else {
11003 if (containsClass(allToasts[i], "toastify-left") === true) {
11004 // Setting the position
11005 allToasts[i].style[classUsed] = topLeftOffsetSize[classUsed] + "px";
11006
11007 topLeftOffsetSize[classUsed] += height + offset;
11008 } else {
11009 // Setting the position
11010 allToasts[i].style[classUsed] = topRightOffsetSize[classUsed] + "px";
11011
11012 topRightOffsetSize[classUsed] += height + offset;
11013 }
11014 }
11015 }
11016
11017 // Supporting function chaining
11018 return this;
11019 };
11020
11021 // Helper function to get offset.
11022 function getAxisOffsetAValue(axis, options) {
11023
11024 if(options.offset[axis]) {
11025 if(isNaN(options.offset[axis])) {
11026 return options.offset[axis];
11027 }
11028 else {
11029 return options.offset[axis] + 'px';
11030 }
11031 }
11032
11033 return '0px';
11034
11035 }
11036
11037 function containsClass(elem, yourClass) {
11038 if (!elem || typeof yourClass !== "string") {
11039 return false;
11040 } else if (
11041 elem.className &&
11042 elem.className
11043 .trim()
11044 .split(/\s+/gi)
11045 .indexOf(yourClass) > -1
11046 ) {
11047 return true;
11048 } else {
11049 return false;
11050 }
11051 }
11052
11053 // Setting up the prototype for the init object
11054 Toastify.lib.init.prototype = Toastify.lib;
11055
11056 // Returning the Toastify function to be assigned to the window object/module
11057 return Toastify;
11058 });
11059
11060
11061 /***/ },
11062
11063 /***/ "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC"
11064 /*!**************************************************************************************************************************************************************************************************************************************************************!*\
11065 !*** data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC ***!
11066 \**************************************************************************************************************************************************************************************************************************************************************/
11067 (module) {
11068
11069 "use strict";
11070 module.exports = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC";
11071
11072 /***/ }
11073
11074 /******/ });
11075 /************************************************************************/
11076 /******/ // The module cache
11077 /******/ var __webpack_module_cache__ = {};
11078 /******/
11079 /******/ // The require function
11080 /******/ function __webpack_require__(moduleId) {
11081 /******/ // Check if module is in cache
11082 /******/ var cachedModule = __webpack_module_cache__[moduleId];
11083 /******/ if (cachedModule !== undefined) {
11084 /******/ return cachedModule.exports;
11085 /******/ }
11086 /******/ // Create a new module (and put it into the cache)
11087 /******/ var module = __webpack_module_cache__[moduleId] = {
11088 /******/ id: moduleId,
11089 /******/ // no module.loaded needed
11090 /******/ exports: {}
11091 /******/ };
11092 /******/
11093 /******/ // Execute the module function
11094 /******/ if (!(moduleId in __webpack_modules__)) {
11095 /******/ delete __webpack_module_cache__[moduleId];
11096 /******/ var e = new Error("Cannot find module '" + moduleId + "'");
11097 /******/ e.code = 'MODULE_NOT_FOUND';
11098 /******/ throw e;
11099 /******/ }
11100 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
11101 /******/
11102 /******/ // Return the exports of the module
11103 /******/ return module.exports;
11104 /******/ }
11105 /******/
11106 /******/ // expose the modules object (__webpack_modules__)
11107 /******/ __webpack_require__.m = __webpack_modules__;
11108 /******/
11109 /************************************************************************/
11110 /******/ /* webpack/runtime/compat get default export */
11111 /******/ (() => {
11112 /******/ // getDefaultExport function for compatibility with non-harmony modules
11113 /******/ __webpack_require__.n = (module) => {
11114 /******/ var getter = module && module.__esModule ?
11115 /******/ () => (module['default']) :
11116 /******/ () => (module);
11117 /******/ __webpack_require__.d(getter, { a: getter });
11118 /******/ return getter;
11119 /******/ };
11120 /******/ })();
11121 /******/
11122 /******/ /* webpack/runtime/define property getters */
11123 /******/ (() => {
11124 /******/ // define getter functions for harmony exports
11125 /******/ __webpack_require__.d = (exports, definition) => {
11126 /******/ for(var key in definition) {
11127 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
11128 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
11129 /******/ }
11130 /******/ }
11131 /******/ };
11132 /******/ })();
11133 /******/
11134 /******/ /* webpack/runtime/hasOwnProperty shorthand */
11135 /******/ (() => {
11136 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
11137 /******/ })();
11138 /******/
11139 /******/ /* webpack/runtime/make namespace object */
11140 /******/ (() => {
11141 /******/ // define __esModule on exports
11142 /******/ __webpack_require__.r = (exports) => {
11143 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
11144 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
11145 /******/ }
11146 /******/ Object.defineProperty(exports, '__esModule', { value: true });
11147 /******/ };
11148 /******/ })();
11149 /******/
11150 /******/ /* webpack/runtime/jsonp chunk loading */
11151 /******/ (() => {
11152 /******/ __webpack_require__.b = (typeof document !== 'undefined' && document.baseURI) || self.location.href;
11153 /******/
11154 /******/ // object to store loaded and loading chunks
11155 /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
11156 /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
11157 /******/ var installedChunks = {
11158 /******/ "./assets/js/dist/frontend/profile": 0
11159 /******/ };
11160 /******/
11161 /******/ // no chunk on demand loading
11162 /******/
11163 /******/ // no prefetching
11164 /******/
11165 /******/ // no preloaded
11166 /******/
11167 /******/ // no HMR
11168 /******/
11169 /******/ // no HMR manifest
11170 /******/
11171 /******/ // no on chunks loaded
11172 /******/
11173 /******/ // no jsonp function
11174 /******/ })();
11175 /******/
11176 /******/ /* webpack/runtime/nonce */
11177 /******/ (() => {
11178 /******/ __webpack_require__.nc = undefined;
11179 /******/ })();
11180 /******/
11181 /************************************************************************/
11182 var __webpack_exports__ = {};
11183 // This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
11184 (() => {
11185 "use strict";
11186 /*!*******************************************!*\
11187 !*** ./assets/src/js/frontend/profile.js ***!
11188 \*******************************************/
11189 __webpack_require__.r(__webpack_exports__);
11190 /* harmony import */ var _profile_course_tab__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./profile/course-tab */ "./assets/src/js/frontend/profile/course-tab.js");
11191 /* harmony import */ var _profile_statistic__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./profile/statistic */ "./assets/src/js/frontend/profile/statistic.js");
11192 /* harmony import */ var _profile_order_recover__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./profile/order-recover */ "./assets/src/js/frontend/profile/order-recover.js");
11193 /* harmony import */ var _profile_cover_image__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./profile/cover-image */ "./assets/src/js/frontend/profile/cover-image.js");
11194 /* harmony import */ var _profile_avatar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./profile/avatar */ "./assets/src/js/frontend/profile/avatar.js");
11195 /* harmony import */ var _profile_quiz__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./profile/quiz */ "./assets/src/js/frontend/profile/quiz.js");
11196 /* harmony import */ var _admin_courses_view_students_modal__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../admin/courses/view-students-modal */ "./assets/src/js/admin/courses/view-students-modal.js");
11197
11198
11199
11200
11201
11202
11203
11204 (0,_profile_cover_image__WEBPACK_IMPORTED_MODULE_3__["default"])();
11205 (0,_profile_quiz__WEBPACK_IMPORTED_MODULE_5__["default"])();
11206 (0,_profile_statistic__WEBPACK_IMPORTED_MODULE_1__["default"])();
11207 (0,_profile_order_recover__WEBPACK_IMPORTED_MODULE_2__["default"])();
11208 new _admin_courses_view_students_modal__WEBPACK_IMPORTED_MODULE_6__.ViewStudentsModal();
11209 document.addEventListener('DOMContentLoaded', function (event) {
11210 (0,_profile_course_tab__WEBPACK_IMPORTED_MODULE_0__["default"])();
11211 });
11212 if (document.getElementById('learnpress-avatar-upload')) {
11213 (0,_profile_avatar__WEBPACK_IMPORTED_MODULE_4__["default"])();
11214 }
11215 })();
11216
11217 /******/ })()
11218 ;
11219 //# sourceMappingURL=profile.js.map