var __spreadArray=this&&this.__spreadArray||function(e,t){for(var n=0,r=t.length,i=e.length;n<r;n++,i++)e[i]=t[n];return e};System.register(["./index-c820db66.system.js"],(function(e){"use strict";var t,n,r;return{setters:[function(e){t=e.r;n=e.j;r=e.g}],execute:function(){var i="smoothly-reorder>*{cursor:move;-webkit-transition:-webkit-transform 0.3s;transition:-webkit-transform 0.3s;transition:transform 0.3s;transition:transform 0.3s, -webkit-transform 0.3s}smoothly-reorder>*.dragging{-webkit-transition:none;transition:none;-webkit-box-shadow:0 0 10px rgba(var(--smoothly-dark-color));box-shadow:0 0 10px rgba(var(--smoothly-dark-color));z-index:1;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}";var o=e("smoothly_reorder",function(){function e(e){t(this,e);this.reorder=n(this,"reorder",7)}Object.defineProperty(e.prototype,"children",{get:function(){var e=[];if(this.childrenCache)e=this.childrenCache;else{for(var t=0;t<this.element.children.length;t++){var n=this.element.children[t];if(n instanceof HTMLElement){var r=n.getBoundingClientRect();e.push({top:r.top,middle:r.top+r.height/2,bottom:r.bottom,element:n})}}this.childrenCache=e}return e},enumerable:false,configurable:true});e.prototype.onMouseDown=function(e){if(!this.move&&this.element.children.length>1){this.bounds=this.element.getBoundingClientRect();this.childrenCache=undefined;var t=this.getCurrentIndex(e.clientY);this.dragged=Object.assign(Object.assign({},this.children[t]),{startY:e.clientY,offsetY:e.clientY-this.children[t].middle,index:t,height:t<this.children.length-1?this.children[t+1].top-this.children[t].top:this.children[t].bottom-this.children[t-1].bottom});this.dragged.element.className+=" dragging"}};e.prototype.onMouseMove=function(e){if(this.dragged&&this.bounds&&e.clientY>=this.bounds.top&&e.clientY<=this.bounds.bottom){var t=this.getCurrentIndex(e.clientY-this.dragged.offsetY);this.translate(this.dragged.index,t,e.clientY-this.dragged.startY)}};e.prototype.onMouseUp=function(e){var t=this;if(this.dragged){this.dragged.element.className=this.dragged.element.className.replace(" dragging","");var n=this.getCurrentIndex(e.clientY-this.dragged.offsetY);this.translate(this.dragged.index,n,this.children[n].top-this.dragged.top);this.move={from:this.dragged.index,to:n};this.dragged=undefined;window.setTimeout((function(){if(t.move){var e=__spreadArray([],t.children.map((function(e){return e.element})));var n=e.splice(t.move.from,1);e.splice.apply(e,__spreadArray([t.move.to,0],n));e.forEach((function(e){return t.element.removeChild(e)}));e.forEach((function(e){e.style.transform="";t.element.appendChild(e)}));t.reorder.emit([t.move.from,t.move.to]);t.move=undefined}}),500)}};e.prototype.translate=function(e,t,n){for(var r=0;r<this.children.length;r++){var i=void 0;if(this.dragged){if(e<t&&r>e&&r<=t)i=-this.dragged.height;else if(e>t&&r<e&&r>=t)i=this.dragged.height;else i=r==e?n:0;this.children[r].element.style.transform="translateY("+i+"px)"}}};e.prototype.getCurrentIndex=function(e){return this.children.findIndex((function(t){return e<t.bottom}))};e.prototype.componentDidLoad=function(){var e=this;this.element.childNodes.forEach((function(t){t.addEventListener("mousedown",(function(t){return e.onMouseDown(t)}));t.addEventListener("mousemove",(function(t){return e.onMouseMove(t)}));t.addEventListener("mouseup",(function(t){return e.onMouseUp(t)}))}))};Object.defineProperty(e.prototype,"element",{get:function(){return r(this)},enumerable:false,configurable:true});return e}());o.style=i}}}));