"use strict";(self["webpackChunkaida"]=self["webpackChunkaida"]||[]).push([[4242],{84242:function(n,e,t){function o(n){var e,t=n.getSelectionContext(),o=5,i=4,r=1,c="rgb(0,255,0)",u=1;function s(n){a(n.x+.5,n.y1>n.y2?n.y2:n.y1,n.x+.5,n.y2>n.y1?n.y2:n.y1)}function f(n){a(n.x1>n.x2?n.x2:n.x1,n.y+.5,n.x2>n.x1?n.x2:n.x1,n.y+.5)}function a(n,o,i,s){t.save(),t.lineWidth=r,t.strokeStyle=c,t.beginPath(),t.moveTo(n*u+e[4],o*u+e[5]),t.lineTo(i*u+e[4],s*u+e[5]),t.stroke(),t.restore()}function g(n,e){n=Math.round(n),e=Math.round(e);for(var t=n-i,o=n+i;t<=o;t++)if(t===e)return!0;return!1}var y=[],h=[];n.on("mouse:down",(function(){e=n.viewportTransform,u=n.getZoom()})),n.on("object:moving",(function(t){var i=t.target,r=n.getObjects(),c=i.getCenterPoint(),u=c.x,s=c.y,f=i.getBoundingRect(),a=f.height/e[3],x=f.width/e[0],l=!1,P=!1,d=n._currentTransform;if(d){for(var b=r.length;b--;)if(r[b]!==i){var p=r[b].getCenterPoint(),w=p.x,v=p.y,m=r[b].getBoundingRect(),B=m.height/e[3],O=m.width/e[0];g(u+x/2,w-O/2)&&(P=!0,y.push({x:w-O/2,y1:v<s?v-B/2-o:v+B/2+o,y2:s>v?s+a/2+o:s-a/2-o}),i.setPositionByOrigin(new fabric.Point(w-O/2-x/2,s),"center","center")),g(u-x/2,w+O/2)&&(P=!0,y.push({x:w+O/2,y1:v<s?v-B/2-o:v+B/2+o,y2:s>v?s+a/2+o:s-a/2-o}),i.setPositionByOrigin(new fabric.Point(w+O/2+x/2,s),"center","center")),g(v+B/2,s-a/2)&&(l=!0,h.push({y:v+B/2,x1:w<u?w-O/2-o:w+O/2+o,x2:u>w?u+x/2+o:u-x/2-o}),i.setPositionByOrigin(new fabric.Point(u,v+B/2+a/2),"center","center")),g(v-B/2,s+a/2)&&(l=!0,h.push({y:v-B/2,x1:w<u?w-O/2-o:w+O/2+o,x2:u>w?u+x/2+o:u-x/2-o}),i.setPositionByOrigin(new fabric.Point(u,v-B/2-a/2),"center","center")),g(w,u)&&(P=!0,y.push({x:w,y1:v<s?v-B/2-o:v+B/2+o,y2:s>v?s+a/2+o:s-a/2-o}),i.setPositionByOrigin(new fabric.Point(w,s),"center","center")),g(w-O/2,u-x/2)&&(P=!0,y.push({x:w-O/2,y1:v<s?v-B/2-o:v+B/2+o,y2:s>v?s+a/2+o:s-a/2-o}),i.setPositionByOrigin(new fabric.Point(w-O/2+x/2,s),"center","center")),g(w+O/2,u+x/2)&&(P=!0,y.push({x:w+O/2,y1:v<s?v-B/2-o:v+B/2+o,y2:s>v?s+a/2+o:s-a/2-o}),i.setPositionByOrigin(new fabric.Point(w+O/2-x/2,s),"center","center")),g(v,s)&&(l=!0,h.push({y:v,x1:w<u?w-O/2-o:w+O/2+o,x2:u>w?u+x/2+o:u-x/2-o}),i.setPositionByOrigin(new fabric.Point(u,v),"center","center")),g(v-B/2,s-a/2)&&(l=!0,h.push({y:v-B/2,x1:w<u?w-O/2-o:w+O/2+o,x2:u>w?u+x/2+o:u-x/2-o}),i.setPositionByOrigin(new fabric.Point(u,v-B/2+a/2),"center","center")),g(v+B/2,s+a/2)&&(l=!0,h.push({y:v+B/2,x1:w<u?w-O/2-o:w+O/2+o,x2:u>w?u+x/2+o:u-x/2-o}),i.setPositionByOrigin(new fabric.Point(u,v+B/2-a/2),"center","center"))}l||(h.length=0),P||(y.length=0)}})),n.on("before:render",(function(){n.contextTop&&n.clearContext(n.contextTop)})),n.on("after:render",(function(){for(var n=y.length;n--;)s(y[n]);for(n=h.length;n--;)f(h[n]);y.length=h.length=0})),n.on("mouse:up",(function(){y.length=h.length=0,n.renderAll()}))}function i(n){for(var e,t=n.getWidth(),o=n.getHeight(),i=t/2,r=o/2,c={},u={},s=4,f="rgba(255,0,241,0.5)",a=1,g=n.getSelectionContext(),y=i-s,h=i+s;y<=h;y++)c[Math.round(y)]=!0;for(y=r-s,h=r+s;y<=h;y++)u[Math.round(y)]=!0;function x(){P(i+.5,0,i+.5,o)}function l(){P(0,r+.5,t,r+.5)}function P(n,t,o,i){g.save(),g.strokeStyle=f,g.lineWidth=a,g.beginPath(),g.moveTo(n*e[0],t*e[3]),g.lineTo(o*e[0],i*e[3]),g.stroke(),g.restore()}var d,b;n.on("mouse:down",(function(){e=n.viewportTransform})),n.on("object:moving",(function(e){var t=e.target,o=t.getCenterPoint(),s=n._currentTransform;s&&(d=Math.round(o.x)in c,b=Math.round(o.y)in u,(b||d)&&t.setPositionByOrigin(new fabric.Point(d?i:o.x,b?r:o.y),"center","center"))})),n.on("before:render",(function(){n.contextTop&&n.clearContext(n.contextTop)})),n.on("after:render",(function(){d&&x(),b&&l()})),n.on("mouse:up",(function(){d=b=null,n.renderAll()}))}t.r(e),t.d(e,{initCenteringGuidelines:function(){return i}}),e["default"]=o}}]);