sortable.esm-34b12dd8.js 45 KB

123456789101112
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.82
  5. */
  6. /**!
  7. * Sortable 1.15.0
  8. * @author RubaXa <trash@rubaxa.org>
  9. * @author owenm <owen23355@gmail.com>
  10. * @license MIT
  11. */
  12. function ownKeys(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);if(t){n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))}o.push.apply(o,n)}return o}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var o=arguments[t]!=null?arguments[t]:{};if(t%2){ownKeys(Object(o),true).forEach((function(t){_defineProperty(e,t,o[t])}))}else if(Object.getOwnPropertyDescriptors){Object.defineProperties(e,Object.getOwnPropertyDescriptors(o))}else{ownKeys(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}}return e}function _typeof(e){"@babel/helpers - typeof";if(typeof Symbol==="function"&&typeof Symbol.iterator==="symbol"){_typeof=function(e){return typeof e}}else{_typeof=function(e){return e&&typeof Symbol==="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e}}return _typeof(e)}function _defineProperty(e,t,o){if(t in e){Object.defineProperty(e,t,{value:o,enumerable:true,configurable:true,writable:true})}else{e[t]=o}return e}function _extends(){_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var o=arguments[t];for(var n in o){if(Object.prototype.hasOwnProperty.call(o,n)){e[n]=o[n]}}}return e};return _extends.apply(this,arguments)}function _objectWithoutPropertiesLoose(e,t){if(e==null)return{};var o={};var n=Object.keys(e);var r,l;for(l=0;l<n.length;l++){r=n[l];if(t.indexOf(r)>=0)continue;o[r]=e[r]}return o}function _objectWithoutProperties(e,t){if(e==null)return{};var o=_objectWithoutPropertiesLoose(e,t);var n,r;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++){n=l[r];if(t.indexOf(n)>=0)continue;if(!Object.prototype.propertyIsEnumerable.call(e,n))continue;o[n]=e[n]}}return o}var version="1.15.0";function userAgent(e){if(typeof window!=="undefined"&&window.navigator){return!!navigator.userAgent.match(e)}}var IE11OrLess=userAgent(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i);var Edge=userAgent(/Edge/i);var FireFox=userAgent(/firefox/i);var Safari=userAgent(/safari/i)&&!userAgent(/chrome/i)&&!userAgent(/android/i);var IOS=userAgent(/iP(ad|od|hone)/i);var ChromeForAndroid=userAgent(/chrome/i)&&userAgent(/android/i);var captureMode={capture:false,passive:false};function on(e,t,o){e.addEventListener(t,o,!IE11OrLess&&captureMode)}function off(e,t,o){e.removeEventListener(t,o,!IE11OrLess&&captureMode)}function matches(e,t){if(!t)return;t[0]===">"&&(t=t.substring(1));if(e){try{if(e.matches){return e.matches(t)}else if(e.msMatchesSelector){return e.msMatchesSelector(t)}else if(e.webkitMatchesSelector){return e.webkitMatchesSelector(t)}}catch(e){return false}}return false}function getParentOrHost(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function closest(e,t,o,n){if(e){o=o||document;do{if(t!=null&&(t[0]===">"?e.parentNode===o&&matches(e,t):matches(e,t))||n&&e===o){return e}if(e===o)break}while(e=getParentOrHost(e))}return null}var R_SPACE=/\s+/g;function toggleClass(e,t,o){if(e&&t){if(e.classList){e.classList[o?"add":"remove"](t)}else{var n=(" "+e.className+" ").replace(R_SPACE," ").replace(" "+t+" "," ");e.className=(n+(o?" "+t:"")).replace(R_SPACE," ")}}}function css(e,t,o){var n=e&&e.style;if(n){if(o===void 0){if(document.defaultView&&document.defaultView.getComputedStyle){o=document.defaultView.getComputedStyle(e,"")}else if(e.currentStyle){o=e.currentStyle}return t===void 0?o:o[t]}else{if(!(t in n)&&t.indexOf("webkit")===-1){t="-webkit-"+t}n[t]=o+(typeof o==="string"?"":"px")}}}function matrix(e,t){var o="";if(typeof e==="string"){o=e}else{do{var n=css(e,"transform");if(n&&n!=="none"){o=n+" "+o}}while(!t&&(e=e.parentNode))}var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(o)}function find(e,t,o){if(e){var n=e.getElementsByTagName(t),r=0,l=n.length;if(o){for(;r<l;r++){o(n[r],r)}}return n}return[]}function getWindowScrollingElement(){var e=document.scrollingElement;if(e){return e}else{return document.documentElement}}function getRect(e,t,o,n,r){if(!e.getBoundingClientRect&&e!==window)return;var l,a,i,s,c,u,d;if(e!==window&&e.parentNode&&e!==getWindowScrollingElement()){l=e.getBoundingClientRect();a=l.top;i=l.left;s=l.bottom;c=l.right;u=l.height;d=l.width}else{a=0;i=0;s=window.innerHeight;c=window.innerWidth;u=window.innerHeight;d=window.innerWidth}if((t||o)&&e!==window){r=r||e.parentNode;if(!IE11OrLess){do{if(r&&r.getBoundingClientRect&&(css(r,"transform")!=="none"||o&&css(r,"position")!=="static")){var f=r.getBoundingClientRect();a-=f.top+parseInt(css(r,"border-top-width"));i-=f.left+parseInt(css(r,"border-left-width"));s=a+l.height;c=i+l.width;break}}while(r=r.parentNode)}}if(n&&e!==window){var g=matrix(r||e),h=g&&g.a,p=g&&g.d;if(g){a/=p;i/=h;d/=h;u/=p;s=a+u;c=i+d}}return{top:a,left:i,bottom:s,right:c,width:d,height:u}}function isScrolledPast(e,t,o){var n=getParentAutoScrollElement(e,true),r=getRect(e)[t];while(n){var l=getRect(n)[o],a=void 0;if(o==="top"||o==="left"){a=r>=l}else{a=r<=l}if(!a)return n;if(n===getWindowScrollingElement())break;n=getParentAutoScrollElement(n,false)}return false}function getChild(e,t,o,n){var r=0,l=0,a=e.children;while(l<a.length){if(a[l].style.display!=="none"&&a[l]!==Sortable.ghost&&(n||a[l]!==Sortable.dragged)&&closest(a[l],o.draggable,e,false)){if(r===t){return a[l]}r++}l++}return null}function lastChild(e,t){var o=e.lastElementChild;while(o&&(o===Sortable.ghost||css(o,"display")==="none"||t&&!matches(o,t))){o=o.previousElementSibling}return o||null}function index(e,t){var o=0;if(!e||!e.parentNode){return-1}while(e=e.previousElementSibling){if(e.nodeName.toUpperCase()!=="TEMPLATE"&&e!==Sortable.clone&&(!t||matches(e,t))){o++}}return o}function getRelativeScrollOffset(e){var t=0,o=0,n=getWindowScrollingElement();if(e){do{var r=matrix(e),l=r.a,a=r.d;t+=e.scrollLeft*l;o+=e.scrollTop*a}while(e!==n&&(e=e.parentNode))}return[t,o]}function indexOfObject(e,t){for(var o in e){if(!e.hasOwnProperty(o))continue;for(var n in t){if(t.hasOwnProperty(n)&&t[n]===e[o][n])return Number(o)}}return-1}function getParentAutoScrollElement(e,t){if(!e||!e.getBoundingClientRect)return getWindowScrollingElement();var o=e;var n=false;do{if(o.clientWidth<o.scrollWidth||o.clientHeight<o.scrollHeight){var r=css(o);if(o.clientWidth<o.scrollWidth&&(r.overflowX=="auto"||r.overflowX=="scroll")||o.clientHeight<o.scrollHeight&&(r.overflowY=="auto"||r.overflowY=="scroll")){if(!o.getBoundingClientRect||o===document.body)return getWindowScrollingElement();if(n||t)return o;n=true}}}while(o=o.parentNode);return getWindowScrollingElement()}function extend(e,t){if(e&&t){for(var o in t){if(t.hasOwnProperty(o)){e[o]=t[o]}}}return e}function isRectEqual(e,t){return Math.round(e.top)===Math.round(t.top)&&Math.round(e.left)===Math.round(t.left)&&Math.round(e.height)===Math.round(t.height)&&Math.round(e.width)===Math.round(t.width)}var _throttleTimeout;function throttle(e,t){return function(){if(!_throttleTimeout){var o=arguments,n=this;if(o.length===1){e.call(n,o[0])}else{e.apply(n,o)}_throttleTimeout=setTimeout((function(){_throttleTimeout=void 0}),t)}}}function cancelThrottle(){clearTimeout(_throttleTimeout);_throttleTimeout=void 0}function scrollBy(e,t,o){e.scrollLeft+=t;e.scrollTop+=o}function clone(e){var t=window.Polymer;var o=window.jQuery||window.Zepto;if(t&&t.dom){return t.dom(e).cloneNode(true)}else if(o){return o(e).clone(true)[0]}else{return e.cloneNode(true)}}var expando="Sortable"+(new Date).getTime();function AnimationStateManager(){var e=[],t;return{captureAnimationState:function t(){e=[];if(!this.options.animation)return;var o=[].slice.call(this.el.children);o.forEach((function(t){if(css(t,"display")==="none"||t===Sortable.ghost)return;e.push({target:t,rect:getRect(t)});var o=_objectSpread2({},e[e.length-1].rect);if(t.thisAnimationDuration){var n=matrix(t,true);if(n){o.top-=n.f;o.left-=n.e}}t.fromRect=o}))},addAnimationState:function t(o){e.push(o)},removeAnimationState:function t(o){e.splice(indexOfObject(e,{target:o}),1)},animateAll:function o(n){var r=this;if(!this.options.animation){clearTimeout(t);if(typeof n==="function")n();return}var l=false,a=0;e.forEach((function(e){var t=0,o=e.target,n=o.fromRect,i=getRect(o),s=o.prevFromRect,c=o.prevToRect,u=e.rect,d=matrix(o,true);if(d){i.top-=d.f;i.left-=d.e}o.toRect=i;if(o.thisAnimationDuration){if(isRectEqual(s,i)&&!isRectEqual(n,i)&&(u.top-i.top)/(u.left-i.left)===(n.top-i.top)/(n.left-i.left)){t=calculateRealTime(u,s,c,r.options)}}if(!isRectEqual(i,n)){o.prevFromRect=n;o.prevToRect=i;if(!t){t=r.options.animation}r.animate(o,u,i,t)}if(t){l=true;a=Math.max(a,t);clearTimeout(o.animationResetTimer);o.animationResetTimer=setTimeout((function(){o.animationTime=0;o.prevFromRect=null;o.fromRect=null;o.prevToRect=null;o.thisAnimationDuration=null}),t);o.thisAnimationDuration=t}}));clearTimeout(t);if(!l){if(typeof n==="function")n()}else{t=setTimeout((function(){if(typeof n==="function")n()}),a)}e=[]},animate:function e(t,o,n,r){if(r){css(t,"transition","");css(t,"transform","");var l=matrix(this.el),a=l&&l.a,i=l&&l.d,s=(o.left-n.left)/(a||1),c=(o.top-n.top)/(i||1);t.animatingX=!!s;t.animatingY=!!c;css(t,"transform","translate3d("+s+"px,"+c+"px,0)");this.forRepaintDummy=repaint(t);css(t,"transition","transform "+r+"ms"+(this.options.easing?" "+this.options.easing:""));css(t,"transform","translate3d(0,0,0)");typeof t.animated==="number"&&clearTimeout(t.animated);t.animated=setTimeout((function(){css(t,"transition","");css(t,"transform","");t.animated=false;t.animatingX=false;t.animatingY=false}),r)}}}}function repaint(e){return e.offsetWidth}function calculateRealTime(e,t,o,n){return Math.sqrt(Math.pow(t.top-e.top,2)+Math.pow(t.left-e.left,2))/Math.sqrt(Math.pow(t.top-o.top,2)+Math.pow(t.left-o.left,2))*n.animation}var plugins=[];var defaults={initializeByDefault:true};var PluginManager={mount:function e(t){for(var o in defaults){if(defaults.hasOwnProperty(o)&&!(o in t)){t[o]=defaults[o]}}plugins.forEach((function(e){if(e.pluginName===t.pluginName){throw"Sortable: Cannot mount plugin ".concat(t.pluginName," more than once")}}));plugins.push(t)},pluginEvent:function e(t,o,n){var r=this;this.eventCanceled=false;n.cancel=function(){r.eventCanceled=true};var l=t+"Global";plugins.forEach((function(e){if(!o[e.pluginName])return;if(o[e.pluginName][l]){o[e.pluginName][l](_objectSpread2({sortable:o},n))}if(o.options[e.pluginName]&&o[e.pluginName][t]){o[e.pluginName][t](_objectSpread2({sortable:o},n))}}))},initializePlugins:function e(t,o,n,r){plugins.forEach((function(e){var r=e.pluginName;if(!t.options[r]&&!e.initializeByDefault)return;var l=new e(t,o,t.options);l.sortable=t;l.options=t.options;t[r]=l;_extends(n,l.defaults)}));for(var l in t.options){if(!t.options.hasOwnProperty(l))continue;var a=this.modifyOption(t,l,t.options[l]);if(typeof a!=="undefined"){t.options[l]=a}}},getEventProperties:function e(t,o){var n={};plugins.forEach((function(e){if(typeof e.eventProperties!=="function")return;_extends(n,e.eventProperties.call(o[e.pluginName],t))}));return n},modifyOption:function e(t,o,n){var r;plugins.forEach((function(e){if(!t[e.pluginName])return;if(e.optionListeners&&typeof e.optionListeners[o]==="function"){r=e.optionListeners[o].call(t[e.pluginName],n)}}));return r}};function dispatchEvent(e){var t=e.sortable,o=e.rootEl,n=e.name,r=e.targetEl,l=e.cloneEl,a=e.toEl,i=e.fromEl,s=e.oldIndex,c=e.newIndex,u=e.oldDraggableIndex,d=e.newDraggableIndex,f=e.originalEvent,g=e.putSortable,h=e.extraEventProperties;t=t||o&&o[expando];if(!t)return;var p,v=t.options,E="on"+n.charAt(0).toUpperCase()+n.substr(1);if(window.CustomEvent&&!IE11OrLess&&!Edge){p=new CustomEvent(n,{bubbles:true,cancelable:true})}else{p=document.createEvent("Event");p.initEvent(n,true,true)}p.to=a||o;p.from=i||o;p.item=r||o;p.clone=l;p.oldIndex=s;p.newIndex=c;p.oldDraggableIndex=u;p.newDraggableIndex=d;p.originalEvent=f;p.pullMode=g?g.lastPutMode:undefined;var m=_objectSpread2(_objectSpread2({},h),PluginManager.getEventProperties(n,t));for(var b in m){p[b]=m[b]}if(o){o.dispatchEvent(p)}if(v[E]){v[E].call(t,p)}}var _excluded=["evt"];var pluginEvent=function e(t,o){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{},r=n.evt,l=_objectWithoutProperties(n,_excluded);PluginManager.pluginEvent.bind(Sortable)(t,o,_objectSpread2({dragEl:dragEl,parentEl:parentEl,ghostEl:ghostEl,rootEl:rootEl,nextEl:nextEl,lastDownEl:lastDownEl,cloneEl:cloneEl,cloneHidden:cloneHidden,dragStarted:moved,putSortable:putSortable,activeSortable:Sortable.active,originalEvent:r,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex,hideGhostForTarget:_hideGhostForTarget,unhideGhostForTarget:_unhideGhostForTarget,cloneNowHidden:function e(){cloneHidden=true},cloneNowShown:function e(){cloneHidden=false},dispatchSortableEvent:function e(t){_dispatchEvent({sortable:o,name:t,originalEvent:r})}},l))};function _dispatchEvent(e){dispatchEvent(_objectSpread2({putSortable:putSortable,cloneEl:cloneEl,targetEl:dragEl,rootEl:rootEl,oldIndex:oldIndex,oldDraggableIndex:oldDraggableIndex,newIndex:newIndex,newDraggableIndex:newDraggableIndex},e))}var dragEl,parentEl,ghostEl,rootEl,nextEl,lastDownEl,cloneEl,cloneHidden,oldIndex,newIndex,oldDraggableIndex,newDraggableIndex,activeGroup,putSortable,awaitingDragStarted=false,ignoreNextClick=false,sortables=[],tapEvt,touchEvt,lastDx,lastDy,tapDistanceLeft,tapDistanceTop,moved,lastTarget,lastDirection,pastFirstInvertThresh=false,isCircumstantialInvert=false,targetMoveDistance,ghostRelativeParent,ghostRelativeParentInitialScroll=[],_silent=false,savedInputChecked=[];var documentExists=typeof document!=="undefined",PositionGhostAbsolutely=IOS,CSSFloatProperty=Edge||IE11OrLess?"cssFloat":"float",supportDraggable=documentExists&&!ChromeForAndroid&&!IOS&&"draggable"in document.createElement("div"),supportCssPointerEvents=function(){if(!documentExists)return;if(IE11OrLess){return false}var e=document.createElement("x");e.style.cssText="pointer-events:auto";return e.style.pointerEvents==="auto"}(),_detectDirection=function e(t,o){var n=css(t),r=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),l=getChild(t,0,o),a=getChild(t,1,o),i=l&&css(l),s=a&&css(a),c=i&&parseInt(i.marginLeft)+parseInt(i.marginRight)+getRect(l).width,u=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+getRect(a).width;if(n.display==="flex"){return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal"}if(n.display==="grid"){return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal"}if(l&&i["float"]&&i["float"]!=="none"){var d=i["float"]==="left"?"left":"right";return a&&(s.clear==="both"||s.clear===d)?"vertical":"horizontal"}return l&&(i.display==="block"||i.display==="flex"||i.display==="table"||i.display==="grid"||c>=r&&n[CSSFloatProperty]==="none"||a&&n[CSSFloatProperty]==="none"&&c+u>r)?"vertical":"horizontal"},_dragElInRowColumn=function e(t,o,n){var r=n?t.left:t.top,l=n?t.right:t.bottom,a=n?t.width:t.height,i=n?o.left:o.top,s=n?o.right:o.bottom,c=n?o.width:o.height;return r===i||l===s||r+a/2===i+c/2},_detectNearestEmptySortable=function e(t,o){var n;sortables.some((function(e){var r=e[expando].options.emptyInsertThreshold;if(!r||lastChild(e))return;var l=getRect(e),a=t>=l.left-r&&t<=l.right+r,i=o>=l.top-r&&o<=l.bottom+r;if(a&&i){return n=e}}));return n},_prepareGroup=function e(t){function o(e,t){return function(n,r,l,a){var i=n.options.group.name&&r.options.group.name&&n.options.group.name===r.options.group.name;if(e==null&&(t||i)){return true}else if(e==null||e===false){return false}else if(t&&e==="clone"){return e}else if(typeof e==="function"){return o(e(n,r,l,a),t)(n,r,l,a)}else{var s=(t?n:r).options.group.name;return e===true||typeof e==="string"&&e===s||e.join&&e.indexOf(s)>-1}}}var n={};var r=t.group;if(!r||_typeof(r)!="object"){r={name:r}}n.name=r.name;n.checkPull=o(r.pull,true);n.checkPut=o(r.put);n.revertClone=r.revertClone;t.group=n},_hideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","none")}},_unhideGhostForTarget=function e(){if(!supportCssPointerEvents&&ghostEl){css(ghostEl,"display","")}};if(documentExists&&!ChromeForAndroid){document.addEventListener("click",(function(e){if(ignoreNextClick){e.preventDefault();e.stopPropagation&&e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();ignoreNextClick=false;return false}}),true)}var nearestEmptyInsertDetectEvent=function e(t){if(dragEl){t=t.touches?t.touches[0]:t;var o=_detectNearestEmptySortable(t.clientX,t.clientY);if(o){var n={};for(var r in t){if(t.hasOwnProperty(r)){n[r]=t[r]}}n.target=n.rootEl=o;n.preventDefault=void 0;n.stopPropagation=void 0;o[expando]._onDragOver(n)}}};var _checkOutsideTargetEl=function e(t){if(dragEl){dragEl.parentNode[expando]._isOutsideThisEl(t.target)}};function Sortable(e,t){if(!(e&&e.nodeType&&e.nodeType===1)){throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e))}this.el=e;this.options=t=_extends({},t);e[expando]=this;var o={group:null,sort:true,disabled:false,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:false,invertedSwapThreshold:null,removeCloneOnHide:true,direction:function t(){return _detectDirection(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:true,animation:0,easing:null,setData:function e(t,o){t.setData("Text",o.textContent)},dropBubble:false,dragoverBubble:false,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:false,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:false,fallbackClass:"sortable-fallback",fallbackOnBody:false,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Sortable.supportPointer!==false&&"PointerEvent"in window&&!Safari,emptyInsertThreshold:5};PluginManager.initializePlugins(this,e,o);for(var n in o){!(n in t)&&(t[n]=o[n])}_prepareGroup(t);for(var r in this){if(r.charAt(0)==="_"&&typeof this[r]==="function"){this[r]=this[r].bind(this)}}this.nativeDraggable=t.forceFallback?false:supportDraggable;if(this.nativeDraggable){this.options.touchStartThreshold=1}if(t.supportPointer){on(e,"pointerdown",this._onTapStart)}else{on(e,"mousedown",this._onTapStart);on(e,"touchstart",this._onTapStart)}if(this.nativeDraggable){on(e,"dragover",this);on(e,"dragenter",this)}sortables.push(this.el);t.store&&t.store.get&&this.sort(t.store.get(this)||[]);_extends(this,AnimationStateManager())}Sortable.prototype={constructor:Sortable,_isOutsideThisEl:function e(t){if(!this.el.contains(t)&&t!==this.el){lastTarget=null}},_getDirection:function e(t,o){return typeof this.options.direction==="function"?this.options.direction.call(this,t,o,dragEl):this.options.direction},_onTapStart:function e(t){if(!t.cancelable)return;var o=this,n=this.el,r=this.options,l=r.preventOnFilter,a=t.type,i=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,s=(i||t).target,c=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,u=r.filter;_saveInputCheckedState(n);if(dragEl){return}if(/mousedown|pointerdown/.test(a)&&t.button!==0||r.disabled){return}if(c.isContentEditable){return}if(!this.nativeDraggable&&Safari&&s&&s.tagName.toUpperCase()==="SELECT"){return}s=closest(s,r.draggable,n,false);if(s&&s.animated){return}if(lastDownEl===s){return}oldIndex=index(s);oldDraggableIndex=index(s,r.draggable);if(typeof u==="function"){if(u.call(this,t,s,this)){_dispatchEvent({sortable:o,rootEl:c,name:"filter",targetEl:s,toEl:n,fromEl:n});pluginEvent("filter",o,{evt:t});l&&t.cancelable&&t.preventDefault();return}}else if(u){u=u.split(",").some((function(e){e=closest(c,e.trim(),n,false);if(e){_dispatchEvent({sortable:o,rootEl:e,name:"filter",targetEl:s,fromEl:n,toEl:n});pluginEvent("filter",o,{evt:t});return true}}));if(u){l&&t.cancelable&&t.preventDefault();return}}if(r.handle&&!closest(c,r.handle,n,false)){return}this._prepareDragStart(t,i,s)},_prepareDragStart:function e(t,o,n){var r=this,l=r.el,a=r.options,i=l.ownerDocument,s;if(n&&!dragEl&&n.parentNode===l){var c=getRect(n);rootEl=l;dragEl=n;parentEl=dragEl.parentNode;nextEl=dragEl.nextSibling;lastDownEl=n;activeGroup=a.group;Sortable.dragged=dragEl;tapEvt={target:dragEl,clientX:(o||t).clientX,clientY:(o||t).clientY};tapDistanceLeft=tapEvt.clientX-c.left;tapDistanceTop=tapEvt.clientY-c.top;this._lastX=(o||t).clientX;this._lastY=(o||t).clientY;dragEl.style["will-change"]="all";s=function e(){pluginEvent("delayEnded",r,{evt:t});if(Sortable.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents();if(!FireFox&&r.nativeDraggable){dragEl.draggable=true}r._triggerDragStart(t,o);_dispatchEvent({sortable:r,name:"choose",originalEvent:t});toggleClass(dragEl,a.chosenClass,true)};a.ignore.split(",").forEach((function(e){find(dragEl,e.trim(),_disableDraggable)}));on(i,"dragover",nearestEmptyInsertDetectEvent);on(i,"mousemove",nearestEmptyInsertDetectEvent);on(i,"touchmove",nearestEmptyInsertDetectEvent);on(i,"mouseup",r._onDrop);on(i,"touchend",r._onDrop);on(i,"touchcancel",r._onDrop);if(FireFox&&this.nativeDraggable){this.options.touchStartThreshold=4;dragEl.draggable=true}pluginEvent("delayStart",this,{evt:t});if(a.delay&&(!a.delayOnTouchOnly||o)&&(!this.nativeDraggable||!(Edge||IE11OrLess))){if(Sortable.eventCanceled){this._onDrop();return}on(i,"mouseup",r._disableDelayedDrag);on(i,"touchend",r._disableDelayedDrag);on(i,"touchcancel",r._disableDelayedDrag);on(i,"mousemove",r._delayedDragTouchMoveHandler);on(i,"touchmove",r._delayedDragTouchMoveHandler);a.supportPointer&&on(i,"pointermove",r._delayedDragTouchMoveHandler);r._dragStartTimer=setTimeout(s,a.delay)}else{s()}}},_delayedDragTouchMoveHandler:function e(t){var o=t.touches?t.touches[0]:t;if(Math.max(Math.abs(o.clientX-this._lastX),Math.abs(o.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))){this._disableDelayedDrag()}},_disableDelayedDrag:function e(){dragEl&&_disableDraggable(dragEl);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._disableDelayedDrag);off(t,"touchend",this._disableDelayedDrag);off(t,"touchcancel",this._disableDelayedDrag);off(t,"mousemove",this._delayedDragTouchMoveHandler);off(t,"touchmove",this._delayedDragTouchMoveHandler);off(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function e(t,o){o=o||t.pointerType=="touch"&&t;if(!this.nativeDraggable||o){if(this.options.supportPointer){on(document,"pointermove",this._onTouchMove)}else if(o){on(document,"touchmove",this._onTouchMove)}else{on(document,"mousemove",this._onTouchMove)}}else{on(dragEl,"dragend",this);on(rootEl,"dragstart",this._onDragStart)}try{if(document.selection){_nextTick((function(){document.selection.empty()}))}else{window.getSelection().removeAllRanges()}}catch(e){}},_dragStarted:function e(t,o){awaitingDragStarted=false;if(rootEl&&dragEl){pluginEvent("dragStarted",this,{evt:o});if(this.nativeDraggable){on(document,"dragover",_checkOutsideTargetEl)}var n=this.options;!t&&toggleClass(dragEl,n.dragClass,false);toggleClass(dragEl,n.ghostClass,true);Sortable.active=this;t&&this._appendGhost();_dispatchEvent({sortable:this,name:"start",originalEvent:o})}else{this._nulling()}},_emulateDragOver:function e(){if(touchEvt){this._lastX=touchEvt.clientX;this._lastY=touchEvt.clientY;_hideGhostForTarget();var t=document.elementFromPoint(touchEvt.clientX,touchEvt.clientY);var o=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(touchEvt.clientX,touchEvt.clientY);if(t===o)break;o=t}dragEl.parentNode[expando]._isOutsideThisEl(t);if(o){do{if(o[expando]){var n=void 0;n=o[expando]._onDragOver({clientX:touchEvt.clientX,clientY:touchEvt.clientY,target:t,rootEl:o});if(n&&!this.options.dragoverBubble){break}}t=o}while(o=o.parentNode)}_unhideGhostForTarget()}},_onTouchMove:function e(t){if(tapEvt){var o=this.options,n=o.fallbackTolerance,r=o.fallbackOffset,l=t.touches?t.touches[0]:t,a=ghostEl&&matrix(ghostEl,true),i=ghostEl&&a&&a.a,s=ghostEl&&a&&a.d,c=PositionGhostAbsolutely&&ghostRelativeParent&&getRelativeScrollOffset(ghostRelativeParent),u=(l.clientX-tapEvt.clientX+r.x)/(i||1)+(c?c[0]-ghostRelativeParentInitialScroll[0]:0)/(i||1),d=(l.clientY-tapEvt.clientY+r.y)/(s||1)+(c?c[1]-ghostRelativeParentInitialScroll[1]:0)/(s||1);if(!Sortable.active&&!awaitingDragStarted){if(n&&Math.max(Math.abs(l.clientX-this._lastX),Math.abs(l.clientY-this._lastY))<n){return}this._onDragStart(t,true)}if(ghostEl){if(a){a.e+=u-(lastDx||0);a.f+=d-(lastDy||0)}else{a={a:1,b:0,c:0,d:1,e:u,f:d}}var f="matrix(".concat(a.a,",").concat(a.b,",").concat(a.c,",").concat(a.d,",").concat(a.e,",").concat(a.f,")");css(ghostEl,"webkitTransform",f);css(ghostEl,"mozTransform",f);css(ghostEl,"msTransform",f);css(ghostEl,"transform",f);lastDx=u;lastDy=d;touchEvt=l}t.cancelable&&t.preventDefault()}},_appendGhost:function e(){if(!ghostEl){var t=this.options.fallbackOnBody?document.body:rootEl,o=getRect(dragEl,true,PositionGhostAbsolutely,true,t),n=this.options;if(PositionGhostAbsolutely){ghostRelativeParent=t;while(css(ghostRelativeParent,"position")==="static"&&css(ghostRelativeParent,"transform")==="none"&&ghostRelativeParent!==document){ghostRelativeParent=ghostRelativeParent.parentNode}if(ghostRelativeParent!==document.body&&ghostRelativeParent!==document.documentElement){if(ghostRelativeParent===document)ghostRelativeParent=getWindowScrollingElement();o.top+=ghostRelativeParent.scrollTop;o.left+=ghostRelativeParent.scrollLeft}else{ghostRelativeParent=getWindowScrollingElement()}ghostRelativeParentInitialScroll=getRelativeScrollOffset(ghostRelativeParent)}ghostEl=dragEl.cloneNode(true);toggleClass(ghostEl,n.ghostClass,false);toggleClass(ghostEl,n.fallbackClass,true);toggleClass(ghostEl,n.dragClass,true);css(ghostEl,"transition","");css(ghostEl,"transform","");css(ghostEl,"box-sizing","border-box");css(ghostEl,"margin",0);css(ghostEl,"top",o.top);css(ghostEl,"left",o.left);css(ghostEl,"width",o.width);css(ghostEl,"height",o.height);css(ghostEl,"opacity","0.8");css(ghostEl,"position",PositionGhostAbsolutely?"absolute":"fixed");css(ghostEl,"zIndex","100000");css(ghostEl,"pointerEvents","none");Sortable.ghost=ghostEl;t.appendChild(ghostEl);css(ghostEl,"transform-origin",tapDistanceLeft/parseInt(ghostEl.style.width)*100+"% "+tapDistanceTop/parseInt(ghostEl.style.height)*100+"%")}},_onDragStart:function e(t,o){var n=this;var r=t.dataTransfer;var l=n.options;pluginEvent("dragStart",this,{evt:t});if(Sortable.eventCanceled){this._onDrop();return}pluginEvent("setupClone",this);if(!Sortable.eventCanceled){cloneEl=clone(dragEl);cloneEl.removeAttribute("id");cloneEl.draggable=false;cloneEl.style["will-change"]="";this._hideClone();toggleClass(cloneEl,this.options.chosenClass,false);Sortable.clone=cloneEl}n.cloneId=_nextTick((function(){pluginEvent("clone",n);if(Sortable.eventCanceled)return;if(!n.options.removeCloneOnHide){rootEl.insertBefore(cloneEl,dragEl)}n._hideClone();_dispatchEvent({sortable:n,name:"clone"})}));!o&&toggleClass(dragEl,l.dragClass,true);if(o){ignoreNextClick=true;n._loopId=setInterval(n._emulateDragOver,50)}else{off(document,"mouseup",n._onDrop);off(document,"touchend",n._onDrop);off(document,"touchcancel",n._onDrop);if(r){r.effectAllowed="move";l.setData&&l.setData.call(n,r,dragEl)}on(document,"drop",n);css(dragEl,"transform","translateZ(0)")}awaitingDragStarted=true;n._dragStartId=_nextTick(n._dragStarted.bind(n,o,t));on(document,"selectstart",n);moved=true;if(Safari){css(document.body,"user-select","none")}},_onDragOver:function e(t){var o=this.el,n=t.target,r,l,a,i=this.options,s=i.group,c=Sortable.active,u=activeGroup===s,d=i.sort,f=putSortable||c,g,h=this,p=false;if(_silent)return;function v(e,i){pluginEvent(e,h,_objectSpread2({evt:t,isOwner:u,axis:g?"vertical":"horizontal",revert:a,dragRect:r,targetRect:l,canSort:d,fromSortable:f,target:n,completed:m,onMove:function e(n,l){return _onMove(rootEl,o,dragEl,r,n,getRect(n),t,l)},changed:b},i))}function E(){v("dragOverAnimationCapture");h.captureAnimationState();if(h!==f){f.captureAnimationState()}}function m(e){v("dragOverCompleted",{insertion:e});if(e){if(u){c._hideClone()}else{c._showClone(h)}if(h!==f){toggleClass(dragEl,putSortable?putSortable.options.ghostClass:c.options.ghostClass,false);toggleClass(dragEl,i.ghostClass,true)}if(putSortable!==h&&h!==Sortable.active){putSortable=h}else if(h===Sortable.active&&putSortable){putSortable=null}if(f===h){h._ignoreWhileAnimating=n}h.animateAll((function(){v("dragOverAnimationComplete");h._ignoreWhileAnimating=null}));if(h!==f){f.animateAll();f._ignoreWhileAnimating=null}}if(n===dragEl&&!dragEl.animated||n===o&&!n.animated){lastTarget=null}if(!i.dragoverBubble&&!t.rootEl&&n!==document){dragEl.parentNode[expando]._isOutsideThisEl(t.target);!e&&nearestEmptyInsertDetectEvent(t)}!i.dragoverBubble&&t.stopPropagation&&t.stopPropagation();return p=true}function b(){newIndex=index(dragEl);newDraggableIndex=index(dragEl,i.draggable);_dispatchEvent({sortable:h,name:"change",toEl:o,newIndex:newIndex,newDraggableIndex:newDraggableIndex,originalEvent:t})}if(t.preventDefault!==void 0){t.cancelable&&t.preventDefault()}n=closest(n,i.draggable,o,true);v("dragOver");if(Sortable.eventCanceled)return p;if(dragEl.contains(t.target)||n.animated&&n.animatingX&&n.animatingY||h._ignoreWhileAnimating===n){return m(false)}ignoreNextClick=false;if(c&&!i.disabled&&(u?d||(a=parentEl!==rootEl):putSortable===this||(this.lastPutMode=activeGroup.checkPull(this,c,dragEl,t))&&s.checkPut(this,c,dragEl,t))){g=this._getDirection(t,n)==="vertical";r=getRect(dragEl);v("dragOverValid");if(Sortable.eventCanceled)return p;if(a){parentEl=rootEl;E();this._hideClone();v("revert");if(!Sortable.eventCanceled){if(nextEl){rootEl.insertBefore(dragEl,nextEl)}else{rootEl.appendChild(dragEl)}}return m(true)}var S=lastChild(o,i.draggable);if(!S||_ghostIsLast(t,g,this)&&!S.animated){if(S===dragEl){return m(false)}if(S&&o===t.target){n=S}if(n){l=getRect(n)}if(_onMove(rootEl,o,dragEl,r,n,l,t,!!n)!==false){E();if(S&&S.nextSibling){o.insertBefore(dragEl,S.nextSibling)}else{o.appendChild(dragEl)}parentEl=o;b();return m(true)}}else if(S&&_ghostIsFirst(t,g,this)){var _=getChild(o,0,i,true);if(_===dragEl){return m(false)}n=_;l=getRect(n);if(_onMove(rootEl,o,dragEl,r,n,l,t,false)!==false){E();o.insertBefore(dragEl,_);parentEl=o;b();return m(true)}}else if(n.parentNode===o){l=getRect(n);var w=0,y,D=dragEl.parentNode!==o,x=!_dragElInRowColumn(dragEl.animated&&dragEl.toRect||r,n.animated&&n.toRect||l,g),I=g?"top":"left",C=isScrolledPast(n,"top","top")||isScrolledPast(dragEl,"top","top"),T=C?C.scrollTop:void 0;if(lastTarget!==n){y=l[I];pastFirstInvertThresh=false;isCircumstantialInvert=!x&&i.invertSwap||D}w=_getSwapDirection(t,n,l,g,x?1:i.swapThreshold,i.invertedSwapThreshold==null?i.swapThreshold:i.invertedSwapThreshold,isCircumstantialInvert,lastTarget===n);var P;if(w!==0){var A=index(dragEl);do{A-=w;P=parentEl.children[A]}while(P&&(css(P,"display")==="none"||P===ghostEl))}if(w===0||P===n){return m(false)}lastTarget=n;lastDirection=w;var R=n.nextElementSibling,O=false;O=w===1;var M=_onMove(rootEl,o,dragEl,r,n,l,t,O);if(M!==false){if(M===1||M===-1){O=M===1}_silent=true;setTimeout(_unsilent,30);E();if(O&&!R){o.appendChild(dragEl)}else{n.parentNode.insertBefore(dragEl,O?R:n)}if(C){scrollBy(C,0,T-C.scrollTop)}parentEl=dragEl.parentNode;if(y!==undefined&&!isCircumstantialInvert){targetMoveDistance=Math.abs(y-getRect(n)[I])}b();return m(true)}}if(o.contains(dragEl)){return m(false)}}return false},_ignoreWhileAnimating:null,_offMoveEvents:function e(){off(document,"mousemove",this._onTouchMove);off(document,"touchmove",this._onTouchMove);off(document,"pointermove",this._onTouchMove);off(document,"dragover",nearestEmptyInsertDetectEvent);off(document,"mousemove",nearestEmptyInsertDetectEvent);off(document,"touchmove",nearestEmptyInsertDetectEvent)},_offUpEvents:function e(){var t=this.el.ownerDocument;off(t,"mouseup",this._onDrop);off(t,"touchend",this._onDrop);off(t,"pointerup",this._onDrop);off(t,"touchcancel",this._onDrop);off(document,"selectstart",this)},_onDrop:function e(t){var o=this.el,n=this.options;newIndex=index(dragEl);newDraggableIndex=index(dragEl,n.draggable);pluginEvent("drop",this,{evt:t});parentEl=dragEl&&dragEl.parentNode;newIndex=index(dragEl);newDraggableIndex=index(dragEl,n.draggable);if(Sortable.eventCanceled){this._nulling();return}awaitingDragStarted=false;isCircumstantialInvert=false;pastFirstInvertThresh=false;clearInterval(this._loopId);clearTimeout(this._dragStartTimer);_cancelNextTick(this.cloneId);_cancelNextTick(this._dragStartId);if(this.nativeDraggable){off(document,"drop",this);off(o,"dragstart",this._onDragStart)}this._offMoveEvents();this._offUpEvents();if(Safari){css(document.body,"user-select","")}css(dragEl,"transform","");if(t){if(moved){t.cancelable&&t.preventDefault();!n.dropBubble&&t.stopPropagation()}ghostEl&&ghostEl.parentNode&&ghostEl.parentNode.removeChild(ghostEl);if(rootEl===parentEl||putSortable&&putSortable.lastPutMode!=="clone"){cloneEl&&cloneEl.parentNode&&cloneEl.parentNode.removeChild(cloneEl)}if(dragEl){if(this.nativeDraggable){off(dragEl,"dragend",this)}_disableDraggable(dragEl);dragEl.style["will-change"]="";if(moved&&!awaitingDragStarted){toggleClass(dragEl,putSortable?putSortable.options.ghostClass:this.options.ghostClass,false)}toggleClass(dragEl,this.options.chosenClass,false);_dispatchEvent({sortable:this,name:"unchoose",toEl:parentEl,newIndex:null,newDraggableIndex:null,originalEvent:t});if(rootEl!==parentEl){if(newIndex>=0){_dispatchEvent({rootEl:parentEl,name:"add",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"remove",toEl:parentEl,originalEvent:t});_dispatchEvent({rootEl:parentEl,name:"sort",toEl:parentEl,fromEl:rootEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}putSortable&&putSortable.save()}else{if(newIndex!==oldIndex){if(newIndex>=0){_dispatchEvent({sortable:this,name:"update",toEl:parentEl,originalEvent:t});_dispatchEvent({sortable:this,name:"sort",toEl:parentEl,originalEvent:t})}}}if(Sortable.active){if(newIndex==null||newIndex===-1){newIndex=oldIndex;newDraggableIndex=oldDraggableIndex}_dispatchEvent({sortable:this,name:"end",toEl:parentEl,originalEvent:t});this.save()}}}this._nulling()},_nulling:function e(){pluginEvent("nulling",this);rootEl=dragEl=parentEl=ghostEl=nextEl=cloneEl=lastDownEl=cloneHidden=tapEvt=touchEvt=moved=newIndex=newDraggableIndex=oldIndex=oldDraggableIndex=lastTarget=lastDirection=putSortable=activeGroup=Sortable.dragged=Sortable.ghost=Sortable.clone=Sortable.active=null;savedInputChecked.forEach((function(e){e.checked=true}));savedInputChecked.length=lastDx=lastDy=0},handleEvent:function e(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(dragEl){this._onDragOver(t);_globalDragOver(t)}break;case"selectstart":t.preventDefault();break}},toArray:function e(){var t=[],o,n=this.el.children,r=0,l=n.length,a=this.options;for(;r<l;r++){o=n[r];if(closest(o,a.draggable,this.el,false)){t.push(o.getAttribute(a.dataIdAttr)||_generateId(o))}}return t},sort:function e(t,o){var n={},r=this.el;this.toArray().forEach((function(e,t){var o=r.children[t];if(closest(o,this.options.draggable,r,false)){n[e]=o}}),this);o&&this.captureAnimationState();t.forEach((function(e){if(n[e]){r.removeChild(n[e]);r.appendChild(n[e])}}));o&&this.animateAll()},save:function e(){var t=this.options.store;t&&t.set&&t.set(this)},closest:function e(t,o){return closest(t,o||this.options.draggable,this.el,false)},option:function e(t,o){var n=this.options;if(o===void 0){return n[t]}else{var r=PluginManager.modifyOption(this,t,o);if(typeof r!=="undefined"){n[t]=r}else{n[t]=o}if(t==="group"){_prepareGroup(n)}}},destroy:function e(){pluginEvent("destroy",this);var t=this.el;t[expando]=null;off(t,"mousedown",this._onTapStart);off(t,"touchstart",this._onTapStart);off(t,"pointerdown",this._onTapStart);if(this.nativeDraggable){off(t,"dragover",this);off(t,"dragenter",this)}Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(e){e.removeAttribute("draggable")}));this._onDrop();this._disableDelayedDragEvents();sortables.splice(sortables.indexOf(this.el),1);this.el=t=null},_hideClone:function e(){if(!cloneHidden){pluginEvent("hideClone",this);if(Sortable.eventCanceled)return;css(cloneEl,"display","none");if(this.options.removeCloneOnHide&&cloneEl.parentNode){cloneEl.parentNode.removeChild(cloneEl)}cloneHidden=true}},_showClone:function e(t){if(t.lastPutMode!=="clone"){this._hideClone();return}if(cloneHidden){pluginEvent("showClone",this);if(Sortable.eventCanceled)return;if(dragEl.parentNode==rootEl&&!this.options.group.revertClone){rootEl.insertBefore(cloneEl,dragEl)}else if(nextEl){rootEl.insertBefore(cloneEl,nextEl)}else{rootEl.appendChild(cloneEl)}if(this.options.group.revertClone){this.animate(dragEl,cloneEl)}css(cloneEl,"display","");cloneHidden=false}}};function _globalDragOver(e){if(e.dataTransfer){e.dataTransfer.dropEffect="move"}e.cancelable&&e.preventDefault()}function _onMove(e,t,o,n,r,l,a,i){var s,c=e[expando],u=c.options.onMove,d;if(window.CustomEvent&&!IE11OrLess&&!Edge){s=new CustomEvent("move",{bubbles:true,cancelable:true})}else{s=document.createEvent("Event");s.initEvent("move",true,true)}s.to=t;s.from=e;s.dragged=o;s.draggedRect=n;s.related=r||t;s.relatedRect=l||getRect(t);s.willInsertAfter=i;s.originalEvent=a;e.dispatchEvent(s);if(u){d=u.call(c,s,a)}return d}function _disableDraggable(e){e.draggable=false}function _unsilent(){_silent=false}function _ghostIsFirst(e,t,o){var n=getRect(getChild(o.el,0,o.options,true));var r=10;return t?e.clientX<n.left-r||e.clientY<n.top&&e.clientX<n.right:e.clientY<n.top-r||e.clientY<n.bottom&&e.clientX<n.left}function _ghostIsLast(e,t,o){var n=getRect(lastChild(o.el,o.options.draggable));var r=10;return t?e.clientX>n.right+r||e.clientX<=n.right&&e.clientY>n.bottom&&e.clientX>=n.left:e.clientX>n.right&&e.clientY>n.top||e.clientX<=n.right&&e.clientY>n.bottom+r}function _getSwapDirection(e,t,o,n,r,l,a,i){var s=n?e.clientY:e.clientX,c=n?o.height:o.width,u=n?o.top:o.left,d=n?o.bottom:o.right,f=false;if(!a){if(i&&targetMoveDistance<c*r){if(!pastFirstInvertThresh&&(lastDirection===1?s>u+c*l/2:s<d-c*l/2)){pastFirstInvertThresh=true}if(!pastFirstInvertThresh){if(lastDirection===1?s<u+targetMoveDistance:s>d-targetMoveDistance){return-lastDirection}}else{f=true}}else{if(s>u+c*(1-r)/2&&s<d-c*(1-r)/2){return _getInsertDirection(t)}}}f=f||a;if(f){if(s<u+c*l/2||s>d-c*l/2){return s>u+c/2?1:-1}}return 0}function _getInsertDirection(e){if(index(dragEl)<index(e)){return 1}else{return-1}}function _generateId(e){var t=e.tagName+e.className+e.src+e.href+e.textContent,o=t.length,n=0;while(o--){n+=t.charCodeAt(o)}return n.toString(36)}function _saveInputCheckedState(e){savedInputChecked.length=0;var t=e.getElementsByTagName("input");var o=t.length;while(o--){var n=t[o];n.checked&&savedInputChecked.push(n)}}function _nextTick(e){return setTimeout(e,0)}function _cancelNextTick(e){return clearTimeout(e)}if(documentExists){on(document,"touchmove",(function(e){if((Sortable.active||awaitingDragStarted)&&e.cancelable){e.preventDefault()}}))}Sortable.utils={on:on,off:off,css:css,find:find,is:function e(t,o){return!!closest(t,o,t,false)},extend:extend,throttle:throttle,closest:closest,toggleClass:toggleClass,clone:clone,index:index,nextTick:_nextTick,cancelNextTick:_cancelNextTick,detectDirection:_detectDirection,getChild:getChild};Sortable.get=function(e){return e[expando]};Sortable.mount=function(){for(var e=arguments.length,t=new Array(e),o=0;o<e;o++){t[o]=arguments[o]}if(t[0].constructor===Array)t=t[0];t.forEach((function(e){if(!e.prototype||!e.prototype.constructor){throw"Sortable: Mounted plugin must be a constructor function, not ".concat({}.toString.call(e))}if(e.utils)Sortable.utils=_objectSpread2(_objectSpread2({},Sortable.utils),e.utils);PluginManager.mount(e)}))};Sortable.create=function(e,t){return new Sortable(e,t)};Sortable.version=version;var autoScrolls=[],scrollEl,scrollRootEl,scrolling=false,lastAutoScrollX,lastAutoScrollY,touchEvt$1,pointerElemChangedInterval;function AutoScrollPlugin(){function e(){this.defaults={scroll:true,forceAutoScrollFallback:false,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:true};for(var e in this){if(e.charAt(0)==="_"&&typeof this[e]==="function"){this[e]=this[e].bind(this)}}}e.prototype={dragStarted:function e(t){var o=t.originalEvent;if(this.sortable.nativeDraggable){on(document,"dragover",this._handleAutoScroll)}else{if(this.options.supportPointer){on(document,"pointermove",this._handleFallbackAutoScroll)}else if(o.touches){on(document,"touchmove",this._handleFallbackAutoScroll)}else{on(document,"mousemove",this._handleFallbackAutoScroll)}}},dragOverCompleted:function e(t){var o=t.originalEvent;if(!this.options.dragOverBubble&&!o.rootEl){this._handleAutoScroll(o)}},drop:function e(){if(this.sortable.nativeDraggable){off(document,"dragover",this._handleAutoScroll)}else{off(document,"pointermove",this._handleFallbackAutoScroll);off(document,"touchmove",this._handleFallbackAutoScroll);off(document,"mousemove",this._handleFallbackAutoScroll)}clearPointerElemChangedInterval();clearAutoScrolls();cancelThrottle()},nulling:function e(){touchEvt$1=scrollRootEl=scrollEl=scrolling=pointerElemChangedInterval=lastAutoScrollX=lastAutoScrollY=null;autoScrolls.length=0},_handleFallbackAutoScroll:function e(t){this._handleAutoScroll(t,true)},_handleAutoScroll:function e(t,o){var n=this;var r=(t.touches?t.touches[0]:t).clientX,l=(t.touches?t.touches[0]:t).clientY,a=document.elementFromPoint(r,l);touchEvt$1=t;if(o||this.options.forceAutoScrollFallback||Edge||IE11OrLess||Safari){autoScroll(t,this.options,a,o);var i=getParentAutoScrollElement(a,true);if(scrolling&&(!pointerElemChangedInterval||r!==lastAutoScrollX||l!==lastAutoScrollY)){pointerElemChangedInterval&&clearPointerElemChangedInterval();pointerElemChangedInterval=setInterval((function(){var e=getParentAutoScrollElement(document.elementFromPoint(r,l),true);if(e!==i){i=e;clearAutoScrolls()}autoScroll(t,n.options,e,o)}),10);lastAutoScrollX=r;lastAutoScrollY=l}}else{if(!this.options.bubbleScroll||getParentAutoScrollElement(a,true)===getWindowScrollingElement()){clearAutoScrolls();return}autoScroll(t,this.options,getParentAutoScrollElement(a,false),false)}}};return _extends(e,{pluginName:"scroll",initializeByDefault:true})}function clearAutoScrolls(){autoScrolls.forEach((function(e){clearInterval(e.pid)}));autoScrolls=[]}function clearPointerElemChangedInterval(){clearInterval(pointerElemChangedInterval)}var autoScroll=throttle((function(e,t,o,n){if(!t.scroll)return;var r=(e.touches?e.touches[0]:e).clientX,l=(e.touches?e.touches[0]:e).clientY,a=t.scrollSensitivity,i=t.scrollSpeed,s=getWindowScrollingElement();var c=false,u;if(scrollRootEl!==o){scrollRootEl=o;clearAutoScrolls();scrollEl=t.scroll;u=t.scrollFn;if(scrollEl===true){scrollEl=getParentAutoScrollElement(o,true)}}var d=0;var f=scrollEl;do{var g=f,h=getRect(g),p=h.top,v=h.bottom,E=h.left,m=h.right,b=h.width,S=h.height,_=void 0,w=void 0,y=g.scrollWidth,D=g.scrollHeight,x=css(g),I=g.scrollLeft,C=g.scrollTop;if(g===s){_=b<y&&(x.overflowX==="auto"||x.overflowX==="scroll"||x.overflowX==="visible");w=S<D&&(x.overflowY==="auto"||x.overflowY==="scroll"||x.overflowY==="visible")}else{_=b<y&&(x.overflowX==="auto"||x.overflowX==="scroll");w=S<D&&(x.overflowY==="auto"||x.overflowY==="scroll")}var T=_&&(Math.abs(m-r)<=a&&I+b<y)-(Math.abs(E-r)<=a&&!!I);var P=w&&(Math.abs(v-l)<=a&&C+S<D)-(Math.abs(p-l)<=a&&!!C);if(!autoScrolls[d]){for(var A=0;A<=d;A++){if(!autoScrolls[A]){autoScrolls[A]={}}}}if(autoScrolls[d].vx!=T||autoScrolls[d].vy!=P||autoScrolls[d].el!==g){autoScrolls[d].el=g;autoScrolls[d].vx=T;autoScrolls[d].vy=P;clearInterval(autoScrolls[d].pid);if(T!=0||P!=0){c=true;autoScrolls[d].pid=setInterval(function(){if(n&&this.layer===0){Sortable.active._onTouchMove(touchEvt$1)}var t=autoScrolls[this.layer].vy?autoScrolls[this.layer].vy*i:0;var o=autoScrolls[this.layer].vx?autoScrolls[this.layer].vx*i:0;if(typeof u==="function"){if(u.call(Sortable.dragged.parentNode[expando],o,t,e,touchEvt$1,autoScrolls[this.layer].el)!=="continue"){return}}scrollBy(autoScrolls[this.layer].el,o,t)}.bind({layer:d}),24)}}d++}while(t.bubbleScroll&&f!==s&&(f=getParentAutoScrollElement(f,false)));scrolling=c}),30);var drop=function e(t){var o=t.originalEvent,n=t.putSortable,r=t.dragEl,l=t.activeSortable,a=t.dispatchSortableEvent,i=t.hideGhostForTarget,s=t.unhideGhostForTarget;if(!o)return;var c=n||l;i();var u=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:o;var d=document.elementFromPoint(u.clientX,u.clientY);s();if(c&&!c.el.contains(d)){a("spill");this.onSpill({dragEl:r,putSortable:n})}};function Revert(){}Revert.prototype={startIndex:null,dragStart:function e(t){var o=t.oldDraggableIndex;this.startIndex=o},onSpill:function e(t){var o=t.dragEl,n=t.putSortable;this.sortable.captureAnimationState();if(n){n.captureAnimationState()}var r=getChild(this.sortable.el,this.startIndex,this.options);if(r){this.sortable.el.insertBefore(o,r)}else{this.sortable.el.appendChild(o)}this.sortable.animateAll();if(n){n.animateAll()}},drop:drop};_extends(Revert,{pluginName:"revertOnSpill"});function Remove(){}Remove.prototype={onSpill:function e(t){var o=t.dragEl,n=t.putSortable;var r=n||this.sortable;r.captureAnimationState();o.parentNode&&o.parentNode.removeChild(o);r.animateAll()},drop:drop};_extends(Remove,{pluginName:"removeOnSpill"});Sortable.mount(new AutoScrollPlugin);Sortable.mount(Remove,Revert);export{Sortable as S};