(function(T,g){typeof exports=="object"&&typeof module!="undefined"?g(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],g):(T=typeof globalThis!="undefined"?globalThis:T||self,g(T.VueDraggablePlus={},T.Vue))})(this,function(T,g){"use strict";var Hn=Object.defineProperty;var qe=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable;var Wt=(T,g,M)=>g in T?Hn(T,g,{enumerable:!0,configurable:!0,writable:!0,value:M}):T[g]=M,he=(T,g)=>{for(var M in g||(g={}))jt.call(g,M)&&Wt(T,M,g[M]);if(qe)for(var M of qe(g))zt.call(g,M)&&Wt(T,M,g[M]);return T};var mt=(T,g)=>{var M={};for(var $ in T)jt.call(T,$)&&g.indexOf($)<0&&(M[$]=T[$]);if(T!=null&&qe)for(var $ of qe(T))g.indexOf($)<0&&zt.call(T,$)&&(M[$]=T[$]);return M};const M="[vue-draggable-plus]: ";function $(t){console.warn(M+t)}function Vt(t){console.error(M+t)}function Ut(t,e,n){Array.isArray(t)&&n>=0&&nn?n.toUpperCase():"")}function qt(t){return Object.keys(t).reduce((e,n)=>(typeof t[n]!="undefined"&&(e[$t(n)]=t[n]),e),{})}function Kt(t,e){if(Array.isArray(t))return t.splice(e,1)}function Jt(t,e,n){if(Array.isArray(t))return t.splice(e,0,n)}function Zt(t){return typeof t=="undefined"}function Qt(t){return typeof t=="string"}function vt(t,e,n){const o=n===0?t.firstElementChild:t.children[n];t.insertBefore(e,o)}function Ke(t){t.parentNode&&t.parentNode.removeChild(t)}function en(t,e=document){var o;let n=null;return typeof(e==null?void 0:e.querySelector)=="function"?n=(o=e==null?void 0:e.querySelector)==null?void 0:o.call(e,t):n=document.querySelector(t),n||$(`Element not found: ${t}`),n}function tn(t,e,n=null){return function(...o){return t.apply(n,o),e.apply(n,o)}}function nn(t,e){const n=he({},t);return Object.keys(e).forEach(o=>{n[o]?n[o]=tn(t[o],e[o]):n[o]=e[o]}),n}function on(t){return t instanceof HTMLElement}function rn(t,e){Object.keys(t).forEach(n=>{e(n,t[n])})}/**! * Sortable 1.15.0 * @author RubaXa * @author owenm * @license MIT */function bt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);e&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),n.push.apply(n,o)}return n}function K(t){for(var e=1;e=0)&&(n[r]=t[r]);return n}function sn(t,e){if(t==null)return{};var n=ln(t,e),o,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(t,o)&&(n[o]=t[o])}return n}var un="1.15.0";function ee(t){if(typeof window!="undefined"&&window.navigator)return!!navigator.userAgent.match(t)}var te=ee(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Ee=ee(/Edge/i),yt=ee(/firefox/i),we=ee(/safari/i)&&!ee(/chrome/i)&&!ee(/android/i),Et=ee(/iP(ad|od|hone)/i),wt=ee(/chrome/i)&&ee(/android/i),_t={capture:!1,passive:!1};function S(t,e,n){t.addEventListener(e,n,!te&&_t)}function _(t,e,n){t.removeEventListener(e,n,!te&&_t)}function Fe(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(n){return!1}return!1}}function fn(t){return t.host&&t!==document&&t.host.nodeType?t.host:t.parentNode}function J(t,e,n,o){if(t){n=n||document;do{if(e!=null&&(e[0]===">"?t.parentNode===n&&Fe(t,e):Fe(t,e))||o&&t===n)return t;if(t===n)break}while(t=fn(t))}return null}var St=/\s+/g;function j(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(St," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(St," ")}}function h(t,e,n){var o=t&&t.style;if(o){if(n===void 0)return document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle),e===void 0?n:n[e];!(e in o)&&e.indexOf("webkit")===-1&&(e="-webkit-"+e),o[e]=n+(typeof n=="string"?"":"px")}}function pe(t,e){var n="";if(typeof t=="string")n=t;else do{var o=h(t,"transform");o&&o!=="none"&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(n)}function Dt(t,e,n){if(t){var o=t.getElementsByTagName(e),r=0,i=o.length;if(n)for(;r=i:a=r<=i,!a)return o;if(o===Z())break;o=oe(o,!1)}return!1}function ge(t,e,n,o){for(var r=0,i=0,a=t.children;i2&&arguments[2]!==void 0?arguments[2]:{},r=o.evt,i=sn(o,bn);Se.pluginEvent.bind(p)(e,n,K({dragEl:f,parentEl:I,ghostEl:m,rootEl:O,nextEl:se,lastDownEl:Re,cloneEl:C,cloneHidden:re,dragStarted:Te,putSortable:F,activeSortable:p.active,originalEvent:r,oldIndex:ve,oldDraggableIndex:De,newIndex:V,newDraggableIndex:ie,hideGhostForTarget:Xt,unhideGhostForTarget:Yt,cloneNowHidden:function(){re=!0},cloneNowShown:function(){re=!1},dispatchSortableEvent:function(l){k({sortable:n,name:l,originalEvent:r})}},i))};function k(t){vn(K({putSortable:F,cloneEl:C,targetEl:f,rootEl:O,oldIndex:ve,oldDraggableIndex:De,newIndex:V,newDraggableIndex:ie},t))}var f,I,m,O,se,Re,C,re,ve,V,De,ie,Xe,F,be=!1,Ye=!1,ke=[],ue,q,et,tt,Nt,Pt,Te,ye,Oe,Ce=!1,Be=!1,He,X,nt=[],ot=!1,Le=[],Ge=typeof document!="undefined",We=Et,xt=Ee||te?"cssFloat":"float",yn=Ge&&!wt&&!Et&&"draggable"in document.createElement("div"),Mt=function(){if(Ge){if(te)return!1;var t=document.createElement("x");return t.style.cssText="pointer-events:auto",t.style.pointerEvents==="auto"}}(),Ft=function(e,n){var o=h(e),r=parseInt(o.width)-parseInt(o.paddingLeft)-parseInt(o.paddingRight)-parseInt(o.borderLeftWidth)-parseInt(o.borderRightWidth),i=ge(e,0,n),a=ge(e,1,n),l=i&&h(i),s=a&&h(a),u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+x(i).width,d=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+x(a).width;if(o.display==="flex")return o.flexDirection==="column"||o.flexDirection==="column-reverse"?"vertical":"horizontal";if(o.display==="grid")return o.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&l.float&&l.float!=="none"){var c=l.float==="left"?"left":"right";return a&&(s.clear==="both"||s.clear===c)?"vertical":"horizontal"}return i&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||u>=r&&o[xt]==="none"||a&&o[xt]==="none"&&u+d>r)?"vertical":"horizontal"},En=function(e,n,o){var r=o?e.left:e.top,i=o?e.right:e.bottom,a=o?e.width:e.height,l=o?n.left:n.top,s=o?n.right:n.bottom,u=o?n.width:n.height;return r===l||i===s||r+a/2===l+u/2},wn=function(e,n){var o;return ke.some(function(r){var i=r[z].options.emptyInsertThreshold;if(!(!i||Je(r))){var a=x(r),l=e>=a.left-i&&e<=a.right+i,s=n>=a.top-i&&n<=a.bottom+i;if(l&&s)return o=r}}),o},Rt=function(e){function n(i,a){return function(l,s,u,d){var c=l.options.group.name&&s.options.group.name&&l.options.group.name===s.options.group.name;if(i==null&&(a||c))return!0;if(i==null||i===!1)return!1;if(a&&i==="clone")return i;if(typeof i=="function")return n(i(l,s,u,d),a)(l,s,u,d);var v=(a?l:s).options.group.name;return i===!0||typeof i=="string"&&i===v||i.join&&i.indexOf(v)>-1}}var o={},r=e.group;(!r||Me(r)!="object")&&(r={name:r}),o.name=r.name,o.checkPull=n(r.pull,!0),o.checkPut=n(r.put),o.revertClone=r.revertClone,e.group=o},Xt=function(){!Mt&&m&&h(m,"display","none")},Yt=function(){!Mt&&m&&h(m,"display","")};Ge&&!wt&&document.addEventListener("click",function(t){if(Ye)return t.preventDefault(),t.stopPropagation&&t.stopPropagation(),t.stopImmediatePropagation&&t.stopImmediatePropagation(),Ye=!1,!1},!0);var fe=function(e){if(f){e=e.touches?e.touches[0]:e;var n=wn(e.clientX,e.clientY);if(n){var o={};for(var r in e)e.hasOwnProperty(r)&&(o[r]=e[r]);o.target=o.rootEl=n,o.preventDefault=void 0,o.stopPropagation=void 0,n[z]._onDragOver(o)}}},_n=function(e){f&&f.parentNode[z]._isOutsideThisEl(e.target)};function p(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t,this.options=e=Q({},e),t[z]=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 Ft(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(a,l){a.setData("Text",l.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:p.supportPointer!==!1&&"PointerEvent"in window&&!we,emptyInsertThreshold:5};Se.initializePlugins(this,t,n);for(var o in n)!(o in e)&&(e[o]=n[o]);Rt(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]=="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=e.forceFallback?!1:yn,this.nativeDraggable&&(this.options.touchStartThreshold=1),e.supportPointer?S(t,"pointerdown",this._onTapStart):(S(t,"mousedown",this._onTapStart),S(t,"touchstart",this._onTapStart)),this.nativeDraggable&&(S(t,"dragover",this),S(t,"dragenter",this)),ke.push(this.el),e.store&&e.store.get&&this.sort(e.store.get(this)||[]),Q(this,pn())}p.prototype={constructor:p,_isOutsideThisEl:function(e){!this.el.contains(e)&&e!==this.el&&(ye=null)},_getDirection:function(e,n){return typeof this.options.direction=="function"?this.options.direction.call(this,e,n,f):this.options.direction},_onTapStart:function(e){if(e.cancelable){var n=this,o=this.el,r=this.options,i=r.preventOnFilter,a=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,s=(l||e).target,u=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||s,d=r.filter;if(Nn(o),!f&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||r.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&we&&s&&s.tagName.toUpperCase()==="SELECT")&&(s=J(s,r.draggable,o,!1),!(s&&s.animated)&&Re!==s)){if(ve=U(s),De=U(s,r.draggable),typeof d=="function"){if(d.call(this,e,s,this)){k({sortable:n,rootEl:u,name:"filter",targetEl:s,toEl:o,fromEl:o}),B("filter",n,{evt:e}),i&&e.cancelable&&e.preventDefault();return}}else if(d&&(d=d.split(",").some(function(c){if(c=J(u,c.trim(),o,!1),c)return k({sortable:n,rootEl:c,name:"filter",targetEl:s,fromEl:o,toEl:o}),B("filter",n,{evt:e}),!0}),d)){i&&e.cancelable&&e.preventDefault();return}r.handle&&!J(u,r.handle,o,!1)||this._prepareDragStart(e,l,s)}}},_prepareDragStart:function(e,n,o){var r=this,i=r.el,a=r.options,l=i.ownerDocument,s;if(o&&!f&&o.parentNode===i){var u=x(o);if(O=i,f=o,I=f.parentNode,se=f.nextSibling,Re=o,Xe=a.group,p.dragged=f,ue={target:f,clientX:(n||e).clientX,clientY:(n||e).clientY},Nt=ue.clientX-u.left,Pt=ue.clientY-u.top,this._lastX=(n||e).clientX,this._lastY=(n||e).clientY,f.style["will-change"]="all",s=function(){if(B("delayEnded",r,{evt:e}),p.eventCanceled){r._onDrop();return}r._disableDelayedDragEvents(),!yt&&r.nativeDraggable&&(f.draggable=!0),r._triggerDragStart(e,n),k({sortable:r,name:"choose",originalEvent:e}),j(f,a.chosenClass,!0)},a.ignore.split(",").forEach(function(d){Dt(f,d.trim(),rt)}),S(l,"dragover",fe),S(l,"mousemove",fe),S(l,"touchmove",fe),S(l,"mouseup",r._onDrop),S(l,"touchend",r._onDrop),S(l,"touchcancel",r._onDrop),yt&&this.nativeDraggable&&(this.options.touchStartThreshold=4,f.draggable=!0),B("delayStart",this,{evt:e}),a.delay&&(!a.delayOnTouchOnly||n)&&(!this.nativeDraggable||!(Ee||te))){if(p.eventCanceled){this._onDrop();return}S(l,"mouseup",r._disableDelayedDrag),S(l,"touchend",r._disableDelayedDrag),S(l,"touchcancel",r._disableDelayedDrag),S(l,"mousemove",r._delayedDragTouchMoveHandler),S(l,"touchmove",r._delayedDragTouchMoveHandler),a.supportPointer&&S(l,"pointermove",r._delayedDragTouchMoveHandler),r._dragStartTimer=setTimeout(s,a.delay)}else s()}},_delayedDragTouchMoveHandler:function(e){var n=e.touches?e.touches[0]:e;Math.max(Math.abs(n.clientX-this._lastX),Math.abs(n.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){f&&rt(f),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var e=this.el.ownerDocument;_(e,"mouseup",this._disableDelayedDrag),_(e,"touchend",this._disableDelayedDrag),_(e,"touchcancel",this._disableDelayedDrag),_(e,"mousemove",this._delayedDragTouchMoveHandler),_(e,"touchmove",this._delayedDragTouchMoveHandler),_(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(e,n){n=n||e.pointerType=="touch"&&e,!this.nativeDraggable||n?this.options.supportPointer?S(document,"pointermove",this._onTouchMove):n?S(document,"touchmove",this._onTouchMove):S(document,"mousemove",this._onTouchMove):(S(f,"dragend",this),S(O,"dragstart",this._onDragStart));try{document.selection?ze(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch(o){}},_dragStarted:function(e,n){if(be=!1,O&&f){B("dragStarted",this,{evt:n}),this.nativeDraggable&&S(document,"dragover",_n);var o=this.options;!e&&j(f,o.dragClass,!1),j(f,o.ghostClass,!0),p.active=this,e&&this._appendGhost(),k({sortable:this,name:"start",originalEvent:n})}else this._nulling()},_emulateDragOver:function(){if(q){this._lastX=q.clientX,this._lastY=q.clientY,Xt();for(var e=document.elementFromPoint(q.clientX,q.clientY),n=e;e&&e.shadowRoot&&(e=e.shadowRoot.elementFromPoint(q.clientX,q.clientY),e!==n);)n=e;if(f.parentNode[z]._isOutsideThisEl(e),n)do{if(n[z]){var o=void 0;if(o=n[z]._onDragOver({clientX:q.clientX,clientY:q.clientY,target:e,rootEl:n}),o&&!this.options.dragoverBubble)break}e=n}while(n=n.parentNode);Yt()}},_onTouchMove:function(e){if(ue){var n=this.options,o=n.fallbackTolerance,r=n.fallbackOffset,i=e.touches?e.touches[0]:e,a=m&&pe(m,!0),l=m&&a&&a.a,s=m&&a&&a.d,u=We&&X&&Ot(X),d=(i.clientX-ue.clientX+r.x)/(l||1)+(u?u[0]-nt[0]:0)/(l||1),c=(i.clientY-ue.clientY+r.y)/(s||1)+(u?u[1]-nt[1]:0)/(s||1);if(!p.active&&!be){if(o&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))=0&&(k({rootEl:I,name:"add",toEl:I,fromEl:O,originalEvent:e}),k({sortable:this,name:"remove",toEl:I,originalEvent:e}),k({rootEl:I,name:"sort",toEl:I,fromEl:O,originalEvent:e}),k({sortable:this,name:"sort",toEl:I,originalEvent:e})),F&&F.save()):V!==ve&&V>=0&&(k({sortable:this,name:"update",toEl:I,originalEvent:e}),k({sortable:this,name:"sort",toEl:I,originalEvent:e})),p.active&&((V==null||V===-1)&&(V=ve,ie=De),k({sortable:this,name:"end",toEl:I,originalEvent:e}),this.save()))),this._nulling()},_nulling:function(){B("nulling",this),O=f=I=m=se=C=Re=re=ue=q=Te=V=ie=ve=De=ye=Oe=F=Xe=p.dragged=p.ghost=p.clone=p.active=null,Le.forEach(function(e){e.checked=!0}),Le.length=et=tt=0},handleEvent:function(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":f&&(this._onDragOver(e),Sn(e));break;case"selectstart":e.preventDefault();break}},toArray:function(){for(var e=[],n,o=this.el.children,r=0,i=o.length,a=this.options;ro.right+r||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+r}function Cn(t,e,n,o,r,i,a,l){var s=o?t.clientY:t.clientX,u=o?n.height:n.width,d=o?n.top:n.left,c=o?n.bottom:n.right,v=!1;if(!a){if(l&&Hed+u*i/2:sc-He)return-Oe}else if(s>d+u*(1-r)/2&&sc-u*i/2)?s>d+u/2?1:-1:0}function An(t){return U(f){y=E(y),i&&A.destroy(),i=new p(y,b())};g.watch(r,()=>{i&&rn(b(),(y,D)=>{i==null||i.option(y,D)})},{deep:!0});const A={option:(y,D)=>i==null?void 0:i.option(y,D),destroy:()=>{i==null||i.destroy(),i=null},save:()=>i==null?void 0:i.save(),toArray:()=>i==null?void 0:i.toArray(),closest:(...y)=>i==null?void 0:i.closest(...y)},H=()=>A==null?void 0:A.option("disabled",!0),R=()=>A==null?void 0:A.option("disabled",!1);return Fn(()=>{a&&w()}),Mn(A.destroy),he({start:w,pause:H,resume:R},A)}const pt=["update","start","add","remove","choose","unchoose","end","sort","filter","clone","move","change"],Rn=["onUpdate","onStart","onAdd","onRemove","animation","ghostClass","group","sort","disabled","store","handle","draggable","swapThreshold","invertSwap","invertedSwapThreshold","removeCloneOnHide","direction","chosenClass","dragClass","ignore","filter","preventOnFilter","easing","setData","dropBubble","dragoverBubble","dataIdAttr","delay","delayOnTouchOnly","touchStartThreshold","forceFallback","fallbackClass","fallbackOnBody","fallbackTolerance","fallbackOffset","supportPointer","emptyInsertThreshold","scroll","forceAutoScrollFallback","scrollSensitivity","scrollSpeed","bubbleScroll","modelValue","tag","target",...pt.map(t=>`on${t.replace(/^\S/,e=>e.toUpperCase())}`)],Xn=g.defineComponent({name:"VueDraggable",model:{prop:"modelValue",event:"update:modelValue"},props:Rn,emits:["update:modelValue",...pt],setup(t,{slots:e,emit:n,expose:o}){const r=g.useAttrs(),i=pt.reduce((d,c)=>{const v=`on${c.replace(/^\S/,E=>E.toUpperCase())}`;return d[v]=E=>n(c,E),d},{}),a=g.computed(()=>{const E=g.toRefs(t),{modelValue:d}=E,c=mt(E,["modelValue"]),v=Object.entries(c).reduce((b,[w,A])=>{const H=g.unref(A);return H!==void 0&&(b[w]=H),b},{});return he(he({},i),qt(he(he({},r),v)))}),l=g.computed({get:()=>t.modelValue,set:d=>n("update:modelValue",d)}),s=g.ref(),u=g.reactive(ht(t.target||s,l,a));return o(u),()=>{if(e.default)return g.h(t.tag||"div",{ref:s},e.default(u))}}}),Lt={mounted:"mounted",unmounted:"unmounted"},gt=new WeakMap,Yn={[Lt.mounted](t,e){const n=g.isProxy(e.value)?[e.value]:e.value,o=ht(t,...n);gt.set(t,o.destroy)},[Lt.unmounted](t){var e;(e=gt.get(t))==null||e(),gt.delete(t)}};T.VueDraggable=Xn,T.useDraggable=ht,T.vDraggable=Yn,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});