@cclr/trans 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var e=require("@cclr/react"),t=require("react"),r=require("@cclr/emitter"),n=require("@cclr/trigger"),o=require("@cclr/front"),i=require("react/jsx-runtime"),u=require("react-dom");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t,r){return t=d(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,p()?Reflect.construct(t,r||[],d(e).constructor):t.apply(e,r))}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,x(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return(t=x(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function g(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}function v(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 y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function h(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||w(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function x(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function w(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}Function.prototype.call.bind(Object.prototype.hasOwnProperty);var D=Function.prototype.call.bind(Object.prototype.toString),O={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function E(e){return O[typeof e]||O[D(e)]||(e?"object":"null")}function I(e){return function(e){return null===e}(e)||function(e){return void 0===e}(e)}function S(e){return"function"===E(e)}function k(e){return function(e){return"object"===E(e)}(e)&&Object.getPrototypeOf(e)===Object.prototype}var C={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:function(){},regexp:/(?:)/};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||z(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(e,t){if(e){if("string"==typeof e)return P(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}var A=Object.freeze({__proto__:null,extend:function(e,t){var r=e||{};return k(t)&&Object.keys(t).forEach((function(e){r[e]=t[e]})),r},filter:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:I,r={};return k(e)&&Object.entries(e).forEach((function(n){var o=R(n,2),i=o[0],u=o[1];t(e[i],i)&&(r[i]=u)})),r},forEach:function(e,t){Object.keys(e).forEach((function(r){t(e[r],r)}))},format:function(e,t){var r,n=k(e)?e:{},o=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=z(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw o}}}}(t);try{for(o.s();!(r=o.n()).done;){var i=r.value,u=R(i,3),a=u[0],s=u[1],c=u[2];E(n[a])!==s&&(3!==i.length?n[a]=C[s]:n[a]=c)}}catch(e){o.e(e)}finally{o.f()}return n},omit:function(e,t){var r={};return k(e)&&Object.entries(e).forEach((function(e){var n=R(e,2),o=n[0],i=n[1];t.includes(o)||(r[o]=i)})),r},pick:function(e,t){return t.reduce((function(t,r){return r in e&&(t[r]=e[r]),t}),{})}}),T=m(e.createCtx({}),2),B=T[0],F=T[1],N=m(e.createCtx({}),2),M=N[0],X=N[1],Y=function(){var e=M().baseCore;return{start:e.start,move:e.move,end:e.end,mouseEvent:e.mouseEvent,getData:e.getData,reset:e.reset,addUser:e.addUser,onDragMove:e.onDragMove,onStatus:e.onStatus,onDomEvent:e.onDomEvent}},_=function(){var e=Y().onStatus,r=m(t.useState({}),2),n=r[0],o=r[1];return t.useEffect((function(){return e((function(e,t){o(t)}))}),[]),n};var q,U,W="data-trans-box-type",L="data-trans-box-id",$="data-trans-box-data",Z=function(e){return e[e.drag=1]="drag",e[e.drop=2]="drop",e[e.resize=4]="resize",e[e.select=8]="select",e[e.stop=64]="stop",e[e.boundary=128]="boundary",e}({}),H=(q=[Z.drag,Z.drop,Z.resize,Z.select,Z.stop,Z.boundary],U=[],function e(t,r){if(t.length&&U.push(t),0!==r.length)for(var n=0;n<r.length;n++)e(t.concat(r[n]),r.slice(0,n))}([],q),U).reduce((function(e,t){var r=t.reduce((function(e,t){return e|t}),0);return e[r.toString()]=r,e}),{}),V=function(e){if(e)return e.getAttribute($)},G=function(e,t){e&&e.setAttribute(L,t.toString())},J=function(e){if(e)return e.getAttribute(L)},K=function(e,t){if(e){var r=e.getAttribute(W)||"",n=(H[r]||0)|t;e.setAttribute(W,n.toString())}},Q=function(e){if(e)return H[e.getAttribute(W)||""]},ee=function(e,t){for(var r=e,n=[],o=[],i=[];r&&r!==document.body;){var u=Q(r);u&&(!t||t&u)&&(n.push(u),o.push(J(r)),i.push(V(r))),r=r.parentElement}return{types:n,ids:o,datas:i}},te=function(){var r=Y(),n=r.start,u=r.move,a=r.end,s=r.reset,c=r.mouseEvent,f=r.getData,l=t.useRef({free:!0,timer:null}),d=function(){clearTimeout(l.current.timer),l.current.timer=null,c("drag")},g=e.useCallbackRef((function(e){var t;if(clearTimeout(l.current.timer),(null==e||null===(t=e.target)||void 0===t?void 0:t.nodeType)===Node.ELEMENT_NODE){l.current.free=!1;var r=ee(e.target),o=e.clientX,i=e.clientY;n({startClientX:o,startClientY:i},r),c("down"),l.current.timer=setTimeout(d,120)}})),p=e.useCallbackRef((function(e){if(!l.current.free){var t=e.clientX,r=e.clientY,n=f(),o=t-n.startClientX,i=r-n.startClientY;(o>30||i>30)&&d(),u({clientX:t,clientY:r,spaceX:o,spaceY:i})}})),v=e.useCallbackRef((function(e){if(clearTimeout(l.current.timer),!l.current.free){l.current.timer&&(c("tap"),l.current.timer=null);var t=e.clientX,r=e.clientY,n=f(),o=n.startClientX,i=n.startClientY;a({clientX:t,clientY:r,spaceX:t-o,spaceY:r-i})}l.current.free=!0,setTimeout((function(){s()}),0)}));return t.useEffect((function(){return o.addEventListenerMultiple(window,{mousedown:g,mousemove:p,mouseup:v})}),[]),i.jsx(i.Fragment,{})},re=f((function e(t){c(this,e),l(this,"baseCore",void 0),this.baseCore=t})),ne={status:"free",users:[],position:{startClientX:0,startClientY:0,clientX:0,clientY:0,spaceX:0,spaceY:0},level:{types:[],ids:[],datas:[]},eventType:"free"},oe=f((function e(){var t=this;c(this,e),l(this,"triggers",n.dataTriggers(ne)),l(this,"onDragMove",(function(e){return t.triggers.onChange("position",(function(){e(t.getData())}))})),l(this,"onStatus",(function(e){var r;return t.triggers.onChange("status",(function(n){r!==n&&(r=n,e(n,t.getBaseData()))}))})),l(this,"onDomEvent",(function(e,r){return t.triggers.onChange("eventType",(function(n){e===n&&r(t.getBaseData())}))})),l(this,"getData",(function(){return y(y({},t.triggers.getter(["status","users"])),t.triggers.getter("position"))})),l(this,"getBaseData",(function(){return t.triggers.getter(["status","users","position","level","eventType"])})),l(this,"reset",(function(){t.triggers.setter(ne)})),l(this,"descroy",(function(){t.triggers.destroy()}))})),ie=function(){function e(){var t;c(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return l(t=s(this,e,[].concat(n)),"start",(function(e,r){t.triggers.setter({position:function(t){return y(y({},t),e)},status:"start",level:r})})),l(t,"move",(function(e){t.triggers.setter({position:function(t){return y(y({},t),e)},status:"move"})})),l(t,"end",(function(e){t.triggers.setter({position:function(t){return y(y({},t),e)},status:"end"})})),l(t,"mouseEvent",(function(e){t.triggers.setter({eventType:e})})),l(t,"addUser",(function(e){t.triggers.setter({users:function(t){return[].concat(j(t),[e])}})})),t}return g(e,oe),f(e)}(),ue=function(r){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=Y().onDragMove,i=e.useThrottleFn(r,{wait:60}),u=i.run,a=i.fun,s=i.cancel;t.useEffect((function(){if(n)return o((function(e){return"start"===e.status||"free"===e.status||"end"===e.status?(s(),a(e)):u(e)}))}),[n])},ae={dragId:"",item:void 0,type:"",offset:{x:0,y:0,w:0,h:0},renderFake:!0},se=function(){function e(){var t;c(this,e);for(var o=arguments.length,i=new Array(o),u=0;u<o;u++)i[u]=arguments[u];return l(t=s(this,e,[].concat(i)),"triggers",n.dataTriggers(ae)),l(t,"dragEmitter",new r.Emitter),l(t,"onDragEvent",(function(e,r){return t.dragEmitter.addListener(e,r)})),l(t,"onDraggingId",(function(e){return t.triggers.onChange("dragId",(function(){e(t.getDraggingData())}))})),l(t,"getDraggingData",(function(){return t.triggers.getter(["dragId","item","type","offset","renderFake"])})),l(t,"reset",(function(){t.triggers.setter(ae)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),ce=function(){function e(t){var r;return c(this,e),l(r=s(this,e,[t]),"setDragData",(function(e){r.triggers.getter("dragId")||r.triggers.setter(y(y({},e),{},{renderFake:function(){return e.renderFake}}))})),l(r,"emitDrag",(function(e){r.dragEmitter.emit(e,{})})),r.init(),r}return g(e,se),f(e,[{key:"init",value:function(){var e=this;this.baseCore.onStatus((function(t){"free"===t&&e.reset()}))}}])}(),fe={stack:[],dropId:"",item:void 0,accept:[]},le=function(){function e(){var t;c(this,e);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return l(t=s(this,e,[].concat(o)),"triggers",n.dataTriggers(fe)),l(t,"onDropStack",(function(e){t.triggers.onChange("stack",e)})),l(t,"onDropId",(function(e){t.triggers.onChange("dropId",(function(){e(t.getDropData())}))})),l(t,"getDropStack",(function(){return t.triggers.getter("stack")})),l(t,"getDropData",(function(){return t.triggers.getter(["dropId","item","accept"])})),l(t,"getStack",(function(){return t.triggers.getter(["stack"])})),l(t,"reset",(function(){t.triggers.setter(fe)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),de=function(){function e(t){var r;return c(this,e),l(r=s(this,e,[t]),"setDropInfo",(function(e){r.triggers.setter(e)})),l(r,"setDropStack",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r.triggers.setter({stack:e})})),r.init(),r}return g(e,le),f(e,[{key:"init",value:function(){var e=this;this.baseCore.onStatus((function(t){"free"===t&&e.reset()}))}}])}(),ge=function(e){var r=t.useRef();return e||r},pe=function(){var e=M().dragCore,t=e.setDragData,r=e.getDraggingData;return{dragCore:e,onDragId:e.onDraggingId,onDragEvent:e.onDragEvent,emitDrag:e.emitDrag,setDragData:t,getDraggingData:r,reset:e.reset}},ve=function(){var e=pe().onDragId,r=m(t.useState({}),2),n=r[0],o=r[1];return t.useEffect((function(){return e((function(e){o(e)}))}),[]),n},ye=function(){return M().dndMonitor},he=function(r){var n=r.id,o=r.item,i=r.type,u=r.renderFake,a=ye(),s=Y(),c=s.getData,f=s.addUser,l=pe(),d=l.setDragData,g=l.onDragEvent,p=ve().dragId,v=p===n,y=ge(r.domRef),h=e.useCallbackRef((function(){var e=c(),t=e.startClientX,r=e.startClientY,s=y.current.getBoundingClientRect(),l=s.left,g=s.top,p=s.width,v=s.height;f("dnd"),d({dragId:n,item:o,type:i,offset:{x:t-l,y:r-g,w:p,h:v},renderFake:S(u)?u.bind(null,a):u})}));return t.useEffect((function(){return K(y.current,Z.drag),G(y.current,n),g(n,h)}),[]),[{id:n,item:o,draggingId:p,isDragging:v},y]},be=function(){var e=M().dropCore,t=e.setDropInfo,r=e.setDropStack,n=e.reset;return{dropCore:e,getDropData:e.getDropData,setDropInfo:t,setDropStack:r,reset:n,onDropStack:e.onDropStack,onDropId:e.onDropId}},me=function(r){var n=r.id,o=r.item,i=r.accept,u=r.onOver,a=r.onDroped,s=ge(r.domRef),c=ye(),f=function(){var e=be().onDropStack,r=m(t.useState([]),2),n=r[0],o=r[1];return t.useEffect((function(){return e((function(e){o(e)}))}),[]),n}(),l=be().setDropInfo,d=n||e.useUuid(),g=ve(),p=g.dragId,v=g.type,h=p&&f[0]===d,b=!(null!=i&&i.length)||(null==i?void 0:i.includes(v||"")),j=function(e){var t,r=(null===(t=s.current)||void 0===t?void 0:t.getBoundingClientRect())||{left:0,top:0},n=r.left,o=r.top;return{offsetX:e.clientX-n,offsetY:e.clientY-o}},x=e.useThrottleFn((function(e){h&&(null==u||u(y(y({},c),{},{getDropPos:function(){return j(e)}})))})),w=x.run;return e.useEventListenerMultiple(s,{mousemove:w,mouseup:function(e){h&&(l({dropId:d,accept:i,item:o}),null==a||a(y(y({},c),{},{getDropPos:function(){return j(e)}})))}}),t.useEffect((function(){K(s.current,Z.drop),G(s.current,d)}),[]),[{id:d,item:o,accept:i,isOver:h,isAccept:b},s]},je=["className","style","children"],xe=t.forwardRef((function(e,r){var n=e.className,u=e.style,a=e.children,s=h(e,je);return t.isValidElement(a)&&function(e){return"string"===E(e)}(a.type)?t.cloneElement(a,y(y({},s),{},{ref:r,className:o.classNames(n,a.props.className),style:A.extend(u,a.props.style)})):i.jsx("div",y(y({ref:r},s),{},{style:u,className:n,children:a}))})),we=["id","renderFake"],De=function(e){var t=e.className,r=e.style,n=e.children,o=B(),u=o.id,a=o.renderFake,s=h(o,we),c=_().status,f=m(he(y({id:u,renderFake:I(a)||a},s)),2),l=f[0].isDragging,d={ref:f[1],className:t,style:y(y({},r),{},{cursor:"move"!==c?"grab":void 0,pointerEvents:l?"none":"unset"})};return i.jsx(xe,y(y({},d),{},{children:n}))},Oe=function(e){var t=e.className,r=e.style,n=e.children,o=e.onOver,u=e.onDroped,a=e.item,s=e.accept,c=e.id,f=m(me({id:c,item:a||{},accept:s||[],onDroped:function(e){var t=e.getDropPos(),r=t.offsetX,n=t.offsetY,o=e.getDraggingBaseData(),i=o.dragId,a=o.offset;g&&(null==u||u(i,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h}))},onOver:function(e){var t=e.getDropPos(),r=t.offsetX,n=t.offsetY,i=e.getDraggingBaseData(),u=i.dragId,a=i.offset;null==o||o(u,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h})}}),2),l=f[0],d=l.isOver,g=l.isAccept,p={ref:f[1],className:t,style:y({boxShadow:d?g?"0 0 4px 1px #1f90fc":"0 0 4px 1px orange":"none"},r)};return i.jsx(xe,y(y({},p),{},{children:n}))},Ee={lt:"nwse-resize",rt:"nesw-resize",lb:"nesw-resize",rb:"nwse-resize",t:"ns-resize",l:"ew-resize",r:"ew-resize",b:"ns-resize"},Ie=function(e){var r=e.hidden,n=e.handles,o=e.id;return r?i.jsx(i.Fragment,{}):(n||["lt","l","lb","t","b","rt","r","rb"]).map((function(e){return t.createElement("span",y(y({},l(l(l({},W,Z.resize),L,o),$,e)),{},{key:e,style:Pe[e]}))}))},Se={position:"absolute",left:0,top:0,transform:"translate(-50%, -50%)",backgroundColor:"green"},ke=y(y({},Se),{},{width:"20px",height:"20px",borderRadius:"2px"}),Ce=y(y({},Se),{},{width:"6px",height:"6px"}),Pe={lt:y(y({},Ce),{},{cursor:Ee.lt}),lb:y(y({},Ce),{},{top:"100%",cursor:Ee.lb}),rt:y(y({},Ce),{},{left:"100%",cursor:Ee.rt}),rb:y(y({},Ce),{},{left:"100%",top:"100%",cursor:Ee.rb}),l:y(y({},ke),{},{top:"50%",width:Ce.height,cursor:Ee.l}),r:y(y({},ke),{},{left:"100%",top:"50%",width:Ce.width,cursor:Ee.r}),t:y(y({},ke),{},{left:"50%",height:Ce.height,cursor:Ee.t}),b:y(y({},ke),{},{left:"50%",top:"100%",height:Ce.height,cursor:Ee.b})},Re={id:"",info:{},startCoord:{x:0,y:0,w:0,h:0}},ze=function(){function e(){var t;c(this,e);for(var o=arguments.length,i=new Array(o),u=0;u<o;u++)i[u]=arguments[u];return l(t=s(this,e,[].concat(i)),"triggers",n.dataTriggers(Re)),l(t,"resizeEmitter",new r.Emitter),l(t,"onBaseInfo",(function(e){return t.triggers.onChange("id",(function(){e(t.getBaseInfo())}))})),l(t,"onResizeEvent",(function(e,r){return t.resizeEmitter.addListener(e,r)})),l(t,"getBaseInfo",(function(){return t.triggers.getter(["id","info","handle","startCoord"])})),l(t,"reset",(function(){t.triggers.setter(Re)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),Ae=function(){function e(t){var r;return c(this,e),l(r=s(this,e,[t]),"setBaseInfo",(function(e){r.triggers.setter(e)})),l(r,"emitResize",(function(e,t){r.resizeEmitter.emit(e,t)})),r.init(),r}return g(e,ze),f(e,[{key:"init",value:function(){var e=this;this.baseCore.onStatus((function(t){"free"===t&&e.reset()}))}}])}(),Te=function(){var e=M().resizeCore;return{reset:e.reset,descroy:e.descroy,getBaseInfo:e.getBaseInfo,onBaseInfo:e.onBaseInfo,emitResize:e.emitResize,onResizeEvent:e.onResizeEvent,setBaseInfo:e.setBaseInfo}},Be=function(){var e=Te().onBaseInfo,r=m(t.useState({}),2),n=r[0],o=r[1];return t.useEffect((function(){return e(o)}),[]),n},Fe=function(r){var n=r.id,o=r.onResizing,i=r.onResized,u=r.domRef,a=Y().addUser,s=Te(),c=s.setBaseInfo,f=s.onResizeEvent,l=Be(),d=l.id,g=l.handle,p=l.startCoord,v=d===n,h=e.useCallbackRef((function(e){var t;a("resize");var r=(null==u||null===(t=u.current)||void 0===t?void 0:t.getBoundingClientRect())||{x:0,y:0,width:0,height:0},o=r.x,i=r.y,s=r.width,f=r.height;c({id:n,startCoord:{x:o,y:i,w:s,h:f},info:{},handle:e})}));return t.useEffect((function(){f(n,h)}),[]),ue((function(e){if("free"!==e.status){var t=function(e,t,r){var n=y({},e),o=n.h,i=n.w,u=n.x,a=n.y,s=t.spaceX,c=t.spaceY;switch(r){case"lt":n.x=u+s,n.y=a+c,n.w=i-s,n.h=o-c;break;case"rt":n.x=u,n.y=a+c,n.w=i+s,n.h=o-c;break;case"lb":n.x=u+s,n.y=a,n.w=i-s,n.h=o+c;break;case"rb":n.x=u,n.y=a,n.w=i+s,n.h=o+c;break;case"l":n.x=u+s,n.y=a,n.w=i-s,n.h=o;break;case"r":n.x=u,n.y=a,n.w=i+s,n.h=o;break;case"b":n.x=u,n.y=a,n.w=i,n.h=o+c;break;case"t":n.x=u,n.y=a+c,n.w=i,n.h=o-c}return n}(p,e,g);null==o||o(t),"end"===e.status&&(null==i||i(t))}}),v&&!!o),[{isResizing:v},{}]},Ne=["children","style","pure","className"];function Me(e,t,r){return(t=qe(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Xe(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;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Xe(Object(r),!0).forEach((function(t){Me(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Xe(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _e(e,t){return _e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_e(e,t)}function qe(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function Ue(){Ue=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,o){var i=RegExp(e,n);return t.set(i,o||t.get(e)),_e(i,r.prototype)}function n(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var o=n[r];if("number"==typeof o)t[r]=e[o];else{for(var i=0;void 0===e[o[i]]&&i+1<o.length;)i++;t[r]=e[o[i]]}return t}),Object.create(null))}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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_e(e,t)}(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=n(r,this);var o=r.indices;o&&(o.groups=n(o,this))}return r},r.prototype[Symbol.replace]=function(r,o){if("string"==typeof o){var i=t.get(this);return e[Symbol.replace].call(this,r,o.replace(/\$<([^>]+)>/g,(function(e,t){var r=i[t];return"$"+(Array.isArray(r)?r.join("$"):r)})))}if("function"==typeof o){var u=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(n(e,u)),o.apply(this,e)}))}return e[Symbol.replace].call(this,r,o)},Ue.apply(this,arguments)}var We=function(e,t){return e.reduce((function(e,r){var n=r[t];return Ye(Ye({},e),{},Me({},n,r))}),{})},Le=function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36,t=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"],r=[],n=0;n<e;n++)r[n]=8===n||13===n||18===n||23===n?"-":t[Math.ceil(Math.random()*t.length-1)];return r.join("")};!function(e,t){t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,qe(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Me(this,"handler",[])}),[{key:"use",value:function(e,t){return this.handler.push({fulfilled:e,rejected:t}),this.handler.length-1}},{key:"eject",value:function(e){this.handler[e]&&(this.handler[e]=null)}},{key:"clear",value:function(){this.handler=[]}},{key:"forEach",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(e,t,r){if(r)for(var n=e.length-1;n>=0;n--)t(e[n],n,e);else for(var o=0;o<e.length;o++)t(e[o],o,e)}(this.handler,(function(t){t&&e(t)}),t)}},{key:"run",value:function(e){var t=arguments;return new Promise(function(r,n){var o=t.length>1&&void 0!==t[1]&&t[1],i=Promise.resolve(e());return this.forEach((function(e){i=i.then(e.fulfilled,e.rejected)}),o),r(i)}.bind(this))}}]),Ue(/\?([^#]*)/,{query:1}),Ue(/#(.*)/,{hash:1}),Ue(/^(?:[a-zA-Z][a-zA-Zd+-.]*:)?(?:\/\/(?:[^@/?#]*@)?[^/?#]*)?([^?#]*)/,{pathname:1});var $e=["show","dom"],Ze=function(e){var t=e.show,r=e.dom,n=h(e,$e);return t&&r?u.createPortal(i.jsx("div",{style:{position:"absolute",inset:0},children:i.jsx(Ie,y({},n))}),r):i.jsx(i.Fragment,{})},He={ids:[],infoMap:{}},Ve=function(){function e(){var t;c(this,e);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return l(t=s(this,e,[].concat(o)),"triggers",n.dataTriggers(He)),l(t,"onSelectIds",(function(e){return t.triggers.onChange("ids",(function(){e(t.getSelectInfo())}))})),l(t,"getSelectInfo",(function(){return t.triggers.getter(["ids","infoMap"])})),l(t,"reset",(function(){t.triggers.setter(He)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),Ge=function(){function e(){var t;c(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return l(t=s(this,e,[].concat(n)),"setSelectIds",(function(e){t.triggers.setter({ids:e})})),t}return g(e,Ve),f(e)}(),Je=function(){var e=M().selectCore,t=e.reset,r=e.setSelectIds,n=e.descroy,o=e.onSelectIds;return{getSelectInfo:e.getSelectInfo,setSelectIds:r,onSelectIds:o,reset:t,descroy:n}},Ke=function(e){var r,n,o,i,u,a,s=e.id,c=e.domRef,f=(r=Je(),n=r.onSelectIds,o=r.getSelectInfo,i=m(t.useState(o()),2),u=i[0],a=i[1],t.useEffect((function(){return n((function(e){a(e)}))}),[]),u),l=f.ids,d=f.infoMap[s],g=l.includes(s);return t.useEffect((function(){K(null==c?void 0:c.current,Z.select)}),[]),[{isSelect:g,selectInfo:d}]},Qe=function(e){var r=e.id,n=e.coord,o=e.item,u=e.className,a=e.onResizing,s=e.onOver,c=e.onDroped,f=_().status,l=m(he({id:r,renderFake:!0,item:o}),2),d=l[0].isDragging,g=l[1],p=m(Ke({id:r,domRef:g}),1)[0].isSelect;Fe({id:r,onResizing:a,domRef:g}),me({id:r,item:o,domRef:g,onOver:s,onDroped:c});var v=t.useMemo((function(){return{left:n.x,top:n.y,width:n.w,height:n.h,cursor:"move"!==f?"grab":void 0,pointerEvents:d?"none":"unset"}}),[n,f,d]),h=t.useMemo((function(){return{boxShadow:p?"0 0 4px 1px #0078d4":void 0}}),[p]),b=t.useMemo((function(){return{contain:p?"layout":void 0}}),[p]);return i.jsxs(i.Fragment,{children:[i.jsx(Ze,{show:p&&!d,id:r,dom:g.current}),i.jsx(xe,{ref:g,className:u,style:y(y(y(y({},v),h),b),e.style),children:e.children})]})},et=["className","style","children"],tt=function(){var e=ve().dragId,r=Be(),n=r.handle,o=r.id,u=Y().getData;return t.useEffect((function(){var t=u().users[0];e&&"dnd"===t?(document.body.style.cursor="grabbing",document.body.style.userSelect="none"):n&&"resize"===t?(document.body.style.cursor=Ee[n],document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")}),[e,n,o]),i.jsx(i.Fragment,{})},rt=function(){var e=Y().onDomEvent,r=pe().emitDrag;return t.useEffect((function(){return e("drag",(function(e){var t=e.level,n=t.types,o=t.ids;if(!(n[0]&Z.resize)){var i=n.findIndex((function(e){return e&Z.drag}));if(!(i<0)){var u=o[i];u&&r(u)}}}))}),[]),i.jsx(i.Fragment,{})},nt=function(){var e=ve(),r=e.dragId,n=e.offset,o=e.renderFake,a=m(t.useState(""),2),s=a[0],c=a[1],f=m(t.useState(!1),2),l=f[0],d=f[1],g=t.useRef({timer:null}),p=function(e){var t=e.clientX,r=e.clientY,o=n,i=o.x,u=o.y;c("translate(".concat(t-(i||0),"px, ").concat(r-(u||0),"px)"))},v=function(e){clearTimeout(g.current.timer),p(e),g.current.timer=setTimeout((function(){d(!0),g.current.timer=null}),100)};ue((function(e){switch(e.status){case"start":v(e);break;case"end":clearTimeout(g.current.timer),g.current.timer=setTimeout((function(){d(!1),c(""),g.current.timer=null}),100);break;case"move":g.current.timer?p(e):v(e)}}),!!r);var y=t.useMemo((function(){return S(o)?o():i.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.5)"}})}),[o]);return u.createPortal(i.jsx("div",{style:{position:"fixed",pointerEvents:"none",left:0,top:0,width:0,height:0,zIndex:1e3},children:o?i.jsx("div",{style:{display:l&&r?"block":"none",position:"absolute",transition:r?"transform linear 0.1s":"",width:null==n?void 0:n.w,height:null==n?void 0:n.h,transform:s},children:y}):i.jsx(i.Fragment,{})}),document.body)},ot=function(){var r=ve().dragId,n=be().setDropStack,u=e.useCallbackRef((function(e){if(r){var t=ee(e.target,Z.drop).ids;n(t.filter(Boolean))}})),a=e.useCallbackRef((function(){setTimeout((function(){n()}),0)}));return t.useEffect((function(){if(r)return o.addEventListenerMultiple(window,{mouseover:u,mouseup:a})}),[!!r]),i.jsx(i.Fragment,{})},it=function(){var e=Y().onDomEvent,r=Te().emitResize;return t.useEffect((function(){return e("down",(function(e){var t=e.level,n=t.types,o=t.ids,i=t.datas;if(n[0]&Z.resize){var u=o[0],a=i[0];r(u,a)}}))}),[]),i.jsx(i.Fragment,{})},ut=function(){var e=Je(),r=e.setSelectIds,n=e.reset,o=Y().onDomEvent;return t.useEffect((function(){return o("tap",(function(e){var t=e.level,o=t.types,i=t.ids,u=o.findIndex((function(e){return e&Z.select}));if(u<0)n();else{var a=i[u];a&&r([a])}}))}),[]),i.jsx(i.Fragment,{})};exports.BoxProviderWrap=function(e){var t=e.id,r=e.item,n=e.type;return i.jsx(F,{value:{id:t,item:r,type:n},children:e.children})},exports.CoordWrap=function(r){var n=r.children,o=r.onWillAdd,u=m(e.useControl(r,[]),2),a=u[0],s=u[1],c=t.useMemo((function(){return We(n,"key")}),[n]),f=function(e,t){if(a){var r=j(a),n=a.findIndex((function(t){return t.i===e}));-1!==n&&(r[n]=y(y({},r[n]),t),null==s||s(r))}};return i.jsx(Oe,{accept:r.accept,className:r.className,style:r.style,onDroped:function(e,t){if(a){var r=j(a),n=a.findIndex((function(t){return t.i===e})),i=y({i:e},t);-1===n&&(i.i=o?o(e,t):Le(),r.push({}),n=r.length-1),r[n]=i,null==s||s(r)}},children:null==a?void 0:a.map((function(e){var r=c[e.i];return r?i.jsx(Qe,{style:{position:"absolute",transition:"all 0.2s"},coord:e,id:e.i,onResizing:f.bind(null,e.i),children:r},e.i):i.jsx(t.Fragment,{},e.i)}))})},exports.Drag=De,exports.DragBoxWrap=function(e){var t=e.className,r=e.style,n=e.children,o=h(e,et);return i.jsx(F,{value:o,children:i.jsx(De,{style:r,className:t,children:n})})},exports.Drop=Oe,exports.PlainWrap=function(r){var n=r.children,o=r.onWillAdd,u=m(e.useControl(r,[]),2),a=u[0],s=u[1],c=t.useMemo((function(){return We(n,"key")}),[n]),f=function(e,t){if(a){var r=j(a),n=a.findIndex((function(t){return t.i===e})),i=y({i:e},t);-1===n&&(i.i=o?o(e,t):Le(),r.push({}),n=r.length-1),r[n]=i,null==s||s(r)}},l=function(e,t){if(a){var r=j(a),n=a.findIndex((function(t){return t.i===e}));-1!==n&&(r[n]=y(y({},r[n]),t),null==s||s(r))}},d=function(e){if(a){var t=e.getDroppingId(),r=e.getDraggingBaseData(),n=r.dragId,o=r.offset,i=a.findIndex((function(e){return e.i===n}));if(console.log(i),-1!==i){var u=a.findIndex((function(e){return e.i===t}));if(console.log(u,t),-1!==u){var c=j(a),l=c[i];c[i]=c[u],c[u]=l,null==s||s(c)}}else null==f||f(n,{x:0,y:0,w:o.w,h:o.h})}};return i.jsx(Oe,{accept:r.accept,className:r.className,style:r.style,onDroped:f,children:null==a?void 0:a.map((function(e){var r=c[e.i];return r?i.jsx(Qe,{coord:e,style:{},id:e.i,onResizing:l.bind(null,e.i),onDroped:d,children:r},e.i):i.jsx(t.Fragment,{},e.i)}))})},exports.ReiseHandle=Ie,exports.Resize=function(e){var t=e.children,r=e.style,n=e.pure,o=e.className,u=h(e,Ne);return m(Fe(u),1),n?i.jsx(Ie,{id:u.id}):i.jsxs("div",{style:y({position:"relative"},r),className:o,children:[i.jsx(Ie,{id:u.id}),t]})},exports.ResizeCore=Ae,exports.TransBox=Qe,exports.TransProviderWrap=function(t){var r=e.useRefPro((function(){var e,t,r,n=new ie,o=new ce(n),i=new de(n),u=(t=(e={droppingCore:i,draggingCore:o}).draggingCore,r=e.droppingCore,{getDraggingBaseData:function(){return t.getDraggingData()},getDraggingId:function(){return t.triggers.getter("dragId")||""},getDraggingItem:function(){return t.triggers.getter("item")||{}},getDraggingType:function(){return t.triggers.getter("type")||""},getDraggingOffset:function(){return t.triggers.getter("offset")},getDroppingBaseData:function(){return r.getDropData()},getDroppingId:function(){return r.triggers.getter("dropId")},getDroppingAccept:function(){return r.triggers.getter("accept")||[]},getDroppingItem:function(){return r.triggers.getter("item")},getDroppingStack:function(){return r.triggers.getter("stack")}});return{baseCore:n,selectCore:new Ge(n),resizeCore:new Ae(n),dragCore:o,dropCore:i,dndMonitor:u}}));return i.jsxs(X,{value:r.current,children:[i.jsx(te,{}),i.jsx(tt,{}),i.jsx(it,{}),i.jsx(rt,{}),i.jsx(ut,{}),i.jsx(nt,{}),i.jsx(ot,{}),t.children]})},exports.useResize=Fe,exports.useResizeCore=Te,exports.useResizeInfo=Be;
1
+ "use strict";var e=require("@cclr/react"),t=require("react"),r=require("@cclr/emitter"),n=require("@cclr/trigger"),o=require("@cclr/front"),i=require("react/jsx-runtime"),u=require("react-dom");function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function s(e,t,r){return t=d(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,p()?Reflect.construct(t,r||[],d(e).constructor):t.apply(e,r))}function c(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function f(e,t,r){return t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,j(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function l(e,t,r){return(t=j(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function g(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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function p(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(p=function(){return!!e})()}function v(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 y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?v(Object(r),!0).forEach((function(t){l(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function h(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||w(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function D(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||w(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function j(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function w(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}Function.prototype.call.bind(Object.prototype.hasOwnProperty);var x=Function.prototype.call.bind(Object.prototype.toString),O={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function E(e){return O[typeof e]||O[x(e)]||(e?"object":"null")}function S(e){return function(e){return null===e}(e)||function(e){return void 0===e}(e)}function I(e){return"function"===E(e)}function C(e){return function(e){return"object"===E(e)}(e)&&Object.getPrototypeOf(e)===Object.prototype}var k={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:function(){},regexp:/(?:)/};function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function R(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,u,a=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(a.push(n.value),a.length!==t);s=!0);}catch(e){c=!0,o=e}finally{try{if(!s&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(c)throw o}}return a}}(e,t)||z(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function z(e,t){if(e){if("string"==typeof e)return P(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?P(e,t):void 0}}var A=Object.freeze({__proto__:null,extend:function(e,t){var r=e||{};return C(t)&&Object.keys(t).forEach((function(e){r[e]=t[e]})),r},filter:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:S,r={};return C(e)&&Object.entries(e).forEach((function(n){var o=R(n,2),i=o[0],u=o[1];t(e[i],i)&&(r[i]=u)})),r},forEach:function(e,t){Object.keys(e).forEach((function(r){t(e[r],r)}))},format:function(e,t){var r,n=C(e)?e:{},o=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=z(e))){t&&(e=t);var r=0,n=function(){};return{s:n,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){t=t.call(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw o}}}}(t);try{for(o.s();!(r=o.n()).done;){var i=r.value,u=R(i,3),a=u[0],s=u[1],c=u[2];E(n[a])!==s&&(3!==i.length?n[a]=k[s]:n[a]=c)}}catch(e){o.e(e)}finally{o.f()}return n},omit:function(e,t){var r={};return C(e)&&Object.entries(e).forEach((function(e){var n=R(e,2),o=n[0],i=n[1];t.includes(o)||(r[o]=i)})),r},pick:function(e,t){return t.reduce((function(t,r){return r in e&&(t[r]=e[r]),t}),{})}}),T=m(e.createCtx({}),2),B=T[0],F=T[1],N=m(e.createCtx({}),2),M=N[0],X=N[1],Y=function(){var e=M().baseCore;return{start:e.start,move:e.move,end:e.end,mouseEvent:e.mouseEvent,getData:e.getData,getBaseData:e.getBaseData,reset:e.reset,addUser:e.addUser,onDragMove:e.onDragMove,onStatus:e.onStatus,onDomEvent:e.onDomEvent}},_=function(){var e=Y().onStatus,r=m(t.useState({}),2),n=r[0],o=r[1];return t.useEffect((function(){return e((function(e,t){o(t)}))}),[]),n};var q,U,W="data-trans-box-type",L="data-trans-box-id",$="data-trans-box-data",Z=function(e){return e[e.drag=1]="drag",e[e.drop=2]="drop",e[e.resize=4]="resize",e[e.select=8]="select",e[e.stop=64]="stop",e[e.boundary=128]="boundary",e}({}),H=(q=[Z.drag,Z.drop,Z.resize,Z.select,Z.stop,Z.boundary],U=[],function e(t,r){if(t.length&&U.push(t),0!==r.length)for(var n=0;n<r.length;n++)e(t.concat(r[n]),r.slice(0,n))}([],q),U).reduce((function(e,t){var r=t.reduce((function(e,t){return e|t}),0);return e[r.toString()]=r,e}),{}),V=function(e){if(e)return e.getAttribute($)},G=function(e,t){e&&e.setAttribute(L,t.toString())},J=function(e){if(e)return e.getAttribute(L)},K=function(e,t){if(e){var r=e.getAttribute(W)||"",n=(H[r]||0)|t;e.setAttribute(W,n.toString())}},Q=function(e){if(e)return H[e.getAttribute(W)||""]},ee=function(e,t){for(var r=e,n=[],o=[],i=[];r&&r!==document.body;){var u=Q(r);u&&(!t||t&u)&&(n.push(u),o.push(J(r)),i.push(V(r))),r=r.parentElement}return{types:n,ids:o,datas:i}},te=function(){var r=Y(),n=r.start,u=r.move,a=r.end,s=r.reset,c=r.mouseEvent,f=r.getData,l=t.useRef({free:!0,timer:null}),d=function(){clearTimeout(l.current.timer),l.current.timer=null,c("drag")},g=e.useCallbackRef((function(e){var t;if(clearTimeout(l.current.timer),(null==e||null===(t=e.target)||void 0===t?void 0:t.nodeType)===Node.ELEMENT_NODE){l.current.free=!1;var r=ee(e.target),o=e.clientX,i=e.clientY;n({startClientX:o,startClientY:i},r),c("down"),l.current.timer=setTimeout(d,120)}})),p=e.useCallbackRef((function(e){if(!l.current.free){var t=e.clientX,r=e.clientY,n=f(),o=t-n.startClientX,i=r-n.startClientY;l.current.timer&&(o>30||i>30)&&d(),u({clientX:t,clientY:r,spaceX:o,spaceY:i})}})),v=e.useCallbackRef((function(e){if(clearTimeout(l.current.timer),!l.current.free){l.current.timer&&(c("tap"),l.current.timer=null);var t=e.clientX,r=e.clientY,n=f(),o=n.startClientX,i=n.startClientY;a({clientX:t,clientY:r,spaceX:t-o,spaceY:r-i})}l.current.free=!0,setTimeout((function(){s()}),0)}));return t.useEffect((function(){return o.addEventListenerMultiple(window,{mousedown:g,mousemove:p,mouseup:v})}),[]),i.jsx(i.Fragment,{})},re=f((function e(t){c(this,e),l(this,"baseCore",void 0),this.baseCore=t})),ne={status:"free",users:[],position:{startClientX:0,startClientY:0,clientX:0,clientY:0,spaceX:0,spaceY:0},level:{types:[],ids:[],datas:[]},eventType:"free"},oe=f((function e(){var t=this;c(this,e),l(this,"triggers",n.dataTriggers(ne)),l(this,"onDragMove",(function(e){return t.triggers.onChange("position",(function(){e(t.getData())}))})),l(this,"onStatus",(function(e){var r;return t.triggers.onChange("status",(function(n){r!==n&&(r=n,e(n,t.getBaseData()))}))})),l(this,"onDomEvent",(function(e,r){return t.triggers.onChange("eventType",(function(n){e===n&&r(t.getBaseData())}))})),l(this,"getData",(function(){return y(y({},t.triggers.getter(["status","users"])),t.triggers.getter("position"))})),l(this,"getBaseData",(function(){return t.triggers.getter(["status","users","position","level","eventType"])})),l(this,"reset",(function(){t.triggers.setter(ne)})),l(this,"descroy",(function(){t.triggers.destroy()}))})),ie=function(){function e(){var t;c(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return l(t=s(this,e,[].concat(n)),"start",(function(e,r){t.triggers.setter({position:function(t){return y(y({},t),e)},status:"start",level:r})})),l(t,"move",(function(e){t.triggers.setter({position:function(t){return y(y({},t),e)},status:"move"})})),l(t,"end",(function(e){t.triggers.setter({position:function(t){return y(y({},t),e)},status:"end"})})),l(t,"mouseEvent",(function(e){t.triggers.setter({eventType:e})})),l(t,"addUser",(function(e){t.triggers.setter({users:function(t){return[].concat(D(t),[e])}})})),t}return g(e,oe),f(e)}(),ue=function(r){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=Y().onDragMove,i=e.useThrottleFn(r,{wait:60}),u=i.run,a=i.fun,s=i.cancel;t.useEffect((function(){if(n)return o((function(e){return"start"===e.status||"free"===e.status||"end"===e.status?(s(),a(e)):u(e)}))}),[n])},ae={dragId:"",item:void 0,type:"",offset:{x:0,y:0,w:0,h:0},renderFake:!0},se=function(){function e(){var t;c(this,e);for(var o=arguments.length,i=new Array(o),u=0;u<o;u++)i[u]=arguments[u];return l(t=s(this,e,[].concat(i)),"triggers",n.dataTriggers(ae)),l(t,"dragEmitter",new r.Emitter),l(t,"onDragStartEvent",(function(e,r){return t.dragEmitter.addListener(e,r)})),l(t,"onDraggingId",(function(e){return t.triggers.onChange("dragId",(function(){e(t.getDraggingData())}))})),l(t,"getDraggingData",(function(){return t.triggers.getter(["dragId","item","type","offset","renderFake"])})),l(t,"reset",(function(){t.triggers.setter(ae)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),ce=function(){function e(t){var r;return c(this,e),l(r=s(this,e,[t]),"setDragData",(function(e){r.triggers.getter("dragId")||r.triggers.setter(y(y({},e),{},{renderFake:function(){return e.renderFake}}))})),l(r,"emitDrag",(function(e){r.dragEmitter.emit(e,{})})),r.init(),r}return g(e,se),f(e,[{key:"init",value:function(){var e=this;this.baseCore.onStatus((function(t){"free"===t&&e.reset()}))}}])}(),fe={stack:[],dropId:"",item:void 0,accept:[]},le=function(){function e(){var t;c(this,e);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return l(t=s(this,e,[].concat(o)),"triggers",n.dataTriggers(fe)),l(t,"onDropStack",(function(e){t.triggers.onChange("stack",e)})),l(t,"onDropId",(function(e){t.triggers.onChange("dropId",(function(){e(t.getDropData())}))})),l(t,"getDropStack",(function(){return t.triggers.getter("stack")})),l(t,"getDropData",(function(){return t.triggers.getter(["dropId","item","accept"])})),l(t,"getStack",(function(){return t.triggers.getter(["stack"])})),l(t,"reset",(function(){t.triggers.setter(fe)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),de=function(){function e(t){var r;return c(this,e),l(r=s(this,e,[t]),"setDropInfo",(function(e){r.triggers.setter(e)})),l(r,"setDropStack",(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r.triggers.setter({stack:e})})),r.init(),r}return g(e,le),f(e,[{key:"init",value:function(){var e=this;this.baseCore.onStatus((function(t){"free"===t&&e.reset()}))}}])}(),ge=function(e){var r=t.useRef();return e||r},pe=function(){var e=M().dragCore,t=e.setDragData,r=e.getDraggingData;return{dragCore:e,onDragId:e.onDraggingId,onDragStartEvent:e.onDragStartEvent,emitDrag:e.emitDrag,setDragData:t,getDraggingData:r,reset:e.reset}},ve=function(){var e=pe().onDragId,r=m(t.useState({}),2),n=r[0],o=r[1];return t.useEffect((function(){return e((function(e){o(e)}))}),[]),n},ye=function(){return M().dndMonitor},he=function(r){var n,o,i,u,a=r.id,s=r.item,c=r.type,f=r.renderFake,l=r.onDragStart,d=r.onDrag,g=r.onDragEnd,p=ye(),v=Y(),y=v.getData,h=v.addUser,b=pe(),m=b.setDragData,D=b.onDragStartEvent,j=ve().dragId,w=j===a,x=ge(r.domRef),O=e.useCallbackRef((function(){var e=y(),t=e.startClientX,r=e.startClientY,n=x.current.getBoundingClientRect(),o=n.left,i=n.top,u=n.width,d=n.height;h("dnd"),m({dragId:a,item:s,type:c,offset:{x:t-o,y:r-i,w:u,h:d},renderFake:I(f)?f.bind(null,p):f}),null==l||l(p)}));return n=function(e){"end"===e&&(null==g||g(p))},o=w,i=Y().onStatus,u=e.useCallbackRef(n),t.useEffect((function(){if(o)return i(u)}),[o]),ue((function(e){"free"!==e.status&&(null==d||d(p))}),w&&!!d),t.useEffect((function(){return K(x.current,Z.drag),G(x.current,a),D(a,O)}),[]),[{id:a,item:s,draggingId:j,isDragging:w},x]},be=function(){var e=M().dropCore,t=e.setDropInfo,r=e.setDropStack,n=e.reset;return{dropCore:e,getDropData:e.getDropData,setDropInfo:t,setDropStack:r,reset:n,onDropStack:e.onDropStack,onDropId:e.onDropId}},me=function(r){var n=r.id,o=r.item,i=r.accept,u=r.onOver,a=r.onDroped,s=ge(r.domRef),c=ye(),f=function(){var e=be().onDropStack,r=m(t.useState([]),2),n=r[0],o=r[1];return t.useEffect((function(){return e((function(e){o(e)}))}),[]),n}(),l=be().setDropInfo,d=n||e.useUuid(),g=ve(),p=g.dragId,v=g.type,h=p&&f[0]===d,b=!(null!=i&&i.length)||(null==i?void 0:i.includes(v||"")),D=function(e){var t,r=(null===(t=s.current)||void 0===t?void 0:t.getBoundingClientRect())||{left:0,top:0},n=r.left,o=r.top;return{offsetX:e.clientX-n,offsetY:e.clientY-o}},j=e.useThrottleFn((function(e){null==u||u(y(y({},c),{},{getDropPos:function(){return D(e)}}))})),w=j.run;return e.useEventListenerMultiple(s,{mousemove:w,mouseup:function(e){l({dropId:d,accept:i,item:o}),null==a||a(y(y({},c),{},{getDropPos:function(){return D(e)}}))}},!!h),t.useEffect((function(){K(s.current,Z.drop),G(s.current,d)}),[]),[{id:d,item:o,accept:i,isOver:h,isAccept:b},s]},De=["className","style","children"],je=t.forwardRef((function(e,r){var n=e.className,u=e.style,a=e.children,s=h(e,De);return t.isValidElement(a)&&function(e){return"string"===E(e)}(a.type)?t.cloneElement(a,y(y({},s),{},{ref:r,className:o.classNames(n,a.props.className),style:A.extend(u,a.props.style)})):i.jsx("div",y(y({ref:r},s),{},{style:u,className:n,children:a}))})),we=["className","style","children"],xe=["id","renderFake"],Oe=function(e){var t=e.className,r=e.style,n=e.children,o=h(e,we),u=B(),a=u.id,s=u.renderFake,c=h(u,xe),f=_().status,l=m(he(y(y({id:a,renderFake:S(s)||s},o),c)),2),d=l[0].isDragging,g={ref:l[1],className:t,style:y(y({},r),{},{cursor:"move"!==f?"grab":void 0,pointerEvents:d?"none":"unset"})};return i.jsx(je,y(y({},g),{},{children:n}))},Ee=function(e){var t=e.className,r=e.style,n=e.children,o=e.onOver,u=e.onDroped,a=e.item,s=e.accept,c=e.id,f=m(me({id:c,item:a||{},accept:s||[],onDroped:function(e){var t=e.getDropPos(),r=t.offsetX,n=t.offsetY,o=e.getDraggingBaseData(),i=o.dragId,a=o.offset;g&&(null==u||u(i,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h}))},onOver:function(e){var t=e.getDropPos(),r=t.offsetX,n=t.offsetY,i=e.getDraggingBaseData(),u=i.dragId,a=i.offset;null==o||o(u,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h})}}),2),l=f[0],d=l.isOver,g=l.isAccept,p={ref:f[1],className:t,style:y({boxShadow:d?g?"0 0 4px 1px #1f90fc":"0 0 4px 1px orange":"none"},r)};return i.jsx(je,y(y({},p),{},{children:n}))},Se={lt:"nwse-resize",rt:"nesw-resize",lb:"nesw-resize",rb:"nwse-resize",t:"ns-resize",l:"ew-resize",r:"ew-resize",b:"ns-resize"},Ie=function(e){var r=e.hidden,n=e.handles,o=e.id;return r?i.jsx(i.Fragment,{}):(n||["lt","l","lb","t","b","rt","r","rb"]).map((function(e){return t.createElement("span",y(y({},l(l(l({},W,Z.resize),L,o),$,e)),{},{key:e,style:Re[e]}))}))},Ce={position:"absolute",left:0,top:0,transform:"translate(-50%, -50%)",backgroundColor:"green"},ke=y(y({},Ce),{},{width:"20px",height:"20px",borderRadius:"2px"}),Pe=y(y({},Ce),{},{width:"6px",height:"6px"}),Re={lt:y(y({},Pe),{},{cursor:Se.lt}),lb:y(y({},Pe),{},{top:"100%",cursor:Se.lb}),rt:y(y({},Pe),{},{left:"100%",cursor:Se.rt}),rb:y(y({},Pe),{},{left:"100%",top:"100%",cursor:Se.rb}),l:y(y({},ke),{},{top:"50%",width:Pe.height,cursor:Se.l}),r:y(y({},ke),{},{left:"100%",top:"50%",width:Pe.width,cursor:Se.r}),t:y(y({},ke),{},{left:"50%",height:Pe.height,cursor:Se.t}),b:y(y({},ke),{},{left:"50%",top:"100%",height:Pe.height,cursor:Se.b})},ze={id:"",info:{},startCoord:{x:0,y:0,w:0,h:0}},Ae=function(){function e(){var t;c(this,e);for(var o=arguments.length,i=new Array(o),u=0;u<o;u++)i[u]=arguments[u];return l(t=s(this,e,[].concat(i)),"triggers",n.dataTriggers(ze)),l(t,"resizeEmitter",new r.Emitter),l(t,"onBaseInfo",(function(e){return t.triggers.onChange("id",(function(){e(t.getBaseInfo())}))})),l(t,"onResizeEvent",(function(e,r){return t.resizeEmitter.addListener(e,r)})),l(t,"getBaseInfo",(function(){return t.triggers.getter(["id","info","handle","startCoord"])})),l(t,"reset",(function(){t.triggers.setter(ze)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),Te=function(){function e(t){var r;return c(this,e),l(r=s(this,e,[t]),"setBaseInfo",(function(e){r.triggers.setter(e)})),l(r,"emitResize",(function(e,t){r.resizeEmitter.emit(e,t)})),r.init(),r}return g(e,Ae),f(e,[{key:"init",value:function(){var e=this;this.baseCore.onStatus((function(t){"free"===t&&e.reset()}))}}])}(),Be=function(){var e=M().resizeCore;return{reset:e.reset,descroy:e.descroy,getBaseInfo:e.getBaseInfo,onBaseInfo:e.onBaseInfo,emitResize:e.emitResize,onResizeEvent:e.onResizeEvent,setBaseInfo:e.setBaseInfo}},Fe=function(){var e=Be().onBaseInfo,r=m(t.useState({}),2),n=r[0],o=r[1];return t.useEffect((function(){return e(o)}),[]),n},Ne=function(r){var n=r.id,o=r.onResizing,i=r.onResized,u=Y().addUser,a=Be(),s=a.setBaseInfo,c=a.onResizeEvent,f=Fe(),l=f.id,d=f.handle,g=f.startCoord,p=ge(r.domRef),v=l===n,h=e.useCallbackRef((function(e){var t,r,o;u("resize");var i=(null==p||null===(t=p.current)||void 0===t?void 0:t.getBoundingClientRect())||{width:0,height:0},a=i.width,c=i.height;s({id:n,startCoord:{x:(null===(r=p.current)||void 0===r?void 0:r.offsetLeft)||0,y:(null===(o=p.current)||void 0===o?void 0:o.offsetTop)||0,w:a,h:c},info:{},handle:e})}));return t.useEffect((function(){c(n,h)}),[]),ue((function(e){if("free"!==e.status){var t=function(e,t,r){var n=y({},e),o=n.h,i=n.w,u=n.x,a=n.y,s=t.spaceX,c=t.spaceY;switch(r){case"lt":n.x=u+s,n.y=a+c,n.w=i-s,n.h=o-c;break;case"rt":n.x=u,n.y=a+c,n.w=i+s,n.h=o-c;break;case"lb":n.x=u+s,n.y=a,n.w=i-s,n.h=o+c;break;case"rb":n.x=u,n.y=a,n.w=i+s,n.h=o+c;break;case"l":n.x=u+s,n.y=a,n.w=i-s,n.h=o;break;case"r":n.x=u,n.y=a,n.w=i+s,n.h=o;break;case"b":n.x=u,n.y=a,n.w=i,n.h=o+c;break;case"t":n.x=u,n.y=a+c,n.w=i,n.h=o-c}return n}(g,e,d);null==o||o(t),"end"===e.status&&(null==i||i(t))}}),v&&!!o),[{isResizing:v},{}]},Me=["children","style","pure","className"];function Xe(e,t,r){return(t=Ue(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Ye(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 _e(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?Ye(Object(r),!0).forEach((function(t){Xe(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ye(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function qe(e,t){return qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},qe(e,t)}function Ue(e){var t=function(e){if("object"!=typeof e||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:t+""}function We(){We=function(e,t){return new r(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function r(e,n,o){var i=RegExp(e,n);return t.set(i,o||t.get(e)),qe(i,r.prototype)}function n(e,r){var n=t.get(r);return Object.keys(n).reduce((function(t,r){var o=n[r];if("number"==typeof o)t[r]=e[o];else{for(var i=0;void 0===e[o[i]]&&i+1<o.length;)i++;t[r]=e[o[i]]}return t}),Object.create(null))}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}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&qe(e,t)}(r,RegExp),r.prototype.exec=function(t){var r=e.exec.call(this,t);if(r){r.groups=n(r,this);var o=r.indices;o&&(o.groups=n(o,this))}return r},r.prototype[Symbol.replace]=function(r,o){if("string"==typeof o){var i=t.get(this);return e[Symbol.replace].call(this,r,o.replace(/\$<([^>]+)>/g,(function(e,t){var r=i[t];return"$"+(Array.isArray(r)?r.join("$"):r)})))}if("function"==typeof o){var u=this;return e[Symbol.replace].call(this,r,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(n(e,u)),o.apply(this,e)}))}return e[Symbol.replace].call(this,r,o)},We.apply(this,arguments)}var Le=function(e,t){return e.reduce((function(e,r){var n=r[t];return _e(_e({},e),{},Xe({},n,r))}),{})};!function(e,t){t&&function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ue(n.key),n)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Xe(this,"handler",[])}),[{key:"use",value:function(e,t){return this.handler.push({fulfilled:e,rejected:t}),this.handler.length-1}},{key:"eject",value:function(e){this.handler[e]&&(this.handler[e]=null)}},{key:"clear",value:function(){this.handler=[]}},{key:"forEach",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(e,t,r){if(r)for(var n=e.length-1;n>=0;n--)t(e[n],n,e);else for(var o=0;o<e.length;o++)t(e[o],o,e)}(this.handler,(function(t){t&&e(t)}),t)}},{key:"run",value:function(e){var t=arguments;return new Promise(function(r,n){var o=t.length>1&&void 0!==t[1]&&t[1],i=Promise.resolve(e());return this.forEach((function(e){i=i.then(e.fulfilled,e.rejected)}),o),r(i)}.bind(this))}}]),We(/\?([^#]*)/,{query:1}),We(/#(.*)/,{hash:1}),We(/^(?:[a-zA-Z][a-zA-Zd+-.]*:)?(?:\/\/(?:[^@/?#]*@)?[^/?#]*)?([^?#]*)/,{pathname:1});var $e=["show","dom"],Ze=function(e){var t=e.show,r=e.dom,n=h(e,$e);return t&&r?u.createPortal(i.jsx("div",{style:{position:"absolute",inset:0},children:i.jsx(Ie,y({},n))}),r):i.jsx(i.Fragment,{})},He={ids:[],infoMap:{}},Ve=function(){function e(){var t;c(this,e);for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return l(t=s(this,e,[].concat(o)),"triggers",n.dataTriggers(He)),l(t,"onSelectIds",(function(e){return t.triggers.onChange("ids",(function(){e(t.getSelectInfo())}))})),l(t,"getSelectInfo",(function(){return t.triggers.getter(["ids","infoMap"])})),l(t,"reset",(function(){t.triggers.setter(He)})),l(t,"descroy",(function(){t.triggers.destroy()})),t}return g(e,re),f(e)}(),Ge=function(){function e(){var t;c(this,e);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return l(t=s(this,e,[].concat(n)),"setSelectIds",(function(e){t.triggers.setter({ids:e})})),t}return g(e,Ve),f(e)}(),Je=function(){var e=M().selectCore,t=e.reset,r=e.setSelectIds,n=e.descroy,o=e.onSelectIds;return{getSelectInfo:e.getSelectInfo,setSelectIds:r,onSelectIds:o,reset:t,descroy:n}},Ke=function(e){var r,n,o,i,u,a,s=e.id,c=e.domRef,f=(r=Je(),n=r.onSelectIds,o=r.getSelectInfo,i=m(t.useState(o()),2),u=i[0],a=i[1],t.useEffect((function(){return n((function(e){a(e)}))}),[]),u),l=f.ids,d=f.infoMap[s],g=l.includes(s);return t.useEffect((function(){K(null==c?void 0:c.current,Z.select)}),[]),[{isSelect:g,selectInfo:d}]},Qe=function(e){var r=e.id,n=e.coord,o=e.item,u=e.className,a=e.onResizing,s=e.onOver,c=e.onDroped,f=_().status,l=m(he({id:r,renderFake:!0,item:o}),2),d=l[0].isDragging,g=l[1],p=m(Ke({id:r,domRef:g}),1)[0].isSelect;Ne({id:r,onResizing:a,domRef:g}),me({id:r,item:o,domRef:g,onOver:s,onDroped:c});var v=t.useMemo((function(){return{left:n.x,top:n.y,width:n.w,height:n.h,cursor:"move"!==f?"grab":void 0,pointerEvents:d?"none":"unset"}}),[n,f,d]),h=t.useMemo((function(){return{boxShadow:p?"0 0 4px 1px #0078d4":void 0}}),[p]),b=t.useMemo((function(){return{contain:p?"layout":void 0}}),[p]);return i.jsxs(i.Fragment,{children:[i.jsx(Ze,{show:p&&!d,id:r,dom:g.current}),i.jsx(je,{ref:g,className:u,style:y(y(y(y({},v),h),b),e.style),children:e.children})]})},et=["className","style","children","id","coord","item"],tt=function(){var e=ve().dragId,r=Fe(),n=r.handle,o=r.id,u=Y().getData;return t.useEffect((function(){var t=u().users[0];e&&"dnd"===t?(document.body.style.cursor="grabbing",document.body.style.userSelect="none"):n&&"resize"===t?(document.body.style.cursor=Se[n],document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")}),[e,n,o]),i.jsx(i.Fragment,{})},rt=function(){var e=Y().onDomEvent,r=pe().emitDrag;return t.useEffect((function(){return e("drag",(function(e){var t=e.level,n=t.types,o=t.ids;if(!(n[0]&Z.resize)){var i=n.findIndex((function(e){return e&Z.drag}));if(!(i<0)){var u=o[i];u&&r(u)}}}))}),[]),i.jsx(i.Fragment,{})},nt=function(){var e=ve(),r=e.dragId,n=e.offset,o=e.renderFake,a=m(t.useState(""),2),s=a[0],c=a[1],f=m(t.useState(!1),2),l=f[0],d=f[1],g=t.useRef({timer:null}),p=function(e){var t=e.clientX,r=e.clientY,o=n,i=o.x,u=o.y;c("translate(".concat(t-(i||0),"px, ").concat(r-(u||0),"px)"))},v=function(e){clearTimeout(g.current.timer),p(e),g.current.timer=setTimeout((function(){d(!0),g.current.timer=null}),100)};ue((function(e){switch(e.status){case"start":v(e);break;case"end":clearTimeout(g.current.timer),g.current.timer=setTimeout((function(){d(!1),c(""),g.current.timer=null}),100);break;case"move":g.current.timer?p(e):v(e)}}),!!r);var y=t.useMemo((function(){return I(o)?o():i.jsx("div",{style:{width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.5)"}})}),[o]);return u.createPortal(i.jsx("div",{style:{position:"fixed",pointerEvents:"none",left:0,top:0,width:0,height:0,zIndex:1e3},children:o?i.jsx("div",{style:{display:l&&r?"block":"none",position:"absolute",transition:r?"transform linear 0.1s":"",width:null==n?void 0:n.w,height:null==n?void 0:n.h,transform:s},children:y}):i.jsx(i.Fragment,{})}),document.body)},ot=function(){var r=ve().dragId,n=be().setDropStack,u=e.useCallbackRef((function(e){if(r){var t=ee(e.target,Z.drop).ids;n(t.filter(Boolean))}})),a=e.useCallbackRef((function(){setTimeout((function(){n()}),0)}));return t.useEffect((function(){if(r)return o.addEventListenerMultiple(window,{mouseover:u,mouseup:a})}),[!!r]),i.jsx(i.Fragment,{})},it=function(){var e=Y().onDomEvent,r=Be().emitResize;return t.useEffect((function(){return e("down",(function(e){var t=e.level,n=t.types,o=t.ids,i=t.datas;if(n[0]&Z.resize){var u=o[0],a=i[0];r(u,a)}}))}),[]),i.jsx(i.Fragment,{})},ut=function(){var e=Je(),r=e.setSelectIds,n=e.reset,o=Y().onDomEvent;return t.useEffect((function(){return o("tap",(function(e){var t=e.level,o=t.types,i=t.ids,u=o.findIndex((function(e){return e&Z.select}));if(u<0)n();else{var a=i[u];a&&r([a])}}))}),[]),i.jsx(i.Fragment,{})};exports.BoxProviderWrap=function(e){var t=e.id,r=e.item,n=e.type;return i.jsx(F,{value:{id:t,item:r,type:n},children:e.children})},exports.CoordWrap=function(r){var n=r.children,o=r.onWillChange,u=m(e.useControl(r,[]),2),a=u[0],s=u[1],c=t.useMemo((function(){return Le(n,"key")}),[n]),f=function(e,t){if(a){var r=D(a),n=a.findIndex((function(t){return t.i===e}));-1!==n&&(r[n]=y(y({},r[n]),t),null==s||s(r))}};return i.jsx(Ee,{accept:r.accept,className:r.className,style:r.style,onDroped:function(e,t){if(a){var r=D(a),n=a.findIndex((function(t){return t.i===e})),i=!1,u=y({i:e},t);-1===n&&(i=!0,r.push({}),n=r.length-1),r[n]=u;var c=o?o(r,{addIds:i?[u.i]:[],removeIds:[],changeIds:[u.i]}):r;c&&(null==s||s(c))}},children:null==a?void 0:a.map((function(e){var r=c[e.i];return r?i.jsx(Qe,{style:{position:"absolute",transition:"all 0.2s"},coord:e,id:e.i,onResizing:f.bind(null,e.i),children:r},e.i):i.jsx(t.Fragment,{},e.i)}))})},exports.Drag=Oe,exports.DragBoxWrap=function(e){var t=e.className,r=e.style,n=e.children,o=e.id,u=e.coord,a=e.item,s=h(e,et);return i.jsx(F,{value:{id:o,coord:u,item:a},children:i.jsx(Oe,y(y({style:r,className:t},s),{},{children:n}))})},exports.Drop=Ee,exports.PlainWrap=function(r){var n=r.children,o=r.onWillAdd,u=m(e.useControl(r,[]),2),a=u[0],s=u[1],c=t.useMemo((function(){return Le(n,"key")}),[n]),f=function(e,t){if(a){var r=D(a),n=a.findIndex((function(t){return t.i===e})),i=y({i:e},t);-1===n&&(i.i=o?o(e,t):function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36,t=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"],r=[],n=0;n<e;n++)r[n]=8===n||13===n||18===n||23===n?"-":t[Math.ceil(Math.random()*t.length-1)];return r.join("")}(),r.push({}),n=r.length-1),r[n]=i,null==s||s(r)}},l=function(e,t){if(a){var r=D(a),n=a.findIndex((function(t){return t.i===e}));-1!==n&&(r[n]=y(y({},r[n]),t),null==s||s(r))}},d=function(e){if(a){var t=e.getDroppingId(),r=e.getDraggingBaseData(),n=r.dragId,o=r.offset,i=a.findIndex((function(e){return e.i===n}));if(-1!==i){var u=a.findIndex((function(e){return e.i===t}));if(-1!==u){var c=D(a),l=c[i];c[i]=c[u],c[u]=l,null==s||s(c)}}else null==f||f(n,{x:0,y:0,w:o.w,h:o.h})}};return i.jsx(Ee,{accept:r.accept,className:r.className,style:r.style,onDroped:f,children:null==a?void 0:a.map((function(e){var r=c[e.i];return r?i.jsx(Qe,{coord:e,style:{},id:e.i,onResizing:l.bind(null,e.i),onDroped:d,children:r},e.i):i.jsx(t.Fragment,{},e.i)}))})},exports.ReiseHandle=Ie,exports.Resize=function(e){var t=e.children,r=e.style,n=e.pure,o=e.className,u=h(e,Me);return m(Ne(u),1),n?i.jsx(Ie,{id:u.id}):i.jsxs("div",{style:y({position:"relative"},r),className:o,children:[i.jsx(Ie,{id:u.id}),t]})},exports.ResizeCore=Te,exports.TransBox=Qe,exports.TransProviderWrap=function(t){var r=e.useRefPro((function(){var e=new ie,t=new ce(e),r=new de(e),n=function(e){var t=e.draggingCore,r=e.droppingCore,n=e.baseCore;return{getBaseMoveData:function(){return n.getBaseData()},getDraggingBaseData:function(){return t.getDraggingData()},getDraggingId:function(){return t.triggers.getter("dragId")||""},getDraggingItem:function(){return t.triggers.getter("item")||{}},getDraggingType:function(){return t.triggers.getter("type")||""},getDraggingOffset:function(){return t.triggers.getter("offset")},getDroppingBaseData:function(){return r.getDropData()},getDroppingId:function(){return r.triggers.getter("dropId")},getDroppingAccept:function(){return r.triggers.getter("accept")||[]},getDroppingItem:function(){return r.triggers.getter("item")},getDroppingStack:function(){return r.triggers.getter("stack")}}}({baseCore:e,droppingCore:r,draggingCore:t});return{baseCore:e,selectCore:new Ge(e),resizeCore:new Te(e),dragCore:t,dropCore:r,dndMonitor:n}}));return i.jsxs(X,{value:r.current,children:[i.jsx(te,{}),i.jsx(tt,{}),i.jsx(it,{}),i.jsx(rt,{}),i.jsx(ut,{}),i.jsx(nt,{}),i.jsx(ot,{}),t.children]})},exports.useResize=Ne,exports.useResizeCore=Be,exports.useResizeInfo=Fe;
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{createCtx as t,useCallbackRef as e,useThrottleFn as r,useUuid as n,useEventListenerMultiple as o,useControl as i,useRefPro as u}from"@cclr/react";import a,{useState as c,useEffect as s,useRef as f,forwardRef as l,isValidElement as d,createElement as g,useMemo as p,Fragment as v}from"react";import{Emitter as y}from"@cclr/emitter";import{dataTriggers as h}from"@cclr/trigger";import{addEventListenerMultiple as b,classNames as m}from"@cclr/front";import{jsx as w,Fragment as D,jsxs as O}from"react/jsx-runtime";import j,{createPortal as I}from"react-dom";function S(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function x(t,e,r){return e=P(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(e,r||[],P(t).constructor):e.apply(t,r))}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function C(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}function z(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&N(t,e)}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function R(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function B(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?R(Object(r),!0).forEach((function(e){C(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):R(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function T(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function N(t,e){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},N(t,e)}function X(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(s)throw o}}return a}}(t,e)||F(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(t){return function(t){if(Array.isArray(t))return S(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||F(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function F(t,e){if(t){if("string"==typeof t)return S(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(t,e):void 0}}Function.prototype.call.bind(Object.prototype.hasOwnProperty);var M=Function.prototype.call.bind(Object.prototype.toString),U={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function $(t){return U[typeof t]||U[M(t)]||(t?"object":"null")}function L(t){return function(t){return null===t}(t)||function(t){return void 0===t}(t)}function W(t){return"function"===$(t)}function Z(t){return function(t){return"object"===$(t)}(t)&&Object.getPrototypeOf(t)===Object.prototype}var q={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:function(){},regexp:/(?:)/};function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(s)throw o}}return a}}(t,e)||J(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(t,e){if(t){if("string"==typeof t)return G(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?G(t,e):void 0}}var K=Object.freeze({__proto__:null,extend:function(t,e){var r=t||{};return Z(e)&&Object.keys(e).forEach((function(t){r[t]=e[t]})),r},filter:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L,r={};return Z(t)&&Object.entries(t).forEach((function(n){var o=H(n,2),i=o[0],u=o[1];e(t[i],i)&&(r[i]=u)})),r},forEach:function(t,e){Object.keys(t).forEach((function(r){e(t[r],r)}))},format:function(t,e){var r,n=Z(t)?t:{},o=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=J(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){u=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(u)throw o}}}}(e);try{for(o.s();!(r=o.n()).done;){var i=r.value,u=H(i,3),a=u[0],c=u[1],s=u[2];$(n[a])!==c&&(3!==i.length?n[a]=q[c]:n[a]=s)}}catch(t){o.e(t)}finally{o.f()}return n},omit:function(t,e){var r={};return Z(t)&&Object.entries(t).forEach((function(t){var n=H(t,2),o=n[0],i=n[1];e.includes(o)||(r[o]=i)})),r},pick:function(t,e){return e.reduce((function(e,r){return r in t&&(e[r]=t[r]),e}),{})}}),Q=X(t({}),2),V=Q[0],tt=Q[1],et=X(t({}),2),rt=et[0],nt=et[1],ot=function(){var t=rt().baseCore;return{start:t.start,move:t.move,end:t.end,mouseEvent:t.mouseEvent,getData:t.getData,reset:t.reset,addUser:t.addUser,onDragMove:t.onDragMove,onStatus:t.onStatus,onDomEvent:t.onDomEvent}},it=function(){var t=ot().onStatus,e=X(c({}),2),r=e[0],n=e[1];return s((function(){return t((function(t,e){n(e)}))}),[]),r};var ut,at,ct="data-trans-box-type",st="data-trans-box-id",ft="data-trans-box-data",lt=function(t){return t[t.drag=1]="drag",t[t.drop=2]="drop",t[t.resize=4]="resize",t[t.select=8]="select",t[t.stop=64]="stop",t[t.boundary=128]="boundary",t}({}),dt=(ut=[lt.drag,lt.drop,lt.resize,lt.select,lt.stop,lt.boundary],at=[],function t(e,r){if(e.length&&at.push(e),0!==r.length)for(var n=0;n<r.length;n++)t(e.concat(r[n]),r.slice(0,n))}([],ut),at).reduce((function(t,e){var r=e.reduce((function(t,e){return t|e}),0);return t[r.toString()]=r,t}),{}),gt=function(t){if(t)return t.getAttribute(ft)},pt=function(t,e){t&&t.setAttribute(st,e.toString())},vt=function(t){if(t)return t.getAttribute(st)},yt=function(t,e){if(t){var r=t.getAttribute(ct)||"",n=(dt[r]||0)|e;t.setAttribute(ct,n.toString())}},ht=function(t){if(t)return dt[t.getAttribute(ct)||""]},bt=function(t,e){for(var r=t,n=[],o=[],i=[];r&&r!==document.body;){var u=ht(r);u&&(!e||e&u)&&(n.push(u),o.push(vt(r)),i.push(gt(r))),r=r.parentElement}return{types:n,ids:o,datas:i}},mt=function(){var t=ot(),r=t.start,n=t.move,o=t.end,i=t.reset,u=t.mouseEvent,a=t.getData,c=f({free:!0,timer:null}),l=function(){clearTimeout(c.current.timer),c.current.timer=null,u("drag")},d=e((function(t){var e;if(clearTimeout(c.current.timer),(null==t||null===(e=t.target)||void 0===e?void 0:e.nodeType)===Node.ELEMENT_NODE){c.current.free=!1;var n=bt(t.target),o=t.clientX,i=t.clientY;r({startClientX:o,startClientY:i},n),u("down"),c.current.timer=setTimeout(l,120)}})),g=e((function(t){if(!c.current.free){var e=t.clientX,r=t.clientY,o=a(),i=e-o.startClientX,u=r-o.startClientY;(i>30||u>30)&&l(),n({clientX:e,clientY:r,spaceX:i,spaceY:u})}})),p=e((function(t){if(clearTimeout(c.current.timer),!c.current.free){c.current.timer&&(u("tap"),c.current.timer=null);var e=t.clientX,r=t.clientY,n=a(),s=n.startClientX,f=n.startClientY;o({clientX:e,clientY:r,spaceX:e-s,spaceY:r-f})}c.current.free=!0,setTimeout((function(){i()}),0)}));return s((function(){return b(window,{mousedown:d,mousemove:g,mouseup:p})}),[]),w(D,{})},wt=k((function t(e){E(this,t),C(this,"baseCore",void 0),this.baseCore=e})),Dt={status:"free",users:[],position:{startClientX:0,startClientY:0,clientX:0,clientY:0,spaceX:0,spaceY:0},level:{types:[],ids:[],datas:[]},eventType:"free"},Ot=k((function t(){var e=this;E(this,t),C(this,"triggers",h(Dt)),C(this,"onDragMove",(function(t){return e.triggers.onChange("position",(function(){t(e.getData())}))})),C(this,"onStatus",(function(t){var r;return e.triggers.onChange("status",(function(n){r!==n&&(r=n,t(n,e.getBaseData()))}))})),C(this,"onDomEvent",(function(t,r){return e.triggers.onChange("eventType",(function(n){t===n&&r(e.getBaseData())}))})),C(this,"getData",(function(){return B(B({},e.triggers.getter(["status","users"])),e.triggers.getter("position"))})),C(this,"getBaseData",(function(){return e.triggers.getter(["status","users","position","level","eventType"])})),C(this,"reset",(function(){e.triggers.setter(Dt)})),C(this,"descroy",(function(){e.triggers.destroy()}))})),jt=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"start",(function(t,r){e.triggers.setter({position:function(e){return B(B({},e),t)},status:"start",level:r})})),C(e,"move",(function(t){e.triggers.setter({position:function(e){return B(B({},e),t)},status:"move"})})),C(e,"end",(function(t){e.triggers.setter({position:function(e){return B(B({},e),t)},status:"end"})})),C(e,"mouseEvent",(function(t){e.triggers.setter({eventType:t})})),C(e,"addUser",(function(t){e.triggers.setter({users:function(e){return[].concat(Y(e),[t])}})})),e}return z(t,Ot),k(t)}(),It=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=ot().onDragMove,o=r(t,{wait:60}),i=o.run,u=o.fun,a=o.cancel;s((function(){if(e)return n((function(t){return"start"===t.status||"free"===t.status||"end"===t.status?(a(),u(t)):i(t)}))}),[e])},St={dragId:"",item:void 0,type:"",offset:{x:0,y:0,w:0,h:0},renderFake:!0},xt=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(St)),C(e,"dragEmitter",new y),C(e,"onDragEvent",(function(t,r){return e.dragEmitter.addListener(t,r)})),C(e,"onDraggingId",(function(t){return e.triggers.onChange("dragId",(function(){t(e.getDraggingData())}))})),C(e,"getDraggingData",(function(){return e.triggers.getter(["dragId","item","type","offset","renderFake"])})),C(e,"reset",(function(){e.triggers.setter(St)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,wt),k(t)}(),Et=function(){function t(e){var r;return E(this,t),C(r=x(this,t,[e]),"setDragData",(function(t){r.triggers.getter("dragId")||r.triggers.setter(B(B({},t),{},{renderFake:function(){return t.renderFake}}))})),C(r,"emitDrag",(function(t){r.dragEmitter.emit(t,{})})),r.init(),r}return z(t,xt),k(t,[{key:"init",value:function(){var t=this;this.baseCore.onStatus((function(e){"free"===e&&t.reset()}))}}])}(),kt={stack:[],dropId:"",item:void 0,accept:[]},Ct=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(kt)),C(e,"onDropStack",(function(t){e.triggers.onChange("stack",t)})),C(e,"onDropId",(function(t){e.triggers.onChange("dropId",(function(){t(e.getDropData())}))})),C(e,"getDropStack",(function(){return e.triggers.getter("stack")})),C(e,"getDropData",(function(){return e.triggers.getter(["dropId","item","accept"])})),C(e,"getStack",(function(){return e.triggers.getter(["stack"])})),C(e,"reset",(function(){e.triggers.setter(kt)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,wt),k(t)}(),Pt=function(){function t(e){var r;return E(this,t),C(r=x(this,t,[e]),"setDropInfo",(function(t){r.triggers.setter(t)})),C(r,"setDropStack",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r.triggers.setter({stack:t})})),r.init(),r}return z(t,Ct),k(t,[{key:"init",value:function(){var t=this;this.baseCore.onStatus((function(e){"free"===e&&t.reset()}))}}])}(),zt=function(t){var e=f();return t||e},At=function(){var t=rt().dragCore,e=t.setDragData,r=t.getDraggingData;return{dragCore:t,onDragId:t.onDraggingId,onDragEvent:t.onDragEvent,emitDrag:t.emitDrag,setDragData:e,getDraggingData:r,reset:t.reset}},Rt=function(){var t=At().onDragId,e=X(c({}),2),r=e[0],n=e[1];return s((function(){return t((function(t){n(t)}))}),[]),r},Bt=function(){return rt().dndMonitor},Tt=function(t){var r=t.id,n=t.item,o=t.type,i=t.renderFake,u=Bt(),a=ot(),c=a.getData,f=a.addUser,l=At(),d=l.setDragData,g=l.onDragEvent,p=Rt().dragId,v=p===r,y=zt(t.domRef),h=e((function(){var t=c(),e=t.startClientX,a=t.startClientY,s=y.current.getBoundingClientRect(),l=s.left,g=s.top,p=s.width,v=s.height;f("dnd"),d({dragId:r,item:n,type:o,offset:{x:e-l,y:a-g,w:p,h:v},renderFake:W(i)?i.bind(null,u):i})}));return s((function(){return yt(y.current,lt.drag),pt(y.current,r),g(r,h)}),[]),[{id:r,item:n,draggingId:p,isDragging:v},y]},Nt=function(){var t=rt().dropCore,e=t.setDropInfo,r=t.setDropStack,n=t.reset;return{dropCore:t,getDropData:t.getDropData,setDropInfo:e,setDropStack:r,reset:n,onDropStack:t.onDropStack,onDropId:t.onDropId}},Xt=function(t){var e=t.id,i=t.item,u=t.accept,a=t.onOver,f=t.onDroped,l=zt(t.domRef),d=Bt(),g=function(){var t=Nt().onDropStack,e=X(c([]),2),r=e[0],n=e[1];return s((function(){return t((function(t){n(t)}))}),[]),r}(),p=Nt().setDropInfo,v=e||n(),y=Rt(),h=y.dragId,b=y.type,m=h&&g[0]===v,w=!(null!=u&&u.length)||(null==u?void 0:u.includes(b||"")),D=function(t){var e,r=(null===(e=l.current)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0},n=r.left,o=r.top;return{offsetX:t.clientX-n,offsetY:t.clientY-o}},O=r((function(t){m&&(null==a||a(B(B({},d),{},{getDropPos:function(){return D(t)}})))})),j=O.run;return o(l,{mousemove:j,mouseup:function(t){m&&(p({dropId:v,accept:u,item:i}),null==f||f(B(B({},d),{},{getDropPos:function(){return D(t)}})))}}),s((function(){yt(l.current,lt.drop),pt(l.current,v)}),[]),[{id:v,item:i,accept:u,isOver:m,isAccept:w},l]},Yt=["className","style","children"],_t=l((function(t,e){var r=t.className,n=t.style,o=t.children,i=T(t,Yt);return d(o)&&function(t){return"string"===$(t)}(o.type)?a.cloneElement(o,B(B({},i),{},{ref:e,className:m(r,o.props.className),style:K.extend(n,o.props.style)})):w("div",B(B({ref:e},i),{},{style:n,className:r,children:o}))})),Ft=["id","renderFake"],Mt=function(t){var e=t.className,r=t.style,n=t.children,o=V(),i=o.id,u=o.renderFake,a=T(o,Ft),c=it().status,s=X(Tt(B({id:i,renderFake:L(u)||u},a)),2),f=s[0].isDragging,l=s[1],d=B(B({},r),{},{cursor:"move"!==c?"grab":void 0,pointerEvents:f?"none":"unset"});return w(_t,B(B({},{ref:l,className:e,style:d}),{},{children:n}))},Ut=function(t){var e=t.className,r=t.style,n=t.children,o=t.onOver,i=t.onDroped,u=t.item,a=t.accept,c=t.id,s=X(Xt({id:c,item:u||{},accept:a||[],onDroped:function(t){var e=t.getDropPos(),r=e.offsetX,n=e.offsetY,o=t.getDraggingBaseData(),u=o.dragId,a=o.offset;d&&(null==i||i(u,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h}))},onOver:function(t){var e=t.getDropPos(),r=e.offsetX,n=e.offsetY,i=t.getDraggingBaseData(),u=i.dragId,a=i.offset;null==o||o(u,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h})}}),2),f=s[0],l=f.isOver,d=f.isAccept,g=s[1],p=B({boxShadow:l?d?"0 0 4px 1px #1f90fc":"0 0 4px 1px orange":"none"},r);return w(_t,B(B({},{ref:g,className:e,style:p}),{},{children:n}))},$t={lt:"nwse-resize",rt:"nesw-resize",lb:"nesw-resize",rb:"nwse-resize",t:"ns-resize",l:"ew-resize",r:"ew-resize",b:"ns-resize"},Lt=function(t){var e=t.hidden,r=t.handles,n=t.id;return e?w(D,{}):(r||["lt","l","lb","t","b","rt","r","rb"]).map((function(t){return g("span",B(B({},C(C(C({},ct,lt.resize),st,n),ft,t)),{},{key:t,style:Gt[t]}))}))},Wt={position:"absolute",left:0,top:0,transform:"translate(-50%, -50%)",backgroundColor:"green"},Zt=B(B({},Wt),{},{width:"20px",height:"20px",borderRadius:"2px"}),qt=B(B({},Wt),{},{width:"6px",height:"6px"}),Gt={lt:B(B({},qt),{},{cursor:$t.lt}),lb:B(B({},qt),{},{top:"100%",cursor:$t.lb}),rt:B(B({},qt),{},{left:"100%",cursor:$t.rt}),rb:B(B({},qt),{},{left:"100%",top:"100%",cursor:$t.rb}),l:B(B({},Zt),{},{top:"50%",width:qt.height,cursor:$t.l}),r:B(B({},Zt),{},{left:"100%",top:"50%",width:qt.width,cursor:$t.r}),t:B(B({},Zt),{},{left:"50%",height:qt.height,cursor:$t.t}),b:B(B({},Zt),{},{left:"50%",top:"100%",height:qt.height,cursor:$t.b})},Ht={id:"",info:{},startCoord:{x:0,y:0,w:0,h:0}},Jt=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(Ht)),C(e,"resizeEmitter",new y),C(e,"onBaseInfo",(function(t){return e.triggers.onChange("id",(function(){t(e.getBaseInfo())}))})),C(e,"onResizeEvent",(function(t,r){return e.resizeEmitter.addListener(t,r)})),C(e,"getBaseInfo",(function(){return e.triggers.getter(["id","info","handle","startCoord"])})),C(e,"reset",(function(){e.triggers.setter(Ht)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,wt),k(t)}(),Kt=function(){function t(e){var r;return E(this,t),C(r=x(this,t,[e]),"setBaseInfo",(function(t){r.triggers.setter(t)})),C(r,"emitResize",(function(t,e){r.resizeEmitter.emit(t,e)})),r.init(),r}return z(t,Jt),k(t,[{key:"init",value:function(){var t=this;this.baseCore.onStatus((function(e){"free"===e&&t.reset()}))}}])}(),Qt=function(){var t=rt().resizeCore;return{reset:t.reset,descroy:t.descroy,getBaseInfo:t.getBaseInfo,onBaseInfo:t.onBaseInfo,emitResize:t.emitResize,onResizeEvent:t.onResizeEvent,setBaseInfo:t.setBaseInfo}},Vt=function(){var t=Qt().onBaseInfo,e=X(c({}),2),r=e[0],n=e[1];return s((function(){return t(n)}),[]),r},te=function(t){var r=t.id,n=t.onResizing,o=t.onResized,i=t.domRef,u=ot().addUser,a=Qt(),c=a.setBaseInfo,f=a.onResizeEvent,l=Vt(),d=l.id,g=l.handle,p=l.startCoord,v=d===r,y=e((function(t){var e;u("resize");var n=(null==i||null===(e=i.current)||void 0===e?void 0:e.getBoundingClientRect())||{x:0,y:0,width:0,height:0},o=n.x,a=n.y,s=n.width,f=n.height;c({id:r,startCoord:{x:o,y:a,w:s,h:f},info:{},handle:t})}));return s((function(){f(r,y)}),[]),It((function(t){if("free"!==t.status){var e=function(t,e,r){var n=B({},t),o=n.h,i=n.w,u=n.x,a=n.y,c=e.spaceX,s=e.spaceY;switch(r){case"lt":n.x=u+c,n.y=a+s,n.w=i-c,n.h=o-s;break;case"rt":n.x=u,n.y=a+s,n.w=i+c,n.h=o-s;break;case"lb":n.x=u+c,n.y=a,n.w=i-c,n.h=o+s;break;case"rb":n.x=u,n.y=a,n.w=i+c,n.h=o+s;break;case"l":n.x=u+c,n.y=a,n.w=i-c,n.h=o;break;case"r":n.x=u,n.y=a,n.w=i+c,n.h=o;break;case"b":n.x=u,n.y=a,n.w=i,n.h=o+s;break;case"t":n.x=u,n.y=a+s,n.w=i,n.h=o-s}return n}(p,t,g);null==n||n(e),"end"===t.status&&(null==o||o(e))}}),v&&!!n),[{isResizing:v},{}]},ee=["children","style","pure","className"],re=function(t){var e=t.children,r=t.style,n=t.pure,o=t.className,i=T(t,ee);return X(te(i),1),n?w(Lt,{id:i.id}):O("div",{style:B({position:"relative"},r),className:o,children:[w(Lt,{id:i.id}),e]})};function ne(t,e,r){return(e=ae(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?oe(Object(r),!0).forEach((function(e){ne(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):oe(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ue(t,e){return ue=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ue(t,e)}function ae(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}function ce(){ce=function(t,e){return new r(t,void 0,e)};var t=RegExp.prototype,e=new WeakMap;function r(t,n,o){var i=RegExp(t,n);return e.set(i,o||e.get(t)),ue(i,r.prototype)}function n(t,r){var n=e.get(r);return Object.keys(n).reduce((function(e,r){var o=n[r];if("number"==typeof o)e[r]=t[o];else{for(var i=0;void 0===t[o[i]]&&i+1<o.length;)i++;e[r]=t[o[i]]}return e}),Object.create(null))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ue(t,e)}(r,RegExp),r.prototype.exec=function(e){var r=t.exec.call(this,e);if(r){r.groups=n(r,this);var o=r.indices;o&&(o.groups=n(o,this))}return r},r.prototype[Symbol.replace]=function(r,o){if("string"==typeof o){var i=e.get(this);return t[Symbol.replace].call(this,r,o.replace(/\$<([^>]+)>/g,(function(t,e){var r=i[e];return"$"+(Array.isArray(r)?r.join("$"):r)})))}if("function"==typeof o){var u=this;return t[Symbol.replace].call(this,r,(function(){var t=arguments;return"object"!=typeof t[t.length-1]&&(t=[].slice.call(t)).push(n(t,u)),o.apply(this,t)}))}return t[Symbol.replace].call(this,r,o)},ce.apply(this,arguments)}var se=function(t,e){return t.reduce((function(t,r){var n=r[e];return ie(ie({},t),{},ne({},n,r))}),{})},fe=function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36,e=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"],r=[],n=0;n<t;n++)r[n]=8===n||13===n||18===n||23===n?"-":e[Math.ceil(Math.random()*e.length-1)];return r.join("")};!function(t,e){e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ae(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1})}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ne(this,"handler",[])}),[{key:"use",value:function(t,e){return this.handler.push({fulfilled:t,rejected:e}),this.handler.length-1}},{key:"eject",value:function(t){this.handler[t]&&(this.handler[t]=null)}},{key:"clear",value:function(){this.handler=[]}},{key:"forEach",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(t,e,r){if(r)for(var n=t.length-1;n>=0;n--)e(t[n],n,t);else for(var o=0;o<t.length;o++)e(t[o],o,t)}(this.handler,(function(e){e&&t(e)}),e)}},{key:"run",value:function(t){var e=arguments;return new Promise(function(r,n){var o=e.length>1&&void 0!==e[1]&&e[1],i=Promise.resolve(t());return this.forEach((function(t){i=i.then(t.fulfilled,t.rejected)}),o),r(i)}.bind(this))}}]),ce(/\?([^#]*)/,{query:1}),ce(/#(.*)/,{hash:1}),ce(/^(?:[a-zA-Z][a-zA-Zd+-.]*:)?(?:\/\/(?:[^@/?#]*@)?[^/?#]*)?([^?#]*)/,{pathname:1});var le=["show","dom"],de=function(t){var e=t.show,r=t.dom,n=T(t,le);return e&&r?j.createPortal(w("div",{style:{position:"absolute",inset:0},children:w(Lt,B({},n))}),r):w(D,{})},ge={ids:[],infoMap:{}},pe=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(ge)),C(e,"onSelectIds",(function(t){return e.triggers.onChange("ids",(function(){t(e.getSelectInfo())}))})),C(e,"getSelectInfo",(function(){return e.triggers.getter(["ids","infoMap"])})),C(e,"reset",(function(){e.triggers.setter(ge)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,wt),k(t)}(),ve=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"setSelectIds",(function(t){e.triggers.setter({ids:t})})),e}return z(t,pe),k(t)}(),ye=function(){var t=rt().selectCore,e=t.reset,r=t.setSelectIds,n=t.descroy,o=t.onSelectIds;return{getSelectInfo:t.getSelectInfo,setSelectIds:r,onSelectIds:o,reset:e,descroy:n}},he=function(t){var e,r,n,o,i,u,a=t.id,f=t.domRef,l=(e=ye(),r=e.onSelectIds,n=e.getSelectInfo,o=X(c(n()),2),i=o[0],u=o[1],s((function(){return r((function(t){u(t)}))}),[]),i),d=l.ids,g=l.infoMap[a],p=d.includes(a);return s((function(){yt(null==f?void 0:f.current,lt.select)}),[]),[{isSelect:p,selectInfo:g}]},be=function(t){var e=t.id,r=t.coord,n=t.item,o=t.className,i=t.onResizing,u=t.onOver,a=t.onDroped,c=it().status,s=X(Tt({id:e,renderFake:!0,item:n}),2),f=s[0].isDragging,l=s[1],d=X(he({id:e,domRef:l}),1)[0].isSelect;te({id:e,onResizing:i,domRef:l}),Xt({id:e,item:n,domRef:l,onOver:u,onDroped:a});var g=p((function(){return{left:r.x,top:r.y,width:r.w,height:r.h,cursor:"move"!==c?"grab":void 0,pointerEvents:f?"none":"unset"}}),[r,c,f]),v=p((function(){return{boxShadow:d?"0 0 4px 1px #0078d4":void 0}}),[d]),y=p((function(){return{contain:d?"layout":void 0}}),[d]);return O(D,{children:[w(de,{show:d&&!f,id:e,dom:l.current}),w(_t,{ref:l,className:o,style:B(B(B(B({},g),v),y),t.style),children:t.children})]})},me=function(t){var e=t.children,r=t.onWillAdd,n=X(i(t,[]),2),o=n[0],u=n[1],a=p((function(){return se(e,"key")}),[e]),c=function(t,e){if(o){var r=Y(o),n=o.findIndex((function(e){return e.i===t}));-1!==n&&(r[n]=B(B({},r[n]),e),null==u||u(r))}};return w(Ut,{accept:t.accept,className:t.className,style:t.style,onDroped:function(t,e){if(o){var n=Y(o),i=o.findIndex((function(e){return e.i===t})),a=B({i:t},e);-1===i&&(a.i=r?r(t,e):fe(),n.push({}),i=n.length-1),n[i]=a,null==u||u(n)}},children:null==o?void 0:o.map((function(t){var e=a[t.i];return e?w(be,{style:{position:"absolute",transition:"all 0.2s"},coord:t,id:t.i,onResizing:c.bind(null,t.i),children:e},t.i):w(v,{},t.i)}))})},we=["className","style","children"],De=function(t){var e=t.className,r=t.style,n=t.children,o=T(t,we);return w(tt,{value:o,children:w(Mt,{style:r,className:e,children:n})})},Oe=function(t){var e=t.children,r=t.onWillAdd,n=X(i(t,[]),2),o=n[0],u=n[1],a=p((function(){return se(e,"key")}),[e]),c=function(t,e){if(o){var n=Y(o),i=o.findIndex((function(e){return e.i===t})),a=B({i:t},e);-1===i&&(a.i=r?r(t,e):fe(),n.push({}),i=n.length-1),n[i]=a,null==u||u(n)}},s=function(t,e){if(o){var r=Y(o),n=o.findIndex((function(e){return e.i===t}));-1!==n&&(r[n]=B(B({},r[n]),e),null==u||u(r))}},f=function(t){if(o){var e=t.getDroppingId(),r=t.getDraggingBaseData(),n=r.dragId,i=r.offset,a=o.findIndex((function(t){return t.i===n}));if(console.log(a),-1!==a){var s=o.findIndex((function(t){return t.i===e}));if(console.log(s,e),-1!==s){var f=Y(o),l=f[a];f[a]=f[s],f[s]=l,null==u||u(f)}}else null==c||c(n,{x:0,y:0,w:i.w,h:i.h})}};return w(Ut,{accept:t.accept,className:t.className,style:t.style,onDroped:c,children:null==o?void 0:o.map((function(t){var e=a[t.i];return e?w(be,{coord:t,style:{},id:t.i,onResizing:s.bind(null,t.i),onDroped:f,children:e},t.i):w(v,{},t.i)}))})},je=function(t){var e=t.id,r=t.item,n=t.type;return w(tt,{value:{id:e,item:r,type:n},children:t.children})},Ie=function(){var t=Rt().dragId,e=Vt(),r=e.handle,n=e.id,o=ot().getData;return s((function(){var e=o().users[0];t&&"dnd"===e?(document.body.style.cursor="grabbing",document.body.style.userSelect="none"):r&&"resize"===e?(document.body.style.cursor=$t[r],document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")}),[t,r,n]),w(D,{})},Se=function(){var t=ot().onDomEvent,e=At().emitDrag;return s((function(){return t("drag",(function(t){var r=t.level,n=r.types,o=r.ids;if(!(n[0]&lt.resize)){var i=n.findIndex((function(t){return t&lt.drag}));if(!(i<0)){var u=o[i];u&&e(u)}}}))}),[]),w(D,{})},xe=function(){var t=Rt(),e=t.dragId,r=t.offset,n=t.renderFake,o=X(c(""),2),i=o[0],u=o[1],a=X(c(!1),2),s=a[0],l=a[1],d=f({timer:null}),g=function(t){var e=t.clientX,n=t.clientY,o=r,i=o.x,a=o.y;u("translate(".concat(e-(i||0),"px, ").concat(n-(a||0),"px)"))},v=function(t){clearTimeout(d.current.timer),g(t),d.current.timer=setTimeout((function(){l(!0),d.current.timer=null}),100)};It((function(t){switch(t.status){case"start":v(t);break;case"end":clearTimeout(d.current.timer),d.current.timer=setTimeout((function(){l(!1),u(""),d.current.timer=null}),100);break;case"move":d.current.timer?g(t):v(t)}}),!!e);var y=p((function(){return W(n)?n():w("div",{style:{width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.5)"}})}),[n]);return I(w("div",{style:{position:"fixed",pointerEvents:"none",left:0,top:0,width:0,height:0,zIndex:1e3},children:n?w("div",{style:{display:s&&e?"block":"none",position:"absolute",transition:e?"transform linear 0.1s":"",width:null==r?void 0:r.w,height:null==r?void 0:r.h,transform:i},children:y}):w(D,{})}),document.body)},Ee=function(){var t=Rt().dragId,r=Nt().setDropStack,n=e((function(e){if(t){var n=bt(e.target,lt.drop).ids;r(n.filter(Boolean))}})),o=e((function(){setTimeout((function(){r()}),0)}));return s((function(){if(t)return b(window,{mouseover:n,mouseup:o})}),[!!t]),w(D,{})},ke=function(){var t=ot().onDomEvent,e=Qt().emitResize;return s((function(){return t("down",(function(t){var r=t.level,n=r.types,o=r.ids,i=r.datas;if(n[0]&lt.resize){var u=o[0],a=i[0];e(u,a)}}))}),[]),w(D,{})},Ce=function(){var t=ye(),e=t.setSelectIds,r=t.reset,n=ot().onDomEvent;return s((function(){return n("tap",(function(t){var n=t.level,o=n.types,i=n.ids,u=o.findIndex((function(t){return t&lt.select}));if(u<0)r();else{var a=i[u];a&&e([a])}}))}),[]),w(D,{})},Pe=function(t){var e=u((function(){var t,e,r,n=new jt,o=new Et(n),i=new Pt(n),u=(e=(t={droppingCore:i,draggingCore:o}).draggingCore,r=t.droppingCore,{getDraggingBaseData:function(){return e.getDraggingData()},getDraggingId:function(){return e.triggers.getter("dragId")||""},getDraggingItem:function(){return e.triggers.getter("item")||{}},getDraggingType:function(){return e.triggers.getter("type")||""},getDraggingOffset:function(){return e.triggers.getter("offset")},getDroppingBaseData:function(){return r.getDropData()},getDroppingId:function(){return r.triggers.getter("dropId")},getDroppingAccept:function(){return r.triggers.getter("accept")||[]},getDroppingItem:function(){return r.triggers.getter("item")},getDroppingStack:function(){return r.triggers.getter("stack")}});return{baseCore:n,selectCore:new ve(n),resizeCore:new Kt(n),dragCore:o,dropCore:i,dndMonitor:u}}));return O(nt,{value:e.current,children:[w(mt,{}),w(Ie,{}),w(ke,{}),w(Se,{}),w(Ce,{}),w(xe,{}),w(Ee,{}),t.children]})};export{je as BoxProviderWrap,me as CoordWrap,Mt as Drag,De as DragBoxWrap,Ut as Drop,Oe as PlainWrap,Lt as ReiseHandle,re as Resize,Kt as ResizeCore,be as TransBox,Pe as TransProviderWrap,te as useResize,Qt as useResizeCore,Vt as useResizeInfo};
1
+ import{createCtx as t,useCallbackRef as e,useThrottleFn as r,useUuid as n,useEventListenerMultiple as o,useControl as i,useRefPro as u}from"@cclr/react";import a,{useState as c,useEffect as s,useRef as f,forwardRef as l,isValidElement as d,createElement as g,useMemo as p,Fragment as v}from"react";import{Emitter as y}from"@cclr/emitter";import{dataTriggers as h}from"@cclr/trigger";import{addEventListenerMultiple as b,classNames as m}from"@cclr/front";import{jsx as D,Fragment as w,jsxs as O}from"react/jsx-runtime";import j,{createPortal as I}from"react-dom";function S(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function x(t,e,r){return e=P(e),function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,A()?Reflect.construct(e,r||[],P(t).constructor):e.apply(t,r))}function E(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function k(t,e,r){return e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function C(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){return P=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},P(t)}function z(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&N(t,e)}function A(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(A=function(){return!!t})()}function B(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function R(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?B(Object(r),!0).forEach((function(e){C(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):B(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function T(t,e){if(null==t)return{};var r,n,o=function(t,e){if(null==t)return{};var r={};for(var n in t)if({}.hasOwnProperty.call(t,n)){if(-1!==e.indexOf(n))continue;r[n]=t[n]}return r}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(n=0;n<i.length;n++)r=i[n],-1===e.indexOf(r)&&{}.propertyIsEnumerable.call(t,r)&&(o[r]=t[r])}return o}function N(t,e){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},N(t,e)}function X(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(s)throw o}}return a}}(t,e)||F(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Y(t){return function(t){if(Array.isArray(t))return S(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||F(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function F(t,e){if(t){if("string"==typeof t)return S(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?S(t,e):void 0}}Function.prototype.call.bind(Object.prototype.hasOwnProperty);var M=Function.prototype.call.bind(Object.prototype.toString),U={boolean:"boolean",undefined:"undefined",number:"number",string:"string",symbol:"symbol",null:"null","[object Object]":"object","[object Function]":"function","[object RegExp]":"regexp","[object Array]":"array","[object Date]":"date","[object Error]":"error","[object Blob]":"blob","[object File]":"file","[object ArrayBuffer]":"arrayBuffer"};function $(t){return U[typeof t]||U[M(t)]||(t?"object":"null")}function L(t){return function(t){return null===t}(t)||function(t){return void 0===t}(t)}function W(t){return"function"===$(t)}function Z(t){return function(t){return"object"===$(t)}(t)&&Object.getPrototypeOf(t)===Object.prototype}var q={string:"",number:0,boolean:!1,undefined:void 0,null:null,object:{},array:[],function:function(){},regexp:/(?:)/};function G(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function H(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,a=[],c=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(s)throw o}}return a}}(t,e)||J(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function J(t,e){if(t){if("string"==typeof t)return G(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?G(t,e):void 0}}var K=Object.freeze({__proto__:null,extend:function(t,e){var r=t||{};return Z(e)&&Object.keys(e).forEach((function(t){r[t]=e[t]})),r},filter:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:L,r={};return Z(t)&&Object.entries(t).forEach((function(n){var o=H(n,2),i=o[0],u=o[1];e(t[i],i)&&(r[i]=u)})),r},forEach:function(t,e){Object.keys(t).forEach((function(r){e(t[r],r)}))},format:function(t,e){var r,n=Z(t)?t:{},o=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=J(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,u=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return i=t.done,t},e:function(t){u=!0,o=t},f:function(){try{i||null==e.return||e.return()}finally{if(u)throw o}}}}(e);try{for(o.s();!(r=o.n()).done;){var i=r.value,u=H(i,3),a=u[0],c=u[1],s=u[2];$(n[a])!==c&&(3!==i.length?n[a]=q[c]:n[a]=s)}}catch(t){o.e(t)}finally{o.f()}return n},omit:function(t,e){var r={};return Z(t)&&Object.entries(t).forEach((function(t){var n=H(t,2),o=n[0],i=n[1];e.includes(o)||(r[o]=i)})),r},pick:function(t,e){return e.reduce((function(e,r){return r in t&&(e[r]=t[r]),e}),{})}}),Q=X(t({}),2),V=Q[0],tt=Q[1],et=X(t({}),2),rt=et[0],nt=et[1],ot=function(){var t=rt().baseCore;return{start:t.start,move:t.move,end:t.end,mouseEvent:t.mouseEvent,getData:t.getData,getBaseData:t.getBaseData,reset:t.reset,addUser:t.addUser,onDragMove:t.onDragMove,onStatus:t.onStatus,onDomEvent:t.onDomEvent}},it=function(){var t=ot().onStatus,e=X(c({}),2),r=e[0],n=e[1];return s((function(){return t((function(t,e){n(e)}))}),[]),r};var ut,at,ct="data-trans-box-type",st="data-trans-box-id",ft="data-trans-box-data",lt=function(t){return t[t.drag=1]="drag",t[t.drop=2]="drop",t[t.resize=4]="resize",t[t.select=8]="select",t[t.stop=64]="stop",t[t.boundary=128]="boundary",t}({}),dt=(ut=[lt.drag,lt.drop,lt.resize,lt.select,lt.stop,lt.boundary],at=[],function t(e,r){if(e.length&&at.push(e),0!==r.length)for(var n=0;n<r.length;n++)t(e.concat(r[n]),r.slice(0,n))}([],ut),at).reduce((function(t,e){var r=e.reduce((function(t,e){return t|e}),0);return t[r.toString()]=r,t}),{}),gt=function(t){if(t)return t.getAttribute(ft)},pt=function(t,e){t&&t.setAttribute(st,e.toString())},vt=function(t){if(t)return t.getAttribute(st)},yt=function(t,e){if(t){var r=t.getAttribute(ct)||"",n=(dt[r]||0)|e;t.setAttribute(ct,n.toString())}},ht=function(t){if(t)return dt[t.getAttribute(ct)||""]},bt=function(t,e){for(var r=t,n=[],o=[],i=[];r&&r!==document.body;){var u=ht(r);u&&(!e||e&u)&&(n.push(u),o.push(vt(r)),i.push(gt(r))),r=r.parentElement}return{types:n,ids:o,datas:i}},mt=function(){var t=ot(),r=t.start,n=t.move,o=t.end,i=t.reset,u=t.mouseEvent,a=t.getData,c=f({free:!0,timer:null}),l=function(){clearTimeout(c.current.timer),c.current.timer=null,u("drag")},d=e((function(t){var e;if(clearTimeout(c.current.timer),(null==t||null===(e=t.target)||void 0===e?void 0:e.nodeType)===Node.ELEMENT_NODE){c.current.free=!1;var n=bt(t.target),o=t.clientX,i=t.clientY;r({startClientX:o,startClientY:i},n),u("down"),c.current.timer=setTimeout(l,120)}})),g=e((function(t){if(!c.current.free){var e=t.clientX,r=t.clientY,o=a(),i=e-o.startClientX,u=r-o.startClientY;c.current.timer&&(i>30||u>30)&&l(),n({clientX:e,clientY:r,spaceX:i,spaceY:u})}})),p=e((function(t){if(clearTimeout(c.current.timer),!c.current.free){c.current.timer&&(u("tap"),c.current.timer=null);var e=t.clientX,r=t.clientY,n=a(),s=n.startClientX,f=n.startClientY;o({clientX:e,clientY:r,spaceX:e-s,spaceY:r-f})}c.current.free=!0,setTimeout((function(){i()}),0)}));return s((function(){return b(window,{mousedown:d,mousemove:g,mouseup:p})}),[]),D(w,{})},Dt=k((function t(e){E(this,t),C(this,"baseCore",void 0),this.baseCore=e})),wt={status:"free",users:[],position:{startClientX:0,startClientY:0,clientX:0,clientY:0,spaceX:0,spaceY:0},level:{types:[],ids:[],datas:[]},eventType:"free"},Ot=k((function t(){var e=this;E(this,t),C(this,"triggers",h(wt)),C(this,"onDragMove",(function(t){return e.triggers.onChange("position",(function(){t(e.getData())}))})),C(this,"onStatus",(function(t){var r;return e.triggers.onChange("status",(function(n){r!==n&&(r=n,t(n,e.getBaseData()))}))})),C(this,"onDomEvent",(function(t,r){return e.triggers.onChange("eventType",(function(n){t===n&&r(e.getBaseData())}))})),C(this,"getData",(function(){return R(R({},e.triggers.getter(["status","users"])),e.triggers.getter("position"))})),C(this,"getBaseData",(function(){return e.triggers.getter(["status","users","position","level","eventType"])})),C(this,"reset",(function(){e.triggers.setter(wt)})),C(this,"descroy",(function(){e.triggers.destroy()}))})),jt=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"start",(function(t,r){e.triggers.setter({position:function(e){return R(R({},e),t)},status:"start",level:r})})),C(e,"move",(function(t){e.triggers.setter({position:function(e){return R(R({},e),t)},status:"move"})})),C(e,"end",(function(t){e.triggers.setter({position:function(e){return R(R({},e),t)},status:"end"})})),C(e,"mouseEvent",(function(t){e.triggers.setter({eventType:t})})),C(e,"addUser",(function(t){e.triggers.setter({users:function(e){return[].concat(Y(e),[t])}})})),e}return z(t,Ot),k(t)}(),It=function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=ot().onDragMove,o=r(t,{wait:60}),i=o.run,u=o.fun,a=o.cancel;s((function(){if(e)return n((function(t){return"start"===t.status||"free"===t.status||"end"===t.status?(a(),u(t)):i(t)}))}),[e])},St={dragId:"",item:void 0,type:"",offset:{x:0,y:0,w:0,h:0},renderFake:!0},xt=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(St)),C(e,"dragEmitter",new y),C(e,"onDragStartEvent",(function(t,r){return e.dragEmitter.addListener(t,r)})),C(e,"onDraggingId",(function(t){return e.triggers.onChange("dragId",(function(){t(e.getDraggingData())}))})),C(e,"getDraggingData",(function(){return e.triggers.getter(["dragId","item","type","offset","renderFake"])})),C(e,"reset",(function(){e.triggers.setter(St)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,Dt),k(t)}(),Et=function(){function t(e){var r;return E(this,t),C(r=x(this,t,[e]),"setDragData",(function(t){r.triggers.getter("dragId")||r.triggers.setter(R(R({},t),{},{renderFake:function(){return t.renderFake}}))})),C(r,"emitDrag",(function(t){r.dragEmitter.emit(t,{})})),r.init(),r}return z(t,xt),k(t,[{key:"init",value:function(){var t=this;this.baseCore.onStatus((function(e){"free"===e&&t.reset()}))}}])}(),kt={stack:[],dropId:"",item:void 0,accept:[]},Ct=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(kt)),C(e,"onDropStack",(function(t){e.triggers.onChange("stack",t)})),C(e,"onDropId",(function(t){e.triggers.onChange("dropId",(function(){t(e.getDropData())}))})),C(e,"getDropStack",(function(){return e.triggers.getter("stack")})),C(e,"getDropData",(function(){return e.triggers.getter(["dropId","item","accept"])})),C(e,"getStack",(function(){return e.triggers.getter(["stack"])})),C(e,"reset",(function(){e.triggers.setter(kt)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,Dt),k(t)}(),Pt=function(){function t(e){var r;return E(this,t),C(r=x(this,t,[e]),"setDropInfo",(function(t){r.triggers.setter(t)})),C(r,"setDropStack",(function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r.triggers.setter({stack:t})})),r.init(),r}return z(t,Ct),k(t,[{key:"init",value:function(){var t=this;this.baseCore.onStatus((function(e){"free"===e&&t.reset()}))}}])}(),zt=function(t){var e=f();return t||e},At=function(){var t=rt().dragCore,e=t.setDragData,r=t.getDraggingData;return{dragCore:t,onDragId:t.onDraggingId,onDragStartEvent:t.onDragStartEvent,emitDrag:t.emitDrag,setDragData:e,getDraggingData:r,reset:t.reset}},Bt=function(){var t=At().onDragId,e=X(c({}),2),r=e[0],n=e[1];return s((function(){return t((function(t){n(t)}))}),[]),r},Rt=function(){return rt().dndMonitor},Tt=function(t){var r,n,o,i,u=t.id,a=t.item,c=t.type,f=t.renderFake,l=t.onDragStart,d=t.onDrag,g=t.onDragEnd,p=Rt(),v=ot(),y=v.getData,h=v.addUser,b=At(),m=b.setDragData,D=b.onDragStartEvent,w=Bt().dragId,O=w===u,j=zt(t.domRef),I=e((function(){var t=y(),e=t.startClientX,r=t.startClientY,n=j.current.getBoundingClientRect(),o=n.left,i=n.top,s=n.width,d=n.height;h("dnd"),m({dragId:u,item:a,type:c,offset:{x:e-o,y:r-i,w:s,h:d},renderFake:W(f)?f.bind(null,p):f}),null==l||l(p)}));return r=function(t){"end"===t&&(null==g||g(p))},n=O,o=ot().onStatus,i=e(r),s((function(){if(n)return o(i)}),[n]),It((function(t){"free"!==t.status&&(null==d||d(p))}),O&&!!d),s((function(){return yt(j.current,lt.drag),pt(j.current,u),D(u,I)}),[]),[{id:u,item:a,draggingId:w,isDragging:O},j]},Nt=function(){var t=rt().dropCore,e=t.setDropInfo,r=t.setDropStack,n=t.reset;return{dropCore:t,getDropData:t.getDropData,setDropInfo:e,setDropStack:r,reset:n,onDropStack:t.onDropStack,onDropId:t.onDropId}},Xt=function(t){var e=t.id,i=t.item,u=t.accept,a=t.onOver,f=t.onDroped,l=zt(t.domRef),d=Rt(),g=function(){var t=Nt().onDropStack,e=X(c([]),2),r=e[0],n=e[1];return s((function(){return t((function(t){n(t)}))}),[]),r}(),p=Nt().setDropInfo,v=e||n(),y=Bt(),h=y.dragId,b=y.type,m=h&&g[0]===v,D=!(null!=u&&u.length)||(null==u?void 0:u.includes(b||"")),w=function(t){var e,r=(null===(e=l.current)||void 0===e?void 0:e.getBoundingClientRect())||{left:0,top:0},n=r.left,o=r.top;return{offsetX:t.clientX-n,offsetY:t.clientY-o}},O=r((function(t){null==a||a(R(R({},d),{},{getDropPos:function(){return w(t)}}))})),j=O.run;return o(l,{mousemove:j,mouseup:function(t){p({dropId:v,accept:u,item:i}),null==f||f(R(R({},d),{},{getDropPos:function(){return w(t)}}))}},!!m),s((function(){yt(l.current,lt.drop),pt(l.current,v)}),[]),[{id:v,item:i,accept:u,isOver:m,isAccept:D},l]},Yt=["className","style","children"],_t=l((function(t,e){var r=t.className,n=t.style,o=t.children,i=T(t,Yt);return d(o)&&function(t){return"string"===$(t)}(o.type)?a.cloneElement(o,R(R({},i),{},{ref:e,className:m(r,o.props.className),style:K.extend(n,o.props.style)})):D("div",R(R({ref:e},i),{},{style:n,className:r,children:o}))})),Ft=["className","style","children"],Mt=["id","renderFake"],Ut=function(t){var e=t.className,r=t.style,n=t.children,o=T(t,Ft),i=V(),u=i.id,a=i.renderFake,c=T(i,Mt),s=it().status,f=X(Tt(R(R({id:u,renderFake:L(a)||a},o),c)),2),l=f[0].isDragging,d=f[1],g=R(R({},r),{},{cursor:"move"!==s?"grab":void 0,pointerEvents:l?"none":"unset"});return D(_t,R(R({},{ref:d,className:e,style:g}),{},{children:n}))},$t=function(t){var e=t.className,r=t.style,n=t.children,o=t.onOver,i=t.onDroped,u=t.item,a=t.accept,c=t.id,s=X(Xt({id:c,item:u||{},accept:a||[],onDroped:function(t){var e=t.getDropPos(),r=e.offsetX,n=e.offsetY,o=t.getDraggingBaseData(),u=o.dragId,a=o.offset;d&&(null==i||i(u,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h}))},onOver:function(t){var e=t.getDropPos(),r=e.offsetX,n=e.offsetY,i=t.getDraggingBaseData(),u=i.dragId,a=i.offset;null==o||o(u,{x:r-(a.x||0),y:n-(a.y||0),w:a.w,h:a.h})}}),2),f=s[0],l=f.isOver,d=f.isAccept,g=s[1],p=R({boxShadow:l?d?"0 0 4px 1px #1f90fc":"0 0 4px 1px orange":"none"},r);return D(_t,R(R({},{ref:g,className:e,style:p}),{},{children:n}))},Lt={lt:"nwse-resize",rt:"nesw-resize",lb:"nesw-resize",rb:"nwse-resize",t:"ns-resize",l:"ew-resize",r:"ew-resize",b:"ns-resize"},Wt=function(t){var e=t.hidden,r=t.handles,n=t.id;return e?D(w,{}):(r||["lt","l","lb","t","b","rt","r","rb"]).map((function(t){return g("span",R(R({},C(C(C({},ct,lt.resize),st,n),ft,t)),{},{key:t,style:Ht[t]}))}))},Zt={position:"absolute",left:0,top:0,transform:"translate(-50%, -50%)",backgroundColor:"green"},qt=R(R({},Zt),{},{width:"20px",height:"20px",borderRadius:"2px"}),Gt=R(R({},Zt),{},{width:"6px",height:"6px"}),Ht={lt:R(R({},Gt),{},{cursor:Lt.lt}),lb:R(R({},Gt),{},{top:"100%",cursor:Lt.lb}),rt:R(R({},Gt),{},{left:"100%",cursor:Lt.rt}),rb:R(R({},Gt),{},{left:"100%",top:"100%",cursor:Lt.rb}),l:R(R({},qt),{},{top:"50%",width:Gt.height,cursor:Lt.l}),r:R(R({},qt),{},{left:"100%",top:"50%",width:Gt.width,cursor:Lt.r}),t:R(R({},qt),{},{left:"50%",height:Gt.height,cursor:Lt.t}),b:R(R({},qt),{},{left:"50%",top:"100%",height:Gt.height,cursor:Lt.b})},Jt={id:"",info:{},startCoord:{x:0,y:0,w:0,h:0}},Kt=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(Jt)),C(e,"resizeEmitter",new y),C(e,"onBaseInfo",(function(t){return e.triggers.onChange("id",(function(){t(e.getBaseInfo())}))})),C(e,"onResizeEvent",(function(t,r){return e.resizeEmitter.addListener(t,r)})),C(e,"getBaseInfo",(function(){return e.triggers.getter(["id","info","handle","startCoord"])})),C(e,"reset",(function(){e.triggers.setter(Jt)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,Dt),k(t)}(),Qt=function(){function t(e){var r;return E(this,t),C(r=x(this,t,[e]),"setBaseInfo",(function(t){r.triggers.setter(t)})),C(r,"emitResize",(function(t,e){r.resizeEmitter.emit(t,e)})),r.init(),r}return z(t,Kt),k(t,[{key:"init",value:function(){var t=this;this.baseCore.onStatus((function(e){"free"===e&&t.reset()}))}}])}(),Vt=function(){var t=rt().resizeCore;return{reset:t.reset,descroy:t.descroy,getBaseInfo:t.getBaseInfo,onBaseInfo:t.onBaseInfo,emitResize:t.emitResize,onResizeEvent:t.onResizeEvent,setBaseInfo:t.setBaseInfo}},te=function(){var t=Vt().onBaseInfo,e=X(c({}),2),r=e[0],n=e[1];return s((function(){return t(n)}),[]),r},ee=function(t){var r=t.id,n=t.onResizing,o=t.onResized,i=ot().addUser,u=Vt(),a=u.setBaseInfo,c=u.onResizeEvent,f=te(),l=f.id,d=f.handle,g=f.startCoord,p=zt(t.domRef),v=l===r,y=e((function(t){var e,n,o;i("resize");var u=(null==p||null===(e=p.current)||void 0===e?void 0:e.getBoundingClientRect())||{width:0,height:0},c=u.width,s=u.height;a({id:r,startCoord:{x:(null===(n=p.current)||void 0===n?void 0:n.offsetLeft)||0,y:(null===(o=p.current)||void 0===o?void 0:o.offsetTop)||0,w:c,h:s},info:{},handle:t})}));return s((function(){c(r,y)}),[]),It((function(t){if("free"!==t.status){var e=function(t,e,r){var n=R({},t),o=n.h,i=n.w,u=n.x,a=n.y,c=e.spaceX,s=e.spaceY;switch(r){case"lt":n.x=u+c,n.y=a+s,n.w=i-c,n.h=o-s;break;case"rt":n.x=u,n.y=a+s,n.w=i+c,n.h=o-s;break;case"lb":n.x=u+c,n.y=a,n.w=i-c,n.h=o+s;break;case"rb":n.x=u,n.y=a,n.w=i+c,n.h=o+s;break;case"l":n.x=u+c,n.y=a,n.w=i-c,n.h=o;break;case"r":n.x=u,n.y=a,n.w=i+c,n.h=o;break;case"b":n.x=u,n.y=a,n.w=i,n.h=o+s;break;case"t":n.x=u,n.y=a+s,n.w=i,n.h=o-s}return n}(g,t,d);null==n||n(e),"end"===t.status&&(null==o||o(e))}}),v&&!!n),[{isResizing:v},{}]},re=["children","style","pure","className"],ne=function(t){var e=t.children,r=t.style,n=t.pure,o=t.className,i=T(t,re);return X(ee(i),1),n?D(Wt,{id:i.id}):O("div",{style:R({position:"relative"},r),className:o,children:[D(Wt,{id:i.id}),e]})};function oe(t,e,r){return(e=ce(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ie(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function ue(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ie(Object(r),!0).forEach((function(e){oe(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ie(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ae(t,e){return ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},ae(t,e)}function ce(t){var e=function(t){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:e+""}function se(){se=function(t,e){return new r(t,void 0,e)};var t=RegExp.prototype,e=new WeakMap;function r(t,n,o){var i=RegExp(t,n);return e.set(i,o||e.get(t)),ae(i,r.prototype)}function n(t,r){var n=e.get(r);return Object.keys(n).reduce((function(e,r){var o=n[r];if("number"==typeof o)e[r]=t[o];else{for(var i=0;void 0===t[o[i]]&&i+1<o.length;)i++;e[r]=t[o[i]]}return e}),Object.create(null))}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&ae(t,e)}(r,RegExp),r.prototype.exec=function(e){var r=t.exec.call(this,e);if(r){r.groups=n(r,this);var o=r.indices;o&&(o.groups=n(o,this))}return r},r.prototype[Symbol.replace]=function(r,o){if("string"==typeof o){var i=e.get(this);return t[Symbol.replace].call(this,r,o.replace(/\$<([^>]+)>/g,(function(t,e){var r=i[e];return"$"+(Array.isArray(r)?r.join("$"):r)})))}if("function"==typeof o){var u=this;return t[Symbol.replace].call(this,r,(function(){var t=arguments;return"object"!=typeof t[t.length-1]&&(t=[].slice.call(t)).push(n(t,u)),o.apply(this,t)}))}return t[Symbol.replace].call(this,r,o)},se.apply(this,arguments)}var fe=function(t,e){return t.reduce((function(t,r){var n=r[e];return ue(ue({},t),{},oe({},n,r))}),{})};!function(t,e){e&&function(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,ce(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1})}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),oe(this,"handler",[])}),[{key:"use",value:function(t,e){return this.handler.push({fulfilled:t,rejected:e}),this.handler.length-1}},{key:"eject",value:function(t){this.handler[t]&&(this.handler[t]=null)}},{key:"clear",value:function(){this.handler=[]}},{key:"forEach",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];!function(t,e,r){if(r)for(var n=t.length-1;n>=0;n--)e(t[n],n,t);else for(var o=0;o<t.length;o++)e(t[o],o,t)}(this.handler,(function(e){e&&t(e)}),e)}},{key:"run",value:function(t){var e=arguments;return new Promise(function(r,n){var o=e.length>1&&void 0!==e[1]&&e[1],i=Promise.resolve(t());return this.forEach((function(t){i=i.then(t.fulfilled,t.rejected)}),o),r(i)}.bind(this))}}]),se(/\?([^#]*)/,{query:1}),se(/#(.*)/,{hash:1}),se(/^(?:[a-zA-Z][a-zA-Zd+-.]*:)?(?:\/\/(?:[^@/?#]*@)?[^/?#]*)?([^?#]*)/,{pathname:1});var le=["show","dom"],de=function(t){var e=t.show,r=t.dom,n=T(t,le);return e&&r?j.createPortal(D("div",{style:{position:"absolute",inset:0},children:D(Wt,R({},n))}),r):D(w,{})},ge={ids:[],infoMap:{}},pe=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"triggers",h(ge)),C(e,"onSelectIds",(function(t){return e.triggers.onChange("ids",(function(){t(e.getSelectInfo())}))})),C(e,"getSelectInfo",(function(){return e.triggers.getter(["ids","infoMap"])})),C(e,"reset",(function(){e.triggers.setter(ge)})),C(e,"descroy",(function(){e.triggers.destroy()})),e}return z(t,Dt),k(t)}(),ve=function(){function t(){var e;E(this,t);for(var r=arguments.length,n=new Array(r),o=0;o<r;o++)n[o]=arguments[o];return C(e=x(this,t,[].concat(n)),"setSelectIds",(function(t){e.triggers.setter({ids:t})})),e}return z(t,pe),k(t)}(),ye=function(){var t=rt().selectCore,e=t.reset,r=t.setSelectIds,n=t.descroy,o=t.onSelectIds;return{getSelectInfo:t.getSelectInfo,setSelectIds:r,onSelectIds:o,reset:e,descroy:n}},he=function(t){var e,r,n,o,i,u,a=t.id,f=t.domRef,l=(e=ye(),r=e.onSelectIds,n=e.getSelectInfo,o=X(c(n()),2),i=o[0],u=o[1],s((function(){return r((function(t){u(t)}))}),[]),i),d=l.ids,g=l.infoMap[a],p=d.includes(a);return s((function(){yt(null==f?void 0:f.current,lt.select)}),[]),[{isSelect:p,selectInfo:g}]},be=function(t){var e=t.id,r=t.coord,n=t.item,o=t.className,i=t.onResizing,u=t.onOver,a=t.onDroped,c=it().status,s=X(Tt({id:e,renderFake:!0,item:n}),2),f=s[0].isDragging,l=s[1],d=X(he({id:e,domRef:l}),1)[0].isSelect;ee({id:e,onResizing:i,domRef:l}),Xt({id:e,item:n,domRef:l,onOver:u,onDroped:a});var g=p((function(){return{left:r.x,top:r.y,width:r.w,height:r.h,cursor:"move"!==c?"grab":void 0,pointerEvents:f?"none":"unset"}}),[r,c,f]),v=p((function(){return{boxShadow:d?"0 0 4px 1px #0078d4":void 0}}),[d]),y=p((function(){return{contain:d?"layout":void 0}}),[d]);return O(w,{children:[D(de,{show:d&&!f,id:e,dom:l.current}),D(_t,{ref:l,className:o,style:R(R(R(R({},g),v),y),t.style),children:t.children})]})},me=function(t){var e=t.children,r=t.onWillChange,n=X(i(t,[]),2),o=n[0],u=n[1],a=p((function(){return fe(e,"key")}),[e]),c=function(t,e){if(o){var r=Y(o),n=o.findIndex((function(e){return e.i===t}));-1!==n&&(r[n]=R(R({},r[n]),e),null==u||u(r))}};return D($t,{accept:t.accept,className:t.className,style:t.style,onDroped:function(t,e){if(o){var n=Y(o),i=o.findIndex((function(e){return e.i===t})),a=!1,c=R({i:t},e);-1===i&&(a=!0,n.push({}),i=n.length-1),n[i]=c;var s=r?r(n,{addIds:a?[c.i]:[],removeIds:[],changeIds:[c.i]}):n;s&&(null==u||u(s))}},children:null==o?void 0:o.map((function(t){var e=a[t.i];return e?D(be,{style:{position:"absolute",transition:"all 0.2s"},coord:t,id:t.i,onResizing:c.bind(null,t.i),children:e},t.i):D(v,{},t.i)}))})},De=["className","style","children","id","coord","item"],we=function(t){var e=t.className,r=t.style,n=t.children,o=t.id,i=t.coord,u=t.item,a=T(t,De);return D(tt,{value:{id:o,coord:i,item:u},children:D(Ut,R(R({style:r,className:e},a),{},{children:n}))})},Oe=function(t){var e=t.children,r=t.onWillAdd,n=X(i(t,[]),2),o=n[0],u=n[1],a=p((function(){return fe(e,"key")}),[e]),c=function(t,e){if(o){var n=Y(o),i=o.findIndex((function(e){return e.i===t})),a=R({i:t},e);-1===i&&(a.i=r?r(t,e):function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:36,e=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"],r=[],n=0;n<t;n++)r[n]=8===n||13===n||18===n||23===n?"-":e[Math.ceil(Math.random()*e.length-1)];return r.join("")}(),n.push({}),i=n.length-1),n[i]=a,null==u||u(n)}},s=function(t,e){if(o){var r=Y(o),n=o.findIndex((function(e){return e.i===t}));-1!==n&&(r[n]=R(R({},r[n]),e),null==u||u(r))}},f=function(t){if(o){var e=t.getDroppingId(),r=t.getDraggingBaseData(),n=r.dragId,i=r.offset,a=o.findIndex((function(t){return t.i===n}));if(-1!==a){var s=o.findIndex((function(t){return t.i===e}));if(-1!==s){var f=Y(o),l=f[a];f[a]=f[s],f[s]=l,null==u||u(f)}}else null==c||c(n,{x:0,y:0,w:i.w,h:i.h})}};return D($t,{accept:t.accept,className:t.className,style:t.style,onDroped:c,children:null==o?void 0:o.map((function(t){var e=a[t.i];return e?D(be,{coord:t,style:{},id:t.i,onResizing:s.bind(null,t.i),onDroped:f,children:e},t.i):D(v,{},t.i)}))})},je=function(t){var e=t.id,r=t.item,n=t.type;return D(tt,{value:{id:e,item:r,type:n},children:t.children})},Ie=function(){var t=Bt().dragId,e=te(),r=e.handle,n=e.id,o=ot().getData;return s((function(){var e=o().users[0];t&&"dnd"===e?(document.body.style.cursor="grabbing",document.body.style.userSelect="none"):r&&"resize"===e?(document.body.style.cursor=Lt[r],document.body.style.userSelect="none"):(document.body.style.cursor="",document.body.style.userSelect="")}),[t,r,n]),D(w,{})},Se=function(){var t=ot().onDomEvent,e=At().emitDrag;return s((function(){return t("drag",(function(t){var r=t.level,n=r.types,o=r.ids;if(!(n[0]&lt.resize)){var i=n.findIndex((function(t){return t&lt.drag}));if(!(i<0)){var u=o[i];u&&e(u)}}}))}),[]),D(w,{})},xe=function(){var t=Bt(),e=t.dragId,r=t.offset,n=t.renderFake,o=X(c(""),2),i=o[0],u=o[1],a=X(c(!1),2),s=a[0],l=a[1],d=f({timer:null}),g=function(t){var e=t.clientX,n=t.clientY,o=r,i=o.x,a=o.y;u("translate(".concat(e-(i||0),"px, ").concat(n-(a||0),"px)"))},v=function(t){clearTimeout(d.current.timer),g(t),d.current.timer=setTimeout((function(){l(!0),d.current.timer=null}),100)};It((function(t){switch(t.status){case"start":v(t);break;case"end":clearTimeout(d.current.timer),d.current.timer=setTimeout((function(){l(!1),u(""),d.current.timer=null}),100);break;case"move":d.current.timer?g(t):v(t)}}),!!e);var y=p((function(){return W(n)?n():D("div",{style:{width:"100%",height:"100%",backgroundColor:"rgba(0,0,0,0.5)"}})}),[n]);return I(D("div",{style:{position:"fixed",pointerEvents:"none",left:0,top:0,width:0,height:0,zIndex:1e3},children:n?D("div",{style:{display:s&&e?"block":"none",position:"absolute",transition:e?"transform linear 0.1s":"",width:null==r?void 0:r.w,height:null==r?void 0:r.h,transform:i},children:y}):D(w,{})}),document.body)},Ee=function(){var t=Bt().dragId,r=Nt().setDropStack,n=e((function(e){if(t){var n=bt(e.target,lt.drop).ids;r(n.filter(Boolean))}})),o=e((function(){setTimeout((function(){r()}),0)}));return s((function(){if(t)return b(window,{mouseover:n,mouseup:o})}),[!!t]),D(w,{})},ke=function(){var t=ot().onDomEvent,e=Vt().emitResize;return s((function(){return t("down",(function(t){var r=t.level,n=r.types,o=r.ids,i=r.datas;if(n[0]&lt.resize){var u=o[0],a=i[0];e(u,a)}}))}),[]),D(w,{})},Ce=function(){var t=ye(),e=t.setSelectIds,r=t.reset,n=ot().onDomEvent;return s((function(){return n("tap",(function(t){var n=t.level,o=n.types,i=n.ids,u=o.findIndex((function(t){return t&lt.select}));if(u<0)r();else{var a=i[u];a&&e([a])}}))}),[]),D(w,{})},Pe=function(t){var e=u((function(){var t=new jt,e=new Et(t),r=new Pt(t),n=function(t){var e=t.draggingCore,r=t.droppingCore,n=t.baseCore;return{getBaseMoveData:function(){return n.getBaseData()},getDraggingBaseData:function(){return e.getDraggingData()},getDraggingId:function(){return e.triggers.getter("dragId")||""},getDraggingItem:function(){return e.triggers.getter("item")||{}},getDraggingType:function(){return e.triggers.getter("type")||""},getDraggingOffset:function(){return e.triggers.getter("offset")},getDroppingBaseData:function(){return r.getDropData()},getDroppingId:function(){return r.triggers.getter("dropId")},getDroppingAccept:function(){return r.triggers.getter("accept")||[]},getDroppingItem:function(){return r.triggers.getter("item")},getDroppingStack:function(){return r.triggers.getter("stack")}}}({baseCore:t,droppingCore:r,draggingCore:e});return{baseCore:t,selectCore:new ve(t),resizeCore:new Qt(t),dragCore:e,dropCore:r,dndMonitor:n}}));return O(nt,{value:e.current,children:[D(mt,{}),D(Ie,{}),D(ke,{}),D(Se,{}),D(Ce,{}),D(xe,{}),D(Ee,{}),t.children]})};export{je as BoxProviderWrap,me as CoordWrap,Ut as Drag,we as DragBoxWrap,$t as Drop,Oe as PlainWrap,Wt as ReiseHandle,ne as Resize,Qt as ResizeCore,be as TransBox,Pe as TransProviderWrap,ee as useResize,Vt as useResizeCore,te as useResizeInfo};
@@ -1,16 +1,10 @@
1
- import { FC, ReactElement } from 'react';
1
+ import { ReactElement, FC } from 'react';
2
2
  import { ICommonUiProps, IControlProps } from '@cclr/react';
3
3
  import * as _cclr_lang from '@cclr/lang';
4
4
  import { TPlainObject, TPlainFunction } from '@cclr/lang';
5
+ import * as _cclr_trigger from '@cclr/trigger';
5
6
  import * as _cclr_emitter from '@cclr/emitter';
6
7
  import { Emitter } from '@cclr/emitter';
7
- import * as _cclr_trigger from '@cclr/trigger';
8
-
9
- interface IProps$3 {
10
- a?: string;
11
- }
12
- /** 移动盒子 */
13
- declare const Drag: FC<ICommonUiProps & IProps$3>;
14
8
 
15
9
  type TStatus = 'start' | 'move' | 'end' | 'free';
16
10
  interface IStartParams {
@@ -146,6 +140,8 @@ type TDroppingBase = Pick<IDroppingData, 'dropId' | 'item' | 'accept'>;
146
140
  type TRDrag = Required<IDraggingData>;
147
141
  type TRDrop = Required<IDroppingData>;
148
142
  interface IMonitor {
143
+ /** 获取基础的移动信息 */
144
+ getBaseMoveData(): IBaseData;
149
145
  /** 获取拖拽数据 */
150
146
  getDraggingBaseData(): TDraggingBase;
151
147
  /** 获取当前拖动的元素id */
@@ -168,6 +164,46 @@ interface IMonitor {
168
164
  getDroppingStack(): string[];
169
165
  }
170
166
 
167
+ interface IDragMonitor extends IMonitor {
168
+ getDragPos?(): {
169
+ x: number;
170
+ y: number;
171
+ };
172
+ }
173
+
174
+ type TDragOpt<T extends HTMLElement = HTMLElement> = {
175
+ /** 拖动元素唯一id */
176
+ id: string;
177
+ /** 拖动元素的类型 */
178
+ type?: string;
179
+ /** 拖动元素特有的数据 */
180
+ item?: TPlainObject;
181
+ /** 拖动元素的类型 */
182
+ domRef?: React.MutableRefObject<T>;
183
+ /** 拖动开始时触发 */
184
+ onDragStart?: (monitor: IDragMonitor) => void;
185
+ /** 拖动结束时触发 */
186
+ onDragEnd?: (monitor: IDragMonitor) => void;
187
+ /** 拖动时触发 */
188
+ onDrag?: (monitor: IDragMonitor) => void;
189
+ /** 渲染 拖动的替身 */
190
+ renderFake?: boolean | ((monitor: IDragMonitor) => ReactElement);
191
+ /** 进入drop时触发 */
192
+ onDragEnter?: (dropId: string, monitor: IDragMonitor) => void;
193
+ /** 离开drop时触发 */
194
+ onDragLeave?: (dropId: string, monitor: IDragMonitor) => void;
195
+ /** drop时触发 */
196
+ onDrop?: (dropId: string, monitor: IDragMonitor) => void;
197
+ /** 放置时触发 */
198
+ onDroped?: (dropId: string, monitor: IDragMonitor) => void;
199
+ /** 收集 */
200
+ collect?: (monitor: IDragMonitor) => void;
201
+ };
202
+
203
+ type TDragProps = ICommonUiProps & Pick<TDragOpt, 'onDrag' | 'onDragStart' | 'onDragEnd'>;
204
+ /** 移动盒子 */
205
+ declare const Drag: FC<TDragProps>;
206
+
171
207
  interface IDropMonitor extends IMonitor {
172
208
  /** 获取放置的位置 */
173
209
  getDropPos(): {
@@ -219,11 +255,11 @@ type TCoordBase = TPosBase & {
219
255
  h: number;
220
256
  };
221
257
 
222
- type TResizeOpt = {
258
+ type TResizeOpt<T extends HTMLElement = HTMLElement> = {
223
259
  /** 盒子id */
224
260
  id: string;
225
261
  /** 拖动元素的类型 */
226
- domRef?: React.MutableRefObject<any>;
262
+ domRef?: React.MutableRefObject<T>;
227
263
  /** 拖动中 */
228
264
  onResizing?: (coord: TCoordBase) => void;
229
265
  /** 拖动结束 */
@@ -302,12 +338,12 @@ declare const useResizeCore: () => {
302
338
 
303
339
  declare const useResizeInfo: () => TResizeBase;
304
340
 
305
- interface IProps$2 {
341
+ interface IProps$1 {
306
342
  pure?: boolean;
307
343
  }
308
- declare const Resize: FC<ICommonUiProps & IProps$2 & TResizeOpt>;
344
+ declare const Resize: FC<ICommonUiProps & IProps$1 & TResizeOpt>;
309
345
 
310
- interface IPos {
346
+ interface IPos$1 {
311
347
  i: string;
312
348
  x: number;
313
349
  y: number;
@@ -316,40 +352,44 @@ interface IPos {
316
352
  }
317
353
 
318
354
  interface ICoordProps {
319
- onWillAdd?: (i: string, pos: TPlainObject) => string;
355
+ /** 修改之前的拦截 */
356
+ onWillChange?: (list: IPos$1[], opt: {
357
+ addIds: string[];
358
+ removeIds: string[];
359
+ changeIds: string[];
360
+ }) => IPos$1[] | void;
320
361
  showShadow?: boolean;
321
362
  children: ReactElement[];
322
363
  }
323
- declare const CoordWrap: FC<ICommonUiProps & IControlProps<IPos[]> & TDropProps & ICoordProps>;
364
+ declare const CoordWrap: FC<ICommonUiProps & IControlProps<IPos$1[]> & TDropProps & ICoordProps>;
324
365
 
325
366
  type IBoxCtx = {
326
367
  id: string;
327
368
  coord?: TCoordBase;
328
369
  } & Pick<IDraggingData, 'item' | 'type' | 'renderFake'>;
329
370
 
330
- interface IProps$1 {
331
- v?: boolean;
332
- }
333
- declare const DragBoxWrap: FC<ICommonUiProps & IBoxCtx & IProps$1>;
371
+ declare const DragBoxWrap: FC<IBoxCtx & TDragProps>;
334
372
 
335
- interface ISize {
373
+ interface IPos {
336
374
  i: string;
337
375
  w?: number;
338
376
  h?: number;
377
+ x?: number;
378
+ y?: number;
339
379
  }
340
380
 
341
381
  interface IProps {
342
382
  onWillAdd?: (i: string, pos: TPlainObject) => string;
343
383
  showShadow?: boolean;
344
384
  children: ReactElement[];
345
- onChange?: (list: ISize[], option: {
346
- add: string[];
347
- remove: string[];
348
- update: string[];
349
- resize: string[];
350
- }) => void;
385
+ /** 修改之前的拦截 */
386
+ onWillChange?: (list: IPos[], opt: {
387
+ addIds: string[];
388
+ removeIds: string[];
389
+ updateIds: string[];
390
+ }) => IPos[] | void;
351
391
  }
352
- declare const PlainWrap: FC<ICommonUiProps & IControlProps<ISize[]> & TDropProps & IProps>;
392
+ declare const PlainWrap: FC<ICommonUiProps & IControlProps<IPos[]> & TDropProps & IProps>;
353
393
 
354
394
  type TTransBoxProps = Pick<IBoxCtx, 'id' | 'item' | 'type' | 'renderFake'> & ICommonUiProps & Pick<TResizeOpt, 'onResized' | 'onResizing'> & {
355
395
  coord: {
@@ -365,4 +405,4 @@ declare const BoxProviderWrap: FC<Pick<ICommonUiProps, 'children'> & IBoxCtx>;
365
405
 
366
406
  declare const TransProviderWrap: FC<Pick<ICommonUiProps, 'children'> & {}>;
367
407
 
368
- export { BoxProviderWrap, CoordWrap, Drag, DragBoxWrap, Drop, type IPos, type ISize, PlainWrap, ReiseHandle, Resize, ResizeCore, type TDropProps, type TResizeOpt, TransBox, TransProviderWrap, useResize, useResizeCore, useResizeInfo };
408
+ export { BoxProviderWrap, CoordWrap, Drag, DragBoxWrap, Drop, type IPos$1 as IPos, type IPos as ISize, PlainWrap, ReiseHandle, Resize, ResizeCore, type TDragProps, type TDropProps, type TResizeOpt, TransBox, TransProviderWrap, useResize, useResizeCore, useResizeInfo };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cclr/trans",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "> TODO: description",
5
5
  "author": "cclr <18843152354@163.com>",
6
6
  "homepage": "",
@@ -27,16 +27,16 @@
27
27
  "g:test": "vitest run",
28
28
  "g:build": "ccf build"
29
29
  },
30
- "gitHead": "82b59c24ac9b3031e9ce241e4e6c5425643f2bc2",
30
+ "gitHead": "56865ee648e597654303fb82c018c63a30c5baf8",
31
31
  "dependencies": {
32
- "@cclr/emitter": "0.1.21",
33
- "@cclr/front": "0.1.21",
34
- "@cclr/lang": "0.1.21",
35
- "@cclr/model": "0.1.21",
36
- "@cclr/react": "0.1.21",
37
- "@cclr/react-model": "0.1.21",
38
- "@cclr/trigger": "0.1.21",
39
- "@cclr/utils": "0.1.21"
32
+ "@cclr/emitter": "0.1.23",
33
+ "@cclr/front": "0.1.23",
34
+ "@cclr/lang": "0.1.23",
35
+ "@cclr/model": "0.1.23",
36
+ "@cclr/react": "0.1.23",
37
+ "@cclr/react-model": "0.1.23",
38
+ "@cclr/trigger": "0.1.23",
39
+ "@cclr/utils": "0.1.23"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/react": "^18.3.18",