/* interact.js 1.10.27 | https://raw.github.com/taye/interact.js/main/LICENSE */ import clone from"../utils/clone.prod.js";import extend from"../utils/extend.prod.js";import*as rectUtils from"../utils/rect.prod.js";class Modification{constructor(t){this.states=[],this.startOffset={left:0,right:0,top:0,bottom:0},this.startDelta=void 0,this.result=void 0,this.endResult=void 0,this.startEdges=void 0,this.edges=void 0,this.interaction=void 0,this.interaction=t,this.result=createResult(),this.edges={left:!1,right:!1,top:!1,bottom:!1}}start(t,e){let{phase:s}=t;const{interaction:o}=this,r=getModifierList(o);this.prepareStates(r),this.startEdges=extend({},o.edges),this.edges=extend({},this.startEdges),this.startOffset=getRectOffset(o.rect,e),this.startDelta={x:0,y:0};const i=this.fillArg({phase:s,pageCoords:e,preEnd:!1});this.result=createResult(),this.startAll(i);return this.result=this.setAll(i)}fillArg(t){const{interaction:e}=this;return t.interaction=e,t.interactable=e.interactable,t.element=e.element,t.rect||(t.rect=e.rect),t.edges||(t.edges=this.startEdges),t.startOffset=this.startOffset,t}startAll(t){for(const e of this.states)e.methods.start&&(t.state=e,e.methods.start(t))}setAll(t){const{phase:e,preEnd:s,skipModifiers:o,rect:r,edges:i}=t;t.coords=extend({},t.pageCoords),t.rect=extend({},r),t.edges=extend({},i);const n=o?this.states.slice(o):this.states,a=createResult(t.coords,t.rect);for(const o of n){var d;const{options:r}=o,i=extend({},t.coords);let n=null;null!=(d=o.methods)&&d.set&&this.shouldDo(r,s,e)&&(t.state=o,n=o.methods.set(t),rectUtils.addEdges(t.edges,t.rect,{x:t.coords.x-i.x,y:t.coords.y-i.y})),a.eventProps.push(n)}extend(this.edges,t.edges),a.delta.x=t.coords.x-t.pageCoords.x,a.delta.y=t.coords.y-t.pageCoords.y,a.rectDelta.left=t.rect.left-r.left,a.rectDelta.right=t.rect.right-r.right,a.rectDelta.top=t.rect.top-r.top,a.rectDelta.bottom=t.rect.bottom-r.bottom;const c=this.result.coords,l=this.result.rect;if(c&&l){const t=a.rect.left!==l.left||a.rect.right!==l.right||a.rect.top!==l.top||a.rect.bottom!==l.bottom;a.changed=t||c.x!==a.coords.x||c.y!==a.coords.y}return a}applyToInteraction(t){const{interaction:e}=this,{phase:s}=t,o=e.coords.cur,r=e.coords.start,{result:i,startDelta:n}=this,a=i.delta;"start"===s&&extend(this.startDelta,i.delta);for(const[t,e]of[[r,n],[o,a]])t.page.x+=e.x,t.page.y+=e.y,t.client.x+=e.x,t.client.y+=e.y;const{rectDelta:d}=this.result,c=t.rect||e.rect;c.left+=d.left,c.right+=d.right,c.top+=d.top,c.bottom+=d.bottom,c.width=c.right-c.left,c.height=c.bottom-c.top}setAndApply(t){const{interaction:e}=this,{phase:s,preEnd:o,skipModifiers:r}=t,i=this.setAll(this.fillArg({preEnd:o,phase:s,pageCoords:t.modifiedCoords||e.coords.cur.page}));if(this.result=i,!i.changed&&(!r||rclone(t))),this.result=createResult(extend({},t.result.coords),extend({},t.result.rect))}destroy(){for(const t in this)this[t]=null}}function createResult(t,e){return{rect:e,coords:t,delta:{x:0,y:0},rectDelta:{left:0,right:0,top:0,bottom:0},eventProps:[],changed:!0}}function getModifierList(t){const e=t.interactable.options[t.prepared.name],s=e.modifiers;return s&&s.length?s:["snap","snapSize","snapEdges","restrict","restrictEdges","restrictSize"].map((t=>{const s=e[t];return s&&s.enabled&&{options:s,methods:s._methods}})).filter((t=>!!t))}function getRectOffset(t,e){return t?{left:e.x-t.left,top:e.y-t.top,right:t.right-e.x,bottom:t.bottom-e.y}:{left:0,top:0,right:0,bottom:0}}export{Modification,getRectOffset}; //# sourceMappingURL=Modification.prod.js.map