!function(e){"use strict";var t="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function r(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{publishSource:!0},n=r.publishSource,i=void 0===n||n,o=r.clientOffset,a=r.getSourceClientOffset,u=e.getMonitor(),c=e.getRegistry();e.dispatch(O(o)),C(t,u,c);var s=N(t,u);if(null!==s){var l=null;o&&(P(a),l=a(s)),e.dispatch(O(o,l));var f=c.getSource(s),d=f.beginDrag(u,s);j(d),c.pinSource(s);var g=c.getSourceType(s);return{type:p,payload:{itemType:g,item:d,sourceId:s,clientOffset:o||null,sourceClientOffset:l||null,isSourcePublic:!!i}}}e.dispatch(E)}}function C(e,t,n){r(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach((function(e){r(n.getSource(e),"Expected sourceIds to be registered.")}))}function P(e){r("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")}function j(e){r(T(e),"Item must be an object.")}function N(e,t){for(var r=null,n=e.length-1;n>=0;n--)if(t.canDragSource(e[n])){r=e[n];break}return r}function x(e){return function(){if(e.getMonitor().isDragging())return{type:v}}}function R(e,t){return null===t?null===e:Array.isArray(e)?e.some((function(e){return e===t})):e===t}function M(e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.clientOffset;A(t);var i=t.slice(0),o=e.getMonitor(),a=e.getRegistry();_(i,o,a);var u=o.getItemType();return L(i,a,u),H(i,o,a),{type:y,payload:{targetIds:i,clientOffset:n||null}}}}function A(e){r(Array.isArray(e),"Expected targetIds to be an array.")}function _(e,t,n){r(t.isDragging(),"Cannot call hover while not dragging."),r(!t.didDrop(),"Cannot call hover after drop.");for(var i=0;i=0;n--){var i=e[n];R(t.getTargetType(i),r)||e.splice(n,1)}}function H(e,t,r){e.forEach((function(e){r.getTarget(e).hover(t,e)}))}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function F(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},r=e.getMonitor(),n=e.getRegistry();G(r);var i=W(r);i.forEach((function(i,o){var a=X(i,o,n,r),u={type:b,payload:{dropResult:F({},t,{},a)}};e.dispatch(u)}))}}function G(e){r(e.isDragging(),"Cannot call drop while not dragging."),r(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function X(e,t,n,i){var o=n.getTarget(e),a=o?o.drop(i,e):void 0;return function(e){r(void 0===e||T(e),"Drop result must either be an object or undefined.")}(a),void 0===a&&(a=0===t?{}:i.getDropResult()),a}function W(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function K(e){return function(){var t=e.getMonitor(),n=e.getRegistry();!function(e){r(e.isDragging(),"Cannot call endDrag while not dragging.")}(t);var i=t.getSourceId();return n.getSource(i,!0).endDrag(t,i),n.unpinSource(),{type:m}}}var V=function(e,t){return e===t};function q(e,t){return!e&&!t||!(!e||!t)&&(e.x===t.x&&e.y===t.y)}function z(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:V;if(e.length!==t.length)return!1;for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:$,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case h:case p:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case y:return q(e.clientOffset,r.clientOffset)?e:Q({},e,{clientOffset:r.clientOffset});case m:case b:return $;default:return e}}var te="dnd-core/ADD_SOURCE",re="dnd-core/ADD_TARGET",ne="dnd-core/REMOVE_SOURCE",ie="dnd-core/REMOVE_TARGET";function oe(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ae(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:ce,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case p:return ae({},e,{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case v:return ae({},e,{isSourcePublic:!0});case y:return ae({},e,{targetIds:r.targetIds});case ie:return-1===e.targetIds.indexOf(r.targetId)?e:ae({},e,{targetIds:S(e.targetIds,r.targetId)});case b:return ae({},e,{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case m:return ae({},e,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function le(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case te:case re:return e+1;case ne:case ie:return e-1;default:return e}}var fe=[],de=[];function ge(e,t){return e!==fe&&(e===de||void 0===t||(r=e,t.filter((function(e){return r.indexOf(e)>-1}))).length>0);var r}function he(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case y:break;case te:case re:case ie:case ne:return fe;case p:case v:case m:case b:default:return de}var t=e.payload,r=t.targetIds,n=void 0===r?[]:r,i=t.prevTargetIds,o=void 0===i?[]:i,a=I(n,o),u=a.length>0||!z(n,o);if(!u)return fe;var c=o[o.length-1],s=n[n.length-1];return c!==s&&(c&&a.push(c),s&&a.push(s)),a}function pe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return e+1}function ve(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function ye(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:he(e.dirtyHandlerIds,{type:t.type,payload:ye({},t.payload,{prevTargetIds:D(e,"dragOperation.targetIds",[])})}),dragOffset:ee(e.dragOffset,t),refCount:le(e.refCount,t),dragOperation:se(e.dragOperation,t),stateId:pe(e.stateId)}}function Oe(e,t){return{x:e.x-t.x,y:e.y-t.y}}function we(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{handlerIds:void 0},i=n.handlerIds;r("function"==typeof e,"listener must be a function."),r(void 0===i||Array.isArray(i),"handlerIds, when specified, must be an array of strings.");var o=this.store.getState().stateId,a=function(){var r=t.store.getState(),n=r.stateId;try{n===o||n===o+1&&!ge(r.dirtyHandlerIds,i)||e()}finally{o=n}};return this.store.subscribe(a)}},{key:"subscribeToOffsetChange",value:function(e){var t=this;r("function"==typeof e,"listener must be a function.");var n=this.store.getState().dragOffset;return this.store.subscribe((function(){var r=t.store.getState().dragOffset;r!==n&&(n=r,e())}))}},{key:"canDragSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return r(t,"Expected to find a valid source."),!this.isDragging()&&t.canDrag(this,e)}},{key:"canDropOnTarget",value:function(e){if(!e)return!1;var t=this.registry.getTarget(e);return r(t,"Expected to find a valid target."),!(!this.isDragging()||this.didDrop())&&R(this.registry.getTargetType(e),this.getItemType())&&t.canDrop(this,e)}},{key:"isDragging",value:function(){return Boolean(this.getItemType())}},{key:"isDraggingSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e,!0);return r(t,"Expected to find a valid source."),!(!this.isDragging()||!this.isSourcePublic())&&this.registry.getSourceType(e)===this.getItemType()&&t.isDragging(this,e)}},{key:"isOverTarget",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{shallow:!1};if(!e)return!1;var r=t.shallow;if(!this.isDragging())return!1;var n=this.registry.getTargetType(e),i=this.getItemType();if(i&&!R(n,i))return!1;var o=this.getTargetIds();if(!o.length)return!1;var a=o.indexOf(e);return r?a===o.length-1:a>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return this.store.getState().dragOperation.isSourcePublic}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return e=this.store.getState().dragOffset,n=e.clientOffset,i=e.initialClientOffset,o=e.initialSourceClientOffset,n&&i&&o?Oe((r=o,{x:(t=n).x+r.x,y:t.y+r.y}),i):null;var e,t,r,n,i,o}},{key:"getDifferenceFromInitialOffset",value:function(){return e=this.store.getState().dragOffset,t=e.clientOffset,r=e.initialClientOffset,t&&r?Oe(t,r):null;var e,t,r}}])&&we(t.prototype,n),i&&we(t,i),e}(),Se=0;function Te(e){return(Te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function Ie(e,t){t&&Array.isArray(e)?e.forEach((function(e){return Ie(e,!1)})):r("string"==typeof e||"symbol"===Te(e),t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}function Ee(e){Ce.length||ke(),Ce[Ce.length]=e}var ke,Ce=[],Pe=0;function je(){for(;Pe1024){for(var t=0,r=Ce.length-Pe;t1&&void 0!==arguments[1]&&arguments[1];r(this.isSourceId(e),"Expected a valid source ID.");var n=t&&e===this.pinnedSourceId,i=n?this.pinnedSource:this.dragSources.get(e);return i}},{key:"getTarget",value:function(e){return r(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}},{key:"getSourceType",value:function(e){return r(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}},{key:"getTargetType",value:function(e){return r(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}},{key:"isSourceId",value:function(e){return We(e)===n.SOURCE}},{key:"isTargetId",value:function(e){return We(e)===n.TARGET}},{key:"removeSource",value:function(e){var t=this;r(this.getSource(e),"Expected an existing source."),this.store.dispatch(function(e){return{type:ne,payload:{sourceId:e}}}(e)),Fe((function(){t.dragSources.delete(e),t.types.delete(e)}))}},{key:"removeTarget",value:function(e){r(this.getTarget(e),"Expected an existing target."),this.store.dispatch(function(e){return{type:ie,payload:{targetId:e}}}(e)),this.dropTargets.delete(e),this.types.delete(e)}},{key:"pinSource",value:function(e){var t=this.getSource(e);r(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}},{key:"unpinSource",value:function(){r(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(e,t,r){var i=Xe(e);return this.types.set(i,t),e===n.SOURCE?this.dragSources.set(i,r):e===n.TARGET&&this.dropTargets.set(i,r),i}}])&&Ye(t.prototype,i),o&&Ye(t,o),e}();function qe(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ze(e,t){for(var r=0;r0&&void 0!==arguments[0]&&arguments[0];qe(this,e),this.isSetUp=!1,this.handleRefCountChange=function(){var e=t.store.getState().refCount>0;t.backend&&(e&&!t.isSetUp?(t.backend.setup(),t.isSetUp=!0):!e&&t.isSetUp&&(t.backend.teardown(),t.isSetUp=!1))};var n=Je(r);this.store=n,this.monitor=new De(n,new Ve(n)),n.subscribe(this.handleRefCountChange)}var t,r,n;return t=e,(r=[{key:"receiveBackend",value:function(e){this.backend=e}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var e=this,t=this.store.dispatch,r=function(e){return{beginDrag:k(e),publishDragSource:x(e),hover:M(e),drop:Y(e),endDrag:K(e)}}(this);return Object.keys(r).reduce((function(n,i){var o,a=r[i];return n[i]=(o=a,function(){for(var r=arguments.length,n=new Array(r),i=0;i or
. Read more: https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute"),i?e.cloneElement(t,{ref:function(e){at(i,e),at(n,e)}}):e.cloneElement(t,{ref:n})}function ct(e){if("string"!=typeof e.type){var t=e.type.displayName||e.type.name||"the component";throw new Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a
, or turn it into a ")+"drag source or a drop target itself.")}}function st(t){var r={};return Object.keys(t).forEach((function(n){var i=t[n];if(n.endsWith("Ref"))r[n]=t[n];else{var o=function(t){return function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.isValidElement(r)){var i=r;return t(i,n),i}var o=r;ct(o);var a=n?function(e){return t(e,n)}:t;return ut(o,a)}}(i);r[n]=function(){return o}}})),r}function lt(e){return(lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ft(e){return null!==e&&"object"===lt(e)&&e.hasOwnProperty("current")}function dt(e,t){for(var r=0;r=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var Ct=0,Pt=e.memo((function(t){var r=t.children,n=Et(function(e){if("manager"in e){return[{dragDropManager:e.manager},!1]}var t=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Nt(),r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,i=t;i[jt]||(i[jt]=et(e,t,r,n));return i[jt]}(e.backend,e.context,e.options,e.debugMode),r=!e.context;return[t,r]}(kt(t,["children"])),2),i=n[0],o=n[1];return e.useEffect((function(){return o&&Ct++,function(){o&&(0===--Ct&&(Nt()[jt]=null))}}),[]),e.createElement($e.Provider,{value:i},r)}));Pt.displayName="DndProvider";var jt=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");function Nt(){return void 0!==t?t:window}function xt(e){var t=null;return function(){return null==t&&(t=e()),t}}function Rt(e,t){for(var r=0;r0}},{key:"leave",value:function(e){var t,r,n=this.entered.length;return this.entered=(t=this.entered.filter(this.isNodeInDocument),r=e,t.filter((function(e){return e!==r}))),n>0&&0===this.entered.length}},{key:"reset",value:function(){this.entered=[]}}])&&Rt(t.prototype,r),n&&Rt(t,n),e}(),At=xt((function(){return/firefox/i.test(navigator.userAgent)})),_t=xt((function(){return Boolean(window.safari)}));function Lt(e,t){for(var r=0;re))return r[u];s=u-1}}var f=e-t[a=Math.max(0,s)],d=f*f;return r[a]+n[a]*f+i[a]*d+o[a]*f*d}}])&&Lt(t.prototype,r),n&&Lt(t,n),e}();function Ut(e){var t=1===e.nodeType?e:e.parentElement;if(!t)return null;var r=t.getBoundingClientRect(),n=r.top;return{x:r.left,y:n}}function Ft(e){return{x:e.clientX,y:e.clientY}}function Bt(e,t,r,n,i){var o,a=function(e){return"IMG"===e.nodeName&&(At()||!document.documentElement.contains(e))}(t),u=Ut(a?e:t),c={x:r.x-u.x,y:r.y-u.y},s=e.offsetWidth,l=e.offsetHeight,f=n.anchorX,d=n.anchorY,g=function(e,t,r,n){var i=e?t.width:r,o=e?t.height:n;return _t()&&e&&(o/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:o}}(a,t,s,l),h=g.dragPreviewWidth,p=g.dragPreviewHeight,v=i.offsetX,y=i.offsetY,b=0===y||y;return{x:0===v||v?v:new Ht([0,.5,1],[c.x,c.x/s*h,c.x+h-s]).interpolate(f),y:b?y:(o=new Ht([0,.5,1],[c.y,c.y/l*p,c.y+p-l]).interpolate(d),_t()&&a&&(o+=(window.devicePixelRatio-1)*p),o)}}var Yt,Gt="__NATIVE_FILE__",Xt="__NATIVE_URL__",Wt="__NATIVE_TEXT__",Kt=Object.freeze({__proto__:null,FILE:Gt,URL:Xt,TEXT:Wt});function Vt(e,t,r){var n=t.reduce((function(t,r){return t||e.getData(r)}),"");return null!=n?n:r}function qt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var zt=(qt(Yt={},Gt,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items}},matchesTypes:["Files"]}),qt(Yt,Xt,{exposeProperties:{urls:function(e,t){return Vt(e,t,"").split("\n")}},matchesTypes:["Url","text/uri-list"]}),qt(Yt,Wt,{exposeProperties:{text:function(e,t){return Vt(e,t,"")}},matchesTypes:["Text","text/plain"]}),Yt);function Jt(e,t){for(var r=0;r-1}))}))[0]||null}function $t(e,t){for(var r=0;r