You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
77 KiB
21 lines
77 KiB
import{o as w,c as y,r as X,L as I,Q as S,w as B,F as At,W as Mt,X as nt,D as $t,E as It,m as jt,$ as ee,V as St}from"./index-3ef4d3eb.js";function xt(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable})),i.push.apply(i,o)}return i}function v(t){for(var e=1;e<arguments.length;e++){var i=arguments[e]!=null?arguments[e]:{};e%2?xt(Object(i),!0).forEach(function(o){C(t,o,i[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):xt(Object(i)).forEach(function(o){Object.defineProperty(t,o,Object.getOwnPropertyDescriptor(i,o))})}return t}function C(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function ie(t,e){if(t==null)return{};var i,o,s=function(a,h){if(a==null)return{};var r,c,l={},u=Object.keys(a);for(c=0;c<u.length;c++)r=u[c],h.indexOf(r)>=0||(l[r]=a[r]);return l}(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(o=0;o<n.length;o++)i=n[o],e.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(t,i)&&(s[i]=t[i])}return s}function k(t){return function(e){if(Array.isArray(e))return at(e)}(t)||function(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}(t)||function(e,i){if(e){if(typeof e=="string")return at(e,i);var o=Object.prototype.toString.call(e).slice(8,-1);if(o==="Object"&&e.constructor&&(o=e.constructor.name),o==="Map"||o==="Set")return Array.from(e);if(o==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return at(e,i)}}(t)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function at(t,e){(e==null||e>t.length)&&(e=t.length);for(var i=0,o=new Array(e);i<e;i++)o[i]=t[i];return o}var Et,ne,Q,z=(Et=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 o=[],s=0;s<arguments.length;s++){var n=arguments[s];if(n){var a=typeof n;if(a==="string"||a==="number")o.push(n);else if(Array.isArray(n)){if(n.length){var h=i.apply(null,n);h&&o.push(h)}}else if(a==="object")if(n.toString===Object.prototype.toString)for(var r in n)e.call(n,r)&&n[r]&&o.push(r);else o.push(n.toString())}}return o.join(" ")}t.exports?(i.default=i,t.exports=i):window.classNames=i})()},Et(Q={path:ne,exports:{},require:function(t,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(e==null&&Q.path)}},Q.exports),Q.exports),W=function(t){return function(e,i){if(!e)return t;var o;typeof e=="string"?o=e:i=e;var s=t;return o&&(s+="__"+o),s+(i?Object.keys(i).reduce(function(n,a){var h=i[a];return h&&(n+=" "+(typeof h=="boolean"?s+"--"+a:s+"--"+a+"_"+h)),n},""):"")}};function mt(t,e,i){var o,s,n,a,h;function r(){var l=Date.now()-a;l<e&&l>=0?o=setTimeout(r,e-l):(o=null,i||(h=t.apply(n,s),n=s=null))}e==null&&(e=100);var c=function(){n=this,s=arguments,a=Date.now();var l=i&&!o;return o||(o=setTimeout(r,e)),l&&(h=t.apply(n,s),n=s=null),h};return c.clear=function(){o&&(clearTimeout(o),o=null)},c.flush=function(){o&&(h=t.apply(n,s),n=s=null,clearTimeout(o),o=null)},c}mt.debounce=mt;var gt=mt,g=function(){return g=Object.assign||function(t){for(var e,i=1,o=arguments.length;i<o;i++)for(var s in e=arguments[i])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);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 Bt(t,e){var i,o;return t&&e?(i=""+t+e[0].toUpperCase()+e.slice(1),o=t+"-"+e):(i=t||e,o=t||e),{name:i,classname:o}}function kt(t){return/^blob:/.test(t)}function Ct(t){return kt(t)||function(e){return/^data:/.test(e)}(t)}function Y(t){return!!(t&&t.constructor&&t.call&&t.apply)}function R(t){return t===void 0}function it(t){return typeof t=="object"&&t!==null}function ft(t,e,i){var o={};return it(t)?(Object.keys(e).forEach(function(s){R(t[s])?o[s]=e[s]:it(e[s])?it(t[s])?o[s]=ft(t[s],e[s],i[s]):o[s]=t[s]?e[s]:i[s]:e[s]===!0||e[s]===!1?o[s]=!!t[s]:o[s]=t[s]}),o):t?e:i}function K(t){var e=Number(t);return Number.isNaN(e)?t:e}function Tt(t){return typeof(t=="number"||function(e){return typeof e=="object"&&e!==null}(t)&&toString.call(t)=="[object Number]")&&!Xt(t)}function Xt(t){return t!=t}function Yt(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}var q=function(t,e){t===void 0&&(t={}),e===void 0&&(e={}),this.type="manipulateImage",this.move=t,this.scale=e},oe=function(t,e){e===void 0&&(e={}),this.type="resize",this.directions=t,this.params=e},wt=function(t){this.type="move",this.directions=t},se=function(){function t(e,i,o,s,n){this.type="drag",this.nativeEvent=e,this.position=o,this.previousPosition=s,this.element=i,this.anchor=n}return t.prototype.shift=function(){var e=this,i=e.element,o=e.anchor,s=e.position;if(i){var n=i.getBoundingClientRect(),a=n.left,h=n.top;return{left:s.left-a-o.left,top:s.top-h-o.top}}return{left:0,top:0}},t}(),yt={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&&t.touches.length===1&&(this.touches=k(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,o=e.right,s=e.bottom,n=e.top;this.anchor={left:t.clientX-i,top:t.clientY-n,bottom:s-t.clientY,right:o-t.clientX}},processMove:function(t,e){var i=k(e);if(this.touches.length){if(this.touches.length===1&&i.length===1){var o=this.$refs.draggable;this.$emit("drag",new se(t,o,{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"]};yt.render=function(t,e,i,o,s,n){return w(),y("div",{ref:"draggable",class:i.classname,onTouchstart:e[1]||(e[1]=function(){return n.onTouchStart&&n.onTouchStart.apply(n,arguments)}),onMousedown:e[2]||(e[2]=function(){return n.onMouseDown&&n.onMouseDown.apply(n,arguments)}),onMouseover:e[3]||(e[3]=function(){return n.onMouseOver&&n.onMouseOver.apply(n,arguments)}),onMouseleave:e[4]||(e[4]=function(){return n.onMouseLeave&&n.onMouseLeave.apply(n,arguments)})},[X(t.$slots,"default")],34)};var ht=W("vue-handler-wrapper"),Ft={name:"HandlerWrapper",components:{DraggableElement:yt},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=Bt(this.horizontalPosition,this.verticalPosition);t=ht((C(e={},i.classname,!0),C(e,"disabled",this.disabled),e))}else t=ht({disabled:this.disabled});return{root:t,draggable:ht("draggable")}}},emits:["leave","enter","drag","drag-end"]};Ft.render=function(t,e,i,o,s,n){var a=I("DraggableElement");return w(),y("div",{class:n.classes.root},[S(a,{class:n.classes.draggable,onDrag:e[1]||(e[1]=function(h){return t.$emit("drag",h)}),onDragEnd:e[2]||(e[2]=function(h){return t.$emit("drag-end")}),onLeave:e[3]||(e[3]=function(h){return t.$emit("leave")}),onEnter:e[4]||(e[4]=function(h){return t.$emit("enter")})},{default:B(function(){return[X(t.$slots,"default")]}),_:3},8,["class"])],2)};var re=W("vue-line-wrapper"),Ut={name:"LineWrapper",components:{DraggableElement:yt},props:{position:{type:String,required:!0},disabled:{type:Boolean,default:!1}},computed:{classname:function(){var t;return re((C(t={},this.position,!0),C(t,"disabled",this.disabled),t))}},emits:["leave","enter","drag","drag-end"]};Ut.render=function(t,e,i,o,s,n){var a=I("DraggableElement");return w(),y(a,{class:n.classname,onDrag:e[1]||(e[1]=function(h){return t.$emit("drag",h)}),onDragEnd:e[2]||(e[2]=function(h){return t.$emit("drag-end")}),onLeave:e[3]||(e[3]=function(h){return t.$emit("leave")}),onEnter:e[4]||(e[4]=function(h){return t.$emit("enter")})},{default:B(function(){return[X(t.$slots,"default")]}),_:3},8,["class"])};var O=["left","right","top","bottom"],ae=["left","right"],he=["top","bottom"],ce=["left","top"],le=["fill-area","fit-area","stencil","none"],Wt={left:0,top:0,width:0,height:0};function Dt(t,e,i){return!(i=i||["width","height","left","top"]).some(function(o){return t[o]!==e[o]})}function H(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 A(t){return{left:t.left+t.width/2,top:t.top+t.height/2}}function _(t,e){var i={left:0,top:0,right:0,bottom:0};return O.forEach(function(o){var s=e[o],n=H(t)[o];i[o]=s!==void 0&&n!==void 0?o==="left"||o==="top"?Math.max(0,s-n):Math.max(0,n-s):0}),i}function D(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 ot(t){return{left:-t.left,top:-t.top}}function x(t,e){return g(g({},t),{left:t.left+e.left,top:t.top+e.top})}function T(t,e,i,o){if(e!==1){if(i){var s=A(t);return{width:t.width*e,height:t.height*e,left:t.left+t.width*(1-e)/2+(i.left-s.left)*(o||1-e),top:t.top+t.height*(1-e)/2+(i.top-s.top)*(o||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 b(t){return t.width/t.height}function U(t,e){return Math.min(e.right!==void 0&&e.left!==void 0?(e.right-e.left)/t.width:1/0,e.bottom!==void 0&&e.top!==void 0?(e.bottom-e.top)/t.height:1/0)}function N(t,e){var i={left:0,top:0},o=_(t,e);return o.left&&o.left>0?i.left=o.left:o.right&&o.right>0&&(i.left=-o.right),o.top&&o.top>0?i.top=o.top:o.bottom&&o.bottom>0&&(i.top=-o.bottom),i}function ct(t,e){var i;return e.minimum&&t<e.minimum?i=e.minimum:e.maximum&&t>e.maximum&&(i=e.maximum),i}function Nt(t,e){var i=b(t),o=b(e);return e.width<1/0&&e.height<1/0?i>o?{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 Vt(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 j(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 st(t,e){var i=_(M(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,U(t,e)):Math.min((t.height+i.top+i.bottom)/t.height,U(t,e)):1}function M(t,e,i){i===void 0&&(i=!1);var o=N(t,e);return x(t,i?ot(o):o)}function pt(t){return{width:t.right!==void 0&&t.left!==void 0?t.right-t.left:1/0,height:t.bottom!==void 0&&t.top!==void 0?t.bottom-t.top:1/0}}function ue(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 Zt(t,e,i){i===void 0&&(i=!0);var o={};return O.forEach(function(s){var n=t[s],a=e[s];n!==void 0&&a!==void 0?o[s]=s==="left"||s==="top"?i?Math.max(n,a):Math.min(n,a):i?Math.min(n,a):Math.max(n,a):a!==void 0?o[s]=a:n!==void 0&&(o[s]=n)}),o}function rt(t,e){return Zt(t,e,!0)}function Ot(t){var e=t.size,i=t.aspectRatio,o=t.ignoreMinimum,s=t.sizeRestrictions;return!!((e.correctRatio||b(e)>=i.minimum&&b(e)<=i.maximum)&&e.height<=s.maxHeight&&e.width<=s.maxWidth&&e.width&&e.height&&(o||e.height>=s.minHeight&&e.width>=s.minWidth))}function Ht(t,e){return Math.pow(t.width-e.width,2)+Math.pow(t.height-e.height,2)}function $(t){var e=t.width,i=t.height,o=t.sizeRestrictions,s={minimum:t.aspectRatio&&t.aspectRatio.minimum||0,maximum:t.aspectRatio&&t.aspectRatio.maximum||1/0},n={width:Math.max(o.minWidth,Math.min(o.maxWidth,e)),height:Math.max(o.minHeight,Math.min(o.maxHeight,i))};function a(c,l){return l===void 0&&(l=!1),c.reduce(function(u,d){return Ot({size:d,aspectRatio:s,sizeRestrictions:o,ignoreMinimum:l})&&(!u||Ht(d,{width:e,height:i})<Ht(u,{width:e,height:i}))?d:u},null)}var h=[];s&&[s.minimum,s.maximum].forEach(function(c){c&&h.push({width:n.width,height:n.width/c,correctRatio:!0},{width:n.height*c,height:n.height,correctRatio:!0})}),Ot({size:n,aspectRatio:s,sizeRestrictions:o})&&h.push(n);var r=a(h)||a(h,!0);return r&&{width:r.width,height:r.height}}function vt(t){var e=t.event,i=t.coordinates,o=t.positionRestrictions,s=o===void 0?{}:o,n=x(i,e.directions);return x(n,N(n,s))}function de(t){var e=t.coordinates,i=t.transform,o=t.imageSize,s=t.sizeRestrictions,n=t.positionRestrictions,a=t.aspectRatio,h=t.visibleArea,r=function(l,u){return vt({coordinates:l,positionRestrictions:n,event:new wt({left:u.left-l.left,top:u.top-l.top})})},c=g({},e);return(Array.isArray(i)?i:[i]).forEach(function(l){var u={};R((u=typeof l=="function"?l({coordinates:c,imageSize:o,visibleArea:h}):l).width)&&R(u.height)||(c=function(d,m){var f=g(g(g({},d),$({width:m.width,height:m.height,sizeRestrictions:s,aspectRatio:a})),{left:0,top:0});return r(f,{left:d.left,top:d.top})}(c,g(g({},c),u))),R(u.left)&&R(u.top)||(c=r(c,g(g({},c),u)))}),c}function me(t){t.event;var e=t.getAreaRestrictions,i=t.boundaries,o=t.coordinates,s=t.visibleArea;t.aspectRatio;var n=t.stencilSize,a=t.sizeRestrictions,h=t.positionRestrictions;t.stencilReference;var r,c,l,u=g({},o),d=g({},s),m=g({},n);r=b(m),c=b(u),l===void 0&&(l=.001),(r===0||c===0?Math.abs(c-r)<l:Math.abs(c/r)<1+l&&Math.abs(c/r)>1-l)||(u=g(g({},u),$({sizeRestrictions:a,width:u.width,height:u.height,aspectRatio:{minimum:b(m),maximum:b(m)}})));var f=st(d=T(d,u.width*i.width/(d.width*m.width)),e({visibleArea:d,type:"resize"}));return f!==1&&(d=T(d,f),u=T(u,f)),d=M(d=x(d,F(A(u),A(d))),e({visibleArea:d,type:"move"})),{coordinates:u=M(u,rt(H(d),h)),visibleArea:d}}function ge(t){var e=t.event,i=t.getAreaRestrictions,o=t.boundaries,s=t.coordinates,n=t.visibleArea;t.aspectRatio,t.stencilSize,t.sizeRestrictions;var a=t.positionRestrictions;t.stencilReference;var h=g({},s),r=g({},n);if(s&&n&&e.type!=="manipulateImage"){var c={width:0,height:0};r.width,o.width,b(o)>b(h)?(c.height=.8*o.height,c.width=c.height*b(h)):(c.width=.8*o.width,c.height=c.width*b(h));var l=st(r=T(r,h.width*o.width/(r.width*c.width)),i({visibleArea:r,type:"resize"}));r=T(r,l),l!==1&&(c.height/=l,c.width/=l),r=M(r=x(r,F(A(h),A(r))),i({visibleArea:r,type:"move"})),h=M(h,rt(H(r),a))}return{coordinates:h,visibleArea:r}}function fe(t){var e=t.event,i=t.coordinates,o=t.visibleArea,s=t.getAreaRestrictions,n=g({},o),a=g({},i);if(e.type==="setCoordinates"){var h=Math.max(0,a.width-n.width),r=Math.max(0,a.height-n.height);h>r?n=T(n,Math.min(a.width/n.width,U(n,s({visibleArea:n,type:"resize"})))):r>h&&(n=T(n,Math.min(a.height/n.height,U(n,s({visibleArea:n,type:"resize"}))))),n=M(n=x(n,ot(N(a,H(n)))),s({visibleArea:n,type:"move"}))}return{visibleArea:n,coordinates:a}}function pe(t){var e=t.imageSize,i=t.visibleArea,o=t.coordinates,s=i||e;return{left:(i?i.left:0)+s.width/2-o.width/2,top:(i?i.top:0)+s.height/2-o.height/2}}function ve(t){var e=t.imageSize,i=t.visibleArea,o=t.aspectRatio,s=t.sizeRestrictions,n=i||e,a=Math.min(o.maximum||1/0,Math.max(o.minimum||0,b(n))),h=n.width<n.height?{width:.8*n.width,height:.8*n.width/a}:{height:.8*n.height,width:.8*n.height*a};return $(g(g({},h),{aspectRatio:o,sizeRestrictions:s}))}function be(t){var e,i,o=t.imageSize,s=t.visibleArea,n=t.boundaries,a=t.aspectRatio,h=t.sizeRestrictions,r=t.stencilSize,c=s||o;return b(c)>b(n)?i=(e=r.height*c.height/n.height)*b(r):e=(i=r.width*c.width/n.width)/b(r),$({width:i,height:e,aspectRatio:a,sizeRestrictions:h})}function we(t){var e=t.getAreaRestrictions,i=t.coordinates,o=t.imageSize,s=b(t.boundaries);if(i){var n={height:Math.max(i.height,o.height),width:Math.max(i.width,o.width)},a=Nt({width:b(n)>s?n.width:n.height*s,height:b(n)>s?n.width/s:n.height},pt(e())),h={left:i.left+i.width/2-a.width/2,top:i.top+i.height/2-a.height/2,width:a.width,height:a.height},r=_(i,H(g({left:0,top:0},o))),c={};return!r.left&&!r.right&&h.width<=o.width&&(c.left=0,c.right=o.width),!r.top&&!r.bottom&&h.height<=o.height&&(c.top=0,c.bottom=o.height),M(h,c)}var l=b(o);return a={height:l>s?o.height:o.width/s,width:l>s?o.height*s:o.width},{left:o.width/2-a.width/2,top:o.height/2-a.height/2,width:a.width,height:a.height}}function J(t,e){return Zt(t,H(e))}function ye(t){var e=t.event,i=t.coordinates,o=t.visibleArea,s=t.sizeRestrictions,n=t.getAreaRestrictions,a=t.positionRestrictions,h=t.adjustStencil,r=e.scale,c=e.move,l=g({},o),u=g({},i),d=1,m=1,f=r.factor&&Math.abs(r.factor-1)>.001;l=x(l,{left:c.left||0,top:c.top||0});var p={stencil:{minimum:Math.max(s.minWidth?s.minWidth/u.width:0,s.minHeight?s.minHeight/u.height:0),maximum:Math.min(s.maxWidth?s.maxWidth/u.width:1/0,s.maxHeight?s.maxHeight/u.height:1/0,U(u,a))},area:{maximum:U(l,n({visibleArea:l,type:"resize"}))}};r.factor&&f&&(r.factor<1?(m=Math.max(r.factor,p.stencil.minimum))>1&&(m=1):r.factor>1&&(m=Math.min(r.factor,Math.min(p.area.maximum,p.stencil.maximum)))<1&&(m=1)),m&&(l=T(l,m,r.center));var E=i.left-o.left,L=o.width+o.left-(i.width+i.left),V=i.top-o.top,G=o.height+o.top-(i.height+i.top);return l=M(l=x(l,N(l,{left:a.left!==void 0?a.left-E*m:void 0,top:a.top!==void 0?a.top-V*m:void 0,bottom:a.bottom!==void 0?a.bottom+G*m:void 0,right:a.right!==void 0?a.right+L*m:void 0})),n({visibleArea:l,type:"move"})),u.width=u.width*m,u.height=u.height*m,u.left=l.left+E*m,u.top=l.top+V*m,u=M(u,rt(H(l),a)),r.factor&&f&&h&&(r.factor>1?d=Math.min(p.area.maximum,r.factor)/m:r.factor<1&&(d=Math.max(u.height/l.height,u.width/l.width,r.factor/m)),d!==1&&(l=x(l=M(l=T(l,d,r.factor>1?r.center:A(u)),n({visibleArea:l,type:"move"})),ot(N(u,H(l)))))),{coordinates:u,visibleArea:l}}function ze(t){var e=t.aspectRatio,i=t.getAreaRestrictions,o=t.coordinates,s=t.visibleArea,n=t.sizeRestrictions,a=t.positionRestrictions,h=t.imageSize,r=t.previousImageSize,c=t.angle,l=g({},o),u=g({},s),d=j(A(g({left:0,top:0},r)),c);return(l=g(g({},$({sizeRestrictions:n,aspectRatio:e,width:l.width,height:l.height})),j(A(l),c))).left-=d.left-h.width/2+l.width/2,l.top-=d.top-h.height/2+l.height/2,u=T(u,st(u,i({visibleArea:u,type:"resize"}))),{coordinates:l=M(l,a),visibleArea:u=M(u=x(u,F(A(l),A(o))),i({visibleArea:u,type:"move"}))}}function Re(t){var e=t.flip,i=t.previousFlip,o=t.rotate;t.aspectRatio;var s=t.getAreaRestrictions,n=t.coordinates,a=t.visibleArea,h=t.imageSize,r=g({},n),c=g({},a),l=i.horizontal!==e.horizontal,u=i.vertical!==e.vertical;if(l||u){var d=j({left:h.width/2,top:h.height/2},-o),m=j(A(r),-o),f=j({left:l?d.left-(m.left-d.left):m.left,top:u?d.top-(m.top-d.top):m.top},o);r=x(r,F(f,A(r))),m=j(A(c),-o),c=M(c=x(c,F(f=j({left:l?d.left-(m.left-d.left):m.left,top:u?d.top-(m.top-d.top):m.top},o),A(c))),s({visibleArea:c,type:"move"}))}return{coordinates:r,visibleArea:c}}function Lt(t){var e=t.directions,i=t.coordinates,o=t.positionRestrictions,s=o===void 0?{}:o,n=t.sizeRestrictions,a=t.preserveRatio,h=t.compensate,r=g({},e),c=D(i,r).width,l=D(i,r).height;c<0&&(r.left<0&&r.right<0?(r.left=-(i.width-n.minWidth)/(r.left/r.right),r.right=-(i.width-n.minWidth)/(r.right/r.left)):r.left<0?r.left=-(i.width-n.minWidth):r.right<0&&(r.right=-(i.width-n.minWidth))),l<0&&(r.top<0&&r.bottom<0?(r.top=-(i.height-n.minHeight)/(r.top/r.bottom),r.bottom=-(i.height-n.minHeight)/(r.bottom/r.top)):r.top<0?r.top=-(i.height-n.minHeight):r.bottom<0&&(r.bottom=-(i.height-n.minHeight)));var u=_(D(i,r),s);h&&(u.left&&u.left>0&&u.right===0?(r.right+=u.left,r.left-=u.left):u.right&&u.right>0&&u.left===0&&(r.left+=u.right,r.right-=u.right),u.top&&u.top>0&&u.bottom===0?(r.bottom+=u.top,r.top-=u.top):u.bottom&&u.bottom>0&&u.top===0&&(r.top+=u.bottom,r.bottom-=u.bottom),u=_(D(i,r),s));var d={width:1/0,height:1/0,left:1/0,right:1/0,top:1/0,bottom:1/0};if(O.forEach(function(p){var E=u[p];E&&r[p]&&(d[p]=Math.max(0,1-E/r[p]))}),a){var m=Math.min.apply(null,O.map(function(p){return d[p]}));m!==1/0&&O.forEach(function(p){r[p]*=m})}else O.forEach(function(p){d[p]!==1/0&&(r[p]*=d[p])});if(c=D(i,r).width,l=D(i,r).height,r.right+r.left&&(c>n.maxWidth?d.width=(n.maxWidth-i.width)/(r.right+r.left):c<n.minWidth&&(d.width=(n.minWidth-i.width)/(r.right+r.left))),r.bottom+r.top&&(l>n.maxHeight?d.height=(n.maxHeight-i.height)/(r.bottom+r.top):l<n.minHeight&&(d.height=(n.minHeight-i.height)/(r.bottom+r.top))),a){var f=Math.min(d.width,d.height);f!==1/0&&O.forEach(function(p){r[p]*=f})}else d.width!==1/0&&ae.forEach(function(p){r[p]*=d.width}),d.height!==1/0&&he.forEach(function(p){r[p]*=d.height});return r}function tt(t,e,i){return e==0&&i==0?t/2:e==0?0:i==0?t:t*Math.abs(e/(e+i))}var Ae=W("vue-simple-handler"),Me=W("vue-simple-handler-wrapper"),zt={name:"SimpleHandler",components:{HandlerWrapper:Ft},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=(C(t={},this.horizontalPosition,!!this.horizontalPosition),C(t,this.verticalPosition,!!this.verticalPosition),C(t,"".concat(this.horizontalPosition,"-").concat(this.verticalPosition),!!(this.verticalPosition&&this.horizontalPosition)),C(t,"hover",this.hover),t);return{default:z(Ae(e),this.defaultClass,this.hover&&this.hoverClass),wrapper:z(Me(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"]};zt.render=function(t,e,i,o,s,n){var a=I("HandlerWrapper");return w(),y(a,{class:n.classes.wrapper,"vertical-position":i.verticalPosition,"horizontal-position":i.horizontalPosition,disabled:i.disabled,onDrag:n.onDrag,onDragEnd:n.onDragEnd,onEnter:n.onEnter,onLeave:n.onLeave},{default:B(function(){return[S("div",{class:n.classes.default},null,2)]}),_:1},8,["class","vertical-position","horizontal-position","disabled","onDrag","onDragEnd","onEnter","onLeave"])};var Se=W("vue-simple-line"),xe=W("vue-simple-line-wrapper"),Rt={name:"SimpleLine",components:{LineWrapper:Ut},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:z(Se(C({},this.position,!0)),this.defaultClass,this.hover&&this.hoverClass),wrapper:z(xe(C({},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"]};Rt.render=function(t,e,i,o,s,n){var a=I("LineWrapper");return w(),y(a,{class:n.classes.wrapper,position:i.position,disabled:i.disabled,onDrag:n.onDrag,onDragEnd:n.onDragEnd,onEnter:n.onEnter,onLeave:n.onLeave},{default:B(function(){return[S("div",{class:n.classes.root},null,2)]}),_:1},8,["class","position","disabled","onDrag","onDragEnd","onEnter","onLeave"])};var lt=W("vue-bounding-box"),Ee=["east","west",null],Ce=["south","north",null],qt={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 zt}},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 Rt}},linesClasses:{type:Object,default:function(){return{}}},linesWrappersClasses:{type:Object,default:function(){return{}}},resizable:{type:Boolean,default:!0}},data:function(){var t=[];return Ee.forEach(function(e){Ce.forEach(function(i){if(e!==i){var o=Bt(e,i),s=o.name,n=o.classname;t.push({name:s,classname:n,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,o=this.linesWrappersClasses;return{root:lt(),handlers:t,handlersWrappers:e,lines:i,linesWrappers:o}},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:z(t.classes.lines.default,t.classes.lines[i.name],!t.resizable&&t.classes.lines.disabled),wrapperClass:z(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 n={name:s.name,component:t.handlersComponent,class:z(t.classes.handlers.default,t.classes.handlers[s.name]),wrapperClass:z(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,r=a==="east"?i:a==="west"?0:i/2,c=h==="south"?o:h==="north"?0:o/2;n.wrapperClass=lt("handler"),n.wrapperStyle={transform:"translate(".concat(r,"px, ").concat(c,"px)")},t.transitions&&t.transitions.enabled&&(n.wrapperStyle.transition="".concat(t.transitions.time,"ms ").concat(t.transitions.timingFunction))}else n.wrapperClass=lt("handler",C({},s.classname,!0));e.push(n)}}),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 o,s=t.shift(),n=s.left,a=s.top,h={left:0,right:0,top:0,bottom:0};e==="west"?h.left-=n:e==="east"&&(h.right+=n),i==="north"?h.top-=a:i==="south"&&(h.bottom+=a),!i&&e?o="width":i&&!e&&(o="height"),this.resizable&&this.$emit("resize",new oe(h,{allowedDirections:{left:e==="west"||!e,right:e==="east"||!e,bottom:i==="south"||!i,top:i==="north"||!i},preserveAspectRatio:t.nativeEvent&&t.nativeEvent.shiftKey,respectDirection:o}))}},emits:["resize","resize-end"]};qt.render=function(t,e,i,o,s,n){return w(),y("div",{ref:"box",class:n.classes.root,style:n.style},[X(t.$slots,"default"),S("div",null,[(w(!0),y(At,null,Mt(n.lineNodes,function(a){return w(),y(nt(a.component),{key:a.name,"default-class":a.class,"hover-class":a.hoverClass,"wrapper-class":a.wrapperClass,position:a.name,disabled:a.disabled,onDrag:function(h){return n.onHandlerDrag(h,a.horizontalDirection,a.verticalDirection)},onDragEnd:e[1]||(e[1]=function(h){return n.onEnd()})},null,8,["default-class","hover-class","wrapper-class","position","disabled","onDrag"])}),128))]),(w(!0),y(At,null,Mt(n.handlerNodes,function(a){return w(),y("div",{key:a.name,style:a.wrapperStyle,class:a.wrapperClass},[(w(),y(nt(a.component),{"default-class":a.class,"hover-class":a.hoverClass,"wrapper-class":a.wrapperClass,"horizontal-position":a.horizontalDirection,"vertical-position":a.verticalDirection,disabled:a.disabled,onDrag:function(h){return n.onHandlerDrag(h,a.horizontalDirection,a.verticalDirection)},onDragEnd:e[2]||(e[2]=function(h){return n.onEnd()})},null,8,["default-class","hover-class","wrapper-class","horizontal-position","vertical-position","disabled","onDrag"]))],6)}),128))],6)};var Te=W("vue-draggable-area"),_t={name:"DraggableArea",props:{movable:{type:Boolean,default:!0},activationDistance:{type:Number,default:20}},computed:{classnames:function(){return{default:Te()}}},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&&t.touches.length===1;e&&(this.touches=k(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()):Yt({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&&t.button===0){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,o=e.top;this.anchor={x:t.clientX-i,y:t.clientY-o}},processMove:function(t,e){var i=k(e);if(this.touches.length){var o=this.$refs.container.getBoundingClientRect(),s=o.left,n=o.top;this.touches.length===1&&i.length===1&&this.$emit("move",new wt({left:i[0].clientX-(s+this.anchor.x),top:i[0].clientY-(n+this.anchor.y)}))}},processEnd:function(){this.touches.length&&this.$emit("move-end"),this.touches=[]}},emits:["move","move-end"]};_t.render=function(t,e,i,o,s,n){return w(),y("div",{ref:"container",onTouchstart:e[1]||(e[1]=function(){return n.onTouchStart&&n.onTouchStart.apply(n,arguments)}),onMousedown:e[2]||(e[2]=function(){return n.onMouseDown&&n.onMouseDown.apply(n,arguments)})},[X(t.$slots,"default")],544)};function ut(t){var e,i;return{rotate:t.rotate||0,flip:{horizontal:((e=t==null?void 0:t.flip)===null||e===void 0?void 0:e.horizontal)||!1,vertical:((i=t==null?void 0:t.flip)===null||i===void 0?void 0:i.vertical)||!1}}}function We(t){return new Promise(function(e,i){try{if(t)if(/^data:/i.test(t))e(function(r){r=r.replace(/^data:([^;]+);base64,/gim,"");for(var c=atob(r),l=c.length,u=new ArrayBuffer(l),d=new Uint8Array(u),m=0;m<l;m++)d[m]=c.charCodeAt(m);return u}(t));else if(/^blob:/i.test(t)){var o=new FileReader;o.onload=function(r){e(r.target.result)},n=t,a=function(r){o.readAsArrayBuffer(r)},(h=new XMLHttpRequest).open("GET",n,!0),h.responseType="blob",h.onload=function(){this.status!=200&&this.status!==0||a(this.response)},h.send()}else{var s=new XMLHttpRequest;s.onreadystatechange=function(){s.readyState===4&&(s.status===200||s.status===0?e(s.response):i("Warning: could not load an image to parse its orientation"),s=null)},s.onprogress=function(){s.getResponseHeader("content-type")!=="image/jpeg"&&s.abort()},s.withCredentials=!1,s.open("GET",t,!0),s.responseType="arraybuffer",s.send(null)}else i("Error: the image is empty")}catch(r){i(r)}var n,a,h})}function Gt(t){var e=t.rotate,i=t.flip,o=t.scaleX,s=t.scaleY,n="";return n+=" rotate("+e+"deg) ",n+=" scaleX("+o*(i.horizontal?-1:1)+") ",n+=" scaleY("+s*(i.vertical?-1:1)+") "}function De(t){try{var e,i=new DataView(t),o=void 0,s=void 0,n=void 0,a=void 0;if(i.getUint8(0)===255&&i.getUint8(1)===216)for(var h=i.byteLength,r=2;r+1<h;){if(i.getUint8(r)===255&&i.getUint8(r+1)===225){n=r;break}r++}if(n&&(o=n+10,function(m,f,p){var E,L="";for(E=f,p+=f;E<p;E++)L+=String.fromCharCode(m.getUint8(E));return L}(i,n+4,4)==="Exif")){var c=i.getUint16(o);if(((s=c===18761)||c===19789)&&i.getUint16(o+2,s)===42){var l=i.getUint32(o+4,s);l>=8&&(a=o+l)}}if(a){for(var u=i.getUint16(a,s),d=0;d<u;d++)if(r=a+12*d+2,i.getUint16(r,s)===274){r+=8,e=i.getUint16(r,s),i.setUint16(r,1,s);break}}return e}catch{return null}}function Pt(t,e){var i=e.getBoundingClientRect(),o=i.left,s=i.top,n={left:0,top:0},a=0;return t.forEach(function(h){n.left+=(h.clientX-o)/t.length,n.top+=(h.clientY-s)/t.length}),t.forEach(function(h){a+=Yt({x:n.left,y:n.top},{x:h.clientX-o,y:h.clientY-s})}),{centerMass:n,spread:a,count:t.length}}var Qt={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=gt(this.processEnd),this.touches=[]},methods:{processMove:function(t,e){if(this.touches.length){if(this.touches.length===1&&e.length===1)this.$emit("move",new q({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=Pt(e,this.$refs.container),o=this.oldGeometricProperties;o.count===i.count&&o.count>1&&this.$emit("resize",new q({left:o.centerMass.left-i.centerMass.left,top:o.centerMass.top-i.centerMass.top},{factor:o.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?this.eventsFilter(t,this.transforming)!==!1:(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(),o=i.left,s=i.top,n=i.bottom,a=i.right;this.touches=k(t.touches).filter(function(h){return h.clientX>o&&h.clientX<a&&h.clientY>s&&h.clientY<n}),this.oldGeometricProperties=Pt(this.touches,e)}},onTouchEnd:function(t){t.touches.length===0&&(this.touches=[],this.processEnd())},onTouchMove:function(t){var e=this;if(this.touches.length){var i=k(t.touches).filter(function(o){return!o.identifier||e.touches.find(function(s){return s.identifier===o.identifier})});this.processEvent(t)&&(this.processMove(t,i),this.processStart())}},onMouseDown:function(t){if(this.mouseMove&&"buttons"in t&&t.buttons===1&&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,o=e.top,s=1+this.wheelResize.ratio*(a=t.deltaY||t.detail||t.wheelDelta,(h=+a)==0||Xt(h)?h:h>0?1:-1),n={left:t.clientX-i,top:t.clientY-o};this.$emit("resize",new q({},{factor:s,center:n})),this.touches.length||this.debouncedProcessEnd()}var a,h}},emits:["resize","move","transform-end"]};Qt.render=function(t,e,i,o,s,n){return w(),y("div",{ref:"container",onTouchstart:e[1]||(e[1]=function(){return n.onTouchStart&&n.onTouchStart.apply(n,arguments)}),onMousedown:e[2]||(e[2]=function(){return n.onMouseDown&&n.onMouseDown.apply(n,arguments)}),onWheel:e[3]||(e[3]=function(){return n.onWheel&&n.onWheel.apply(n,arguments)})},[X(t.$slots,"default")],544)};var bt={components:{TransformableImage:Qt},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"]};bt.render=function(t,e,i,o,s,n){var a=I("transformable-image");return w(),y(a,{"touch-move":i.touchMove,"touch-resize":i.touchResize,"mouse-move":i.mouseMove,"wheel-resize":i.wheelResize,onMove:e[1]||(e[1]=function(h){return t.$emit("move",h)}),onResize:e[2]||(e[2]=function(h){return t.$emit("resize",h)})},{default:B(function(){return[X(t.$slots,"default")]}),_:3},8,["touch-move","touch-resize","mouse-move","wheel-resize"])};var et=W("vue-preview"),Kt={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:et({fill:this.fill}),wrapper:et("wrapper"),imageWrapper:et("image-wrapper"),image:z(et("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=v(v({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=Vt({width:i,height:o},e.rotate),n={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 n.transform=`translate(
|
|
`.concat(-this.coordinates.left/t-a.rotate.left-a.scale.left,"px,").concat(-this.coordinates.top/t-a.rotate.top-a.scale.top,"px) ")+Gt(e),this.transitions&&this.transitions.enabled&&(n.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),n}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()}}};Kt.render=function(t,e,i,o,s,n){return w(),y("div",{ref:"root",class:n.classes.root,style:n.style},[S("div",{ref:"wrapper",class:n.classes.wrapper,style:n.wrapperStyle},[$t(S("img",{ref:"image",src:i.image&&i.image.src,class:n.classes.image,style:n.imageStyle},null,14,["src"]),[[It,i.image&&i.image.src]])],6)],6)};var Jt={components:{Preview:Kt},inheritAttrs:!1};Jt.render=function(t,e,i,o,s,n){var a=I("preview");return w(),y(a,jt(t.$attrs,{fill:!0}),null,16)};var dt=W("vue-rectangle-stencil"),te={name:"RectangleStencil",components:{StencilPreview:Jt,BoundingBox:qt,DraggableArea:_t},props:{image:{type:Object},coordinates:{type:Object},stencilCoordinates:{type:Object},handlers:{type:Object},handlersComponent:{type:[Object,String],default:function(){return zt}},lines:{type:Object},linesComponent:{type:[Object,String],default:function(){return Rt}},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:z(dt({movable:this.movable,moving:this.moving,resizing:this.resizing}),this.moving&&this.movingClass,this.resizing&&this.resizingClass),preview:z(dt("preview"),this.previewClass),boundingBox:z(dt("bounding-box"),this.boundingBoxClass)}},style:function(){var t=this.stencilCoordinates,e=t.height,i=t.width,o=t.left,s=t.top,n={width:"".concat(i,"px"),height:"".concat(e,"px"),transform:"translate(".concat(o,"px, ").concat(s,"px)")};return this.transitions&&this.transitions.enabled&&(n.transition="".concat(this.transitions.time,"ms ").concat(this.transitions.timingFunction)),n}},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"]};te.render=function(t,e,i,o,s,n){var a=I("stencil-preview"),h=I("draggable-area"),r=I("bounding-box");return w(),y("div",{class:n.classes.stencil,style:n.style},[S(r,{width:i.stencilCoordinates.width,height:i.stencilCoordinates.height,transitions:i.transitions,class:n.classes.boundingBox,handlers:i.handlers,"handlers-component":i.handlersComponent,"handlers-classes":i.handlersClasses,"handlers-wrappers-classes":i.handlersWrappersClasses,lines:i.lines,"lines-component":i.linesComponent,"lines-classes":i.linesClasses,"lines-wrappers-classes":i.linesWrappersClasses,resizable:i.resizable,onResize:n.onResize,onResizeEnd:n.onResizeEnd},{default:B(function(){return[S(h,{movable:i.movable,onMove:n.onMove,onMoveEnd:n.onMoveEnd},{default:B(function(){return[S(a,{image:i.image,coordinates:i.coordinates,width:i.stencilCoordinates.width,height:i.stencilCoordinates.height,class:n.classes.preview,transitions:i.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 Oe=["transitions"],P=W("vue-advanced-cropper"),He={name:"Cropper",components:{BackgroundWrapper:bt},props:{src:{type:String,default:null},stencilComponent:{type:[Object,String],default:function(){return te}},backgroundWrapperComponent:{type:[Object,String],default:function(){return bt}},stencilProps:{type:Object,default:function(){return{}}},autoZoom:{type:Boolean,default:!1},imageClass:{type:String},boundariesClass:{type:String},backgroundClass:{type:String},foregroundClass:{type:String},minWidth:{type:[Number,String]},minHeight:{type:[Number,String]},maxWidth:{type:[Number,String]},maxHeight:{type:[Number,String]},debounce:{type:[Boolean,Number],default:500},transitions:{type:Boolean,default:!0},checkOrientation:{type:Boolean,default:!0},canvas:{type:[Object,Boolean],default:!0},crossOrigin:{type:[Boolean,String],default:void 0},transitionTime:{type:Number,default:300},imageRestriction:{type:String,default:"fit-area",validator:function(t){return le.indexOf(t)!==-1}},roundResult:{type:Boolean,default:!0},defaultSize:{type:[Function,Object]},defaultPosition:{type:[Function,Object]},defaultVisibleArea:{type:[Function,Object]},defaultTransforms:{type:[Function,Object]},defaultBoundaries:{type:[Function,String],validator:function(t){return!(typeof t=="string"&&t!=="fill"&&t!=="fit")}},priority:{type:String,default:"coordinates"},stencilSize:{type:[Object,Function]},resizeImage:{type:[Boolean,Object],default:!0},moveImage:{type:[Boolean,Object],default:!0},autoZoomAlgorithm:{type:Function},resizeAlgorithm:{type:Function,default:function(t){var e=t.event,i=t.coordinates,o=t.aspectRatio,s=t.positionRestrictions,n=t.sizeRestrictions,a=g(g({},i),{right:i.left+i.width,bottom:i.top+i.height}),h=e.params||{},r=g({},e.directions),c=h.allowedDirections||{left:!0,right:!0,bottom:!0,top:!0};n.widthFrozen&&(r.left=0,r.right=0),n.heightFrozen&&(r.top=0,r.bottom=0),O.forEach(function(Z){c[Z]||(r[Z]=0)});var l=D(a,r=Lt({coordinates:a,directions:r,sizeRestrictions:n,positionRestrictions:s})).width,u=D(a,r).height,d=h.preserveRatio?b(a):ct(l/u,o);if(d){var m=h.respectDirection;if(m||(m=a.width>=a.height||d===1?"width":"height"),m==="width"){var f=l/d-a.height;if(c.top&&c.bottom){var p=r.top,E=r.bottom;r.bottom=tt(f,E,p),r.top=tt(f,p,E)}else c.bottom?r.bottom=f:c.top?r.top=f:c.right?r.right=0:c.left&&(r.left=0)}else if(m==="height"){var L=a.width-u*d;if(c.left&&c.right){var V=r.left,G=r.right;r.left=-tt(L,V,G),r.right=-tt(L,G,V)}else c.left?r.left=-L:c.right?r.right=-L:c.top?r.top=0:c.bottom&&(r.bottom=0)}r=Lt({directions:r,coordinates:a,sizeRestrictions:n,positionRestrictions:s,preserveRatio:!0,compensate:h.compensate})}return l=D(a,r).width,u=D(a,r).height,(d=h.preserveRatio?b(a):ct(l/u,o))&&Math.abs(d-l/u)>.001&&O.forEach(function(Z){c[Z]||(r[Z]=0)}),vt({event:new wt({left:-r.left,top:-r.top}),coordinates:{width:i.width+r.right+r.left,height:i.height+r.top+r.bottom,left:i.left,top:i.top},positionRestrictions:s})}},moveAlgorithm:{type:Function,default:vt},initStretcher:{type:Function,default:function(t){var e=t.stretcher,i=t.imageSize,o=b(i);e.style.width=i.width+"px",e.style.height=e.clientWidth/o+"px",e.style.width=e.clientWidth+"px"}},fitCoordinates:{type:Function,default:function(t){var e=t.visibleArea,i=t.coordinates,o=t.aspectRatio,s=t.sizeRestrictions,n=t.positionRestrictions,a=g(g({},i),$({width:i.width,height:i.height,aspectRatio:o,sizeRestrictions:{maxWidth:e.width,maxHeight:e.height,minHeight:Math.min(e.height,s.minHeight),minWidth:Math.min(e.width,s.minWidth)}}));return a=M(a=x(a,F(A(i),A(a))),rt(H(e),n))}},fitVisibleArea:{type:Function,default:function(t){var e=t.visibleArea,i=t.boundaries,o=t.getAreaRestrictions,s=t.coordinates,n=g({},e);n.height=n.width/b(i),n.top+=(e.height-n.height)/2,(s.height-n.height>0||s.width-n.width>0)&&(n=T(n,Math.max(s.height/n.height,s.width/n.width)));var a=ot(N(s,H(n=T(n,st(n,o({visibleArea:n,type:"resize"}))))));return n.width<s.width&&(a.left=0),n.height<s.height&&(a.top=0),n=M(n=x(n,a),o({visibleArea:n,type:"move"}))}},areaRestrictionsAlgorithm:{type:Function,default:function(t){var e=t.visibleArea,i=t.boundaries,o=t.imageSize,s=t.imageRestriction,n=t.type,a={};return s==="fill-area"?a={left:0,top:0,right:o.width,bottom:o.height}:s==="fit-area"&&(b(i)>b(o)?(a={top:0,bottom:o.height},e&&n==="move"&&(e.width>o.width?(a.left=-(e.width-o.width)/2,a.right=o.width-a.left):(a.left=0,a.right=o.width))):(a={left:0,right:o.width},e&&n==="move"&&(e.height>o.height?(a.top=-(e.height-o.height)/2,a.bottom=o.height-a.top):(a.top=0,a.bottom=o.height)))),a}},sizeRestrictionsAlgorithm:{type:Function,default:function(t){return{minWidth:t.minWidth,minHeight:t.minHeight,maxWidth:t.maxWidth,maxHeight:t.maxHeight}}},positionRestrictionsAlgorithm:{type:Function,default:function(t){var e=t.imageSize,i={};return t.imageRestriction!=="none"&&(i={left:0,top:0,right:e.width,bottom:e.height}),i}}},data:function(){return{transitionsActive:!1,imageLoaded:!1,imageAttributes:{width:null,height:null,crossOrigin:null,src:null},defaultImageTransforms:{rotate:0,flip:{horizontal:!1,vertical:!1}},appliedImageTransforms:{rotate:0,flip:{horizontal:!1,vertical:!1}},boundaries:{width:0,height:0},visibleArea:null,coordinates:v({},Wt)}},computed:{image:function(){return{src:this.imageAttributes.src,width:this.imageAttributes.width,height:this.imageAttributes.height,transforms:this.imageTransforms}},imageTransforms:function(){return{rotate:this.appliedImageTransforms.rotate,flip:{horizontal:this.appliedImageTransforms.flip.horizontal,vertical:this.appliedImageTransforms.flip.vertical},translateX:this.visibleArea?this.visibleArea.left/this.coefficient:0,translateY:this.visibleArea?this.visibleArea.top/this.coefficient:0,scaleX:1/this.coefficient,scaleY:1/this.coefficient}},imageSize:function(){var t=function(e){return e*Math.PI/180}(this.imageTransforms.rotate);return{width:Math.abs(this.imageAttributes.width*Math.cos(t))+Math.abs(this.imageAttributes.height*Math.sin(t)),height:Math.abs(this.imageAttributes.width*Math.sin(t))+Math.abs(this.imageAttributes.height*Math.cos(t))}},initialized:function(){return!!(this.visibleArea&&this.imageLoaded)},settings:function(){var t=ft(this.resizeImage,{touch:!0,wheel:{ratio:.1},adjustStencil:!0},{touch:!1,wheel:!1,adjustStencil:!1});return{moveImage:ft(this.moveImage,{touch:!0,mouse:!0},{touch:!1,mouse:!1}),resizeImage:t}},coefficient:function(){return this.visibleArea?this.visibleArea.width/this.boundaries.width:0},areaRestrictions:function(){return this.imageLoaded?this.areaRestrictionsAlgorithm({imageSize:this.imageSize,imageRestriction:this.imageRestriction,boundaries:this.boundaries}):{}},transitionsOptions:function(){return{enabled:this.transitionsActive,timingFunction:"ease-in-out",time:350}},sizeRestrictions:function(){if(this.boundaries.width&&this.boundaries.height&&this.imageSize.width&&this.imageSize.height){var t=this.sizeRestrictionsAlgorithm({imageSize:this.imageSize,minWidth:R(this.minWidth)?0:K(this.minWidth),minHeight:R(this.minHeight)?0:K(this.minHeight),maxWidth:R(this.maxWidth)?1/0:K(this.maxWidth),maxHeight:R(this.maxHeight)?1/0:K(this.maxHeight)});if(t=function(o){var s=o.areaRestrictions,n=o.sizeRestrictions;o.imageSize;var a=o.boundaries,h=o.positionRestrictions;o.imageRestriction;var r=g(g({},n),{minWidth:n.minWidth!==void 0?n.minWidth:0,minHeight:n.minHeight!==void 0?n.minHeight:0,maxWidth:n.maxWidth!==void 0?n.maxWidth:1/0,maxHeight:n.maxHeight!==void 0?n.maxHeight:1/0});h.left!==void 0&&h.right!==void 0&&(r.maxWidth=Math.min(r.maxWidth,h.right-h.left)),h.bottom!==void 0&&h.top!==void 0&&(r.maxHeight=Math.min(r.maxHeight,h.bottom-h.top));var c=pt(s),l=Nt(a,c);return c.width<1/0&&(!r.maxWidth||r.maxWidth>l.width)&&(r.maxWidth=Math.min(r.maxWidth,l.width)),c.height<1/0&&(!r.maxHeight||r.maxHeight>l.height)&&(r.maxHeight=Math.min(r.maxHeight,l.height)),r.minWidth>r.maxWidth&&(r.minWidth=r.maxWidth,r.widthFrozen=!0),r.minHeight>r.maxHeight&&(r.minHeight=r.maxHeight,r.heightFrozen=!0),r}({sizeRestrictions:t,areaRestrictions:this.getAreaRestrictions({visibleArea:this.visibleArea,type:"resize"}),imageSize:this.imageSize,boundaries:this.boundaries,positionRestrictions:this.positionRestrictions,imageRestriction:this.imageRestriction,visibleArea:this.visibleArea,stencilSize:this.getStencilSize()}),this.visibleArea&&this.stencilSize){var e=this.getStencilSize(),i=pt(this.getAreaRestrictions({visibleArea:this.visibleArea,type:"resize"}));t.maxWidth=Math.min(t.maxWidth,i.width*e.width/this.boundaries.width),t.maxHeight=Math.min(t.maxHeight,i.height*e.height/this.boundaries.height),t.maxWidth<t.minWidth&&(t.minWidth=t.maxWidth),t.maxHeight<t.minHeight&&(t.minHeight=t.maxHeight)}return t}return{minWidth:0,minHeight:0,maxWidth:0,maxHeight:0}},positionRestrictions:function(){return this.positionRestrictionsAlgorithm({imageSize:this.imageSize,imageRestriction:this.imageRestriction})},classes:function(){return{cropper:P(),image:z(P("image"),this.imageClass),stencil:P("stencil"),boundaries:z(P("boundaries"),this.boundariesClass),stretcher:z(P("stretcher")),background:z(P("background"),this.backgroundClass),foreground:z(P("foreground"),this.foregroundClass),imageWrapper:z(P("image-wrapper")),cropperWrapper:z(P("cropper-wrapper"))}},stencilCoordinates:function(){if(this.initialized){var t=this.coordinates,e=t.width,i=t.height,o=t.left,s=t.top;return{width:e/this.coefficient,height:i/this.coefficient,left:(o-this.visibleArea.left)/this.coefficient,top:(s-this.visibleArea.top)/this.coefficient}}return this.defaultCoordinates()},boundariesStyle:function(){var t={width:this.boundaries.width?"".concat(Math.round(this.boundaries.width),"px"):"auto",height:this.boundaries.height?"".concat(Math.round(this.boundaries.height),"px"):"auto",transition:"opacity ".concat(this.transitionTime,"ms"),pointerEvents:this.imageLoaded?"all":"none"};return this.imageLoaded||(t.opacity="0"),t},imageStyle:function(){var t=this.imageAttributes.width>this.imageAttributes.height?{width:Math.min(1024,this.imageAttributes.width),height:Math.min(1024,this.imageAttributes.width)/(this.imageAttributes.width/this.imageAttributes.height)}:{height:Math.min(1024,this.imageAttributes.height),width:Math.min(1024,this.imageAttributes.height)*(this.imageAttributes.width/this.imageAttributes.height)},e={left:(t.width-this.imageSize.width)/(2*this.coefficient),top:(t.height-this.imageSize.height)/(2*this.coefficient)},i={left:(1-1/this.coefficient)*t.width/2,top:(1-1/this.coefficient)*t.height/2},o=v(v({},this.imageTransforms),{},{scaleX:this.imageTransforms.scaleX*(this.imageAttributes.width/t.width),scaleY:this.imageTransforms.scaleY*(this.imageAttributes.height/t.height)}),s={width:"".concat(t.width,"px"),height:"".concat(t.height,"px"),left:"0px",top:"0px",transform:"translate(".concat(-e.left-i.left-this.imageTransforms.translateX,"px, ").concat(-e.top-i.top-this.imageTransforms.translateY,"px)")+Gt(o)};return this.transitionsOptions.enabled&&(s.transition="".concat(this.transitionsOptions.time,"ms ").concat(this.transitionsOptions.timingFunction)),s}},watch:{src:function(){this.onChangeImage()},stencilComponent:function(){var t=this;this.$nextTick(function(){t.resetCoordinates(),t.runAutoZoom("setCoordinates"),t.onChange()})},minWidth:function(){this.onPropsChange()},maxWidth:function(){this.onPropsChange()},minHeight:function(){this.onPropsChange()},maxHeight:function(){this.onPropsChange()},imageRestriction:function(){this.reset()},stencilProps:function(t,e){["aspectRatio","minAspectRatio","maxAspectRatio"].find(function(i){return t[i]!==e[i]})&&this.$nextTick(this.onPropsChange)}},created:function(){this.debouncedUpdate=gt(this.update,this.debounce),this.debouncedDisableTransitions=gt(this.disableTransitions,this.transitionsOptions.time),this.awaiting=!1},mounted:function(){this.$refs.image.addEventListener("load",this.onSuccessLoadImage),this.$refs.image.addEventListener("error",this.onFailLoadImage),this.onChangeImage(),window.addEventListener("resize",this.refresh),window.addEventListener("orientationchange",this.refresh)},unmounted:function(){window.removeEventListener("resize",this.refresh),window.removeEventListener("orientationchange",this.refresh),this.imageAttributes.revoke&&this.imageAttributes.src&&URL.revokeObjectURL(this.imageAttributes.src),this.debouncedUpdate.clear(),this.debouncedDisableTransitions.clear()},methods:{getResult:function(){var t=this.initialized?this.prepareResult(v({},this.coordinates)):this.defaultCoordinates(),e={rotate:this.imageTransforms.rotate%360,flip:v({},this.imageTransforms.flip)};if(this.src&&this.imageLoaded){var i=this;return{image:this.image,coordinates:t,visibleArea:this.visibleArea?v({},this.visibleArea):null,imageTransforms:e,get canvas(){return i.canvas?i.getCanvas():void 0}}}return{image:this.image,coordinates:t,visibleArea:this.visibleArea?v({},this.visibleArea):null,canvas:void 0,imageTransforms:e}},zoom:function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.transitions,s=o===void 0||o;this.onManipulateImage(new q({},{factor:1/t,center:e}),{normalize:!1,transitions:s})},move:function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.transitions,s=o===void 0||o;this.onManipulateImage(new q({left:t||0,top:e||0}),{normalize:!1,transitions:s})},setCoordinates:function(t){var e=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.autoZoom,s=o===void 0||o,n=i.transitions,a=n===void 0||n;this.$nextTick(function(){e.imageLoaded?(e.transitionsActive||(a&&e.enableTransitions(),e.coordinates=e.applyTransform(t),s&&e.runAutoZoom("setCoordinates"),a&&e.debouncedDisableTransitions()),e.onChange()):e.delayedTransforms=t})},refresh:function(){var t=this,e=this.$refs.image;if(this.src&&e)return this.initialized?this.updateVisibleArea().then(function(){t.onChange()}):this.resetVisibleArea().then(function(){t.onChange()})},reset:function(){var t=this;return this.resetVisibleArea().then(function(){t.onChange(!1)})},awaitRender:function(t){var e=this;this.awaiting||(this.awaiting=!0,this.$nextTick(function(){t(),e.awaiting=!1}))},prepareResult:function(t){return this.roundResult?function(e){var i=e.coordinates,o=e.sizeRestrictions,s=e.positionRestrictions,n={width:Math.round(i.width),height:Math.round(i.height),left:Math.round(i.left),top:Math.round(i.top)};return n.width>o.maxWidth?n.width=Math.floor(i.width):n.width<o.minWidth&&(n.width=Math.ceil(i.width)),n.height>o.maxHeight?n.height=Math.floor(i.height):n.height<o.minHeight&&(n.height=Math.ceil(i.height)),M(n,s)}(v(v({},this.getPublicProperties()),{},{positionRestrictions:J(this.positionRestrictions,this.visibleArea),coordinates:t})):t},processAutoZoom:function(t,e,i,o){var s=this.autoZoomAlgorithm;s||(s=this.stencilSize?me:this.autoZoom?ge:fe);var n=s({event:{type:t,params:o},visibleArea:e,coordinates:i,boundaries:this.boundaries,aspectRatio:this.getAspectRatio(),positionRestrictions:this.positionRestrictions,getAreaRestrictions:this.getAreaRestrictions,sizeRestrictions:this.sizeRestrictions,stencilSize:this.getStencilSize()});return v(v({},n),{},{changed:!Dt(n.visibleArea,e)||!Dt(n.coordinates,i)})},runAutoZoom:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=e.transitions,o=i!==void 0&&i,s=ie(e,Oe),n=this.processAutoZoom(t,this.visibleArea,this.coordinates,s),a=n.visibleArea,h=n.coordinates,r=n.changed;o&&r&&this.enableTransitions(),this.visibleArea=a,this.coordinates=h,o&&r&&this.debouncedDisableTransitions()},normalizeEvent:function(t){return function(e){var i=e.event,o=e.visibleArea,s=e.coefficient;if(i.type==="manipulateImage")return g(g({},i),{move:{left:i.move&&i.move.left?s*i.move.left:0,top:i.move&&i.move.top?s*i.move.top:0},scale:{factor:i.scale&&i.scale.factor?i.scale.factor:1,center:i.scale&&i.scale.center?{left:i.scale.center.left*s+o.left,top:i.scale.center.top*s+o.top}:null}});if(i.type==="resize"){var n=g(g({},i),{directions:g({},i.directions)});return O.forEach(function(h){n.directions[h]*=s}),n}if(i.type==="move"){var a=g(g({},i),{directions:g({},i.directions)});return ce.forEach(function(h){a.directions[h]*=s}),a}return i}(v(v({},this.getPublicProperties()),{},{event:t}))},getCanvas:function(){if(this.$refs.canvas){var t=this.$refs.canvas,e=this.$refs.image,i=this.imageTransforms.rotate!==0||this.imageTransforms.flip.horizontal||this.imageTransforms.flip.vertical?function(h,r,c){var l=c.rotate,u=c.flip,d={width:r.naturalWidth,height:r.naturalHeight},m=Vt(d,l),f=h.getContext("2d");h.height=m.height,h.width=m.width,f.save();var p=j(A(g({left:0,top:0},d)),l);return f.translate(-(p.left-m.width/2),-(p.top-m.height/2)),f.rotate(l*Math.PI/180),f.translate(u.horizontal?d.width:0,u.vertical?d.height:0),f.scale(u.horizontal?-1:1,u.vertical?-1:1),f.drawImage(r,0,0,d.width,d.height),f.restore(),h}(this.$refs.sourceCanvas,e,this.imageTransforms):e,o=v({minWidth:0,minHeight:0,maxWidth:1/0,maxHeight:1/0,maxArea:this.maxCanvasSize,imageSmoothingEnabled:!0,imageSmoothingQuality:"high",fillColor:"transparent"},this.canvas),s=function(h){return h.find(function(r){return c=r,!Number.isNaN(parseFloat(c))&&isFinite(c);var c})},n=$({sizeRestrictions:{minWidth:s([o.width,o.minWidth])||0,minHeight:s([o.height,o.minHeight])||0,maxWidth:s([o.width,o.maxWidth])||1/0,maxHeight:s([o.height,o.maxHeight])||1/0},width:this.coordinates.width,height:this.coordinates.height,aspectRatio:{minimum:this.coordinates.width/this.coordinates.height,maximum:this.coordinates.width/this.coordinates.height}});if(o.maxArea&&n.width*n.height>o.maxArea){var a=Math.sqrt(o.maxArea/(n.width*n.height));n={width:Math.round(a*n.width),height:Math.round(a*n.height)}}return function(h,r,c,l,u){h.width=l?l.width:c.width,h.height=l?l.height:c.height;var d=h.getContext("2d");d.clearRect(0,0,h.width,h.height),u&&(u.imageSmoothingEnabled&&(d.imageSmoothingEnabled=u.imageSmoothingEnabled),u.imageSmoothingQuality&&(d.imageSmoothingQuality=u.imageSmoothingQuality),u.fillColor&&(d.fillStyle=u.fillColor,d.fillRect(0,0,h.width,h.height),d.save()));var m=c.left<0?-c.left:0,f=c.top<0?-c.top:0;d.drawImage(r,c.left+m,c.top+f,c.width,c.height,m,f,h.width,h.height)}(t,i,this.coordinates,n,o),t}},update:function(){this.$emit("change",this.getResult())},applyTransform:function(t){var e=arguments.length>1&&arguments[1]!==void 0&&arguments[1],i=this.visibleArea&&e?ue(this.sizeRestrictions,this.visibleArea):this.sizeRestrictions,o=this.visibleArea&&e?J(this.positionRestrictions,this.visibleArea):this.positionRestrictions;return de({transform:t,coordinates:this.coordinates,imageSize:this.imageSize,sizeRestrictions:i,positionRestrictions:o,aspectRatio:this.getAspectRatio(),visibleArea:this.visibleArea})},resetCoordinates:function(){var t=this;if(this.$refs.image){this.$refs.cropper,this.$refs.image;var e=this.defaultSize;e||(e=this.stencilSize?be:ve);var i=this.sizeRestrictions;i.minWidth,i.minHeight,i.maxWidth,i.maxHeight;var o=Y(e)?e({boundaries:this.boundaries,imageSize:this.imageSize,aspectRatio:this.getAspectRatio(),sizeRestrictions:this.sizeRestrictions,stencilSize:this.getStencilSize(),visibleArea:this.visibleArea}):e,s=this.defaultPosition||pe,n=[o,function(a){var h=a.coordinates;return v({},Y(s)?s({coordinates:h,imageSize:t.imageSize,visibleArea:t.visibleArea}):t.defaultPosition)}];this.delayedTransforms&&n.push.apply(n,k(Array.isArray(this.delayedTransforms)?this.delayedTransforms:[this.delayedTransforms])),this.coordinates=this.applyTransform(n,!0),this.delayedTransforms=null}},clearImage:function(){var t=this;this.imageLoaded=!1,setTimeout(function(){var e=t.$refs.stretcher;e&&(e.style.height="auto",e.style.width="auto"),t.coordinates=t.defaultCoordinates(),t.boundaries={width:0,height:0}},this.transitionTime)},enableTransitions:function(){this.transitions&&(this.transitionsActive=!0)},disableTransitions:function(){this.transitionsActive=!1},updateBoundaries:function(){var t=this,e=this.$refs.stretcher,i=this.$refs.cropper;return this.initStretcher({cropper:i,stretcher:e,imageSize:this.imageSize}),this.$nextTick().then(function(){var o={cropper:i,imageSize:t.imageSize};if(Y(t.defaultBoundaries)?t.boundaries=t.defaultBoundaries(o):t.defaultBoundaries==="fit"?t.boundaries=function(s){var n=s.cropper,a=s.imageSize,h=n.clientHeight,r=n.clientWidth,c=h,l=a.width*h/a.height;return l>r&&(l=r,c=a.height*r/a.width),{width:l,height:c}}(o):t.boundaries=function(s){var n=s.cropper;return{width:n.clientWidth,height:n.clientHeight}}(o),!t.boundaries.width||!t.boundaries.height)throw new Error("It's impossible to fit the cropper in the current container")})},resetVisibleArea:function(){var t=this;return this.appliedImageTransforms=v(v({},this.defaultImageTransforms),{},{flip:v({},this.defaultImageTransforms.flip)}),this.updateBoundaries().then(function(){t.priority!=="visible-area"&&(t.visibleArea=null,t.resetCoordinates());var e,i,o,s,n,a,h=t.defaultVisibleArea||we;t.visibleArea=Y(h)?h({imageSize:t.imageSize,boundaries:t.boundaries,coordinates:t.priority!=="visible-area"?t.coordinates:null,getAreaRestrictions:t.getAreaRestrictions,stencilSize:t.getStencilSize()}):t.defaultVisibleArea,t.visibleArea=(e={visibleArea:t.visibleArea,boundaries:t.boundaries,getAreaRestrictions:t.getAreaRestrictions},i=e.visibleArea,o=e.boundaries,s=e.getAreaRestrictions,n=g({},i),a=b(o),n.width/n.height!==a&&(n.height=n.width/a),M(n,s({visibleArea:n,type:"move"}))),t.priority==="visible-area"?t.resetCoordinates():t.coordinates=t.fitCoordinates({visibleArea:t.visibleArea,coordinates:t.coordinates,aspectRatio:t.getAspectRatio(),positionRestrictions:t.positionRestrictions,sizeRestrictions:t.sizeRestrictions}),t.runAutoZoom("resetVisibleArea")}).catch(function(){t.visibleArea=null})},updateVisibleArea:function(){var t=this;return this.updateBoundaries().then(function(){t.visibleArea=t.fitVisibleArea({imageSize:t.imageSize,boundaries:t.boundaries,visibleArea:t.visibleArea,coordinates:t.coordinates,getAreaRestrictions:t.getAreaRestrictions}),t.coordinates=t.fitCoordinates({visibleArea:t.visibleArea,coordinates:t.coordinates,aspectRatio:t.getAspectRatio(),positionRestrictions:t.positionRestrictions,sizeRestrictions:t.sizeRestrictions}),t.runAutoZoom("updateVisibleArea")}).catch(function(){t.visibleArea=null})},onChange:function(){var t=!(arguments.length>0&&arguments[0]!==void 0)||arguments[0];t&&this.debounce?this.debouncedUpdate():this.update()},onChangeImage:function(){var t,e=this;if(this.imageLoaded=!1,this.delayedTransforms=null,this.src){if(function(s){if(Ct(s))return!1;var n=window.location,a=/(\w+:)?(?:\/\/)([\w.-]+)?(?::(\d+))?\/?/.exec(s)||[],h={protocol:a[1]||"",host:a[2]||"",port:a[3]||""},r=function(c){return c.port||((c.protocol||n.protocol)==="http"?80:433)};return!(!h.protocol&&!h.host&&!h.port||h.protocol&&h.protocol==n.protocol&&h.host&&h.host==n.host&&h.host&&r(h)==r(n))}(this.src)){var i=R(this.crossOrigin)?this.canvas:this.crossOrigin;i===!0&&(i="anonymous"),this.imageAttributes.crossOrigin=i||null}if(this.checkOrientation){var o=(t=this.src,new Promise(function(s){We(t).then(function(n){var a=De(n);s(n?{source:t,arrayBuffer:n,orientation:a}:{source:t,arrayBuffer:null,orientation:null})}).catch(function(n){s({source:t,arrayBuffer:null,orientation:null})})}));setTimeout(function(){o.then(e.onParseImage)},this.transitionTime)}else setTimeout(function(){e.onParseImage({source:e.src})},this.transitionTime)}else this.clearImage()},onFailLoadImage:function(){this.imageAttributes.src&&(this.clearImage(),this.$emit("error"))},onSuccessLoadImage:function(){var t=this,e=this.$refs.image;e&&!this.imageLoaded&&(this.imageAttributes.height=e.naturalHeight,this.imageAttributes.width=e.naturalWidth,this.imageLoaded=!0,this.resetVisibleArea().then(function(){t.$emit("ready"),t.onChange(!1)}))},onParseImage:function(t){var e=this,i=t.source,o=t.arrayBuffer,s=t.orientation;this.imageAttributes.revoke&&this.imageAttributes.src&&URL.revokeObjectURL(this.imageAttributes.src),this.imageAttributes.revoke=!1,o&&s&&s>1?kt(i)||!Ct(i)?(this.imageAttributes.src=URL.createObjectURL(new Blob([o])),this.imageAttributes.revoke=!0):this.imageAttributes.src=function(n){for(var a=[],h=new Uint8Array(n);h.length>0;){var r=h.subarray(0,8192);a.push(String.fromCharCode.apply(null,Array.from?Array.from(r):r.slice())),h=h.subarray(8192)}return"data:image/jpeg;base64,"+btoa(a.join(""))}(o):this.imageAttributes.src=i,Y(this.defaultTransforms)?this.appliedImageTransforms=ut(this.defaultTransforms()):it(this.defaultTransforms)?this.appliedImageTransforms=ut(this.defaultTransforms):this.appliedImageTransforms=function(n){var a=ut({});if(n)switch(n){case 2:a.flip.horizontal=!0;break;case 3:a.rotate=-180;break;case 4:a.flip.vertical=!0;break;case 5:a.rotate=90,a.flip.vertical=!0;break;case 6:a.rotate=90;break;case 7:a.rotate=90,a.flip.horizontal=!0;break;case 8:a.rotate=-90}return a}(s),this.defaultImageTransforms=v(v({},this.appliedImageTransforms),{},{flip:v({},this.appliedImageTransforms.flip)}),this.$nextTick(function(){var n=e.$refs.image;n&&n.complete&&(function(a){return!!a.naturalWidth}(n)?e.onSuccessLoadImage():e.onFailLoadImage())})},onResizeEnd:function(){this.runAutoZoom("resize",{transitions:!0})},onMoveEnd:function(){this.runAutoZoom("move",{transitions:!0})},onMove:function(t){var e=this;this.transitionsOptions.enabled||this.awaitRender(function(){e.coordinates=e.moveAlgorithm(v(v({},e.getPublicProperties()),{},{positionRestrictions:J(e.positionRestrictions,e.visibleArea),coordinates:e.coordinates,event:e.normalizeEvent(t)})),e.onChange()})},onResize:function(t){var e=this;this.transitionsOptions.enabled||this.stencilSize&&!this.autoZoom||this.awaitRender(function(){var i=e.sizeRestrictions,o=Math.min(e.coordinates.width,e.coordinates.height,20*e.coefficient);e.coordinates=e.resizeAlgorithm(v(v({},e.getPublicProperties()),{},{positionRestrictions:J(e.positionRestrictions,e.visibleArea),sizeRestrictions:{maxWidth:Math.min(i.maxWidth,e.visibleArea.width),maxHeight:Math.min(i.maxHeight,e.visibleArea.height),minWidth:Math.max(i.minWidth,o),minHeight:Math.max(i.minHeight,o)},event:e.normalizeEvent(t)})),e.onChange(),e.ticking=!1})},onManipulateImage:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.transitionsOptions.enabled){var i=e.transitions,o=i!==void 0&&i,s=e.normalize,n=s===void 0||s;o&&this.enableTransitions();var a=ye(v(v({},this.getPublicProperties()),{},{event:n?this.normalizeEvent(t):t,getAreaRestrictions:this.getAreaRestrictions,imageRestriction:this.imageRestriction,adjustStencil:!this.stencilSize&&this.settings.resizeImage.adjustStencil})),h=a.visibleArea,r=a.coordinates;this.visibleArea=h,this.coordinates=r,this.runAutoZoom("manipulateImage"),this.onChange(),o&&this.debouncedDisableTransitions()}},onPropsChange:function(){this.coordinates=this.applyTransform(this.coordinates,!0),this.onChange(!1)},getAreaRestrictions:function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=t.visibleArea,i=t.type,o=i===void 0?"move":i;return this.areaRestrictionsAlgorithm({boundaries:this.boundaries,imageSize:this.imageSize,imageRestriction:this.imageRestriction,visibleArea:e,type:o})},getAspectRatio:function(t){var e,i,o=this.stencilProps,s=o.aspectRatio,n=o.minAspectRatio,a=o.maxAspectRatio;if(this.$refs.stencil&&this.$refs.stencil.aspectRatios){var h=this.$refs.stencil.aspectRatios();e=h.minimum,i=h.maximum}if(R(e)&&(e=R(s)?n:s),R(i)&&(i=R(s)?a:s),!t&&(R(e)||R(i))){var r=this.getStencilSize(),c=r?b(r):null;R(e)&&(e=Tt(c)?c:void 0),R(i)&&(i=Tt(c)?c:void 0)}return{minimum:e,maximum:i}},getStencilSize:function(){if(this.stencilSize)return t={currentStencilSize:{width:this.stencilCoordinates.width,height:this.stencilCoordinates.height},stencilSize:this.stencilSize,boundaries:this.boundaries,coefficient:this.coefficient,coordinates:this.coordinates,aspectRatio:this.getAspectRatio(!0)},e=t.boundaries,i=t.stencilSize,o=t.aspectRatio,ct(b(s=Y(i)?i({boundaries:e,aspectRatio:o}):i),o)&&(s=$({sizeRestrictions:{maxWidth:e.width,maxHeight:e.height,minWidth:0,minHeight:0},width:s.width,height:s.height,aspectRatio:{minimum:o.minimum,maximum:o.maximum}})),(s.width>e.width||s.height>e.height)&&(s=$({sizeRestrictions:{maxWidth:e.width,maxHeight:e.height,minWidth:0,minHeight:0},width:s.width,height:s.height,aspectRatio:{minimum:b(s),maximum:b(s)}})),s;var t,e,i,o,s},getPublicProperties:function(){return{coefficient:this.coefficient,visibleArea:this.visibleArea,coordinates:this.coordinates,boundaries:this.boundaries,sizeRestrictions:this.sizeRestrictions,positionRestrictions:this.positionRestrictions,aspectRatio:this.getAspectRatio(),imageRestriction:this.imageRestriction}},defaultCoordinates:function(){return v({},Wt)},flip:function(t,e){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=i.transitions,s=o===void 0||o;if(!this.transitionsActive){s&&this.enableTransitions();var n=v({},this.imageTransforms.flip),a=Re({flip:{horizontal:t?!n.horizontal:n.horizontal,vertical:e?!n.vertical:n.vertical},previousFlip:n,rotate:this.imageTransforms.rotate,visibleArea:this.visibleArea,coordinates:this.coordinates,imageSize:this.imageSize,positionRestrictions:this.positionRestrictions,sizeRestrictions:this.sizeRestrictions,getAreaRestrictions:this.getAreaRestrictions,aspectRatio:this.getAspectRatio()}),h=a.visibleArea,r=a.coordinates;t&&(this.appliedImageTransforms.flip.horizontal=!this.appliedImageTransforms.flip.horizontal),e&&(this.appliedImageTransforms.flip.vertical=!this.appliedImageTransforms.flip.vertical),this.visibleArea=h,this.coordinates=r,this.onChange(),s&&this.debouncedDisableTransitions()}},rotate:function(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=e.transitions,o=i===void 0||i;if(!this.transitionsActive){o&&this.enableTransitions();var s=v({},this.imageSize);this.appliedImageTransforms.rotate+=t;var n=ze({visibleArea:this.visibleArea,coordinates:this.coordinates,previousImageSize:s,imageSize:this.imageSize,angle:t,positionRestrictions:this.positionRestrictions,sizeRestrictions:this.sizeRestrictions,getAreaRestrictions:this.getAreaRestrictions,aspectRatio:this.getAspectRatio()}),a=n.visibleArea,h=n.coordinates,r=this.processAutoZoom("rotateImage",a,h);a=r.visibleArea,h=r.coordinates,this.visibleArea=a,this.coordinates=h,this.onChange(),o&&this.debouncedDisableTransitions()}}},emits:["change","error","ready"]},Le={key:0,ref:"canvas",style:{display:"none"}},Pe={key:1,ref:"sourceCanvas",style:{display:"none"}};He.render=function(t,e,i,o,s,n){return w(),y("div",{ref:"cropper",class:n.classes.cropper},[S("div",{ref:"stretcher",class:n.classes.stretcher},null,2),S("div",{class:n.classes.boundaries,style:n.boundariesStyle},[(w(),y(nt(i.backgroundWrapperComponent),{class:n.classes.cropperWrapper,"wheel-resize":n.settings.resizeImage.wheel,"touch-resize":n.settings.resizeImage.touch,"touch-move":n.settings.moveImage.touch,"mouse-move":n.settings.moveImage.mouse,onMove:n.onManipulateImage,onResize:n.onManipulateImage},{default:B(function(){return[S("div",{class:n.classes.background,style:n.boundariesStyle},null,6),S("div",{class:n.classes.imageWrapper},[S("img",{ref:"image",crossorigin:s.imageAttributes.crossOrigin,src:s.imageAttributes.src,class:n.classes.image,style:n.imageStyle,onMousedown:e[1]||(e[1]=ee(function(){},["prevent"]))},null,46,["crossorigin","src"])],2),S("div",{class:n.classes.foreground,style:n.boundariesStyle},null,6),$t((w(),y(nt(i.stencilComponent),jt({ref:"stencil",image:n.image,coordinates:s.coordinates,"stencil-coordinates":n.stencilCoordinates,transitions:n.transitionsOptions},i.stencilProps,{onResize:n.onResize,onResizeEnd:n.onResizeEnd,onMove:n.onMove,onMoveEnd:n.onMoveEnd}),null,16,["image","coordinates","stencil-coordinates","transitions","onResize","onResizeEnd","onMove","onMoveEnd"])),[[It,s.imageLoaded]]),i.canvas?(w(),y("canvas",Le,null,512)):St("",!0),i.canvas?(w(),y("canvas",Pe,null,512)):St("",!0)]}),_:1},8,["class","wheel-resize","touch-resize","touch-move","mouse-move","onMove","onResize"]))],6)],2)};export{He as f};
|