!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e=e||self).ReactDnD={},e.React)}(this,(function(e,t){"use strict";var r;!function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"}(r||(r={}));var n=function(e){var t,r=e.Symbol;return"function"==typeof r?r.observable?t=r.observable:(t=r("observable"),r.observable=t):t="@@observable",t}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof module?module:Function("return this")()),o=function(){return Math.random().toString(36).substring(7).split("").join(".")},i={INIT:"@@redux/INIT"+o(),REPLACE:"@@redux/REPLACE"+o(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+o()}};function a(e,t,r){var o;if("function"==typeof t&&"function"==typeof r||"function"==typeof r&&"function"==typeof arguments[3])throw new Error("It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function.");if("function"==typeof t&&void 0===r&&(r=t,t=void 0),void 0!==r){if("function"!=typeof r)throw new Error("Expected the enhancer to be a function.");return r(a)(e,t)}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var u=e,c=t,s=[],f=s,l=!1;function d(){f===s&&(f=s.slice())}function p(){if(l)throw new Error("You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return c}function g(e){if("function"!=typeof e)throw new Error("Expected the listener to be a function.");if(l)throw new Error("You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");var t=!0;return d(),f.push(e),function(){if(t){if(l)throw new Error("You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api-reference/store#subscribe(listener) for more details.");t=!1,d();var r=f.indexOf(e);f.splice(r,1)}}}function h(e){if(!function(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}(e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(l)throw new Error("Reducers may not dispatch actions.");try{l=!0,c=u(c,e)}finally{l=!1}for(var t=s=f,r=0;r2?r-2:0),o=2;o0&&void 0!==arguments[0]?arguments[0]:[],r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{publishSource:!0},n=r.publishSource,o=void 0===n||n,i=r.clientOffset,a=r.getSourceClientOffset,u=e.getMonitor(),c=e.getRegistry();e.dispatch(h(i)),O(t,u,c);var s=D(t,u);if(null!==s){var l=null;i&&(S(a),l=a(s)),e.dispatch(h(i,l));var d=c.getSource(s),p=d.beginDrag(u,s);w(p),c.pinSource(s);var g=c.getSourceType(s);return{type:f,payload:{itemType:g,item:p,sourceId:s,clientOffset:i||null,sourceClientOffset:l||null,isSourcePublic:!!o}}}e.dispatch(b)}}function O(e,t,r){c(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach((function(e){c(r.getSource(e),"Expected sourceIds to be registered.")}))}function S(e){c("function"==typeof e,"When clientOffset is provided, getSourceClientOffset must be a function.")}function w(e){c(v(e),"Item must be an object.")}function D(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 C(e){return function(){if(e.getMonitor().isDragging())return{type:l}}}function I(e,t){return null===t?null===e:Array.isArray(e)?e.some((function(e){return e===t})):e===t}function k(e){return function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.clientOffset;T(t);var o=t.slice(0),i=e.getMonitor(),a=e.getRegistry();E(o,i,a);var u=i.getItemType();return P(o,a,u),j(o,i,a),{type:d,payload:{targetIds:o,clientOffset:n||null}}}}function T(e){c(Array.isArray(e),"Expected targetIds to be an array.")}function E(e,t,r){c(t.isDragging(),"Cannot call hover while not dragging."),c(!t.didDrop(),"Cannot call hover after drop.");for(var n=0;n=0;n--){var o=e[n];I(t.getTargetType(o),r)||e.splice(n,1)}}function j(e,t,r){e.forEach((function(e){r.getTarget(e).hover(t,e)}))}function R(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 x(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:{},r=e.getMonitor(),n=e.getRegistry();_(r);var o=$(r);o.forEach((function(o,i){var a=N(o,i,n,r),u={type:p,payload:{dropResult:x({},t,{},a)}};e.dispatch(u)}))}}function _(e){c(e.isDragging(),"Cannot call drop while not dragging."),c(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function N(e,t,r,n){var o=r.getTarget(e),i=o?o.drop(n,e):void 0;return function(e){c(void 0===e||v(e),"Drop result must either be an object or undefined.")}(i),void 0===i&&(i=0===t?{}:n.getDropResult()),i}function $(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function H(e){return function(){var t=e.getMonitor(),r=e.getRegistry();!function(e){c(e.isDragging(),"Cannot call endDrag while not dragging.")}(t);var n=t.getSourceId();return r.getSource(n,!0).endDrag(t,n),r.unpinSource(),{type:g}}}var F=function(e,t){return e===t};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 L(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var V={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function G(){var e,t,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:V,n=arguments.length>1?arguments[1]:void 0,o=n.payload;switch(n.type){case s:case f:return{initialSourceClientOffset:o.sourceClientOffset,initialClientOffset:o.clientOffset,clientOffset:o.clientOffset};case d:return e=r.clientOffset,t=o.clientOffset,!e&&!t||e&&t&&e.x===t.x&&e.y===t.y?r:function(e){for(var t=1;t0&&void 0!==arguments[0]?arguments[0]:J,n=arguments.length>1?arguments[1]:void 0,o=n.payload;switch(n.type){case f:return K({},r,{itemType:o.itemType,item:o.item,sourceId:o.sourceId,isSourcePublic:o.isSourcePublic,dropResult:null,didDrop:!1});case l:return K({},r,{isSourcePublic:!0});case d:return K({},r,{targetIds:o.targetIds});case W:return-1===r.targetIds.indexOf(o.targetId)?r:K({},r,{targetIds:(e=r.targetIds,t=o.targetId,e.filter((function(e){return e!==t})))});case p:return K({},r,{dropResult:o.dropResult,didDrop:!0,targetIds:[]});case g:return K({},r,{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return r}}function Z(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;switch((arguments.length>1?arguments[1]:void 0).type){case q:case z:return e+1;case B:case W:return e-1;default:return e}}var ee=[],te=[];function re(e,t){return e!==ee&&(e===te||void 0===t||(r=e,t.filter((function(e){return r.indexOf(e)>-1}))).length>0);var r}function ne(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case d:break;case q:case z:case W:case B:return ee;case f:case l:case g:case p:default:return te}var t=e.payload,r=t.targetIds,n=void 0===r?[]:r,o=t.prevTargetIds,i=void 0===o?[]:o,a=function(e,t){var r=new Map,n=function(e){return r.set(e,r.has(e)?r.get(e)+1:1)};e.forEach(n),t.forEach(n);var o=[];return r.forEach((function(e,t){1===e&&o.push(t)})),o}(n,i);if(!(a.length>0||!function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:F;if(e.length!==t.length)return!1;for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:0)+1}function ie(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]:{},o=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:ne(n.dirtyHandlerIds,{type:o.type,payload:ae({},o.payload,{prevTargetIds:(e=n,t="dragOperation.targetIds",r=[],t.split(".").reduce((function(e,t){return e&&e[t]?e[t]:r||null}),e))})}),dragOffset:G(n.dragOffset,o),refCount:Z(n.refCount,o),dragOperation:Q(n.dragOperation,o),stateId:oe(n.stateId)}}function se(e,t){return{x:e.x-t.x,y:e.y-t.y}}function fe(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{handlerIds:void 0},n=r.handlerIds;c("function"==typeof e,"listener must be a function."),c(void 0===n||Array.isArray(n),"handlerIds, when specified, must be an array of strings.");var o=this.store.getState().stateId,i=function(){var r=t.store.getState(),i=r.stateId;try{i===o||i===o+1&&!re(r.dirtyHandlerIds,n)||e()}finally{o=i}};return this.store.subscribe(i)}},{key:"subscribeToOffsetChange",value:function(e){var t=this;c("function"==typeof e,"listener must be a function.");var r=this.store.getState().dragOffset;return this.store.subscribe((function(){var n=t.store.getState().dragOffset;n!==r&&(r=n,e())}))}},{key:"canDragSource",value:function(e){if(!e)return!1;var t=this.registry.getSource(e);return c(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 c(t,"Expected to find a valid target."),!(!this.isDragging()||this.didDrop())&&I(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 c(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),o=this.getItemType();if(o&&!I(n,o))return!1;var i=this.getTargetIds();if(!i.length)return!1;var a=i.indexOf(e);return r?a===i.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,o=e.initialClientOffset,i=e.initialSourceClientOffset,n&&o&&i?se((r=i,{x:(t=n).x+r.x,y:t.y+r.y}),o):null;var e,t,r,n,o,i}},{key:"getDifferenceFromInitialOffset",value:function(){return e=this.store.getState().dragOffset,t=e.clientOffset,r=e.initialClientOffset,t&&r?se(t,r):null;var e,t,r}}])&&fe(t.prototype,r),n&&fe(t,n),e}(),de=0;function pe(e){return(pe="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 ge(e,t){t&&Array.isArray(e)?e.forEach((function(e){return ge(e,!1)})):c("string"==typeof e||"symbol"===pe(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 he(e){ve.length||ye(),ve[ve.length]=e}var ye,ve=[],be=0,me=1024;function Oe(){for(;beme){for(var t=0,r=ve.length-be;t1&&void 0!==arguments[1]&&arguments[1];c(this.isSourceId(e),"Expected a valid source ID.");var r=t&&e===this.pinnedSourceId,n=r?this.pinnedSource:this.dragSources.get(e);return n}},{key:"getTarget",value:function(e){return c(this.isTargetId(e),"Expected a valid target ID."),this.dropTargets.get(e)}},{key:"getSourceType",value:function(e){return c(this.isSourceId(e),"Expected a valid source ID."),this.types.get(e)}},{key:"getTargetType",value:function(e){return c(this.isTargetId(e),"Expected a valid target ID."),this.types.get(e)}},{key:"isSourceId",value:function(e){return _e(e)===r.SOURCE}},{key:"isTargetId",value:function(e){return _e(e)===r.TARGET}},{key:"removeSource",value:function(e){var t=this;c(this.getSource(e),"Expected an existing source."),this.store.dispatch(function(e){return{type:B,payload:{sourceId:e}}}(e)),je((function(){t.dragSources.delete(e),t.types.delete(e)}))}},{key:"removeTarget",value:function(e){c(this.getTarget(e),"Expected an existing target."),this.store.dispatch(function(e){return{type:W,payload:{targetId:e}}}(e)),this.dropTargets.delete(e),this.types.delete(e)}},{key:"pinSource",value:function(e){var t=this.getSource(e);c(t,"Expected an existing source."),this.pinnedSourceId=e,this.pinnedSource=t}},{key:"unpinSource",value:function(){c(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(e,t,n){var o=Ae(e);return this.types.set(o,t),e===r.SOURCE?this.dragSources.set(o,n):e===r.TARGET&&this.dropTargets.set(o,n),o}}])&&xe(t.prototype,n),o&&xe(t,o),e}();function He(e,t){for(var r=0;r0&&void 0!==arguments[0]&&arguments[0];!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(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=function(e){var t="undefined"!=typeof window&&window.__REDUX_DEVTOOLS_EXTENSION__;return a(ce,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}(r);this.store=n,this.monitor=new le(n,new $e(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:m(e),publishDragSource:C(e),hover:k(e),drop:A(e),endDrag:H(e)}}(this);return Object.keys(r).reduce((function(n,o){var i,a=r[o];return n[o]=(i=a,function(){for(var r=arguments.length,n=new Array(r),o=0;o=0||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}var ze=0,Be=t.memo((function(e){var r=e.children,n=Ge(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]:Ye(),r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,o=t;o[We]||(o[We]=Ve(e,t,r,n));return o[We]}(e.backend,e.context,e.options,e.debugMode),r=!e.context;return[t,r]}(qe(e,["children"])),2),o=n[0],i=n[1];return t.useEffect((function(){return i&&ze++,function(){i&&(0===--ze&&(Ye()[We]=null))}}),[]),t.createElement(Le.Provider,{value:o},r)}));Be.displayName="DndProvider";var We=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__");function Ye(){return"undefined"!=typeof global?global:window}var Ke=t.memo((function(e){var t=e.connect,r=e.src;if("undefined"!=typeof Image){var n=new Image;n.src=r,n.onload=function(){return t(n)}}return null}));Ke.displayName="DragPreviewImage";var Xe="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function Je(e,t,r,n){var o=r?r.call(n,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(var u=Object.prototype.hasOwnProperty.bind(t),c=0;c or
. Read more: https://facebook.github.io/react/docs/more-about-refs.html#the-ref-callback-attribute"),n?t.cloneElement(e,{ref:function(e){st(n,e),st(r,e)}}):t.cloneElement(e,{ref:r})}function lt(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 dt(e){var r={};return Object.keys(e).forEach((function(n){var o=e[n];if(n.endsWith("Ref"))r[n]=e[n];else{var i=function(e){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(!t.isValidElement(r)){var o=r;return e(o,n),o}var i=r;lt(i);var a=n?function(t){return e(t,n)}:e;return ft(i,a)}}(o);r[n]=function(){return i}}})),r}function pt(e){return(pt="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 gt(e){return null!==e&&"object"===pt(e)&&e.hasOwnProperty("current")}function ht(e,t){for(var r=0;r1?t-1:0),n=1;n2?r-2:0),o=2;o1&&void 0!==arguments[1]?arguments[1]:{};return At("DragLayer","collect[, options]",e,r),c("function"==typeof e,'Expected "collect" provided as the first argument to DragLayer to be a function that collects props to inject into the component. ',"Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer",e),c(Rt(r),'Expected "options" provided as the second argument to DragLayer to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-layer',r),function(n){var o=n,i=r.arePropsEqual,a=void 0===i?Je:i,u=o.displayName||o.name||"Component",s=function(r){function n(){var e;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,n),(e=wr(this,Dr(n).apply(this,arguments))).isCurrentlyMounted=!1,e.ref=t.createRef(),e.handleChange=function(){if(e.isCurrentlyMounted){var t=e.getCurrentState();Je(t,e.state)||e.setState(t)}},e}var i,s,f;return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&Cr(e,t)}(n,r),i=n,(s=[{key:"getDecoratedComponentInstance",value:function(){return c(this.ref.current,"In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()"),this.ref.current}},{key:"shouldComponentUpdate",value:function(e,t){return!a(e,this.props)||!Je(t,this.state)}},{key:"componentDidMount",value:function(){this.isCurrentlyMounted=!0,this.handleChange()}},{key:"componentWillUnmount",value:function(){this.isCurrentlyMounted=!1,this.unsubscribeFromOffsetChange&&(this.unsubscribeFromOffsetChange(),this.unsubscribeFromOffsetChange=void 0),this.unsubscribeFromStateChange&&(this.unsubscribeFromStateChange(),this.unsubscribeFromStateChange=void 0)}},{key:"render",value:function(){var e=this;return t.createElement(Le.Consumer,null,(function(r){var n=r.dragDropManager;return void 0===n?null:(e.receiveDragDropManager(n),e.isCurrentlyMounted?t.createElement(o,Object.assign({},e.props,e.state,{ref:Mt(o)?e.ref:null})):null)}))}},{key:"receiveDragDropManager",value:function(e){if(void 0===this.manager){this.manager=e,c("object"===Or(e),"Could not find the drag and drop manager in the context of %s. Make sure to render a DndProvider component in your top-level component. Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context",u,u);var t=this.manager.getMonitor();this.unsubscribeFromOffsetChange=t.subscribeToOffsetChange(this.handleChange),this.unsubscribeFromStateChange=t.subscribeToStateChange(this.handleChange)}}},{key:"getCurrentState",value:function(){if(!this.manager)return{};var t=this.manager.getMonitor();return e(t,this.props)}}])&&Sr(i.prototype,s),f&&Sr(i,f),n}(t.Component);return s.displayName="DragLayer(".concat(u,")"),s.DecoratedComponent=n,Jt(s,n)}},e.DragPreviewImage=Ke,e.DragSource=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};At("DragSource","type, spec, collect[, options]",e,t,r,n);var o=e;"function"!=typeof e&&(c(dr(e),'Expected "type" provided as the first argument to DragSource to be a string, or a function that returns a string given the current props. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',e),o=function(){return e}),c(Rt(t),'Expected "spec" provided as the second argument to DragSource to be a plain object. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',t);var i=function(e){return Object.keys(e).forEach((function(t){c(gr.indexOf(t)>-1,'Expected the drag source specification to only have some of the following keys: %s. Instead received a specification with an unexpected "%s" key. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',gr.join(", "),t),c("function"==typeof e[t],"Expected %s in the drag source specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source",t,t,e[t])})),hr.forEach((function(t){c("function"==typeof e[t],"Expected %s in the drag source specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source",t,t,e[t])})),function(t,r){return new yr(e,t,r)}}(t);return c("function"==typeof r,'Expected "collect" provided as the third argument to DragSource to be a function that returns a plain object of props to inject. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',r),c(Rt(n),'Expected "options" provided as the fourth argument to DragSource to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source',r),function(e){return fr({containerDisplayName:"DragSource",createHandler:i,registerHandler:nt,createConnector:function(e){return new yt(e)},createMonitor:function(e){return new ct(e)},DecoratedComponent:e,getType:o,collect:r,options:n})}},e.DropTarget=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};At("DropTarget","type, spec, collect[, options]",e,t,r,n);var o=e;"function"!=typeof e&&(c(dr(e,!0),'Expected "type" provided as the first argument to DropTarget to be a string, an array of strings, or a function that returns either given the current props. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',e),o=function(){return e}),c(Rt(t),'Expected "spec" provided as the second argument to DropTarget to be a plain object. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',t);var i=function(e){return Object.keys(e).forEach((function(t){c(br.indexOf(t)>-1,'Expected the drop target specification to only have some of the following keys: %s. Instead received a specification with an unexpected "%s" key. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',br.join(", "),t),c("function"==typeof e[t],"Expected %s in the drop target specification to be a function. Instead received a specification with %s: %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target",t,t,e[t])})),function(t,r){return new mr(e,t,r)}}(t);return c("function"==typeof r,'Expected "collect" provided as the third argument to DropTarget to be a function that returns a plain object of props to inject. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',r),c(Rt(n),'Expected "options" provided as the fourth argument to DropTarget to be a plain object when specified. Instead, received %s. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target',r),function(e){return fr({containerDisplayName:"DropTarget",createHandler:i,registerHandler:rt,createMonitor:function(e){return new Ct(e)},createConnector:function(e){return new St(e)},DecoratedComponent:e,getType:o,collect:r,options:n})}},e.createDndContext=Ve,e.useDrag=function(e){var r=t.useRef(e);r.current=e,c(null!=e.item,"item must be defined"),c(null!=e.item.type,"item type must be defined");var n,o=mt((n=ot(),[t.useMemo((function(){return new ct(n)}),[n]),t.useMemo((function(){return new yt(n.getBackend())}),[n])]),2),i=o[0],a=o[1];!function(e,r,n){var o=ot(),i=t.useMemo((function(){return{beginDrag:function(){var t=e.current,n=t.begin,o=t.item;if(n){var i=n(r);return c(null==i||"object"===bt(i),"dragSpec.begin() must either return an object, undefined, or null"),i||o||{}}return o||{}},canDrag:function(){return"boolean"==typeof e.current.canDrag?e.current.canDrag:"function"!=typeof e.current.canDrag||e.current.canDrag(r)},isDragging:function(t,n){var o=e.current.isDragging;return o?o(r):n===t.getSourceId()},endDrag:function(){var t=e.current.end;t&&t(r.getItem(),r),n.reconnect()}}}),[]);Xe((function(){var t=vt(nt(e.current.item.type,i,o),2),a=t[0],u=t[1];return r.receiveHandlerId(a),n.receiveHandlerId(a),u}),[])}(r,i,a);var u=tt(i,r.current.collect||function(){return{}},(function(){return a.reconnect()})),s=t.useMemo((function(){return a.hooks.dragSource()}),[a]),f=t.useMemo((function(){return a.hooks.dragPreview()}),[a]);return Xe((function(){a.dragSourceOptions=r.current.options||null,a.reconnect()}),[a]),Xe((function(){a.dragPreviewOptions=r.current.previewOptions||null,a.reconnect()}),[a]),[u,s,f]},e.useDragLayer=function(e){var r=ot().getMonitor(),n=Tt(Ze(r,e),2),o=n[0],i=n[1];return t.useEffect((function(){return r.subscribeToOffsetChange(i)})),t.useEffect((function(){return r.subscribeToStateChange(i)})),o},e.useDrop=function(e){var r=t.useRef(e);r.current=e,c(null!=e.accept,"accept must be defined");var n,o=kt((n=ot(),[t.useMemo((function(){return new Ct(n)}),[n]),t.useMemo((function(){return new St(n.getBackend())}),[n])]),2),i=o[0],a=o[1];!function(e,r,n){var o=ot(),i=t.useMemo((function(){return{canDrop:function(){var t=e.current.canDrop;return!t||t(r.getItem(),r)},hover:function(){var t=e.current.hover;t&&t(r.getItem(),r)},drop:function(){var t=e.current.drop;if(t)return t(r.getItem(),r)}}}),[r]);Xe((function(){var t=It(rt(e.current.accept,i,o),2),a=t[0],u=t[1];return r.receiveHandlerId(a),n.receiveHandlerId(a),u}),[r,n])}(r,i,a);var u=tt(i,r.current.collect||function(){return{}},(function(){return a.reconnect()})),s=t.useMemo((function(){return a.hooks.dropTarget()}),[a]);return Xe((function(){a.dropTargetOptions=e.options||null,a.reconnect()}),[e.options]),[u,s]},Object.defineProperty(e,"__esModule",{value:!0})}));