UNPKG

vue-advanced-cropper

Version:

The advanced library to create your own croppers suited for any website design

21 lines (19 loc) 85.7 kB
var VueAdvancedCropper=function(t,e){"use strict";function i(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 n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?i(Object(n),!0).forEach((function(e){o(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function o(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function s(t,e){if(null==t)return{};var i,n,o=function(t,e){if(null==t)return{};var i,n,o={},s=Object.keys(t);for(n=0;n<s.length;n++)i=s[n],e.indexOf(i)>=0||(o[i]=t[i]);return o}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(n=0;n<s.length;n++)i=s[n],e.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(o[i]=t[i])}return o}function r(t){return function(t){if(Array.isArray(t))return a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return a(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return a(t,e)}(t)||function(){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 a(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 h,c,l,u=(h=function(t){ /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames */ !function(){var e={}.hasOwnProperty;function i(){for(var t=[],n=0;n<arguments.length;n++){var o=arguments[n];if(o){var s=typeof o;if("string"===s||"number"===s)t.push(o);else if(Array.isArray(o)){if(o.length){var r=i.apply(null,o);r&&t.push(r)}}else if("object"===s)if(o.toString===Object.prototype.toString)for(var a in o)e.call(o,a)&&o[a]&&t.push(a);else t.push(o.toString())}}return t.join(" ")}t.exports?(i.default=i,t.exports=i):window.classNames=i}()},h(l={path:c,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&l.path)}},l.exports),l.exports),d=function(t){return function(e,i){if(!e)return t;var n;"string"==typeof e?n=e:i=e;var o=t;return n&&(o+="__"+n),o+(i?Object.keys(i).reduce((function(t,e){var n=i[e];return n&&(t+=" "+("boolean"==typeof n?o+"--"+e:o+"--"+e+"_"+n)),t}),""):"")}};function m(t,e,i){var n,o,s,r,a;function h(){var c=Date.now()-r;c<e&&c>=0?n=setTimeout(h,e-c):(n=null,i||(a=t.apply(s,o),s=o=null))}null==e&&(e=100);var c=function(){s=this,o=arguments,r=Date.now();var c=i&&!n;return n||(n=setTimeout(h,e)),c&&(a=t.apply(s,o),s=o=null),a};return c.clear=function(){n&&(clearTimeout(n),n=null)},c.flush=function(){n&&(a=t.apply(s,o),s=o=null,clearTimeout(n),n=null)},c}m.debounce=m;var p=m,g=function(){return g=Object.assign||function(t){for(var e,i=1,n=arguments.length;i<n;i++)for(var o in e=arguments[i])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},g.apply(this,arguments)}; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function f(t,e){var i,n;return t&&e?(i=""+t+e[0].toUpperCase()+e.slice(1),n=t+"-"+e):(i=t||e,n=t||e),{name:i,classname:n}}function v(t){return/^blob:/.test(t)}function b(t){return v(t)||function(t){return/^data:/.test(t)}(t)}function w(t){return!!(t&&t.constructor&&t.call&&t.apply)}function y(t){return void 0===t}function z(t){return"object"==typeof t&&null!==t}function R(t,e,i){var n={};return z(t)?(Object.keys(e).forEach((function(o){y(t[o])?n[o]=e[o]:z(e[o])?z(t[o])?n[o]=R(t[o],e[o],i[o]):n[o]=t[o]?e[o]:i[o]:!0===e[o]||!1===e[o]?n[o]=Boolean(t[o]):n[o]=t[o]})),n):t?e:i}function A(t){var e=Number(t);return Number.isNaN(e)?t:e}function S(t){return typeof("number"==t||function(t){return"object"==typeof t&&null!==t}(t)&&"[object Number]"==toString.call(t))&&!M(t)}function M(t){return t!=t}function x(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}var C=function(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.type="manipulateImage",this.move=t,this.scale=e},E=function(t,e){void 0===e&&(e={}),this.type="resize",this.directions=t,this.params=e},W=function(t){this.type="move",this.directions=t},T=function(){function t(t,e,i,n,o){this.type="drag",this.nativeEvent=t,this.position=i,this.previousPosition=n,this.element=e,this.anchor=o}return t.prototype.shift=function(){var t=this,e=t.element,i=t.anchor,n=t.position;if(e){var o=e.getBoundingClientRect(),s=o.left,r=o.top;return{left:n.left-s-i.left,top:n.top-r-i.top}}return{left:0,top:0}},t}(),B={name:"DraggableElement",props:{classname:{type:String}},beforeMount:function(){window.addEventListener("mouseup",this.onMouseUp,{passive:!1}),window.addEventListener("mousemove",this.onMouseMove,{passive:!1}),window.addEventListener("touchmove",this.onTouchMove,{passive:!1}),window.addEventListener("touchend",this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd)},mounted:function(){if(!this.$refs.draggable)throw new Error('You should add ref "draggable" to your root element to use draggable mixin');this.touches=[],this.hovered=!1},methods:{onMouseOver:function(){this.hovered||(this.hovered=!0,this.$emit("enter"))},onMouseLeave:function(){this.hovered&&!this.touches.length&&(this.hovered=!1,this.$emit("leave"))},onTouchStart:function(t){t.cancelable&&!this.disabled&&1===t.touches.length&&(this.touches=r(t.touches),this.hovered||(this.$emit("enter"),this.hovered=!0),t.touches.length&&this.initAnchor(this.touches.reduce((function(e,i){return{clientX:e.clientX+i.clientX/t.touches.length,clientY:e.clientY+i.clientY/t.touches.length}}),{clientX:0,clientY:0})),t.preventDefault&&t.preventDefault(),t.stopPropagation())},onTouchEnd:function(){this.processEnd()},onTouchMove:function(t){this.touches.length&&(this.processMove(t,t.touches),t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation())},onMouseDown:function(t){if(!this.disabled){var e={fake:!0,clientX:t.clientX,clientY:t.clientY};this.touches=[e],this.initAnchor(e),t.stopPropagation()}},onMouseMove:function(t){this.touches.length&&(this.processMove(t,[{fake:!0,clientX:t.clientX,clientY:t.clientY}]),t.preventDefault&&t.preventDefault())},onMouseUp:function(){this.processEnd()},initAnchor:function(t){var e=this.$refs.draggable.getBoundingClientRect(),i=e.left,n=e.right,o=e.bottom,s=e.top;this.anchor={left:t.clientX-i,top:t.clientY-s,bottom:o-t.clientY,right:n-t.clientX}},processMove:function(t,e){var i=r(e);if(this.touches.length){if(1===this.touches.length&&1===i.length){var n=this.$refs.draggable;this.$emit("drag",new T(t,n,{left:i[0].clientX,top:i[0].clientY},{left:this.touches[0].clientX,top:this.touches[0].clientY},this.anchor))}this.touches=i}},processEnd:function(){this.touches.length&&this.$emit("drag-end"),this.hovered&&(this.$emit("leave"),this.hovered=!1),this.touches=[]}},emits:["drag","drag-end","leave","enter"]};B.render=function(t,i,n,o,s,r){return e.openBlock(),e.createBlock("div",{ref:"draggable",class:n.classname,onTouchstart:i[1]||(i[1]=function(){return r.onTouchStart&&r.onTouchStart.apply(r,arguments)}),onMousedown:i[2]||(i[2]=function(){return r.onMouseDown&&r.onMouseDown.apply(r,arguments)}),onMouseover:i[3]||(i[3]=function(){return r.onMouseOver&&r.onMouseOver.apply(r,arguments)}),onMouseleave:i[4]||(i[4]=function(){return r.onMouseLeave&&r.onMouseLeave.apply(r,arguments)})},[e.renderSlot(t.$slots,"default")],34)};var O=d("vue-handler-wrapper"),D={name:"HandlerWrapper",components:{DraggableElement:B},props:{horizontalPosition:{type:String},verticalPosition:{type:String},disabled:{type:Boolean,default:!1}},computed:{classes:function(){var t;if(this.horizontalPosition||this.verticalPosition){var e,i=f(this.horizontalPosition,this.verticalPosition);t=O((o(e={},i.classname,!0),o(e,"disabled",this.disabled),e))}else t=O({disabled:this.disabled});return{root:t,draggable:O("draggable")}}},emits:["leave","enter","drag","drag-end"]};D.render=function(t,i,n,o,s,r){var a=e.resolveComponent("DraggableElement");return e.openBlock(),e.createBlock("div",{class:r.classes.root},[e.createVNode(a,{class:r.classes.draggable,onDrag:i[1]||(i[1]=function(e){return t.$emit("drag",e)}),onDragEnd:i[2]||(i[2]=function(e){return t.$emit("drag-end")}),onLeave:i[3]||(i[3]=function(e){return t.$emit("leave")}),onEnter:i[4]||(i[4]=function(e){return t.$emit("enter")})},{default:e.withCtx((function(){return[e.renderSlot(t.$slots,"default")]})),_:3},8,["class"])],2)};var H=d("vue-line-wrapper"),j={name:"LineWrapper",components:{DraggableElement:B},props:{position:{type:String,required:!0},disabled:{type:Boolean,default:!1}},computed:{classname:function(){var t;return H((o(t={},this.position,!0),o(t,"disabled",this.disabled),t))}},emits:["leave","enter","drag","drag-end"]};j.render=function(t,i,n,o,s,r){var a=e.resolveComponent("DraggableElement");return e.openBlock(),e.createBlock(a,{class:r.classname,onDrag:i[1]||(i[1]=function(e){return t.$emit("drag",e)}),onDragEnd:i[2]||(i[2]=function(e){return t.$emit("drag-end")}),onLeave:i[3]||(i[3]=function(e){return t.$emit("leave")}),onEnter:i[4]||(i[4]=function(e){return t.$emit("enter")})},{default:e.withCtx((function(){return[e.renderSlot(t.$slots,"default")]})),_:3},8,["class"])};var k=["left","right","top","bottom"],L=["left","right"],P=["top","bottom"],$=["left","top"],I=["fill-area","fit-area","stencil","none"],N={left:0,top:0,width:0,height:0};function X(t,e,i){return!(i=i||["width","height","left","top"]).some((function(i){return t[i]!==e[i]}))}function Y(t){return{left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height}}function F(t,e){return{left:t.left-e.left,top:t.top-e.top}}function U(t){return{left:t.left+t.width/2,top:t.top+t.height/2}}function V(t,e){var i={left:0,top:0,right:0,bottom:0};return k.forEach((function(n){var o=e[n],s=Y(t)[n];i[n]=void 0!==o&&void 0!==s?"left"===n||"top"===n?Math.max(0,o-s):Math.max(0,s-o):0})),i}function Z(t,e){return{left:t.left-e.left,top:t.top-e.top,width:t.width+e.left+e.right,height:t.height+e.top+e.bottom}}function q(t){return{left:-t.left,top:-t.top}}function _(t,e){return g(g({},t),{left:t.left+e.left,top:t.top+e.top})}function G(t,e,i,n){if(1!==e){if(i){var o=U(t);return{width:t.width*e,height:t.height*e,left:t.left+t.width*(1-e)/2+(i.left-o.left)*(n||1-e),top:t.top+t.height*(1-e)/2+(i.top-o.top)*(n||1-e)}}return{width:t.width*e,height:t.height*e,left:t.left+t.width*(1-e)/2,top:t.top+t.height*(1-e)/2}}return t}function Q(t){return t.width/t.height}function K(t,e){return Math.min(void 0!==e.right&&void 0!==e.left?(e.right-e.left)/t.width:1/0,void 0!==e.bottom&&void 0!==e.top?(e.bottom-e.top)/t.height:1/0)}function J(t,e){var i={left:0,top:0},n=V(t,e);return n.left&&n.left>0?i.left=n.left:n.right&&n.right>0&&(i.left=-n.right),n.top&&n.top>0?i.top=n.top:n.bottom&&n.bottom>0&&(i.top=-n.bottom),i}function tt(t,e){var i;return e.minimum&&t<e.minimum?i=e.minimum:e.maximum&&t>e.maximum&&(i=e.maximum),i}function et(t,e){var i=Q(t),n=Q(e);return e.width<1/0&&e.height<1/0?i>n?{width:e.width,height:e.width/i}:{width:e.height*i,height:e.height}:e.width<1/0?{width:e.width,height:e.width/i}:e.height<1/0?{width:e.height*i,height:e.height}:t}function it(t,e){var i=e*Math.PI/180;return{width:Math.abs(t.width*Math.cos(i))+Math.abs(t.height*Math.sin(i)),height:Math.abs(t.width*Math.sin(i))+Math.abs(t.height*Math.cos(i))}}function nt(t,e){var i=e*Math.PI/180;return{left:t.left*Math.cos(i)-t.top*Math.sin(i),top:t.left*Math.sin(i)+t.top*Math.cos(i)}}function ot(t,e){var i=V(st(t,e),e);return i.left+i.right+i.top+i.bottom?i.left+i.right>i.top+i.bottom?Math.min((t.width+i.left+i.right)/t.width,K(t,e)):Math.min((t.height+i.top+i.bottom)/t.height,K(t,e)):1}function st(t,e,i){void 0===i&&(i=!1);var n=J(t,e);return _(t,i?q(n):n)}function rt(t){return{width:void 0!==t.right&&void 0!==t.left?t.right-t.left:1/0,height:void 0!==t.bottom&&void 0!==t.top?t.bottom-t.top:1/0}}function at(t,e){return g(g({},t),{minWidth:Math.min(e.width,t.minWidth),minHeight:Math.min(e.height,t.minHeight),maxWidth:Math.min(e.width,t.maxWidth),maxHeight:Math.min(e.height,t.maxHeight)})}function ht(t,e,i){void 0===i&&(i=!0);var n={};return k.forEach((function(o){var s=t[o],r=e[o];void 0!==s&&void 0!==r?n[o]="left"===o||"top"===o?i?Math.max(s,r):Math.min(s,r):i?Math.min(s,r):Math.max(s,r):void 0!==r?n[o]=r:void 0!==s&&(n[o]=s)})),n}function ct(t,e){return ht(t,e,!0)}function lt(t){var e=t.size,i=t.aspectRatio,n=t.ignoreMinimum,o=t.sizeRestrictions;return Boolean((e.correctRatio||Q(e)>=i.minimum&&Q(e)<=i.maximum)&&e.height<=o.maxHeight&&e.width<=o.maxWidth&&e.width&&e.height&&(n||e.height>=o.minHeight&&e.width>=o.minWidth))}function ut(t,e){return Math.pow(t.width-e.width,2)+Math.pow(t.height-e.height,2)}function dt(t){var e=t.width,i=t.height,n=t.sizeRestrictions,o={minimum:t.aspectRatio&&t.aspectRatio.minimum||0,maximum:t.aspectRatio&&t.aspectRatio.maximum||1/0},s={width:Math.max(n.minWidth,Math.min(n.maxWidth,e)),height:Math.max(n.minHeight,Math.min(n.maxHeight,i))};function r(t,s){return void 0===s&&(s=!1),t.reduce((function(t,r){return lt({size:r,aspectRatio:o,sizeRestrictions:n,ignoreMinimum:s})&&(!t||ut(r,{width:e,height:i})<ut(t,{width:e,height:i}))?r:t}),null)}var a=[];o&&[o.minimum,o.maximum].forEach((function(t){t&&a.push({width:s.width,height:s.width/t,correctRatio:!0},{width:s.height*t,height:s.height,correctRatio:!0})})),lt({size:s,aspectRatio:o,sizeRestrictions:n})&&a.push(s);var h=r(a)||r(a,!0);return h&&{width:h.width,height:h.height}}function mt(t){var e=t.event,i=t.coordinates,n=t.positionRestrictions,o=void 0===n?{}:n,s=_(i,e.directions);return _(s,J(s,o))}function pt(t){var e=t.coordinates,i=t.transform,n=t.imageSize,o=t.sizeRestrictions,s=t.positionRestrictions,r=t.aspectRatio,a=t.visibleArea,h=function(t,e){return mt({coordinates:t,positionRestrictions:s,event:new W({left:e.left-t.left,top:e.top-t.top})})},c=g({},e);return(Array.isArray(i)?i:[i]).forEach((function(t){var e={};y((e="function"==typeof t?t({coordinates:c,imageSize:n,visibleArea:a}):t).width)&&y(e.height)||(c=function(t,e){var i=g(g(g({},t),dt({width:e.width,height:e.height,sizeRestrictions:o,aspectRatio:r})),{left:0,top:0});return h(i,{left:t.left,top:t.top})}(c,g(g({},c),e))),y(e.left)&&y(e.top)||(c=h(c,g(g({},c),e)))})),c}function gt(t){t.event;var e=t.getAreaRestrictions,i=t.boundaries,n=t.coordinates,o=t.visibleArea;t.aspectRatio;var s=t.stencilSize,r=t.sizeRestrictions,a=t.positionRestrictions;t.stencilReference;var h,c,l,u=g({},n),d=g({},o),m=g({},s);h=Q(m),c=Q(u),void 0===l&&(l=.001),(0===h||0===c?Math.abs(c-h)<l:Math.abs(c/h)<1+l&&Math.abs(c/h)>1-l)||(u=g(g({},u),dt({sizeRestrictions:r,width:u.width,height:u.height,aspectRatio:{minimum:Q(m),maximum:Q(m)}})));var p=ot(d=G(d,u.width*i.width/(d.width*m.width)),e({visibleArea:d,type:"resize"}));return 1!==p&&(d=G(d,p),u=G(u,p)),d=st(d=_(d,F(U(u),U(d))),e({visibleArea:d,type:"move"})),{coordinates:u=st(u,ct(Y(d),a)),visibleArea:d}}function ft(t){var e=t.event,i=t.getAreaRestrictions,n=t.boundaries,o=t.coordinates,s=t.visibleArea;t.aspectRatio,t.stencilSize,t.sizeRestrictions;var r=t.positionRestrictions;t.stencilReference;var a=g({},o),h=g({},s);if(o&&s&&"manipulateImage"!==e.type){var c={width:0,height:0};h.width,n.width,Q(n)>Q(a)?(c.height=.8*n.height,c.width=c.height*Q(a)):(c.width=.8*n.width,c.height=c.width*Q(a));var l=ot(h=G(h,a.width*n.width/(h.width*c.width)),i({visibleArea:h,type:"resize"}));h=G(h,l),1!==l&&(c.height/=l,c.width/=l),h=st(h=_(h,F(U(a),U(h))),i({visibleArea:h,type:"move"})),a=st(a,ct(Y(h),r))}return{coordinates:a,visibleArea:h}}function vt(t){var e=t.event,i=t.coordinates,n=t.visibleArea,o=t.getAreaRestrictions,s=g({},n),r=g({},i);if("setCoordinates"===e.type){var a=Math.max(0,r.width-s.width),h=Math.max(0,r.height-s.height);a>h?s=G(s,Math.min(r.width/s.width,K(s,o({visibleArea:s,type:"resize"})))):h>a&&(s=G(s,Math.min(r.height/s.height,K(s,o({visibleArea:s,type:"resize"}))))),s=st(s=_(s,q(J(r,Y(s)))),o({visibleArea:s,type:"move"}))}return{visibleArea:s,coordinates:r}}function bt(t){var e=t.imageSize,i=t.visibleArea,n=t.coordinates,o=i||e;return{left:(i?i.left:0)+o.width/2-n.width/2,top:(i?i.top:0)+o.height/2-n.height/2}}function wt(t){var e=t.imageSize,i=t.visibleArea,n=t.aspectRatio,o=t.sizeRestrictions,s=i||e,r=Math.min(n.maximum||1/0,Math.max(n.minimum||0,Q(s))),a=s.width<s.height?{width:.8*s.width,height:.8*s.width/r}:{height:.8*s.height,width:.8*s.height*r};return dt(g(g({},a),{aspectRatio:n,sizeRestrictions:o}))}function yt(t){var e,i,n=t.imageSize,o=t.visibleArea,s=t.boundaries,r=t.aspectRatio,a=t.sizeRestrictions,h=t.stencilSize,c=o||n;return Q(c)>Q(s)?i=(e=h.height*c.height/s.height)*Q(h):e=(i=h.width*c.width/s.width)/Q(h),dt({width:i,height:e,aspectRatio:r,sizeRestrictions:a})}function zt(t){var e=t.getAreaRestrictions,i=t.coordinates,n=t.imageSize,o=Q(t.boundaries);if(i){var s={height:Math.max(i.height,n.height),width:Math.max(i.width,n.width)},r=et({width:Q(s)>o?s.width:s.height*o,height:Q(s)>o?s.width/o:s.height},rt(e())),a={left:i.left+i.width/2-r.width/2,top:i.top+i.height/2-r.height/2,width:r.width,height:r.height},h=V(i,Y(g({left:0,top:0},n))),c={};return!h.left&&!h.right&&a.width<=n.width&&(c.left=0,c.right=n.width),!h.top&&!h.bottom&&a.height<=n.height&&(c.top=0,c.bottom=n.height),st(a,c)}var l=Q(n);r={height:l>o?n.height:n.width/o,width:l>o?n.height*o:n.width};return{left:n.width/2-r.width/2,top:n.height/2-r.height/2,width:r.width,height:r.height}}function Rt(t,e){return ht(t,Y(e))}function At(t){var e=t.event,i=t.coordinates,n=t.visibleArea,o=t.sizeRestrictions,s=t.getAreaRestrictions,r=t.positionRestrictions,a=t.adjustStencil,h=e.scale,c=e.move,l=g({},n),u=g({},i),d=1,m=1,p=h.factor&&Math.abs(h.factor-1)>.001;l=_(l,{left:c.left||0,top:c.top||0});var f={stencil:{minimum:Math.max(o.minWidth?o.minWidth/u.width:0,o.minHeight?o.minHeight/u.height:0),maximum:Math.min(o.maxWidth?o.maxWidth/u.width:1/0,o.maxHeight?o.maxHeight/u.height:1/0,K(u,r))},area:{maximum:K(l,s({visibleArea:l,type:"resize"}))}};h.factor&&p&&(h.factor<1?(m=Math.max(h.factor,f.stencil.minimum))>1&&(m=1):h.factor>1&&(m=Math.min(h.factor,Math.min(f.area.maximum,f.stencil.maximum)))<1&&(m=1)),m&&(l=G(l,m,h.center));var v=i.left-n.left,b=n.width+n.left-(i.width+i.left),w=i.top-n.top,y=n.height+n.top-(i.height+i.top);return l=st(l=_(l,J(l,{left:void 0!==r.left?r.left-v*m:void 0,top:void 0!==r.top?r.top-w*m:void 0,bottom:void 0!==r.bottom?r.bottom+y*m:void 0,right:void 0!==r.right?r.right+b*m:void 0})),s({visibleArea:l,type:"move"})),u.width=u.width*m,u.height=u.height*m,u.left=l.left+v*m,u.top=l.top+w*m,u=st(u,ct(Y(l),r)),h.factor&&p&&a&&(h.factor>1?d=Math.min(f.area.maximum,h.factor)/m:h.factor<1&&(d=Math.max(u.height/l.height,u.width/l.width,h.factor/m)),1!==d&&(l=_(l=st(l=G(l,d,h.factor>1?h.center:U(u)),s({visibleArea:l,type:"move"})),q(J(u,Y(l)))))),{coordinates:u,visibleArea:l}}function St(t){var e=t.aspectRatio,i=t.getAreaRestrictions,n=t.coordinates,o=t.visibleArea,s=t.sizeRestrictions,r=t.positionRestrictions,a=t.imageSize,h=t.previousImageSize,c=t.angle,l=g({},n),u=g({},o),d=nt(U(g({left:0,top:0},h)),c);return(l=g(g({},dt({sizeRestrictions:s,aspectRatio:e,width:l.width,height:l.height})),nt(U(l),c))).left-=d.left-a.width/2+l.width/2,l.top-=d.top-a.height/2+l.height/2,u=G(u,ot(u,i({visibleArea:u,type:"resize"}))),{coordinates:l=st(l,r),visibleArea:u=st(u=_(u,F(U(l),U(n))),i({visibleArea:u,type:"move"}))}}function Mt(t){var e=t.flip,i=t.previousFlip,n=t.rotate;t.aspectRatio;var o=t.getAreaRestrictions,s=t.coordinates,r=t.visibleArea,a=t.imageSize,h=g({},s),c=g({},r),l=i.horizontal!==e.horizontal,u=i.vertical!==e.vertical;if(l||u){var d=nt({left:a.width/2,top:a.height/2},-n),m=nt(U(h),-n),p=nt({left:l?d.left-(m.left-d.left):m.left,top:u?d.top-(m.top-d.top):m.top},n);h=_(h,F(p,U(h))),m=nt(U(c),-n),c=st(c=_(c,F(p=nt({left:l?d.left-(m.left-d.left):m.left,top:u?d.top-(m.top-d.top):m.top},n),U(c))),o({visibleArea:c,type:"move"}))}return{coordinates:h,visibleArea:c}}function xt(t){var e=t.directions,i=t.coordinates,n=t.positionRestrictions,o=void 0===n?{}:n,s=t.sizeRestrictions,r=t.preserveRatio,a=t.compensate,h=g({},e),c=Z(i,h).width,l=Z(i,h).height;c<0&&(h.left<0&&h.right<0?(h.left=-(i.width-s.minWidth)/(h.left/h.right),h.right=-(i.width-s.minWidth)/(h.right/h.left)):h.left<0?h.left=-(i.width-s.minWidth):h.right<0&&(h.right=-(i.width-s.minWidth))),l<0&&(h.top<0&&h.bottom<0?(h.top=-(i.height-s.minHeight)/(h.top/h.bottom),h.bottom=-(i.height-s.minHeight)/(h.bottom/h.top)):h.top<0?h.top=-(i.height-s.minHeight):h.bottom<0&&(h.bottom=-(i.height-s.minHeight)));var u=V(Z(i,h),o);a&&(u.left&&u.left>0&&0===u.right?(h.right+=u.left,h.left-=u.left):u.right&&u.right>0&&0===u.left&&(h.left+=u.right,h.right-=u.right),u.top&&u.top>0&&0===u.bottom?(h.bottom+=u.top,h.top-=u.top):u.bottom&&u.bottom>0&&0===u.top&&(h.top+=u.bottom,h.bottom-=u.bottom),u=V(Z(i,h),o));var d={width:1/0,height:1/0,left:1/0,right:1/0,top:1/0,bottom:1/0};if(k.forEach((function(t){var e=u[t];e&&h[t]&&(d[t]=Math.max(0,1-e/h[t]))})),r){var m=Math.min.apply(null,k.map((function(t){return d[t]})));m!==1/0&&k.forEach((function(t){h[t]*=m}))}else k.forEach((function(t){d[t]!==1/0&&(h[t]*=d[t])}));if(c=Z(i,h).width,l=Z(i,h).height,h.right+h.left&&(c>s.maxWidth?d.width=(s.maxWidth-i.width)/(h.right+h.left):c<s.minWidth&&(d.width=(s.minWidth-i.width)/(h.right+h.left))),h.bottom+h.top&&(l>s.maxHeight?d.height=(s.maxHeight-i.height)/(h.bottom+h.top):l<s.minHeight&&(d.height=(s.minHeight-i.height)/(h.bottom+h.top))),r){var p=Math.min(d.width,d.height);p!==1/0&&k.forEach((function(t){h[t]*=p}))}else d.width!==1/0&&L.forEach((function(t){h[t]*=d.width})),d.height!==1/0&&P.forEach((function(t){h[t]*=d.height}));return h}function Ct(t,e,i){return 0==e&&0==i?t/2:0==e?0:0==i?t:t*Math.abs(e/(e+i))}var Et=d("vue-simple-handler"),Wt=d("vue-simple-handler-wrapper"),Tt={name:"SimpleHandler",components:{HandlerWrapper:D},props:{defaultClass:{type:String},hoverClass:{type:String},wrapperClass:{type:String},horizontalPosition:{type:String},verticalPosition:{type:String},disabled:{type:Boolean,default:!1}},data:function(){return{hover:!1}},computed:{classes:function(){var t,e=(o(t={},this.horizontalPosition,Boolean(this.horizontalPosition)),o(t,this.verticalPosition,Boolean(this.verticalPosition)),o(t,"".concat(this.horizontalPosition,"-").concat(this.verticalPosition),Boolean(this.verticalPosition&&this.horizontalPosition)),o(t,"hover",this.hover),t);return{default:u(Et(e),this.defaultClass,this.hover&&this.hoverClass),wrapper:u(Wt(e),this.wrapperClass)}}},methods:{onDrag:function(t){this.$emit("drag",t)},onEnter:function(){this.hover=!0},onLeave:function(){this.hover=!1},onDragEnd:function(){this.$emit("drag-end")}},emits:["drag","drag-end"]};Tt.render=function(t,i,n,o,s,r){var a=e.resolveComponent("HandlerWrapper");return e.openBlock(),e.createBlock(a,{class:r.classes.wrapper,"vertical-position":n.verticalPosition,"horizontal-position":n.horizontalPosition,disabled:n.disabled,onDrag:r.onDrag,onDragEnd:r.onDragEnd,onEnter:r.onEnter,onLeave:r.onLeave},{default:e.withCtx((function(){return[e.createVNode("div",{class:r.classes.default},null,2)]})),_:1},8,["class","vertical-position","horizontal-position","disabled","onDrag","onDragEnd","onEnter","onLeave"])};var Bt=d("vue-simple-line"),Ot=d("vue-simple-line-wrapper"),Dt={name:"SimpleLine",components:{LineWrapper:j},props:{defaultClass:{type:String},hoverClass:{type:String},wrapperClass:{type:String},position:{type:String},disabled:{type:Boolean,default:!1}},data:function(){return{hover:!1}},computed:{classes:function(){return{root:u(Bt(o({},this.position,!0)),this.defaultClass,this.hover&&this.hoverClass),wrapper:u(Ot(o({},this.position,!0)),this.wrapperClass)}}},methods:{onDrag:function(t){this.$emit("drag",t)},onEnter:function(){this.hover=!0},onLeave:function(){this.hover=!1},onDragEnd:function(){this.$emit("drag-end")}},emits:["drag","drag-end"]};Dt.render=function(t,i,n,o,s,r){var a=e.resolveComponent("LineWrapper");return e.openBlock(),e.createBlock(a,{class:r.classes.wrapper,position:n.position,disabled:n.disabled,onDrag:r.onDrag,onDragEnd:r.onDragEnd,onEnter:r.onEnter,onLeave:r.onLeave},{default:e.withCtx((function(){return[e.createVNode("div",{class:r.classes.root},null,2)]})),_:1},8,["class","position","disabled","onDrag","onDragEnd","onEnter","onLeave"])};var Ht=d("vue-bounding-box"),jt=["east","west",null],kt=["south","north",null],Lt={name:"BoundingBox",props:{width:{type:Number},height:{type:Number},transitions:{type:Object},handlers:{type:Object,default:function(){return{eastNorth:!0,north:!0,westNorth:!0,west:!0,westSouth:!0,south:!0,eastSouth:!0,east:!0}}},handlersComponent:{type:[Object,String],default:function(){return Tt}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function(){return{}}},lines:{type:Object,default:function(){return{west:!0,north:!0,east:!0,south:!0}}},linesComponent:{type:[Object,String],default:function(){return Dt}},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},resizable:{type:Boolean,default:!0}},data:function(){var t=[];return jt.forEach((function(e){kt.forEach((function(i){if(e!==i){var n=f(e,i),o=n.name,s=n.classname;t.push({name:o,classname:s,verticalDirection:i,horizontalDirection:e})}}))})),{points:t}},computed:{style:function(){var t={};return this.width&&this.height&&(t.width="".concat(this.width,"px"),t.height="".concat(this.height,"px"),this.transitions&&this.transitions.enabled&&(t.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction))),t},classes:function(){var t=this.handlersClasses,e=this.handlersWrappersClasses,i=this.linesClasses,n=this.linesWrappersClasses;return{root:Ht(),handlers:t,handlersWrappers:e,lines:i,linesWrappers:n}},lineNodes:function(){var t=this,e=[];return this.points.forEach((function(i){i.horizontalDirection&&i.verticalDirection||!t.lines[i.name]||e.push({name:i.name,component:t.linesComponent,class:u(t.classes.lines.default,t.classes.lines[i.name],!t.resizable&&t.classes.lines.disabled),wrapperClass:u(t.classes.linesWrappers.default,t.classes.linesWrappers[i.name],!t.resizable&&t.classes.linesWrappers.disabled),hoverClass:t.classes.lines.hover,verticalDirection:i.verticalDirection,horizontalDirection:i.horizontalDirection,disabled:!t.resizable})})),e},handlerNodes:function(){var t=this,e=[],i=this.width,n=this.height;return this.points.forEach((function(s){if(t.handlers[s.name]){var r={name:s.name,component:t.handlersComponent,class:u(t.classes.handlers.default,t.classes.handlers[s.name]),wrapperClass:u(t.classes.handlersWrappers.default,t.classes.handlersWrappers[s.name]),hoverClass:t.classes.handlers.hover,verticalDirection:s.verticalDirection,horizontalDirection:s.horizontalDirection,disabled:!t.resizable};if(i&&n){var a=s.horizontalDirection,h=s.verticalDirection,c="east"===a?i:"west"===a?0:i/2,l="south"===h?n:"north"===h?0:n/2;r.wrapperClass=Ht("handler"),r.wrapperStyle={transform:"translate(".concat(c,"px, ").concat(l,"px)")},t.transitions&&t.transitions.enabled&&(r.wrapperStyle.transition="".concat(t.transitions.time,"ms ").concat(t.transitions.timingFunction))}else r.wrapperClass=Ht("handler",o({},s.classname,!0));e.push(r)}})),e}},beforeMount:function(){window.addEventListener("mouseup",this.onMouseUp,{passive:!1}),window.addEventListener("mousemove",this.onMouseMove,{passive:!1}),window.addEventListener("touchmove",this.onTouchMove,{passive:!1}),window.addEventListener("touchend",this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd)},mounted:function(){this.touches=[]},methods:{onEnd:function(){this.$emit("resize-end")},onHandlerDrag:function(t,e,i){var n,o=t.shift(),s=o.left,r=o.top,a={left:0,right:0,top:0,bottom:0};"west"===e?a.left-=s:"east"===e&&(a.right+=s),"north"===i?a.top-=r:"south"===i&&(a.bottom+=r),!i&&e?n="width":i&&!e&&(n="height"),this.resizable&&this.$emit("resize",new E(a,{allowedDirections:{left:"west"===e||!e,right:"east"===e||!e,bottom:"south"===i||!i,top:"north"===i||!i},preserveAspectRatio:t.nativeEvent&&t.nativeEvent.shiftKey,respectDirection:n}))}},emits:["resize","resize-end"]};Lt.render=function(t,i,n,o,s,r){return e.openBlock(),e.createBlock("div",{ref:"box",class:r.classes.root,style:r.style},[e.renderSlot(t.$slots,"default"),e.createVNode("div",null,[(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(r.lineNodes,(function(t){return e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.component),{key:t.name,"default-class":t.class,"hover-class":t.hoverClass,"wrapper-class":t.wrapperClass,position:t.name,disabled:t.disabled,onDrag:function(e){return r.onHandlerDrag(e,t.horizontalDirection,t.verticalDirection)},onDragEnd:i[1]||(i[1]=function(t){return r.onEnd()})},null,8,["default-class","hover-class","wrapper-class","position","disabled","onDrag"])})),128))]),(e.openBlock(!0),e.createBlock(e.Fragment,null,e.renderList(r.handlerNodes,(function(t){return e.openBlock(),e.createBlock("div",{key:t.name,style:t.wrapperStyle,class:t.wrapperClass},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.component),{"default-class":t.class,"hover-class":t.hoverClass,"wrapper-class":t.wrapperClass,"horizontal-position":t.horizontalDirection,"vertical-position":t.verticalDirection,disabled:t.disabled,onDrag:function(e){return r.onHandlerDrag(e,t.horizontalDirection,t.verticalDirection)},onDragEnd:i[2]||(i[2]=function(t){return r.onEnd()})},null,8,["default-class","hover-class","wrapper-class","horizontal-position","vertical-position","disabled","onDrag"]))],6)})),128))],6)};var Pt=d("vue-draggable-area"),$t={name:"DraggableArea",props:{movable:{type:Boolean,default:!0},activationDistance:{type:Number,default:20}},computed:{classnames:function(){return{default:Pt()}}},beforeMount:function(){window.addEventListener("mouseup",this.onMouseUp,{passive:!1}),window.addEventListener("mousemove",this.onMouseMove,{passive:!1}),window.addEventListener("touchmove",this.onTouchMove,{passive:!1}),window.addEventListener("touchend",this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd)},mounted:function(){this.touches=[],this.touchStarted=!1},methods:{onTouchStart:function(t){if(t.cancelable){var e=this.movable&&1===t.touches.length;e&&(this.touches=r(t.touches)),(this.touchStarted||e)&&(t.preventDefault(),t.stopPropagation())}},onTouchEnd:function(){this.touchStarted=!1,this.processEnd()},onTouchMove:function(t){this.touches.length>=1&&(this.touchStarted?(this.processMove(t,t.touches),t.preventDefault(),t.stopPropagation()):x({x:this.touches[0].clientX,y:this.touches[0].clientY},{x:t.touches[0].clientX,y:t.touches[0].clientY})>this.activationDistance&&(this.initAnchor({clientX:t.touches[0].clientX,clientY:t.touches[0].clientY}),this.touchStarted=!0))},onMouseDown:function(t){if(this.movable&&0===t.button){var e={fake:!0,clientX:t.clientX,clientY:t.clientY};this.touches=[e],this.initAnchor(e),t.stopPropagation()}},onMouseMove:function(t){this.touches.length&&(this.processMove(t,[{fake:!0,clientX:t.clientX,clientY:t.clientY}]),t.preventDefault&&t.cancelable&&t.preventDefault(),t.stopPropagation())},onMouseUp:function(){this.processEnd()},initAnchor:function(t){var e=this.$refs.container.getBoundingClientRect(),i=e.left,n=e.top;this.anchor={x:t.clientX-i,y:t.clientY-n}},processMove:function(t,e){var i=r(e);if(this.touches.length){var n=this.$refs.container.getBoundingClientRect(),o=n.left,s=n.top;1===this.touches.length&&1===i.length&&this.$emit("move",new W({left:i[0].clientX-(o+this.anchor.x),top:i[0].clientY-(s+this.anchor.y)}))}},processEnd:function(){this.touches.length&&this.$emit("move-end"),this.touches=[]}},emits:["move","move-end"]};$t.render=function(t,i,n,o,s,r){return e.openBlock(),e.createBlock("div",{ref:"container",onTouchstart:i[1]||(i[1]=function(){return r.onTouchStart&&r.onTouchStart.apply(r,arguments)}),onMousedown:i[2]||(i[2]=function(){return r.onMouseDown&&r.onMouseDown.apply(r,arguments)})},[e.renderSlot(t.$slots,"default")],544)};function It(t){var e,i;return{rotate:t.rotate||0,flip:{horizontal:(null===(e=null==t?void 0:t.flip)||void 0===e?void 0:e.horizontal)||!1,vertical:(null===(i=null==t?void 0:t.flip)||void 0===i?void 0:i.vertical)||!1}}}function Nt(t){return new Promise((function(e,i){try{if(t)if(/^data:/i.test(t))e(function(t){t=t.replace(/^data:([^;]+);base64,/gim,"");for(var e=atob(t),i=e.length,n=new ArrayBuffer(i),o=new Uint8Array(n),s=0;s<i;s++)o[s]=e.charCodeAt(s);return n}(t));else if(/^blob:/i.test(t)){var n=new FileReader;n.onload=function(t){e(t.target.result)},s=t,r=function(t){n.readAsArrayBuffer(t)},(a=new XMLHttpRequest).open("GET",s,!0),a.responseType="blob",a.onload=function(){200!=this.status&&0!==this.status||r(this.response)},a.send()}else{var o=new XMLHttpRequest;o.onreadystatechange=function(){4===o.readyState&&(200===o.status||0===o.status?e(o.response):i("Warning: could not load an image to parse its orientation"),o=null)},o.onprogress=function(){"image/jpeg"!==o.getResponseHeader("content-type")&&o.abort()},o.withCredentials=!1,o.open("GET",t,!0),o.responseType="arraybuffer",o.send(null)}else i("Error: the image is empty")}catch(t){i(t)}var s,r,a}))}function Xt(t){var e=t.rotate,i=t.flip,n=t.scaleX,o=t.scaleY,s="";return s+=" rotate("+e+"deg) ",s+=" scaleX("+n*(i.horizontal?-1:1)+") ",s+=" scaleY("+o*(i.vertical?-1:1)+") "}function Yt(t){try{var e,i=new DataView(t),n=void 0,o=void 0,s=void 0,r=void 0;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var a=i.byteLength,h=2;h+1<a;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){s=h;break}h++}if(s&&(n=s+10,"Exif"===function(t,e,i){var n,o="";for(n=e,i+=e;n<i;n++)o+=String.fromCharCode(t.getUint8(n));return o}(i,s+4,4))){var c=i.getUint16(n);if(((o=18761===c)||19789===c)&&42===i.getUint16(n+2,o)){var l=i.getUint32(n+4,o);l>=8&&(r=n+l)}}if(r)for(var u=i.getUint16(r,o),d=0;d<u;d++){h=r+12*d+2;if(274===i.getUint16(h,o)){h+=8,e=i.getUint16(h,o),i.setUint16(h,1,o);break}}return e}catch(t){return null}}var Ft=d("vue-preview-result"),Ut={name:"PreviewResult",props:{image:{type:Object},transitions:{type:Object},stencilCoordinates:{type:Object,default:function(){return{width:0,height:0,left:0,top:0}}},imageClass:{type:String}},computed:{classes:function(){return{root:Ft(),wrapper:Ft("wrapper"),imageWrapper:Ft("image-wrapper"),image:u(Ft("image"),this.imageClass)}},wrapperStyle:function(){var t={width:"".concat(this.stencilCoordinates.width,"px"),height:"".concat(this.stencilCoordinates.height,"px"),left:"calc(50% - ".concat(this.stencilCoordinates.width/2,"px)"),top:"calc(50% - ".concat(this.stencilCoordinates.height/2,"px)")};return this.transitions&&this.transitions.enabled&&(t.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),t},imageStyle:function(){var t=this.image.transforms,e=it({width:this.image.width,height:this.image.height},t.rotate),i={width:"".concat(this.image.width,"px"),height:"".concat(this.image.height,"px"),left:"0px",top:"0px"},n={left:(this.image.width-e.width)*t.scaleX/2,top:(this.image.height-e.height)*t.scaleY/2},o={left:(1-t.scaleX)*this.image.width/2,top:(1-t.scaleY)*this.image.height/2};return i.transform="translate(\n\t\t\t\t".concat(-this.stencilCoordinates.left-t.translateX-n.left-o.left,"px,").concat(-this.stencilCoordinates.top-t.translateY-n.top-o.top,"px) ")+Xt(t),this.transitions&&this.transitions.enabled&&(i.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),i}}};function Vt(t,e){var i=e.getBoundingClientRect(),n=i.left,o=i.top,s={left:0,top:0},r=0;return t.forEach((function(e){s.left+=(e.clientX-n)/t.length,s.top+=(e.clientY-o)/t.length})),t.forEach((function(t){r+=x({x:s.left,y:s.top},{x:t.clientX-n,y:t.clientY-o})})),{centerMass:s,spread:r,count:t.length}}Ut.render=function(t,i,n,o,s,r){return e.openBlock(),e.createBlock("div",{class:r.classes.root},[e.createVNode("div",{ref:"wrapper",class:r.classes.wrapper,style:r.wrapperStyle},[e.createVNode("img",{ref:"image",src:n.image.src,class:r.classes.image,style:r.imageStyle},null,14,["src"])],6)],2)};var Zt={props:{touchMove:{type:Boolean,required:!0},mouseMove:{type:Boolean,required:!0},touchResize:{type:Boolean,required:!0},wheelResize:{type:[Boolean,Object],required:!0},eventsFilter:{type:Function,required:!1}},beforeMount:function(){window.addEventListener("mouseup",this.onMouseUp,{passive:!1}),window.addEventListener("mousemove",this.onMouseMove,{passive:!1}),window.addEventListener("touchmove",this.onTouchMove,{passive:!1}),window.addEventListener("touchend",this.onTouchEnd,{passive:!1})},beforeUnmount:function(){window.removeEventListener("mouseup",this.onMouseUp),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd)},created:function(){this.transforming=!1,this.debouncedProcessEnd=p(this.processEnd),this.touches=[]},methods:{processMove:function(t,e){if(this.touches.length){if(1===this.touches.length&&1===e.length)this.$emit("move",new C({left:this.touches[0].clientX-e[0].clientX,top:this.touches[0].clientY-e[0].clientY}));else if(this.touches.length>1&&this.touchResize){var i=Vt(e,this.$refs.container),n=this.oldGeometricProperties;n.count===i.count&&n.count>1&&this.$emit("resize",new C({left:n.centerMass.left-i.centerMass.left,top:n.centerMass.top-i.centerMass.top},{factor:n.spread/i.spread,center:i.centerMass})),this.oldGeometricProperties=i}this.touches=e}},processEnd:function(){this.transforming&&(this.transforming=!1,this.$emit("transform-end"))},processStart:function(){this.transforming=!0,this.debouncedProcessEnd.clear()},processEvent:function(t){return this.eventsFilter?!1!==this.eventsFilter(t,this.transforming):(t.preventDefault(),t.stopPropagation(),!0)},onTouchStart:function(t){if(t.cancelable&&(this.touchMove||this.touchResize&&t.touches.length>1)&&this.processEvent(t)){var e=this.$refs.container,i=e.getBoundingClientRect(),n=i.left,o=i.top,s=i.bottom,a=i.right;this.touches=r(t.touches).filter((function(t){return t.clientX>n&&t.clientX<a&&t.clientY>o&&t.clientY<s})),this.oldGeometricProperties=Vt(this.touches,e)}},onTouchEnd:function(t){0===t.touches.length&&(this.touches=[],this.processEnd())},onTouchMove:function(t){var e=this;if(this.touches.length){var i=r(t.touches).filter((function(t){return!t.identifier||e.touches.find((function(e){return e.identifier===t.identifier}))}));this.processEvent(t)&&(this.processMove(t,i),this.processStart())}},onMouseDown:function(t){if(this.mouseMove&&"buttons"in t&&1===t.buttons&&this.processEvent(t)){var e={fake:!0,clientX:t.clientX,clientY:t.clientY};this.touches=[e],this.processStart()}},onMouseMove:function(t){this.touches.length&&this.processEvent(t)&&this.processMove(t,[{clientX:t.clientX,clientY:t.clientY}])},onMouseUp:function(){this.touches=[],this.processEnd()},onWheel:function(t){if(this.wheelResize&&this.processEvent(t)){var e=this.$refs.container.getBoundingClientRect(),i=e.left,n=e.top,o=1+this.wheelResize.ratio*(r=t.deltaY||t.detail||t.wheelDelta,0===(a=+r)||M(a)?a:a>0?1:-1),s={left:t.clientX-i,top:t.clientY-n};this.$emit("resize",new C({},{factor:o,center:s})),this.touches.length||this.debouncedProcessEnd()}var r,a}},emits:["resize","move","transform-end"]};Zt.render=function(t,i,n,o,s,r){return e.openBlock(),e.createBlock("div",{ref:"container",onTouchstart:i[1]||(i[1]=function(){return r.onTouchStart&&r.onTouchStart.apply(r,arguments)}),onMousedown:i[2]||(i[2]=function(){return r.onMouseDown&&r.onMouseDown.apply(r,arguments)}),onWheel:i[3]||(i[3]=function(){return r.onWheel&&r.onWheel.apply(r,arguments)})},[e.renderSlot(t.$slots,"default")],544)};var qt={components:{TransformableImage:Zt},props:{touchMove:{type:Boolean,required:!0},mouseMove:{type:Boolean,required:!0},touchResize:{type:Boolean,required:!0},wheelResize:{type:[Boolean,Object],required:!0}},emits:["resize","move"]};qt.render=function(t,i,n,o,s,r){var a=e.resolveComponent("transformable-image");return e.openBlock(),e.createBlock(a,{"touch-move":n.touchMove,"touch-resize":n.touchResize,"mouse-move":n.mouseMove,"wheel-resize":n.wheelResize,onMove:i[1]||(i[1]=function(e){return t.$emit("move",e)}),onResize:i[2]||(i[2]=function(e){return t.$emit("resize",e)})},{default:e.withCtx((function(){return[e.renderSlot(t.$slots,"default")]})),_:3},8,["touch-move","touch-resize","mouse-move","wheel-resize"])};var _t=d("vue-preview"),Gt={props:{coordinates:{type:Object},transitions:{type:Object},image:{type:Object,default:function(){return{}}},imageClass:{type:String},width:{type:Number},height:{type:Number},fill:{type:Boolean}},data:function(){return{calculatedImageSize:{width:0,height:0},calculatedSize:{width:0,height:0}}},computed:{classes:function(){return{root:_t({fill:this.fill}),wrapper:_t("wrapper"),imageWrapper:_t("image-wrapper"),image:u(_t("image"),this.imageClass)}},style:function(){if(this.fill)return{};var t={};return this.width&&(t.width="".concat(this.size.width,"px")),this.height&&(t.height="".concat(this.size.height,"px")),this.transitions&&this.transitions.enabled&&(t.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),t},wrapperStyle:function(){var t={width:"".concat(this.size.width,"px"),height:"".concat(this.size.height,"px"),left:"calc(50% - ".concat(this.size.width/2,"px)"),top:"calc(50% - ".concat(this.size.height/2,"px)")};return this.transitions&&this.transitions.enabled&&(t.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),t},imageStyle:function(){if(this.coordinates&&this.image){var t=this.coordinates.width/this.size.width,e=n(n({rotate:0,flip:{horizontal:!1,vertical:!1}},this.image.transforms),{},{scaleX:1/t,scaleY:1/t}),i=this.imageSize.width,o=this.imageSize.height,s=it({width:i,height:o},e.rotate),r={width:"".concat(i,"px"),height:"".concat(o,"px"),left:"0px",top:"0px"},a={rotate:{left:(i-s.width)*e.scaleX/2,top:(o-s.height)*e.scaleY/2},scale:{left:(1-e.scaleX)*i/2,top:(1-e.scaleY)*o/2}};return r.transform="translate(\n\t\t\t\t".concat(-this.coordinates.left/t-a.rotate.left-a.scale.left,"px,").concat(-this.coordinates.top/t-a.rotate.top-a.scale.top,"px) ")+Xt(e),this.transitions&&this.transitions.enabled&&(r.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),r}return{}},size:function(){return{width:this.width||this.calculatedSize.width,height:this.height||this.calculatedSize.height}},imageSize:function(){return{width:this.image.width||this.calculatedImageSize.width,height:this.image.height||this.calculatedImageSize.height}}},watch:{image:function(t){(t.width||t.height)&&this.onChangeImage()}},mounted:function(){var t=this;this.onChangeImage(),this.$refs.image.addEventListener("load",(function(){t.refreshImage()})),window.addEventListener("resize",this.refresh),window.addEventListener("orientationchange",this.refresh)},unmounted:function(){window.removeEventListener("resize",this.refresh),window.removeEventListener("orientationchange",this.refresh)},methods:{refreshImage:function(){var t=this.$refs.image;this.calculatedImageSize.height=t.naturalHeight,this.calculatedImageSize.width=t.naturalWidth},refresh:function(){var t=this.$refs.root;this.width||(this.calculatedSize.width=t.clientWidth),this.height||(this.calculatedSize.height=t.clientHeight)},onChangeImage:function(){var t=this.$refs.image;t&&t.complete&&this.refreshImage(),this.refresh()}}};Gt.render=function(t,i,n,o,s,r){return e.openBlock(),e.createBlock("div",{ref:"root",class:r.classes.root,style:r.style},[e.createVNode("div",{ref:"wrapper",class:r.classes.wrapper,style:r.wrapperStyle},[e.withDirectives(e.createVNode("img",{ref:"image",src:n.image&&n.image.src,class:r.classes.image,style:r.imageStyle},null,14,["src"]),[[e.vShow,n.image&&n.image.src]])],6)],6)};var Qt={components:{Preview:Gt},inheritAttrs:!1};Qt.render=function(t,i,n,o,s,r){var a=e.resolveComponent("preview");return e.openBlock(),e.createBlock(a,e.mergeProps(t.$attrs,{fill:!0}),null,16)};var Kt=d("vue-rectangle-stencil"),Jt={name:"RectangleStencil",components:{StencilPreview:Qt,BoundingBox:Lt,DraggableArea:$t},props:{image:{type:Object},coordinates:{type:Object},stencilCoordinates:{type:Object},handlers:{type:Object},handlersComponent:{type:[Object,String],default:function(){return Tt}},lines:{type:Object},linesComponent:{type:[Object,String],default:function(){return Dt}},aspectRatio:{type:[Number,String]},minAspectRatio:{type:[Number,String]},maxAspectRatio:{type:[Number,String]},movable:{type:Boolean,default:!0},resizable:{type:Boolean,default:!0},transitions:{type:Object},movingClass:{type:String},resizingClass:{type:String},previewClass:{type:String},boundingBoxClass:{type:String},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function(){return{}}}},data:function(){return{moving:!1,resizing:!1}},computed:{classes:function(){return{stencil:u(Kt({movable:this.movable,moving:this.moving,resizing:this.resizing}),this.moving&&this.movingClass,this.resizing&&this.resizingClass),preview:u(Kt("preview"),this.previewClass),boundingBox:u(Kt("bounding-box"),this.boundingBoxClass)}},style:function(){var t=this.stencilCoordinates,e=t.height,i=t.width,n=t.left,o=t.top,s={width:"".concat(i,"px"),height:"".concat(e,"px"),transform:"translate(".concat(n,"px, ").concat(o,"px)")};return this.transitions&&this.transitions.enabled&&(s.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),s}},methods:{onMove:function(t){this.$emit("move",t),this.moving=!0},onMoveEnd:function(){this.$emit("move-end"),this.moving=!1},onResize:function(t){this.$emit("resize",t),this.resizing=!0},onResizeEnd:function(){this.$emit("resize-end"),this.resizing=!1},aspectRatios:function(){return{minimum:this.aspectRatio||this.minAspectRatio,maximum:this.aspectRatio||this.maxAspectRatio}}},emits:["resize","resize-end","move","move-end"]};Jt.render=function(t,i,n,o,s,r){var a=e.resolveComponent("stencil-preview"),h=e.resolveComponent("draggable-area"),c=e.resolveComponent("bounding-box");return e.openBlock(),e.createBlock("div",{class:r.classes.stencil,style:r.style},[e.createVNode(c,{width:n.stencilCoordinates.width,height:n.stencilCoordinates.height,transitions:n.transitions,class:r.classes.boundingBox,handlers:n.handlers,"handlers-component":n.handlersComponent,"handlers-classes":n.handlersClasses,"handlers-wrappers-classes":n.handlersWrappersClasses,lines:n.lines,"lines-component":n.linesComponent,"lines-classes":n.linesClasses,"lines-wrappers-classes":n.linesWrappersClasses,resizable:n.resizable,onResize:r.onResize,onResizeEnd:r.onResizeEnd},{default:e.withCtx((function(){return[e.createVNode(h,{movable:n.movable,onMove:r.onMove,onMoveEnd:r.onMoveEnd},{default:e.withCtx((function(){return[e.createVNode(a,{image:n.image,coordinates:n.coordinates,width:n.stencilCoordinates.width,height:n.stencilCoordinates.height,class:r.classes.preview,transitions:n.transitions},null,8,["image","coordinates","width","height","class","transitions"])]})),_:1},8,["movable","onMove","onMoveEnd"])]})),_:1},8,["width","height","transitions","class","handlers","handlers-component","handlers-classes","handlers-wrappers-classes","lines","lines-component","lines-classes","lines-wrappers-classes","resizable","onResize","onResizeEnd"])],6)};var te=d("vue-circle-stencil"),ee={components:{StencilPreview:Qt,BoundingBox:Lt,DraggableArea:$t},props:{image:{type:Object},coordinates:{type:Object},stencilCoordinates:{type:Object},handlers:{type:Object,default:function(){return{eastNorth:!0,westNorth:!0,westSouth:!0,eastSouth:!0}}},handlersComponent:{type:[Object,String],default:function(){return Tt}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function(){retur