raffaello 1.2.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,4 +12,4 @@
12
12
  * RAFFAELLO
13
13
  * (c) 2025 Theo Francart
14
14
  * Proprietary License - All Rights Reserved
15
- */.raffaello-imageContainer{border-radius:5px;display:block;max-width:100%;position:relative}.raffaello-imageContainer>*{border-radius:3px}.raffaello-imageContainer img{border:0!important;box-shadow:0!important}.raffaello-upload{align-items:center;background-color:#e7e7ee;border:0!important;cursor:pointer;display:flex;flex-direction:column;gap:10px;height:100%;justify-content:center;left:0;position:absolute;text-align:center;top:0;width:100%;z-index:3}.raffaello-upload svg{fill:#585e74;height:40px;opacity:.8;pointer-events:none;user-select:none;width:40px}.raffaello-loading{align-items:center;background-color:rgba(231,231,238,.5);border:0!important;display:flex;flex-direction:column;gap:10px;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%;z-index:2}.raffaello-loading-circle{animation:raffaello-spin 1s linear infinite;border:4px solid hsla(0,0%,98%,.575);border-radius:50%;border-top-color:#333;height:50px;width:50px}@keyframes raffaello-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.raffaello-templateName{display:flex}.raffaello-restart{cursor:pointer;display:none;opacity:.7}.raffaello-restart svg{fill:#585e74;height:25px;pointer-events:none;user-select:none;width:25px}.raffaello-canvas-to-overlay{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:1}.raffaello-nav{align-items:flex-start;display:flex;filter:drop-shadow(0 0 5px rgba(32,32,72,.1));height:120px;margin-left:40px;margin-top:0;opacity:1;z-index:10}@media screen and (min-width:1400px){.raffaello-nav{margin-left:1170px}}@media screen and (max-width:1400px){.raffaello-nav{margin-left:calc(100vw - 230px)}}
15
+ */.raffaello-imageContainer{border-radius:5px;display:block;max-width:100%;position:relative}.raffaello-imageContainer>*{border-radius:3px}.raffaello-imageContainer img{border:0!important;box-shadow:0!important}.raffaello-upload{align-items:center;background-color:#e7e7ee;border:0!important;cursor:pointer;display:flex;flex-direction:column;gap:10px;height:100%;justify-content:center;left:0;position:absolute;text-align:center;top:0;width:100%;z-index:4}.raffaello-upload svg{fill:#585e74;height:40px;opacity:.8;pointer-events:none;user-select:none;width:40px}.raffaello-loading{align-items:center;background-color:rgba(231,231,238,.5);border:0!important;display:flex;flex-direction:column;gap:10px;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%;z-index:2}.raffaello-loading-circle{animation:raffaello-spin 1s linear infinite;border:4px solid hsla(0,0%,98%,.575);border-radius:50%;border-top-color:#333;height:50px;width:50px}@keyframes raffaello-spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}.raffaello-restart{background-color:grey;cursor:pointer;left:0;opacity:.7;padding:4px 5px;position:absolute;top:0;z-index:2}.raffaello-restart svg{fill:#fff;height:25px;pointer-events:none;user-select:none;width:25px}.raffaello-imageFilters p{font-size:14px;line-height:12px;opacity:.8;user-select:none}.raffaello-canvas-to-overlay{height:100%;left:0;pointer-events:none;position:absolute;top:0;width:100%;z-index:1}.raffaello-templateName{display:flex}.raffaello-nav{align-items:flex-start;display:flex;filter:drop-shadow(0 0 5px rgba(32,32,72,.1));height:120px;margin-left:40px;margin-top:0;opacity:1;z-index:10}@media screen and (min-width:1400px){.raffaello-nav{margin-left:1170px}}@media screen and (max-width:1400px){.raffaello-nav{margin-left:calc(100vw - 230px)}}
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * RAFFAELLO - v1.2.0
2
+ * RAFFAELLO - v1.2.1
3
3
  *
4
4
  * ,%DDJ*.
5
5
  * .P +D+ .,. ,,
@@ -22,7 +22,7 @@
22
22
  * Unauthorized use, modification, or distribution is strictly prohibited.
23
23
  * © 2025 Theo Francart | RTS - Radio Television Suisse. All rights reserved.
24
24
  *
25
- * Build: 2025-04-25
25
+ * Build: 2025-05-01
26
26
  */
27
27
  !function(){"use strict";
28
28
  /*!
@@ -33,4 +33,4 @@
33
33
  * Released under the MIT license
34
34
  *
35
35
  * Date: 2022-11-20T05:30:46.114Z
36
- */var t,e;t=window,e=function(){function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(i),!0).forEach((function(e){_defineProperty(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var t="undefined"!=typeof window&&void 0!==window.document,e=t?window:{},i=!(!t||!e.document.documentElement)&&"ontouchstart"in e.document.documentElement,n=!!t&&"PointerEvent"in e,o="cropper",r="all",s="crop",h="move",l="zoom",c="e",d="w",p="s",u="n",g="ne",m="nw",f="se",v="sw",y="".concat(o,"-crop"),w="".concat(o,"-disabled"),b="".concat(o,"-hidden"),x="".concat(o,"-hide"),C="".concat(o,"-invisible"),L="".concat(o,"-modal"),S="".concat(o,"-move"),k="".concat(o,"Action"),E="".concat(o,"Preview"),D="crop",M="move",R="none",T="crop",I="cropend",N="cropmove",B="cropstart",A="dblclick",_=n?"pointerdown":i?"touchstart":"mousedown",O=n?"pointermove":i?"touchmove":"mousemove",z=n?"pointerup pointercancel":i?"touchend touchcancel":"mouseup",W="ready",F="resize",P="wheel",H="zoom",j="image/jpeg",Y=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,U=/^data:/,X=/^data:image\/jpeg;base64,/,$=/^img|canvas$/i,Z={viewMode:0,dragMode:D,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},q=Number.isNaN||e.isNaN;function isNumber(t){return"number"==typeof t&&!q(t)}var G=function isPositiveNumber(t){return t>0&&t<1/0};function isUndefined(t){return void 0===t}function isObject(t){return"object"===_typeof(t)&&null!==t}var V=Object.prototype.hasOwnProperty;function isPlainObject(t){if(!isObject(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&V.call(i,"isPrototypeOf")}catch(t){return!1}}function isFunction(t){return"function"==typeof t}var Q=Array.prototype.slice;function toArray(t){return Array.from?Array.from(t):Q.call(t)}function forEach(t,e){return t&&isFunction(e)&&(Array.isArray(t)||isNumber(t.length)?toArray(t).forEach((function(i,n){e.call(t,i,n,t)})):isObject(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}))),t}var K=Object.assign||function assign(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return isObject(t)&&i.length>0&&i.forEach((function(e){isObject(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))})),t},J=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return J.test(t)?Math.round(t*e)/e:t}var tt=/^width|height|left|top|marginLeft|marginTop$/;function setStyle(t,e){var i=t.style;forEach(e,(function(t,e){tt.test(e)&&isNumber(t)&&(t="".concat(t,"px")),i[e]=t}))}function addClass(t,e){if(e)if(isNumber(t.length))forEach(t,(function(t){addClass(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function removeClass(t,e){e&&(isNumber(t.length)?forEach(t,(function(t){removeClass(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function toggleClass(t,e,i){e&&(isNumber(t.length)?forEach(t,(function(t){toggleClass(t,e,i)})):i?addClass(t,e):removeClass(t,e))}var et=/([a-z\d])([A-Z])/g;function toParamCase(t){return t.replace(et,"$1-$2").toLowerCase()}function getData(t,e){return isObject(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(toParamCase(e)))}function setData(t,e,i){isObject(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(toParamCase(e)),i)}var it=/\s\s*/,at=function(){var i=!1;if(t){var n=!1,o=function listener(){},r=Object.defineProperty({},"once",{get:function get(){return i=!0,n},set:function set(t){n=t}});e.addEventListener("test",o,r),e.removeEventListener("test",o,r)}return i}();function removeListener(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i;e.trim().split(it).forEach((function(e){if(!at){var r=t.listeners;r&&r[e]&&r[e][i]&&(o=r[e][i],delete r[e][i],0===Object.keys(r[e]).length&&delete r[e],0===Object.keys(r).length&&delete t.listeners)}t.removeEventListener(e,o,n)}))}function addListener(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i;e.trim().split(it).forEach((function(e){if(n.once&&!at){var r=t.listeners,s=void 0===r?{}:r;o=function handler(){delete s[e][i],t.removeEventListener(e,o,n);for(var r=arguments.length,h=new Array(r),l=0;l<r;l++)h[l]=arguments[l];i.apply(t,h)},s[e]||(s[e]={}),s[e][i]&&t.removeEventListener(e,s[e][i],n),s[e][i]=o,t.listeners=s}t.addEventListener(e,o,n)}))}function dispatchEvent(t,e,i){var n;return isFunction(Event)&&isFunction(CustomEvent)?n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(n)}function getOffset(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var nt=e.location,ot=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function isCrossOriginURL(t){var e=t.match(ot);return null!==e&&(e[1]!==nt.protocol||e[2]!==nt.hostname||e[3]!==nt.port)}function addTimestamp(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function getTransforms(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,o=t.translateX,r=t.translateY,s=[];isNumber(o)&&0!==o&&s.push("translateX(".concat(o,"px)")),isNumber(r)&&0!==r&&s.push("translateY(".concat(r,"px)")),isNumber(e)&&0!==e&&s.push("rotate(".concat(e,"deg)")),isNumber(i)&&1!==i&&s.push("scaleX(".concat(i,")")),isNumber(n)&&1!==n&&s.push("scaleY(".concat(n,")"));var h=s.length?s.join(" "):"none";return{WebkitTransform:h,msTransform:h,transform:h}}function getPointer(t,e){var i=t.pageX,n=t.pageY,o={endX:i,endY:n};return e?o:_objectSpread2({startX:i,startY:n},o)}function getAdjustedSizes(t){var e=t.aspectRatio,i=t.height,n=t.width,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",r=G(n),s=G(i);if(r&&s){var h=i*e;"contain"===o&&h>n||"cover"===o&&h<n?i=n/e:n=i*e}else r?i=n/e:s&&(n=i*e);return{width:n,height:i}}var rt=String.fromCharCode,st=/^data:.*,/;function resetAndGetOrientation(t){var e,i=new DataView(t);try{var n,o,r;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var s=i.byteLength,h=2;h+1<s;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){o=h;break}h+=1}if(o){var l=o+10;if("Exif"===function getStringFromCharCode(t,e,i){var n="";i+=e;for(var o=e;o<i;o+=1)n+=rt(t.getUint8(o));return n}(i,o+4,4)){var c=i.getUint16(l);if(((n=18761===c)||19789===c)&&42===i.getUint16(l+2,n)){var d=i.getUint32(l+4,n);d>=8&&(r=l+d)}}}if(r){var p,u,g=i.getUint16(r,n);for(u=0;u<g;u+=1)if(p=r+12*u+2,274===i.getUint16(p,n)){p+=8,e=i.getUint16(p,n),i.setUint16(p,1,n);break}}}catch(t){e=1}return e}var ht={render:function render(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function initContainer(){var t=this.element,e=this.options,i=this.container,n=this.cropper,o=Number(e.minContainerWidth),r=Number(e.minContainerHeight);addClass(n,b),removeClass(t,b);var s={width:Math.max(i.offsetWidth,o>=0?o:200),height:Math.max(i.offsetHeight,r>=0?r:100)};this.containerData=s,setStyle(n,{width:s.width,height:s.height}),addClass(t,b),removeClass(n,b)},initCanvas:function initCanvas(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,n=Math.abs(e.rotate)%180==90,o=n?e.naturalHeight:e.naturalWidth,r=n?e.naturalWidth:e.naturalHeight,s=o/r,h=t.width,l=t.height;t.height*s>t.width?3===i?h=t.height*s:l=t.width/s:3===i?l=t.width/s:h=t.height*s;var c={aspectRatio:s,naturalWidth:o,naturalHeight:r,width:h,height:l};this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),c.width=Math.min(Math.max(c.width,c.minWidth),c.maxWidth),c.height=Math.min(Math.max(c.height,c.minHeight),c.maxHeight),c.left=(t.width-c.width)/2,c.top=(t.height-c.height)/2,c.oldLeft=c.left,c.oldTop=c.top,this.initialCanvasData=K({},c)},limitCanvas:function limitCanvas(t,e){var i=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,s=i.viewMode,h=o.aspectRatio,l=this.cropped&&r;if(t){var c=Number(i.minCanvasWidth)||0,d=Number(i.minCanvasHeight)||0;s>1?(c=Math.max(c,n.width),d=Math.max(d,n.height),3===s&&(d*h>c?c=d*h:d=c/h)):s>0&&(c?c=Math.max(c,l?r.width:0):d?d=Math.max(d,l?r.height:0):l&&(c=r.width,(d=r.height)*h>c?c=d*h:d=c/h));var p=getAdjustedSizes({aspectRatio:h,width:c,height:d});c=p.width,d=p.height,o.minWidth=c,o.minHeight=d,o.maxWidth=1/0,o.maxHeight=1/0}if(e)if(s>(l?0:1)){var u=n.width-o.width,g=n.height-o.height;o.minLeft=Math.min(0,u),o.minTop=Math.min(0,g),o.maxLeft=Math.max(0,u),o.maxTop=Math.max(0,g),l&&this.limited&&(o.minLeft=Math.min(r.left,r.left+(r.width-o.width)),o.minTop=Math.min(r.top,r.top+(r.height-o.height)),o.maxLeft=r.left,o.maxTop=r.top,2===s&&(o.width>=n.width&&(o.minLeft=Math.min(0,u),o.maxLeft=Math.max(0,u)),o.height>=n.height&&(o.minTop=Math.min(0,g),o.maxTop=Math.max(0,g))))}else o.minLeft=-o.width,o.minTop=-o.height,o.maxLeft=n.width,o.maxTop=n.height},renderCanvas:function renderCanvas(t,e){var i=this.canvasData,n=this.imageData;if(e){var o=function getRotatedSizes(t){var e=t.width,i=t.height,n=t.degree;if(90==(n=Math.abs(n)%180))return{width:i,height:e};var o=n%90*Math.PI/180,r=Math.sin(o),s=Math.cos(o),h=e*s+i*r,l=e*r+i*s;return n>90?{width:l,height:h}:{width:h,height:l}}({width:n.naturalWidth*Math.abs(n.scaleX||1),height:n.naturalHeight*Math.abs(n.scaleY||1),degree:n.rotate||0}),r=o.width,s=o.height,h=i.width*(r/i.naturalWidth),l=i.height*(s/i.naturalHeight);i.left-=(h-i.width)/2,i.top-=(l-i.height)/2,i.width=h,i.height=l,i.aspectRatio=r/s,i.naturalWidth=r,i.naturalHeight=s,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,setStyle(this.canvas,K({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function renderImage(t){var e=this.canvasData,i=this.imageData,n=i.naturalWidth*(e.width/e.naturalWidth),o=i.naturalHeight*(e.height/e.naturalHeight);K(i,{width:n,height:o,left:(e.width-n)/2,top:(e.height-o)/2}),setStyle(this.image,K({width:i.width,height:i.height},getTransforms(K({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function initCropBox(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,n=Number(t.autoCropArea)||.8,o={width:e.width,height:e.height};i&&(e.height*i>e.width?o.height=o.width/i:o.width=o.height*i),this.cropBoxData=o,this.limitCropBox(!0,!0),o.width=Math.min(Math.max(o.width,o.minWidth),o.maxWidth),o.height=Math.min(Math.max(o.height,o.minHeight),o.maxHeight),o.width=Math.max(o.minWidth,o.width*n),o.height=Math.max(o.minHeight,o.height*n),o.left=e.left+(e.width-o.width)/2,o.top=e.top+(e.height-o.height)/2,o.oldLeft=o.left,o.oldTop=o.top,this.initialCropBoxData=K({},o)},limitCropBox:function limitCropBox(t,e){var i=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,s=this.limited,h=i.aspectRatio;if(t){var l=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,d=s?Math.min(n.width,o.width,o.width+o.left,n.width-o.left):n.width,p=s?Math.min(n.height,o.height,o.height+o.top,n.height-o.top):n.height;l=Math.min(l,n.width),c=Math.min(c,n.height),h&&(l&&c?c*h>l?c=l/h:l=c*h:l?c=l/h:c&&(l=c*h),p*h>d?p=d/h:d=p*h),r.minWidth=Math.min(l,d),r.minHeight=Math.min(c,p),r.maxWidth=d,r.maxHeight=p}e&&(s?(r.minLeft=Math.max(0,o.left),r.minTop=Math.max(0,o.top),r.maxLeft=Math.min(n.width,o.left+o.width)-r.width,r.maxTop=Math.min(n.height,o.top+o.height)-r.height):(r.minLeft=0,r.minTop=0,r.maxLeft=n.width-r.width,r.maxTop=n.height-r.height))},renderCropBox:function renderCropBox(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&setData(this.face,k,i.width>=e.width&&i.height>=e.height?h:r),setStyle(this.cropBox,K({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function output(){this.preview(),dispatchEvent(this.element,T,this.getData())}},lt={initPreview:function initPreview(){var t=this.element,e=this.crossOrigin,i=this.options.preview,n=e?this.crossOriginUrl:this.url,o=t.alt||"The image to preview",r=document.createElement("img");if(e&&(r.crossOrigin=e),r.src=n,r.alt=o,this.viewBox.appendChild(r),this.viewBoxImage=r,i){var s=i;"string"==typeof i?s=t.ownerDocument.querySelectorAll(i):i.querySelector&&(s=[i]),this.previews=s,forEach(s,(function(t){var i=document.createElement("img");setData(t,E,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=n,i.alt=o,i.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(i)}))}},resetPreview:function resetPreview(){forEach(this.previews,(function(t){var e=getData(t,E);setStyle(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function removeData(t,e){if(isObject(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(toParamCase(e)))}(t,E)}))},preview:function preview(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,n=i.width,o=i.height,r=t.width,s=t.height,h=i.left-e.left-t.left,l=i.top-e.top-t.top;this.cropped&&!this.disabled&&(setStyle(this.viewBoxImage,K({width:r,height:s},getTransforms(K({translateX:-h,translateY:-l},t)))),forEach(this.previews,(function(e){var i=getData(e,E),c=i.width,d=i.height,p=c,u=d,g=1;n&&(u=o*(g=c/n)),o&&u>d&&(p=n*(g=d/o),u=d),setStyle(e,{width:p,height:u}),setStyle(e.getElementsByTagName("img")[0],K({width:r*g,height:s*g},getTransforms(K({translateX:-h*g,translateY:-l*g},t))))})))}},ct={bind:function bind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&addListener(t,B,e.cropstart),isFunction(e.cropmove)&&addListener(t,N,e.cropmove),isFunction(e.cropend)&&addListener(t,I,e.cropend),isFunction(e.crop)&&addListener(t,T,e.crop),isFunction(e.zoom)&&addListener(t,H,e.zoom),addListener(i,_,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&addListener(i,P,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&addListener(i,A,this.onDblclick=this.dblclick.bind(this)),addListener(t.ownerDocument,O,this.onCropMove=this.cropMove.bind(this)),addListener(t.ownerDocument,z,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&addListener(window,F,this.onResize=this.resize.bind(this))},unbind:function unbind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&removeListener(t,B,e.cropstart),isFunction(e.cropmove)&&removeListener(t,N,e.cropmove),isFunction(e.cropend)&&removeListener(t,I,e.cropend),isFunction(e.crop)&&removeListener(t,T,e.crop),isFunction(e.zoom)&&removeListener(t,H,e.zoom),removeListener(i,_,this.onCropStart),e.zoomable&&e.zoomOnWheel&&removeListener(i,P,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&removeListener(i,A,this.onDblclick),removeListener(t.ownerDocument,O,this.onCropMove),removeListener(t.ownerDocument,z,this.onCropEnd),e.responsive&&removeListener(window,F,this.onResize)}},dt={resize:function resize(){if(!this.disabled){var t,e,i=this.options,n=this.container,o=this.containerData,r=n.offsetWidth/o.width,s=n.offsetHeight/o.height,h=Math.abs(r-1)>Math.abs(s-1)?r:s;1!==h&&(i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(forEach(t,(function(e,i){t[i]=e*h}))),this.setCropBoxData(forEach(e,(function(t,i){e[i]=t*h})))))}},dblclick:function dblclick(){this.disabled||this.options.dragMode===R||this.setDragMode(function hasClass(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}(this.dragBox,y)?M:D)},wheel:function wheel(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,n=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout((function(){e.wheeling=!1}),50),t.deltaY?n=t.deltaY>0?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=t.detail>0?1:-1),this.zoom(-n*i,t)))},cropStart:function cropStart(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(isNumber(e)&&1!==e||isNumber(i)&&0!==i||t.ctrlKey))){var n,o=this.options,r=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){r[t.identifier]=getPointer(t)})):r[t.pointerId||0]=getPointer(t),n=Object.keys(r).length>1&&o.zoomable&&o.zoomOnTouch?l:getData(t.target,k),Y.test(n)&&!1!==dispatchEvent(this.element,B,{originalEvent:t,action:n})&&(t.preventDefault(),this.action=n,this.cropping=!1,n===s&&(this.cropping=!0,addClass(this.dragBox,L)))}},cropMove:function cropMove(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==dispatchEvent(this.element,N,{originalEvent:t,action:e})&&(t.changedTouches?forEach(t.changedTouches,(function(t){K(i[t.identifier]||{},getPointer(t,!0))})):K(i[t.pointerId||0]||{},getPointer(t,!0)),this.change(t))}},cropEnd:function cropEnd(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){delete i[t.identifier]})):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,toggleClass(this.dragBox,L,this.cropped&&this.options.modal)),dispatchEvent(this.element,I,{originalEvent:t,action:e}))}}},pt={change:function change(t){var e,i=this.options,n=this.canvasData,o=this.containerData,y=this.cropBoxData,w=this.pointers,x=this.action,C=i.aspectRatio,L=y.left,S=y.top,k=y.width,E=y.height,D=L+k,M=S+E,R=0,T=0,I=o.width,N=o.height,B=!0;!C&&t.shiftKey&&(C=k&&E?k/E:1),this.limited&&(R=y.minLeft,T=y.minTop,I=R+Math.min(o.width,n.width,n.left+n.width),N=T+Math.min(o.height,n.height,n.top+n.height));var A=w[Object.keys(w)[0]],_={x:A.endX-A.startX,y:A.endY-A.startY},O=function check(t){switch(t){case c:D+_.x>I&&(_.x=I-D);break;case d:L+_.x<R&&(_.x=R-L);break;case u:S+_.y<T&&(_.y=T-S);break;case p:M+_.y>N&&(_.y=N-M)}};switch(x){case r:L+=_.x,S+=_.y;break;case c:if(_.x>=0&&(D>=I||C&&(S<=T||M>=N))){B=!1;break}O(c),(k+=_.x)<0&&(x=d,L-=k=-k),C&&(E=k/C,S+=(y.height-E)/2);break;case u:if(_.y<=0&&(S<=T||C&&(L<=R||D>=I))){B=!1;break}O(u),E-=_.y,S+=_.y,E<0&&(x=p,S-=E=-E),C&&(k=E*C,L+=(y.width-k)/2);break;case d:if(_.x<=0&&(L<=R||C&&(S<=T||M>=N))){B=!1;break}O(d),k-=_.x,L+=_.x,k<0&&(x=c,L-=k=-k),C&&(E=k/C,S+=(y.height-E)/2);break;case p:if(_.y>=0&&(M>=N||C&&(L<=R||D>=I))){B=!1;break}O(p),(E+=_.y)<0&&(x=u,S-=E=-E),C&&(k=E*C,L+=(y.width-k)/2);break;case g:if(C){if(_.y<=0&&(S<=T||D>=I)){B=!1;break}O(u),E-=_.y,S+=_.y,k=E*C}else O(u),O(c),_.x>=0?D<I?k+=_.x:_.y<=0&&S<=T&&(B=!1):k+=_.x,_.y<=0?S>T&&(E-=_.y,S+=_.y):(E-=_.y,S+=_.y);k<0&&E<0?(x=v,S-=E=-E,L-=k=-k):k<0?(x=m,L-=k=-k):E<0&&(x=f,S-=E=-E);break;case m:if(C){if(_.y<=0&&(S<=T||L<=R)){B=!1;break}O(u),E-=_.y,S+=_.y,k=E*C,L+=y.width-k}else O(u),O(d),_.x<=0?L>R?(k-=_.x,L+=_.x):_.y<=0&&S<=T&&(B=!1):(k-=_.x,L+=_.x),_.y<=0?S>T&&(E-=_.y,S+=_.y):(E-=_.y,S+=_.y);k<0&&E<0?(x=f,S-=E=-E,L-=k=-k):k<0?(x=g,L-=k=-k):E<0&&(x=v,S-=E=-E);break;case v:if(C){if(_.x<=0&&(L<=R||M>=N)){B=!1;break}O(d),k-=_.x,L+=_.x,E=k/C}else O(p),O(d),_.x<=0?L>R?(k-=_.x,L+=_.x):_.y>=0&&M>=N&&(B=!1):(k-=_.x,L+=_.x),_.y>=0?M<N&&(E+=_.y):E+=_.y;k<0&&E<0?(x=g,S-=E=-E,L-=k=-k):k<0?(x=f,L-=k=-k):E<0&&(x=m,S-=E=-E);break;case f:if(C){if(_.x>=0&&(D>=I||M>=N)){B=!1;break}O(c),E=(k+=_.x)/C}else O(p),O(c),_.x>=0?D<I?k+=_.x:_.y>=0&&M>=N&&(B=!1):k+=_.x,_.y>=0?M<N&&(E+=_.y):E+=_.y;k<0&&E<0?(x=m,S-=E=-E,L-=k=-k):k<0?(x=v,L-=k=-k):E<0&&(x=g,S-=E=-E);break;case h:this.move(_.x,_.y),B=!1;break;case l:this.zoom(function getMaxZoomRatio(t){var e=_objectSpread2({},t),i=0;return forEach(t,(function(t,n){delete e[n],forEach(e,(function(e){var n=Math.abs(t.startX-e.startX),o=Math.abs(t.startY-e.startY),r=Math.abs(t.endX-e.endX),s=Math.abs(t.endY-e.endY),h=Math.sqrt(n*n+o*o),l=(Math.sqrt(r*r+s*s)-h)/h;Math.abs(l)>Math.abs(i)&&(i=l)}))})),i}(w),t),B=!1;break;case s:if(!_.x||!_.y){B=!1;break}e=getOffset(this.cropper),L=A.startX-e.left,S=A.startY-e.top,k=y.minWidth,E=y.minHeight,_.x>0?x=_.y>0?f:g:_.x<0&&(L-=k,x=_.y>0?v:m),_.y<0&&(S-=E),this.cropped||(removeClass(this.cropBox,b),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}B&&(y.width=k,y.height=E,y.left=L,y.top=S,this.action=x,this.renderCropBox()),forEach(w,(function(t){t.startX=t.endX,t.startY=t.endY}))}},ut={crop:function crop(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&addClass(this.dragBox,L),removeClass(this.cropBox,b),this.setCropBoxData(this.initialCropBoxData)),this},reset:function reset(){return this.ready&&!this.disabled&&(this.imageData=K({},this.initialImageData),this.canvasData=K({},this.initialCanvasData),this.cropBoxData=K({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function clear(){return this.cropped&&!this.disabled&&(K(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),removeClass(this.dragBox,L),addClass(this.cropBox,b)),this},replace:function replace(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,forEach(this.previews,(function(e){e.getElementsByTagName("img")[0].src=t})))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function enable(){return this.ready&&this.disabled&&(this.disabled=!1,removeClass(this.cropper,w)),this},disable:function disable(){return this.ready&&!this.disabled&&(this.disabled=!0,addClass(this.cropper,w)),this},destroy:function destroy(){var t=this.element;return t[o]?(t[o]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function move(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,n=i.left,o=i.top;return this.moveTo(isUndefined(t)?t:n+Number(t),isUndefined(e)?e:o+Number(e))},moveTo:function moveTo(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(isNumber(t)&&(i.left=t,n=!0),isNumber(e)&&(i.top=e,n=!0),n&&this.renderCanvas(!0)),this},zoom:function zoom(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function zoomTo(t,e,i){var n=this.options,o=this.canvasData,r=o.width,s=o.height,h=o.naturalWidth,l=o.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&n.zoomable){var c=h*t,d=l*t;if(i){var p=this.pointers,u=getOffset(this.cropper),g=p&&Object.keys(p).length?function getPointersCenter(t){var e=0,i=0,n=0;return forEach(t,(function(t){var o=t.startX,r=t.startY;e+=o,i+=r,n+=1})),{pageX:e/=n,pageY:i/=n}}(p):{pageX:i.pageX,pageY:i.pageY};o.left-=(c-r)*((g.pageX-u.left-o.left)/r),o.top-=(d-s)*((g.pageY-u.top-o.top)/s)}else isPlainObject(e)&&isNumber(e.x)&&isNumber(e.y)?(o.left-=(c-r)*((e.x-o.left)/r),o.top-=(d-s)*((e.y-o.top)/s)):(o.left-=(c-r)/2,o.top-=(d-s)/2);if(o.width=c,o.height=d,this.renderCanvas(!0),!1===dispatchEvent(this.element,H,{ratio:t,oldRatio:r/h,originalEvent:i}))return this}return this},rotate:function rotate(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function rotateTo(t){return isNumber(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function scaleX(t){var e=this.imageData.scaleY;return this.scale(t,isNumber(e)?e:1)},scaleY:function scaleY(t){var e=this.imageData.scaleX;return this.scale(isNumber(e)?e:1,t)},scale:function scale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(isNumber(t)&&(i.scaleX=t,n=!0),isNumber(e)&&(i.scaleY=e,n=!0),n&&this.renderCanvas(!0,!0)),this},getData:function getData(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,n=this.imageData,o=this.canvasData,r=this.cropBoxData;if(this.ready&&this.cropped){t={x:r.left-o.left,y:r.top-o.top,width:r.width,height:r.height};var s=n.width/n.naturalWidth;if(forEach(t,(function(e,i){t[i]=e/s})),e){var h=Math.round(t.y+t.height),l=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=l-t.x,t.height=h-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=n.rotate||0),i.scalable&&(t.scaleX=n.scaleX||1,t.scaleY=n.scaleY||1),t},setData:function setData(t){var e=this.options,i=this.imageData,n=this.canvasData,o={};if(this.ready&&!this.disabled&&isPlainObject(t)){var r=!1;e.rotatable&&isNumber(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,r=!0),e.scalable&&(isNumber(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,r=!0),isNumber(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,r=!0)),r&&this.renderCanvas(!0,!0);var s=i.width/i.naturalWidth;isNumber(t.x)&&(o.left=t.x*s+n.left),isNumber(t.y)&&(o.top=t.y*s+n.top),isNumber(t.width)&&(o.width=t.width*s),isNumber(t.height)&&(o.height=t.height*s),this.setCropBoxData(o)}return this},getContainerData:function getContainerData(){return this.ready?K({},this.containerData):{}},getImageData:function getImageData(){return this.sized?K({},this.imageData):{}},getCanvasData:function getCanvasData(){var t=this.canvasData,e={};return this.ready&&forEach(["left","top","width","height","naturalWidth","naturalHeight"],(function(i){e[i]=t[i]})),e},setCanvasData:function setCanvasData(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(e.left=t.left),isNumber(t.top)&&(e.top=t.top),isNumber(t.width)?(e.width=t.width,e.height=t.width/i):isNumber(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function getCropBoxData(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function setCropBoxData(t){var e,i,n=this.cropBoxData,o=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(n.left=t.left),isNumber(t.top)&&(n.top=t.top),isNumber(t.width)&&t.width!==n.width&&(e=!0,n.width=t.width),isNumber(t.height)&&t.height!==n.height&&(i=!0,n.height=t.height),o&&(e?n.height=n.width/o:i&&(n.width=n.height*o)),this.renderCropBox()),this},getCroppedCanvas:function getCroppedCanvas(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=function getSourceCanvas(t,e,i,n){var o=e.aspectRatio,r=e.naturalWidth,s=e.naturalHeight,h=e.rotate,l=void 0===h?0:h,c=e.scaleX,d=void 0===c?1:c,p=e.scaleY,u=void 0===p?1:p,g=i.aspectRatio,m=i.naturalWidth,f=i.naturalHeight,v=n.fillColor,y=void 0===v?"transparent":v,w=n.imageSmoothingEnabled,b=void 0===w||w,x=n.imageSmoothingQuality,C=void 0===x?"low":x,L=n.maxWidth,S=void 0===L?1/0:L,k=n.maxHeight,E=void 0===k?1/0:k,D=n.minWidth,M=void 0===D?0:D,R=n.minHeight,T=void 0===R?0:R,I=document.createElement("canvas"),N=I.getContext("2d"),B=getAdjustedSizes({aspectRatio:g,width:S,height:E}),A=getAdjustedSizes({aspectRatio:g,width:M,height:T},"cover"),_=Math.min(B.width,Math.max(A.width,m)),O=Math.min(B.height,Math.max(A.height,f)),z=getAdjustedSizes({aspectRatio:o,width:S,height:E}),W=getAdjustedSizes({aspectRatio:o,width:M,height:T},"cover"),F=Math.min(z.width,Math.max(W.width,r)),P=Math.min(z.height,Math.max(W.height,s)),H=[-F/2,-P/2,F,P];return I.width=normalizeDecimalNumber(_),I.height=normalizeDecimalNumber(O),N.fillStyle=y,N.fillRect(0,0,_,O),N.save(),N.translate(_/2,O/2),N.rotate(l*Math.PI/180),N.scale(d,u),N.imageSmoothingEnabled=b,N.imageSmoothingQuality=C,N.drawImage.apply(N,[t].concat(_toConsumableArray(H.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),N.restore(),I}(this.image,this.imageData,e,t);if(!this.cropped)return i;var n=this.getData(),o=n.x,r=n.y,s=n.width,h=n.height,l=i.width/Math.floor(e.naturalWidth);1!==l&&(o*=l,r*=l,s*=l,h*=l);var c=s/h,d=getAdjustedSizes({aspectRatio:c,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),p=getAdjustedSizes({aspectRatio:c,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=getAdjustedSizes({aspectRatio:c,width:t.width||(1!==l?i.width:s),height:t.height||(1!==l?i.height:h)}),g=u.width,m=u.height;g=Math.min(d.width,Math.max(p.width,g)),m=Math.min(d.height,Math.max(p.height,m));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=normalizeDecimalNumber(g),f.height=normalizeDecimalNumber(m),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,g,m);var y=t.imageSmoothingEnabled,w=void 0===y||y,b=t.imageSmoothingQuality;v.imageSmoothingEnabled=w,b&&(v.imageSmoothingQuality=b);var x,C,L,S,k,E,D=i.width,M=i.height,R=o,T=r;R<=-s||R>D?(R=0,x=0,L=0,k=0):R<=0?(L=-R,R=0,k=x=Math.min(D,s+R)):R<=D&&(L=0,k=x=Math.min(s,D-R)),x<=0||T<=-h||T>M?(T=0,C=0,S=0,E=0):T<=0?(S=-T,T=0,E=C=Math.min(M,h+T)):T<=M&&(S=0,E=C=Math.min(h,M-T));var I=[R,T,x,C];if(k>0&&E>0){var N=g/s;I.push(L*N,S*N,k*N,E*N)}return v.drawImage.apply(v,[i].concat(_toConsumableArray(I.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),f},setAspectRatio:function setAspectRatio(t){var e=this.options;return this.disabled||isUndefined(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function setDragMode(t){var e=this.options,i=this.dragBox,n=this.face;if(this.ready&&!this.disabled){var o=t===D,r=e.movable&&t===M;t=o||r?t:R,e.dragMode=t,setData(i,k,t),toggleClass(i,y,o),toggleClass(i,S,r),e.cropBoxMovable||(setData(n,k,t),toggleClass(n,y,o),toggleClass(n,S,r))}return this}},gt=e.Cropper,mt=function(){function Cropper(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,Cropper),!t||!$.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=K({},Z,isPlainObject(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(Cropper,[{key:"init",value:function init(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[o]){if(e[o]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function load(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,n=this.options;if(n.rotatable||n.scalable||(n.checkOrientation=!1),n.checkOrientation&&window.ArrayBuffer)if(U.test(t))X.test(t)?this.read(function dataURLToArrayBuffer(t){var e=t.replace(st,""),i=atob(e),n=new ArrayBuffer(i.length),o=new Uint8Array(n);return forEach(o,(function(t,e){o[e]=i.charCodeAt(e)})),n}(t)):this.clone();else{var o=new XMLHttpRequest,r=this.clone.bind(this);this.reloading=!0,this.xhr=o,o.onabort=r,o.onerror=r,o.ontimeout=r,o.onprogress=function(){o.getResponseHeader("content-type")!==j&&o.abort()},o.onload=function(){e.read(o.response)},o.onloadend=function(){e.reloading=!1,e.xhr=null},n.checkCrossOrigin&&isCrossOriginURL(t)&&i.crossOrigin&&(t=addTimestamp(t)),o.open("GET",t,!0),o.responseType="arraybuffer",o.withCredentials="use-credentials"===i.crossOrigin,o.send()}else this.clone()}}},{key:"read",value:function read(t){var e=this.options,i=this.imageData,n=resetAndGetOrientation(t),o=0,r=1,s=1;if(n>1){this.url=function arrayBufferToDataURL(t,e){for(var i=[],n=new Uint8Array(t);n.length>0;)i.push(rt.apply(null,toArray(n.subarray(0,8192)))),n=n.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,j);var h=function parseOrientation(t){var e=0,i=1,n=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:n=-1;break;case 5:e=90,n=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:n}}(n);o=h.rotate,r=h.scaleX,s=h.scaleY}e.rotatable&&(i.rotate=o),e.scalable&&(i.scaleX=r,i.scaleY=s),this.clone()}},{key:"clone",value:function clone(){var t=this.element,e=this.url,i=t.crossOrigin,n=e;this.options.checkCrossOrigin&&isCrossOriginURL(e)&&(i||(i="anonymous"),n=addTimestamp(e)),this.crossOrigin=i,this.crossOriginUrl=n;var o=document.createElement("img");i&&(o.crossOrigin=i),o.src=n||e,o.alt=t.alt||"The image to crop",this.image=o,o.onload=this.start.bind(this),o.onerror=this.stop.bind(this),addClass(o,x),t.parentNode.insertBefore(o,t.nextSibling)}},{key:"start",value:function start(){var t=this,i=this.image;i.onload=null,i.onerror=null,this.sizing=!0;var n=e.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(e.navigator.userAgent),o=function done(e,i){K(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.initialImageData=K({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(!i.naturalWidth||n){var r=document.createElement("img"),s=document.body||document.documentElement;this.sizingImage=r,r.onload=function(){o(r.width,r.height),n||s.removeChild(r)},r.src=i.src,n||(r.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",s.appendChild(r))}else o(i.naturalWidth,i.naturalHeight)}},{key:"stop",value:function stop(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function build(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,n=t.parentNode,s=document.createElement("div");s.innerHTML='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';var h=s.querySelector(".".concat(o,"-container")),l=h.querySelector(".".concat(o,"-canvas")),c=h.querySelector(".".concat(o,"-drag-box")),d=h.querySelector(".".concat(o,"-crop-box")),p=d.querySelector(".".concat(o,"-face"));this.container=n,this.cropper=h,this.canvas=l,this.dragBox=c,this.cropBox=d,this.viewBox=h.querySelector(".".concat(o,"-view-box")),this.face=p,l.appendChild(i),addClass(t,b),n.insertBefore(h,t.nextSibling),removeClass(i,x),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,addClass(d,b),e.guides||addClass(d.getElementsByClassName("".concat(o,"-dashed")),b),e.center||addClass(d.getElementsByClassName("".concat(o,"-center")),b),e.background&&addClass(h,"".concat(o,"-bg")),e.highlight||addClass(p,C),e.cropBoxMovable&&(addClass(p,S),setData(p,k,r)),e.cropBoxResizable||(addClass(d.getElementsByClassName("".concat(o,"-line")),b),addClass(d.getElementsByClassName("".concat(o,"-point")),b)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),isFunction(e.ready)&&addListener(t,W,e.ready,{once:!0}),dispatchEvent(t,W)}}},{key:"unbuild",value:function unbuild(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var t=this.cropper.parentNode;t&&t.removeChild(this.cropper),removeClass(this.element,b)}}},{key:"uncreate",value:function uncreate(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function noConflict(){return window.Cropper=gt,Cropper}},{key:"setDefaults",value:function setDefaults(t){K(Z,isPlainObject(t)&&t)}}]),Cropper}();return K(mt.prototype,ht,lt,ct,dt,pt,ut),mt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Cropper=e(),window.validLicenseCheckPassed=!0,window.systemVerified=!0,window.initComplete=!0;const i=["","Uk-FGRkF-FTExPOiBO-byBsaWNlb-nNlIGtleSB-wcm92aWRlZA==","UkFGRk-FFTExPOiBJbnZhbGlk-IG9yIHVuYXV0-aG9yaXp-lZCBsa-WNlbnNlIGtleQ==","UkFGR-kFFTE-xPOiBDb3VsZCBub3QgdmFsaWRhdGU-gbGljZW5zZSBrZX-kgKG5ldHdvcmsg-aXNzdWU/KQ==","aHR0cHM6Ly9-yYWZmYW-VsbG8ub25yZW5kZXIuY29tL2xpY2Vu-Y2U/a2V5PQ==","JmRv-bWFp-bj0=","UkFGRkF-FTExPX2xpY-2VuY2-VfY2hlY2-tlZF8=","Um-FmZmF-lbGxvX0N-hbnZh-cw==","c-mVuZ-GV-y","cmVu-ZGVy-UH-Jldmlldw==","dm-FsaW-Q=","TGljZW5-zZSB2YWxpZGF0aW9uIGNvdWxkIG5-vdCBiZSBjb25maXJtZWQuIENvbnRpbn-Vpbmcgd2l0aG91dCBkaXNhY-mxpbmcu","c2N-yaXB0W3N-yYyo9InJhZ-mZhZWxsbyJd","c2N-yaXB0W3N-yYyo9InJhZ-mZhZWxsbyJd",""];function a(t){return atob(i[t].split("").filter((t=>"-"!==t)).join(""))}window.r_o=!0;class Raffaello_CanvasLayer{constructor(t,e,i="normal",n=null){this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.type=i,this.effect=n,this.drawInstructions=null,this.bounds={minX:null,minY:null,maxX:null,maxY:null},this.isDrawn=!1}draw(t){return this.drawInstructions=t,this.drawInstructions(),this.isDrawn=!0,this}drawText(t){if(!t.text)return void(this.bounds={minX:null,maxX:null,minY:null,maxY:null});let e;if(t.text instanceof HTMLInputElement||t.text instanceof HTMLTextAreaElement)e=t.text.value;else{if("string"!=typeof t.text)return console.log("Error on the drawText(), the text input is not a valid string."),void console.log(t.text);e=t.text}const i={fontKerningOptical:!1,fontLetterSpacing:0,textAlign:{horizontal:"left",vertical:"bottom"},textBaseline:"alphabetic",anchorPoint:"none",position:{max_width:0,max_width_rescale:!1,max_lines:0,ignore_empty_lines:!0,ignore_double_spaces:!0},bounds:[!0,!0]},n={...i,...t,textAlign:{...i.textAlign,...t.textAlign},bounds:{...i.bounds,...t.bounds},position:{...i.position,...t.position}};n.fontLineHeight=t.fontLineHeight||t.fontSize;let o=e.split("\n");!1!==n.position.ignore_empty_lines&&(o=o.filter((t=>t.trim().length>0))),o=o.map((t=>t.trim())),!1!==n.position.ignore_double_spaces&&(o=o.map((t=>t.replace(/\s+/g," ")))),this.context.font=`${n.fontSize}px ${n.fontFamily}`,this.context.letterSpacing=n.fontSize/100*n.fontLetterSpacing+"px",this.context.textAlign=n.textAlign.horizontal,this.context.textBaseline=n.textBaseline,this.context.fontKerning=n.fontKerningOptical?"auto":"normal";let r=o.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("§","")).actualBoundingBoxLeft)),0),s=1;if(n.position.max_width&&n.position.max_width_rescale)s=r>n.position.max_width?1/r*n.position.max_width:1;else if(n.position.max_width&&!n.position.max_width_rescale){let t=[];o.forEach((e=>{let i=e.split(" "),o="";i.forEach(((e,r)=>{let s=o+(o?" ":"")+e;this.context.measureText(s.replaceAll("§","")).width>n.position.max_width&&""!==o?(t.push(o),o=e):o=s,r===i.length-1&&t.push(o)}))})),o=t,r=o.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("§","")).actualBoundingBoxLeft)),0)}n.position.max_lines&&(o=o.slice(0,n.position.max_lines)),this.context.font=`${n.fontSize*s}px ${n.fontFamily}`,this.context.letterSpacing=n.fontSize*s/100*n.fontLetterSpacing+"px";let h=this.context.measureText("Lp");n.bounds&&(!n.bounds[0]&&n.bounds[1]?h=this.context.measureText("p"):n.bounds[0]&&!n.bounds[1]?h=this.context.measureText("L"):n.bounds[0]||n.bounds[1]||(h=this.context.measureText("x")));let l=0;switch(n.position.true_anchorPoint_x&&(this.context.textAlign="left",l=this.context.measureText("L").actualBoundingBoxLeft,this.context.textAlign=n.textAlign.horizontal),this.context.textAlign="left",n.anchorPoint){default:case"none":break;case"true":l=this.context.measureText(o[0].slice(0,1)).actualBoundingBoxLeft;break;case"L":l=this.context.measureText("L").actualBoundingBoxLeft}this.context.textAlign=n.textAlign.horizontal;let c=n.position.pos_x,d=n.position.pos_y+h.actualBoundingBoxDescent,p=c+r*s,u=n.position.pos_y-h.actualBoundingBoxAscent,g=n.fontLineHeight*s*(o.length-1);switch(n.textAlign.vertical){default:case"top":d+=g;break;case"center":d+=g/2,u-=g/2;break;case"bottom":u-=g}switch(n.textAlign.horizontal){default:case"left":break;case"center":c-=r*s/2,p-=r*s/2;break;case"right":c-=r*s,p-=r*s}if(this.bounds={minX:c,maxX:p,minY:u,maxY:d},n.background){"string"==typeof n.background&&(n.background={fill_color:n.background,round_radius:0});let t={top:0,right:0,left:0,bottom:0};n.background.margins&&(n.background.margins.top&&(t.top=n.background.margins.top),n.background.margins.bottom&&(t.bottom=n.background.margins.bottom),n.background.margins.left&&(t.left=n.background.margins.left),n.background.margins.right&&(t.right=n.background.margins.right));let e=this.bounds.minX-t.left,i=this.bounds.maxX-this.bounds.minX+t.right+t.left,o=this.bounds.minY-t.top,r=this.bounds.maxY-this.bounds.minY+t.top+t.bottom,s=0;n.background.round_radius&&(s=n.background.round_radius),this.context.fillStyle=n.background.fill_color,n.background.stroke&&(this.context.lineWidth=n.background.stroke.width||10,this.context.strokeStyle=n.background.stroke.color||"black"),this.context.beginPath(),this.context.roundRect(e,o,i,r,s),this.context.fill(),n.background.stroke&&this.context.stroke()}o.forEach(((t,e)=>{let i,r=n.position.pos_x+l;if("center"===n.textAlign.horizontal){this.context.textAlign="left",r-=(this.context.measureText(t.replaceAll("§","")).actualBoundingBoxRight+this.context.measureText(t.replaceAll("§","")).actualBoundingBoxLeft)/2}switch(n.textAlign.vertical){default:case"top":i=e*n.fontLineHeight*s;break;case"bottom":i=-(o.length-1-e)*n.fontLineHeight*s;break;case"center":i=-(o.length-1)*n.fontLineHeight*s/2+e*n.fontLineHeight*s}const h=t.replace(/§+$/,"").split("§");for(let t=0;t<h.length;t++){let e="right"===n.textAlign.horizontal?h.length-1-t:t,o=h[e];if(this.context.fillStyle=n.fontFillColor,n.highlight&&e%2==1){this.context.fillStyle=n.highlight.fontFillColor?n.highlight.fontFillColor:n.fontFillColor;let t=n.highlight.fontSize?n.highlight.fontSize:n.fontSize,e=n.highlight.fontFamily?n.highlight.fontFamily:n.fontFamily;this.context.font=`${t*s}px ${e}`,this.context.letterSpacing=n.highlight.fontLetterSpacing?t*s/100*n.highlight.fontLetterSpacing+"px":t*s/100*n.fontLetterSpacing+"px"}this.context.fillText(o,r,n.position.pos_y+i),r+=("right"===n.textAlign.horizontal?-1:1)*this.context.measureText(o).width}})),this.isDrawn=!0}drawImage(...t){let e,i,n,o;if(this.context.drawImage(...t),3===t.length){const[r,s,h]=t;e=s,i=h,n=s+r.width,o=h+r.height}else if(5===t.length){const[,,,r,s,h,l]=t;e=h,i=l,n=h+r,o=l+s}else if(9===t.length){const[,,,,,r,s,h,l]=t;e=r,i=s,n=r+h,o=s+l}this.bounds={minX:e,minY:i,maxX:n,maxY:o},this.context.filter="none",this.isDrawn=!0}drawImageInput(t,e,i){this.context.drawImage(t.config.rawImage,Math.round(t.config.cropInfo.x),Math.round(t.config.cropInfo.y),Math.round(t.config.cropInfo.width),Math.round(t.config.cropInfo.height),e,i,Math.round(t.config.width),Math.round(t.config.height))}drawRect_old(t){const e={...{x:0,y:0,width:this.canvas.width,height:this.canvas.height,color:"rgba(0, 0, 0, 0)"},...t};this.context.fillStyle=e.color,this.context.fillRect(e.x,e.y,e.width,e.height)}drawRect(t){const e={...{x:0,y:0,width:this.canvas.width,height:this.canvas.height,radius:[0],color:"rgba(0, 0, 0, 0)",strokeStyle:"middle",strokeWidth:0,strokeColor:"rgba(0, 0, 0, 0)"},...t},i=this.context,{x:n,y:o,width:r,height:s,radius:h,strokeWidth:l,strokeStyle:c}=e,[d,p,u,g]="number"==typeof h?[h,h,h,h]:Array.isArray(h)?[h[0]??0,h[1]??h[0]??0,h[2]??h[0]??0,h[3]??h[1]??0]:[0,0,0,0];let m=n,f=o,v=r,y=s;l>0&&("inside"===c?(m+=l/2,f+=l/2,v-=l,y-=l):"outside"===c&&(m-=l/2,f-=l/2,v+=l,y+=l)),i.beginPath(),i.moveTo(m+d,f),i.lineTo(m+v-p,f),i.quadraticCurveTo(m+v,f,m+v,f+p),i.lineTo(m+v,f+y-u),i.quadraticCurveTo(m+v,f+y,m+v-u,f+y),i.lineTo(m+g,f+y),i.quadraticCurveTo(m,f+y,m,f+y-g),i.lineTo(m,f+d),i.quadraticCurveTo(m,f,m+d,f),i.closePath(),i.fillStyle=e.color,i.fill(),l>0&&(i.strokeStyle=e.strokeColor,i.lineWidth=l,i.stroke())}drawStar(t){const e={x_center:0,y_center:0,spikes:5,color:"rgba(0,0,0,1)",outerRadius:100,innerRadius:150,...t};var i=Math.PI/2*3,n=e.x_center,o=e.y_center,r=Math.PI/e.spikes;this.context.beginPath(),this.context.moveTo(e.x_center,e.y_center-e.outerRadius);for(let t=0;t<e.spikes;t++)n=e.x_center+Math.cos(i)*e.outerRadius,o=e.y_center+Math.sin(i)*e.outerRadius,this.context.lineTo(n,o),i+=r,n=e.x_center+Math.cos(i)*e.innerRadius,o=e.y_center+Math.sin(i)*e.innerRadius,this.context.lineTo(n,o),i+=r;this.context.lineTo(e.x_center,e.y_center-e.outerRadius),this.context.closePath(),this.context.fillStyle=e.color,this.context.fill()}drawGradient(t){const e={x:0,y:0,width:100,height:100,direction:"DOWN",gradient:[[0,"rgba(0,0,0, 0)"],[1,"rgba(0,0,0, 1)"]],...t};if(!["UP","RIGHT","DOWN","LEFT"].includes(e.direction))throw new Error('Invalid direction value. It must be "UP", "RIGHT", "DOWN", or "LEFT".');let i,n,o,r;"UP"===e.direction?(i=e.x,n=e.y+e.height,o=e.x,r=e.y):"RIGHT"===e.direction?(i=e.x,n=e.y,o=e.x+e.width,r=e.y):"DOWN"===e.direction?(i=e.x,n=e.y,o=e.x,r=e.y+e.height):"LEFT"===e.direction&&(i=e.x+e.width,n=e.y,o=e.x,r=e.y);const s=this.context.createLinearGradient(i,n,o,r);for(let t=0;t<e.gradient.length;t++){let i=e.gradient[t][0],n=e.gradient[t][1];s.addColorStop(i,n)}this.context.fillStyle=s,this.context.fillRect(e.x,e.y,e.width,e.height)}prepareFilter(t){this.context.filter=t}applyFilter(t){this.context.filter=t,this.context.drawImage(this.canvas,0,0),this.context.filter="none"}applyLUT(t){t.isLoaded||console.log("LUT not loaded",t.name);const e=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),i=e.data;for(let e=0;e<i.length;e+=4){const n=i[e]/255,o=i[e+1]/255,r=i[e+2]/255,[s,h,l]=apply3DLUT(n,o,r,t.lutData);i[e]=255*s,i[e+1]=255*h,i[e+2]=255*l}function apply3DLUT(t,e,i,{size:n,lut:o}){const r=n-1;return o[Math.min(Math.floor(t*r),r)+Math.min(Math.floor(e*r),r)*n+Math.min(Math.floor(i*r),r)*n*n]}this.context.putImageData(e,0,0)}update(){this.drawInstructions&&(this.clear(),this.drawInstructions())}clear(){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.isDrawn=!1}}class Raffaello_ImageCropper{constructor(...t){this.container=null,this.config={};for(const e of t)e instanceof HTMLElement?this.container=e:"object"==typeof e&&null!==e&&(this.config=e);if(!this.container&&this.config.container instanceof HTMLElement&&(this.container=this.config.container),this.config&&0!==Object.keys(this.config).length||console.error("[Raffaello_ImageCropper] Missing configuration object. Please provide a valid config."),!this.container&&this.config.layerRef?.container instanceof HTMLElement&&(this.container=this.config.layerRef.container),!this.container)throw console.error("[Raffaello_ImageCropper] No container provided. Either pass it directly, or use config.layerRef.container."),new Error("Missing container");null==this.config.width&&(this.config.layerRef?.canvas?.width?this.config.width=this.config.layerRef.canvas.width:console.warn("[Raffaello_ImageCropper] No width provided in config, and no fallback from layerRef.canvas.width.")),null==this.config.height&&(this.config.layerRef?.canvas?.height?this.config.height=this.config.layerRef.canvas.height:console.warn("[Raffaello_ImageCropper] No height provided in config, and no fallback from layerRef.canvas.height.")),this.config.imageReady=!1,this.initDynamicElements(),this.initElements(),this.initCropper(),this.bindEvents(),this.initRatioSelect(),this.initWatermark(),this.filterValues={},this.initFilterControls()}initDynamicElements(){const t=this.container.querySelector(".raffaello-imageContainer");t.style.backgroundColor="rgb(51, 51, 51)";const e=document.createElement("input");e.type="file",e.className="raffaello-imageInput",e.accept="image/*",e.style.display="none",t.innerHTML+="\x3c!-- FILE INPUT --\x3e",t.appendChild(e);const i=document.createElement("div");i.className="raffaello-upload",i.innerHTML+='\n <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 16 20"\n class=\'icon\'\n style="enable-background:new 0 0 16 20" >\n <path d="M7 17h2v-4.2l1.6 1.6L12 13 8 9l-4 4 1.4 1.4L7 12.8V17zm-5 3c-.6 0-1-.2-1.4-.6S0 18.5 0 18V2C0 1.5.2 1 .6.6S1.5 0 2 0h8l6 6v12c0 .5-.2 1-.6 1.4s-.8.6-1.4.6H2zM9 7V2H2v16h12V7H9zM2 2v5-5 16V2z"/>\n </svg>',t.innerHTML+="\x3c!-- UPLOAD INPUT --\x3e",t.appendChild(i);const n=document.createElement("div");n.className="raffaello-loading";const o=document.createElement("div");o.className="raffaello-loading-circle",n.appendChild(o),t.appendChild(n);const r=this.container.querySelector(".raffaello-imageFiltres");if(r){r.classList.add("flex-row"),r.style.gap="2px";const t=document.createElement("p");t.className="small-p-2 brightness-label",r.appendChild(t);const e=document.createElement("input");e.type="range",e.name="brightness",e.displayName="Luminosité",e.min="-100",e.max="100",e.value="20",r.appendChild(e);const i=document.createElement("p");i.className="small-p-2 contrast-label",r.appendChild(i);const n=document.createElement("input");n.type="range",n.name="contrast",n.displayName="Contraste",n.min="-100",n.max="100",n.value="20",r.appendChild(n);const o=document.createElement("p");o.className="small-p-2 saturate-label",r.appendChild(o);const s=document.createElement("input");s.type="range",s.name="saturate",s.displayName="Saturation",s.min="-100",s.max="100",s.value="20",r.appendChild(s)}const s=this.container.querySelector(".raffaello-cropperRestart");s&&(this.cropperRestart=s,s.classList.add("raffaello-restart"),s.innerHTML+="\x3c!-- REFRESH SVG --\x3e",s.innerHTML+='\n <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 16 18.5"\n class="icon"\n style="enable-background:new 0 0 16 18.5" >\n <path d="M7 18.5c-2-.2-3.7-1.1-5-2.6s-2-3.3-2-5.3c0-1.1.2-2.2.7-3.2s1-1.9 1.9-2.6L4 6.2c-.6.6-1.1 1.2-1.4 2S2 9.7 2 10.5c0 1.5.5 2.8 1.4 3.9s2.1 1.8 3.6 2.1v2zm2 0v-2c1.4-.3 2.6-1 3.6-2.1S14 12 14 10.5c0-1.7-.6-3.1-1.8-4.2S9.7 4.5 8 4.5h-.1L9 5.6 7.6 7 4.1 3.5 7.6 0 9 1.4 7.9 2.5H8c2.2 0 4.1.8 5.7 2.3S16 8.3 16 10.5c0 2-.7 3.8-2 5.3s-3 2.4-5 2.7z"/>\n </svg>')}initElements(){this.dropzone=this.container.querySelector(".raffaello-imageContainer"),this.imageInput=this.container.querySelector(".raffaello-imageInput"),this.upload=this.container.querySelector(".raffaello-upload"),this.loading=this.container.querySelector(".raffaello-loading"),this.cropperContainer=this.container.querySelector(".raffaello-cropperContainer")}initCropper(){this.cropper=new Cropper(this.cropperContainer,{aspectRatio:this.config.aspectRatio??this.config.width/this.config.height,viewMode:this.config.viewMode??2,autoCropArea:1,zoomOnWheel:this.config.zoomOnWheel??0,ready:()=>{this.applyFilters(),this.config.rawImage=this.cropperContainer,this.config.cropInfo=this.cropper.getData(),this.config.imageReady=!0,this.config.onImageReady?this.config.onImageReady():console.log(this.config)}})}bindEvents(){this.upload.addEventListener("click",(()=>{"INPUT"===this.imageInput.tagName&&"file"===this.imageInput.type||console.warn('Warning: this.imageInput is not an <input> element of type "file". Nothing should have a class "raffaello-imageInput"'),this.imageInput.click()})),this.imageInput.addEventListener("change",(t=>{this.loadSelectedImage(t)})),this.dropzone.addEventListener("dragover",(t=>t.preventDefault())),this.dropzone.addEventListener("drop",(t=>{t.preventDefault(),console.log("We have a drop");const e=t.dataTransfer.files[0];e.type.match(/^image\//)?this.loadSelectedImage({target:{files:[e]}}):console.log("Invalid file type. Only image files are allowed.")})),this.cropperContainer.addEventListener("crop",(t=>{this.config.cropInfo=this.cropper.getData()})),this.cropperRestart&&this.cropperRestart.addEventListener("click",(()=>{this.imageInput.click()})),this.config.onCrop&&this.cropperContainer.addEventListener("crop",this.config.onCrop),this.config.onCropStart&&this.cropperContainer.addEventListener("cropstart",this.config.onCropStart),this.config.onCropEnd&&this.cropperContainer.addEventListener("cropend",this.config.onCropEnd),this.config.onZoom&&this.cropperContainer.addEventListener("zoom",this.config.onZoom),void 0!==this.config.layerIndex&&void 0!==this.config.layerRef&&(this.config.onImageReady=()=>{this.config.layerRef.initiateDrawing()},this.config.onFilterChange=()=>{this.config.layerRef.canvas.updateLayers([this.config.layerIndex])},this.cropperContainer.addEventListener("onCrop",(()=>{})),this.cropperContainer.addEventListener("cropstart",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=.5})),this.cropperContainer.addEventListener("cropend",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=1,this.config.layerRef.canvas.updateLayers([this.config.layerIndex])})))}showBackInitialUI(){"none"==this.upload.style.display&&(this.upload.style.display="flex");const t=this.cropperRestart;t&&(t.style.display="none")}loadSelectedImage(t){return new Promise(((e,i)=>{const n=t.target.files[0];if(!n)return;"none"!==this.upload.style.display&&(this.upload.style.display="none"),"none"===this.loading.style.display&&(this.loading.style.display="flex");const o=this.cropperRestart;o&&(o.style.display="block");const r=new FileReader;r.addEventListener("load",(()=>{this.loading.style.display="none",this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")));let t=n.name.split(".")[0];this.config.fileName=t,this.cropperContainer.src=r.result,this.cropper.replace(this.cropperContainer.src),e(t)})),r.readAsDataURL(n)}))}initRatioSelect(){this.imageRatioSelect=this.container.querySelector(".raffaello-imageRatioSelect"),this.imageRatioSelect&&this.imageRatioSelect.addEventListener("change",(()=>{const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.width,e=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.height;this.config.width=t,this.config.height=e;const i=t/e;this.cropper.setAspectRatio(i),this.watermarkSelect&&this.resetWatermarkList()}))}setNewSize(t,e){const i=t/e;this.cropper.setAspectRatio(i)}initWatermark(){this.watermarkDiv=this.container.querySelector(".raffaello-watermark"),this.watermarkDiv&&(this.watermarkDiv.classList.add("raffaello-canvas-to-overlay","icon"),""!==this.watermarkDiv.src&&this.watermarkDiv.src!==window.location.href||(this.watermarkDiv.style.display="none"),this.cropperContainer.addEventListener("crop",(()=>{this.updateWatermarkPositionAndSize()})),this.watermarkSelect=this.container.querySelector(".raffaello-watermarkSelect"),this.watermarkSelect&&this.watermarkSelect.addEventListener("change",(()=>{this.updateWatermark()})))}updateWatermark(){const t=this.watermarkSelect.options[this.watermarkSelect.selectedIndex].dataset.watermark;t?(this.watermarkDiv.src=t,this.watermarkDiv.style.display="block"):(this.watermarkDiv.src="",this.watermarkDiv.style.display="none"),this.updateWatermarkPositionAndSize()}updateWatermarkPositionAndSize(){const t=this.cropper.getCropBoxData();this.watermarkDiv.style.width=Math.ceil(t.width)+1+"px",this.watermarkDiv.style.height=Math.ceil(t.height)+1+"px",this.watermarkDiv.style.left=t.left-.5+"px",this.watermarkDiv.style.top=t.top-.5+"px"}resetWatermarkList(){this.watermarkSelect.selectedIndex=0,this.watermarkDiv.src="",this.watermarkDiv.style.display="none";const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.ratio;for(let e=1;e<this.watermarkSelect.options.length;e++){const i=this.watermarkSelect.options[e];i.dataset.ratio===t?i.style.display="block":i.style.display="none"}}initFilterControls(){const t=this.container.querySelector(".raffaello-imageFiltres");if(t){t.querySelectorAll('input[type="range"]').forEach((t=>{const e=t.name||t.dataset.filter,i=t.displayName;this.filterValues[e]=t.value,this.updateFilterValue(e,i,t.value),t.addEventListener("input",(t=>{this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),t.addEventListener("dblclick",(t=>{t.target.value=20,this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),this.config.onFilterChange&&(t.addEventListener("input",this.config.onFilterChange),t.addEventListener("dblclick",this.config.onFilterChange))}))}}linear(t,e,i,n,o){return(t-e)/(i-e)*(o-n)+n}updateFilterValue(t,e,i){let n;n="brightness"===t?i<0?this.linear(i,-100,0,.8,1):this.linear(i,0,100,1,1.4):"contrast"===t?i<0?this.linear(i,-100,0,.9,1):this.linear(i,0,100,1,1.3):"saturate"===t?i<0?this.linear(i,-100,0,0,1):this.linear(i,0,100,1,1.3):i;let o=i,r=this.container.querySelector(`.${t}-label`);r&&(r.innerHTML=`${e.charAt(0).toUpperCase()+e.slice(1)} <i>(${o})</i>`),this.filterValues[t]=n}applyFilters(){let t=Object.entries(this.filterValues).map((([t,e])=>`${t}(${e})`)).join(" ");this.config.filter=t;const e=this.container.querySelector(".cropper-crop-box .cropper-view-box"),i=this.container.querySelector(".cropper-wrap-box div");e&&(e.style.filter=t),i&&(i.style.filter=t)}}function d_r(){console.log("> d_r()")}window.Raffaello_Canvas=class Raffaello_Canvas{constructor(t){if(this.width=t.width??1e3,this.height=t.height??1e3,this.cornerRadius=t.cornerRadius??0,this.previewContainer=t.previewContainer??null,this.nameInputContainer=t.nameInputContainer??null,this.previewQuality=t.previewQuality??"0.8",this.renderQuality=t.renderQuality??"0.96",this.layers=[],this.previewContainer){const e=window.getComputedStyle(this.previewContainer).backgroundColor;t.previewBackgroundColor?this.previewBackgroundColor=t.previewBackgroundColor:e&&"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(this.previewBackgroundColor=e)}}addLayer(t="normal",e=null){let i=new Raffaello_CanvasLayer(this.width,this.height,t,e);return this.layers.push(i),i}updateLayers(t){for(const e of t)this.layers[e]?this.layers[e].update():console.warn(`> updateLayers([${e}]): The canvas does not have a layer ${e}`);this.renderPreview()}resetLayers(){this.layers=[]}render(t=!1){if(!window.r_o)return void console.log(a(2));let e=document.createElement("canvas");e.width=this.width,e.height=this.height;let i=e.getContext("2d");this.cornerRadius>0&&(i.save(),i.beginPath(),i.roundRect(0,0,e.width,e.height,this.cornerRadius),i.clip()),t&&null!=this.previewBackgroundColor&&(i.fillStyle=this.previewBackgroundColor,i.fillRect(0,0,e.width,e.height));for(let t=0;t<this.layers.length;t++){const e=this.layers[t],n=this.layers[t+1];let o=e.canvas;if("alpha"===n?.type){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;let i=t.getContext("2d");i.drawImage(n.canvas,0,0),i.globalCompositeOperation="source-in",i.drawImage(e.canvas,0,0),i.globalCompositeOperation="source-over",o=t}["image","normal"].includes(e.type)&&i.drawImage(o,0,0),"effect"===e.type&&(i.globalCompositeOperation=e.effect,i.drawImage(o,0,0),i.globalCompositeOperation="source-over")}return this.cornerRadius>0&&i.restore(),e}renderPreview(){if(!window.r_o)return void console.log(a(2));if(!this.previewContainer)return;const t=this.previewContainer;/iPad|iPhone|iPod/.test(navigator.userAgent)?t.src=this.render().toDataURL("image/jpeg",.9):t.src=this.render(!0).toDataURL("image/jpeg",this.previewQuality)}downloadImage(){const t=this.render();if(!t)return;let e,i,n=this.nameInputContainer.value.trim(),o=n?n.split(".")[0].replace(/[^a-zA-Z0-9\_-]/g,""):"Image_Raffaello";switch(n.split(".").pop().toLowerCase()){case"jpg":case"jpeg":e="image/jpeg",i=".jpg";break;default:e="image/png",i=".png"}if(/iPad|iPhone|iPod/.test(navigator.userAgent))window.alert("Appuyez et maintenez l'image pour l'enregistrer.");else{const n=document.createElement("a");n.download=o+i,n.href=t.toDataURL(e,"image/jpeg"===e?this.renderQuality:void 0),document.body.appendChild(n),n.click(),document.body.removeChild(n)}}renderBis(){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;const e=t.getContext("2d");return e.fillStyle=atob("I2Y4ZDdkYQ=="),e.fillRect(0,0,this.width,this.height),e.fillStyle=atob("IzcyMWMyNA=="),e.font="bold 24px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(atob("TGljZW5zZSBrZXkgbm90IHZhbGlk"),this.width/2,this.height/2),t}},window.Raffaello_CanvasLayer=Raffaello_CanvasLayer,window.Raffaello_ImageCropper=Raffaello_ImageCropper,window.Raffaello_BatchImageCropper=class Raffaello_BatchImageCropper{constructor(t,e){this.input=t,this.container=this.input.container,this.canvas=this.input.canvas,this.imageConfigs=e,this.imagesAreReady=e.map((t=>!0===t.isOptionnal)),this.inputImages=[],this.initializeCroppers()}initializeCroppers(){this.inputImages=this.imageConfigs.map(((t,e)=>new Raffaello_ImageCropper(this.container.querySelector(t.selector),{layerRef:this.input,width:t.width,height:t.height,viewMode:t.viewMode??2,zoomOnWheel:t.zoomOnWheel??0,onImageReady:()=>{this.markImageAsReady(e)},onCropStart:()=>{this.canvas.previewContainer.style.opacity=.5},onCropEnd:()=>{this.canvas.previewContainer.style.opacity=1,this.canvas.updateLayers([t.layerIndex])},onZoom:()=>{this.canvas.updateLayers([t.layerIndex])},onFilterChange:()=>{this.canvas.updateLayers([t.layerIndex])}})))}markImageAsReady(t){this.imagesAreReady[t]=!0,this.checkImagesAreReady()}checkImagesAreReady(){this.imagesAreReady.every((t=>t))&&(this.removePendingState(),console.log("All images are ready, starting to draw..."),this.input.initiateDrawing())}removePendingState(){this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")))}},window.Raffaello_Image=class Raffaello_Image{constructor(t){const e=t.url;this.img=new Image,this.img.src=e,this.isLoaded=!1,this.img.onload=()=>{this.isLoaded=!0,console.log(`✅ Image ${e.split("/").slice(-1)} loaded successfully.`)},this.img.onerror=()=>{console.error("❌ Failed to load image:",e)}}getImage(){return this.isLoaded?this.img:(console.warn("❌ Image not loaded yet."),null)}isLoaded(){return this.isLoaded}},window.Raffaello_Font=class Raffaello_Font{constructor(t){const e=t.name;this.font=new FontFace(e,`url(${t.url})`),this.font.display="swap",this.isLoaded=!1;let i=this.font;document.fonts.add(i),i.load().then((()=>{this.isLoaded=!0,console.log(`✅ Font ${e} loaded successfully.`)})).catch((()=>{console.error("❌ Failed to load font:",e)}))}isLoaded(){return this.isLoaded}},window.Raffaello_LUT=class Raffaello_LUT{constructor(t){const e=t.url;this.lutData=null,this.isLoaded=!1,this.name=e.split("/").slice(-1),this.loadLUT(e).then((t=>{this.lutData=t,this.isLoaded=!0,console.log(`✅ LUT ${this.name} loaded successfully.`)})).catch((t=>{console.log(`❌ Failed to load LUT: ${e}`),console.error(t)}))}async loadLUT(t){try{const e=await fetch(t),i=(await e.text()).split("\n"),n=[];let o=0;for(const t of i)if(t.startsWith("LUT_3D_SIZE"))o=parseInt(t.split(" ")[1],10);else if(!t.startsWith("#")&&""!==t.trim()){const e=t.split(" ").map(Number);3===e.length&&n.push(e)}if(!o)throw new Error("Invalid LUT file.");return{size:o,lut:n}}catch(t){throw new Error(`Error parsing LUT file: ${t.message}`)}}getLUT(){return this.isLoaded?this.lutData:(console.warn("❌ LUT not loaded yet."),null)}isLUTLoaded(){return this.isLoaded}},window.Raffaello_FullScreen=class Raffaello_FullScreen{constructor(t){this.previewContainers=document.querySelectorAll(`.${t.previewContainer}`),this.fullScreenElement=null,this.isFullScreen=!1,this.previewContainers.length?(this.initializeFullScreen(),this.setupEventListeners()):console.error("RAFFAELLO - No preview containers found.")}initializeFullScreen(){this.fullScreenElement=document.createElement("div"),this.fullScreenElement.classList.add("raffaello-fullscreen-overlay"),this.fullScreenElement.style.position="fixed",this.fullScreenElement.style.top="0",this.fullScreenElement.style.left="0",this.fullScreenElement.style.width="100%",this.fullScreenElement.style.height="100%",this.fullScreenElement.style.padding="25px",this.fullScreenElement.style.backgroundColor="rgba(0, 0, 0, 0.9)",this.fullScreenElement.style.display="none",this.fullScreenElement.style.zIndex="9999",this.fullScreenElement.style.cursor="pointer",this.fullScreenElement.style.alignItems="center",this.fullScreenElement.style.justifyContent="center";const t=document.createElement("img");t.style.maxWidth="100%",t.style.maxHeight="100%",t.setAttribute("draggable","false"),t.addEventListener("dragstart",(function(t){t.preventDefault()})),t.addEventListener("contextmenu",(function(t){t.preventDefault()})),this.fullScreenElement.appendChild(t),document.body.appendChild(this.fullScreenElement)}toggleFullScreen(){this.isFullScreen=!this.isFullScreen,this.isFullScreen?(this.fullScreenElement.style.display="flex",document.body.style.overflow="hidden"):(this.fullScreenElement.style.display="none",document.body.style.overflow="auto")}setupEventListeners(){this.previewContainers.forEach((t=>{t.style.cursor="pointer",t.addEventListener("click",(()=>{const e=t.src;this.fullScreenElement.querySelector("img").src=e,this.toggleFullScreen()}))})),this.fullScreenElement.addEventListener("click",(()=>{this.toggleFullScreen()}))}},window.Raffaello_PersistentInputs=class Raffaello_PersistentInputs{constructor({inputs:t,timeout:e}){this.textareas=document.querySelectorAll(`.${t}`),this.timeout=e,this.textareas.length?this.init():console.error(`INFO: No element with class ${t}`)}init(){this.cleanupOldKeys(),this.textareas.forEach(((t,e)=>{const i=this.generateKey(e);this.loadAndValidateContent(t,i);const n=this.debounce((()=>this.saveContent(t,i)),500);t.addEventListener("input",n)}))}cleanupOldKeys(){for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&e.startsWith("textareaContent_")&&localStorage.removeItem(e)}}generateKey(t){return`${window.location.pathname}_textareaContent_${this.timeout}_${t}`}loadAndValidateContent(t,e){const i=`${e}_timestamp`,n=localStorage.getItem(e),o=localStorage.getItem(i);if(n&&o){const r=Date.now()-parseInt(o,10);console.log("elapsed",r),console.log("this.timeout",this.timeout),r<=this.timeout?t.value=n:(console.log(`Key expired: ${e}`),localStorage.removeItem(e),localStorage.removeItem(i))}else localStorage.removeItem(e),localStorage.removeItem(i)}saveContent(t,e){const i=`${e}_timestamp`;localStorage.setItem(e,t.value),localStorage.setItem(i,Date.now().toString())}debounce(t,e){let i;return(...n)=>{clearTimeout(i),i=setTimeout((()=>t(...n)),e)}}},async function v_k(t=1){console.log(`> v_k() #${t}`);const e=document.currentScript||document.querySelector(a(12)),i=e?.dataset?.[atob("bGljZW5zZQ==")]||e?.dataset?.[atob("a2V5")],n=window.location[atob("aG9zdG5hbWU=")];if(!i)return console.log(a(1)),void d_r();const o=`${a(6)}${i}`,r=localStorage.getItem(o),s=Date.now();if(r&&s<parseInt(r))console.log("> g_k_u");else try{const t=await fetch(`${a(4)}${i}${a(5)}${n}`),e=await t.json();if(console.log("> res"),console.log(e),e.status!==a(10))return console.log(a(2)),void d_r();const r=s+1728e5;localStorage.setItem(o,r.toString())}catch(e){console.log(`${a(3)} (${t}/4)`),t<4?setTimeout((()=>v_k(t+1)),6e4):console.log(a(11))}}()}();
36
+ */var t,e;t=window,e=function(){function ownKeys(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,n)}return i}function _objectSpread2(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(Object(i),!0).forEach((function(e){_defineProperty(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):ownKeys(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function _defineProperty(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function _toConsumableArray(t){return function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}(t)||function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function _unsupportedIterableToArray(t,e){if(t){if("string"==typeof t)return _arrayLikeToArray(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?_arrayLikeToArray(t,e):void 0}}(t)||function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}var t="undefined"!=typeof window&&void 0!==window.document,e=t?window:{},i=!(!t||!e.document.documentElement)&&"ontouchstart"in e.document.documentElement,n=!!t&&"PointerEvent"in e,o="cropper",r="all",s="crop",h="move",l="zoom",c="e",d="w",p="s",u="n",m="ne",g="nw",f="se",v="sw",y="".concat(o,"-crop"),w="".concat(o,"-disabled"),b="".concat(o,"-hidden"),x="".concat(o,"-hide"),C="".concat(o,"-invisible"),k="".concat(o,"-modal"),L="".concat(o,"-move"),S="".concat(o,"Action"),E="".concat(o,"Preview"),D="crop",M="move",R="none",T="crop",I="cropend",N="cropmove",B="cropstart",A="dblclick",W=n?"pointerdown":i?"touchstart":"mousedown",O=n?"pointermove":i?"touchmove":"mousemove",z=n?"pointerup pointercancel":i?"touchend touchcancel":"mouseup",F="ready",_="resize",P="wheel",H="zoom",j="image/jpeg",Y=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,U=/^data:/,X=/^data:image\/jpeg;base64,/,$=/^img|canvas$/i,Z={viewMode:0,dragMode:D,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},q=Number.isNaN||e.isNaN;function isNumber(t){return"number"==typeof t&&!q(t)}var G=function isPositiveNumber(t){return t>0&&t<1/0};function isUndefined(t){return void 0===t}function isObject(t){return"object"===_typeof(t)&&null!==t}var V=Object.prototype.hasOwnProperty;function isPlainObject(t){if(!isObject(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&V.call(i,"isPrototypeOf")}catch(t){return!1}}function isFunction(t){return"function"==typeof t}var Q=Array.prototype.slice;function toArray(t){return Array.from?Array.from(t):Q.call(t)}function forEach(t,e){return t&&isFunction(e)&&(Array.isArray(t)||isNumber(t.length)?toArray(t).forEach((function(i,n){e.call(t,i,n,t)})):isObject(t)&&Object.keys(t).forEach((function(i){e.call(t,t[i],i,t)}))),t}var K=Object.assign||function assign(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),n=1;n<e;n++)i[n-1]=arguments[n];return isObject(t)&&i.length>0&&i.forEach((function(e){isObject(e)&&Object.keys(e).forEach((function(i){t[i]=e[i]}))})),t},J=/\.\d*(?:0|9){12}\d*$/;function normalizeDecimalNumber(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return J.test(t)?Math.round(t*e)/e:t}var tt=/^width|height|left|top|marginLeft|marginTop$/;function setStyle(t,e){var i=t.style;forEach(e,(function(t,e){tt.test(e)&&isNumber(t)&&(t="".concat(t,"px")),i[e]=t}))}function addClass(t,e){if(e)if(isNumber(t.length))forEach(t,(function(t){addClass(t,e)}));else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function removeClass(t,e){e&&(isNumber(t.length)?forEach(t,(function(t){removeClass(t,e)})):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function toggleClass(t,e,i){e&&(isNumber(t.length)?forEach(t,(function(t){toggleClass(t,e,i)})):i?addClass(t,e):removeClass(t,e))}var et=/([a-z\d])([A-Z])/g;function toParamCase(t){return t.replace(et,"$1-$2").toLowerCase()}function getData(t,e){return isObject(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(toParamCase(e)))}function setData(t,e,i){isObject(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(toParamCase(e)),i)}var it=/\s\s*/,at=function(){var i=!1;if(t){var n=!1,o=function listener(){},r=Object.defineProperty({},"once",{get:function get(){return i=!0,n},set:function set(t){n=t}});e.addEventListener("test",o,r),e.removeEventListener("test",o,r)}return i}();function removeListener(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i;e.trim().split(it).forEach((function(e){if(!at){var r=t.listeners;r&&r[e]&&r[e][i]&&(o=r[e][i],delete r[e][i],0===Object.keys(r[e]).length&&delete r[e],0===Object.keys(r).length&&delete t.listeners)}t.removeEventListener(e,o,n)}))}function addListener(t,e,i){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=i;e.trim().split(it).forEach((function(e){if(n.once&&!at){var r=t.listeners,s=void 0===r?{}:r;o=function handler(){delete s[e][i],t.removeEventListener(e,o,n);for(var r=arguments.length,h=new Array(r),l=0;l<r;l++)h[l]=arguments[l];i.apply(t,h)},s[e]||(s[e]={}),s[e][i]&&t.removeEventListener(e,s[e][i],n),s[e][i]=o,t.listeners=s}t.addEventListener(e,o,n)}))}function dispatchEvent(t,e,i){var n;return isFunction(Event)&&isFunction(CustomEvent)?n=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(n=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(n)}function getOffset(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var nt=e.location,ot=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function isCrossOriginURL(t){var e=t.match(ot);return null!==e&&(e[1]!==nt.protocol||e[2]!==nt.hostname||e[3]!==nt.port)}function addTimestamp(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function getTransforms(t){var e=t.rotate,i=t.scaleX,n=t.scaleY,o=t.translateX,r=t.translateY,s=[];isNumber(o)&&0!==o&&s.push("translateX(".concat(o,"px)")),isNumber(r)&&0!==r&&s.push("translateY(".concat(r,"px)")),isNumber(e)&&0!==e&&s.push("rotate(".concat(e,"deg)")),isNumber(i)&&1!==i&&s.push("scaleX(".concat(i,")")),isNumber(n)&&1!==n&&s.push("scaleY(".concat(n,")"));var h=s.length?s.join(" "):"none";return{WebkitTransform:h,msTransform:h,transform:h}}function getPointer(t,e){var i=t.pageX,n=t.pageY,o={endX:i,endY:n};return e?o:_objectSpread2({startX:i,startY:n},o)}function getAdjustedSizes(t){var e=t.aspectRatio,i=t.height,n=t.width,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",r=G(n),s=G(i);if(r&&s){var h=i*e;"contain"===o&&h>n||"cover"===o&&h<n?i=n/e:n=i*e}else r?i=n/e:s&&(n=i*e);return{width:n,height:i}}var rt=String.fromCharCode,st=/^data:.*,/;function resetAndGetOrientation(t){var e,i=new DataView(t);try{var n,o,r;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var s=i.byteLength,h=2;h+1<s;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){o=h;break}h+=1}if(o){var l=o+10;if("Exif"===function getStringFromCharCode(t,e,i){var n="";i+=e;for(var o=e;o<i;o+=1)n+=rt(t.getUint8(o));return n}(i,o+4,4)){var c=i.getUint16(l);if(((n=18761===c)||19789===c)&&42===i.getUint16(l+2,n)){var d=i.getUint32(l+4,n);d>=8&&(r=l+d)}}}if(r){var p,u,m=i.getUint16(r,n);for(u=0;u<m;u+=1)if(p=r+12*u+2,274===i.getUint16(p,n)){p+=8,e=i.getUint16(p,n),i.setUint16(p,1,n);break}}}catch(t){e=1}return e}var ht={render:function render(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function initContainer(){var t=this.element,e=this.options,i=this.container,n=this.cropper,o=Number(e.minContainerWidth),r=Number(e.minContainerHeight);addClass(n,b),removeClass(t,b);var s={width:Math.max(i.offsetWidth,o>=0?o:200),height:Math.max(i.offsetHeight,r>=0?r:100)};this.containerData=s,setStyle(n,{width:s.width,height:s.height}),addClass(t,b),removeClass(n,b)},initCanvas:function initCanvas(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,n=Math.abs(e.rotate)%180==90,o=n?e.naturalHeight:e.naturalWidth,r=n?e.naturalWidth:e.naturalHeight,s=o/r,h=t.width,l=t.height;t.height*s>t.width?3===i?h=t.height*s:l=t.width/s:3===i?l=t.width/s:h=t.height*s;var c={aspectRatio:s,naturalWidth:o,naturalHeight:r,width:h,height:l};this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),c.width=Math.min(Math.max(c.width,c.minWidth),c.maxWidth),c.height=Math.min(Math.max(c.height,c.minHeight),c.maxHeight),c.left=(t.width-c.width)/2,c.top=(t.height-c.height)/2,c.oldLeft=c.left,c.oldTop=c.top,this.initialCanvasData=K({},c)},limitCanvas:function limitCanvas(t,e){var i=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,s=i.viewMode,h=o.aspectRatio,l=this.cropped&&r;if(t){var c=Number(i.minCanvasWidth)||0,d=Number(i.minCanvasHeight)||0;s>1?(c=Math.max(c,n.width),d=Math.max(d,n.height),3===s&&(d*h>c?c=d*h:d=c/h)):s>0&&(c?c=Math.max(c,l?r.width:0):d?d=Math.max(d,l?r.height:0):l&&(c=r.width,(d=r.height)*h>c?c=d*h:d=c/h));var p=getAdjustedSizes({aspectRatio:h,width:c,height:d});c=p.width,d=p.height,o.minWidth=c,o.minHeight=d,o.maxWidth=1/0,o.maxHeight=1/0}if(e)if(s>(l?0:1)){var u=n.width-o.width,m=n.height-o.height;o.minLeft=Math.min(0,u),o.minTop=Math.min(0,m),o.maxLeft=Math.max(0,u),o.maxTop=Math.max(0,m),l&&this.limited&&(o.minLeft=Math.min(r.left,r.left+(r.width-o.width)),o.minTop=Math.min(r.top,r.top+(r.height-o.height)),o.maxLeft=r.left,o.maxTop=r.top,2===s&&(o.width>=n.width&&(o.minLeft=Math.min(0,u),o.maxLeft=Math.max(0,u)),o.height>=n.height&&(o.minTop=Math.min(0,m),o.maxTop=Math.max(0,m))))}else o.minLeft=-o.width,o.minTop=-o.height,o.maxLeft=n.width,o.maxTop=n.height},renderCanvas:function renderCanvas(t,e){var i=this.canvasData,n=this.imageData;if(e){var o=function getRotatedSizes(t){var e=t.width,i=t.height,n=t.degree;if(90==(n=Math.abs(n)%180))return{width:i,height:e};var o=n%90*Math.PI/180,r=Math.sin(o),s=Math.cos(o),h=e*s+i*r,l=e*r+i*s;return n>90?{width:l,height:h}:{width:h,height:l}}({width:n.naturalWidth*Math.abs(n.scaleX||1),height:n.naturalHeight*Math.abs(n.scaleY||1),degree:n.rotate||0}),r=o.width,s=o.height,h=i.width*(r/i.naturalWidth),l=i.height*(s/i.naturalHeight);i.left-=(h-i.width)/2,i.top-=(l-i.height)/2,i.width=h,i.height=l,i.aspectRatio=r/s,i.naturalWidth=r,i.naturalHeight=s,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,setStyle(this.canvas,K({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function renderImage(t){var e=this.canvasData,i=this.imageData,n=i.naturalWidth*(e.width/e.naturalWidth),o=i.naturalHeight*(e.height/e.naturalHeight);K(i,{width:n,height:o,left:(e.width-n)/2,top:(e.height-o)/2}),setStyle(this.image,K({width:i.width,height:i.height},getTransforms(K({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function initCropBox(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,n=Number(t.autoCropArea)||.8,o={width:e.width,height:e.height};i&&(e.height*i>e.width?o.height=o.width/i:o.width=o.height*i),this.cropBoxData=o,this.limitCropBox(!0,!0),o.width=Math.min(Math.max(o.width,o.minWidth),o.maxWidth),o.height=Math.min(Math.max(o.height,o.minHeight),o.maxHeight),o.width=Math.max(o.minWidth,o.width*n),o.height=Math.max(o.minHeight,o.height*n),o.left=e.left+(e.width-o.width)/2,o.top=e.top+(e.height-o.height)/2,o.oldLeft=o.left,o.oldTop=o.top,this.initialCropBoxData=K({},o)},limitCropBox:function limitCropBox(t,e){var i=this.options,n=this.containerData,o=this.canvasData,r=this.cropBoxData,s=this.limited,h=i.aspectRatio;if(t){var l=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,d=s?Math.min(n.width,o.width,o.width+o.left,n.width-o.left):n.width,p=s?Math.min(n.height,o.height,o.height+o.top,n.height-o.top):n.height;l=Math.min(l,n.width),c=Math.min(c,n.height),h&&(l&&c?c*h>l?c=l/h:l=c*h:l?c=l/h:c&&(l=c*h),p*h>d?p=d/h:d=p*h),r.minWidth=Math.min(l,d),r.minHeight=Math.min(c,p),r.maxWidth=d,r.maxHeight=p}e&&(s?(r.minLeft=Math.max(0,o.left),r.minTop=Math.max(0,o.top),r.maxLeft=Math.min(n.width,o.left+o.width)-r.width,r.maxTop=Math.min(n.height,o.top+o.height)-r.height):(r.minLeft=0,r.minTop=0,r.maxLeft=n.width-r.width,r.maxTop=n.height-r.height))},renderCropBox:function renderCropBox(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&setData(this.face,S,i.width>=e.width&&i.height>=e.height?h:r),setStyle(this.cropBox,K({width:i.width,height:i.height},getTransforms({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function output(){this.preview(),dispatchEvent(this.element,T,this.getData())}},lt={initPreview:function initPreview(){var t=this.element,e=this.crossOrigin,i=this.options.preview,n=e?this.crossOriginUrl:this.url,o=t.alt||"The image to preview",r=document.createElement("img");if(e&&(r.crossOrigin=e),r.src=n,r.alt=o,this.viewBox.appendChild(r),this.viewBoxImage=r,i){var s=i;"string"==typeof i?s=t.ownerDocument.querySelectorAll(i):i.querySelector&&(s=[i]),this.previews=s,forEach(s,(function(t){var i=document.createElement("img");setData(t,E,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=n,i.alt=o,i.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(i)}))}},resetPreview:function resetPreview(){forEach(this.previews,(function(t){var e=getData(t,E);setStyle(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function removeData(t,e){if(isObject(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(toParamCase(e)))}(t,E)}))},preview:function preview(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,n=i.width,o=i.height,r=t.width,s=t.height,h=i.left-e.left-t.left,l=i.top-e.top-t.top;this.cropped&&!this.disabled&&(setStyle(this.viewBoxImage,K({width:r,height:s},getTransforms(K({translateX:-h,translateY:-l},t)))),forEach(this.previews,(function(e){var i=getData(e,E),c=i.width,d=i.height,p=c,u=d,m=1;n&&(u=o*(m=c/n)),o&&u>d&&(p=n*(m=d/o),u=d),setStyle(e,{width:p,height:u}),setStyle(e.getElementsByTagName("img")[0],K({width:r*m,height:s*m},getTransforms(K({translateX:-h*m,translateY:-l*m},t))))})))}},ct={bind:function bind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&addListener(t,B,e.cropstart),isFunction(e.cropmove)&&addListener(t,N,e.cropmove),isFunction(e.cropend)&&addListener(t,I,e.cropend),isFunction(e.crop)&&addListener(t,T,e.crop),isFunction(e.zoom)&&addListener(t,H,e.zoom),addListener(i,W,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&addListener(i,P,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&addListener(i,A,this.onDblclick=this.dblclick.bind(this)),addListener(t.ownerDocument,O,this.onCropMove=this.cropMove.bind(this)),addListener(t.ownerDocument,z,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&addListener(window,_,this.onResize=this.resize.bind(this))},unbind:function unbind(){var t=this.element,e=this.options,i=this.cropper;isFunction(e.cropstart)&&removeListener(t,B,e.cropstart),isFunction(e.cropmove)&&removeListener(t,N,e.cropmove),isFunction(e.cropend)&&removeListener(t,I,e.cropend),isFunction(e.crop)&&removeListener(t,T,e.crop),isFunction(e.zoom)&&removeListener(t,H,e.zoom),removeListener(i,W,this.onCropStart),e.zoomable&&e.zoomOnWheel&&removeListener(i,P,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&removeListener(i,A,this.onDblclick),removeListener(t.ownerDocument,O,this.onCropMove),removeListener(t.ownerDocument,z,this.onCropEnd),e.responsive&&removeListener(window,_,this.onResize)}},dt={resize:function resize(){if(!this.disabled){var t,e,i=this.options,n=this.container,o=this.containerData,r=n.offsetWidth/o.width,s=n.offsetHeight/o.height,h=Math.abs(r-1)>Math.abs(s-1)?r:s;1!==h&&(i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(forEach(t,(function(e,i){t[i]=e*h}))),this.setCropBoxData(forEach(e,(function(t,i){e[i]=t*h})))))}},dblclick:function dblclick(){this.disabled||this.options.dragMode===R||this.setDragMode(function hasClass(t,e){return t.classList?t.classList.contains(e):t.className.indexOf(e)>-1}(this.dragBox,y)?M:D)},wheel:function wheel(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,n=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout((function(){e.wheeling=!1}),50),t.deltaY?n=t.deltaY>0?1:-1:t.wheelDelta?n=-t.wheelDelta/120:t.detail&&(n=t.detail>0?1:-1),this.zoom(-n*i,t)))},cropStart:function cropStart(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(isNumber(e)&&1!==e||isNumber(i)&&0!==i||t.ctrlKey))){var n,o=this.options,r=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){r[t.identifier]=getPointer(t)})):r[t.pointerId||0]=getPointer(t),n=Object.keys(r).length>1&&o.zoomable&&o.zoomOnTouch?l:getData(t.target,S),Y.test(n)&&!1!==dispatchEvent(this.element,B,{originalEvent:t,action:n})&&(t.preventDefault(),this.action=n,this.cropping=!1,n===s&&(this.cropping=!0,addClass(this.dragBox,k)))}},cropMove:function cropMove(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==dispatchEvent(this.element,N,{originalEvent:t,action:e})&&(t.changedTouches?forEach(t.changedTouches,(function(t){K(i[t.identifier]||{},getPointer(t,!0))})):K(i[t.pointerId||0]||{},getPointer(t,!0)),this.change(t))}},cropEnd:function cropEnd(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?forEach(t.changedTouches,(function(t){delete i[t.identifier]})):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,toggleClass(this.dragBox,k,this.cropped&&this.options.modal)),dispatchEvent(this.element,I,{originalEvent:t,action:e}))}}},pt={change:function change(t){var e,i=this.options,n=this.canvasData,o=this.containerData,y=this.cropBoxData,w=this.pointers,x=this.action,C=i.aspectRatio,k=y.left,L=y.top,S=y.width,E=y.height,D=k+S,M=L+E,R=0,T=0,I=o.width,N=o.height,B=!0;!C&&t.shiftKey&&(C=S&&E?S/E:1),this.limited&&(R=y.minLeft,T=y.minTop,I=R+Math.min(o.width,n.width,n.left+n.width),N=T+Math.min(o.height,n.height,n.top+n.height));var A=w[Object.keys(w)[0]],W={x:A.endX-A.startX,y:A.endY-A.startY},O=function check(t){switch(t){case c:D+W.x>I&&(W.x=I-D);break;case d:k+W.x<R&&(W.x=R-k);break;case u:L+W.y<T&&(W.y=T-L);break;case p:M+W.y>N&&(W.y=N-M)}};switch(x){case r:k+=W.x,L+=W.y;break;case c:if(W.x>=0&&(D>=I||C&&(L<=T||M>=N))){B=!1;break}O(c),(S+=W.x)<0&&(x=d,k-=S=-S),C&&(E=S/C,L+=(y.height-E)/2);break;case u:if(W.y<=0&&(L<=T||C&&(k<=R||D>=I))){B=!1;break}O(u),E-=W.y,L+=W.y,E<0&&(x=p,L-=E=-E),C&&(S=E*C,k+=(y.width-S)/2);break;case d:if(W.x<=0&&(k<=R||C&&(L<=T||M>=N))){B=!1;break}O(d),S-=W.x,k+=W.x,S<0&&(x=c,k-=S=-S),C&&(E=S/C,L+=(y.height-E)/2);break;case p:if(W.y>=0&&(M>=N||C&&(k<=R||D>=I))){B=!1;break}O(p),(E+=W.y)<0&&(x=u,L-=E=-E),C&&(S=E*C,k+=(y.width-S)/2);break;case m:if(C){if(W.y<=0&&(L<=T||D>=I)){B=!1;break}O(u),E-=W.y,L+=W.y,S=E*C}else O(u),O(c),W.x>=0?D<I?S+=W.x:W.y<=0&&L<=T&&(B=!1):S+=W.x,W.y<=0?L>T&&(E-=W.y,L+=W.y):(E-=W.y,L+=W.y);S<0&&E<0?(x=v,L-=E=-E,k-=S=-S):S<0?(x=g,k-=S=-S):E<0&&(x=f,L-=E=-E);break;case g:if(C){if(W.y<=0&&(L<=T||k<=R)){B=!1;break}O(u),E-=W.y,L+=W.y,S=E*C,k+=y.width-S}else O(u),O(d),W.x<=0?k>R?(S-=W.x,k+=W.x):W.y<=0&&L<=T&&(B=!1):(S-=W.x,k+=W.x),W.y<=0?L>T&&(E-=W.y,L+=W.y):(E-=W.y,L+=W.y);S<0&&E<0?(x=f,L-=E=-E,k-=S=-S):S<0?(x=m,k-=S=-S):E<0&&(x=v,L-=E=-E);break;case v:if(C){if(W.x<=0&&(k<=R||M>=N)){B=!1;break}O(d),S-=W.x,k+=W.x,E=S/C}else O(p),O(d),W.x<=0?k>R?(S-=W.x,k+=W.x):W.y>=0&&M>=N&&(B=!1):(S-=W.x,k+=W.x),W.y>=0?M<N&&(E+=W.y):E+=W.y;S<0&&E<0?(x=m,L-=E=-E,k-=S=-S):S<0?(x=f,k-=S=-S):E<0&&(x=g,L-=E=-E);break;case f:if(C){if(W.x>=0&&(D>=I||M>=N)){B=!1;break}O(c),E=(S+=W.x)/C}else O(p),O(c),W.x>=0?D<I?S+=W.x:W.y>=0&&M>=N&&(B=!1):S+=W.x,W.y>=0?M<N&&(E+=W.y):E+=W.y;S<0&&E<0?(x=g,L-=E=-E,k-=S=-S):S<0?(x=v,k-=S=-S):E<0&&(x=m,L-=E=-E);break;case h:this.move(W.x,W.y),B=!1;break;case l:this.zoom(function getMaxZoomRatio(t){var e=_objectSpread2({},t),i=0;return forEach(t,(function(t,n){delete e[n],forEach(e,(function(e){var n=Math.abs(t.startX-e.startX),o=Math.abs(t.startY-e.startY),r=Math.abs(t.endX-e.endX),s=Math.abs(t.endY-e.endY),h=Math.sqrt(n*n+o*o),l=(Math.sqrt(r*r+s*s)-h)/h;Math.abs(l)>Math.abs(i)&&(i=l)}))})),i}(w),t),B=!1;break;case s:if(!W.x||!W.y){B=!1;break}e=getOffset(this.cropper),k=A.startX-e.left,L=A.startY-e.top,S=y.minWidth,E=y.minHeight,W.x>0?x=W.y>0?f:m:W.x<0&&(k-=S,x=W.y>0?v:g),W.y<0&&(L-=E),this.cropped||(removeClass(this.cropBox,b),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}B&&(y.width=S,y.height=E,y.left=k,y.top=L,this.action=x,this.renderCropBox()),forEach(w,(function(t){t.startX=t.endX,t.startY=t.endY}))}},ut={crop:function crop(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&addClass(this.dragBox,k),removeClass(this.cropBox,b),this.setCropBoxData(this.initialCropBoxData)),this},reset:function reset(){return this.ready&&!this.disabled&&(this.imageData=K({},this.initialImageData),this.canvasData=K({},this.initialCanvasData),this.cropBoxData=K({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function clear(){return this.cropped&&!this.disabled&&(K(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),removeClass(this.dragBox,k),addClass(this.cropBox,b)),this},replace:function replace(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,forEach(this.previews,(function(e){e.getElementsByTagName("img")[0].src=t})))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function enable(){return this.ready&&this.disabled&&(this.disabled=!1,removeClass(this.cropper,w)),this},disable:function disable(){return this.ready&&!this.disabled&&(this.disabled=!0,addClass(this.cropper,w)),this},destroy:function destroy(){var t=this.element;return t[o]?(t[o]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function move(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,n=i.left,o=i.top;return this.moveTo(isUndefined(t)?t:n+Number(t),isUndefined(e)?e:o+Number(e))},moveTo:function moveTo(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(isNumber(t)&&(i.left=t,n=!0),isNumber(e)&&(i.top=e,n=!0),n&&this.renderCanvas(!0)),this},zoom:function zoom(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function zoomTo(t,e,i){var n=this.options,o=this.canvasData,r=o.width,s=o.height,h=o.naturalWidth,l=o.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&n.zoomable){var c=h*t,d=l*t;if(i){var p=this.pointers,u=getOffset(this.cropper),m=p&&Object.keys(p).length?function getPointersCenter(t){var e=0,i=0,n=0;return forEach(t,(function(t){var o=t.startX,r=t.startY;e+=o,i+=r,n+=1})),{pageX:e/=n,pageY:i/=n}}(p):{pageX:i.pageX,pageY:i.pageY};o.left-=(c-r)*((m.pageX-u.left-o.left)/r),o.top-=(d-s)*((m.pageY-u.top-o.top)/s)}else isPlainObject(e)&&isNumber(e.x)&&isNumber(e.y)?(o.left-=(c-r)*((e.x-o.left)/r),o.top-=(d-s)*((e.y-o.top)/s)):(o.left-=(c-r)/2,o.top-=(d-s)/2);if(o.width=c,o.height=d,this.renderCanvas(!0),!1===dispatchEvent(this.element,H,{ratio:t,oldRatio:r/h,originalEvent:i}))return this}return this},rotate:function rotate(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function rotateTo(t){return isNumber(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function scaleX(t){var e=this.imageData.scaleY;return this.scale(t,isNumber(e)?e:1)},scaleY:function scaleY(t){var e=this.imageData.scaleX;return this.scale(isNumber(e)?e:1,t)},scale:function scale(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,n=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(isNumber(t)&&(i.scaleX=t,n=!0),isNumber(e)&&(i.scaleY=e,n=!0),n&&this.renderCanvas(!0,!0)),this},getData:function getData(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,n=this.imageData,o=this.canvasData,r=this.cropBoxData;if(this.ready&&this.cropped){t={x:r.left-o.left,y:r.top-o.top,width:r.width,height:r.height};var s=n.width/n.naturalWidth;if(forEach(t,(function(e,i){t[i]=e/s})),e){var h=Math.round(t.y+t.height),l=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=l-t.x,t.height=h-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=n.rotate||0),i.scalable&&(t.scaleX=n.scaleX||1,t.scaleY=n.scaleY||1),t},setData:function setData(t){var e=this.options,i=this.imageData,n=this.canvasData,o={};if(this.ready&&!this.disabled&&isPlainObject(t)){var r=!1;e.rotatable&&isNumber(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,r=!0),e.scalable&&(isNumber(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,r=!0),isNumber(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,r=!0)),r&&this.renderCanvas(!0,!0);var s=i.width/i.naturalWidth;isNumber(t.x)&&(o.left=t.x*s+n.left),isNumber(t.y)&&(o.top=t.y*s+n.top),isNumber(t.width)&&(o.width=t.width*s),isNumber(t.height)&&(o.height=t.height*s),this.setCropBoxData(o)}return this},getContainerData:function getContainerData(){return this.ready?K({},this.containerData):{}},getImageData:function getImageData(){return this.sized?K({},this.imageData):{}},getCanvasData:function getCanvasData(){var t=this.canvasData,e={};return this.ready&&forEach(["left","top","width","height","naturalWidth","naturalHeight"],(function(i){e[i]=t[i]})),e},setCanvasData:function setCanvasData(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(e.left=t.left),isNumber(t.top)&&(e.top=t.top),isNumber(t.width)?(e.width=t.width,e.height=t.width/i):isNumber(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function getCropBoxData(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function setCropBoxData(t){var e,i,n=this.cropBoxData,o=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&isPlainObject(t)&&(isNumber(t.left)&&(n.left=t.left),isNumber(t.top)&&(n.top=t.top),isNumber(t.width)&&t.width!==n.width&&(e=!0,n.width=t.width),isNumber(t.height)&&t.height!==n.height&&(i=!0,n.height=t.height),o&&(e?n.height=n.width/o:i&&(n.width=n.height*o)),this.renderCropBox()),this},getCroppedCanvas:function getCroppedCanvas(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=function getSourceCanvas(t,e,i,n){var o=e.aspectRatio,r=e.naturalWidth,s=e.naturalHeight,h=e.rotate,l=void 0===h?0:h,c=e.scaleX,d=void 0===c?1:c,p=e.scaleY,u=void 0===p?1:p,m=i.aspectRatio,g=i.naturalWidth,f=i.naturalHeight,v=n.fillColor,y=void 0===v?"transparent":v,w=n.imageSmoothingEnabled,b=void 0===w||w,x=n.imageSmoothingQuality,C=void 0===x?"low":x,k=n.maxWidth,L=void 0===k?1/0:k,S=n.maxHeight,E=void 0===S?1/0:S,D=n.minWidth,M=void 0===D?0:D,R=n.minHeight,T=void 0===R?0:R,I=document.createElement("canvas"),N=I.getContext("2d"),B=getAdjustedSizes({aspectRatio:m,width:L,height:E}),A=getAdjustedSizes({aspectRatio:m,width:M,height:T},"cover"),W=Math.min(B.width,Math.max(A.width,g)),O=Math.min(B.height,Math.max(A.height,f)),z=getAdjustedSizes({aspectRatio:o,width:L,height:E}),F=getAdjustedSizes({aspectRatio:o,width:M,height:T},"cover"),_=Math.min(z.width,Math.max(F.width,r)),P=Math.min(z.height,Math.max(F.height,s)),H=[-_/2,-P/2,_,P];return I.width=normalizeDecimalNumber(W),I.height=normalizeDecimalNumber(O),N.fillStyle=y,N.fillRect(0,0,W,O),N.save(),N.translate(W/2,O/2),N.rotate(l*Math.PI/180),N.scale(d,u),N.imageSmoothingEnabled=b,N.imageSmoothingQuality=C,N.drawImage.apply(N,[t].concat(_toConsumableArray(H.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),N.restore(),I}(this.image,this.imageData,e,t);if(!this.cropped)return i;var n=this.getData(),o=n.x,r=n.y,s=n.width,h=n.height,l=i.width/Math.floor(e.naturalWidth);1!==l&&(o*=l,r*=l,s*=l,h*=l);var c=s/h,d=getAdjustedSizes({aspectRatio:c,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),p=getAdjustedSizes({aspectRatio:c,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=getAdjustedSizes({aspectRatio:c,width:t.width||(1!==l?i.width:s),height:t.height||(1!==l?i.height:h)}),m=u.width,g=u.height;m=Math.min(d.width,Math.max(p.width,m)),g=Math.min(d.height,Math.max(p.height,g));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=normalizeDecimalNumber(m),f.height=normalizeDecimalNumber(g),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,m,g);var y=t.imageSmoothingEnabled,w=void 0===y||y,b=t.imageSmoothingQuality;v.imageSmoothingEnabled=w,b&&(v.imageSmoothingQuality=b);var x,C,k,L,S,E,D=i.width,M=i.height,R=o,T=r;R<=-s||R>D?(R=0,x=0,k=0,S=0):R<=0?(k=-R,R=0,S=x=Math.min(D,s+R)):R<=D&&(k=0,S=x=Math.min(s,D-R)),x<=0||T<=-h||T>M?(T=0,C=0,L=0,E=0):T<=0?(L=-T,T=0,E=C=Math.min(M,h+T)):T<=M&&(L=0,E=C=Math.min(h,M-T));var I=[R,T,x,C];if(S>0&&E>0){var N=m/s;I.push(k*N,L*N,S*N,E*N)}return v.drawImage.apply(v,[i].concat(_toConsumableArray(I.map((function(t){return Math.floor(normalizeDecimalNumber(t))}))))),f},setAspectRatio:function setAspectRatio(t){var e=this.options;return this.disabled||isUndefined(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function setDragMode(t){var e=this.options,i=this.dragBox,n=this.face;if(this.ready&&!this.disabled){var o=t===D,r=e.movable&&t===M;t=o||r?t:R,e.dragMode=t,setData(i,S,t),toggleClass(i,y,o),toggleClass(i,L,r),e.cropBoxMovable||(setData(n,S,t),toggleClass(n,y,o),toggleClass(n,L,r))}return this}},mt=e.Cropper,gt=function(){function Cropper(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,Cropper),!t||!$.test(t.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=t,this.options=K({},Z,isPlainObject(e)&&e),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}(Cropper,[{key:"init",value:function init(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[o]){if(e[o]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function load(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,n=this.options;if(n.rotatable||n.scalable||(n.checkOrientation=!1),n.checkOrientation&&window.ArrayBuffer)if(U.test(t))X.test(t)?this.read(function dataURLToArrayBuffer(t){var e=t.replace(st,""),i=atob(e),n=new ArrayBuffer(i.length),o=new Uint8Array(n);return forEach(o,(function(t,e){o[e]=i.charCodeAt(e)})),n}(t)):this.clone();else{var o=new XMLHttpRequest,r=this.clone.bind(this);this.reloading=!0,this.xhr=o,o.onabort=r,o.onerror=r,o.ontimeout=r,o.onprogress=function(){o.getResponseHeader("content-type")!==j&&o.abort()},o.onload=function(){e.read(o.response)},o.onloadend=function(){e.reloading=!1,e.xhr=null},n.checkCrossOrigin&&isCrossOriginURL(t)&&i.crossOrigin&&(t=addTimestamp(t)),o.open("GET",t,!0),o.responseType="arraybuffer",o.withCredentials="use-credentials"===i.crossOrigin,o.send()}else this.clone()}}},{key:"read",value:function read(t){var e=this.options,i=this.imageData,n=resetAndGetOrientation(t),o=0,r=1,s=1;if(n>1){this.url=function arrayBufferToDataURL(t,e){for(var i=[],n=new Uint8Array(t);n.length>0;)i.push(rt.apply(null,toArray(n.subarray(0,8192)))),n=n.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,j);var h=function parseOrientation(t){var e=0,i=1,n=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:n=-1;break;case 5:e=90,n=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:n}}(n);o=h.rotate,r=h.scaleX,s=h.scaleY}e.rotatable&&(i.rotate=o),e.scalable&&(i.scaleX=r,i.scaleY=s),this.clone()}},{key:"clone",value:function clone(){var t=this.element,e=this.url,i=t.crossOrigin,n=e;this.options.checkCrossOrigin&&isCrossOriginURL(e)&&(i||(i="anonymous"),n=addTimestamp(e)),this.crossOrigin=i,this.crossOriginUrl=n;var o=document.createElement("img");i&&(o.crossOrigin=i),o.src=n||e,o.alt=t.alt||"The image to crop",this.image=o,o.onload=this.start.bind(this),o.onerror=this.stop.bind(this),addClass(o,x),t.parentNode.insertBefore(o,t.nextSibling)}},{key:"start",value:function start(){var t=this,i=this.image;i.onload=null,i.onerror=null,this.sizing=!0;var n=e.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(e.navigator.userAgent),o=function done(e,i){K(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.initialImageData=K({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(!i.naturalWidth||n){var r=document.createElement("img"),s=document.body||document.documentElement;this.sizingImage=r,r.onload=function(){o(r.width,r.height),n||s.removeChild(r)},r.src=i.src,n||(r.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",s.appendChild(r))}else o(i.naturalWidth,i.naturalHeight)}},{key:"stop",value:function stop(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function build(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,n=t.parentNode,s=document.createElement("div");s.innerHTML='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';var h=s.querySelector(".".concat(o,"-container")),l=h.querySelector(".".concat(o,"-canvas")),c=h.querySelector(".".concat(o,"-drag-box")),d=h.querySelector(".".concat(o,"-crop-box")),p=d.querySelector(".".concat(o,"-face"));this.container=n,this.cropper=h,this.canvas=l,this.dragBox=c,this.cropBox=d,this.viewBox=h.querySelector(".".concat(o,"-view-box")),this.face=p,l.appendChild(i),addClass(t,b),n.insertBefore(h,t.nextSibling),removeClass(i,x),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,addClass(d,b),e.guides||addClass(d.getElementsByClassName("".concat(o,"-dashed")),b),e.center||addClass(d.getElementsByClassName("".concat(o,"-center")),b),e.background&&addClass(h,"".concat(o,"-bg")),e.highlight||addClass(p,C),e.cropBoxMovable&&(addClass(p,L),setData(p,S,r)),e.cropBoxResizable||(addClass(d.getElementsByClassName("".concat(o,"-line")),b),addClass(d.getElementsByClassName("".concat(o,"-point")),b)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),isFunction(e.ready)&&addListener(t,F,e.ready,{once:!0}),dispatchEvent(t,F)}}},{key:"unbuild",value:function unbuild(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var t=this.cropper.parentNode;t&&t.removeChild(this.cropper),removeClass(this.element,b)}}},{key:"uncreate",value:function uncreate(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}],[{key:"noConflict",value:function noConflict(){return window.Cropper=mt,Cropper}},{key:"setDefaults",value:function setDefaults(t){K(Z,isPlainObject(t)&&t)}}]),Cropper}();return K(gt.prototype,ht,lt,ct,dt,pt,ut),gt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).Cropper=e(),window.validLicenseCheckPassed=!0,window.systemVerified=!0,window.initComplete=!0;const i=["","Uk-FGRkF-FTExPOiBO-byBsaWNlb-nNlIGtleSB-wcm92aWRlZA==","UkFGRk-FFTExPOiBJbnZhbGlk-IG9yIHVuYXV0-aG9yaXp-lZCBsa-WNlbnNlIGtleQ==","UkFGR-kFFTE-xPOiBDb3VsZCBub3QgdmFsaWRhdGU-gbGljZW5zZSBrZX-kgKG5ldHdvcmsg-aXNzdWU/KQ==","aHR0cHM6Ly9-yYWZmYW-VsbG8ub25yZW5kZXIuY29tL2xpY2Vu-Y2U/a2V5PQ==","JmRv-bWFp-bj0=","UkFGRkF-FTExPX2xpY-2VuY2-VfY2hlY2-tlZF8=","Um-FmZmF-lbGxvX0N-hbnZh-cw==","c-mVuZ-GV-y","cmVu-ZGVy-UH-Jldmlldw==","dm-FsaW-Q=","TGljZW5-zZSB2YWxpZGF0aW9uIGNvdWxkIG5-vdCBiZSBjb25maXJtZWQuIENvbnRpbn-Vpbmcgd2l0aG91dCBkaXNhY-mxpbmcu","c2N-yaXB0W3N-yYyo9InJhZ-mZhZWxsbyJd","c2N-yaXB0W3N-yYyo9InJhZ-mZhZWxsbyJd",""];function a(t){return atob(i[t].split("").filter((t=>"-"!==t)).join(""))}window.r_o=!0;class Raffaello_CanvasLayer{constructor(t,e,i="normal",n=null){this.canvas=document.createElement("canvas"),this.canvas.width=t,this.canvas.height=e,this.context=this.canvas.getContext("2d",{willReadFrequently:!0}),this.type=i,this.effect=n,this.drawInstructions=null,this.bounds={minX:null,minY:null,maxX:null,maxY:null},this.isDrawn=!1}draw(t){return this.drawInstructions=t,this.drawInstructions(),this.isDrawn=!0,this}drawText(t){if(!t.text)return void(this.bounds={minX:null,maxX:null,minY:null,maxY:null});let e;if(t.text instanceof HTMLInputElement||t.text instanceof HTMLTextAreaElement)e=t.text.value;else{if("string"!=typeof t.text)return console.log("Error on the drawText(), the text input is not a valid string."),void console.log(t.text);e=t.text}const i={fontKerningOptical:!1,fontLetterSpacing:0,textAlign:{horizontal:"left",vertical:"bottom"},textBaseline:"alphabetic",anchorPoint:"none",bounds:[!0,!0]};let n={...i,...t,textAlign:{...i.textAlign,...t.textAlign},bounds:{...i.bounds,...t.bounds}};n.fontLineHeight=t.fontLineHeight??t.fontSize??30,n.position={x:t.position.x??t.position.pos_x??0,y:t.position.y??t.position.pos_y??0,maxWidth:t.maxWidth??t.max_width??0,maxWidthRescale:t.maxWidthRescale??t.max_width_rescale??!1,maxLines:t.maxLines??t.max_lines??0,ignoreEmptyLines:t.ignoreEmptyLines??t.ignore_empty_lines??!0,ignoreDoubleSpaces:t.ignoreDoubleSpaces??t.ignore_double_spaces??!0};let o=e.split("\n");!1!==n.position.ignoreEmptyLines&&(o=o.filter((t=>t.trim().length>0))),o=o.map((t=>t.trim())),!1!==n.position.ignoreDoubleSpaces&&(o=o.map((t=>t.replace(/\s+/g," ")))),this.context.font=`${n.fontSize}px ${n.fontFamily}`,this.context.letterSpacing=n.fontSize/100*n.fontLetterSpacing+"px",this.context.textAlign=n.textAlign.horizontal,this.context.textBaseline=n.textBaseline,this.context.fontKerning=n.fontKerningOptical?"auto":"normal";let r=o.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("§","")).actualBoundingBoxLeft)),0),s=1;if(n.position.maxWidth&&n.position.maxWidthRescale)s=r>n.position.maxWidth?1/r*n.position.maxWidth:1;else if(n.position.maxWidth&&!n.position.maxWidthRescale){let t=[];o.forEach((e=>{let i=e.split(" "),o="";i.forEach(((e,r)=>{let s=o+(o?" ":"")+e;this.context.measureText(s.replaceAll("§","")).width>n.position.maxWidth&&""!==o?(t.push(o),o=e):o=s,r===i.length-1&&t.push(o)}))})),o=t,r=o.reduce(((t,e)=>Math.max(t,this.context.measureText(e.replaceAll("§","")).actualBoundingBoxRight+this.context.measureText(e.replaceAll("§","")).actualBoundingBoxLeft)),0)}n.position.maxLines&&(o=o.slice(0,n.position.maxLines)),this.context.font=`${n.fontSize*s}px ${n.fontFamily}`,this.context.letterSpacing=n.fontSize*s/100*n.fontLetterSpacing+"px";let h=this.context.measureText("Lp");n.bounds&&(!n.bounds[0]&&n.bounds[1]?h=this.context.measureText("p"):n.bounds[0]&&!n.bounds[1]?h=this.context.measureText("L"):n.bounds[0]||n.bounds[1]||(h=this.context.measureText("x")));let l=0;switch(this.context.textAlign="left",n.anchorPoint){default:case"none":break;case"true":l=this.context.measureText(o[0].slice(0,1)).actualBoundingBoxLeft;break;case"L":l=this.context.measureText("L").actualBoundingBoxLeft}this.context.textAlign=n.textAlign.horizontal;let c=n.position.x,d=n.position.y+h.actualBoundingBoxDescent,p=c+r*s,u=n.position.y-h.actualBoundingBoxAscent,m=n.fontLineHeight*s*(o.length-1);switch(n.textAlign.vertical){default:case"top":d+=m;break;case"center":d+=m/2,u-=m/2;break;case"bottom":u-=m}switch(n.textAlign.horizontal){default:case"left":break;case"center":c-=r*s/2,p-=r*s/2;break;case"right":c-=r*s,p-=r*s}if(this.bounds={minX:c,maxX:p,minY:u,maxY:d},n.background){"string"==typeof n.background&&(n.background={color:n.background,cornerRadius:0,stroke:{width:0}});let t={top:0,right:0,left:0,bottom:0};n.background.margins&&(n.background.margins.top&&(t.top=n.background.margins.top),n.background.margins.bottom&&(t.bottom=n.background.margins.bottom),n.background.margins.left&&(t.left=n.background.margins.left),n.background.margins.right&&(t.right=n.background.margins.right));let e=this.bounds.minX-t.left,i=this.bounds.maxX-this.bounds.minX+t.right+t.left,o=this.bounds.minY-t.top,r=this.bounds.maxY-this.bounds.minY+t.top+t.bottom;n.background?.stroke?.width>0&&("inside"===n.stroke.style?(e+=n.stroke.width/2,o+=n.stroke.width/2,i-=n.stroke.width,r-=n.stroke.width):"outside"===n.stroke.style&&(e-=n.stroke.width/2,o-=n.stroke.width/2,i+=n.stroke.width,r+=n.stroke.width));let s=n.background.round_radius??n.background.cornerRadius??0;this.context.beginPath(),this.context.roundRect(e,o,i,r,s),this.context.fillStyle=n.background.fill_color??n.background.color??"red",this.context.fill(),n.background.stroke&&(this.context.lineWidth=n.background.stroke.width??0,this.context.strokeStyle=n.background.stroke.color??"red",this.context.stroke())}o.forEach(((t,e)=>{let i,r=n.position.x+l;if("center"===n.textAlign.horizontal){this.context.textAlign="left",r-=(this.context.measureText(t.replaceAll("§","")).actualBoundingBoxRight+this.context.measureText(t.replaceAll("§","")).actualBoundingBoxLeft)/2}switch(n.textAlign.vertical){default:case"top":i=e*n.fontLineHeight*s;break;case"bottom":i=-(o.length-1-e)*n.fontLineHeight*s;break;case"center":i=-(o.length-1)*n.fontLineHeight*s/2+e*n.fontLineHeight*s}const h=t.replace(/§+$/,"").split("§");for(let t=0;t<h.length;t++){let e="right"===n.textAlign.horizontal?h.length-1-t:t,o=h[e];if(this.context.fillStyle=n.fontFillColor,n.highlight&&e%2==1){this.context.fillStyle=n.highlight.fontFillColor?n.highlight.fontFillColor:n.fontFillColor;let t=n.highlight.fontSize?n.highlight.fontSize:n.fontSize,e=n.highlight.fontFamily?n.highlight.fontFamily:n.fontFamily;this.context.font=`${t*s}px ${e}`,this.context.letterSpacing=n.highlight.fontLetterSpacing?t*s/100*n.highlight.fontLetterSpacing+"px":t*s/100*n.fontLetterSpacing+"px"}this.context.fillText(o,r,n.position.y+i),r+=("right"===n.textAlign.horizontal?-1:1)*this.context.measureText(o).width}})),this.isDrawn=!0}drawImage(...t){let e,i,n,o;if(this.context.drawImage(...t),3===t.length){const[r,s,h]=t;e=s,i=h,n=s+r.width,o=h+r.height}else if(5===t.length){const[,,,r,s,h,l]=t;e=h,i=l,n=h+r,o=l+s}else if(9===t.length){const[,,,,,r,s,h,l]=t;e=r,i=s,n=r+h,o=s+l}this.bounds={minX:e,minY:i,maxX:n,maxY:o},this.context.filter="none",this.isDrawn=!0}drawImageInput(t,e,i){this.context.drawImage(t.config.rawImage,Math.round(t.config.cropInfo.x),Math.round(t.config.cropInfo.y),Math.round(t.config.cropInfo.width),Math.round(t.config.cropInfo.height),e??0,i??0,Math.round(t.config.width),Math.round(t.config.height))}drawRect(t){const e={x:t.x??0,y:t.y??0,width:t.width??this.canvas.width,height:t.height??this.canvas.height,cornerRadius:t.cornerRadius??t.radius??0,color:t.color??"black",stroke:{style:t.stroke?.style??t.strokeStyle??"middle",width:t.stroke?.width??t.strokeWidth??0,color:t.stroke?.color??t.strokeColor??"black"}},i=e.cornerRadius,[n,o,r,s]="number"==typeof i?[i,i,i,i]:Array.isArray(i)?[i[0]??0,i[1]??i[0]??0,i[2]??i[0]??0,i[3]??i[1]??0]:[0,0,0,0];let h=e.x,l=e.y,c=e.width,d=e.height;e.stroke.width>0&&("inside"===e.stroke.style?(h+=e.stroke.width/2,l+=e.stroke.width/2,c-=e.stroke.width,d-=e.stroke.width):"outside"===e.stroke.style&&(h-=e.stroke.width/2,l-=e.stroke.width/2,c+=e.stroke.width,d+=e.stroke.width));const p=this.context;p.beginPath(),p.moveTo(h+n,l),p.lineTo(h+c-o,l),p.quadraticCurveTo(h+c,l,h+c,l+o),p.lineTo(h+c,l+d-r),p.quadraticCurveTo(h+c,l+d,h+c-r,l+d),p.lineTo(h+s,l+d),p.quadraticCurveTo(h,l+d,h,l+d-s),p.lineTo(h,l+n),p.quadraticCurveTo(h,l,h+n,l),p.closePath(),p.fillStyle=e.color,p.fill(),e.stroke.width>0&&(p.strokeStyle=e.stroke.color,p.lineWidth=e.stroke.width,p.stroke())}drawStar(t){const e={x_center:0,y_center:0,spikes:5,color:"rgba(0,0,0,1)",outerRadius:100,innerRadius:150,...t};var i=Math.PI/2*3,n=e.x_center,o=e.y_center,r=Math.PI/e.spikes;this.context.beginPath(),this.context.moveTo(e.x_center,e.y_center-e.outerRadius);for(let t=0;t<e.spikes;t++)n=e.x_center+Math.cos(i)*e.outerRadius,o=e.y_center+Math.sin(i)*e.outerRadius,this.context.lineTo(n,o),i+=r,n=e.x_center+Math.cos(i)*e.innerRadius,o=e.y_center+Math.sin(i)*e.innerRadius,this.context.lineTo(n,o),i+=r;this.context.lineTo(e.x_center,e.y_center-e.outerRadius),this.context.closePath(),this.context.fillStyle=e.color,this.context.fill()}drawGradient(t){const e={x:t.x??0,y:t.y??0,width:t.width??100,height:t.height??100,direction:t.direction??"DOWN",gradient:t.gradient??[[0,"rgba(0,0,0, 0)"],[1,"rgba(0,0,0, 1)"]]};if(!["UP","RIGHT","DOWN","LEFT"].includes(e.direction))throw new Error('Invalid direction value. It must be "UP", "RIGHT", "DOWN", or "LEFT".');let i,n,o,r;"UP"===e.direction?(i=e.x,n=e.y+e.height,o=e.x,r=e.y):"RIGHT"===e.direction?(i=e.x,n=e.y,o=e.x+e.width,r=e.y):"DOWN"===e.direction?(i=e.x,n=e.y,o=e.x,r=e.y+e.height):"LEFT"===e.direction&&(i=e.x+e.width,n=e.y,o=e.x,r=e.y);const s=this.context.createLinearGradient(i,n,o,r);for(let t=0;t<e.gradient.length;t++){let i=e.gradient[t][0],n=e.gradient[t][1];s.addColorStop(i,n)}this.context.fillStyle=s,this.context.fillRect(e.x,e.y,e.width,e.height)}prepareFilter(t){this.context.filter=t}applyFilter(t){this.context.filter=t,this.context.drawImage(this.canvas,0,0),this.context.filter="none"}applyLUT(t){t.isLoaded||console.log("LUT not loaded",t.name);const e=this.context.getImageData(0,0,this.canvas.width,this.canvas.height),i=e.data;for(let e=0;e<i.length;e+=4){const n=i[e]/255,o=i[e+1]/255,r=i[e+2]/255,[s,h,l]=apply3DLUT(n,o,r,t.lutData);i[e]=255*s,i[e+1]=255*h,i[e+2]=255*l}function apply3DLUT(t,e,i,{size:n,lut:o}){const r=n-1;return o[Math.min(Math.floor(t*r),r)+Math.min(Math.floor(e*r),r)*n+Math.min(Math.floor(i*r),r)*n*n]}this.context.putImageData(e,0,0)}update(){this.drawInstructions&&(this.clear(),this.drawInstructions())}clear(){this.context.clearRect(0,0,this.canvas.width,this.canvas.height),this.isDrawn=!1}}class Raffaello_ImageCropper{constructor(...t){this.container=null,this.config={};for(const e of t)e instanceof HTMLElement?this.container=e:"object"==typeof e&&null!==e&&(this.config=e);if(!this.container&&this.config.container instanceof HTMLElement&&(this.container=this.config.container),this.config&&0!==Object.keys(this.config).length||console.error("[Raffaello_ImageCropper] Missing configuration object. Please provide a valid config."),!this.container&&this.config.layerRef?.container instanceof HTMLElement&&(this.container=this.config.layerRef.container),!this.container)throw console.error("[Raffaello_ImageCropper] No container provided. Either pass it directly, or use config.layerRef.container."),new Error("Missing container");null==this.config.width&&(this.config.layerRef?.canvas?.width?this.config.width=this.config.layerRef.canvas.width:console.warn("[Raffaello_ImageCropper] No width provided in config, and no fallback from layerRef.canvas.width.")),null==this.config.height&&(this.config.layerRef?.canvas?.height?this.config.height=this.config.layerRef.canvas.height:console.warn("[Raffaello_ImageCropper] No height provided in config, and no fallback from layerRef.canvas.height.")),this.config.imageReady=!1,this.initDynamicElements(),this.initElements(),this.initCropper(),this.bindEvents(),this.initRatioSelect(),this.initWatermark(),this.filterValues={},this.initFilterControls()}initDynamicElements(){const t=this.container.querySelector(".raffaello-imageInput")||this.container.querySelector(".raffaello-imageContainer");if(!t)return void console.error("No valid element 'raffaello-imageInput' within the container");t.classList.contains("raffaello-imageContainer")||t.classList.add("raffaello-imageContainer"),t.style.backgroundColor="rgb(51, 51, 51)";if(!t.querySelector(".raffaello-cropperContainer")){t.innerHTML+="\x3c!-- CROPPER INPUT --\x3e";const e=document.createElement("img");e.className="raffaello-cropperContainer",t.appendChild(e)}t.innerHTML+="\x3c!-- FILE INPUT --\x3e";const e=document.createElement("input");e.type="file",e.className="raffaello-imageInputFile",e.accept="image/*",e.style.display="none",t.appendChild(e),t.innerHTML+="\x3c!-- UPLOAD INPUT --\x3e";const i=document.createElement("div");i.className="raffaello-upload",i.innerHTML+='\n <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 16 20"\n class=\'icon\'\n style="enable-background:new 0 0 16 20" >\n <path d="M7 17h2v-4.2l1.6 1.6L12 13 8 9l-4 4 1.4 1.4L7 12.8V17zm-5 3c-.6 0-1-.2-1.4-.6S0 18.5 0 18V2C0 1.5.2 1 .6.6S1.5 0 2 0h8l6 6v12c0 .5-.2 1-.6 1.4s-.8.6-1.4.6H2zM9 7V2H2v16h12V7H9zM2 2v5-5 16V2z"/>\n </svg>',t.appendChild(i),t.innerHTML+="\x3c!-- LOADING --\x3e";const n=document.createElement("div");n.className="raffaello-loading";const o=document.createElement("div");o.className="raffaello-loading-circle",n.appendChild(o),t.appendChild(n),t.innerHTML+="\x3c!-- RESTART --\x3e";const r=document.createElement("div");this.cropperRestart=r,r.classList.add("raffaello-restart"),r.innerHTML+='\n <svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" viewBox="0 0 16 18.5"\n class="icon"\n style="enable-background:new 0 0 16 18.5" >\n <path d="M7 18.5c-2-.2-3.7-1.1-5-2.6s-2-3.3-2-5.3c0-1.1.2-2.2.7-3.2s1-1.9 1.9-2.6L4 6.2c-.6.6-1.1 1.2-1.4 2S2 9.7 2 10.5c0 1.5.5 2.8 1.4 3.9s2.1 1.8 3.6 2.1v2zm2 0v-2c1.4-.3 2.6-1 3.6-2.1S14 12 14 10.5c0-1.7-.6-3.1-1.8-4.2S9.7 4.5 8 4.5h-.1L9 5.6 7.6 7 4.1 3.5 7.6 0 9 1.4 7.9 2.5H8c2.2 0 4.1.8 5.7 2.3S16 8.3 16 10.5c0 2-.7 3.8-2 5.3s-3 2.4-5 2.7z"/>\n </svg>',t.appendChild(r);const s=this.container.querySelector(".raffaello-imageFiltres")||this.container.querySelector(".raffaello-imageFilters");if(s){s.classList.contains("raffaello-imageFilters")||s.classList.add("raffaello-imageFilters"),this.imageFilters=s,s.classList.add("flex-row"),s.style.gap="2px";const t=document.createElement("p");t.className="brightness-label",s.appendChild(t);const e=document.createElement("input");e.type="range",e.name="brightness",e.displayName="Luminosité",e.min="-100",e.max="100",e.value="20",s.appendChild(e);const i=document.createElement("p");i.className="contrast-label",s.appendChild(i);const n=document.createElement("input");n.type="range",n.name="contrast",n.displayName="Contraste",n.min="-100",n.max="100",n.value="20",s.appendChild(n);const o=document.createElement("p");o.className="saturate-label",s.appendChild(o);const r=document.createElement("input");r.type="range",r.name="saturate",r.displayName="Saturation",r.min="-100",r.max="100",r.value="20",s.appendChild(r)}}initElements(){this.dropzone=this.container.querySelector(".raffaello-imageContainer"),this.imageInput=this.container.querySelector(".raffaello-imageInputFile"),this.upload=this.container.querySelector(".raffaello-upload"),this.loading=this.container.querySelector(".raffaello-loading"),this.cropperContainer=this.container.querySelector(".raffaello-cropperContainer")}initCropper(){this.cropper=new Cropper(this.cropperContainer,{aspectRatio:this.config.aspectRatio??this.config.width/this.config.height,viewMode:this.config.viewMode??2,autoCropArea:1,zoomOnWheel:this.config.zoomOnWheel??0,ready:()=>{this.applyFilters(),this.config.rawImage=this.cropperContainer,this.config.cropInfo=this.cropper.getData(),this.config.imageReady=!0,this.config.onImageReady?this.config.onImageReady():console.log(this.config)}})}bindEvents(){this.upload.addEventListener("click",(()=>{"INPUT"===this.imageInput.tagName&&"file"===this.imageInput.type||console.warn('Warning: this.imageInput is not an <input> element of type "file". Nothing should have a class "raffaello-imageInput"'),this.imageInput.click()})),this.imageInput.addEventListener("change",(t=>{this.loadSelectedImage(t)})),this.dropzone.addEventListener("dragover",(t=>t.preventDefault())),this.dropzone.addEventListener("drop",(t=>{t.preventDefault(),console.log("We have a drop");const e=t.dataTransfer.files[0];e.type.match(/^image\//)?this.loadSelectedImage({target:{files:[e]}}):console.log("Invalid file type. Only image files are allowed.")})),this.cropperContainer.addEventListener("crop",(t=>{this.config.cropInfo=this.cropper.getData()})),this.cropperRestart&&this.cropperRestart.addEventListener("click",(()=>{this.imageInput.click()})),this.config.onCrop&&this.cropperContainer.addEventListener("crop",this.config.onCrop),this.config.onCropStart&&this.cropperContainer.addEventListener("cropstart",this.config.onCropStart),this.config.onCropEnd&&this.cropperContainer.addEventListener("cropend",this.config.onCropEnd),this.config.onZoom&&this.cropperContainer.addEventListener("zoom",this.config.onZoom),void 0!==this.config.layerIndex&&void 0!==this.config.layerRef&&(this.config.onImageReady=()=>{const t=this.config.layerRef;if(t.canvas.resetLayers(),"function"==typeof t.templateInstructions)t.templateInstructions();else{if("function"!=typeof t.initiateDrawing)return void console.error("No drawing method found: expected 'templateInstructions()'.");t.initiateDrawing()}t.canvas.renderPreview()},this.config.onFilterChange=()=>{this.config.layerRef.canvas.updateLayers([this.config.layerIndex])},this.cropperContainer.addEventListener("onCrop",(()=>{})),this.cropperContainer.addEventListener("cropstart",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=.5})),this.cropperContainer.addEventListener("cropend",(()=>{this.config.layerRef.canvas.previewContainer.style.opacity=1,this.config.layerRef.canvas.updateLayers([this.config.layerIndex])})))}showBackInitialUI(){"none"==this.upload.style.display&&(this.upload.style.display="flex");const t=this.cropperRestart;t&&(t.style.display="none")}loadSelectedImage(t){return new Promise(((e,i)=>{const n=t.target.files[0];if(!n)return;"none"!==this.upload.style.display&&(this.upload.style.display="none"),"none"===this.loading.style.display&&(this.loading.style.display="flex");const o=this.cropperRestart;o&&(o.style.display="block");const r=new FileReader;r.addEventListener("load",(()=>{this.loading.style.display="none",this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")));let t=n.name.split(".")[0];this.config.fileName=t,this.cropperContainer.src=r.result,this.cropper.replace(this.cropperContainer.src),e(t)})),r.readAsDataURL(n)}))}initRatioSelect(){this.imageRatioSelect=this.container.querySelector(".raffaello-imageRatioSelect"),this.imageRatioSelect&&this.imageRatioSelect.addEventListener("change",(()=>{const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.width,e=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.height;this.config.width=t,this.config.height=e;const i=t/e;this.cropper.setAspectRatio(i),this.watermarkSelect&&this.resetWatermarkList()}))}setNewSize(t,e){const i=t/e;this.cropper.setAspectRatio(i)}initWatermark(){this.watermarkDiv=this.container.querySelector(".raffaello-watermark"),this.watermarkDiv&&(this.watermarkDiv.classList.add("raffaello-canvas-to-overlay","icon"),""!==this.watermarkDiv.src&&this.watermarkDiv.src!==window.location.href||(this.watermarkDiv.style.display="none"),this.cropperContainer.addEventListener("crop",(()=>{this.updateWatermarkPositionAndSize()})),this.watermarkSelect=this.container.querySelector(".raffaello-watermarkSelect"),this.watermarkSelect&&this.watermarkSelect.addEventListener("change",(()=>{this.updateWatermark()})))}updateWatermark(){const t=this.watermarkSelect.options[this.watermarkSelect.selectedIndex].dataset.watermark;t?(this.watermarkDiv.src=t,this.watermarkDiv.style.display="block"):(this.watermarkDiv.src="",this.watermarkDiv.style.display="none"),this.updateWatermarkPositionAndSize()}updateWatermarkPositionAndSize(){const t=this.cropper.getCropBoxData();this.watermarkDiv.style.width=Math.ceil(t.width)+1+"px",this.watermarkDiv.style.height=Math.ceil(t.height)+1+"px",this.watermarkDiv.style.left=t.left-.5+"px",this.watermarkDiv.style.top=t.top-.5+"px"}resetWatermarkList(){this.watermarkSelect.selectedIndex=0,this.watermarkDiv.src="",this.watermarkDiv.style.display="none";const t=this.imageRatioSelect.options[this.imageRatioSelect.selectedIndex].dataset.ratio;for(let e=1;e<this.watermarkSelect.options.length;e++){const i=this.watermarkSelect.options[e];i.dataset.ratio===t?i.style.display="block":i.style.display="none"}}initFilterControls(){const t=this.imageFilters;if(t){t.querySelectorAll('input[type="range"]').forEach((t=>{const e=t.name||t.dataset.filter,i=t.displayName;this.filterValues[e]=t.value,this.updateFilterValue(e,i,t.value),t.addEventListener("input",(t=>{this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),t.addEventListener("dblclick",(t=>{t.target.value=20,this.updateFilterValue(e,i,t.target.value),this.applyFilters()})),this.config.onFilterChange&&(t.addEventListener("input",this.config.onFilterChange),t.addEventListener("dblclick",this.config.onFilterChange))}))}}linear(t,e,i,n,o){return(t-e)/(i-e)*(o-n)+n}updateFilterValue(t,e,i){let n;n="brightness"===t?i<0?this.linear(i,-100,0,.8,1):this.linear(i,0,100,1,1.4):"contrast"===t?i<0?this.linear(i,-100,0,.9,1):this.linear(i,0,100,1,1.3):"saturate"===t?i<0?this.linear(i,-100,0,0,1):this.linear(i,0,100,1,1.3):i;let o=i,r=this.container.querySelector(`.${t}-label`);r&&(r.innerHTML=`${e.charAt(0).toUpperCase()+e.slice(1)} <i>(${o})</i>`),this.filterValues[t]=n}applyFilters(){let t=Object.entries(this.filterValues).map((([t,e])=>`${t}(${e})`)).join(" ");this.config.filter=t;const e=this.container.querySelector(".cropper-crop-box .cropper-view-box"),i=this.container.querySelector(".cropper-wrap-box div");e&&(e.style.filter=t),i&&(i.style.filter=t)}}function d_r(){console.log("> d_r()"),window[atob("cl9v")]=!1,window[a(7)].prototype[a(8)]=function(){return console.log(a(2)),null},window[a(7)].prototype[a(9)]=function(){return console.log(a(2)),null}}window.Raffaello_Canvas=class Raffaello_Canvas{constructor(t){if(this.width=t.width??1e3,this.height=t.height??1e3,this.cornerRadius=t.cornerRadius??0,this.previewContainer=t.previewContainer??null,this.nameInputContainer=t.nameInputContainer??null,this.name=t.name??"Image_Raffaello.jpg",this.previewQuality=t.previewQuality??"0.8",this.renderQuality=t.renderQuality??"0.96",this.layers=[],this.previewContainer){const e=window.getComputedStyle(this.previewContainer).backgroundColor;t.previewBackgroundColor?this.previewBackgroundColor=t.previewBackgroundColor:e&&"rgba(0, 0, 0, 0)"!==e&&"transparent"!==e&&(this.previewBackgroundColor=e)}}addLayer(t="normal",e=null){let i=new Raffaello_CanvasLayer(this.width,this.height,t,e);return this.layers.push(i),i}updateLayers(t){for(const e of t)this.layers[e]?this.layers[e].update():console.warn(`> updateLayers([${e}]): The canvas does not have a layer ${e}`);this.renderPreview()}resetLayers(){this.layers=[]}render(t=!1){if(!window.r_o)return void console.log(a(2));let e=document.createElement("canvas");e.width=this.width,e.height=this.height;let i=e.getContext("2d");this.cornerRadius>0&&(i.save(),i.beginPath(),i.roundRect(0,0,e.width,e.height,this.cornerRadius),i.clip()),t&&null!=this.previewBackgroundColor&&(i.fillStyle=this.previewBackgroundColor,i.fillRect(0,0,e.width,e.height));for(let t=0;t<this.layers.length;t++){const e=this.layers[t],n=this.layers[t+1];let o=e.canvas;if("alpha"===n?.type){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;let i=t.getContext("2d");i.drawImage(n.canvas,0,0),i.globalCompositeOperation="source-in",i.drawImage(e.canvas,0,0),i.globalCompositeOperation="source-over",o=t}["image","normal"].includes(e.type)&&i.drawImage(o,0,0),"effect"===e.type&&(i.globalCompositeOperation=e.effect,i.drawImage(o,0,0),i.globalCompositeOperation="source-over")}return this.cornerRadius>0&&i.restore(),e}renderPreview(){if(!window.r_o)return void console.log(a(2));if(!this.previewContainer)return;const t=this.previewContainer;/iPad|iPhone|iPod/.test(navigator.userAgent)?t.src=this.render().toDataURL("image/jpeg",.9):t.src=this.render(!0).toDataURL("image/jpeg",this.previewQuality)}downloadImage(){const t=this.render();if(!t)return;let e,i,n=this.nameInputContainer.value.trim(),o=n?n.split(".")[0].replace(/[^a-zA-Z0-9\_-]/g,""):this.name;switch(n.split(".").pop().toLowerCase()){case"jpg":case"jpeg":e="image/jpeg",i=".jpg";break;default:e="image/png",i=".png"}if(/iPad|iPhone|iPod/.test(navigator.userAgent))window.alert("Tap and hold the image to save.");else{const n=document.createElement("a");n.download=o+i,n.href=t.toDataURL(e,"image/jpeg"===e?this.renderQuality:void 0),document.body.appendChild(n),n.click(),document.body.removeChild(n)}}renderBis(){let t=document.createElement("canvas");t.width=this.width,t.height=this.height;const e=t.getContext("2d");return e.fillStyle=atob("I2Y4ZDdkYQ=="),e.fillRect(0,0,this.width,this.height),e.fillStyle=atob("IzcyMWMyNA=="),e.font="bold 24px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(atob("TGljZW5zZSBrZXkgbm90IHZhbGlk"),this.width/2,this.height/2),t}},window.Raffaello_CanvasLayer=Raffaello_CanvasLayer,window.Raffaello_ImageCropper=Raffaello_ImageCropper,window.Raffaello_BatchImageCropper=class Raffaello_BatchImageCropper{constructor(t,e){this.input=t,this.container=this.input.container,this.canvas=this.input.canvas,this.imageConfigs=e,this.imagesAreReady=e.map((t=>!0===t.isOptional)),this.inputImages=[],this.initializeCroppers()}initializeCroppers(){this.inputImages=this.imageConfigs.map(((t,e)=>new Raffaello_ImageCropper(this.container.querySelector(t.selector),{layerRef:this.input,width:t.width,height:t.height,viewMode:t.viewMode??2,zoomOnWheel:t.zoomOnWheel??0,onImageReady:()=>{this.markImageAsReady(e)},onCropStart:()=>{this.canvas.previewContainer.style.opacity=.5},onCropEnd:()=>{this.canvas.previewContainer.style.opacity=1,this.canvas.updateLayers([t.layerIndex])},onZoom:()=>{this.canvas.updateLayers([t.layerIndex])},onFilterChange:()=>{this.canvas.updateLayers([t.layerIndex])}})))}markImageAsReady(t){this.imagesAreReady[t]=!0,this.checkImagesAreReady()}checkImagesAreReady(){this.imagesAreReady.every((t=>t))&&(this.removePendingState(),console.log("All images are ready, starting to draw..."),this.input.initiateDrawing())}removePendingState(){this.container.querySelectorAll(".pending").forEach((t=>t.classList.remove("pending")))}},window.Raffaello_Image=class Raffaello_Image{constructor(t){const e=t.url;this.img=new Image,this.img.src=e,this.isLoaded=!1,this.img.onload=()=>{this.isLoaded=!0,console.log(`✅ Image ${e.split("/").slice(-1)} loaded successfully.`)},this.img.onerror=()=>{console.error("❌ Failed to load image:",e)}}getImage(){return this.isLoaded?this.img:(console.warn("❌ Image not loaded yet."),null)}isLoaded(){return this.isLoaded}},window.Raffaello_Font=class Raffaello_Font{constructor(t){const e=t.name;this.font=new FontFace(e,`url(${t.url})`),this.font.display="swap",this.isLoaded=!1;let i=this.font;document.fonts.add(i),i.load().then((()=>{this.isLoaded=!0,console.log(`✅ Font ${e} loaded successfully.`)})).catch((()=>{console.error("❌ Failed to load font:",e)}))}isLoaded(){return this.isLoaded}},window.Raffaello_LUT=class Raffaello_LUT{constructor(t){const e=t.url;this.lutData=null,this.isLoaded=!1,this.name=e.split("/").slice(-1),this.loadLUT(e).then((t=>{this.lutData=t,this.isLoaded=!0,console.log(`✅ LUT ${this.name} loaded successfully.`)})).catch((t=>{console.log(`❌ Failed to load LUT: ${e}`),console.error(t)}))}async loadLUT(t){try{const e=await fetch(t),i=(await e.text()).split("\n"),n=[];let o=0;for(const t of i)if(t.startsWith("LUT_3D_SIZE"))o=parseInt(t.split(" ")[1],10);else if(!t.startsWith("#")&&""!==t.trim()){const e=t.split(" ").map(Number);3===e.length&&n.push(e)}if(!o)throw new Error("Invalid LUT file.");return{size:o,lut:n}}catch(t){throw new Error(`Error parsing LUT file: ${t.message}`)}}getLUT(){return this.isLoaded?this.lutData:(console.warn("❌ LUT not loaded yet."),null)}isLUTLoaded(){return this.isLoaded}},window.Raffaello_FullScreen=class Raffaello_FullScreen{constructor(t){this.previewContainers=document.querySelectorAll(`.${t.previewContainer}`),this.fullScreenElement=null,this.isFullScreen=!1,this.previewContainers.length?(this.initializeFullScreen(),this.setupEventListeners()):console.error("RAFFAELLO - No preview containers found.")}initializeFullScreen(){this.fullScreenElement=document.createElement("div"),this.fullScreenElement.classList.add("raffaello-fullscreen-overlay"),this.fullScreenElement.style.position="fixed",this.fullScreenElement.style.top="0",this.fullScreenElement.style.left="0",this.fullScreenElement.style.width="100%",this.fullScreenElement.style.height="100%",this.fullScreenElement.style.padding="25px",this.fullScreenElement.style.backgroundColor="rgba(0, 0, 0, 0.9)",this.fullScreenElement.style.display="none",this.fullScreenElement.style.zIndex="9999",this.fullScreenElement.style.cursor="pointer",this.fullScreenElement.style.alignItems="center",this.fullScreenElement.style.justifyContent="center";const t=document.createElement("img");t.style.maxWidth="100%",t.style.maxHeight="100%",t.setAttribute("draggable","false"),t.addEventListener("dragstart",(function(t){t.preventDefault()})),t.addEventListener("contextmenu",(function(t){t.preventDefault()})),this.fullScreenElement.appendChild(t),document.body.appendChild(this.fullScreenElement)}toggleFullScreen(){this.isFullScreen=!this.isFullScreen,this.isFullScreen?(this.fullScreenElement.style.display="flex",document.body.style.overflow="hidden"):(this.fullScreenElement.style.display="none",document.body.style.overflow="auto")}setupEventListeners(){this.previewContainers.forEach((t=>{t.style.cursor="pointer",t.addEventListener("click",(()=>{const e=t.src;this.fullScreenElement.querySelector("img").src=e,this.toggleFullScreen()}))})),this.fullScreenElement.addEventListener("click",(()=>{this.toggleFullScreen()}))}},window.Raffaello_PersistentInputs=class Raffaello_PersistentInputs{constructor({inputs:t,timeout:e}){this.textareas=document.querySelectorAll(`.${t}`),this.timeout=e,this.textareas.length?this.init():console.error(`INFO: No element with class ${t}`)}init(){this.cleanupOldKeys(),this.textareas.forEach(((t,e)=>{const i=this.generateKey(e);this.loadAndValidateContent(t,i);const n=this.debounce((()=>this.saveContent(t,i)),500);t.addEventListener("input",n)}))}cleanupOldKeys(){for(let t=0;t<localStorage.length;t++){const e=localStorage.key(t);e&&e.startsWith("textareaContent_")&&localStorage.removeItem(e)}}generateKey(t){return`${window.location.pathname}_textareaContent_${this.timeout}_${t}`}loadAndValidateContent(t,e){const i=`${e}_timestamp`,n=localStorage.getItem(e),o=localStorage.getItem(i);if(n&&o){const r=Date.now()-parseInt(o,10);console.log("elapsed",r),console.log("this.timeout",this.timeout),r<=this.timeout?t.value=n:(console.log(`Key expired: ${e}`),localStorage.removeItem(e),localStorage.removeItem(i))}else localStorage.removeItem(e),localStorage.removeItem(i)}saveContent(t,e){const i=`${e}_timestamp`;localStorage.setItem(e,t.value),localStorage.setItem(i,Date.now().toString())}debounce(t,e){let i;return(...n)=>{clearTimeout(i),i=setTimeout((()=>t(...n)),e)}}},async function v_k(t=1){console.log(`> v_k() #${t}`);const e=document.currentScript||document.querySelector(a(12)),i=e?.dataset?.[atob("bGljZW5zZQ==")]||e?.dataset?.[atob("a2V5")],n=window.location[atob("aG9zdG5hbWU=")];if(!i)return console.log(a(1)),void d_r();const o=`${a(6)}${i}`,r=localStorage.getItem(o),s=Date.now();if(r&&s<parseInt(r))console.log("> g_k_u");else try{const t=await fetch(`${a(4)}${i}${a(5)}${n}`),e=await t.json();if(console.log("> res"),console.log(e),e.status!==a(10))return console.log(a(2)),void d_r();const r=s+1728e5;localStorage.setItem(o,r.toString())}catch(e){console.log(`${a(3)} (${t}/4)`),t<4?setTimeout((()=>v_k(t+1)),6e4):console.log(a(11))}}()}();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "raffaello",
3
- "version": "1.2.1",
3
+ "version": "1.3.0",
4
4
  "description": "A suite of client-side JavaScript objects and tools for image templatisation.",
5
5
  "main": "dist/raffaello.min.js",
6
6
  "style": "dist/raffaello.min.css",