Sortable.js 41 KB

12
  1. /*! Sortable 1.10.0-rc3 - MIT | git://github.com/SortableJS/Sortable.git */
  2. !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Sortable=e()}(this,function(){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function I(i){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},e=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(r).filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable}))),e.forEach(function(t){var e,n,o;e=i,o=r[n=t],n in e?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o})}return i}function l(t,e){if(null==t)return{};var n,o,i=function(t,e){if(null==t)return{};var n,o,i={},r=Object.keys(t);for(o=0;o<r.length;o++)n=r[o],0<=e.indexOf(n)||(i[n]=t[n]);return i}(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(o=0;o<r.length;o++)n=r[o],0<=e.indexOf(n)||Object.prototype.propertyIsEnumerable.call(t,n)&&(i[n]=t[n])}return i}function e(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function t(t){return!!navigator.userAgent.match(t)}var y=t(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),E=t(/Edge/i),s=t(/firefox/i),c=t(/safari/i)&&!t(/chrome/i)&&!t(/android/i),n=t(/iP(ad|od|hone)/i),r=t(/chrome/i)&&t(/android/i),u={capture:!1,passive:!1};function d(t,e,n){t.addEventListener(e,n,!y&&u)}function h(t,e,n){t.removeEventListener(e,n,!y&&u)}function f(t,e){if(e){if(">"===e[0]&&(e=e.substring(1)),t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return!1}return!1}}function k(t,e,n,o){if(t){n=n||document;do{if(null!=e&&(">"===e[0]?t.parentNode===n&&f(t,e):f(t,e))||o&&t===n)return t;if(t===n)break}while(t=(i=t).host&&i!==document&&i.host.nodeType?i.host:i.parentNode)}var i;return null}var p,g=/\s+/g;function P(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(g," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(g," ")}}function R(t,e,n){var o=t&&t.style;if(o){if(void 0===n)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),void 0===e?n:n[e];e in o||-1!==e.indexOf("webkit")||(e="-webkit-"+e),o[e]=n+("string"==typeof n?"":"px")}}function v(t,e){var n="";do{var o=R(t,"transform");o&&"none"!==o&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix;return i&&new i(n)}function m(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i<r;i++)n(o[i],i);return o}return[]}function M(){return y?document.documentElement:document.scrollingElement}function X(t,e,n,o,i){if(t.getBoundingClientRect||t===window){var r,a,l,s,c,u,d;if(d=t!==window&&t!==M()?(a=(r=t.getBoundingClientRect()).top,l=r.left,s=r.bottom,c=r.right,u=r.height,r.width):(l=a=0,s=window.innerHeight,c=window.innerWidth,u=window.innerHeight,window.innerWidth),(e||n)&&t!==window&&(i=i||t.parentNode,!y))do{if(i&&i.getBoundingClientRect&&("none"!==R(i,"transform")||n&&"static"!==R(i,"position"))){var h=i.getBoundingClientRect();a-=h.top+parseInt(R(i,"border-top-width")),l-=h.left+parseInt(R(i,"border-left-width")),s=a+r.height,c=l+r.width;break}}while(i=i.parentNode);if(o&&t!==window){var f=v(i||t),p=f&&f.a,g=f&&f.d;f&&(s=(a/=g)+(u/=g),c=(l/=p)+(d/=p))}return{top:a,left:l,bottom:s,right:c,width:d,height:u}}}function Y(t,e,n,o){for(var i=A(t,!0),r=(e||X(t))[n];i;){var a=X(i)[o];if(!("top"===o||"left"===o?a<=r:r<=a))return i;if(i===M())break;i=A(i,!1)}return!1}function b(t,e,n){for(var o=0,i=0,r=t.children;i<r.length;){if("none"!==r[i].style.display&&r[i]!==Nt.ghost&&r[i]!==Nt.dragged&&k(r[i],n.draggable,t,!1)){if(o===e)return r[i];o++}i++}return null}function B(t,e){for(var n=t.lastElementChild;n&&(n===Nt.ghost||"none"===R(n,"display")||e&&!f(n,e));)n=n.previousElementSibling;return n||null}function F(t,e){var n=0;if(!t||!t.parentNode)return-1;for(;t=t.previousElementSibling;)"TEMPLATE"===t.nodeName.toUpperCase()||t===Nt.clone||e&&!f(t,e)||n++;return n}function w(t){var e=0,n=0,o=M();if(t)do{var i=v(t),r=i.a,a=i.d;e+=t.scrollLeft*r,n+=t.scrollTop*a}while(t!==o&&(t=t.parentNode));return[e,n]}function A(t,e){if(!t||!t.getBoundingClientRect)return M();var n=t,o=!1;do{if(n.clientWidth<n.scrollWidth||n.clientHeight<n.scrollHeight){var i=R(n);if(n.clientWidth<n.scrollWidth&&("auto"==i.overflowX||"scroll"==i.overflowX)||n.clientHeight<n.scrollHeight&&("auto"==i.overflowY||"scroll"==i.overflowY)){if(!n.getBoundingClientRect||n===document.body)return M();if(o||e)return n;o=!0}}}while(n=n.parentNode);return M()}function D(t,e){return Math.round(t.top)===Math.round(e.top)&&Math.round(t.left)===Math.round(e.left)&&Math.round(t.height)===Math.round(e.height)&&Math.round(t.width)===Math.round(e.width)}function _(e,n){return function(){if(!p){var t=arguments;1===t.length?e.call(this,t[0]):e.apply(this,t),p=setTimeout(function(){p=void 0},n)}}}function H(t,e,n){t.scrollLeft+=e,t.scrollTop+=n}function S(t){var e=window.Polymer,n=window.jQuery||window.Zepto;return e&&e.dom?e.dom(t).cloneNode(!0):n?n(t).clone(!0)[0]:t.cloneNode(!0)}function C(t,e){R(t,"position","absolute"),R(t,"top",e.top),R(t,"left",e.left),R(t,"width",e.width),R(t,"height",e.height)}function T(t){R(t,"position",""),R(t,"top",""),R(t,"left",""),R(t,"width",""),R(t,"height","")}var L="Sortable"+(new Date).getTime();function x(){var e,o=[];return{captureAnimationState:function(){o=[],this.options.animation&&[].slice.call(this.el.children).forEach(function(t){if("none"!==R(t,"display")&&t!==Nt.ghost){o.push({target:t,rect:X(t)});var e=X(t);if(t.thisAnimationDuration){var n=v(t,!0);n&&(e.top-=n.f,e.left-=n.e)}t.fromRect=e}})},addAnimationState:function(t){o.push(t)},removeAnimationState:function(t){o.splice(function(t,e){for(var n in t)if(t.hasOwnProperty(n))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[n][o])return Number(n);return-1}(o,{target:t}),1)},animateAll:function(t){var c=this;if(!this.options.animation)return clearTimeout(e),void("function"==typeof t&&t());var u=!1,d=0;o.forEach(function(t){var e=0,n=t.target,o=n.fromRect,i=X(n),r=n.prevFromRect,a=n.prevToRect,l=t.rect,s=v(n,!0);s&&(i.top-=s.f,i.left-=s.e),n.toRect=i,(Y(n,i,"bottom","top")||Y(n,i,"top","bottom")||Y(n,i,"right","left")||Y(n,i,"left","right"))&&(Y(n,l,"bottom","top")||Y(n,l,"top","bottom")||Y(n,l,"right","left")||Y(n,l,"left","right"))&&(Y(n,o,"bottom","top")||Y(n,o,"top","bottom")||Y(n,o,"right","left")||Y(n,o,"left","right"))||(n.thisAnimationDuration&&D(r,i)&&!D(o,i)&&(l.top-i.top)/(l.left-i.left)==(o.top-i.top)/(o.left-i.left)&&(e=function(t,e,n,o){return Math.sqrt(Math.pow(e.top-t.top,2)+Math.pow(e.left-t.left,2))/Math.sqrt(Math.pow(e.top-n.top,2)+Math.pow(e.left-n.left,2))*o.animation}(l,r,a,c.options)),D(i,o)||(n.prevFromRect=o,n.prevToRect=i,e||(e=c.options.animation),c.animate(n,l,e)),e&&(u=!0,d=Math.max(d,e),clearTimeout(n.animationResetTimer),n.animationResetTimer=setTimeout(function(){n.animationTime=0,n.prevFromRect=null,n.fromRect=null,n.prevToRect=null,n.thisAnimationDuration=null},e),n.thisAnimationDuration=e))}),clearTimeout(e),u?e=setTimeout(function(){"function"==typeof t&&t()},d):"function"==typeof t&&t(),o=[]},animate:function(t,e,n){if(n){R(t,"transition",""),R(t,"transform","");var o=X(t),i=v(this.el),r=i&&i.a,a=i&&i.d,l=(e.left-o.left)/(r||1),s=(e.top-o.top)/(a||1);t.animatingX=!!l,t.animatingY=!!s,R(t,"transform","translate3d("+l+"px,"+s+"px,0)"),function(t){t.offsetWidth}(t),R(t,"transition","transform "+n+"ms"+(this.options.easing?" "+this.options.easing:"")),R(t,"transform","translate3d(0,0,0)"),"number"==typeof t.animated&&clearTimeout(t.animated),t.animated=setTimeout(function(){R(t,"transition",""),R(t,"transform",""),t.animated=!1,t.animatingX=!1,t.animatingY=!1},n)}}}}var O=[],N={initializeByDefault:!0},j={mount:function(t){for(var e in N)!N.hasOwnProperty(e)||e in t||(t[e]=N[e]);O.push(t)},pluginEvent:function(e,n,o){var i=this;this.eventCanceled=!1;var r=e+"Global";O.forEach(function(t){n[t.pluginName]&&(n[t.pluginName][r]&&(i.eventCanceled=!!n[t.pluginName][r](I({sortable:n},o))),n.options[t.pluginName]&&n[t.pluginName][e]&&(i.eventCanceled=i.eventCanceled||!!n[t.pluginName][e](I({sortable:n},o))))})},initializePlugins:function(o,i,r){for(var t in O.forEach(function(t){var e=t.pluginName;if(o.options[e]||t.initializeByDefault){var n=new t(o,i);(n.sortable=o)[e]=n,a(r,n.options)}}),o.options)if(o.options.hasOwnProperty(t)){var e=this.modifyOption(o,t,o.options[t]);void 0!==e&&(o.options[t]=e)}},getEventOptions:function(e,n){var o={};return O.forEach(function(t){"function"==typeof t.eventOptions&&a(o,t.eventOptions.call(n,e))}),o},modifyOption:function(e,n,o){var i;return O.forEach(function(t){e[t.pluginName]&&t.optionListeners&&"function"==typeof t.optionListeners[n]&&(i=t.optionListeners[n].call(e[t.pluginName],o))}),i}};function K(t){var e,n=t.sortable,o=t.rootEl,i=t.name,r=t.targetEl,a=t.cloneEl,l=t.toEl,s=t.fromEl,c=t.oldIndex,u=t.newIndex,d=t.oldDraggableIndex,h=t.newDraggableIndex,f=t.originalEvent,p=t.putSortable,g=t.eventOptions,v=(n=n||o[L]).options,m="on"+i.charAt(0).toUpperCase()+i.substr(1);!window.CustomEvent||y||E?(e=document.createEvent("Event")).initEvent(i,!0,!0):e=new CustomEvent(i,{bubbles:!0,cancelable:!0}),e.to=l||o,e.from=s||o,e.item=r||o,e.clone=a,e.oldIndex=c,e.newIndex=u,e.oldDraggableIndex=d,e.newDraggableIndex=h,e.originalEvent=f,e.pullMode=p?p.lastPutMode:void 0;var b=I({},g,j.getEventOptions(i,n));for(var w in b)e[w]=b[w];o&&o.dispatchEvent(e),v[m]&&v[m].call(n,e)}function W(t,e,n){var o=2<arguments.length&&void 0!==n?n:{},i=o.evt,r=l(o,["evt"]);j.pluginEvent.bind(Nt)(t,e,I({dragEl:G,parentEl:U,ghostEl:q,rootEl:V,nextEl:Z,lastDownEl:Q,cloneEl:$,cloneHidden:J,dragStarted:st,putSortable:rt,activeSortable:Nt.active,originalEvent:i,oldIndex:tt,oldDraggableIndex:nt,newIndex:et,newDraggableIndex:ot,hideGhostForTarget:xt,unhideGhostForTarget:Ot,cloneNowHidden:function(){J=!0},cloneNowShown:function(){J=!1},dispatchSortableEvent:function(t){z({sortable:e,name:t,originalEvent:i})}},r))}function z(t){K(I({putSortable:rt,cloneEl:$,targetEl:G,rootEl:V,oldIndex:tt,oldDraggableIndex:nt,newIndex:et,newDraggableIndex:ot},t))}if("undefined"==typeof window||!window.document)throw new Error("Sortable.js requires a window with a document");var G,U,q,V,Z,Q,$,J,tt,et,nt,ot,it,rt,at,lt,st,ct,ut,dt,ht,ft=!1,pt=!1,gt=[],vt=!1,mt=!1,bt=[],wt=!1,yt=[],Et=n,Dt=E||y?"cssFloat":"float",_t=!r&&!n&&"draggable"in document.createElement("div"),St=function(){if(y)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto","auto"===t.style.pointerEvents}(),Ct=function(t,e){var n=R(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=b(t,0,e),r=b(t,1,e),a=i&&R(i),l=r&&R(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+X(i).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+X(r).width;if("flex"===n.display)return"column"===n.flexDirection||"column-reverse"===n.flexDirection?"vertical":"horizontal";if("grid"===n.display)return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&"none"!==a.float){var u="left"===a.float?"left":"right";return!r||"both"!==l.clear&&l.clear!==u?"horizontal":"vertical"}return i&&("block"===a.display||"flex"===a.display||"table"===a.display||"grid"===a.display||o<=s&&"none"===n[Dt]||r&&"none"===n[Dt]&&o<s+c)?"vertical":"horizontal"},Tt=function(t){function s(a,l){return function(t,e,n,o){var i=t.options.group.name&&e.options.group.name&&t.options.group.name===e.options.group.name;if(null==a&&(l||i))return!0;if(null==a||!1===a)return!1;if(l&&"clone"===a)return a;if("function"==typeof a)return s(a(t,e,n,o),l)(t,e,n,o);var r=(l?t:e).options.group.name;return!0===a||"string"==typeof a&&a===r||a.join&&-1<a.indexOf(r)}}var e={},n=t.group;n&&"object"==o(n)||(n={name:n}),e.name=n.name,e.checkPull=s(n.pull,!0),e.checkPut=s(n.put),e.revertClone=n.revertClone,t.group=e},xt=function(){!St&&q&&R(q,"display","none")},Ot=function(){!St&&q&&R(q,"display","")};document.addEventListener("click",function(t){if(pt)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),pt=!1},!0);function Mt(t){if(G){var e=function(r,a){var l;return gt.some(function(t){if(!B(t)){var e=X(t),n=t[L].options.emptyInsertThreshold,o=r>=e.left-n&&r<=e.right+n,i=a>=e.top-n&&a<=e.bottom+n;return n&&o&&i?l=t:void 0}}),l}((t=t.touches?t.touches[0]:t).clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[L]._onDragOver(n)}}}function At(t){G&&G.parentNode[L]._isOutsideThisEl(t.target)}function Nt(t,e){if(!t||!t.nodeType||1!==t.nodeType)throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=a({},e),t[L]=this;var n={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return Ct(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:!1!==Nt.supportPointer&&"PointerEvent"in window,emptyInsertThreshold:5};for(var o in j.initializePlugins(this,t,n),n)o in e||(e[o]=n[o]);for(var i in Tt(e),this)"_"===i.charAt(0)&&"function"==typeof this[i]&&(this[i]=this[i].bind(this));this.nativeDraggable=!e.forceFallback&&_t,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?d(t,"pointerdown",this._onTapStart):(d(t,"mousedown",this._onTapStart),d(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(d(t,"dragover",this),d(t,"dragenter",this)),gt.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),a(this,x())}function It(t,e,n,o,i,r,a,l){var s,c,u=t[L],d=u.options.onMove;return!window.CustomEvent||y||E?(s=document.createEvent("Event")).initEvent("move",!0,!0):s=new CustomEvent("move",{bubbles:!0,cancelable:!0}),s.to=e,s.from=t,s.dragged=n,s.draggedRect=o,s.related=i||e,s.relatedRect=r||X(e),s.willInsertAfter=l,s.originalEvent=a,t.dispatchEvent(s),d&&(c=d.call(u,s,a)),c}function kt(t){t.draggable=!1}function Pt(){wt=!1}function Rt(t){for(var e=t.tagName+t.className+t.src+t.href+t.textContent,n=e.length,o=0;n--;)o+=e.charCodeAt(n);return o.toString(36)}function Xt(t){return setTimeout(t,0)}function Yt(t){return clearTimeout(t)}Nt.prototype={constructor:Nt,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(ct=null)},_getDirection:function(t,e){return"function"==typeof this.options.direction?this.options.direction.call(this,t,e,G):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,t=this.options,i=t.preventOnFilter,r=e.type,a=e.touches&&e.touches[0],l=(a||e).target,s=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||l,c=t.filter;if(function(t){yt.length=0;var e=t.getElementsByTagName("input"),n=e.length;for(;n--;){var o=e[n];o.checked&&yt.push(o)}}(o),!G&&!(/mousedown|pointerdown/.test(r)&&0!==e.button||t.disabled||s.isContentEditable||(l=k(l,t.draggable,o,!1))&&l.animated||Q===l)){if(tt=F(l),nt=F(l,t.draggable),"function"==typeof c){if(c.call(this,e,l,this))return z({sortable:n,rootEl:s,name:"filter",targetEl:l,toEl:o,fromEl:o}),W("filter",n,{evt:e}),void(i&&e.cancelable&&e.preventDefault())}else if(c&&(c=c.split(",").some(function(t){if(t=k(s,t.trim(),o,!1))return z({sortable:n,rootEl:t,name:"filter",targetEl:l,fromEl:o,toEl:o}),W("filter",n,{evt:e}),!0})))return void(i&&e.cancelable&&e.preventDefault());t.handle&&!k(s,t.handle,o,!1)||this._prepareDragStart(e,a,l)}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;if(n&&!G&&n.parentNode===r)if(V=r,U=(G=n).parentNode,Z=G.nextSibling,Q=n,it=a.group,at={target:Nt.dragged=G,clientX:(e||t).clientX,clientY:(e||t).clientY},this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,G.style["will-change"]="all",o=function(){W("delayEnded",i,{evt:t}),Nt.eventCanceled?i._onDrop():(i._disableDelayedDragEvents(),!s&&i.nativeDraggable&&(G.draggable=!0),i._triggerDragStart(t,e),z({sortable:i,name:"choose",originalEvent:t}),P(G,a.chosenClass,!0))},a.ignore.split(",").forEach(function(t){m(G,t.trim(),kt)}),d(l,"dragover",Mt),d(l,"mousemove",Mt),d(l,"touchmove",Mt),d(l,"mouseup",i._onDrop),d(l,"touchend",i._onDrop),d(l,"touchcancel",i._onDrop),s&&this.nativeDraggable&&(this.options.touchStartThreshold=4,G.draggable=!0),W("delayStart",this,{evt:t}),!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(E||y))o();else{if(Nt.eventCanceled)return void this._onDrop();d(l,"mouseup",i._disableDelayedDrag),d(l,"touchend",i._disableDelayedDrag),d(l,"touchcancel",i._disableDelayedDrag),d(l,"mousemove",i._delayedDragTouchMoveHandler),d(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&d(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(o,a.delay)}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){G&&kt(G),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;h(t,"mouseup",this._disableDelayedDrag),h(t,"touchend",this._disableDelayedDrag),h(t,"touchcancel",this._disableDelayedDrag),h(t,"mousemove",this._delayedDragTouchMoveHandler),h(t,"touchmove",this._delayedDragTouchMoveHandler),h(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||"touch"==t.pointerType&&t,!this.nativeDraggable||e?this.options.supportPointer?d(document,"pointermove",this._onTouchMove):d(document,e?"touchmove":"mousemove",this._onTouchMove):(d(G,"dragend",this),d(V,"dragstart",this._onDragStart));try{document.selection?Xt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){if(ft=!1,V&&G){W("dragStarted",this,{evt:e}),this.nativeDraggable&&d(document,"dragover",At);var n=this.options;t||P(G,n.dragClass,!1),P(G,n.ghostClass,!0),Nt.active=this,t&&this._appendGhost(),z({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(lt){this._lastX=lt.clientX,this._lastY=lt.clientY,xt();for(var t=document.elementFromPoint(lt.clientX,lt.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(lt.clientX,lt.clientY))!==e;)e=t;if(G.parentNode[L]._isOutsideThisEl(t),e)do{if(e[L]){if(e[L]._onDragOver({clientX:lt.clientX,clientY:lt.clientY,target:t,rootEl:e})&&!this.options.dragoverBubble)break}t=e}while(e=e.parentNode);Ot()}},_onTouchMove:function(t){if(at){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=q&&v(q),a=q&&r&&r.a,l=q&&r&&r.d,s=Et&&ht&&w(ht),c=(i.clientX-at.clientX+o.x)/(a||1)+(s?s[0]-bt[0]:0)/(a||1),u=(i.clientY-at.clientY+o.y)/(l||1)+(s?s[1]-bt[1]:0)/(l||1),d=t.touches?"translate3d("+c+"px,"+u+"px,0)":"translate("+c+"px,"+u+"px)";if(!Nt.active&&!ft){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))<n)return;this._onDragStart(t,!0)}lt=i,R(q,"webkitTransform",d),R(q,"mozTransform",d),R(q,"msTransform",d),R(q,"transform",d),t.cancelable&&t.preventDefault()}},_appendGhost:function(){if(!q){var t=this.options.fallbackOnBody?document.body:V,e=X(G,!0,Et,!0,t),n=this.options;if(Et){for(ht=t;"static"===R(ht,"position")&&"none"===R(ht,"transform")&&ht!==document;)ht=ht.parentNode;ht!==document.body&&ht!==document.documentElement?(ht===document&&(ht=M()),e.top+=ht.scrollTop,e.left+=ht.scrollLeft):ht=M(),bt=w(ht)}P(q=G.cloneNode(!0),n.ghostClass,!1),P(q,n.fallbackClass,!0),P(q,n.dragClass,!0),R(q,"transition",""),R(q,"transform",""),R(q,"box-sizing","border-box"),R(q,"margin",0),R(q,"top",e.top),R(q,"left",e.left),R(q,"width",e.width),R(q,"height",e.height),R(q,"opacity","0.8"),R(q,"position",Et?"absolute":"fixed"),R(q,"zIndex","100000"),R(q,"pointerEvents","none"),Nt.ghost=q,t.appendChild(q)}},_onDragStart:function(t,e){var n=this,o=t.dataTransfer,i=n.options;W("dragStart",this,{evt:t}),Nt.eventCanceled?this._onDrop():(W("setupClone",this),Nt.eventCanceled||(($=S(G)).draggable=!1,$.style["will-change"]="",this._hideClone(),P($,this.options.chosenClass,!1),Nt.clone=$),n.cloneId=Xt(function(){W("clone",n),Nt.eventCanceled||(n.options.removeCloneOnHide||V.insertBefore($,G),n._hideClone(),z({sortable:n,name:"clone"}))}),e||P(G,i.dragClass,!0),e?(pt=!0,n._loopId=setInterval(n._emulateDragOver,50)):(h(document,"mouseup",n._onDrop),h(document,"touchend",n._onDrop),h(document,"touchcancel",n._onDrop),o&&(o.effectAllowed="move",i.setData&&i.setData.call(n,o,G)),d(document,"drop",n),R(G,"transform","translateZ(0)")),ft=!0,n._dragStartId=Xt(n._dragStarted.bind(n,e,t)),d(document,"selectstart",n),st=!0,c&&R(document.body,"user-select","none"))},_onDragOver:function(n){var o,i,r,a,l=this.el,s=n.target,e=this.options,t=e.group,c=Nt.active,u=it===t,d=e.sort,h=rt||c,f=this,p=!1;if(!wt){if(void 0!==n.preventDefault&&n.cancelable&&n.preventDefault(),s=k(s,e.draggable,l,!0),O("dragOver"),Nt.eventCanceled)return p;if(G.contains(n.target)||s.animated&&s.animatingX&&s.animatingY||f._ignoreWhileAnimating===s)return A(!1);if(pt=!1,c&&!e.disabled&&(u?d||(r=!V.contains(G)):rt===this||(this.lastPutMode=it.checkPull(this,c,G,n))&&t.checkPut(this,c,G,n))){if(a="vertical"===this._getDirection(n,s),o=X(G),O("dragOverValid"),Nt.eventCanceled)return p;if(r)return U=V,M(),this._hideClone(),O("revert"),Nt.eventCanceled||(Z?V.insertBefore(G,Z):V.appendChild(G)),A(!0);var g=B(l,e.draggable);if(!g||function(t,e,n){var o=X(B(n.el,n.options.draggable));return e?t.clientX>o.right+10||t.clientX<=o.right&&t.clientY>o.bottom&&t.clientX>=o.left:t.clientX>o.right&&t.clientY>o.top||t.clientX<=o.right&&t.clientY>o.bottom+10}(n,a,this)&&!g.animated){if(g===G)return A(!1);if(g&&l===n.target&&(s=g),s&&(i=X(s)),!1!==It(V,l,G,o,s,i,n,!!s))return M(),l.appendChild(G),U=l,N(),A(!0)}else if(s.parentNode===l){i=X(s);var v,m,b,w=G.parentNode!==l,y=!function(t,e,n){var o=n?t.left:t.top,i=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,s=n?e.width:e.height;return o===a||i===l||o+r/2===a+s/2}(G.animated&&G.toRect||o,s.animated&&s.toRect||i,a),E=a?"top":"left",D=Y(s,null,"top","top")||Y(G,null,"top","top"),_=D?D.scrollTop:void 0;if(ct!==s&&(m=i[E],vt=!1,mt=!y&&e.invertSwap||w),0!==(v=function(t,e,n,o,i,r,a,l){var s=o?t.clientY:t.clientX,c=o?n.height:n.width,u=o?n.top:n.left,d=o?n.bottom:n.right,h=!1;if(!a)if(l&&dt<c*i){if(!vt&&(1===ut?u+c*r/2<s:s<d-c*r/2)&&(vt=!0),vt)h=!0;else if(1===ut?s<u+dt:d-dt<s)return-ut}else if(u+c*(1-i)/2<s&&s<d-c*(1-i)/2)return function(t){return F(G)<F(t)?1:-1}(e);if((h=h||a)&&(s<u+c*r/2||d-c*r/2<s))return u+c/2<s?1:-1;return 0}(n,s,i,a,y?1:e.swapThreshold,null==e.invertedSwapThreshold?e.swapThreshold:e.invertedSwapThreshold,mt,ct===s)))for(var S=F(G);S-=v,(b=U.children[S])&&("none"===R(b,"display")||b===q););if(0===v||b===s)return A(!1);ut=v;var C=(ct=s).nextElementSibling,T=!1,x=It(V,l,G,o,s,i,n,T=1===v);if(!1!==x)return 1!==x&&-1!==x||(T=1===x),wt=!0,setTimeout(Pt,30),M(),T&&!C?l.appendChild(G):s.parentNode.insertBefore(G,T?C:s),D&&H(D,0,_-D.scrollTop),U=G.parentNode,void 0===m||mt||(dt=Math.abs(m-X(s)[E])),N(),A(!0)}if(l.contains(G))return A(!1)}return!1}function O(t,e){W(t,f,I({evt:n,isOwner:u,axis:a?"vertical":"horizontal",revert:r,dragRect:o,targetRect:i,canSort:d,fromSortable:h,target:s,completed:A,onMove:function(t,e){return It(V,l,G,o,t,X(t),n,e)},changed:N},e))}function M(){O("dragOverAnimationCapture"),f.captureAnimationState(),f!==h&&h.captureAnimationState()}function A(t){return O("dragOverCompleted",{insertion:t}),t&&(u?c._hideClone():c._showClone(f),f!==h&&(P(G,rt?rt.options.ghostClass:c.options.ghostClass,!1),P(G,e.ghostClass,!0)),rt!==f&&f!==Nt.active?rt=f:f===Nt.active&&rt&&(rt=null),h===f&&(f._ignoreWhileAnimating=s),f.animateAll(function(){O("dragOverAnimationComplete"),f._ignoreWhileAnimating=null}),f!==h&&(h.animateAll(),h._ignoreWhileAnimating=null)),(s===G&&!G.animated||s===l&&!s.animated)&&(ct=null),e.dragoverBubble||n.rootEl||s===document||(G.parentNode[L]._isOutsideThisEl(n.target),t||Mt(n)),!e.dragoverBubble&&n.stopPropagation&&n.stopPropagation(),p=!0}function N(){et=F(G),ot=F(G,e.draggable),z({sortable:f,name:"change",toEl:l,newIndex:et,newDraggableIndex:ot,originalEvent:n})}},_ignoreWhileAnimating:null,_offMoveEvents:function(){h(document,"mousemove",this._onTouchMove),h(document,"touchmove",this._onTouchMove),h(document,"pointermove",this._onTouchMove),h(document,"dragover",Mt),h(document,"mousemove",Mt),h(document,"touchmove",Mt)},_offUpEvents:function(){var t=this.el.ownerDocument;h(t,"mouseup",this._onDrop),h(t,"touchend",this._onDrop),h(t,"pointerup",this._onDrop),h(t,"touchcancel",this._onDrop),h(document,"selectstart",this)},_onDrop:function(t){var e=this.el,n=this.options;et=F(G),ot=F(G,n.draggable),W("drop",this,{evt:t}),et=F(G),ot=F(G,n.draggable),Nt.eventCanceled||(vt=mt=ft=!1,clearInterval(this._loopId),clearTimeout(this._dragStartTimer),Yt(this.cloneId),Yt(this._dragStartId),this.nativeDraggable&&(h(document,"drop",this),h(e,"dragstart",this._onDragStart)),this._offMoveEvents(),this._offUpEvents(),c&&R(document.body,"user-select",""),t&&(st&&(t.cancelable&&t.preventDefault(),n.dropBubble||t.stopPropagation()),q&&q.parentNode&&q.parentNode.removeChild(q),(V===U||rt&&"clone"!==rt.lastPutMode)&&$&&$.parentNode&&$.parentNode.removeChild($),G&&(this.nativeDraggable&&h(G,"dragend",this),kt(G),G.style["will-change"]="",st&&!ft&&P(G,rt?rt.options.ghostClass:this.options.ghostClass,!1),P(G,this.options.chosenClass,!1),z({sortable:this,name:"unchoose",toEl:U,newIndex:null,newDraggableIndex:null,originalEvent:t}),V!==U?(0<=et&&(z({rootEl:U,name:"add",toEl:U,fromEl:V,originalEvent:t}),z({sortable:this,name:"remove",toEl:U,originalEvent:t}),z({rootEl:U,name:"sort",toEl:U,fromEl:V,originalEvent:t}),z({sortable:this,name:"sort",toEl:U,originalEvent:t})),rt&&rt.save()):et!==tt&&0<=et&&(z({sortable:this,name:"update",toEl:U,originalEvent:t}),z({sortable:this,name:"sort",toEl:U,originalEvent:t})),Nt.active&&(null!=et&&-1!==et||(et=tt,ot=nt),z({sortable:this,name:"end",toEl:U,originalEvent:t}),this.save())))),this._nulling()},_nulling:function(){W("nulling",this),V=G=U=q=Z=$=Q=J=at=lt=st=et=ot=tt=nt=ct=ut=rt=it=Nt.dragged=Nt.ghost=Nt.clone=Nt.active=null,yt.forEach(function(t){t.checked=!0}),yt.length=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":G&&(this._onDragOver(t),function(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}(t));break;case"selectstart":t.preventDefault()}},toArray:function(){for(var t,e=[],n=this.el.children,o=0,i=n.length,r=this.options;o<i;o++)k(t=n[o],r.draggable,this.el,!1)&&e.push(t.getAttribute(r.dataIdAttr)||Rt(t));return e},sort:function(t){var o={},i=this.el;this.toArray().forEach(function(t,e){var n=i.children[e];k(n,this.options.draggable,i,!1)&&(o[t]=n)},this),t.forEach(function(t){o[t]&&(i.removeChild(o[t]),i.appendChild(o[t]))})},save:function(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function(t,e){return k(t,e||this.options.draggable,this.el,!1)},option:function(t,e){var n=this.options;if(void 0===e)return n[t];var o=j.modifyOption(this,t,e);n[t]=void 0!==o?o:e,"group"===t&&Tt(n)},destroy:function(){W("destroy",this);var t=this.el;t[L]=null,h(t,"mousedown",this._onTapStart),h(t,"touchstart",this._onTapStart),h(t,"pointerdown",this._onTapStart),this.nativeDraggable&&(h(t,"dragover",this),h(t,"dragenter",this)),Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),function(t){t.removeAttribute("draggable")}),this._onDrop(),gt.splice(gt.indexOf(this.el),1),this.el=t=null},_hideClone:function(){if(!J){if(W("hideClone",this),Nt.eventCanceled)return;R($,"display","none"),this.options.removeCloneOnHide&&$.parentNode&&$.parentNode.removeChild($),J=!0}},_showClone:function(t){if("clone"===t.lastPutMode){if(J){if(W("showClone",this),Nt.eventCanceled)return;V.contains(G)&&!this.options.group.revertClone?V.insertBefore($,G):Z?V.insertBefore($,Z):V.appendChild($),this.options.group.revertClone&&this._animate(G,$),R($,"display",""),J=!1}}else this._hideClone()}},d(document,"touchmove",function(t){(Nt.active||ft)&&t.cancelable&&t.preventDefault()}),Nt.utils={on:d,off:h,css:R,find:m,is:function(t,e){return!!k(t,e,t,!1)},extend:function(t,e){if(t&&e)for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t},throttle:_,closest:k,toggleClass:P,clone:S,index:F,nextTick:Xt,cancelNextTick:Yt,detectDirection:Ct,getChild:b},Nt.mount=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];e[0].constructor===Array&&(e=e[0]),e.forEach(function(t){if(!t.prototype||!t.prototype.constructor)throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(el));t.utils&&(Nt.utils=I({},Nt.utils,t.utils)),j.mount(t)})},Nt.create=function(t,e){return new Nt(t,e)};var Bt,Ft,Ht,Lt,jt,Kt,Wt=[],zt=!(Nt.version="1.10.0-rc3");function Gt(){Wt.forEach(function(t){clearInterval(t.pid)}),Wt=[]}function Ut(){clearInterval(Kt)}function qt(t){var e=t.originalEvent,n=t.putSortable,o=t.dragEl,i=t.activeSortable,r=t.dispatchSortableEvent,a=t.hideGhostForTarget,l=t.unhideGhostForTarget,s=n||i;a();var c=document.elementFromPoint(e.clientX,e.clientY);l(),s&&!s.el.contains(c)&&(r("spill"),this.onSpill(o))}var Vt,Zt=_(function(n,t,e,o){if(t.scroll){var i,r=t.scrollSensitivity,a=t.scrollSpeed,l=M(),s=!1;Ft!==e&&(Ft=e,Gt(),Bt=t.scroll,i=t.scrollFn,!0===Bt&&(Bt=A(e,!0)));var c=0,u=Bt;do{var d=u,h=X(d),f=h.top,p=h.bottom,g=h.left,v=h.right,m=h.width,b=h.height,w=void 0,y=void 0,E=d.scrollWidth,D=d.scrollHeight,_=R(d),S=d.scrollLeft,C=d.scrollTop;y=d===l?(w=m<E&&("auto"===_.overflowX||"scroll"===_.overflowX||"visible"===_.overflowX),b<D&&("auto"===_.overflowY||"scroll"===_.overflowY||"visible"===_.overflowY)):(w=m<E&&("auto"===_.overflowX||"scroll"===_.overflowX),b<D&&("auto"===_.overflowY||"scroll"===_.overflowY));var T=w&&(Math.abs(v-n.clientX)<=r&&S+m<E)-(Math.abs(g-n.clientX)<=r&&!!S),x=y&&(Math.abs(p-n.clientY)<=r&&C+b<D)-(Math.abs(f-n.clientY)<=r&&!!C);if(!Wt[c])for(var O=0;O<=c;O++)Wt[O]||(Wt[O]={});Wt[c].vx==T&&Wt[c].vy==x&&Wt[c].el===d||(Wt[c].el=d,Wt[c].vx=T,Wt[c].vy=x,clearInterval(Wt[c].pid),0==T&&0==x||(s=!0,Wt[c].pid=setInterval(function(){o&&0===this.layer&&Nt.active._onTouchMove(jt);var t=Wt[this.layer].vy?Wt[this.layer].vy*a:0,e=Wt[this.layer].vx?Wt[this.layer].vx*a:0;"function"==typeof i&&"continue"!==i.call(Nt.dragged.parentNode[L],e,t,n,jt,Wt[this.layer].el)||H(Wt[this.layer].el,e,t)}.bind({layer:c}),24))),c++}while(t.bubbleScroll&&u!==l&&(u=A(u,!1)));zt=s}},30);function Qt(){}function $t(){}Qt.prototype={startIndex:null,dragStart:function(t){var e=t.oldDraggableIndex;this.startIndex=e},onSpill:function(t){this.sortable.captureAnimationState();var e=b(this.sortable.el,this.startIndex,this.sortable.options);e?this.sortable.el.insertBefore(t,e):this.sortable.el.appendChild(t),this.sortable.animateAll()},drop:qt},a(Qt,{pluginName:"revertOnSpill"}),$t.prototype={onSpill:function(t){this.sortable.captureAnimationState(),t.parentNode&&t.parentNode.removeChild(t),this.sortable.animateAll()},drop:qt},a($t,{pluginName:"removeOnSpill"});var Jt,te,ee,ne,oe,ie=[],re=[],ae=!1,le=!1,se=!1;function ce(n,o){re.forEach(function(t){var e=o.children[t.sortableIndex+(n?Number(i):0)];e?o.insertBefore(t,e):o.appendChild(t)})}function ue(){ie.forEach(function(t){t!==ee&&t.parentNode&&t.parentNode.removeChild(t)})}return Nt.mount(new function(){function t(){for(var t in this.options={scroll:!0,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:!0},this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this))}return t.prototype={dragStarted:function(t){var e=t.originalEvent;this.sortable.nativeDraggable?d(document,"dragover",this._handleAutoScroll):this.sortable.options.supportPointer?d(document,"pointermove",this._handleFallbackAutoScroll):e.touches?d(document,"touchmove",this._handleFallbackAutoScroll):d(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var e=t.originalEvent;this.sortable.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){this.sortable.nativeDraggable?h(document,"dragover",this._handleAutoScroll):(h(document,"pointermove",this._handleFallbackAutoScroll),h(document,"touchmove",this._handleFallbackAutoScroll),h(document,"mousemove",this._handleFallbackAutoScroll)),Ut(),Gt(),clearTimeout(p),p=void 0},nulling:function(){jt=Ft=Bt=zt=Kt=Ht=Lt=null,Wt.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,!0)},_handleAutoScroll:function(e,n){var o=this,i=e.clientX,r=e.clientY,t=document.elementFromPoint(i,r);if(jt=e,n||E||y||c){Zt(e,this.options,t,n);var a=A(t,!0);!zt||Kt&&i===Ht&&r===Lt||(Kt&&Ut(),Kt=setInterval(function(){var t=A(document.elementFromPoint(i,r),!0);t!==a&&(a=t,Gt()),Zt(e,o.options,t,n)},10),Ht=i,Lt=r)}else{if(!this.sortable.options.bubbleScroll||A(t,!0)===M())return void Gt();Zt(e,this.options,A(t,!1),!1)}}},a(t,{pluginName:"scroll",initializeByDefault:!0})}),Nt.mount($t,Qt),Nt.mount(new function(){function t(){this.options={swapClass:"sortable-swap-highlight"}}return t.prototype={dragStart:function(t){var e=t.dragEl;Vt=e},dragOverValid:function(t){var e=t.completed,n=t.target,o=t.onMove,i=t.activeSortable,r=t.changed;if(i.options.swap){var a=this.sortable.el,l=this.sortable.options;if(n&&n!==a){var s=Vt;Vt=!1!==o(n)?(P(n,l.swapClass,!0),n):null,s&&s!==Vt&&P(s,l.swapClass,!1)}return r(),e(!0)}},drop:function(t){var e=t.activeSortable,n=t.putSortable,o=t.dragEl,i=n||this.sortable,r=this.sortable.options;Vt&&P(Vt,r.swapClass,!1),Vt&&(r.swap||n&&n.options.swap)&&o!==Vt&&(i.captureAnimationState(),i!==e&&e.captureAnimationState(),function(t,e){var n,o,i=t.parentNode,r=e.parentNode;if(!i||!r||i.isEqualNode(e)||r.isEqualNode(t))return;n=F(t),o=F(e),i.isEqualNode(r)&&n<o&&o++;i.insertBefore(e,i.children[n]),r.insertBefore(t,r.children[o])}(o,Vt),i.animateAll(),i!==e&&e.animateAll())},nulling:function(){Vt=null}},a(t,{pluginName:"swap",eventOptions:function(){return{swapItem:Vt}}})}),Nt.mount(new function(){function t(o){for(var t in this)"_"===t.charAt(0)&&"function"==typeof this[t]&&(this[t]=this[t].bind(this));o.options.supportPointer?d(document,"pointerup",this._deselectMultiDrag):(d(document,"mouseup",this._deselectMultiDrag),d(document,"touchend",this._deselectMultiDrag)),d(document,"keydown",this._checkKeyDown),d(document,"keyup",this._checkKeyUp),this.options={selectedClass:"sortable-selected",multiDragKey:null,setData:function(t,e){var n="";ie.length&&te===o?ie.forEach(function(t,e){n+=(e?", ":"")+t.textContent}):n=e.textContent,t.setData("Text",n)}}}return t.prototype={multiDragKeyDown:!1,isMultiDrag:!1,delayStartGlobal:function(t){var e=t.dragEl;ee=e},delayEnded:function(){this.isMultiDrag=~ie.indexOf(ee)},setupClone:function(t){var e=t.sortable;if(this.isMultiDrag){for(var n=0;n<ie.length;n++)re.push(S(ie[n])),re[n].sortableIndex=ie[n].sortableIndex,re[n].draggable=!1,re[n].style["will-change"]="",P(re[n],e.options.selectedClass,!1),ie[n]===ee&&P(re[n],e.options.chosenClass,!1);return e._hideClone(),!0}},clone:function(t){var e=t.sortable,n=t.rootEl,o=t.dispatchSortableEvent;if(this.isMultiDrag)return!e.options.removeCloneOnHide&&ie.length&&te===e?(ce(!0,n),o("clone"),!0):void 0},showClone:function(t){var e=t.cloneNowShown,n=t.rootEl;if(this.isMultiDrag)return ce(!1,n),re.forEach(function(t){R(t,"display","")}),e(),!(oe=!1)},hideClone:function(t){var e=t.sortable,n=t.cloneNowHidden;if(this.isMultiDrag)return re.forEach(function(t){R(t,"display","none"),e.options.removeCloneOnHide&&t.parentNode&&t.parentNode.removeChild(t)}),n(),oe=!0},dragStartGlobal:function(t){t.sortable;!this.isMultiDrag&&te&&te.multiDrag._deselectMultiDrag(),ie.forEach(function(t){t.sortableIndex=F(t)}),ie=ie.sort(function(t,e){return t.sortableIndex-e.sortableIndex}),se=!0},dragStarted:function(t){var e=t.sortable;if(this.isMultiDrag){if(e.options.sort&&(e.captureAnimationState(),e.options.animation)){ie.forEach(function(t){t!==ee&&R(t,"position","absolute")});var n=X(ee,!1,!0,!0);ie.forEach(function(t){t!==ee&&C(t,n)}),ae=le=!0}e.animateAll(function(){ae=le=!1,e.options.animation&&ie.forEach(function(t){T(t)}),e.options.sort&&ue()})}},dragOver:function(t){var e=t.target,n=t.completed;if(le&&~ie.indexOf(e))return n(!1)},revert:function(t){var e=t.fromSortable,n=t.rootEl,o=t.sortable,r=t.dragRect;1<ie.length&&(ie.forEach(function(t){o.addAnimationState({target:t,rect:le?X(t):r}),T(t),t.fromRect=r,e.removeAnimationState(t)}),le=!1,function(n,o){ie.forEach(function(t){var e=o.children[t.sortableIndex+(n?Number(i):0)];e?o.insertBefore(t,e):o.appendChild(t)})}(!o.options.removeCloneOnHide,n))},dragOverCompleted:function(t){var e=t.sortable,n=t.isOwner,o=t.insertion,i=t.activeSortable,r=t.parentEl,a=t.putSortable,l=e.options;if(o){if(n&&i._hideClone(),ae=!1,l.animation&&1<ie.length&&(le||!n&&!i.options.sort&&!a)){var s=X(ee,!1,!0,!0);ie.forEach(function(t){t!==ee&&(C(t,s),r.appendChild(t))}),le=!0}if(!n)if(le||ue(),1<ie.length){var c=oe;i._showClone(e),i.options.animation&&!oe&&c&&re.forEach(function(t){i.addAnimationState({target:t,rect:ne}),t.fromRect=ne,t.thisAnimationDuration=null})}else i._showClone(e)}},dragOverAnimationCapture:function(t){var e=t.dragRect,n=t.isOwner,o=t.activeSortable;if(ie.forEach(function(t){t.thisAnimationDuration=null}),o.options.animation&&!n&&o.multiDrag.isMultiDrag){ne=a({},e);var i=v(ee,!0);ne.top-=i.f,ne.left-=i.e}},dragOverAnimationComplete:function(){le&&(le=!1,ue())},drop:function(t){var e=t.originalEvent,n=t.rootEl,o=t.parentEl,i=t.sortable,r=t.dispatchSortableEvent,a=t.oldIndex,l=t.putSortable,s=l||this.sortable;if(e){var c=i.options,u=o.children;if(!se)if(c.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag(),P(ee,c.selectedClass,!~ie.indexOf(ee)),~ie.indexOf(ee))ie.splice(ie.indexOf(ee),1),Jt=null,K({sortable:i,rootEl:n,name:"deselect",targetEl:ee,originalEvt:e});else{if(ie.push(ee),K({sortable:i,rootEl:n,name:"select",targetEl:ee,originalEvt:e}),(!c.multiDragKey||this.multiDragKeyDown)&&e.shiftKey&&Jt&&i.el.contains(Jt)){var d,h,f=F(Jt),p=F(ee);if(~f&&~p&&f!==p)for(d=f<p?(h=f,p):(h=p,f+1);h<d;h++)~ie.indexOf(u[h])||(P(u[h],c.selectedClass,!0),ie.push(u[h]),K({sortable:i,rootEl:n,name:"select",targetEl:u[h],originalEvt:e}))}else Jt=ee;te=s}if(se&&this.isMultiDrag){if((o[L].options.sort||o!==n)&&1<ie.length){var g=X(ee),v=F(ee,":not(."+this.options.selectedClass+")");if(!ae&&c.animation&&(ee.thisAnimationDuration=null),s.captureAnimationState(),!ae&&(c.animation&&(ee.fromRect=g,ie.forEach(function(t){if(t.thisAnimationDuration=null,t!==ee){var e=le?X(t):g;t.fromRect=e,s.addAnimationState({target:t,rect:e})}})),ue(),ie.forEach(function(t){u[v]?o.insertBefore(t,u[v]):o.appendChild(t),v++}),a===F(ee))){var m=!1;ie.forEach(function(t){t.sortableIndex===F(t)||(m=!0)}),m&&r("update")}ie.forEach(function(t){T(t)}),s.animateAll()}te=s}(n===o||l&&"clone"!==l.lastPutMode)&&re.forEach(function(t){t.parentNode&&t.parentNode.removeChild(t)})}},nullingGlobal:function(){this.isMultiDrag=se=!1,re.length=0},destroy:function(){this._deselectMultiDrag(),h(document,"pointerup",this._deselectMultiDrag),h(document,"mouseup",this._deselectMultiDrag),h(document,"touchend",this._deselectMultiDrag),h(document,"keydown",this._checkKeyDown),h(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if(!se&&te===this.sortable&&!(t&&k(t.target,this.sortable.options.draggable,this.sortable.el,!1)||t&&0!==t.button))for(;ie.length;){var e=ie[0];P(e,this.sortable.options.selectedClass,!1),ie.shift(),K({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:e,originalEvt:t})}},_checkKeyDown:function(t){t.key===this.sortable.options.multiDragKey&&(this.multiDragKeyDown=!0)},_checkKeyUp:function(t){t.key===this.sortable.options.multiDragKey&&(this.multiDragKeyDown=!1)}},a(t,{pluginName:"multiDrag",utils:{select:function(t){var e=t.parentNode[L];e&&e.options.multiDrag&&!~ie.indexOf(t)&&(te&&te!==e&&(te.multiDrag._deselectMultiDrag(),te=e),P(t,e.options.selectedClass,!0),ie.push(t))},deselect:function(t){var e=t.parentNode[L],n=ie.indexOf(t);e&&e.options.multiDrag&&~n&&(P(t,e.options.selectedClass,!1),ie.splice(n,1))}},eventOptions:function(){var n=this,o=[],i=[];return ie.forEach(function(t){var e;o.push({multiDragElement:t,index:t.sortableIndex}),e=le&&t!==ee?-1:le?F(t,":not(."+n.options.selectedClass+")"):F(t),i.push({multiDragElement:t,index:e})}),{items:e(ie),clones:[].concat(re),oldIndicies:o,newIndicies:i}},optionListeners:{multiDragKey:function(t){return"ctrl"===(t=t.toLowerCase())?t="Control":1<t.length&&(t=t.charAt(0).toUpperCase()+t.substr(1)),t}}})}),Nt});