vue-advanced-cropper
Version:
The advanced library to create your own croppers suited for any website design
21 lines (19 loc) • 85.7 kB
JavaScript
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("vue");function e(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 i(t){for(var i=1;i<arguments.length;i++){var o=null!=arguments[i]?arguments[i]:{};i%2?e(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function o(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 s(t){return function(t){if(Array.isArray(t))return r(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 r(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 r(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 r(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 a,h,c,l=(a=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}()},a(c={path:h,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&c.path)}},c.exports),c.exports),u=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 d(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}d.debounce=d;var m=d,p=function(){return p=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},p.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 g(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 f(t){return/^blob:/.test(t)}function v(t){return f(t)||function(t){return/^data:/.test(t)}(t)}function b(t){return!!(t&&t.constructor&&t.call&&t.apply)}function w(t){return void 0===t}function y(t){return"object"==typeof t&&null!==t}function z(t,e,i){var n={};return y(t)?(Object.keys(e).forEach((function(o){w(t[o])?n[o]=e[o]:y(e[o])?y(t[o])?n[o]=z(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 R(t){var e=Number(t);return Number.isNaN(e)?t:e}function A(t){return typeof("number"==t||function(t){return"object"==typeof t&&null!==t}(t)&&"[object Number]"==toString.call(t))&&!x(t)}function x(t){return t!=t}function S(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}var M=function(t,e){void 0===t&&(t={}),void 0===e&&(e={}),this.type="manipulateImage",this.move=t,this.scale=e},C=function(t,e){void 0===e&&(e={}),this.type="resize",this.directions=t,this.params=e},E=function(t){this.type="move",this.directions=t},W=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}(),T={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=s(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=s(e);if(this.touches.length){if(1===this.touches.length&&1===i.length){var n=this.$refs.draggable;this.$emit("drag",new W(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"]};T.render=function(e,i,n,o,s,r){return t.openBlock(),t.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)})},[t.renderSlot(e.$slots,"default")],34)};var B=u("vue-handler-wrapper"),O={name:"HandlerWrapper",components:{DraggableElement:T},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=g(this.horizontalPosition,this.verticalPosition);t=B((n(e={},i.classname,!0),n(e,"disabled",this.disabled),e))}else t=B({disabled:this.disabled});return{root:t,draggable:B("draggable")}}},emits:["leave","enter","drag","drag-end"]};O.render=function(e,i,n,o,s,r){var a=t.resolveComponent("DraggableElement");return t.openBlock(),t.createBlock("div",{class:r.classes.root},[t.createVNode(a,{class:r.classes.draggable,onDrag:i[1]||(i[1]=function(t){return e.$emit("drag",t)}),onDragEnd:i[2]||(i[2]=function(t){return e.$emit("drag-end")}),onLeave:i[3]||(i[3]=function(t){return e.$emit("leave")}),onEnter:i[4]||(i[4]=function(t){return e.$emit("enter")})},{default:t.withCtx((function(){return[t.renderSlot(e.$slots,"default")]})),_:3},8,["class"])],2)};var D=u("vue-line-wrapper"),H={name:"LineWrapper",components:{DraggableElement:T},props:{position:{type:String,required:!0},disabled:{type:Boolean,default:!1}},computed:{classname:function(){var t;return D((n(t={},this.position,!0),n(t,"disabled",this.disabled),t))}},emits:["leave","enter","drag","drag-end"]};H.render=function(e,i,n,o,s,r){var a=t.resolveComponent("DraggableElement");return t.openBlock(),t.createBlock(a,{class:r.classname,onDrag:i[1]||(i[1]=function(t){return e.$emit("drag",t)}),onDragEnd:i[2]||(i[2]=function(t){return e.$emit("drag-end")}),onLeave:i[3]||(i[3]=function(t){return e.$emit("leave")}),onEnter:i[4]||(i[4]=function(t){return e.$emit("enter")})},{default:t.withCtx((function(){return[t.renderSlot(e.$slots,"default")]})),_:3},8,["class"])};var j=["left","right","top","bottom"],k=["left","right"],L=["top","bottom"],P=["left","top"],$=["fill-area","fit-area","stencil","none"],I={left:0,top:0,width:0,height:0};function N(t,e,i){return!(i=i||["width","height","left","top"]).some((function(i){return t[i]!==e[i]}))}function X(t){return{left:t.left,top:t.top,right:t.left+t.width,bottom:t.top+t.height}}function Y(t,e){return{left:t.left-e.left,top:t.top-e.top}}function F(t){return{left:t.left+t.width/2,top:t.top+t.height/2}}function U(t,e){var i={left:0,top:0,right:0,bottom:0};return j.forEach((function(n){var o=e[n],s=X(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 V(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 Z(t,e){return p(p({},t),{left:t.left+e.left,top:t.top+e.top})}function _(t,e,i,n){if(1!==e){if(i){var o=F(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 G(t){return t.width/t.height}function Q(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 K(t,e){var i={left:0,top:0},n=U(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 J(t,e){var i;return e.minimum&&t<e.minimum?i=e.minimum:e.maximum&&t>e.maximum&&(i=e.maximum),i}function tt(t,e){var i=G(t),n=G(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 et(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 it(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 nt(t,e){var i=U(ot(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,Q(t,e)):Math.min((t.height+i.top+i.bottom)/t.height,Q(t,e)):1}function ot(t,e,i){void 0===i&&(i=!1);var n=K(t,e);return Z(t,i?q(n):n)}function st(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 rt(t,e){return p(p({},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 at(t,e,i){void 0===i&&(i=!0);var n={};return j.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 ht(t,e){return at(t,e,!0)}function ct(t){var e=t.size,i=t.aspectRatio,n=t.ignoreMinimum,o=t.sizeRestrictions;return Boolean((e.correctRatio||G(e)>=i.minimum&&G(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 lt(t,e){return Math.pow(t.width-e.width,2)+Math.pow(t.height-e.height,2)}function ut(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 ct({size:r,aspectRatio:o,sizeRestrictions:n,ignoreMinimum:s})&&(!t||lt(r,{width:e,height:i})<lt(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})})),ct({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 dt(t){var e=t.event,i=t.coordinates,n=t.positionRestrictions,o=void 0===n?{}:n,s=Z(i,e.directions);return Z(s,K(s,o))}function mt(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 dt({coordinates:t,positionRestrictions:s,event:new E({left:e.left-t.left,top:e.top-t.top})})},c=p({},e);return(Array.isArray(i)?i:[i]).forEach((function(t){var e={};w((e="function"==typeof t?t({coordinates:c,imageSize:n,visibleArea:a}):t).width)&&w(e.height)||(c=function(t,e){var i=p(p(p({},t),ut({width:e.width,height:e.height,sizeRestrictions:o,aspectRatio:r})),{left:0,top:0});return h(i,{left:t.left,top:t.top})}(c,p(p({},c),e))),w(e.left)&&w(e.top)||(c=h(c,p(p({},c),e)))})),c}function pt(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=p({},n),d=p({},o),m=p({},s);h=G(m),c=G(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=p(p({},u),ut({sizeRestrictions:r,width:u.width,height:u.height,aspectRatio:{minimum:G(m),maximum:G(m)}})));var g=nt(d=_(d,u.width*i.width/(d.width*m.width)),e({visibleArea:d,type:"resize"}));return 1!==g&&(d=_(d,g),u=_(u,g)),d=ot(d=Z(d,Y(F(u),F(d))),e({visibleArea:d,type:"move"})),{coordinates:u=ot(u,ht(X(d),a)),visibleArea:d}}function gt(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=p({},o),h=p({},s);if(o&&s&&"manipulateImage"!==e.type){var c={width:0,height:0};h.width,n.width,G(n)>G(a)?(c.height=.8*n.height,c.width=c.height*G(a)):(c.width=.8*n.width,c.height=c.width*G(a));var l=nt(h=_(h,a.width*n.width/(h.width*c.width)),i({visibleArea:h,type:"resize"}));h=_(h,l),1!==l&&(c.height/=l,c.width/=l),h=ot(h=Z(h,Y(F(a),F(h))),i({visibleArea:h,type:"move"})),a=ot(a,ht(X(h),r))}return{coordinates:a,visibleArea:h}}function ft(t){var e=t.event,i=t.coordinates,n=t.visibleArea,o=t.getAreaRestrictions,s=p({},n),r=p({},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=_(s,Math.min(r.width/s.width,Q(s,o({visibleArea:s,type:"resize"})))):h>a&&(s=_(s,Math.min(r.height/s.height,Q(s,o({visibleArea:s,type:"resize"}))))),s=ot(s=Z(s,q(K(r,X(s)))),o({visibleArea:s,type:"move"}))}return{visibleArea:s,coordinates:r}}function vt(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 bt(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,G(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 ut(p(p({},a),{aspectRatio:n,sizeRestrictions:o}))}function wt(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 G(c)>G(s)?i=(e=h.height*c.height/s.height)*G(h):e=(i=h.width*c.width/s.width)/G(h),ut({width:i,height:e,aspectRatio:r,sizeRestrictions:a})}function yt(t){var e=t.getAreaRestrictions,i=t.coordinates,n=t.imageSize,o=G(t.boundaries);if(i){var s={height:Math.max(i.height,n.height),width:Math.max(i.width,n.width)},r=tt({width:G(s)>o?s.width:s.height*o,height:G(s)>o?s.width/o:s.height},st(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=U(i,X(p({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),ot(a,c)}var l=G(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 zt(t,e){return at(t,X(e))}function Rt(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=p({},n),u=p({},i),d=1,m=1,g=h.factor&&Math.abs(h.factor-1)>.001;l=Z(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,Q(u,r))},area:{maximum:Q(l,s({visibleArea:l,type:"resize"}))}};h.factor&&g&&(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=_(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=ot(l=Z(l,K(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=ot(u,ht(X(l),r)),h.factor&&g&&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=Z(l=ot(l=_(l,d,h.factor>1?h.center:F(u)),s({visibleArea:l,type:"move"})),q(K(u,X(l)))))),{coordinates:u,visibleArea:l}}function At(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=p({},n),u=p({},o),d=it(F(p({left:0,top:0},h)),c);return(l=p(p({},ut({sizeRestrictions:s,aspectRatio:e,width:l.width,height:l.height})),it(F(l),c))).left-=d.left-a.width/2+l.width/2,l.top-=d.top-a.height/2+l.height/2,u=_(u,nt(u,i({visibleArea:u,type:"resize"}))),{coordinates:l=ot(l,r),visibleArea:u=ot(u=Z(u,Y(F(l),F(n))),i({visibleArea:u,type:"move"}))}}function xt(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=p({},s),c=p({},r),l=i.horizontal!==e.horizontal,u=i.vertical!==e.vertical;if(l||u){var d=it({left:a.width/2,top:a.height/2},-n),m=it(F(h),-n),g=it({left:l?d.left-(m.left-d.left):m.left,top:u?d.top-(m.top-d.top):m.top},n);h=Z(h,Y(g,F(h))),m=it(F(c),-n),c=ot(c=Z(c,Y(g=it({left:l?d.left-(m.left-d.left):m.left,top:u?d.top-(m.top-d.top):m.top},n),F(c))),o({visibleArea:c,type:"move"}))}return{coordinates:h,visibleArea:c}}function St(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=p({},e),c=V(i,h).width,l=V(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=U(V(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=U(V(i,h),o));var d={width:1/0,height:1/0,left:1/0,right:1/0,top:1/0,bottom:1/0};if(j.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,j.map((function(t){return d[t]})));m!==1/0&&j.forEach((function(t){h[t]*=m}))}else j.forEach((function(t){d[t]!==1/0&&(h[t]*=d[t])}));if(c=V(i,h).width,l=V(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 g=Math.min(d.width,d.height);g!==1/0&&j.forEach((function(t){h[t]*=g}))}else d.width!==1/0&&k.forEach((function(t){h[t]*=d.width})),d.height!==1/0&&L.forEach((function(t){h[t]*=d.height}));return h}function Mt(t,e,i){return 0==e&&0==i?t/2:0==e?0:0==i?t:t*Math.abs(e/(e+i))}var Ct=u("vue-simple-handler"),Et=u("vue-simple-handler-wrapper"),Wt={name:"SimpleHandler",components:{HandlerWrapper:O},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=(n(t={},this.horizontalPosition,Boolean(this.horizontalPosition)),n(t,this.verticalPosition,Boolean(this.verticalPosition)),n(t,"".concat(this.horizontalPosition,"-").concat(this.verticalPosition),Boolean(this.verticalPosition&&this.horizontalPosition)),n(t,"hover",this.hover),t);return{default:l(Ct(e),this.defaultClass,this.hover&&this.hoverClass),wrapper:l(Et(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"]};Wt.render=function(e,i,n,o,s,r){var a=t.resolveComponent("HandlerWrapper");return t.openBlock(),t.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:t.withCtx((function(){return[t.createVNode("div",{class:r.classes.default},null,2)]})),_:1},8,["class","vertical-position","horizontal-position","disabled","onDrag","onDragEnd","onEnter","onLeave"])};var Tt=u("vue-simple-line"),Bt=u("vue-simple-line-wrapper"),Ot={name:"SimpleLine",components:{LineWrapper:H},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:l(Tt(n({},this.position,!0)),this.defaultClass,this.hover&&this.hoverClass),wrapper:l(Bt(n({},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"]};Ot.render=function(e,i,n,o,s,r){var a=t.resolveComponent("LineWrapper");return t.openBlock(),t.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:t.withCtx((function(){return[t.createVNode("div",{class:r.classes.root},null,2)]})),_:1},8,["class","position","disabled","onDrag","onDragEnd","onEnter","onLeave"])};var Dt=u("vue-bounding-box"),Ht=["east","west",null],jt=["south","north",null],kt={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 Wt}},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 Ot}},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},resizable:{type:Boolean,default:!0}},data:function(){var t=[];return Ht.forEach((function(e){jt.forEach((function(i){if(e!==i){var n=g(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:Dt(),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:l(t.classes.lines.default,t.classes.lines[i.name],!t.resizable&&t.classes.lines.disabled),wrapperClass:l(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,o=this.height;return this.points.forEach((function(s){if(t.handlers[s.name]){var r={name:s.name,component:t.handlersComponent,class:l(t.classes.handlers.default,t.classes.handlers[s.name]),wrapperClass:l(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&&o){var a=s.horizontalDirection,h=s.verticalDirection,c="east"===a?i:"west"===a?0:i/2,u="south"===h?o:"north"===h?0:o/2;r.wrapperClass=Dt("handler"),r.wrapperStyle={transform:"translate(".concat(c,"px, ").concat(u,"px)")},t.transitions&&t.transitions.enabled&&(r.wrapperStyle.transition="".concat(t.transitions.time,"ms ").concat(t.transitions.timingFunction))}else r.wrapperClass=Dt("handler",n({},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 C(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"]};kt.render=function(e,i,n,o,s,r){return t.openBlock(),t.createBlock("div",{ref:"box",class:r.classes.root,style:r.style},[t.renderSlot(e.$slots,"default"),t.createVNode("div",null,[(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(r.lineNodes,(function(e){return t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.component),{key:e.name,"default-class":e.class,"hover-class":e.hoverClass,"wrapper-class":e.wrapperClass,position:e.name,disabled:e.disabled,onDrag:function(t){return r.onHandlerDrag(t,e.horizontalDirection,e.verticalDirection)},onDragEnd:i[1]||(i[1]=function(t){return r.onEnd()})},null,8,["default-class","hover-class","wrapper-class","position","disabled","onDrag"])})),128))]),(t.openBlock(!0),t.createBlock(t.Fragment,null,t.renderList(r.handlerNodes,(function(e){return t.openBlock(),t.createBlock("div",{key:e.name,style:e.wrapperStyle,class:e.wrapperClass},[(t.openBlock(),t.createBlock(t.resolveDynamicComponent(e.component),{"default-class":e.class,"hover-class":e.hoverClass,"wrapper-class":e.wrapperClass,"horizontal-position":e.horizontalDirection,"vertical-position":e.verticalDirection,disabled:e.disabled,onDrag:function(t){return r.onHandlerDrag(t,e.horizontalDirection,e.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 Lt=u("vue-draggable-area"),Pt={name:"DraggableArea",props:{movable:{type:Boolean,default:!0},activationDistance:{type:Number,default:20}},computed:{classnames:function(){return{default:Lt()}}},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=s(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()):S({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=s(e);if(this.touches.length){var n=this.$refs.container.getBoundingClientRect(),o=n.left,r=n.top;1===this.touches.length&&1===i.length&&this.$emit("move",new E({left:i[0].clientX-(o+this.anchor.x),top:i[0].clientY-(r+this.anchor.y)}))}},processEnd:function(){this.touches.length&&this.$emit("move-end"),this.touches=[]}},emits:["move","move-end"]};Pt.render=function(e,i,n,o,s,r){return t.openBlock(),t.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)})},[t.renderSlot(e.$slots,"default")],544)};function $t(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 It(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 Nt(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 Xt(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 Yt=u("vue-preview-result"),Ft={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:Yt(),wrapper:Yt("wrapper"),imageWrapper:Yt("image-wrapper"),image:l(Yt("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=et({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) ")+Nt(t),this.transitions&&this.transitions.enabled&&(i.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),i}}};function Ut(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+=S({x:s.left,y:s.top},{x:t.clientX-n,y:t.clientY-o})})),{centerMass:s,spread:r,count:t.length}}Ft.render=function(e,i,n,o,s,r){return t.openBlock(),t.createBlock("div",{class:r.classes.root},[t.createVNode("div",{ref:"wrapper",class:r.classes.wrapper,style:r.wrapperStyle},[t.createVNode("img",{ref:"image",src:n.image.src,class:r.classes.image,style:r.imageStyle},null,14,["src"])],6)],2)};var Vt={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=m(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 M({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=Ut(e,this.$refs.container),n=this.oldGeometricProperties;n.count===i.count&&n.count>1&&this.$emit("resize",new M({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,r=i.bottom,a=i.right;this.touches=s(t.touches).filter((function(t){return t.clientX>n&&t.clientX<a&&t.clientY>o&&t.clientY<r})),this.oldGeometricProperties=Ut(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=s(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)||x(a)?a:a>0?1:-1),s={left:t.clientX-i,top:t.clientY-n};this.$emit("resize",new M({},{factor:o,center:s})),this.touches.length||this.debouncedProcessEnd()}var r,a}},emits:["resize","move","transform-end"]};Vt.render=function(e,i,n,o,s,r){return t.openBlock(),t.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)})},[t.renderSlot(e.$slots,"default")],544)};var qt={components:{TransformableImage:Vt},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(e,i,n,o,s,r){var a=t.resolveComponent("transformable-image");return t.openBlock(),t.createBlock(a,{"touch-move":n.touchMove,"touch-resize":n.touchResize,"mouse-move":n.mouseMove,"wheel-resize":n.wheelResize,onMove:i[1]||(i[1]=function(t){return e.$emit("move",t)}),onResize:i[2]||(i[2]=function(t){return e.$emit("resize",t)})},{default:t.withCtx((function(){return[t.renderSlot(e.$slots,"default")]})),_:3},8,["touch-move","touch-resize","mouse-move","wheel-resize"])};var Zt=u("vue-preview"),_t={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:Zt({fill:this.fill}),wrapper:Zt("wrapper"),imageWrapper:Zt("image-wrapper"),image:l(Zt("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=i(i({rotate:0,flip:{horizontal:!1,vertical:!1}},this.image.transforms),{},{scaleX:1/t,scaleY:1/t}),n=this.imageSize.width,o=this.imageSize.height,s=et({width:n,height:o},e.rotate),r={width:"".concat(n,"px"),height:"".concat(o,"px"),left:"0px",top:"0px"},a={rotate:{left:(n-s.width)*e.scaleX/2,top:(o-s.height)*e.scaleY/2},scale:{left:(1-e.scaleX)*n/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) ")+Nt(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()}}};_t.render=function(e,i,n,o,s,r){return t.openBlock(),t.createBlock("div",{ref:"root",class:r.classes.root,style:r.style},[t.createVNode("div",{ref:"wrapper",class:r.classes.wrapper,style:r.wrapperStyle},[t.withDirectives(t.createVNode("img",{ref:"image",src:n.image&&n.image.src,class:r.classes.image,style:r.imageStyle},null,14,["src"]),[[t.vShow,n.image&&n.image.src]])],6)],6)};var Gt={components:{Preview:_t},inheritAttrs:!1};Gt.render=function(e,i,n,o,s,r){var a=t.resolveComponent("preview");return t.openBlock(),t.createBlock(a,t.mergeProps(e.$attrs,{fill:!0}),null,16)};var Qt=u("vue-rectangle-stencil"),Kt={name:"RectangleStencil",components:{StencilPreview:Gt,BoundingBox:kt,DraggableArea:Pt},props:{image:{type:Object},coordinates:{type:Object},stencilCoordinates:{type:Object},handlers:{type:Object},handlersComponent:{type:[Object,String],default:function(){return Wt}},lines:{type:Object},linesComponent:{type:[Object,String],default:function(){return Ot}},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:l(Qt({movable:this.movable,moving:this.moving,resizing:this.resizing}),this.moving&&this.movingClass,this.resizing&&this.resizingClass),preview:l(Qt("preview"),this.previewClass),boundingBox:l(Qt("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"]};Kt.render=function(e,i,n,o,s,r){var a=t.resolveComponent("stencil-preview"),h=t.resolveComponent("draggable-area"),c=t.resolveComponent("bounding-box");return t.openBlock(),t.createBlock("div",{class:r.classes.stencil,style:r.style},[t.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:t.withCtx((function(){return[t.createVNode(h,{movable:n.movable,onMove:r.onMove,onMoveEnd:r.onMoveEnd},{default:t.withCtx((function(){return[t.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 Jt=u("vue-circle-stencil"),te={components:{StencilPreview:Gt,BoundingBox:kt,DraggableArea:Pt},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 Wt}},handlersClasses:{type:Object,default:function(){return{}}},handlersWrappersClasses:{type:Object,default:function