UNPKG

survey-analytics

Version:

SurveyJS analytics Library.

2 lines 202 kB
/*! For license information please see survey.analytics.min.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("plotly.js-dist-min"),require("survey-core")):"function"==typeof define&&define.amd?define("SurveyAnalytics",["plotly.js-dist-min","survey-core"],t):"object"==typeof exports?exports.SurveyAnalytics=t(require("plotly.js-dist-min"),require("survey-core")):e.SurveyAnalytics=t(e.Plotly,e.Survey)}(this,((e,t)=>(()=>{var i={820:function(e){e.exports=function(){"use strict";var e={},t="swap",i="move",r="layoutStart",n="layoutEnd",s="remove",o="filter",a="sort",l="move",h="send",u="beforeSend",c="receive",d="beforeReceive",p="dragReleaseEnd";function f(){this._events={},this._queue=[],this._counter=0,this._isDestroyed=!1}f.prototype.on=function(e,t){if(this._isDestroyed)return this;var i=this._events[e];return i||(i=this._events[e]=[]),i.push(t),this},f.prototype.off=function(e,t){if(this._isDestroyed)return this;var i=this._events[e];if(!i||!i.length)return this;if(!t)return i.length=0,this;for(var r=i.length;r--;)t===i[r]&&i.splice(r,1);return this},f.prototype.emit=function(e,t,i,r){if(this._isDestroyed)return this;var n=this._events[e];if(!n||!n.length)return this;var s,o=this._queue,a=o.length,l=arguments.length-1;for(s=0;s<n.length;s++)o.push(n[s]);for(++this._counter,s=a,a=o.length;s<a;s++)if(0===l?o[s]():1===l?o[s](t):2===l?o[s](t,i):o[s](t,i,r),this._isDestroyed)return this;return--this._counter,this._counter||(o.length=0),this},f.prototype.destroy=function(){if(this._isDestroyed)return this;var e,t=this._events;for(e in this._isDestroyed=!0,this._queue.length=this._counter=0,t)t[e]&&(t[e].length=0,t[e]=void 0);return this};var m="transform",g="transform",_=window.document.documentElement.style,v="transform",y=!1;["","Webkit","Moz","O","ms"].forEach((function(e){if(!y){var t=e?e+"Transform":v;void 0!==_[t]&&(e=e.toLowerCase(),m=e?"-"+e+"-"+v:v,g=t,y=!0)}}));var w="function"==typeof WeakMap?new WeakMap:null;function b(e,t){var i=w&&w.get(e);return i||(i=window.getComputedStyle(e,null),w&&w.set(e,i)),i.getPropertyValue("transform"===t?m:t)}var C=/([A-Z])/g;function T(e){return e.replace(C,"-$1").toLowerCase()}function P(e){return"function"==typeof e}function x(e,t){for(var i in t)e.style["transform"===i?g:i]=t[i]}function A(e){this._element=e,this._animation=null,this._callback=null,this._props=[],this._values=[],this._keyframes=[],this._options={},this._isDestroyed=!1,this._onFinish=this._onFinish.bind(this)}A.prototype.start=function(e,t,i){if(!this._isDestroyed){var r=this._animation,n=this._props,s=this._values,o=i||0,a=!1;if(r){var l,h=0;for(var u in t)if(++h,-1===(l=n.indexOf(u))||t[u]!==s[l]){a=!0;break}a||h===n.length||(a=!0)}if(a&&r.cancel(),this._callback=P(o.onFinish)?o.onFinish:null,!r||a){for(u in n.length=s.length=0,t)n.push(u),s.push(t[u]);var c=this._keyframes;c[0]=e,c[1]=t;var d=this._options;d.duration=o.duration||300,d.easing=o.easing||"ease";var p=this._element;(r=p.animate(c,d)).onfinish=this._onFinish,this._animation=r,x(p,t)}}},A.prototype.stop=function(e){if(!this._isDestroyed&&this._animation){var t,i,r,n=this._element,s=this._props,o=this._values;if(e)x(n,e);else for(r=0;r<s.length;r++)i=b(n,T(t=s[r])),n.style["transform"===t?g:t]=i;this._animation.cancel(),this._animation=this._callback=null,s.length=o.length=0}},A.prototype.isAnimating=function(){return!!this._animation},A.prototype.destroy=function(){this._isDestroyed||(this.stop(),this._element=this._options=this._keyframes=null,this._isDestroyed=!0)},A.prototype._onFinish=function(){var e=this._callback;this._animation=this._callback=null,this._props.length=this._values.length=0,e&&e()};var S=["","webkit","moz","ms","o","Webkit","Moz","MS","O"];function E(e,t){for(var i,r,n=t[0].toUpperCase()+t.slice(1),s=0;s<S.length;){if((r=(i=S[s])?i+n:t)in e)return r;++s}return null}var D=1e3/60,k=(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(e){return this.setTimeout((function(){e(D)}),D)}).bind(window),z=!1;try{var V=Object.defineProperty({},"passive",{get:function(){z=!0}});window.addEventListener("testPassive",null,V),window.removeEventListener("testPassive",null,V)}catch(e){}var L="start",O="move",M="end",B="cancel",R=!(!("ontouchstart"in window)&&!window.TouchEvent),N=!!window.PointerEvent,I=!!window.navigator.msPointerEnabled,j=/(android)/i.test(window.navigator.userAgent),q=!!z&&{passive:!0},F="touchAction",H=E(window.document.documentElement.style,F);function G(e,t){this._element=e,this._emitter=new f,this._isDestroyed=!1,this._cssProps={},this._touchAction="",this._startEvent=null,this._pointerId=null,this._startTime=0,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._preStartCheck=this._preStartCheck.bind(this),this._abortNonCancelable=this._abortNonCancelable.bind(this),this._onStart=this._onStart.bind(this),this._onMove=this._onMove.bind(this),this._onCancel=this._onCancel.bind(this),this._onEnd=this._onEnd.bind(this),this.setCssProps(t),this._touchAction||this.setTouchAction("auto"),e.addEventListener("dragstart",G._preventDefault,!1),e.addEventListener(G._events.start,this._preStartCheck,q),!R||N||I||e.addEventListener(G._mouseEvents.start,this._preStartCheck,q)}function X(){this._nextStep=null,this._queue=[],this._reads={},this._writes={},this._batch=[],this._batchReads={},this._batchWrites={},this._step=this._step.bind(this)}G._pointerEvents={start:"pointerdown",move:"pointermove",cancel:"pointercancel",end:"pointerup"},G._msPointerEvents={start:"MSPointerDown",move:"MSPointerMove",cancel:"MSPointerCancel",end:"MSPointerUp"},G._touchEvents={start:"touchstart",move:"touchmove",cancel:"touchcancel",end:"touchend"},G._mouseEvents={start:"mousedown",move:"mousemove",cancel:"",end:"mouseup"},G._events=N?G._pointerEvents:I?G._msPointerEvents:R?G._touchEvents:G._mouseEvents,G._emitter=new f,G._activeInstances=[],G._preventDefault=function(e){e.preventDefault&&!1!==e.cancelable&&e.preventDefault()},G._activateInstance=function(e){G._activeInstances.indexOf(e)>-1||(G._activeInstances.push(e),G._emitter.on(O,e._onMove),G._emitter.on(B,e._onCancel),G._emitter.on(M,e._onEnd),1===G._activeInstances.length&&G._bindListeners())},G._deactivateInstance=function(e){var t=G._activeInstances.indexOf(e);-1!==t&&(G._activeInstances.splice(t,1),G._emitter.off(O,e._onMove),G._emitter.off(B,e._onCancel),G._emitter.off(M,e._onEnd),G._activeInstances.length||G._unbindListeners())},G._bindListeners=function(){var e=G._events;window.addEventListener(e.move,G._onMove,q),window.addEventListener(e.end,G._onEnd,q),e.cancel&&window.addEventListener(e.cancel,G._onCancel,q)},G._unbindListeners=function(){var e=G._events;window.removeEventListener(e.move,G._onMove,q),window.removeEventListener(e.end,G._onEnd,q),e.cancel&&window.removeEventListener(e.cancel,G._onCancel,q)},G._getEventPointerId=function(e){return"number"==typeof e.pointerId?e.pointerId:e.changedTouches?e.changedTouches[0]?e.changedTouches[0].identifier:null:1},G._getTouchById=function(e,t){if("number"==typeof e.pointerId)return e.pointerId===t?e:null;if(e.changedTouches){for(var i=0;i<e.changedTouches.length;i++)if(e.changedTouches[i].identifier===t)return e.changedTouches[i];return null}return e},G._onMove=function(e){G._emitter.emit(O,e)},G._onCancel=function(e){G._emitter.emit(B,e)},G._onEnd=function(e){G._emitter.emit(M,e)},G.prototype._reset=function(){this._isDestroyed||(this._pointerId=null,this._startTime=0,this._startX=0,this._startY=0,this._currentX=0,this._currentY=0,this._startEvent=null,this._element.removeEventListener(G._touchEvents.start,this._abortNonCancelable,q),G._deactivateInstance(this))},G.prototype._createEvent=function(e,t){var i=this._getTrackedTouch(t);return{type:e,srcEvent:t,distance:this.getDistance(),deltaX:this.getDeltaX(),deltaY:this.getDeltaY(),deltaTime:e===L?0:this.getDeltaTime(),isFirst:e===L,isFinal:e===M||e===B,identifier:this._pointerId,screenX:i.screenX,screenY:i.screenY,clientX:i.clientX,clientY:i.clientY,pageX:i.pageX,pageY:i.pageY,target:i.target}},G.prototype._emit=function(e,t){this._emitter.emit(e,this._createEvent(e,t))},G.prototype._getTrackedTouch=function(e){return null===this._pointerId?null:G._getTouchById(e,this._pointerId)},G.prototype._preStartCheck=function(e){this._isDestroyed||this.isDragging()||j&&!1===e.cancelable||e.button||(this._pointerId=G._getEventPointerId(e),null!==this._pointerId&&(this._startEvent=e,R&&(N||I)?(j&&this._element.addEventListener(G._touchEvents.start,this._abortNonCancelable,q),k(this._onStart)):this._onStart()))},G.prototype._abortNonCancelable=function(e){this._element.removeEventListener(G._touchEvents.start,this._abortNonCancelable,q),this._startEvent&&!1===e.cancelable&&(this._pointerId=null,this._startEvent=null)},G.prototype._onStart=function(){var e=this._startEvent;if(e){this._startEvent=null;var t=this._getTrackedTouch(e);t&&(this._startX=this._currentX=t.clientX,this._startY=this._currentY=t.clientY,this._startTime=Date.now(),this._emit(L,e),G._activateInstance(this))}},G.prototype._onMove=function(e){var t=this._getTrackedTouch(e);t&&(this._currentX=t.clientX,this._currentY=t.clientY,this._emit(O,e))},G.prototype._onCancel=function(e){this._getTrackedTouch(e)&&(this._emit(B,e),this._reset())},G.prototype._onEnd=function(e){this._getTrackedTouch(e)&&(this._emit(M,e),this._reset())},G.prototype.isDragging=function(){return null!==this._pointerId},G.prototype.setTouchAction=function(e){this._touchAction=e,H&&(this._cssProps[H]="",this._element.style[H]=e),R&&(this._element.removeEventListener(G._touchEvents.start,G._preventDefault,!1),this._element.style[H]!==e&&this._element.addEventListener(G._touchEvents.start,G._preventDefault,!1))},G.prototype.setCssProps=function(e){if(e){var t,i,r=this._cssProps,n=this._element;for(t in r)n.style[t]=r[t],delete r[t];for(t in e)e[t]&&(t!==F?(i=E(n.style,t))&&(r[i]="",n.style[i]=e[t]):this.setTouchAction(e[t]))}},G.prototype.getDeltaX=function(){return this._currentX-this._startX},G.prototype.getDeltaY=function(){return this._currentY-this._startY},G.prototype.getDistance=function(){var e=this.getDeltaX(),t=this.getDeltaY();return Math.sqrt(e*e+t*t)},G.prototype.getDeltaTime=function(){return this._startTime?Date.now()-this._startTime:0},G.prototype.on=function(e,t){this._emitter.on(e,t)},G.prototype.off=function(e,t){this._emitter.off(eventName,t)},G.prototype.destroy=function(){if(!this._isDestroyed){var e=this._element,t=G._events;for(var i in this._reset(),this._emitter.destroy(),e.removeEventListener(t.start,this._preStartCheck,q),e.removeEventListener(G._mouseEvents.start,this._preStartCheck,q),e.removeEventListener("dragstart",G._preventDefault,!1),e.removeEventListener(G._touchEvents.start,G._preventDefault,!1),this._cssProps)e.style[i]=this._cssProps[i],delete this._cssProps[i];this._element=null,this._isDestroyed=!0}},X.prototype.add=function(e,t,i,r){var n=this._queue.indexOf(e);n>-1&&(this._queue[n]=void 0),r?this._queue.unshift(e):this._queue.push(e),this._reads[e]=t,this._writes[e]=i,this._nextStep||(this._nextStep=k(this._step))},X.prototype.cancel=function(e){var t=this._queue.indexOf(e);t>-1&&(this._queue[t]=void 0,delete this._reads[e],delete this._writes[e])},X.prototype._step=function(){var e,t,i=this._queue,r=this._reads,n=this._writes,s=this._batch,o=this._batchReads,a=this._batchWrites,l=i.length;for(this._nextStep=null,t=0;t<l;t++)(e=i[t])&&(s.push(e),o[e]=r[e],delete r[e],a[e]=n[e],delete n[e]);for(i.length=0,t=0;t<l;t++)o[e=s[t]]&&(o[e](),delete o[e]);for(t=0;t<l;t++)a[e=s[t]]&&(a[e](),delete a[e]);s.length=0,!this._nextStep&&i.length&&(this._nextStep=k(this._step))};var W=new X,Y="layout",Q="visibility",U="move",K="scroll",Z="placeholder";function J(e){return W.cancel(e+Q)}function $(e){return W.cancel(e+U)}function ee(e){return W.cancel(e+K)}function te(e){return W.cancel(e+Z)}var ie=window.Element.prototype,re=ie.matches||ie.matchesSelector||ie.webkitMatchesSelector||ie.mozMatchesSelector||ie.msMatchesSelector||ie.oMatchesSelector||function(){return!1};function ne(e,t){return re.call(e,t)}function se(e,t){e.classList?e.classList.add(t):ne(e,"."+t)||(e.className+=" "+t)}var oe=[];function ae(e,t,i){var r="number"==typeof i?i:-1;r<0&&(r=e.length-r+1),e.splice.apply(e,oe.concat(r,0,t)),oe.length=0}function le(e,t,i){var r=e.length,n=Math.max(0,i?r:r-1);return t>n?n:t<0?Math.max(n+t+1,0):t}function he(e,t,i){if(!(e.length<2)){var r=le(e,t),n=le(e,i);r!==n&&e.splice(n,0,e.splice(r,1)[0])}}function ue(e,t,i){if(!(e.length<2)){var r,n=le(e,t),s=le(e,i);n!==s&&(r=e[n],e[n]=e[s],e[s]=r)}}var ce="cancel",de="finish",pe=0;function fe(e,t){var i,r=++pe+"debounce";return t>0?function(n){void 0!==i&&(i=window.clearTimeout(i),W.cancel(r),n===de&&e()),n!==ce&&n!==de&&(i=window.setTimeout((function(){i=void 0,W.add(r,e,null,!0)}),t))}:function(t){t!==ce&&e()}}function me(e){var t=b(e,"transform");if(!t||"none"===t)return!1;var i=b(e,"display");return"inline"!==i&&"none"!==i}function ge(e,t){for(var i=window.document,r=(t?e:e.parentElement)||i;r&&r!==i&&"static"===b(r,"position")&&!me(r);)r=r.parentElement||i;return r}function _e(e,t){return parseFloat(b(e,t))||0}var ve={},ye={},we={};function be(e,t){var i,r=t||{};return r.left=0,r.top=0,e===document||(r.left=window.pageXOffset||0,r.top=window.pageYOffset||0,e.self===window.self||(i=e.getBoundingClientRect(),r.left+=i.left,r.top+=i.top,r.left+=_e(e,"border-left-width"),r.top+=_e(e,"border-top-width"))),r}function Ce(e,t,i){return we.left=0,we.top=0,e===t||i&&(e=ge(e,!0))===(t=ge(t,!0))||(be(e,ve),be(t,ye),we.left=ye.left-ve.left,we.top=ye.top-ve.top),we}var Te="auto",Pe="scroll";function xe(e){var t=b(e,"overflow");return t===Te||t===Pe||(t=b(e,"overflow-x"))===Te||t===Pe||(t=b(e,"overflow-y"))===Te||t===Pe}function Ae(e,t,i){for(var r=i||[],n=t?e:e.parentNode;n&&n!==document;)n.getRootNode&&n instanceof DocumentFragment?n=n.getRootNode().host:(xe(n)&&r.push(n),n=n.parentNode);return r.push(window),r}var Se={},Ee=/^matrix3d/,De=/([^,]*,){4}/,ke=/([^,]*,){12}/,ze=/[^,]*,/;function Ve(e){Se.x=0,Se.y=0;var t=b(e,"transform");if(!t||"none"===t)return Se;var i=Ee.test(t),r=t.replace(i?ke:De,""),n=r.replace(ze,"");return Se.x=parseFloat(r)||0,Se.y=parseFloat(n)||0,Se}function Le(e,t){return"translateX("+e+"px) translateY("+t+"px)"}function Oe(e,t){e.classList?e.classList.remove(t):ne(e,"."+t)&&(e.className=(" "+e.className+" ").replace(" "+t+" "," ").trim())}var Me,Be,Re,Ne;function Ie(e){var t=e._element,i=e.getGrid(),r=i._settings;this._item=e,this._gridId=i._id,this._isDestroyed=!1,this._isMigrating=!1,this._startPredicate=P(r.dragStartPredicate)?r.dragStartPredicate:Ie.defaultStartPredicate,this._startPredicateState=0,this._startPredicateResult=void 0,this._hBlockedIndex=null,this._hX1=0,this._hX2=0,this._hY1=0,this._hY2=0,this._reset(),this._preStartCheck=this._preStartCheck.bind(this),this._preEndCheck=this._preEndCheck.bind(this),this._onScroll=this._onScroll.bind(this),this._prepareMove=this._prepareMove.bind(this),this._applyMove=this._applyMove.bind(this),this._prepareScroll=this._prepareScroll.bind(this),this._applyScroll=this._applyScroll.bind(this),this._checkOverlap=this._checkOverlap.bind(this);var n=r.dragSortHeuristics.sortInterval;this._checkOverlapDebounce=fe(this._checkOverlap,n),this._dragger=new G(t,r.dragCssProps),this._dragger.on("start",this._preStartCheck),this._dragger.on("move",this._preStartCheck),this._dragger.on("cancel",this._preEndCheck),this._dragger.on("end",this._preEndCheck)}function je(e,t){return e.left+e.width<=t.left||t.left+t.width<=e.left||e.top+e.height<=t.top||t.top+t.height<=e.top?0:(Math.min(e.left+e.width,t.left+t.width)-Math.max(e.left,t.left))*(Math.min(e.top+e.height,t.top+t.height)-Math.max(e.top,t.top))/(Math.min(e.width,t.width)*Math.min(e.height,t.height))*100}function qe(e){this._item=e,this._animate=new A,this._element=null,this._className="",this._didMigrate=!1,this._resetAfterLayout=!1,this._currentLeft=0,this._currentTop=0,this._nextLeft=0,this._nextTop=0,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this),this._onLayoutStart=this._onLayoutStart.bind(this),this._onLayoutEnd=this._onLayoutEnd.bind(this),this._onReleaseEnd=this._onReleaseEnd.bind(this),this._onMigrate=this._onMigrate.bind(this)}function Fe(){this._queue=[],this._isDestroyed=!1}function He(e){this._item=e,this._isActive=!1,this._isDestroyed=!1,this._isInterrupted=!1,this._currentStyles={},this._targetStyles={},this._currentLeft=0,this._currentTop=0,this._offsetLeft=0,this._offsetTop=0,this._skipNextAnimation=!1,this._animateOptions={onFinish:this._finish.bind(this)},this._queue=new Fe,this._setupAnimation=this._setupAnimation.bind(this),this._startAnimation=this._startAnimation.bind(this)}Ie.defaultStartPredicate=function(e,t,i){var r=e._drag,n=r._startPredicateData||r._setupStartPredicate(i);if(!t.isFinal)return!(!n.handleElement&&(n.handleElement=r._getStartPredicateHandle(t),!n.handleElement))&&(n.delay&&(n.event=t,n.delayTimer||(n.delayTimer=window.setTimeout((function(){n.delay=0,r._resolveStartPredicate(n.event)&&(r._forceResolveStartPredicate(n.event),r._resetStartPredicate())}),n.delay))),r._resolveStartPredicate(t));r._finishStartPredicate(t)},Ie.defaultSortPredicate=(Me={},Be={},Re={},Ne=[],function(e,r){var n=e._drag,s=n._getGrid(),o=r&&"number"==typeof r.threshold?r.threshold:50,a=r&&r.action===t?t:i;Me.width=e._width,Me.height=e._height,Me.left=n._elementClientX,Me.top=n._elementClientY;var l=function(e,t,i){var r,n,s,o,a=null,l=t._settings.dragSort,h=-1;if(!0===l?(Ne[0]=t,n=Ne):n=l.call(t,e),!Array.isArray(n))return a;for(o=0;o<n.length;o++)(s=n[o])._isDestroyed||(s._updateBoundingRect(),Be.width=s._width,Be.height=s._height,Be.left=s._left,Be.top=s._top,(r=je(Me,Be))>i&&r>h&&(h=r,a=s));return Ne.length=0,a}(e,s,o);if(!l)return!1;var h,u,c,d,p,f=0,m=0,g=-1;for(l===s?(Me.left=n._gridX+e._marginLeft,Me.top=n._gridY+e._marginTop):(l._updateBorders(1,0,1,0),f=l._left+l._borderLeft,m=l._top+l._borderTop),p=0;p<l._items.length;p++)(c=l._items[p])._isActive&&c!==e&&(u=!0,Be.width=c._width,Be.height=c._height,Be.left=c._left+c._marginLeft+f,Be.top=c._top+c._marginTop+m,(d=je(Me,Be))>g&&(h=p,g=d));return g<o&&e.getGrid()!==l&&(h=u?-1:0,g=1/0),g>=o&&(Re.grid=l,Re.index=h,Re.action=a,Re)}),Ie.prototype.stop=function(){var e=this._item,t=e._element,i=this._getGrid();return this._isActive?this._isMigrating?(this._finishMigration(),this):($(e._id),ee(e._id),this._unbindScrollListeners(),this._checkOverlapDebounce("cancel"),t.parentNode!==i._element&&(i._element.appendChild(t),t.style[g]=Le(this._gridX,this._gridY)),Oe(t,i._settings.itemDraggingClass),this._reset(),this):this},Ie.prototype.destroy=function(){return this._isDestroyed||(this.stop(),this._dragger.destroy(),this._isDestroyed=!0),this},Ie.prototype._getGrid=function(){return e[this._gridId]||null},Ie.prototype._reset=function(){this._isActive=!1,this._container=null,this._containingBlock=null,this._dragEvent=null,this._scrollEvent=null,this._scrollers=[],this._left=0,this._top=0,this._gridX=0,this._gridY=0,this._elementClientX=0,this._elementClientY=0,this._containerDiffX=0,this._containerDiffY=0},Ie.prototype._bindScrollListeners=function(){var e,t,i=this._getGrid()._element,r=this._container,n=this._scrollers;if(n.length=0,Ae(this._item._element,!1,n),r!==i)for(Ae(i,!0,e=[]),t=0;t<e.length;t++)n.indexOf(e[t])<0&&n.push(e[t]);for(t=0;t<n.length;t++)n[t].addEventListener("scroll",this._onScroll)},Ie.prototype._unbindScrollListeners=function(){var e,t=this._scrollers;for(e=0;e<t.length;e++)t[e].removeEventListener("scroll",this._onScroll);t.length=0},Ie.prototype._setupStartPredicate=function(e){var t=e||this._getGrid()._settings.dragStartPredicate||0;return this._startPredicateData={distance:Math.abs(t.distance)||0,delay:Math.max(t.delay,0)||0,handle:"string"==typeof t.handle&&t.handle}},Ie.prototype._getStartPredicateHandle=function(e){var t=this._startPredicateData,i=this._item._element,r=i;if(!t.handle)return r;for(r=e.target;r&&!ne(r,t.handle);)r=r!==i?r.parentElement:null;return r||null},Ie.prototype._resolveStartPredicate=function(e){var t=this._startPredicateData;if(!(e.distance<t.distance||t.delay)){var i=t.handleElement.getBoundingClientRect(),r=i.left+(window.pageXOffset||0),n=i.top+(window.pageYOffset||0),s=i.width,o=i.height;return this._resetStartPredicate(),s&&o&&e.pageX>=r&&e.pageX<r+s&&e.pageY>=n&&e.pageY<n+o}},Ie.prototype._forceResolveStartPredicate=function(e){this._isDestroyed||1!==this._startPredicateState||(this._startPredicateState=2,this._onStart(e))},Ie.prototype._finishStartPredicate=function(e){var t=this._item._element,i=Math.abs(e.deltaX)<2&&Math.abs(e.deltaY)<2&&e.deltaTime<200;this._resetStartPredicate(),i&&function(e){if("a"===e.tagName.toLowerCase()){var t=e.getAttribute("href");if(t){var i=e.getAttribute("target");i&&"_self"!==i?window.open(t,i):window.location.href=t}}}(t)},Ie.prototype._resetHeuristics=function(e){this._hBlockedIndex=null,this._hX1=this._hX2=e.clientX,this._hY1=this._hY2=e.clientY},Ie.prototype._checkHeuristics=function(e){var t=this._getGrid()._settings.dragSortHeuristics,i=t.minDragDistance;if(i<=0)return this._hBlockedIndex=null,!0;var r=e.clientX,n=e.clientY,s=r-this._hX2,o=n-this._hY2,a=i>3&&t.minBounceBackAngle>0;if(a||(this._hBlockedIndex=null),Math.abs(s)>i||Math.abs(o)>i){if(a){var l=Math.atan2(s,o),h=Math.atan2(this._hX2-this._hX1,this._hY2-this._hY1),u=Math.atan2(Math.sin(l-h),Math.cos(l-h));Math.abs(u)>t.minBounceBackAngle&&(this._hBlockedIndex=null)}return this._hX1=this._hX2,this._hY1=this._hY2,this._hX2=r,this._hY2=n,!0}return!1},Ie.prototype._resetStartPredicate=function(){var e=this._startPredicateData;e&&(e.delayTimer&&(e.delayTimer=window.clearTimeout(e.delayTimer)),this._startPredicateData=null)},Ie.prototype._checkOverlap=function(){if(this._isActive){var e,r,n,s,o,a,p,f=this._item,m=this._getGrid()._settings;(e=P(m.dragSortPredicate)?m.dragSortPredicate(f,this._dragEvent):Ie.defaultSortPredicate(f,m.dragSortPredicate))&&"number"==typeof e.index&&(p=(r=f.getGrid())!==(s=e.grid||r),n=r._items.indexOf(f),o=le(s._items,e.index,p),a=e.action===t?t:i,(p||o!==this._hBlockedIndex)&&(p?(this._hBlockedIndex=null,r._hasListeners(u)&&r._emit(u,{item:f,fromGrid:r,fromIndex:n,toGrid:s,toIndex:o}),s._hasListeners(d)&&s._emit(d,{item:f,fromGrid:r,fromIndex:n,toGrid:s,toIndex:o}),f._gridId=s._id,this._isMigrating=f._gridId!==this._gridId,r._items.splice(n,1),ae(s._items,f,o),f._sortData=null,r._hasListeners(h)&&r._emit(h,{item:f,fromGrid:r,fromIndex:n,toGrid:s,toIndex:o}),s._hasListeners(c)&&s._emit(c,{item:f,fromGrid:r,fromIndex:n,toGrid:s,toIndex:o}),r.layout(),s.layout()):n!==o&&(this._hBlockedIndex=n,(a===t?ue:he)(r._items,n,o),r._hasListeners(l)&&r._emit(l,{item:f,fromIndex:n,toIndex:o,action:a}),r.layout())))}},Ie.prototype._finishMigration=function(){var e,t,i=this._item,r=i._release,n=i._element,s=i._isActive,o=i.getGrid(),a=o._element,l=o._settings,h=l.dragContainer||a,u=this._getGrid()._settings,c=n.parentNode;this._isMigrating=!1,this.destroy(),Oe(n,u.itemClass),Oe(n,u.itemVisibleClass),Oe(n,u.itemHiddenClass),se(n,l.itemClass),se(n,s?l.itemVisibleClass:l.itemHiddenClass),h!==c&&(h.appendChild(n),t=Ce(c,h,!0),(e=Ve(n)).x-=t.left,e.y-=t.top),i._refreshDimensions(),i._refreshSortData(),t=Ce(h,a,!0),r._containerDiffX=t.left,r._containerDiffY=t.top,i._drag=l.dragEnabled?new Ie(i):null,h!==c&&(n.style[g]=Le(e.x,e.y)),i._child.removeAttribute("style"),x(i._child,s?l.visibleStyles:l.hiddenStyles),r.start()},Ie.prototype._preStartCheck=function(e){0===this._startPredicateState&&(this._startPredicateState=1),1===this._startPredicateState?(this._startPredicateResult=this._startPredicate(this._item,e),!0===this._startPredicateResult?(this._startPredicateState=2,this._onStart(e)):!1===this._startPredicateResult&&(this._startPredicateState=3)):2===this._startPredicateState&&this._isActive&&this._onMove(e)},Ie.prototype._preEndCheck=function(e){var t=2===this._startPredicateState;this._startPredicate(this._item,e),this._startPredicateState=0,t&&this._isActive&&this._onEnd(e)},Ie.prototype._onStart=function(e){var t=this._item;if(t._isActive){var i,r=t._element,n=this._getGrid(),s=n._settings,o=t._release,a=t._migrate,l=n._element,h=s.dragContainer||l,u=ge(h,!0),c=Ve(r),d=c.x,p=c.y,f=r.getBoundingClientRect(),m=h!==l;this._resetHeuristics(e),m&&(i=Ce(u,l)),t.isPositioning()&&t._layout.stop(!0,{transform:Le(d,p)}),a._isActive&&(d-=a._containerDiffX,p-=a._containerDiffY,a.stop(!0,{transform:Le(d,p)})),t.isReleasing()&&o._reset(),this._isActive=!0,this._dragEvent=e,this._container=h,this._containingBlock=u,this._elementClientX=f.left,this._elementClientY=f.top,this._left=this._gridX=d,this._top=this._gridY=p,s.dragPlaceholder.enabled&&t._dragPlaceholder.create(),n._emit("dragInit",t,e),m&&(this._containerDiffX=i.left,this._containerDiffY=i.top,r.parentNode===h?(this._gridX=d-this._containerDiffX,this._gridY=p-this._containerDiffY):(this._left=d+this._containerDiffX,this._top=p+this._containerDiffY,h.appendChild(r),r.style[g]=Le(this._left,this._top))),se(r,s.itemDraggingClass),this._bindScrollListeners(),n._emit("dragStart",t,e)}},Ie.prototype._onMove=function(e){var t,i,r,n=this._item;if(n._isActive){var s=this._getGrid()._settings.dragAxis;if("y"!==s){var o=e.clientX-this._dragEvent.clientX;this._left+=o,this._gridX+=o,this._elementClientX+=o}if("x"!==s){var a=e.clientY-this._dragEvent.clientY;this._top+=a,this._gridY+=a,this._elementClientY+=a}this._dragEvent=e,t=n._id,i=this._prepareMove,r=this._applyMove,W.add(t+U,i,r,!0)}else this.stop()},Ie.prototype._prepareMove=function(){this._item._isActive&&this._getGrid()._settings.dragSort&&this._checkHeuristics(this._dragEvent)&&this._checkOverlapDebounce()},Ie.prototype._applyMove=function(){var e=this._item;e._isActive&&(e._element.style[g]=Le(this._left,this._top),this._getGrid()._emit("dragMove",e,this._dragEvent))},Ie.prototype._onScroll=function(e){var t,i,r,n=this._item;n._isActive?(this._scrollEvent=e,t=n._id,i=this._prepareScroll,r=this._applyScroll,W.add(t+K,i,r,!0)):this.stop()},Ie.prototype._prepareScroll=function(){var e=this._item;if(e._isActive){var t,i=e._element,r=this._getGrid(),n=r._settings,s=n.dragAxis,o=r._element,a=i.getBoundingClientRect(),l=this._elementClientX-a.left,h=this._elementClientY-a.top;this._container!==o&&(t=Ce(this._containingBlock,o),this._containerDiffX=t.left,this._containerDiffY=t.top),"y"!==s&&(this._left+=l,this._gridX=this._left-this._containerDiffX),"x"!==s&&(this._top+=h,this._gridY=this._top-this._containerDiffY),n.dragSort&&this._checkOverlapDebounce()}},Ie.prototype._applyScroll=function(){var e=this._item;e._isActive&&(e._element.style[g]=Le(this._left,this._top),this._getGrid()._emit("dragScroll",e,this._scrollEvent))},Ie.prototype._onEnd=function(e){var t=this._item,i=t._element,r=this._getGrid(),n=r._settings,s=t._release;t._isActive?($(t._id),ee(t._id),n.dragSort&&this._checkOverlapDebounce("finish"),this._unbindScrollListeners(),s._containerDiffX=this._containerDiffX,s._containerDiffY=this._containerDiffY,this._reset(),Oe(i,n.itemDraggingClass),r._emit("dragEnd",t,e),this._isMigrating?this._finishMigration():s.start()):this.stop()},qe.prototype._onLayoutStart=function(){var e,t,i,r=this._item,n=r.getGrid(),s=n._items.indexOf(r),o=n._layout.slots[2*s],a=n._layout.slots[2*s+1];if(this._didMigrate||r._left!==o||r._top!==a){if(o+=r._marginLeft,a+=r._marginTop,!(n._settings.dragPlaceholder.duration>0)||this._didMigrate){te(r._id);var l={transform:Le(o,a)};return this._animate.isAnimating()?this._animate.stop(l):x(this._element,l),void(this._didMigrate&&(n.getElement().appendChild(this._element),this._didMigrate=!1))}this._nextLeft=o,this._nextTop=a,e=r._id,t=this._setupAnimation,i=this._startAnimation,W.add(e+Z,t,i)}},qe.prototype._setupAnimation=function(){if(this.isActive()){var e=Ve(this._element);this._currentLeft=e.x,this._currentTop=e.y}},qe.prototype._startAnimation=function(){if(this.isActive()){var e=this._animate,t=this._currentLeft,i=this._currentTop,r=this._nextLeft,n=this._nextTop,s={transform:Le(r,n)};if(t!==r||i!==n){var o=this._item.getGrid()._settings.dragPlaceholder,a={transform:Le(t,i)};e.start(a,s,{duration:o.duration,easing:o.easing,onFinish:this._onLayoutEnd})}else e.isAnimating()&&e.stop(s)}},qe.prototype._onLayoutEnd=function(){this._resetAfterLayout&&this.reset()},qe.prototype._onReleaseEnd=function(e){if(e._id===this._item._id){if(!this._animate.isAnimating())return void this.reset();this._resetAfterLayout=!0}},qe.prototype._onMigrate=function(e){if(e.item===this._item){var t=this._item.getGrid(),i=e.toGrid;t.off(p,this._onReleaseEnd),t.off(r,this._onLayoutStart),t.off(u,this._onMigrate),i.on(p,this._onReleaseEnd),i.on(r,this._onLayoutStart),i.on(u,this._onMigrate),this._didMigrate=!0}},qe.prototype.create=function(){if(this.isActive())this._resetAfterLayout=!1;else{var e,t=this._item,i=t.getGrid(),n=i._settings,s=this._animate;e=P(n.dragPlaceholder.createElement)?n.dragPlaceholder.createElement(t):window.document.createElement("div"),this._element=e,s._element=e,this._className=n.itemPlaceholderClass||"",this._className&&se(e,this._className);var o=t._left+t._marginLeft,a=t._top+t._marginTop;x(e,{display:"block",position:"absolute",left:"0",top:"0",width:t._width+"px",height:t._height+"px",transform:Le(o,a)}),i.on(r,this._onLayoutStart),i.on(p,this._onReleaseEnd),i.on(u,this._onMigrate),P(n.dragPlaceholder.onCreate)&&n.dragPlaceholder.onCreate(t,e),i.getElement().appendChild(e)}},qe.prototype.reset=function(){if(this.isActive()){var e=this._element,t=this._item,i=t.getGrid(),n=i._settings,s=this._animate;this._resetAfterLayout=!1,te(t._id),s.stop(),s._element=null,i.off(p,this._onReleaseEnd),i.off(r,this._onLayoutStart),i.off(u,this._onMigrate),this._className&&(Oe(e,this._className),this._className=""),e.parentNode.removeChild(e),this._element=null,P(n.dragPlaceholder.onRemove)&&n.dragPlaceholder.onRemove(t,e)}},qe.prototype.updateDimensions=function(e,t){this.isActive()&&x(this._element,{width:e+"px",height:t+"px"})},qe.prototype.isActive=function(){return!!this._element},qe.prototype.destroy=function(){this.reset(),this._animate.destroy(),this._item=this._animate=null},Fe.prototype.add=function(e){return this._isDestroyed||this._queue.push(e),this},Fe.prototype.flush=function(e,t){if(this._isDestroyed)return this;var i,r=this._queue,n=r.length;if(!n)return this;var s=1===n,o=s?r[0]:r.slice(0);if(r.length=0,s)return o(e,t),this;for(i=0;i<n&&(o[i](e,t),!this._isDestroyed);i++);return this},Fe.prototype.destroy=function(){return this._isDestroyed||(this._isDestroyed=!0,this._queue.length=0),this},He.prototype.start=function(e,t){if(!this._isDestroyed){var i,r=this._item,n=r._element,s=r._release,o=r.getGrid()._settings,a=this._isActive,l=s._isActive&&!1===s._isPositioningStarted,h=l?o.dragReleaseDuration:o.layoutDuration,u=l?o.dragReleaseEasing:o.layoutEasing,c=!e&&!this._skipNextAnimation&&h>0;return a&&this._queue.flush(!0,r),l&&(s._isPositioningStarted=!0),P(t)&&this._queue.add(t),c?(this._isActive=!0,this._animateOptions.easing=u,this._animateOptions.duration=h,this._isInterrupted=a,d=r._id,p=this._setupAnimation,f=this._startAnimation,W.add(d+Y,p,f),this):(this._updateOffsets(),this._updateTargetStyles(),i=r._animate.isAnimating(),this.stop(!1,this._targetStyles),!i&&x(n,this._targetStyles),this._skipNextAnimation=!1,this._finish())}var d,p,f},He.prototype.stop=function(e,t){if(this._isDestroyed||!this._isActive)return this;var i,r=this._item;return i=r._id,W.cancel(i+Y),r._animate.stop(t),Oe(r._element,r.getGrid()._settings.itemPositioningClass),this._isActive=!1,e&&this._queue.flush(!0,r),this},He.prototype.destroy=function(){return this._isDestroyed||(this.stop(!0,{}),this._queue.destroy(),this._item=this._currentStyles=this._targetStyles=this._animateOptions=null,this._isDestroyed=!0),this},He.prototype._updateOffsets=function(){if(!this._isDestroyed){var e=this._item,t=e._migrate,i=e._release;this._offsetLeft=i._isActive?i._containerDiffX:t._isActive?t._containerDiffX:0,this._offsetTop=i._isActive?i._containerDiffY:t._isActive?t._containerDiffY:0}},He.prototype._updateTargetStyles=function(){this._isDestroyed||(this._targetStyles.transform=Le(this._item._left+this._offsetLeft,this._item._top+this._offsetTop))},He.prototype._finish=function(){if(!this._isDestroyed){var e=this._item,t=e._migrate,i=e._release;this._isActive&&(this._isActive=!1,Oe(e._element,e.getGrid()._settings.itemPositioningClass)),i._isActive&&i.stop(),t._isActive&&t.stop(),this._queue.flush(!1,e)}},He.prototype._setupAnimation=function(){var e=Ve(this._item._element);this._currentLeft=e.x,this._currentTop=e.y},He.prototype._startAnimation=function(){var e=this._item,t=e.getGrid()._settings;if(this._updateOffsets(),this._updateTargetStyles(),e._left===this._currentLeft-this._offsetLeft&&e._top===this._currentTop-this._offsetTop)return this._isInterrupted&&this.stop(!1,this._targetStyles),this._isActive=!1,void this._finish();this._isInterrupted||se(e._element,t.itemPositioningClass),this._currentStyles.transform=Le(this._currentLeft,this._currentTop),e._animate.start(this._currentStyles,this._targetStyles,this._animateOptions)};var Ge={};function Xe(e){this._item=e,this._isActive=!1,this._isDestroyed=!1,this._container=!1,this._containerDiffX=0,this._containerDiffY=0}Xe.prototype.start=function(e,t,i){if(this._isDestroyed)return this;var r,n,s,o,a,l,p,f,m=this._item,_=m._element,v=m.isVisible(),y=m.getGrid(),w=y._settings,b=e._settings,C=e._element,T=e._items,P=y._items.indexOf(m),A=i||window.document.body;if("number"==typeof t)r=le(T,t,!0);else{if(!(n=e._getItem(t)))return this;r=T.indexOf(n)}return(m.isPositioning()||this._isActive||m.isReleasing())&&(p=(l=Ve(_)).x,f=l.y),m.isPositioning()&&m._layout.stop(!0,{transform:Le(p,f)}),this._isActive&&(p-=this._containerDiffX,f-=this._containerDiffY,this.stop(!0,{transform:Le(p,f)})),m.isReleasing()&&(p-=m._release._containerDiffX,f-=m._release._containerDiffY,m._release.stop(!0,{transform:Le(p,f)})),m._visibility._stopAnimation(),m._drag&&m._drag.destroy(),m._visibility._queue.flush(!0,m),y._hasListeners(u)&&y._emit(u,{item:m,fromGrid:y,fromIndex:P,toGrid:e,toIndex:r}),e._hasListeners(d)&&e._emit(d,{item:m,fromGrid:y,fromIndex:P,toGrid:e,toIndex:r}),Oe(_,w.itemClass),Oe(_,w.itemVisibleClass),Oe(_,w.itemHiddenClass),se(_,b.itemClass),se(_,v?b.itemVisibleClass:b.itemHiddenClass),y._items.splice(P,1),ae(T,m,r),m._gridId=e._id,A!==(s=_.parentNode)&&(A.appendChild(_),o=Ce(A,s,!0),l||(p=(l=Ve(_)).x,f=l.y),_.style[g]=Le(p+o.left,f+o.top)),m._child.removeAttribute("style"),x(m._child,v?b.visibleStyles:b.hiddenStyles),_.style.display=v?"block":"hidden",a=Ce(A,C,!0),m._refreshDimensions(),m._refreshSortData(),m._drag=b.dragEnabled?new Ie(m):null,this._isActive=!0,this._container=A,this._containerDiffX=a.left,this._containerDiffY=a.top,y._hasListeners(h)&&y._emit(h,{item:m,fromGrid:y,fromIndex:P,toGrid:e,toIndex:r}),e._hasListeners(c)&&e._emit(c,{item:m,fromGrid:y,fromIndex:P,toGrid:e,toIndex:r}),this},Xe.prototype.stop=function(e,t){if(this._isDestroyed||!this._isActive)return this;var i,r=this._item,n=r._element,s=r.getGrid()._element;return this._container!==s&&(t||(e?(i=Ve(n),Ge.transform=Le(i.x-this._containerDiffX,i.y-this._containerDiffY)):Ge.transform=Le(r._left,r._top),t=Ge),s.appendChild(n),x(n,t)),this._isActive=!1,this._container=null,this._containerDiffX=0,this._containerDiffY=0,this},Xe.prototype.destroy=function(){return this._isDestroyed||(this.stop(!0),this._item=null,this._isDestroyed=!0),this};var We={};function Ye(e){this._item=e,this._isActive=!1,this._isDestroyed=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0}function Qe(e){var t=e._isActive,i=e._element,r=e.getGrid()._settings;this._item=e,this._isDestroyed=!1,this._isHidden=!t,this._isHiding=!1,this._isShowing=!1,this._queue=new Fe,this._finishShow=this._finishShow.bind(this),this._finishHide=this._finishHide.bind(this),i.style.display=t?"block":"none",se(i,t?r.itemVisibleClass:r.itemHiddenClass),x(e._child,t?r.visibleStyles:r.hiddenStyles)}Ye.prototype.start=function(){if(this._isDestroyed||this._isActive)return this;var e=this._item,t=e.getGrid();return this._isActive=!0,se(e._element,t._settings.itemReleasingClass),t._emit("dragReleaseStart",e),e._layout.start(!1),this},Ye.prototype.stop=function(e,t){if(this._isDestroyed||!this._isActive)return this;var i,r=this._item,n=r._element,s=r.getGrid(),o=s._element;return this._reset(),n.parentNode!==o&&(t||(e?(i=Ve(n),We.transform=Le(i.x-this._containerDiffX,i.y-this._containerDiffY)):We.transform=Le(r._left,r._top),t=We),o.appendChild(n),x(n,t)),e||s._emit(p,r),this},Ye.prototype.destroy=function(){return this._isDestroyed||(this.stop(!0),this._item=null,this._isDestroyed=!0),this},Ye.prototype._reset=function(){if(!this._isDestroyed){var e=this._item;this._isActive=!1,this._isPositioningStarted=!1,this._containerDiffX=0,this._containerDiffY=0,Oe(e._element,e.getGrid()._settings.itemReleasingClass)}},Qe.prototype.show=function(e,t){if(this._isDestroyed)return this;var i=this._item,r=i._element,n=this._queue,s=P(t)?t:null,o=i.getGrid()._settings;return this._isShowing||this._isHidden?this._isShowing&&!e?(s&&n.add(s),this):(this._isShowing||(n.flush(!0,i),Oe(r,o.itemHiddenClass),se(r,o.itemVisibleClass),this._isHiding||(r.style.display="block")),s&&n.add(s),i._isActive=this._isShowing=!0,this._isHiding=this._isHidden=!1,this._startAnimation(!0,e,this._finishShow),this):(s&&s(!1,i),this)},Qe.prototype.hide=function(e,t){if(this._isDestroyed)return this;var i=this._item,r=i._element,n=this._queue,s=P(t)?t:null,o=i.getGrid()._settings;return!this._isHiding&&this._isHidden?(s&&s(!1,i),this):this._isHiding&&!e?(s&&n.add(s),this):(this._isHiding||(n.flush(!0,i),se(r,o.itemHiddenClass),Oe(r,o.itemVisibleClass)),s&&n.add(s),this._isHidden=this._isHiding=!0,i._isActive=this._isShowing=!1,this._startAnimation(!1,e,this._finishHide),this)},Qe.prototype.destroy=function(){if(this._isDestroyed)return this;var e=this._item,t=e._element,i=e.getGrid(),r=this._queue,n=i._settings;return this._stopAnimation({}),r.flush(!0,e).destroy(),Oe(t,n.itemVisibleClass),Oe(t,n.itemHiddenClass),this._item=null,this._isHiding=this._isShowing=!1,this._isDestroyed=this._isHidden=!0,this},Qe.prototype._startAnimation=function(e,t,i){if(!this._isDestroyed){var r,n=this._item,s=n.getGrid()._settings,o=e?s.visibleStyles:s.hiddenStyles,a=parseInt(e?s.showDuration:s.hideDuration)||0,l=(e?s.showEasing:s.hideEasing)||"ease",h=t||a<=0;if(o){if(J(n._id),h)return n._animateChild.isAnimating()?n._animateChild.stop(o):x(n._child,o),void(i&&i());u=n._id,c=function(){r=function(e,t){var i={};for(var r in t)i[r]=b(e,T(r));return i}(n._child,o)},d=function(){n._animateChild.start(r,o,{duration:a,easing:l,onFinish:i})},W.add(u+Q,c,d)}else i&&i()}var u,c,d},Qe.prototype._stopAnimation=function(e){if(!this._isDestroyed){var t=this._item;J(t._id),t._animateChild.stop(e)}},Qe.prototype._finishShow=function(){this._isHidden||(this._isShowing=!1,this._queue.flush(!1,this._item))};var Ue={};Qe.prototype._finishHide=function(){if(this._isHidden){var e=this._item;this._isHiding=!1,Ue.transform=Le(0,0),e._layout.stop(!0,Ue),e._element.style.display="none",this._queue.flush(!1,e)}};var Ke,Ze,Je,$e,et=0;function tt(){return++et}function it(e,t,i){var r=e._settings;this._id=tt(),this._gridId=e._id,this._isDestroyed=!1,this._left=0,this._top=0,this._element=t,this._child=t.children[0],t.parentNode!==e._element&&e._element.appendChild(t),se(t,r.itemClass),"boolean"!=typeof i&&(i="none"!==b(t,"display")),this._isActive=i,t.style.left="0",t.style.top="0",t.style[g]=Le(0,0),this._animate=new A(t),this._animateChild=new A(this._child),this._visibility=new Qe(this),this._layout=new He(this),this._migrate=new Xe(this),this._release=new Ye(this),this._dragPlaceholder=new qe(this),this._drag=r.dragEnabled?new Ie(this):null,this._refreshDimensions(),this._refreshSortData()}function rt(){this._slots=[],this._slotSizes=[],this._freeSlots=[],this._newSlots=[],this._rectItem={},this._rectStore=[],this._rectId=0,this._layout={slots:null,setWidth:!1,setHeight:!1,width:!1,height:!1},this._sortRectsLeftTop=this._sortRectsLeftTop.bind(this),this._sortRectsTopLeft=this._sortRectsTopLeft.bind(this)}it.prototype.getGrid=function(){return e[this._gridId]},it.prototype.getElement=function(){return this._element},it.prototype.getWidth=function(){return this._width},it.prototype.getHeight=function(){return this._height},it.prototype.getMargin=function(){return{left:this._marginLeft,right:this._marginRight,top:this._marginTop,bottom:this._marginBottom}},it.prototype.getPosition=function(){return{left:this._left,top:this._top}},it.prototype.isActive=function(){return this._isActive},it.prototype.isVisible=function(){return!!this._visibility&&!this._visibility._isHidden},it.prototype.isShowing=function(){return!(!this._visibility||!this._visibility._isShowing)},it.prototype.isHiding=function(){return!(!this._visibility||!this._visibility._isHiding)},it.prototype.isPositioning=function(){return!(!this._layout||!this._layout._isActive)},it.prototype.isDragging=function(){return!(!this._drag||!this._drag._isActive)},it.prototype.isReleasing=function(){return!(!this._release||!this._release._isActive)},it.prototype.isDestroyed=function(){return this._isDestroyed},it.prototype._refreshDimensions=function(){if(!this._isDestroyed&&!this._visibility._isHidden){var e=this._element,t=this._dragPlaceholder,i=e.getBoundingClientRect();this._width=i.width,this._height=i.height,this._marginLeft=Math.max(0,_e(e,"margin-left")),this._marginRight=Math.max(0,_e(e,"margin-right")),this._marginTop=Math.max(0,_e(e,"margin-top")),this._marginBottom=Math.max(0,_e(e,"margin-bottom")),t&&t.updateDimensions(this._width,this._height)}},it.prototype._refreshSortData=function(){if(!this._isDestroyed){var e,t=this._sortData={},i=this.getGrid()._settings.sortData;for(e in i)t[e]=i[e](this,this._element)}},it.prototype._destroy=function(e){if(!this._isDestroyed){var t=this._element,i=this.getGrid(),r=i._settings,n=i._items.indexOf(this);this._release.destroy(),this._migrate.destroy(),this._layout.destroy(),this._visibility.destroy(),this._animate.destroy(),this._animateChild.destroy(),this._dragPlaceholder.destroy(),this._drag&&this._drag.destroy(),t.removeAttribute("style"),this._child.removeAttribute("style"),Oe(t,r.itemClass),n>-1&&i._items.splice(n,1),e&&t.parentNode.removeChild(t),this._isActive=!1,this._isDestroyed=!0}},rt.prototype.getLayout=function(e,t,i,r,n){var s,o=this._layout,a=!(!n||!n.fillGaps),l=!(!n||!n.horizontal),h=!(!n||!n.alignRight),u=!(!n||!n.alignBottom),c=!(!n||!n.rounding),d=this._slotSizes;if(o.slots=r||this._slots,o.width=l?0:c?Math.round(t):t,o.height=l?c?Math.round(i):i:0,o.setWidth=l,o.setHeight=!l,o.slots.length=0,d.length=0,!e.length)return o;for(s=0;s<e.length;s++)this._addSlot(e[s],l,a,c,h||u);if(h)for(s=0;s<o.slots.length;s+=2)o.slots[s]=o.width-(o.slots[s]+d[s]);if(u)for(s=1;s<o.slots.length;s+=2)o.slots[s]=o.height-(o.slots[s]+d[s]);return d.length=0,this._freeSlots.length=0,this._newSlots.length=0,this._rectId=0,o},rt.prototype._addSlot=($e={},function(e,t,i,r,n){var s,o,a,l,h,u,c=this._layout,d=this._freeSlots,p=this._newSlots;for(p.length=0,$e.left=null,$e.top=null,$e.width=e._width+e._marginLeft+e._marginRight,$e.height=e._height+e._marginTop+e._marginBottom,r&&($e.width=Math.round($e.width),$e.height=Math.round($e.height)),h=0;h<d.length;h++)if((o=d[h])&&(s=this._getRect(o),$e.width<=s.width+.001&&$e.height<=s.height+.001)){$e.left=s.left,$e.top=s.top;break}for(null===$e.left&&($e.left=t?c.width:0,$e.top=t?0:c.height,i||(l=!0)),!t&&$e.top+$e.height>c.height&&($e.left>0&&p.push(this._addRect(0,c.height,$e.left,1/0)),$e.left+$e.width<c.width&&p.push(this._addRect($e.left+$e.width,c.height,c.width-$e.left-$e.width,1/0)),c.height=$e.top+$e.height),t&&$e.left+$e.width>c.width&&($e.top>0&&p.push(this._addRect(c.width,0,1/0,$e.top)),$e.top+$e.height<c.height&&p.push(this._addRect(c.width,$e.top+$e.height,1/0,c.height-$e.top-$e.height)),c.width=$e.left+$e.width),h=i?0:l?d.length:h;h<d.length;h++)if(o=d[h])for(s=this._getRect(o),a=this._splitRect(s,$e),u=0;u<a.length;u++)o=a[u],(s=this._getRect(o)).width>.49&&s.height>.49&&(!t&&s.top<c.height||t&&s.left<c.width)&&p.push(o);p.length&&this._purgeRects(p).sort(t?this._sortRectsLeftTop:this._sortRectsTopLeft),t?c.width=Math.max(c.width,$e.left+$e.width):c.height=Math.max(c.height,$e.top+$e.height),c.slots.push($e.left,$e.top),n&&this._slotSizes.push($e.width,$e.height),this._freeSlots=p,this._newSlots=d}),rt.prototype._addRect=function(e,t,i,r){var n=++this._rectId,s=this._rectStore;return s[n]=e||0,s[++this._rectId]=t||0,s[++this._rectId]=i||0,s[++this._rectId]=r||0,n},rt.prototype._getRect=function(e,t){var i=t||this._rectItem,r=this._rectStore;return i.left=r[e]||0,i.top=r[++e]||0,i.width=r[++e]||0,i.height=r[++e]||0,i},rt.prototype._splitRect=(Je=[],function(e,t){return Je.length=0,this._doRectsOverlap(e,t)?(e.left<t.left&&Je.push(this._addRect(e.left,e.top,t.left-e.left,e.height)),e.left+e.width>t.left+t.width&&Je.push(this._addRect(t.left+t.width,e.top,e.left+e.width-(t.left+t.width),e.height)),e.top<t.top&&Je.push(this._addRect(e.left,e.top,e.width,t.top-e.top)),e.top+e.height>t.top+t.height&&Je.push(this._addRect(e.left,t.top+t.height,e.width,e.top+e.height-(t.top+t.height))),Je):(Je.push(this._addRect(e.left,e.top,e.width,e.height)),Je)}),rt.prototype._doRectsOverlap=function(e,t){return!(e.left+e.width<=t.left||t.left+t.width<=e.left||e.top+e.height<=t.top||t.top+t.height<=e.top)},rt.prototype._isRectWithinRect=function(e,t){return e.left>=t.left&&e.top>=t.top&&e.left+e.width<=t.left+t.width&&e.top+e.height<=t.top+t.height},rt.prototype._purgeRects=(Ke={},Ze={},function(e){for(var t,i=e.length;i--;)if(t=e.length,e[i])for(this._getRect(e[i],Ke);t--;)if(e[t]&&i!==t&&this._isRectWithinRect(Ke,this._getRect(e[t],Ze))){e[i]=0;break}return e}),rt.prototype._sortRectsTopLeft=function(){var e={},t={};return function(i,r){return this._getRect(i,e),this._getRect(r,t),e.top<t.top?-1:e.top>t.top?1:e.left<t.left?-1:e.left>t.left?1:0}}(),rt.prototype._sortRectsLeftTop=function(){var e={},t={};return function(i,r){return this._getRect(i,e),this._getRect(r,t),e.left<t.left?-1:e.left>t.left?1:e.top<t.top?-1:e.top>t.top?1:0}}();function nt(e){var t=Object.prototype.toString.call(e);return"[object HTMLCollection]"===t||"[object NodeList]"===t}var st=Object.prototype.toString;function ot(e){return"object"==typeof e&&"[object Object]"===st.call(e)}function at(e){return nt(e)?Array.prototype.slice.call(e):Array.prototype.concat(e)}var lt=new rt,ht=function(){},ut="number",ct="string",dt="instant";function pt(t,i){var r,n,s,o,a,l,h=this;if(!((t=this._element=typeof t===ct?window.document.querySelector(t):t).getRootNode?t.getRootNode({composed:!0})===document:window.document.body.contains(t))||t===window.document.documentElement)throw new Error("Container element must be an existing DOM element");P((r=this._settings=(o=pt.defaultOptions,a=i,l=ft({},o),a&&(l=ft(l,a)),l.visibleStyles=(a||0).visibleStyles||(o||0).visibleStyles,l.hiddenStyles=(a||0).hiddenStyles||(o||0).hiddenStyles,l)).dragSort)||(r.dragSort=!!r.dragSort),this._id=tt(),e[this._id]=h,this._isDestroyed=!1,this._layout={id:0,items:[],slots:[],setWidth:!1,setHeight:!1,width:0,height:0},this._emitter=new f,se(t,r.containerClass),this._items=[],typeof(n=r.items)===ct?at(t.children).forEach((function(e){("*"===n||ne(e,n))&&h._items.push(new it(h,e))})):(Array.isArray(n)||nt(n))&&(this._items=at(n).map((function(e){return new it(h,e)}))),typeof(s=r.layoutOnResize)!==ut&&(s=!0===s?0:-1),s>=0&&window.addEventListener("resize",h._resizeHandler=fe((function(){h.refreshItems().layout()}),s)),r.layoutOnInit&&this.layout(!0)}function ft(e,t){var i,r,n,s=Object.keys(t),o=s.length;for(n=0;n<o;n++)i=ot(t[r=s[n]]),ot(e[r])&&i?e[r]=ft(ft({},e[r]),t[r]):i?e[r]=ft({},t[r]):Array.isArray(t[r])?e[r]=t[r].slice(0):e[r]=t[r];return e}return pt.Item=it,pt.ItemLayout=He,pt.ItemVisibility=Qe,pt.ItemMigrate=Xe,pt.ItemAnimate=A,pt.ItemDrag=Ie,pt.ItemRelease=Ye,pt.ItemDragPlaceholder=qe,pt.Emitter=f,pt.Dragger=G,pt.Packer=rt,pt.defaultOptions={items:"*",showDuration:300,showEasing:"ease",hideDuration:300,hideEasing:"ease",visibleStyles:{opacity:"1",transform:"scale(1)"},hiddenStyles:{opacity:"0",transform:"scale(0.5)"},layout:{fillGaps:!1,horizontal:!1,alignRight:!1,alignBottom:!1,rounding:!0},layoutOnResize:100,layoutOnInit:!0,layoutDuration:300,layoutEasing:"ease",sortData:null,dragEnabled:!1,dragContainer:null,dragStartPredicate:{distance:0,delay:0,handle:!1},dragAxis:null,dragSort:!0,dragSortHeuristics:{sortInterval:100,minDragDistance:10,minBounceBackAngle:1},dragSortPredicate:{threshold:50,action:i},dragReleaseDuration:300,dragReleaseEasing:"ease",dragCssProps:{touchAction:"none",userSelect:"none",userDrag:"none",tapHighlightColor:"rgba(0, 0, 0, 0)",touchCallout:"none",contentZooming:"none"},dragPlaceholder:{enabled:!1,duration:300,easing:"ease",createElement:null,onCreate:null,onRemove:null},containerClass:"muuri",itemClass:"muuri-item",itemVisibleClass:"muuri-item-shown",itemHiddenClass:"muuri-item-hidden",itemPositioningClass:"muuri-item-positioning",itemDraggingClass:"muuri-item-dragging",itemReleasingClass:"muuri-item-releasing",itemPlaceholderClass:"muuri-item-placeholder"},pt.prototype.on=function(e,t){return this._emitter.on(e,t),this},pt.prototype.off=function(e,t){return this._emitter.off(e,t),this},pt.prototype.getElement=function(){return this._element},pt.prototype.getItems=function(e){if(this._isDestroyed||!e&&0!==e)return this._items.slice(0);var t,i,r=[],n=at(e);for(i=0;i<n.length;i++)(t=this._getItem(n[i]))&&r.push(t);return r},pt.prototype.refreshItems=function(e){if(this._isDe