PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
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.1.7.3, at assets/js/dist/frontend/profile.js

2,565 lines 94.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function() { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ "./assets/src/apps/js/frontend/profile/avatar.js":
5 /*!*******************************************************!*\
6 !*** ./assets/src/apps/js/frontend/profile/avatar.js ***!
7 \*******************************************************/
8 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
10 "use strict";
11 __webpack_require__.r(__webpack_exports__);
12 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
13 /* harmony export */ "default": function() { return /* binding */ Avatar; }
14 /* harmony export */ });
15 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
16 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
17 /* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/api-fetch */ "@wordpress/api-fetch");
18 /* harmony import */ var _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1__);
19 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n");
20 /* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__);
21 /* harmony import */ var react_easy_crop__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! react-easy-crop */ "./node_modules/react-easy-crop/index.module.js");
22
23
24
25
26
27 function Avatar() {
28 const [file, setFile] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)();
29 const [width, setWidth] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
30 const [height, setHeight] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
31 const [crop, setCrop] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)({
32 x: 0,
33 y: 0
34 });
35 const [rotation, setRotation] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
36 const [croppedAreaPixels, setCroppedAreaPixels] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(null);
37 const [naturalWidth, setNaturalWidth] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
38 const [naturalHeight, setNaturalHeight] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(0);
39 const [loading, setLoading] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(false);
40 const [skeleton, setSkeleton] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)(true);
41 const [uploadError, setUploadError] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)('');
42 const [notice, setNotice] = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useState)({
43 type: '',
44 message: ''
45 });
46 const fileInput = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useRef)();
47 (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
48 async function getAvatar() {
49 setSkeleton(true);
50
51 try {
52 var _response$data, _response$data2, _response$data3;
53
54 const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({
55 method: 'GET',
56 path: 'lp/v1/profile/get-avatar'
57 });
58 setWidth(response !== null && response !== void 0 && (_response$data = response.data) !== null && _response$data !== void 0 && _response$data.width ? parseInt(response.data.width) : 0);
59 setHeight(response !== null && response !== void 0 && (_response$data2 = response.data) !== null && _response$data2 !== void 0 && _response$data2.height ? parseInt(response.data.height) : 0);
60 setFile(response !== null && response !== void 0 && (_response$data3 = response.data) !== null && _response$data3 !== void 0 && _response$data3.url ? response.data.url : '');
61 } catch (error) {
62 setNotice({
63 type: 'error',
64 message: error.message
65 });
66 }
67
68 setSkeleton(false);
69 }
70
71 getAvatar();
72 }, []);
73
74 function readFile(file) {
75 return new Promise(resolve => {
76 const reader = new FileReader();
77 reader.addEventListener('load', () => resolve(reader.result), false);
78 reader.readAsDataURL(file);
79 });
80 }
81
82 const onCropComplete = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useCallback)((croppedArea, croppedAreaPixels) => {
83 setCroppedAreaPixels(croppedAreaPixels);
84 }, []);
85
86 const base64Resize = (base64, width, height) => {
87 return new Promise((resolve, reject) => {
88 const canvas = document.createElement('canvas');
89 const img = document.createElement('img');
90 img.src = base64;
91 img.setAttribute('crossOrigin', 'anonymous');
92
93 img.onload = () => {
94 if (img.naturalWidth > width || img.naturalHeight > height) {
95 canvas.width = width;
96 canvas.height = height;
97 const ctx = canvas.getContext('2d');
98 ctx.drawImage(img, 0, 0, width, height);
99 resolve(canvas.toDataURL('image/jpeg'));
100 }
101
102 resolve(base64);
103 };
104
105 img.onerror = err => reject(err);
106 });
107 };
108
109 const updateAvatar = (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useCallback)(async () => {
110 setLoading({
111 save: true
112 });
113
114 try {
115 const croppedImage = await getCroppedImg(file, croppedAreaPixels, rotation);
116 const imageResize = await base64Resize(croppedImage, width, height);
117 const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({
118 path: 'lp/v1/profile/upload-avatar',
119 method: 'POST',
120 data: {
121 file: imageResize || ''
122 }
123 });
124 const {
125 data,
126 status,
127 message
128 } = await response;
129
130 if (status === 'success') {
131 window.location.reload();
132 }
133
134 setNotice({
135 type: status,
136 message
137 });
138 } catch (e) {
139 setNotice({
140 type: 'error',
141 message: e.message || ''
142 });
143 }
144
145 setLoading({
146 save: false
147 });
148 }, [croppedAreaPixels, rotation]);
149
150 const setFileInput = async fileUpload => {
151 const file = await readFile(fileUpload);
152 const img = new Image();
153 img.src = await file;
154 img.onload = await function () {
155 setNaturalWidth(img.naturalWidth);
156 setNaturalHeight(img.naturalHeight);
157 let error = '';
158
159 if (parseInt(fileUpload.size) > 2097152) {
160 error = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('File size too large. You need to upload a file < 2MB', 'learnpress');
161 } else if (img.naturalWidth < width || img.naturalHeight < height) {
162 error = (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.sprintf)((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Image size must be greater than or equal to %1$sx%2$spx', 'learnpress'), width, height);
163 }
164
165 if (error) {
166 setUploadError(error);
167 } else {
168 setUploadError('');
169 setFile(file);
170 }
171 };
172 };
173
174 async function removeAvatar() {
175 if (confirm((0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Are you sure you want to remove your avatar?', 'learnpress'))) {
176 setLoading({
177 remove: true
178 });
179
180 try {
181 const response = await _wordpress_api_fetch__WEBPACK_IMPORTED_MODULE_1___default()({
182 path: 'lp/v1/profile/remove-avatar',
183 method: 'POST'
184 });
185 const {
186 data,
187 status,
188 message
189 } = await response;
190 setNotice({
191 type: status,
192 message
193 });
194 setFile('');
195 } catch (e) {
196 setNotice({
197 type: 'error',
198 message: e.message || ''
199 });
200 }
201
202 setLoading({
203 remove: false
204 });
205 }
206 }
207
208 return (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
209 className: "learnpress_avatar"
210 }, !skeleton ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, file && !uploadError && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.Fragment, null, naturalHeight && naturalWidth ? (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
211 className: "learnpress_avatar__cropper"
212 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
213 style: {
214 position: 'relative',
215 width: naturalWidth,
216 height: naturalHeight,
217 zIndex: 9999,
218 maxWidth: '100%',
219 maxHeight: '800px'
220 }
221 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(react_easy_crop__WEBPACK_IMPORTED_MODULE_3__["default"], {
222 image: file,
223 crop: crop,
224 zoom: "1",
225 cropSize: {
226 width,
227 height
228 },
229 onCropChange: setCrop,
230 onCropComplete: onCropComplete
231 })), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", {
232 className: `learnpress_avatar__button learnpress_avatar__button--save ${loading !== null && loading !== void 0 && loading.save ? 'learnpress_avatar__button--loading' : ''}`,
233 onClick: updateAvatar
234 }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Save', 'learnpress')))) : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
235 className: "learnpress_avatar__cropper"
236 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("img", {
237 src: file,
238 alt: ""
239 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", {
240 className: `learnpress_avatar__button learnpress_avatar__button--replace`,
241 onClick: () => fileInput.current && fileInput.current.click()
242 }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Replace', 'learnpress')), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("button", {
243 className: `learnpress_avatar__button learnpress_avatar__button--remove ${loading !== null && loading !== void 0 && loading.remove ? 'learnpress_avatar__button--loading' : ''}`,
244 onClick: removeAvatar
245 }, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Remove', 'learnpress'))))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("form", {
246 style: {
247 display: !file ? '' : 'none'
248 }
249 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
250 className: "learnpress_avatar__form"
251 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
252 className: "learnpress_avatar__form-group"
253 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("label", {
254 htmlFor: "avatar-file"
255 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
256 className: "learnpress_avatar__form__upload"
257 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("span", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("svg", {
258 viewBox: "64 64 896 896",
259 focusable: "false",
260 "data-icon": "plus",
261 width: "1em",
262 height: "1em",
263 fill: "currentColor",
264 "aria-hidden": "true"
265 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("defs", null, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("style", null)), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
266 d: "M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8z"
267 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("path", {
268 d: "M176 474h672q8 0 8 8v60q0 8-8 8H176q-8 0-8-8v-60q0-8 8-8z"
269 }))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", null, (0,_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__.__)('Upload', 'learnpress')))), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("input", {
270 ref: fileInput,
271 type: "file",
272 id: "avatar-file",
273 accept: "image/*",
274 onChange: e => setFileInput(e.target.files && e.target.files.length > 0 ? e.target.files[0] : '')
275 }))))), uploadError && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
276 className: `lp-ajax-message error`,
277 style: {
278 display: 'block'
279 }
280 }, uploadError), !uploadError && notice && notice.type && notice.message && (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
281 className: `lp-ajax-message ${notice.type}`,
282 style: {
283 display: 'block'
284 }
285 }, notice.message)) : (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("ul", {
286 className: "lp-skeleton-animation"
287 }, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", {
288 style: {
289 width: 200,
290 height: 200
291 }
292 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", {
293 style: {
294 width: 200,
295 height: 20
296 }
297 }), (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("li", {
298 style: {
299 width: 200,
300 height: 20
301 }
302 })));
303 } // Link: https://codesandbox.io/s/q8q1mnr01w
304
305 const createImage = url => new Promise((resolve, reject) => {
306 const image = new Image();
307 image.addEventListener('load', () => resolve(image));
308 image.addEventListener('error', error => reject(error));
309 image.setAttribute('crossOrigin', 'anonymous'); // needed to avoid cross-origin issues on CodeSandbox
310
311 image.src = url;
312 });
313
314 function getRadianAngle(degreeValue) {
315 return degreeValue * Math.PI / 180;
316 }
317 /**
318 * Returns the new bounding area of a rotated rectangle.
319 *
320 * @param width
321 * @param height
322 * @param rotation
323 */
324
325
326 function rotateSize(width, height, rotation) {
327 const rotRad = getRadianAngle(rotation);
328 return {
329 width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height),
330 height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height)
331 };
332 }
333 /**
334 * This function was adapted from the one in the ReadMe of https://github.com/DominicTobias/react-image-crop
335 *
336 * @param imageSrc
337 * @param pixelCrop
338 * @param rotation
339 * @param flip
340 */
341
342
343 async function getCroppedImg(imageSrc, pixelCrop) {
344 let rotation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
345 let flip = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
346 horizontal: false,
347 vertical: false
348 };
349 const image = await createImage(imageSrc);
350 const canvas = document.createElement('canvas');
351 const ctx = canvas.getContext('2d');
352
353 if (!ctx) {
354 return null;
355 }
356
357 const rotRad = getRadianAngle(rotation); // calculate bounding box of the rotated image
358
359 const {
360 width: bBoxWidth,
361 height: bBoxHeight
362 } = rotateSize(image.width, image.height, rotation); // set canvas size to match the bounding box
363
364 canvas.width = bBoxWidth;
365 canvas.height = bBoxHeight; // translate canvas context to a central location to allow rotating and flipping around the center
366
367 ctx.translate(bBoxWidth / 2, bBoxHeight / 2);
368 ctx.rotate(rotRad);
369 ctx.scale(flip.horizontal ? -1 : 1, flip.vertical ? -1 : 1);
370 ctx.translate(-image.width / 2, -image.height / 2); // draw rotated image
371
372 ctx.drawImage(image, 0, 0); // croppedAreaPixels values are bounding box relative
373 // extract the cropped image using these values
374
375 const data = ctx.getImageData(pixelCrop.x, pixelCrop.y, pixelCrop.width, pixelCrop.height); // set canvas width to final desired crop size - this will clear existing context
376
377 canvas.width = pixelCrop.width;
378 canvas.height = pixelCrop.height; // paste generated rotate image at the top left corner
379
380 ctx.putImageData(data, 0, 0); // As Base64 string
381
382 return canvas.toDataURL('image/jpeg');
383 }
384
385 /***/ }),
386
387 /***/ "./assets/src/apps/js/frontend/profile/course-tab.js":
388 /*!***********************************************************!*\
389 !*** ./assets/src/apps/js/frontend/profile/course-tab.js ***!
390 \***********************************************************/
391 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
392
393 "use strict";
394 __webpack_require__.r(__webpack_exports__);
395 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
396 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
397 // Rest API load content course enrolled, created - Nhamdv.
398
399 const courseTab = () => {
400 const elements = document.querySelectorAll('.learn-press-course-tab__filter__content');
401
402 const getResponse = function (ele, dataset) {
403 let append = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
404 let viewMoreEle = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
405 wp.apiFetch({
406 path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/profile/course-tab', dataset),
407 method: 'GET'
408 }).then(response => {
409 const skeleton = ele.querySelector('.lp-skeleton-animation');
410 skeleton && skeleton.remove();
411
412 if (response.status === 'success' && response.data) {
413 if (append) {
414 ele.innerHTML += response.data;
415 } else {
416 ele.innerHTML = response.data;
417 }
418 } else if (append) {
419 ele.innerHTML += `<div class="lp-ajax-message" style="display:block">${response.message && response.message}</div>`;
420 } else {
421 ele.innerHTML = `<div class="lp-ajax-message" style="display:block">${response.message && response.message}</div>`;
422 }
423
424 if (viewMoreEle) {
425 viewMoreEle.classList.remove('loading');
426 const paged = viewMoreEle.dataset.paged;
427 const numberPage = viewMoreEle.dataset.number;
428
429 if (numberPage <= paged) {
430 viewMoreEle.remove();
431 }
432
433 viewMoreEle.dataset.paged = parseInt(paged) + 1;
434 }
435
436 viewMore(ele, dataset);
437 }).catch(error => {
438 if (append) {
439 ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${error.message && error.message}</div>`;
440 } else {
441 ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${error.message && error.message}</div>`;
442 }
443
444 if (viewMoreEle) {
445 viewMoreEle.classList.remove('loading');
446 const paged = viewMoreEle.dataset.paged;
447 const numberPage = viewMoreEle.dataset.number;
448
449 if (numberPage <= paged) {
450 viewMoreEle.remove();
451 }
452
453 viewMoreEle.dataset.paged = parseInt(paged) + 1;
454 }
455 });
456 };
457
458 if ('IntersectionObserver' in window) {
459 const eleObserver = new IntersectionObserver((entries, observer) => {
460 entries.forEach(entry => {
461 if (entry.isIntersecting) {
462 const ele = entry.target;
463 const params = ele.parentNode.querySelector('.lp_profile_tab_input_param');
464 const data = { ...JSON.parse(params.value),
465 status: ele.dataset.tab || ''
466 };
467 getResponse(ele, data);
468 eleObserver.unobserve(ele);
469 }
470 });
471 });
472 [...elements].map(ele => {
473 if (ele.dataset.tab !== 'all') {
474 eleObserver.observe(ele);
475 } else {
476 const params = ele.parentNode.querySelector('.lp_profile_tab_input_param');
477 const data = { ...JSON.parse(params.value),
478 status: ele.dataset.tab === 'all' ? '' : ele.dataset.tab || ''
479 };
480 getResponse(ele, data);
481 }
482 });
483 }
484
485 const changeFilter = () => {
486 const tabs = document.querySelectorAll('.learn-press-course-tab-filters');
487 tabs.forEach(tab => {
488 const filters = tab.querySelectorAll('.learn-press-filters a');
489 filters.forEach(filter => {
490 filter.addEventListener('click', e => {
491 e.preventDefault();
492 const tabName = filter.dataset.tab;
493 [...filters].map(ele => {
494 ele.classList.remove('active');
495 });
496 filter.classList.add('active');
497 [...tab.querySelectorAll('.learn-press-course-tab__filter__content')].map(ele => {
498 ele.style.display = 'none';
499
500 if (ele.dataset.tab === tabName) {
501 ele.style.display = '';
502 }
503 });
504 });
505 });
506 });
507 };
508
509 changeFilter();
510
511 const changeTab = () => {
512 const tabUls = document.querySelectorAll('.learn-press-profile-course__tab__inner');
513 tabUls.forEach(tabUl => {
514 const tabs = tabUl.querySelectorAll('li> a');
515 tabs.forEach(tab => {
516 tab.addEventListener('click', e => {
517 e.preventDefault();
518 const tabName = tab.dataset.tab;
519 [...tabs].map(ele => {
520 ele.classList.remove('active');
521 });
522 tab.classList.add('active');
523 [...document.querySelectorAll('.learn-press-course-tab-filters')].map(ele => {
524 ele.style.display = 'none';
525
526 if (ele.dataset.tab === tabName) {
527 ele.style.display = '';
528 }
529 });
530 });
531 });
532 });
533 };
534
535 changeTab();
536
537 const viewMore = (ele, dataset) => {
538 const viewMoreEle = ele.querySelector('button[data-paged]');
539
540 if (viewMoreEle) {
541 viewMoreEle.addEventListener('click', e => {
542 e.preventDefault();
543 const paged = viewMoreEle && viewMoreEle.dataset.paged;
544 viewMoreEle.classList.add('loading');
545 const element = dataset.layout === 'list' ? '.lp_profile_course_progress' : '.learn-press-courses';
546 getResponse(ele.querySelector(element), { ...dataset,
547 ...{
548 paged
549 }
550 }, true, viewMoreEle);
551 });
552 }
553 };
554 };
555
556 /* harmony default export */ __webpack_exports__["default"] = (courseTab);
557
558 /***/ }),
559
560 /***/ "./assets/src/apps/js/frontend/profile/order-recover.js":
561 /*!**************************************************************!*\
562 !*** ./assets/src/apps/js/frontend/profile/order-recover.js ***!
563 \**************************************************************/
564 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
565
566 "use strict";
567 __webpack_require__.r(__webpack_exports__);
568 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
569 /* harmony export */ "default": function() { return /* binding */ recoverOrder; }
570 /* harmony export */ });
571 const $ = window.jQuery;
572 function recoverOrder() {
573 const wrap = $('.order-recover'),
574 buttonRecoverOrder = wrap.find('.button-recover-order');
575
576 const ajaxRecover = () => {
577 wrap.find('.learn-press-message').remove();
578 $('.profile-recover-order').find('.learn-press-message').remove();
579 $.post({
580 url: '',
581 data: wrap.serializeJSON(),
582
583 beforeSend() {
584 buttonRecoverOrder.addClass('loading').attr('disabled', 'disabled');
585 },
586
587 success(response) {
588 response = LP.parseJSON(response);
589
590 if (response.message) {
591 const $msg = $('<div class="learn-press-message icon"><i class="fa"></i> ' + response.message + '</div>');
592
593 if (response.result == 'error') {
594 $msg.addClass('error');
595 }
596
597 wrap.before($msg);
598 }
599
600 if (response.redirect) {
601 window.location.href = response.redirect;
602 }
603
604 buttonRecoverOrder.removeClass('loading').removeAttr('disabled', '');
605 },
606
607 error() {
608 buttonRecoverOrder.removeClass('loading').removeAttr('disabled', '');
609 }
610
611 });
612 };
613
614 buttonRecoverOrder.on('click', ajaxRecover);
615 }
616 ;
617
618 /***/ }),
619
620 /***/ "./assets/src/apps/js/frontend/profile/statistic.js":
621 /*!**********************************************************!*\
622 !*** ./assets/src/apps/js/frontend/profile/statistic.js ***!
623 \**********************************************************/
624 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
625
626 "use strict";
627 __webpack_require__.r(__webpack_exports__);
628 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/url */ "@wordpress/url");
629 /* harmony import */ var _wordpress_url__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_url__WEBPACK_IMPORTED_MODULE_0__);
630 // Rest API load content course progress - Nhamdv.
631
632 const courseStatistics = () => {
633 const elements = document.querySelector('.learn-press-profile-course__statistic');
634
635 if (!elements) {
636 return;
637 }
638
639 const getResponse = (ele, dataset) => {
640 wp.apiFetch({
641 path: (0,_wordpress_url__WEBPACK_IMPORTED_MODULE_0__.addQueryArgs)('lp/v1/profile/statistic', dataset),
642 method: 'GET'
643 }).then(response => {
644 if (response.status === 'success' && response.data) {
645 ele.innerHTML = response.data;
646 } else {
647 ele.innerHTML = `<div class="lp-ajax-message error" style="display:block">${response.message && response.message}</div>`;
648 }
649 }).catch(err => {
650 console.log(err); //ele.innerHTML += `<div class="lp-ajax-message error" style="display:block">${ err.message && err.message }</div>`;
651 });
652 };
653
654 const elArgStatistic = document.querySelector('[name="args_query_user_courses_statistic"]');
655
656 if (!elArgStatistic) {
657 return;
658 }
659
660 const data = JSON.parse(elArgStatistic.value);
661 getResponse(elements, data);
662 };
663
664 /* harmony default export */ __webpack_exports__["default"] = (courseStatistics);
665
666 /***/ }),
667
668 /***/ "./node_modules/normalize-wheel/index.js":
669 /*!***********************************************!*\
670 !*** ./node_modules/normalize-wheel/index.js ***!
671 \***********************************************/
672 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
673
674 module.exports = __webpack_require__(/*! ./src/normalizeWheel.js */ "./node_modules/normalize-wheel/src/normalizeWheel.js");
675
676
677 /***/ }),
678
679 /***/ "./node_modules/normalize-wheel/src/ExecutionEnvironment.js":
680 /*!******************************************************************!*\
681 !*** ./node_modules/normalize-wheel/src/ExecutionEnvironment.js ***!
682 \******************************************************************/
683 /***/ (function(module) {
684
685 "use strict";
686 /**
687 * Copyright (c) 2015, Facebook, Inc.
688 * All rights reserved.
689 *
690 * This source code is licensed under the BSD-style license found in the
691 * LICENSE file in the root directory of this source tree. An additional grant
692 * of patent rights can be found in the PATENTS file in the same directory.
693 *
694 * @providesModule ExecutionEnvironment
695 */
696
697 /*jslint evil: true */
698
699
700
701 var canUseDOM = !!(
702 typeof window !== 'undefined' &&
703 window.document &&
704 window.document.createElement
705 );
706
707 /**
708 * Simple, lightweight module assisting with the detection and context of
709 * Worker. Helps avoid circular dependencies and allows code to reason about
710 * whether or not they are in a Worker, even if they never include the main
711 * `ReactWorker` dependency.
712 */
713 var ExecutionEnvironment = {
714
715 canUseDOM: canUseDOM,
716
717 canUseWorkers: typeof Worker !== 'undefined',
718
719 canUseEventListeners:
720 canUseDOM && !!(window.addEventListener || window.attachEvent),
721
722 canUseViewport: canUseDOM && !!window.screen,
723
724 isInWorker: !canUseDOM // For now, this is true - might change in the future.
725
726 };
727
728 module.exports = ExecutionEnvironment;
729
730
731 /***/ }),
732
733 /***/ "./node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js":
734 /*!******************************************************************!*\
735 !*** ./node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js ***!
736 \******************************************************************/
737 /***/ (function(module) {
738
739 /**
740 * Copyright 2004-present Facebook. All Rights Reserved.
741 *
742 * @providesModule UserAgent_DEPRECATED
743 */
744
745 /**
746 * Provides entirely client-side User Agent and OS detection. You should prefer
747 * the non-deprecated UserAgent module when possible, which exposes our
748 * authoritative server-side PHP-based detection to the client.
749 *
750 * Usage is straightforward:
751 *
752 * if (UserAgent_DEPRECATED.ie()) {
753 * // IE
754 * }
755 *
756 * You can also do version checks:
757 *
758 * if (UserAgent_DEPRECATED.ie() >= 7) {
759 * // IE7 or better
760 * }
761 *
762 * The browser functions will return NaN if the browser does not match, so
763 * you can also do version compares the other way:
764 *
765 * if (UserAgent_DEPRECATED.ie() < 7) {
766 * // IE6 or worse
767 * }
768 *
769 * Note that the version is a float and may include a minor version number,
770 * so you should always use range operators to perform comparisons, not
771 * strict equality.
772 *
773 * **Note:** You should **strongly** prefer capability detection to browser
774 * version detection where it's reasonable:
775 *
776 * http://www.quirksmode.org/js/support.html
777 *
778 * Further, we have a large number of mature wrapper functions and classes
779 * which abstract away many browser irregularities. Check the documentation,
780 * grep for things, or ask on javascript@lists.facebook.com before writing yet
781 * another copy of "event || window.event".
782 *
783 */
784
785 var _populated = false;
786
787 // Browsers
788 var _ie, _firefox, _opera, _webkit, _chrome;
789
790 // Actual IE browser for compatibility mode
791 var _ie_real_version;
792
793 // Platforms
794 var _osx, _windows, _linux, _android;
795
796 // Architectures
797 var _win64;
798
799 // Devices
800 var _iphone, _ipad, _native;
801
802 var _mobile;
803
804 function _populate() {
805 if (_populated) {
806 return;
807 }
808
809 _populated = true;
810
811 // To work around buggy JS libraries that can't handle multi-digit
812 // version numbers, Opera 10's user agent string claims it's Opera
813 // 9, then later includes a Version/X.Y field:
814 //
815 // Opera/9.80 (foo) Presto/2.2.15 Version/10.10
816 var uas = navigator.userAgent;
817 var agent = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(uas);
818 var os = /(Mac OS X)|(Windows)|(Linux)/.exec(uas);
819
820 _iphone = /\b(iPhone|iP[ao]d)/.exec(uas);
821 _ipad = /\b(iP[ao]d)/.exec(uas);
822 _android = /Android/i.exec(uas);
823 _native = /FBAN\/\w+;/i.exec(uas);
824 _mobile = /Mobile/i.exec(uas);
825
826 // Note that the IE team blog would have you believe you should be checking
827 // for 'Win64; x64'. But MSDN then reveals that you can actually be coming
828 // from either x64 or ia64; so ultimately, you should just check for Win64
829 // as in indicator of whether you're in 64-bit IE. 32-bit IE on 64-bit
830 // Windows will send 'WOW64' instead.
831 _win64 = !!(/Win64/.exec(uas));
832
833 if (agent) {
834 _ie = agent[1] ? parseFloat(agent[1]) : (
835 agent[5] ? parseFloat(agent[5]) : NaN);
836 // IE compatibility mode
837 if (_ie && document && document.documentMode) {
838 _ie = document.documentMode;
839 }
840 // grab the "true" ie version from the trident token if available
841 var trident = /(?:Trident\/(\d+.\d+))/.exec(uas);
842 _ie_real_version = trident ? parseFloat(trident[1]) + 4 : _ie;
843
844 _firefox = agent[2] ? parseFloat(agent[2]) : NaN;
845 _opera = agent[3] ? parseFloat(agent[3]) : NaN;
846 _webkit = agent[4] ? parseFloat(agent[4]) : NaN;
847 if (_webkit) {
848 // We do not add the regexp to the above test, because it will always
849 // match 'safari' only since 'AppleWebKit' appears before 'Chrome' in
850 // the userAgent string.
851 agent = /(?:Chrome\/(\d+\.\d+))/.exec(uas);
852 _chrome = agent && agent[1] ? parseFloat(agent[1]) : NaN;
853 } else {
854 _chrome = NaN;
855 }
856 } else {
857 _ie = _firefox = _opera = _chrome = _webkit = NaN;
858 }
859
860 if (os) {
861 if (os[1]) {
862 // Detect OS X version. If no version number matches, set _osx to true.
863 // Version examples: 10, 10_6_1, 10.7
864 // Parses version number as a float, taking only first two sets of
865 // digits. If only one set of digits is found, returns just the major
866 // version number.
867 var ver = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(uas);
868
869 _osx = ver ? parseFloat(ver[1].replace('_', '.')) : true;
870 } else {
871 _osx = false;
872 }
873 _windows = !!os[2];
874 _linux = !!os[3];
875 } else {
876 _osx = _windows = _linux = false;
877 }
878 }
879
880 var UserAgent_DEPRECATED = {
881
882 /**
883 * Check if the UA is Internet Explorer.
884 *
885 *
886 * @return float|NaN Version number (if match) or NaN.
887 */
888 ie: function() {
889 return _populate() || _ie;
890 },
891
892 /**
893 * Check if we're in Internet Explorer compatibility mode.
894 *
895 * @return bool true if in compatibility mode, false if
896 * not compatibility mode or not ie
897 */
898 ieCompatibilityMode: function() {
899 return _populate() || (_ie_real_version > _ie);
900 },
901
902
903 /**
904 * Whether the browser is 64-bit IE. Really, this is kind of weak sauce; we
905 * only need this because Skype can't handle 64-bit IE yet. We need to remove
906 * this when we don't need it -- tracked by #601957.
907 */
908 ie64: function() {
909 return UserAgent_DEPRECATED.ie() && _win64;
910 },
911
912 /**
913 * Check if the UA is Firefox.
914 *
915 *
916 * @return float|NaN Version number (if match) or NaN.
917 */
918 firefox: function() {
919 return _populate() || _firefox;
920 },
921
922
923 /**
924 * Check if the UA is Opera.
925 *
926 *
927 * @return float|NaN Version number (if match) or NaN.
928 */
929 opera: function() {
930 return _populate() || _opera;
931 },
932
933
934 /**
935 * Check if the UA is WebKit.
936 *
937 *
938 * @return float|NaN Version number (if match) or NaN.
939 */
940 webkit: function() {
941 return _populate() || _webkit;
942 },
943
944 /**
945 * For Push
946 * WILL BE REMOVED VERY SOON. Use UserAgent_DEPRECATED.webkit
947 */
948 safari: function() {
949 return UserAgent_DEPRECATED.webkit();
950 },
951
952 /**
953 * Check if the UA is a Chrome browser.
954 *
955 *
956 * @return float|NaN Version number (if match) or NaN.
957 */
958 chrome : function() {
959 return _populate() || _chrome;
960 },
961
962
963 /**
964 * Check if the user is running Windows.
965 *
966 * @return bool `true' if the user's OS is Windows.
967 */
968 windows: function() {
969 return _populate() || _windows;
970 },
971
972
973 /**
974 * Check if the user is running Mac OS X.
975 *
976 * @return float|bool Returns a float if a version number is detected,
977 * otherwise true/false.
978 */
979 osx: function() {
980 return _populate() || _osx;
981 },
982
983 /**
984 * Check if the user is running Linux.
985 *
986 * @return bool `true' if the user's OS is some flavor of Linux.
987 */
988 linux: function() {
989 return _populate() || _linux;
990 },
991
992 /**
993 * Check if the user is running on an iPhone or iPod platform.
994 *
995 * @return bool `true' if the user is running some flavor of the
996 * iPhone OS.
997 */
998 iphone: function() {
999 return _populate() || _iphone;
1000 },
1001
1002 mobile: function() {
1003 return _populate() || (_iphone || _ipad || _android || _mobile);
1004 },
1005
1006 nativeApp: function() {
1007 // webviews inside of the native apps
1008 return _populate() || _native;
1009 },
1010
1011 android: function() {
1012 return _populate() || _android;
1013 },
1014
1015 ipad: function() {
1016 return _populate() || _ipad;
1017 }
1018 };
1019
1020 module.exports = UserAgent_DEPRECATED;
1021
1022
1023 /***/ }),
1024
1025 /***/ "./node_modules/normalize-wheel/src/isEventSupported.js":
1026 /*!**************************************************************!*\
1027 !*** ./node_modules/normalize-wheel/src/isEventSupported.js ***!
1028 \**************************************************************/
1029 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1030
1031 "use strict";
1032 /**
1033 * Copyright 2013-2015, Facebook, Inc.
1034 * All rights reserved.
1035 *
1036 * This source code is licensed under the BSD-style license found in the
1037 * LICENSE file in the root directory of this source tree. An additional grant
1038 * of patent rights can be found in the PATENTS file in the same directory.
1039 *
1040 * @providesModule isEventSupported
1041 */
1042
1043
1044
1045 var ExecutionEnvironment = __webpack_require__(/*! ./ExecutionEnvironment */ "./node_modules/normalize-wheel/src/ExecutionEnvironment.js");
1046
1047 var useHasFeature;
1048 if (ExecutionEnvironment.canUseDOM) {
1049 useHasFeature =
1050 document.implementation &&
1051 document.implementation.hasFeature &&
1052 // always returns true in newer browsers as per the standard.
1053 // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
1054 document.implementation.hasFeature('', '') !== true;
1055 }
1056
1057 /**
1058 * Checks if an event is supported in the current execution environment.
1059 *
1060 * NOTE: This will not work correctly for non-generic events such as `change`,
1061 * `reset`, `load`, `error`, and `select`.
1062 *
1063 * Borrows from Modernizr.
1064 *
1065 * @param {string} eventNameSuffix Event name, e.g. "click".
1066 * @param {?boolean} capture Check if the capture phase is supported.
1067 * @return {boolean} True if the event is supported.
1068 * @internal
1069 * @license Modernizr 3.0.0pre (Custom Build) | MIT
1070 */
1071 function isEventSupported(eventNameSuffix, capture) {
1072 if (!ExecutionEnvironment.canUseDOM ||
1073 capture && !('addEventListener' in document)) {
1074 return false;
1075 }
1076
1077 var eventName = 'on' + eventNameSuffix;
1078 var isSupported = eventName in document;
1079
1080 if (!isSupported) {
1081 var element = document.createElement('div');
1082 element.setAttribute(eventName, 'return;');
1083 isSupported = typeof element[eventName] === 'function';
1084 }
1085
1086 if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
1087 // This is the only way to test support for the `wheel` event in IE9+.
1088 isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
1089 }
1090
1091 return isSupported;
1092 }
1093
1094 module.exports = isEventSupported;
1095
1096
1097 /***/ }),
1098
1099 /***/ "./node_modules/normalize-wheel/src/normalizeWheel.js":
1100 /*!************************************************************!*\
1101 !*** ./node_modules/normalize-wheel/src/normalizeWheel.js ***!
1102 \************************************************************/
1103 /***/ (function(module, __unused_webpack_exports, __webpack_require__) {
1104
1105 "use strict";
1106 /**
1107 * Copyright (c) 2015, Facebook, Inc.
1108 * All rights reserved.
1109 *
1110 * This source code is licensed under the BSD-style license found in the
1111 * LICENSE file in the root directory of this source tree. An additional grant
1112 * of patent rights can be found in the PATENTS file in the same directory.
1113 *
1114 * @providesModule normalizeWheel
1115 * @typechecks
1116 */
1117
1118
1119
1120 var UserAgent_DEPRECATED = __webpack_require__(/*! ./UserAgent_DEPRECATED */ "./node_modules/normalize-wheel/src/UserAgent_DEPRECATED.js");
1121
1122 var isEventSupported = __webpack_require__(/*! ./isEventSupported */ "./node_modules/normalize-wheel/src/isEventSupported.js");
1123
1124
1125 // Reasonable defaults
1126 var PIXEL_STEP = 10;
1127 var LINE_HEIGHT = 40;
1128 var PAGE_HEIGHT = 800;
1129
1130 /**
1131 * Mouse wheel (and 2-finger trackpad) support on the web sucks. It is
1132 * complicated, thus this doc is long and (hopefully) detailed enough to answer
1133 * your questions.
1134 *
1135 * If you need to react to the mouse wheel in a predictable way, this code is
1136 * like your bestest friend. * hugs *
1137 *
1138 * As of today, there are 4 DOM event types you can listen to:
1139 *
1140 * 'wheel' -- Chrome(31+), FF(17+), IE(9+)
1141 * 'mousewheel' -- Chrome, IE(6+), Opera, Safari
1142 * 'MozMousePixelScroll' -- FF(3.5 only!) (2010-2013) -- don't bother!
1143 * 'DOMMouseScroll' -- FF(0.9.7+) since 2003
1144 *
1145 * So what to do? The is the best:
1146 *
1147 * normalizeWheel.getEventType();
1148 *
1149 * In your event callback, use this code to get sane interpretation of the
1150 * deltas. This code will return an object with properties:
1151 *
1152 * spinX -- normalized spin speed (use for zoom) - x plane
1153 * spinY -- " - y plane
1154 * pixelX -- normalized distance (to pixels) - x plane
1155 * pixelY -- " - y plane
1156 *
1157 * Wheel values are provided by the browser assuming you are using the wheel to
1158 * scroll a web page by a number of lines or pixels (or pages). Values can vary
1159 * significantly on different platforms and browsers, forgetting that you can
1160 * scroll at different speeds. Some devices (like trackpads) emit more events
1161 * at smaller increments with fine granularity, and some emit massive jumps with
1162 * linear speed or acceleration.
1163 *
1164 * This code does its best to normalize the deltas for you:
1165 *
1166 * - spin is trying to normalize how far the wheel was spun (or trackpad
1167 * dragged). This is super useful for zoom support where you want to
1168 * throw away the chunky scroll steps on the PC and make those equal to
1169 * the slow and smooth tiny steps on the Mac. Key data: This code tries to
1170 * resolve a single slow step on a wheel to 1.
1171 *
1172 * - pixel is normalizing the desired scroll delta in pixel units. You'll
1173 * get the crazy differences between browsers, but at least it'll be in
1174 * pixels!
1175 *
1176 * - positive value indicates scrolling DOWN/RIGHT, negative UP/LEFT. This
1177 * should translate to positive value zooming IN, negative zooming OUT.
1178 * This matches the newer 'wheel' event.
1179 *
1180 * Why are there spinX, spinY (or pixels)?
1181 *
1182 * - spinX is a 2-finger side drag on the trackpad, and a shift + wheel turn
1183 * with a mouse. It results in side-scrolling in the browser by default.
1184 *
1185 * - spinY is what you expect -- it's the classic axis of a mouse wheel.
1186 *
1187 * - I dropped spinZ/pixelZ. It is supported by the DOM 3 'wheel' event and
1188 * probably is by browsers in conjunction with fancy 3D controllers .. but
1189 * you know.
1190 *
1191 * Implementation info:
1192 *
1193 * Examples of 'wheel' event if you scroll slowly (down) by one step with an
1194 * average mouse:
1195 *
1196 * OS X + Chrome (mouse) - 4 pixel delta (wheelDelta -120)
1197 * OS X + Safari (mouse) - N/A pixel delta (wheelDelta -12)
1198 * OS X + Firefox (mouse) - 0.1 line delta (wheelDelta N/A)
1199 * Win8 + Chrome (mouse) - 100 pixel delta (wheelDelta -120)
1200 * Win8 + Firefox (mouse) - 3 line delta (wheelDelta -120)
1201 *
1202 * On the trackpad:
1203 *
1204 * OS X + Chrome (trackpad) - 2 pixel delta (wheelDelta -6)
1205 * OS X + Firefox (trackpad) - 1 pixel delta (wheelDelta N/A)
1206 *
1207 * On other/older browsers.. it's more complicated as there can be multiple and
1208 * also missing delta values.
1209 *
1210 * The 'wheel' event is more standard:
1211 *
1212 * http://www.w3.org/TR/DOM-Level-3-Events/#events-wheelevents
1213 *
1214 * The basics is that it includes a unit, deltaMode (pixels, lines, pages), and
1215 * deltaX, deltaY and deltaZ. Some browsers provide other values to maintain
1216 * backward compatibility with older events. Those other values help us
1217 * better normalize spin speed. Example of what the browsers provide:
1218 *
1219 * | event.wheelDelta | event.detail
1220 * ------------------+------------------+--------------
1221 * Safari v5/OS X | -120 | 0
1222 * Safari v5/Win7 | -120 | 0
1223 * Chrome v17/OS X | -120 | 0
1224 * Chrome v17/Win7 | -120 | 0
1225 * IE9/Win7 | -120 | undefined
1226 * Firefox v4/OS X | undefined | 1
1227 * Firefox v4/Win7 | undefined | 3
1228 *
1229 */
1230 function normalizeWheel(/*object*/ event) /*object*/ {
1231 var sX = 0, sY = 0, // spinX, spinY
1232 pX = 0, pY = 0; // pixelX, pixelY
1233
1234 // Legacy
1235 if ('detail' in event) { sY = event.detail; }
1236 if ('wheelDelta' in event) { sY = -event.wheelDelta / 120; }
1237 if ('wheelDeltaY' in event) { sY = -event.wheelDeltaY / 120; }
1238 if ('wheelDeltaX' in event) { sX = -event.wheelDeltaX / 120; }
1239
1240 // side scrolling on FF with DOMMouseScroll
1241 if ( 'axis' in event && event.axis === event.HORIZONTAL_AXIS ) {
1242 sX = sY;
1243 sY = 0;
1244 }
1245
1246 pX = sX * PIXEL_STEP;
1247 pY = sY * PIXEL_STEP;
1248
1249 if ('deltaY' in event) { pY = event.deltaY; }
1250 if ('deltaX' in event) { pX = event.deltaX; }
1251
1252 if ((pX || pY) && event.deltaMode) {
1253 if (event.deltaMode == 1) { // delta in LINE units
1254 pX *= LINE_HEIGHT;
1255 pY *= LINE_HEIGHT;
1256 } else { // delta in PAGE units
1257 pX *= PAGE_HEIGHT;
1258 pY *= PAGE_HEIGHT;
1259 }
1260 }
1261
1262 // Fall-back if spin cannot be determined
1263 if (pX && !sX) { sX = (pX < 1) ? -1 : 1; }
1264 if (pY && !sY) { sY = (pY < 1) ? -1 : 1; }
1265
1266 return { spinX : sX,
1267 spinY : sY,
1268 pixelX : pX,
1269 pixelY : pY };
1270 }
1271
1272
1273 /**
1274 * The best combination if you prefer spinX + spinY normalization. It favors
1275 * the older DOMMouseScroll for Firefox, as FF does not include wheelDelta with
1276 * 'wheel' event, making spin speed determination impossible.
1277 */
1278 normalizeWheel.getEventType = function() /*string*/ {
1279 return (UserAgent_DEPRECATED.firefox())
1280 ? 'DOMMouseScroll'
1281 : (isEventSupported('wheel'))
1282 ? 'wheel'
1283 : 'mousewheel';
1284 };
1285
1286 module.exports = normalizeWheel;
1287
1288
1289 /***/ }),
1290
1291 /***/ "./node_modules/react-easy-crop/index.module.js":
1292 /*!******************************************************!*\
1293 !*** ./node_modules/react-easy-crop/index.module.js ***!
1294 \******************************************************/
1295 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
1296
1297 "use strict";
1298 __webpack_require__.r(__webpack_exports__);
1299 /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js");
1300 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react */ "react");
1301 /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
1302 /* harmony import */ var normalize_wheel__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! normalize-wheel */ "./node_modules/normalize-wheel/index.js");
1303 /* harmony import */ var normalize_wheel__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(normalize_wheel__WEBPACK_IMPORTED_MODULE_1__);
1304
1305
1306
1307
1308 /**
1309 * Compute the dimension of the crop area based on media size,
1310 * aspect ratio and optionally rotation
1311 */
1312
1313 function getCropSize(mediaWidth, mediaHeight, containerWidth, containerHeight, aspect, rotation) {
1314 if (rotation === void 0) {
1315 rotation = 0;
1316 }
1317
1318 var _a = rotateSize(mediaWidth, mediaHeight, rotation),
1319 width = _a.width,
1320 height = _a.height;
1321
1322 var fittingWidth = Math.min(width, containerWidth);
1323 var fittingHeight = Math.min(height, containerHeight);
1324
1325 if (fittingWidth > fittingHeight * aspect) {
1326 return {
1327 width: fittingHeight * aspect,
1328 height: fittingHeight
1329 };
1330 }
1331
1332 return {
1333 width: fittingWidth,
1334 height: fittingWidth / aspect
1335 };
1336 }
1337 /**
1338 * Compute media zoom.
1339 * We fit the media into the container with "max-width: 100%; max-height: 100%;"
1340 */
1341
1342 function getMediaZoom(mediaSize) {
1343 // Take the axis with more pixels to improve accuracy
1344 return mediaSize.width > mediaSize.height ? mediaSize.width / mediaSize.naturalWidth : mediaSize.height / mediaSize.naturalHeight;
1345 }
1346 /**
1347 * Ensure a new media position stays in the crop area.
1348 */
1349
1350 function restrictPosition(position, mediaSize, cropSize, zoom, rotation) {
1351 if (rotation === void 0) {
1352 rotation = 0;
1353 }
1354
1355 var _a = rotateSize(mediaSize.width, mediaSize.height, rotation),
1356 width = _a.width,
1357 height = _a.height;
1358
1359 return {
1360 x: restrictPositionCoord(position.x, width, cropSize.width, zoom),
1361 y: restrictPositionCoord(position.y, height, cropSize.height, zoom)
1362 };
1363 }
1364
1365 function restrictPositionCoord(position, mediaSize, cropSize, zoom) {
1366 var maxPosition = mediaSize * zoom / 2 - cropSize / 2;
1367 return clamp(position, -maxPosition, maxPosition);
1368 }
1369
1370 function getDistanceBetweenPoints(pointA, pointB) {
1371 return Math.sqrt(Math.pow(pointA.y - pointB.y, 2) + Math.pow(pointA.x - pointB.x, 2));
1372 }
1373 function getRotationBetweenPoints(pointA, pointB) {
1374 return Math.atan2(pointB.y - pointA.y, pointB.x - pointA.x) * 180 / Math.PI;
1375 }
1376 /**
1377 * Compute the output cropped area of the media in percentages and pixels.
1378 * x/y are the top-left coordinates on the src media
1379 */
1380
1381 function computeCroppedArea(crop, mediaSize, cropSize, aspect, zoom, rotation, restrictPosition) {
1382 if (rotation === void 0) {
1383 rotation = 0;
1384 }
1385
1386 if (restrictPosition === void 0) {
1387 restrictPosition = true;
1388 } // if the media is rotated by the user, we cannot limit the position anymore
1389 // as it might need to be negative.
1390
1391
1392 var limitAreaFn = restrictPosition ? limitArea : noOp;
1393 var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation);
1394 var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation); // calculate the crop area in percentages
1395 // in the rotated space
1396
1397 var croppedAreaPercentages = {
1398 x: limitAreaFn(100, ((mediaBBoxSize.width - cropSize.width / zoom) / 2 - crop.x / zoom) / mediaBBoxSize.width * 100),
1399 y: limitAreaFn(100, ((mediaBBoxSize.height - cropSize.height / zoom) / 2 - crop.y / zoom) / mediaBBoxSize.height * 100),
1400 width: limitAreaFn(100, cropSize.width / mediaBBoxSize.width * 100 / zoom),
1401 height: limitAreaFn(100, cropSize.height / mediaBBoxSize.height * 100 / zoom)
1402 }; // we compute the pixels size naively
1403
1404 var widthInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.width, croppedAreaPercentages.width * mediaNaturalBBoxSize.width / 100));
1405 var heightInPixels = Math.round(limitAreaFn(mediaNaturalBBoxSize.height, croppedAreaPercentages.height * mediaNaturalBBoxSize.height / 100));
1406 var isImgWiderThanHigh = mediaNaturalBBoxSize.width >= mediaNaturalBBoxSize.height * aspect; // then we ensure the width and height exactly match the aspect (to avoid rounding approximations)
1407 // if the media is wider than high, when zoom is 0, the crop height will be equals to image height
1408 // thus we want to compute the width from the height and aspect for accuracy.
1409 // Otherwise, we compute the height from width and aspect.
1410
1411 var sizePixels = isImgWiderThanHigh ? {
1412 width: Math.round(heightInPixels * aspect),
1413 height: heightInPixels
1414 } : {
1415 width: widthInPixels,
1416 height: Math.round(widthInPixels / aspect)
1417 };
1418
1419 var croppedAreaPixels = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, sizePixels), {
1420 x: Math.round(limitAreaFn(mediaNaturalBBoxSize.width - sizePixels.width, croppedAreaPercentages.x * mediaNaturalBBoxSize.width / 100)),
1421 y: Math.round(limitAreaFn(mediaNaturalBBoxSize.height - sizePixels.height, croppedAreaPercentages.y * mediaNaturalBBoxSize.height / 100))
1422 });
1423
1424 return {
1425 croppedAreaPercentages: croppedAreaPercentages,
1426 croppedAreaPixels: croppedAreaPixels
1427 };
1428 }
1429 /**
1430 * Ensure the returned value is between 0 and max
1431 */
1432
1433 function limitArea(max, value) {
1434 return Math.min(max, Math.max(0, value));
1435 }
1436
1437 function noOp(_max, value) {
1438 return value;
1439 }
1440 /**
1441 * Compute crop and zoom from the croppedAreaPercentages.
1442 */
1443
1444
1445 function getInitialCropFromCroppedAreaPercentages(croppedAreaPercentages, mediaSize, rotation, cropSize, minZoom, maxZoom) {
1446 var mediaBBoxSize = rotateSize(mediaSize.width, mediaSize.height, rotation); // This is the inverse process of computeCroppedArea
1447
1448 var zoom = clamp(cropSize.width / mediaBBoxSize.width * (100 / croppedAreaPercentages.width), minZoom, maxZoom);
1449 var crop = {
1450 x: zoom * mediaBBoxSize.width / 2 - cropSize.width / 2 - mediaBBoxSize.width * zoom * (croppedAreaPercentages.x / 100),
1451 y: zoom * mediaBBoxSize.height / 2 - cropSize.height / 2 - mediaBBoxSize.height * zoom * (croppedAreaPercentages.y / 100)
1452 };
1453 return {
1454 crop: crop,
1455 zoom: zoom
1456 };
1457 }
1458 /**
1459 * Compute zoom from the croppedAreaPixels
1460 */
1461
1462 function getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize) {
1463 var mediaZoom = getMediaZoom(mediaSize);
1464 return cropSize.height > cropSize.width ? cropSize.height / (croppedAreaPixels.height * mediaZoom) : cropSize.width / (croppedAreaPixels.width * mediaZoom);
1465 }
1466 /**
1467 * Compute crop and zoom from the croppedAreaPixels
1468 */
1469
1470
1471 function getInitialCropFromCroppedAreaPixels(croppedAreaPixels, mediaSize, rotation, cropSize, minZoom, maxZoom) {
1472 if (rotation === void 0) {
1473 rotation = 0;
1474 }
1475
1476 var mediaNaturalBBoxSize = rotateSize(mediaSize.naturalWidth, mediaSize.naturalHeight, rotation);
1477 var zoom = clamp(getZoomFromCroppedAreaPixels(croppedAreaPixels, mediaSize, cropSize), minZoom, maxZoom);
1478 var cropZoom = cropSize.height > cropSize.width ? cropSize.height / croppedAreaPixels.height : cropSize.width / croppedAreaPixels.width;
1479 var crop = {
1480 x: ((mediaNaturalBBoxSize.width - croppedAreaPixels.width) / 2 - croppedAreaPixels.x) * cropZoom,
1481 y: ((mediaNaturalBBoxSize.height - croppedAreaPixels.height) / 2 - croppedAreaPixels.y) * cropZoom
1482 };
1483 return {
1484 crop: crop,
1485 zoom: zoom
1486 };
1487 }
1488 /**
1489 * Return the point that is the center of point a and b
1490 */
1491
1492 function getCenter(a, b) {
1493 return {
1494 x: (b.x + a.x) / 2,
1495 y: (b.y + a.y) / 2
1496 };
1497 }
1498 function getRadianAngle(degreeValue) {
1499 return degreeValue * Math.PI / 180;
1500 }
1501 /**
1502 * Returns the new bounding area of a rotated rectangle.
1503 */
1504
1505 function rotateSize(width, height, rotation) {
1506 var rotRad = getRadianAngle(rotation);
1507 return {
1508 width: Math.abs(Math.cos(rotRad) * width) + Math.abs(Math.sin(rotRad) * height),
1509 height: Math.abs(Math.sin(rotRad) * width) + Math.abs(Math.cos(rotRad) * height)
1510 };
1511 }
1512 /**
1513 * Clamp value between min and max
1514 */
1515
1516 function clamp(value, min, max) {
1517 return Math.min(Math.max(value, min), max);
1518 }
1519 /**
1520 * Combine multiple class names into a single string.
1521 */
1522
1523 function classNames() {
1524 var args = [];
1525
1526 for (var _i = 0; _i < arguments.length; _i++) {
1527 args[_i] = arguments[_i];
1528 }
1529
1530 return args.filter(function (value) {
1531 if (typeof value === 'string' && value.length > 0) {
1532 return true;
1533 }
1534
1535 return false;
1536 }).join(' ').trim();
1537 }
1538
1539 var css_248z = ".reactEasyCrop_Container {\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n overflow: hidden;\n user-select: none;\n touch-action: none;\n cursor: move;\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.reactEasyCrop_Image,\n.reactEasyCrop_Video {\n will-change: transform; /* this improves performances and prevent painting issues on iOS Chrome */\n}\n\n.reactEasyCrop_Contain {\n max-width: 100%;\n max-height: 100%;\n margin: auto;\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n}\n.reactEasyCrop_Cover_Horizontal {\n width: 100%;\n height: auto;\n}\n.reactEasyCrop_Cover_Vertical {\n width: auto;\n height: 100%;\n}\n\n.reactEasyCrop_CropArea {\n position: absolute;\n left: 50%;\n top: 50%;\n transform: translate(-50%, -50%);\n border: 1px solid rgba(255, 255, 255, 0.5);\n box-sizing: border-box;\n box-shadow: 0 0 0 9999em;\n color: rgba(0, 0, 0, 0.5);\n overflow: hidden;\n}\n\n.reactEasyCrop_CropAreaRound {\n border-radius: 50%;\n}\n\n.reactEasyCrop_CropAreaGrid::before {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 0;\n bottom: 0;\n left: 33.33%;\n right: 33.33%;\n border-top: 0;\n border-bottom: 0;\n}\n\n.reactEasyCrop_CropAreaGrid::after {\n content: ' ';\n box-sizing: border-box;\n position: absolute;\n border: 1px solid rgba(255, 255, 255, 0.5);\n top: 33.33%;\n bottom: 33.33%;\n left: 0;\n right: 0;\n border-left: 0;\n border-right: 0;\n}\n";
1540
1541 var MIN_ZOOM = 1;
1542 var MAX_ZOOM = 3;
1543
1544 var Cropper =
1545 /** @class */
1546 function (_super) {
1547 (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(Cropper, _super);
1548
1549 function Cropper() {
1550 var _this = _super !== null && _super.apply(this, arguments) || this;
1551
1552 _this.imageRef = null;
1553 _this.videoRef = null;
1554 _this.containerRef = null;
1555 _this.styleRef = null;
1556 _this.containerRect = null;
1557 _this.mediaSize = {
1558 width: 0,
1559 height: 0,
1560 naturalWidth: 0,
1561 naturalHeight: 0
1562 };
1563 _this.dragStartPosition = {
1564 x: 0,
1565 y: 0
1566 };
1567 _this.dragStartCrop = {
1568 x: 0,
1569 y: 0
1570 };
1571 _this.lastPinchDistance = 0;
1572 _this.lastPinchRotation = 0;
1573 _this.rafDragTimeout = null;
1574 _this.rafPinchTimeout = null;
1575 _this.wheelTimer = null;
1576 _this.state = {
1577 cropSize: null,
1578 hasWheelJustStarted: false
1579 }; // this is to prevent Safari on iOS >= 10 to zoom the page
1580
1581 _this.preventZoomSafari = function (e) {
1582 return e.preventDefault();
1583 };
1584
1585 _this.cleanEvents = function () {
1586 document.removeEventListener('mousemove', _this.onMouseMove);
1587 document.removeEventListener('mouseup', _this.onDragStopped);
1588 document.removeEventListener('touchmove', _this.onTouchMove);
1589 document.removeEventListener('touchend', _this.onDragStopped);
1590 };
1591
1592 _this.clearScrollEvent = function () {
1593 if (_this.containerRef) _this.containerRef.removeEventListener('wheel', _this.onWheel);
1594
1595 if (_this.wheelTimer) {
1596 clearTimeout(_this.wheelTimer);
1597 }
1598 };
1599
1600 _this.onMediaLoad = function () {
1601 var cropSize = _this.computeSizes();
1602
1603 if (cropSize) {
1604 _this.emitCropData();
1605
1606 _this.setInitialCrop(cropSize);
1607 }
1608
1609 if (_this.props.onMediaLoaded) {
1610 _this.props.onMediaLoaded(_this.mediaSize);
1611 }
1612 };
1613
1614 _this.setInitialCrop = function (cropSize) {
1615 if (_this.props.initialCroppedAreaPercentages) {
1616 var _a = getInitialCropFromCroppedAreaPercentages(_this.props.initialCroppedAreaPercentages, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom),
1617 crop = _a.crop,
1618 zoom = _a.zoom;
1619
1620 _this.props.onCropChange(crop);
1621
1622 _this.props.onZoomChange && _this.props.onZoomChange(zoom);
1623 } else if (_this.props.initialCroppedAreaPixels) {
1624 var _b = getInitialCropFromCroppedAreaPixels(_this.props.initialCroppedAreaPixels, _this.mediaSize, _this.props.rotation, cropSize, _this.props.minZoom, _this.props.maxZoom),
1625 crop = _b.crop,
1626 zoom = _b.zoom;
1627
1628 _this.props.onCropChange(crop);
1629
1630 _this.props.onZoomChange && _this.props.onZoomChange(zoom);
1631 }
1632 };
1633
1634 _this.computeSizes = function () {
1635 var _a, _b, _c, _d, _e, _f;
1636
1637 var mediaRef = _this.imageRef || _this.videoRef;
1638
1639 if (mediaRef && _this.containerRef) {
1640 _this.containerRect = _this.containerRef.getBoundingClientRect();
1641 var containerAspect = _this.containerRect.width / _this.containerRect.height;
1642 var naturalWidth = ((_a = _this.imageRef) === null || _a === void 0 ? void 0 : _a.naturalWidth) || ((_b = _this.videoRef) === null || _b === void 0 ? void 0 : _b.videoWidth) || 0;
1643 var naturalHeight = ((_c = _this.imageRef) === null || _c === void 0 ? void 0 : _c.naturalHeight) || ((_d = _this.videoRef) === null || _d === void 0 ? void 0 : _d.videoHeight) || 0;
1644 var isMediaScaledDown = mediaRef.offsetWidth < naturalWidth || mediaRef.offsetHeight < naturalHeight;
1645 var mediaAspect = naturalWidth / naturalHeight; // We do not rely on the offsetWidth/offsetHeight if the media is scaled down
1646 // as the values they report are rounded. That will result in precision losses
1647 // when calculating zoom. We use the fact that the media is positionned relative
1648 // to the container. That allows us to use the container's dimensions
1649 // and natural aspect ratio of the media to calculate accurate media size.
1650 // However, for this to work, the container should not be rotated
1651
1652 var renderedMediaSize = void 0;
1653
1654 if (isMediaScaledDown) {
1655 switch (_this.props.objectFit) {
1656 default:
1657 case 'contain':
1658 renderedMediaSize = containerAspect > mediaAspect ? {
1659 width: _this.containerRect.height * mediaAspect,
1660 height: _this.containerRect.height
1661 } : {
1662 width: _this.containerRect.width,
1663 height: _this.containerRect.width / mediaAspect
1664 };
1665 break;
1666
1667 case 'horizontal-cover':
1668 renderedMediaSize = {
1669 width: _this.containerRect.width,
1670 height: _this.containerRect.width / mediaAspect
1671 };
1672 break;
1673
1674 case 'vertical-cover':
1675 renderedMediaSize = {
1676 width: _this.containerRect.height * mediaAspect,
1677 height: _this.containerRect.height
1678 };
1679 break;
1680 }
1681 } else {
1682 renderedMediaSize = {
1683 width: mediaRef.offsetWidth,
1684 height: mediaRef.offsetHeight
1685 };
1686 }
1687
1688 _this.mediaSize = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, renderedMediaSize), {
1689 naturalWidth: naturalWidth,
1690 naturalHeight: naturalHeight
1691 });
1692 var cropSize = _this.props.cropSize ? _this.props.cropSize : getCropSize(_this.mediaSize.width, _this.mediaSize.height, _this.containerRect.width, _this.containerRect.height, _this.props.aspect, _this.props.rotation);
1693
1694 if (((_e = _this.state.cropSize) === null || _e === void 0 ? void 0 : _e.height) !== cropSize.height || ((_f = _this.state.cropSize) === null || _f === void 0 ? void 0 : _f.width) !== cropSize.width) {
1695 _this.props.onCropSizeChange && _this.props.onCropSizeChange(cropSize);
1696 }
1697
1698 _this.setState({
1699 cropSize: cropSize
1700 }, _this.recomputeCropPosition);
1701
1702 return cropSize;
1703 }
1704 };
1705
1706 _this.onMouseDown = function (e) {
1707 e.preventDefault();
1708 document.addEventListener('mousemove', _this.onMouseMove);
1709 document.addEventListener('mouseup', _this.onDragStopped);
1710
1711 _this.onDragStart(Cropper.getMousePoint(e));
1712 };
1713
1714 _this.onMouseMove = function (e) {
1715 return _this.onDrag(Cropper.getMousePoint(e));
1716 };
1717
1718 _this.onTouchStart = function (e) {
1719 if (_this.props.onTouchRequest && !_this.props.onTouchRequest(e)) {
1720 return;
1721 }
1722
1723 document.addEventListener('touchmove', _this.onTouchMove, {
1724 passive: false
1725 }); // iOS 11 now defaults to passive: true
1726
1727 document.addEventListener('touchend', _this.onDragStopped);
1728
1729 if (e.touches.length === 2) {
1730 _this.onPinchStart(e);
1731 } else if (e.touches.length === 1) {
1732 _this.onDragStart(Cropper.getTouchPoint(e.touches[0]));
1733 }
1734 };
1735
1736 _this.onTouchMove = function (e) {
1737 // Prevent whole page from scrolling on iOS.
1738 e.preventDefault();
1739
1740 if (e.touches.length === 2) {
1741 _this.onPinchMove(e);
1742 } else if (e.touches.length === 1) {
1743 _this.onDrag(Cropper.getTouchPoint(e.touches[0]));
1744 }
1745 };
1746
1747 _this.onDragStart = function (_a) {
1748 var _b, _c;
1749
1750 var x = _a.x,
1751 y = _a.y;
1752 _this.dragStartPosition = {
1753 x: x,
1754 y: y
1755 };
1756 _this.dragStartCrop = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, _this.props.crop);
1757 (_c = (_b = _this.props).onInteractionStart) === null || _c === void 0 ? void 0 : _c.call(_b);
1758 };
1759
1760 _this.onDrag = function (_a) {
1761 var x = _a.x,
1762 y = _a.y;
1763 if (_this.rafDragTimeout) window.cancelAnimationFrame(_this.rafDragTimeout);
1764 _this.rafDragTimeout = window.requestAnimationFrame(function () {
1765 if (!_this.state.cropSize) return;
1766 if (x === undefined || y === undefined) return;
1767 var offsetX = x - _this.dragStartPosition.x;
1768 var offsetY = y - _this.dragStartPosition.y;
1769 var requestedPosition = {
1770 x: _this.dragStartCrop.x + offsetX,
1771 y: _this.dragStartCrop.y + offsetY
1772 };
1773 var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : requestedPosition;
1774
1775 _this.props.onCropChange(newPosition);
1776 });
1777 };
1778
1779 _this.onDragStopped = function () {
1780 var _a, _b;
1781
1782 _this.cleanEvents();
1783
1784 _this.emitCropData();
1785
1786 (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
1787 };
1788
1789 _this.onWheel = function (e) {
1790 if (_this.props.onWheelRequest && !_this.props.onWheelRequest(e)) {
1791 return;
1792 }
1793
1794 e.preventDefault();
1795 var point = Cropper.getMousePoint(e);
1796 var pixelY = normalize_wheel__WEBPACK_IMPORTED_MODULE_1___default()(e).pixelY;
1797 var newZoom = _this.props.zoom - pixelY * _this.props.zoomSpeed / 200;
1798
1799 _this.setNewZoom(newZoom, point);
1800
1801 if (!_this.state.hasWheelJustStarted) {
1802 _this.setState({
1803 hasWheelJustStarted: true
1804 }, function () {
1805 var _a, _b;
1806
1807 return (_b = (_a = _this.props).onInteractionStart) === null || _b === void 0 ? void 0 : _b.call(_a);
1808 });
1809 }
1810
1811 if (_this.wheelTimer) {
1812 clearTimeout(_this.wheelTimer);
1813 }
1814
1815 _this.wheelTimer = window.setTimeout(function () {
1816 return _this.setState({
1817 hasWheelJustStarted: false
1818 }, function () {
1819 var _a, _b;
1820
1821 return (_b = (_a = _this.props).onInteractionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);
1822 });
1823 }, 250);
1824 };
1825
1826 _this.getPointOnContainer = function (_a) {
1827 var x = _a.x,
1828 y = _a.y;
1829
1830 if (!_this.containerRect) {
1831 throw new Error('The Cropper is not mounted');
1832 }
1833
1834 return {
1835 x: _this.containerRect.width / 2 - (x - _this.containerRect.left),
1836 y: _this.containerRect.height / 2 - (y - _this.containerRect.top)
1837 };
1838 };
1839
1840 _this.getPointOnMedia = function (_a) {
1841 var x = _a.x,
1842 y = _a.y;
1843 var _b = _this.props,
1844 crop = _b.crop,
1845 zoom = _b.zoom;
1846 return {
1847 x: (x + crop.x) / zoom,
1848 y: (y + crop.y) / zoom
1849 };
1850 };
1851
1852 _this.setNewZoom = function (zoom, point) {
1853 if (!_this.state.cropSize || !_this.props.onZoomChange) return;
1854
1855 var zoomPoint = _this.getPointOnContainer(point);
1856
1857 var zoomTarget = _this.getPointOnMedia(zoomPoint);
1858
1859 var newZoom = clamp(zoom, _this.props.minZoom, _this.props.maxZoom);
1860 var requestedPosition = {
1861 x: zoomTarget.x * newZoom - zoomPoint.x,
1862 y: zoomTarget.y * newZoom - zoomPoint.y
1863 };
1864 var newPosition = _this.props.restrictPosition ? restrictPosition(requestedPosition, _this.mediaSize, _this.state.cropSize, newZoom, _this.props.rotation) : requestedPosition;
1865
1866 _this.props.onCropChange(newPosition);
1867
1868 _this.props.onZoomChange(newZoom);
1869 };
1870
1871 _this.getCropData = function () {
1872 if (!_this.state.cropSize) {
1873 return null;
1874 } // this is to ensure the crop is correctly restricted after a zoom back (https://github.com/ValentinH/react-easy-crop/issues/6)
1875
1876
1877 var restrictedPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
1878 return computeCroppedArea(restrictedPosition, _this.mediaSize, _this.state.cropSize, _this.getAspect(), _this.props.zoom, _this.props.rotation, _this.props.restrictPosition);
1879 };
1880
1881 _this.emitCropData = function () {
1882 var cropData = _this.getCropData();
1883
1884 if (!cropData) return;
1885 var croppedAreaPercentages = cropData.croppedAreaPercentages,
1886 croppedAreaPixels = cropData.croppedAreaPixels;
1887
1888 if (_this.props.onCropComplete) {
1889 _this.props.onCropComplete(croppedAreaPercentages, croppedAreaPixels);
1890 }
1891
1892 if (_this.props.onCropAreaChange) {
1893 _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
1894 }
1895 };
1896
1897 _this.emitCropAreaChange = function () {
1898 var cropData = _this.getCropData();
1899
1900 if (!cropData) return;
1901 var croppedAreaPercentages = cropData.croppedAreaPercentages,
1902 croppedAreaPixels = cropData.croppedAreaPixels;
1903
1904 if (_this.props.onCropAreaChange) {
1905 _this.props.onCropAreaChange(croppedAreaPercentages, croppedAreaPixels);
1906 }
1907 };
1908
1909 _this.recomputeCropPosition = function () {
1910 if (!_this.state.cropSize) return;
1911 var newPosition = _this.props.restrictPosition ? restrictPosition(_this.props.crop, _this.mediaSize, _this.state.cropSize, _this.props.zoom, _this.props.rotation) : _this.props.crop;
1912
1913 _this.props.onCropChange(newPosition);
1914
1915 _this.emitCropData();
1916 };
1917
1918 return _this;
1919 }
1920
1921 Cropper.prototype.componentDidMount = function () {
1922 window.addEventListener('resize', this.computeSizes);
1923
1924 if (this.containerRef) {
1925 this.props.zoomWithScroll && this.containerRef.addEventListener('wheel', this.onWheel, {
1926 passive: false
1927 });
1928 this.containerRef.addEventListener('gesturestart', this.preventZoomSafari);
1929 this.containerRef.addEventListener('gesturechange', this.preventZoomSafari);
1930 }
1931
1932 if (!this.props.disableAutomaticStylesInjection) {
1933 this.styleRef = document.createElement('style');
1934 this.styleRef.setAttribute('type', 'text/css');
1935 this.styleRef.innerHTML = css_248z;
1936 document.head.appendChild(this.styleRef);
1937 } // when rendered via SSR, the image can already be loaded and its onLoad callback will never be called
1938
1939
1940 if (this.imageRef && this.imageRef.complete) {
1941 this.onMediaLoad();
1942 }
1943 };
1944
1945 Cropper.prototype.componentWillUnmount = function () {
1946 var _a;
1947
1948 window.removeEventListener('resize', this.computeSizes);
1949
1950 if (this.containerRef) {
1951 this.containerRef.removeEventListener('gesturestart', this.preventZoomSafari);
1952 this.containerRef.removeEventListener('gesturechange', this.preventZoomSafari);
1953 }
1954
1955 if (this.styleRef) {
1956 (_a = this.styleRef.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.styleRef);
1957 }
1958
1959 this.cleanEvents();
1960 this.props.zoomWithScroll && this.clearScrollEvent();
1961 };
1962
1963 Cropper.prototype.componentDidUpdate = function (prevProps) {
1964 var _a, _b, _c, _d, _e, _f, _g, _h, _j;
1965
1966 if (prevProps.rotation !== this.props.rotation) {
1967 this.computeSizes();
1968 this.recomputeCropPosition();
1969 } else if (prevProps.aspect !== this.props.aspect) {
1970 this.computeSizes();
1971 } else if (prevProps.zoom !== this.props.zoom) {
1972 this.recomputeCropPosition();
1973 } else if (((_a = prevProps.cropSize) === null || _a === void 0 ? void 0 : _a.height) !== ((_b = this.props.cropSize) === null || _b === void 0 ? void 0 : _b.height) || ((_c = prevProps.cropSize) === null || _c === void 0 ? void 0 : _c.width) !== ((_d = this.props.cropSize) === null || _d === void 0 ? void 0 : _d.width)) {
1974 this.computeSizes();
1975 } else if (((_e = prevProps.crop) === null || _e === void 0 ? void 0 : _e.x) !== ((_f = this.props.crop) === null || _f === void 0 ? void 0 : _f.x) || ((_g = prevProps.crop) === null || _g === void 0 ? void 0 : _g.y) !== ((_h = this.props.crop) === null || _h === void 0 ? void 0 : _h.y)) {
1976 this.emitCropAreaChange();
1977 }
1978
1979 if (prevProps.zoomWithScroll !== this.props.zoomWithScroll && this.containerRef) {
1980 this.props.zoomWithScroll ? this.containerRef.addEventListener('wheel', this.onWheel, {
1981 passive: false
1982 }) : this.clearScrollEvent();
1983 }
1984
1985 if (prevProps.video !== this.props.video) {
1986 (_j = this.videoRef) === null || _j === void 0 ? void 0 : _j.load();
1987 }
1988 };
1989
1990 Cropper.prototype.getAspect = function () {
1991 var _a = this.props,
1992 cropSize = _a.cropSize,
1993 aspect = _a.aspect;
1994
1995 if (cropSize) {
1996 return cropSize.width / cropSize.height;
1997 }
1998
1999 return aspect;
2000 };
2001
2002 Cropper.prototype.onPinchStart = function (e) {
2003 var pointA = Cropper.getTouchPoint(e.touches[0]);
2004 var pointB = Cropper.getTouchPoint(e.touches[1]);
2005 this.lastPinchDistance = getDistanceBetweenPoints(pointA, pointB);
2006 this.lastPinchRotation = getRotationBetweenPoints(pointA, pointB);
2007 this.onDragStart(getCenter(pointA, pointB));
2008 };
2009
2010 Cropper.prototype.onPinchMove = function (e) {
2011 var _this = this;
2012
2013 var pointA = Cropper.getTouchPoint(e.touches[0]);
2014 var pointB = Cropper.getTouchPoint(e.touches[1]);
2015 var center = getCenter(pointA, pointB);
2016 this.onDrag(center);
2017 if (this.rafPinchTimeout) window.cancelAnimationFrame(this.rafPinchTimeout);
2018 this.rafPinchTimeout = window.requestAnimationFrame(function () {
2019 var distance = getDistanceBetweenPoints(pointA, pointB);
2020 var newZoom = _this.props.zoom * (distance / _this.lastPinchDistance);
2021
2022 _this.setNewZoom(newZoom, center);
2023
2024 _this.lastPinchDistance = distance;
2025 var rotation = getRotationBetweenPoints(pointA, pointB);
2026 var newRotation = _this.props.rotation + (rotation - _this.lastPinchRotation);
2027 _this.props.onRotationChange && _this.props.onRotationChange(newRotation);
2028 _this.lastPinchRotation = rotation;
2029 });
2030 };
2031
2032 Cropper.prototype.render = function () {
2033 var _this = this;
2034
2035 var _a = this.props,
2036 image = _a.image,
2037 video = _a.video,
2038 mediaProps = _a.mediaProps,
2039 transform = _a.transform,
2040 _b = _a.crop,
2041 x = _b.x,
2042 y = _b.y,
2043 rotation = _a.rotation,
2044 zoom = _a.zoom,
2045 cropShape = _a.cropShape,
2046 showGrid = _a.showGrid,
2047 _c = _a.style,
2048 containerStyle = _c.containerStyle,
2049 cropAreaStyle = _c.cropAreaStyle,
2050 mediaStyle = _c.mediaStyle,
2051 _d = _a.classes,
2052 containerClassName = _d.containerClassName,
2053 cropAreaClassName = _d.cropAreaClassName,
2054 mediaClassName = _d.mediaClassName,
2055 objectFit = _a.objectFit;
2056 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
2057 onMouseDown: this.onMouseDown,
2058 onTouchStart: this.onTouchStart,
2059 ref: function ref(el) {
2060 return _this.containerRef = el;
2061 },
2062 "data-testid": "container",
2063 style: containerStyle,
2064 className: classNames('reactEasyCrop_Container', containerClassName)
2065 }, image ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("img", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({
2066 alt: "",
2067 className: classNames('reactEasyCrop_Image', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName)
2068 }, mediaProps, {
2069 src: image,
2070 ref: function ref(el) {
2071 return _this.imageRef = el;
2072 },
2073 style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), {
2074 transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
2075 }),
2076 onLoad: this.onMediaLoad
2077 })) : video && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("video", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({
2078 autoPlay: true,
2079 loop: true,
2080 muted: true,
2081 className: classNames('reactEasyCrop_Video', objectFit === 'contain' && 'reactEasyCrop_Contain', objectFit === 'horizontal-cover' && 'reactEasyCrop_Cover_Horizontal', objectFit === 'vertical-cover' && 'reactEasyCrop_Cover_Vertical', mediaClassName)
2082 }, mediaProps, {
2083 ref: function ref(el) {
2084 return _this.videoRef = el;
2085 },
2086 onLoadedMetadata: this.onMediaLoad,
2087 style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, mediaStyle), {
2088 transform: transform || "translate(" + x + "px, " + y + "px) rotate(" + rotation + "deg) scale(" + zoom + ")"
2089 }),
2090 controls: false
2091 }), (Array.isArray(video) ? video : [{
2092 src: video
2093 }]).map(function (item) {
2094 return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("source", (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({
2095 key: item.src
2096 }, item));
2097 })), this.state.cropSize && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
2098 style: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, cropAreaStyle), {
2099 width: this.state.cropSize.width,
2100 height: this.state.cropSize.height
2101 }),
2102 "data-testid": "cropper",
2103 className: classNames('reactEasyCrop_CropArea', cropShape === 'round' && 'reactEasyCrop_CropAreaRound', showGrid && 'reactEasyCrop_CropAreaGrid', cropAreaClassName)
2104 }));
2105 };
2106
2107 Cropper.defaultProps = {
2108 zoom: 1,
2109 rotation: 0,
2110 aspect: 4 / 3,
2111 maxZoom: MAX_ZOOM,
2112 minZoom: MIN_ZOOM,
2113 cropShape: 'rect',
2114 objectFit: 'contain',
2115 showGrid: true,
2116 style: {},
2117 classes: {},
2118 mediaProps: {},
2119 zoomSpeed: 1,
2120 restrictPosition: true,
2121 zoomWithScroll: true
2122 };
2123
2124 Cropper.getMousePoint = function (e) {
2125 return {
2126 x: Number(e.clientX),
2127 y: Number(e.clientY)
2128 };
2129 };
2130
2131 Cropper.getTouchPoint = function (touch) {
2132 return {
2133 x: Number(touch.clientX),
2134 y: Number(touch.clientY)
2135 };
2136 };
2137
2138 return Cropper;
2139 }((react__WEBPACK_IMPORTED_MODULE_0___default().Component));
2140
2141 /* harmony default export */ __webpack_exports__["default"] = (Cropper);
2142 //# sourceMappingURL=index.module.js.map
2143
2144
2145 /***/ }),
2146
2147 /***/ "./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js":
2148 /*!**********************************************************************!*\
2149 !*** ./node_modules/react-easy-crop/node_modules/tslib/tslib.es6.js ***!
2150 \**********************************************************************/
2151 /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2152
2153 "use strict";
2154 __webpack_require__.r(__webpack_exports__);
2155 /* harmony export */ __webpack_require__.d(__webpack_exports__, {
2156 /* harmony export */ "__assign": function() { return /* binding */ __assign; },
2157 /* harmony export */ "__asyncDelegator": function() { return /* binding */ __asyncDelegator; },
2158 /* harmony export */ "__asyncGenerator": function() { return /* binding */ __asyncGenerator; },
2159 /* harmony export */ "__asyncValues": function() { return /* binding */ __asyncValues; },
2160 /* harmony export */ "__await": function() { return /* binding */ __await; },
2161 /* harmony export */ "__awaiter": function() { return /* binding */ __awaiter; },
2162 /* harmony export */ "__classPrivateFieldGet": function() { return /* binding */ __classPrivateFieldGet; },
2163 /* harmony export */ "__classPrivateFieldSet": function() { return /* binding */ __classPrivateFieldSet; },
2164 /* harmony export */ "__createBinding": function() { return /* binding */ __createBinding; },
2165 /* harmony export */ "__decorate": function() { return /* binding */ __decorate; },
2166 /* harmony export */ "__exportStar": function() { return /* binding */ __exportStar; },
2167 /* harmony export */ "__extends": function() { return /* binding */ __extends; },
2168 /* harmony export */ "__generator": function() { return /* binding */ __generator; },
2169 /* harmony export */ "__importDefault": function() { return /* binding */ __importDefault; },
2170 /* harmony export */ "__importStar": function() { return /* binding */ __importStar; },
2171 /* harmony export */ "__makeTemplateObject": function() { return /* binding */ __makeTemplateObject; },
2172 /* harmony export */ "__metadata": function() { return /* binding */ __metadata; },
2173 /* harmony export */ "__param": function() { return /* binding */ __param; },
2174 /* harmony export */ "__read": function() { return /* binding */ __read; },
2175 /* harmony export */ "__rest": function() { return /* binding */ __rest; },
2176 /* harmony export */ "__spread": function() { return /* binding */ __spread; },
2177 /* harmony export */ "__spreadArrays": function() { return /* binding */ __spreadArrays; },
2178 /* harmony export */ "__values": function() { return /* binding */ __values; }
2179 /* harmony export */ });
2180 /*! *****************************************************************************
2181 Copyright (c) Microsoft Corporation.
2182
2183 Permission to use, copy, modify, and/or distribute this software for any
2184 purpose with or without fee is hereby granted.
2185
2186 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
2187 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
2188 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
2189 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
2190 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
2191 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
2192 PERFORMANCE OF THIS SOFTWARE.
2193 ***************************************************************************** */
2194 /* global Reflect, Promise */
2195
2196 var extendStatics = function(d, b) {
2197 extendStatics = Object.setPrototypeOf ||
2198 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
2199 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
2200 return extendStatics(d, b);
2201 };
2202
2203 function __extends(d, b) {
2204 extendStatics(d, b);
2205 function __() { this.constructor = d; }
2206 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2207 }
2208
2209 var __assign = function() {
2210 __assign = Object.assign || function __assign(t) {
2211 for (var s, i = 1, n = arguments.length; i < n; i++) {
2212 s = arguments[i];
2213 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
2214 }
2215 return t;
2216 }
2217 return __assign.apply(this, arguments);
2218 }
2219
2220 function __rest(s, e) {
2221 var t = {};
2222 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
2223 t[p] = s[p];
2224 if (s != null && typeof Object.getOwnPropertySymbols === "function")
2225 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
2226 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
2227 t[p[i]] = s[p[i]];
2228 }
2229 return t;
2230 }
2231
2232 function __decorate(decorators, target, key, desc) {
2233 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2234 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
2235 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2236 return c > 3 && r && Object.defineProperty(target, key, r), r;
2237 }
2238
2239 function __param(paramIndex, decorator) {
2240 return function (target, key) { decorator(target, key, paramIndex); }
2241 }
2242
2243 function __metadata(metadataKey, metadataValue) {
2244 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
2245 }
2246
2247 function __awaiter(thisArg, _arguments, P, generator) {
2248 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
2249 return new (P || (P = Promise))(function (resolve, reject) {
2250 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
2251 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
2252 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
2253 step((generator = generator.apply(thisArg, _arguments || [])).next());
2254 });
2255 }
2256
2257 function __generator(thisArg, body) {
2258 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
2259 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
2260 function verb(n) { return function (v) { return step([n, v]); }; }
2261 function step(op) {
2262 if (f) throw new TypeError("Generator is already executing.");
2263 while (_) try {
2264 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
2265 if (y = 0, t) op = [op[0] & 2, t.value];
2266 switch (op[0]) {
2267 case 0: case 1: t = op; break;
2268 case 4: _.label++; return { value: op[1], done: false };
2269 case 5: _.label++; y = op[1]; op = [0]; continue;
2270 case 7: op = _.ops.pop(); _.trys.pop(); continue;
2271 default:
2272 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
2273 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
2274 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
2275 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
2276 if (t[2]) _.ops.pop();
2277 _.trys.pop(); continue;
2278 }
2279 op = body.call(thisArg, _);
2280 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
2281 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
2282 }
2283 }
2284
2285 var __createBinding = Object.create ? (function(o, m, k, k2) {
2286 if (k2 === undefined) k2 = k;
2287 Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
2288 }) : (function(o, m, k, k2) {
2289 if (k2 === undefined) k2 = k;
2290 o[k2] = m[k];
2291 });
2292
2293 function __exportStar(m, o) {
2294 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
2295 }
2296
2297 function __values(o) {
2298 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
2299 if (m) return m.call(o);
2300 if (o && typeof o.length === "number") return {
2301 next: function () {
2302 if (o && i >= o.length) o = void 0;
2303 return { value: o && o[i++], done: !o };
2304 }
2305 };
2306 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
2307 }
2308
2309 function __read(o, n) {
2310 var m = typeof Symbol === "function" && o[Symbol.iterator];
2311 if (!m) return o;
2312 var i = m.call(o), r, ar = [], e;
2313 try {
2314 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
2315 }
2316 catch (error) { e = { error: error }; }
2317 finally {
2318 try {
2319 if (r && !r.done && (m = i["return"])) m.call(i);
2320 }
2321 finally { if (e) throw e.error; }
2322 }
2323 return ar;
2324 }
2325
2326 function __spread() {
2327 for (var ar = [], i = 0; i < arguments.length; i++)
2328 ar = ar.concat(__read(arguments[i]));
2329 return ar;
2330 }
2331
2332 function __spreadArrays() {
2333 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
2334 for (var r = Array(s), k = 0, i = 0; i < il; i++)
2335 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2336 r[k] = a[j];
2337 return r;
2338 };
2339
2340 function __await(v) {
2341 return this instanceof __await ? (this.v = v, this) : new __await(v);
2342 }
2343
2344 function __asyncGenerator(thisArg, _arguments, generator) {
2345 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2346 var g = generator.apply(thisArg, _arguments || []), i, q = [];
2347 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
2348 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
2349 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
2350 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
2351 function fulfill(value) { resume("next", value); }
2352 function reject(value) { resume("throw", value); }
2353 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
2354 }
2355
2356 function __asyncDelegator(o) {
2357 var i, p;
2358 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
2359 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
2360 }
2361
2362 function __asyncValues(o) {
2363 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
2364 var m = o[Symbol.asyncIterator], i;
2365 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
2366 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
2367 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
2368 }
2369
2370 function __makeTemplateObject(cooked, raw) {
2371 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
2372 return cooked;
2373 };
2374
2375 var __setModuleDefault = Object.create ? (function(o, v) {
2376 Object.defineProperty(o, "default", { enumerable: true, value: v });
2377 }) : function(o, v) {
2378 o["default"] = v;
2379 };
2380
2381 function __importStar(mod) {
2382 if (mod && mod.__esModule) return mod;
2383 var result = {};
2384 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
2385 __setModuleDefault(result, mod);
2386 return result;
2387 }
2388
2389 function __importDefault(mod) {
2390 return (mod && mod.__esModule) ? mod : { default: mod };
2391 }
2392
2393 function __classPrivateFieldGet(receiver, privateMap) {
2394 if (!privateMap.has(receiver)) {
2395 throw new TypeError("attempted to get private field on non-instance");
2396 }
2397 return privateMap.get(receiver);
2398 }
2399
2400 function __classPrivateFieldSet(receiver, privateMap, value) {
2401 if (!privateMap.has(receiver)) {
2402 throw new TypeError("attempted to set private field on non-instance");
2403 }
2404 privateMap.set(receiver, value);
2405 return value;
2406 }
2407
2408
2409 /***/ }),
2410
2411 /***/ "react":
2412 /*!************************!*\
2413 !*** external "React" ***!
2414 \************************/
2415 /***/ (function(module) {
2416
2417 "use strict";
2418 module.exports = window["React"];
2419
2420 /***/ }),
2421
2422 /***/ "@wordpress/api-fetch":
2423 /*!**********************************!*\
2424 !*** external ["wp","apiFetch"] ***!
2425 \**********************************/
2426 /***/ (function(module) {
2427
2428 "use strict";
2429 module.exports = window["wp"]["apiFetch"];
2430
2431 /***/ }),
2432
2433 /***/ "@wordpress/element":
2434 /*!*********************************!*\
2435 !*** external ["wp","element"] ***!
2436 \*********************************/
2437 /***/ (function(module) {
2438
2439 "use strict";
2440 module.exports = window["wp"]["element"];
2441
2442 /***/ }),
2443
2444 /***/ "@wordpress/i18n":
2445 /*!******************************!*\
2446 !*** external ["wp","i18n"] ***!
2447 \******************************/
2448 /***/ (function(module) {
2449
2450 "use strict";
2451 module.exports = window["wp"]["i18n"];
2452
2453 /***/ }),
2454
2455 /***/ "@wordpress/url":
2456 /*!*****************************!*\
2457 !*** external ["wp","url"] ***!
2458 \*****************************/
2459 /***/ (function(module) {
2460
2461 "use strict";
2462 module.exports = window["wp"]["url"];
2463
2464 /***/ })
2465
2466 /******/ });
2467 /************************************************************************/
2468 /******/ // The module cache
2469 /******/ var __webpack_module_cache__ = {};
2470 /******/
2471 /******/ // The require function
2472 /******/ function __webpack_require__(moduleId) {
2473 /******/ // Check if module is in cache
2474 /******/ var cachedModule = __webpack_module_cache__[moduleId];
2475 /******/ if (cachedModule !== undefined) {
2476 /******/ return cachedModule.exports;
2477 /******/ }
2478 /******/ // Create a new module (and put it into the cache)
2479 /******/ var module = __webpack_module_cache__[moduleId] = {
2480 /******/ // no module.id needed
2481 /******/ // no module.loaded needed
2482 /******/ exports: {}
2483 /******/ };
2484 /******/
2485 /******/ // Execute the module function
2486 /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2487 /******/
2488 /******/ // Return the exports of the module
2489 /******/ return module.exports;
2490 /******/ }
2491 /******/
2492 /************************************************************************/
2493 /******/ /* webpack/runtime/compat get default export */
2494 /******/ !function() {
2495 /******/ // getDefaultExport function for compatibility with non-harmony modules
2496 /******/ __webpack_require__.n = function(module) {
2497 /******/ var getter = module && module.__esModule ?
2498 /******/ function() { return module['default']; } :
2499 /******/ function() { return module; };
2500 /******/ __webpack_require__.d(getter, { a: getter });
2501 /******/ return getter;
2502 /******/ };
2503 /******/ }();
2504 /******/
2505 /******/ /* webpack/runtime/define property getters */
2506 /******/ !function() {
2507 /******/ // define getter functions for harmony exports
2508 /******/ __webpack_require__.d = function(exports, definition) {
2509 /******/ for(var key in definition) {
2510 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
2511 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
2512 /******/ }
2513 /******/ }
2514 /******/ };
2515 /******/ }();
2516 /******/
2517 /******/ /* webpack/runtime/hasOwnProperty shorthand */
2518 /******/ !function() {
2519 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
2520 /******/ }();
2521 /******/
2522 /******/ /* webpack/runtime/make namespace object */
2523 /******/ !function() {
2524 /******/ // define __esModule on exports
2525 /******/ __webpack_require__.r = function(exports) {
2526 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
2527 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2528 /******/ }
2529 /******/ Object.defineProperty(exports, '__esModule', { value: true });
2530 /******/ };
2531 /******/ }();
2532 /******/
2533 /************************************************************************/
2534 var __webpack_exports__ = {};
2535 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
2536 !function() {
2537 "use strict";
2538 /*!************************************************!*\
2539 !*** ./assets/src/apps/js/frontend/profile.js ***!
2540 \************************************************/
2541 __webpack_require__.r(__webpack_exports__);
2542 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element");
2543 /* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
2544 /* harmony import */ var _profile_course_tab__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./profile/course-tab */ "./assets/src/apps/js/frontend/profile/course-tab.js");
2545 /* harmony import */ var _profile_statistic__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./profile/statistic */ "./assets/src/apps/js/frontend/profile/statistic.js");
2546 /* harmony import */ var _profile_order_recover__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./profile/order-recover */ "./assets/src/apps/js/frontend/profile/order-recover.js");
2547 /* harmony import */ var _profile_avatar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./profile/avatar */ "./assets/src/apps/js/frontend/profile/avatar.js");
2548
2549
2550
2551
2552
2553 document.addEventListener('DOMContentLoaded', function (event) {
2554 (0,_profile_course_tab__WEBPACK_IMPORTED_MODULE_1__["default"])();
2555 (0,_profile_statistic__WEBPACK_IMPORTED_MODULE_2__["default"])();
2556 (0,_profile_order_recover__WEBPACK_IMPORTED_MODULE_3__["default"])();
2557 });
2558
2559 if (document.getElementById('learnpress-avatar-upload')) {
2560 wp.element.render((0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)(_profile_avatar__WEBPACK_IMPORTED_MODULE_4__["default"], null), document.getElementById('learnpress-avatar-upload'));
2561 }
2562 }();
2563 /******/ })()
2564 ;
2565 //# sourceMappingURL=profile.js.map