mirror of https://github.com/Mai-with-u/MaiBot.git
6 lines
44 KiB
JavaScript
6 lines
44 KiB
JavaScript
import{r as c,R as P,b as Oe}from"./router-Bz250laD.js";function Rn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>r=>{t.forEach(o=>o(r))},t)}const et=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function me(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function pt(e){return"nodeType"in e}function B(e){var t,n;return e?me(e)?e:pt(e)&&(t=(n=e.ownerDocument)==null?void 0:n.defaultView)!=null?t:window:window}function bt(e){const{Document:t}=B(e);return e instanceof t}function Be(e){return me(e)?!1:e instanceof B(e).HTMLElement}function Ut(e){return e instanceof B(e).SVGElement}function ye(e){return e?me(e)?e.document:pt(e)?bt(e)?e:Be(e)||Ut(e)?e.ownerDocument:document:document:document}const Q=et?c.useLayoutEffect:c.useEffect;function wt(e){const t=c.useRef(e);return Q(()=>{t.current=e}),c.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}function Sn(){const e=c.useRef(null),t=c.useCallback((r,o)=>{e.current=setInterval(r,o)},[]),n=c.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,n]}function ke(e,t){t===void 0&&(t=[e]);const n=c.useRef(e);return Q(()=>{n.current!==e&&(n.current=e)},t),n}function Fe(e,t){const n=c.useRef();return c.useMemo(()=>{const r=e(n.current);return n.current=r,r},[...t])}function Ge(e){const t=wt(e),n=c.useRef(null),r=c.useCallback(o=>{o!==n.current&&t?.(o,n.current),n.current=o},[]);return[n,r]}function dt(e){const t=c.useRef();return c.useEffect(()=>{t.current=e},[e]),t.current}let at={};function $e(e,t){return c.useMemo(()=>{if(t)return t;const n=at[e]==null?0:at[e]+1;return at[e]=n,e+"-"+n},[e,t])}function Wt(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,u]of a){const f=i[l];f!=null&&(i[l]=f+e*u)}return i},{...t})}}const we=Wt(1),ze=Wt(-1);function En(e){return"clientX"in e&&"clientY"in e}function mt(e){if(!e)return!1;const{KeyboardEvent:t}=B(e.target);return t&&e instanceof t}function Mn(e){if(!e)return!1;const{TouchEvent:t}=B(e.target);return t&&e instanceof t}function ft(e){if(Mn(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return En(e)?{x:e.clientX,y:e.clientY}:null}const Je=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:n}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:n}=e;return"scaleX("+t+") scaleY("+n+")"}},Transform:{toString(e){if(e)return[Je.Translate.toString(e),Je.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+" "+n+"ms "+r}}}),Ot="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function In(e){return e.matches(Ot)?e:e.querySelector(Ot)}const An={display:"none"};function On(e){let{id:t,value:n}=e;return P.createElement("div",{id:t,style:An},n)}function Tn(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return P.createElement("div",{id:t,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function Nn(){const[e,t]=c.useState("");return{announce:c.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Ht=c.createContext(null);function Ln(e){const t=c.useContext(Ht);c.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function kn(){const[e]=c.useState(()=>new Set),t=c.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[c.useCallback(r=>{let{type:o,event:i}=r;e.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[e]),t]}const zn={draggable:`
|
|
To pick up a draggable item, press the space bar.
|
|
While dragging, use the arrow keys to move the item.
|
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
`},Pn={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Bn(e){let{announcements:t=Pn,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=zn}=e;const{announce:i,announcement:s}=Nn(),a=$e("DndLiveRegion"),[l,u]=c.useState(!1);if(c.useEffect(()=>{u(!0)},[]),Ln(c.useMemo(()=>({onDragStart(d){let{active:g}=d;i(t.onDragStart({active:g}))},onDragMove(d){let{active:g,over:h}=d;t.onDragMove&&i(t.onDragMove({active:g,over:h}))},onDragOver(d){let{active:g,over:h}=d;i(t.onDragOver({active:g,over:h}))},onDragEnd(d){let{active:g,over:h}=d;i(t.onDragEnd({active:g,over:h}))},onDragCancel(d){let{active:g,over:h}=d;i(t.onDragCancel({active:g,over:h}))}}),[i,t])),!l)return null;const f=P.createElement(P.Fragment,null,P.createElement(On,{id:r,value:o.draggable}),P.createElement(Tn,{id:a,announcement:s}));return n?Oe.createPortal(f,n):f}var O;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(O||(O={}));function _e(){}function io(e,t){return c.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function so(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const V=Object.freeze({x:0,y:0});function Kt(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Vt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Fn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Tt(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function qt(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function Nt(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}const ao=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Nt(t,t.left,t.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const u=Kt(Nt(l),o);i.push({id:a,data:{droppableContainer:s,value:u}})}}return i.sort(Vt)},$n=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Tt(t),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const u=Tt(l),f=o.reduce((g,h,C)=>g+Kt(u[C],h),0),d=Number((f/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(Vt)};function Xn(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),i=Math.min(t.top+t.height,e.top+e.height),s=o-r,a=i-n;if(r<o&&n<i){const l=t.width*t.height,u=e.width*e.height,f=s*a,d=f/(l+u-f);return Number(d.toFixed(4))}return 0}const Yn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=Xn(a,t);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(Fn)};function jn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Gt(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:V}function Un(e){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+e*a.y,bottom:s.bottom+e*a.y,left:s.left+e*a.x,right:s.right+e*a.x}),{...n})}}const Wn=Un(1);function Hn(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Kn(e,t,n){const r=Hn(t);if(!r)return e;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=e.left-s-(1-o)*parseFloat(n),u=e.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),f=o?e.width/o:e.width,d=i?e.height/i:e.height;return{width:f,height:d,top:u,right:l+f,bottom:u+d,left:l}}const Vn={ignoreTransform:!1};function xe(e,t){t===void 0&&(t=Vn);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:f}=B(e).getComputedStyle(e);u&&(n=Kn(n,u,f))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function Lt(e){return xe(e,{ignoreTransform:!0})}function qn(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Gn(e,t){return t===void 0&&(t=B(e).getComputedStyle(e)),t.position==="fixed"}function Jn(e,t){t===void 0&&(t=B(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=t[o];return typeof i=="string"?n.test(i):!1})}function tt(e,t){const n=[];function r(o){if(t!=null&&n.length>=t||!o)return n;if(bt(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Be(o)||Ut(o)||n.includes(o))return n;const i=B(e).getComputedStyle(o);return o!==e&&Jn(o,i)&&n.push(o),Gn(o,i)?n:r(o.parentNode)}return e?r(e):n}function Jt(e){const[t]=tt(e,1);return t??null}function ct(e){return!et||!e?null:me(e)?e:pt(e)?bt(e)||e===ye(e).scrollingElement?window:Be(e)?e:null:null}function _t(e){return me(e)?e.scrollX:e.scrollLeft}function Qt(e){return me(e)?e.scrollY:e.scrollTop}function ht(e){return{x:_t(e),y:Qt(e)}}var N;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(N||(N={}));function Zt(e){return!et||!e?!1:e===document.scrollingElement}function en(e){const t={x:0,y:0},n=Zt(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},o=e.scrollTop<=t.y,i=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const _n={x:.2,y:.2};function Qn(e,t,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=_n);const{isTop:u,isBottom:f,isLeft:d,isRight:g}=en(e),h={x:0,y:0},C={x:0,y:0},v={height:t.height*o.y,width:t.width*o.x};return!u&&i<=t.top+v.height?(h.y=N.Backward,C.y=r*Math.abs((t.top+v.height-i)/v.height)):!f&&l>=t.bottom-v.height&&(h.y=N.Forward,C.y=r*Math.abs((t.bottom-v.height-l)/v.height)),!g&&a>=t.right-v.width?(h.x=N.Forward,C.x=r*Math.abs((t.right-v.width-a)/v.width)):!d&&s<=t.left+v.width&&(h.x=N.Backward,C.x=r*Math.abs((t.left+v.width-s)/v.width)),{direction:h,speed:C}}function Zn(e){if(e===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:t,left:n,right:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function tn(e){return e.reduce((t,n)=>we(t,ht(n)),V)}function er(e){return e.reduce((t,n)=>t+_t(n),0)}function tr(e){return e.reduce((t,n)=>t+Qt(n),0)}function nr(e,t){if(t===void 0&&(t=xe),!e)return;const{top:n,left:r,bottom:o,right:i}=t(e);Jt(e)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const rr=[["x",["left","right"],er],["y",["top","bottom"],tr]];class yt{constructor(t,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=tt(n),o=tn(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[i,s,a]of rr)for(const l of s)Object.defineProperty(this,l,{get:()=>{const u=a(r),f=o[i]-u;return this.rect[l]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Te{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=t}add(t,n,r){var o;(o=this.target)==null||o.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function or(e){const{EventTarget:t}=B(e);return e instanceof t?e:ye(e)}function lt(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t?r>t.y:!1}var W;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(W||(W={}));function kt(e){e.preventDefault()}function ir(e){e.stopPropagation()}var w;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(w||(w={}));const nn={start:[w.Space,w.Enter],cancel:[w.Esc],end:[w.Space,w.Enter,w.Tab]},sr=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case w.Right:return{...n,x:n.x+25};case w.Left:return{...n,x:n.x-25};case w.Down:return{...n,y:n.y+25};case w.Up:return{...n,y:n.y-25}}};class rn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:n}}=t;this.props=t,this.listeners=new Te(ye(n)),this.windowListeners=new Te(B(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(W.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&nr(r),n(V)}handleKeyDown(t){if(mt(t)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=nn,coordinateGetter:s=sr,scrollBehavior:a="smooth"}=o,{code:l}=t;if(i.end.includes(l)){this.handleEnd(t);return}if(i.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:u}=r.current,f=u?{x:u.left,y:u.top}:V;this.referenceCoordinates||(this.referenceCoordinates=f);const d=s(t,{active:n,context:r.current,currentCoordinates:f});if(d){const g=ze(d,f),h={x:0,y:0},{scrollableAncestors:C}=r.current;for(const v of C){const p=t.code,{isTop:m,isRight:y,isLeft:b,isBottom:R,maxScroll:S,minScroll:E}=en(v),x=Zn(v),D={x:Math.min(p===w.Right?x.right-x.width/2:x.right,Math.max(p===w.Right?x.left:x.left+x.width/2,d.x)),y:Math.min(p===w.Down?x.bottom-x.height/2:x.bottom,Math.max(p===w.Down?x.top:x.top+x.height/2,d.y))},A=p===w.Right&&!y||p===w.Left&&!b,T=p===w.Down&&!R||p===w.Up&&!m;if(A&&D.x!==d.x){const I=v.scrollLeft+g.x,H=p===w.Right&&I<=S.x||p===w.Left&&I>=E.x;if(H&&!g.y){v.scrollTo({left:I,behavior:a});return}H?h.x=v.scrollLeft-I:h.x=p===w.Right?v.scrollLeft-S.x:v.scrollLeft-E.x,h.x&&v.scrollBy({left:-h.x,behavior:a});break}else if(T&&D.y!==d.y){const I=v.scrollTop+g.y,H=p===w.Down&&I<=S.y||p===w.Up&&I>=E.y;if(H&&!g.x){v.scrollTo({top:I,behavior:a});return}H?h.y=v.scrollTop-I:h.y=p===w.Down?v.scrollTop-S.y:v.scrollTop-E.y,h.y&&v.scrollBy({top:-h.y,behavior:a});break}}this.handleMove(t,we(ze(d,this.referenceCoordinates),h))}}}handleMove(t,n){const{onMove:r}=this.props;t.preventDefault(),r(n)}handleEnd(t){const{onEnd:n}=this.props;t.preventDefault(),this.detach(),n()}handleCancel(t){const{onCancel:n}=this.props;t.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}rn.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=nn,onActivation:o}=t,{active:i}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),o?.({event:e.nativeEvent}),!0)}return!1}}];function zt(e){return!!(e&&"distance"in e)}function Pt(e){return!!(e&&"delay"in e)}class xt{constructor(t,n,r){var o;r===void 0&&(r=or(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=n;const{event:i}=t,{target:s}=i;this.props=t,this.events=n,this.document=ye(s),this.documentListeners=new Te(this.document),this.listeners=new Te(r),this.windowListeners=new Te(B(s)),this.initialCoordinates=(o=ft(i))!=null?o:V,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(W.Resize,this.handleCancel),this.windowListeners.add(W.DragStart,kt),this.windowListeners.add(W.VisibilityChange,this.handleCancel),this.windowListeners.add(W.ContextMenu,kt),this.documentListeners.add(W.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Pt(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(zt(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,n){const{active:r,onPending:o}=this.props;o(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(W.Click,ir,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(W.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=ft(t))!=null?n:V,u=ze(o,l);if(!r&&a){if(zt(a)){if(a.tolerance!=null&<(u,a.tolerance))return this.handleCancel();if(lt(u,a.distance))return this.handleStart()}if(Pt(a)&<(u,a.tolerance))return this.handleCancel();this.handlePending(a,u);return}t.cancelable&&t.preventDefault(),s(l)}handleEnd(){const{onAbort:t,onEnd:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleCancel(){const{onAbort:t,onCancel:n}=this.props;this.detach(),this.activated||t(this.props.active),n()}handleKeydown(t){t.code===w.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const ar={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class on extends xt{constructor(t){const{event:n}=t,r=ye(n.target);super(t,ar,r)}}on.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];const cr={move:{name:"mousemove"},end:{name:"mouseup"}};var gt;(function(e){e[e.RightClick=2]="RightClick"})(gt||(gt={}));class lr extends xt{constructor(t){super(t,cr,ye(t.event.target))}}lr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===gt.RightClick?!1:(r?.({event:n}),!0)}}];const ut={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class ur extends xt{constructor(t){super(t,ut)}static setup(){return window.addEventListener(ut.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ut.move.name,t)};function t(){}}}ur.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return o.length>1?!1:(r?.({event:n}),!0)}}];var Ne;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ne||(Ne={}));var Qe;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(Qe||(Qe={}));function dr(e){let{acceleration:t,activator:n=Ne.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Qe.TreeOrder,pointerCoordinates:l,scrollableAncestors:u,scrollableAncestorRects:f,delta:d,threshold:g}=e;const h=hr({delta:d,disabled:!i}),[C,v]=Sn(),p=c.useRef({x:0,y:0}),m=c.useRef({x:0,y:0}),y=c.useMemo(()=>{switch(n){case Ne.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Ne.DraggableRect:return o}},[n,o,l]),b=c.useRef(null),R=c.useCallback(()=>{const E=b.current;if(!E)return;const x=p.current.x*m.current.x,D=p.current.y*m.current.y;E.scrollBy(x,D)},[]),S=c.useMemo(()=>a===Qe.TreeOrder?[...u].reverse():u,[a,u]);c.useEffect(()=>{if(!i||!u.length||!y){v();return}for(const E of S){if(r?.(E)===!1)continue;const x=u.indexOf(E),D=f[x];if(!D)continue;const{direction:A,speed:T}=Qn(E,D,y,t,g);for(const I of["x","y"])h[I][A[I]]||(T[I]=0,A[I]=0);if(T.x>0||T.y>0){v(),b.current=E,C(R,s),p.current=T,m.current=A;return}}p.current={x:0,y:0},m.current={x:0,y:0},v()},[t,R,r,v,i,s,JSON.stringify(y),JSON.stringify(h),C,u,S,f,JSON.stringify(g)])}const fr={x:{[N.Backward]:!1,[N.Forward]:!1},y:{[N.Backward]:!1,[N.Forward]:!1}};function hr(e){let{delta:t,disabled:n}=e;const r=dt(t);return Fe(o=>{if(n||!r||!o)return fr;const i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[N.Backward]:o.x[N.Backward]||i.x===-1,[N.Forward]:o.x[N.Forward]||i.x===1},y:{[N.Backward]:o.y[N.Backward]||i.y===-1,[N.Forward]:o.y[N.Forward]||i.y===1}}},[n,t,r])}function gr(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return Fe(o=>{var i;return t==null?null:(i=r??o)!=null?i:null},[r,t])}function vr(e,t){return c.useMemo(()=>e.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...i]},[]),[e,t])}var Pe;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Pe||(Pe={}));var vt;(function(e){e.Optimized="optimized"})(vt||(vt={}));const Bt=new Map;function pr(e,t){let{dragging:n,dependencies:r,config:o}=t;const[i,s]=c.useState(null),{frequency:a,measure:l,strategy:u}=o,f=c.useRef(e),d=p(),g=ke(d),h=c.useCallback(function(m){m===void 0&&(m=[]),!g.current&&s(y=>y===null?m:y.concat(m.filter(b=>!y.includes(b))))},[g]),C=c.useRef(null),v=Fe(m=>{if(d&&!n)return Bt;if(!m||m===Bt||f.current!==e||i!=null){const y=new Map;for(let b of e){if(!b)continue;if(i&&i.length>0&&!i.includes(b.id)&&b.rect.current){y.set(b.id,b.rect.current);continue}const R=b.node.current,S=R?new yt(l(R),R):null;b.rect.current=S,S&&y.set(b.id,S)}return y}return m},[e,i,n,d,l]);return c.useEffect(()=>{f.current=e},[e]),c.useEffect(()=>{d||h()},[n,d]),c.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),c.useEffect(()=>{d||typeof a!="number"||C.current!==null||(C.current=setTimeout(()=>{h(),C.current=null},a))},[a,d,h,...r]),{droppableRects:v,measureDroppableContainers:h,measuringScheduled:i!=null};function p(){switch(u){case Pe.Always:return!1;case Pe.BeforeDragging:return n;default:return!n}}}function sn(e,t){return Fe(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function br(e,t){return sn(e,t)}function wr(e){let{callback:t,disabled:n}=e;const r=wt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function nt(e){let{callback:t,disabled:n}=e;const r=wt(t),o=c.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return c.useEffect(()=>()=>o?.disconnect(),[o]),o}function mr(e){return new yt(xe(e),e)}function Ft(e,t,n){t===void 0&&(t=mr);const[r,o]=c.useState(null);function i(){o(l=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=l??n)!=null?u:null}const f=t(e);return JSON.stringify(l)===JSON.stringify(f)?l:f})}const s=wr({callback(l){if(e)for(const u of l){const{type:f,target:d}=u;if(f==="childList"&&d instanceof HTMLElement&&d.contains(e)){i();break}}}}),a=nt({callback:i});return Q(()=>{i(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function yr(e){const t=sn(e);return Gt(e,t)}const $t=[];function xr(e){const t=c.useRef(e),n=Fe(r=>e?r&&r!==$t&&e&&t.current&&e.parentNode===t.current.parentNode?r:tt(e):$t,[e]);return c.useEffect(()=>{t.current=e},[e]),n}function Dr(e){const[t,n]=c.useState(null),r=c.useRef(e),o=c.useCallback(i=>{const s=ct(i.target);s&&n(a=>a?(a.set(s,ht(s)),new Map(a)):null)},[]);return c.useEffect(()=>{const i=r.current;if(e!==i){s(i);const a=e.map(l=>{const u=ct(l);return u?(u.addEventListener("scroll",o,{passive:!0}),[u,ht(u)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(i)};function s(a){a.forEach(l=>{const u=ct(l);u?.removeEventListener("scroll",o)})}},[o,e]),c.useMemo(()=>e.length?t?Array.from(t.values()).reduce((i,s)=>we(i,s),V):tn(e):V,[e,t])}function Xt(e,t){t===void 0&&(t=[]);const n=c.useRef(null);return c.useEffect(()=>{n.current=null},t),c.useEffect(()=>{const r=e!==V;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?ze(e,n.current):V}function Cr(e){c.useEffect(()=>{if(!et)return;const t=e.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of t)n?.()}},e.map(t=>{let{sensor:n}=t;return n}))}function Rr(e,t){return c.useMemo(()=>e.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,t)},n},{}),[e,t])}function an(e){return c.useMemo(()=>e?qn(e):null,[e])}const Yt=[];function Sr(e,t){t===void 0&&(t=xe);const[n]=e,r=an(n?B(n):null),[o,i]=c.useState(Yt);function s(){i(()=>e.length?e.map(l=>Zt(l)?r:new yt(t(l),l)):Yt)}const a=nt({callback:s});return Q(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),o}function Er(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Be(t)?t:e}function Mr(e){let{measure:t}=e;const[n,r]=c.useState(null),o=c.useCallback(u=>{for(const{target:f}of u)if(Be(f)){r(d=>{const g=t(f);return d?{...d,width:g.width,height:g.height}:g});break}},[t]),i=nt({callback:o}),s=c.useCallback(u=>{const f=Er(u);i?.disconnect(),f&&i?.observe(f),r(f?t(f):null)},[t,i]),[a,l]=Ge(s);return c.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Ir=[{sensor:on,options:{}},{sensor:rn,options:{}}],Ar={current:{}},qe={draggable:{measure:Lt},droppable:{measure:Lt,strategy:Pe.WhileDragging,frequency:vt.Optimized},dragOverlay:{measure:xe}};class Le extends Map{get(t){var n;return t!=null&&(n=super.get(t))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:n}=t;return!n})}getNodeFor(t){var n,r;return(n=(r=this.get(t))==null?void 0:r.node.current)!=null?n:void 0}}const Or={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Le,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_e},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:qe,measureDroppableContainers:_e,windowRect:null,measuringScheduled:!1},Tr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_e,draggableNodes:new Map,over:null,measureDroppableContainers:_e},rt=c.createContext(Tr),cn=c.createContext(Or);function Nr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Le}}}function Lr(e,t){switch(t.type){case O.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case O.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case O.DragEnd:case O.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case O.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Le(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case O.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const s=new Le(e.droppable.containers);return s.set(n,{...i,disabled:o}),{...e,droppable:{...e.droppable,containers:s}}}case O.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const i=new Le(e.droppable.containers);return i.delete(n),{...e,droppable:{...e.droppable,containers:i}}}default:return e}}function kr(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=c.useContext(rt),i=dt(r),s=dt(n?.id);return c.useEffect(()=>{if(!t&&!r&&i&&s!=null){if(!mt(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:u}=a;if(!l.current&&!u.current)return;requestAnimationFrame(()=>{for(const f of[l.current,u.current]){if(!f)continue;const d=In(f);if(d){d.focus();break}}})}},[r,t,o,s,i]),null}function zr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((o,i)=>i({transform:o,...r}),n):n}function Pr(e){return c.useMemo(()=>({draggable:{...qe.draggable,...e?.draggable},droppable:{...qe.droppable,...e?.droppable},dragOverlay:{...qe.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Br(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const i=c.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Q(()=>{if(!s&&!a||!t){i.current=!1;return}if(i.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const f=n(u),d=Gt(f,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const g=Jt(u);g&&g.scrollBy({top:d.y,left:d.x})}},[t,s,a,r,n])}const ln=c.createContext({...V,scaleX:1,scaleY:1});var ue;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ue||(ue={}));const co=c.memo(function(t){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:u,sensors:f=Ir,collisionDetection:d=Yn,measuring:g,modifiers:h,...C}=t;const v=c.useReducer(Lr,void 0,Nr),[p,m]=v,[y,b]=kn(),[R,S]=c.useState(ue.Uninitialized),E=R===ue.Initialized,{draggable:{active:x,nodes:D,translate:A},droppable:{containers:T}}=p,I=x!=null?D.get(x):null,H=c.useRef({initial:null,translated:null}),K=c.useMemo(()=>{var k;return x!=null?{id:x,data:(k=I?.data)!=null?k:Ar,rect:H}:null},[x,I]),q=c.useRef(null),[De,Xe]=c.useState(null),[F,Ye]=c.useState(null),Z=ke(C,Object.values(C)),Ce=$e("DndDescribedBy",s),je=c.useMemo(()=>T.getEnabled(),[T]),z=Pr(g),{droppableRects:ee,measureDroppableContainers:de,measuringScheduled:Re}=pr(je,{dragging:E,dependencies:[A.x,A.y],config:z.droppable}),j=gr(D,x),Ue=c.useMemo(()=>F?ft(F):null,[F]),oe=Cn(),te=br(j,z.draggable.measure);Br({activeNode:x!=null?D.get(x):null,config:oe.layoutShiftCompensation,initialRect:te,measure:z.draggable.measure});const M=Ft(j,z.draggable.measure,te),Se=Ft(j?j.parentElement:null),G=c.useRef({activatorEvent:null,active:null,activeNode:j,collisionRect:null,collisions:null,droppableRects:ee,draggableNodes:D,draggingNode:null,draggingNodeRect:null,droppableContainers:T,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),fe=T.getNodeFor((n=G.current.over)==null?void 0:n.id),ne=Mr({measure:z.dragOverlay.measure}),he=(r=ne.nodeRef.current)!=null?r:j,ge=E?(o=ne.rect)!=null?o:M:null,Dt=!!(ne.nodeRef.current&&ne.rect),Ct=yr(Dt?null:M),ot=an(he?B(he):null),ie=xr(E?fe??j:null),We=Sr(ie),He=zr(h,{transform:{x:A.x-Ct.x,y:A.y-Ct.y,scaleX:1,scaleY:1},activatorEvent:F,active:K,activeNodeRect:M,containerNodeRect:Se,draggingNodeRect:ge,over:G.current.over,overlayNodeRect:ne.rect,scrollableAncestors:ie,scrollableAncestorRects:We,windowRect:ot}),Rt=Ue?we(Ue,A):null,St=Dr(ie),pn=Xt(St),bn=Xt(St,[M]),ve=we(He,pn),pe=ge?Wn(ge,He):null,Ee=K&&pe?d({active:K,collisionRect:pe,droppableRects:ee,droppableContainers:je,pointerCoordinates:Rt}):null,Et=qt(Ee,"id"),[se,Mt]=c.useState(null),wn=Dt?He:we(He,bn),mn=jn(wn,(i=se?.rect)!=null?i:null,M),it=c.useRef(null),It=c.useCallback((k,$)=>{let{sensor:X,options:ae}=$;if(q.current==null)return;const U=D.get(q.current);if(!U)return;const Y=k.nativeEvent,J=new X({active:q.current,activeNode:U,event:Y,options:ae,context:G,onAbort(L){if(!D.get(L))return;const{onDragAbort:_}=Z.current,re={id:L};_?.(re),y({type:"onDragAbort",event:re})},onPending(L,ce,_,re){if(!D.get(L))return;const{onDragPending:Ie}=Z.current,le={id:L,constraint:ce,initialCoordinates:_,offset:re};Ie?.(le),y({type:"onDragPending",event:le})},onStart(L){const ce=q.current;if(ce==null)return;const _=D.get(ce);if(!_)return;const{onDragStart:re}=Z.current,Me={activatorEvent:Y,active:{id:ce,data:_.data,rect:H}};Oe.unstable_batchedUpdates(()=>{re?.(Me),S(ue.Initializing),m({type:O.DragStart,initialCoordinates:L,active:ce}),y({type:"onDragStart",event:Me}),Xe(it.current),Ye(Y)})},onMove(L){m({type:O.DragMove,coordinates:L})},onEnd:be(O.DragEnd),onCancel:be(O.DragCancel)});it.current=J;function be(L){return async function(){const{active:_,collisions:re,over:Me,scrollAdjustedTranslate:Ie}=G.current;let le=null;if(_&&Ie){const{cancelDrop:Ae}=Z.current;le={activatorEvent:Y,active:_,collisions:re,delta:Ie,over:Me},L===O.DragEnd&&typeof Ae=="function"&&await Promise.resolve(Ae(le))&&(L=O.DragCancel)}q.current=null,Oe.unstable_batchedUpdates(()=>{m({type:L}),S(ue.Uninitialized),Mt(null),Xe(null),Ye(null),it.current=null;const Ae=L===O.DragEnd?"onDragEnd":"onDragCancel";if(le){const st=Z.current[Ae];st?.(le),y({type:Ae,event:le})}})}}},[D]),yn=c.useCallback((k,$)=>(X,ae)=>{const U=X.nativeEvent,Y=D.get(ae);if(q.current!==null||!Y||U.dndKit||U.defaultPrevented)return;const J={active:Y};k(X,$.options,J)===!0&&(U.dndKit={capturedBy:$.sensor},q.current=ae,It(X,$))},[D,It]),At=vr(f,yn);Cr(f),Q(()=>{M&&R===ue.Initializing&&S(ue.Initialized)},[M,R]),c.useEffect(()=>{const{onDragMove:k}=Z.current,{active:$,activatorEvent:X,collisions:ae,over:U}=G.current;if(!$||!X)return;const Y={active:$,activatorEvent:X,collisions:ae,delta:{x:ve.x,y:ve.y},over:U};Oe.unstable_batchedUpdates(()=>{k?.(Y),y({type:"onDragMove",event:Y})})},[ve.x,ve.y]),c.useEffect(()=>{const{active:k,activatorEvent:$,collisions:X,droppableContainers:ae,scrollAdjustedTranslate:U}=G.current;if(!k||q.current==null||!$||!U)return;const{onDragOver:Y}=Z.current,J=ae.get(Et),be=J&&J.rect.current?{id:J.id,rect:J.rect.current,data:J.data,disabled:J.disabled}:null,L={active:k,activatorEvent:$,collisions:X,delta:{x:U.x,y:U.y},over:be};Oe.unstable_batchedUpdates(()=>{Mt(be),Y?.(L),y({type:"onDragOver",event:L})})},[Et]),Q(()=>{G.current={activatorEvent:F,active:K,activeNode:j,collisionRect:pe,collisions:Ee,droppableRects:ee,draggableNodes:D,draggingNode:he,draggingNodeRect:ge,droppableContainers:T,over:se,scrollableAncestors:ie,scrollAdjustedTranslate:ve},H.current={initial:ge,translated:pe}},[K,j,Ee,pe,D,he,ge,ee,T,se,ie,ve]),dr({...oe,delta:A,draggingRect:pe,pointerCoordinates:Rt,scrollableAncestors:ie,scrollableAncestorRects:We});const xn=c.useMemo(()=>({active:K,activeNode:j,activeNodeRect:M,activatorEvent:F,collisions:Ee,containerNodeRect:Se,dragOverlay:ne,draggableNodes:D,droppableContainers:T,droppableRects:ee,over:se,measureDroppableContainers:de,scrollableAncestors:ie,scrollableAncestorRects:We,measuringConfiguration:z,measuringScheduled:Re,windowRect:ot}),[K,j,M,F,Ee,Se,ne,D,T,ee,se,de,ie,We,z,Re,ot]),Dn=c.useMemo(()=>({activatorEvent:F,activators:At,active:K,activeNodeRect:M,ariaDescribedById:{draggable:Ce},dispatch:m,draggableNodes:D,over:se,measureDroppableContainers:de}),[F,At,K,M,m,Ce,D,se,de]);return P.createElement(Ht.Provider,{value:b},P.createElement(rt.Provider,{value:Dn},P.createElement(cn.Provider,{value:xn},P.createElement(ln.Provider,{value:mn},u)),P.createElement(kr,{disabled:a?.restoreFocus===!1})),P.createElement(Bn,{...a,hiddenTextDescribedById:Ce}));function Cn(){const k=De?.autoScrollEnabled===!1,$=typeof l=="object"?l.enabled===!1:l===!1,X=E&&!k&&!$;return typeof l=="object"?{...l,enabled:X}:{enabled:X}}}),Fr=c.createContext(null),jt="button",$r="Draggable";function Xr(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const i=$e($r),{activators:s,activatorEvent:a,active:l,activeNodeRect:u,ariaDescribedById:f,draggableNodes:d,over:g}=c.useContext(rt),{role:h=jt,roleDescription:C="draggable",tabIndex:v=0}=o??{},p=l?.id===t,m=c.useContext(p?ln:Fr),[y,b]=Ge(),[R,S]=Ge(),E=Rr(s,t),x=ke(n);Q(()=>(d.set(t,{id:t,key:i,node:y,activatorNode:R,data:x}),()=>{const A=d.get(t);A&&A.key===i&&d.delete(t)}),[d,t]);const D=c.useMemo(()=>({role:h,tabIndex:v,"aria-disabled":r,"aria-pressed":p&&h===jt?!0:void 0,"aria-roledescription":C,"aria-describedby":f.draggable}),[r,h,v,p,C,f.draggable]);return{active:l,activatorEvent:a,activeNodeRect:u,attributes:D,isDragging:p,listeners:r?void 0:E,node:y,over:g,setNodeRef:b,setActivatorNodeRef:S,transform:m}}function Yr(){return c.useContext(cn)}const jr="Droppable",Ur={timeout:25};function Wr(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const i=$e(jr),{active:s,dispatch:a,over:l,measureDroppableContainers:u}=c.useContext(rt),f=c.useRef({disabled:n}),d=c.useRef(!1),g=c.useRef(null),h=c.useRef(null),{disabled:C,updateMeasurementsFor:v,timeout:p}={...Ur,...o},m=ke(v??r),y=c.useCallback(()=>{if(!d.current){d.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),h.current=null},p)},[p]),b=nt({callback:y,disabled:C||!s}),R=c.useCallback((D,A)=>{b&&(A&&(b.unobserve(A),d.current=!1),D&&b.observe(D))},[b]),[S,E]=Ge(R),x=ke(t);return c.useEffect(()=>{!b||!S.current||(b.disconnect(),d.current=!1,b.observe(S.current))},[S,b]),c.useEffect(()=>(a({type:O.RegisterDroppable,element:{id:r,key:i,disabled:n,node:S,rect:g,data:x}}),()=>a({type:O.UnregisterDroppable,key:i,id:r})),[r]),c.useEffect(()=>{n!==f.current.disabled&&(a({type:O.SetDroppableDisabled,id:r,key:i,disabled:n}),f.current.disabled=n)},[r,i,n,a]),{active:s,rect:g,isOver:l?.id===r,node:S,over:l,setNodeRef:E}}function un(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function Hr(e,t){return e.reduce((n,r,o)=>{const i=t.get(r);return i&&(n[o]=i),n},Array(e.length))}function Ke(e){return e!==null&&e>=0}function Kr(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Vr(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Ve={scaleX:1,scaleY:1},lo=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:i,index:s}=e;const a=(t=n[o])!=null?t:r;if(!a)return null;const l=qr(n,s,o);if(s===o){const u=n[i];return u?{x:o<i?u.left+u.width-(a.left+a.width):u.left-a.left,y:0,...Ve}:null}return s>o&&s<=i?{x:-a.width-l,y:0,...Ve}:s<o&&s>=i?{x:a.width+l,y:0,...Ve}:{x:0,y:0,...Ve}};function qr(e,t,n){const r=e[t],o=e[t-1],i=e[t+1];return!r||!o&&!i?0:n<t?o?r.left-(o.left+o.width):i.left-(r.left+r.width):i?i.left-(r.left+r.width):r.left-(o.left+o.width)}const dn=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const i=un(t,r,n),s=t[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},fn="Sortable",hn=P.createContext({activeIndex:-1,containerId:fn,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:dn,disabled:{draggable:!1,droppable:!1}});function uo(e){let{children:t,id:n,items:r,strategy:o=dn,disabled:i=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:u,measureDroppableContainers:f}=Yr(),d=$e(fn,n),g=a.rect!==null,h=c.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),C=s!=null,v=s?h.indexOf(s.id):-1,p=u?h.indexOf(u.id):-1,m=c.useRef(h),y=!Kr(h,m.current),b=p!==-1&&v===-1||y,R=Vr(i);Q(()=>{y&&C&&f(h)},[y,h,C,f]),c.useEffect(()=>{m.current=h},[h]);const S=c.useMemo(()=>({activeIndex:v,containerId:d,disabled:R,disableTransforms:b,items:h,overIndex:p,useDragOverlay:g,sortedRects:Hr(h,l),strategy:o}),[v,d,R.draggable,R.droppable,b,h,p,l,g,o]);return P.createElement(hn.Provider,{value:S},t)}const Gr=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return un(n,r,o).indexOf(t)},Jr=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:u}=e;return!u||!r||a!==i&&o===s?!1:n?!0:s!==o&&t===l},_r={duration:200,easing:"ease"},gn="transform",Qr=Je.Transition.toString({property:gn,duration:0,easing:"linear"}),Zr={roleDescription:"sortable"};function eo(e){let{disabled:t,index:n,node:r,rect:o}=e;const[i,s]=c.useState(null),a=c.useRef(n);return Q(()=>{if(!t&&n!==a.current&&r.current){const l=o.current;if(l){const u=xe(r.current,{ignoreTransform:!0}),f={x:l.left-u.left,y:l.top-u.top,scaleX:l.width/u.width,scaleY:l.height/u.height};(f.x||f.y)&&s(f)}}n!==a.current&&(a.current=n)},[t,n,r,o]),c.useEffect(()=>{i&&s(null)},[i]),i}function fo(e){let{animateLayoutChanges:t=Jr,attributes:n,disabled:r,data:o,getNewIndex:i=Gr,id:s,strategy:a,resizeObserverConfig:l,transition:u=_r}=e;const{items:f,containerId:d,activeIndex:g,disabled:h,disableTransforms:C,sortedRects:v,overIndex:p,useDragOverlay:m,strategy:y}=c.useContext(hn),b=to(r,h),R=f.indexOf(s),S=c.useMemo(()=>({sortable:{containerId:d,index:R,items:f},...o}),[d,o,R,f]),E=c.useMemo(()=>f.slice(f.indexOf(s)),[f,s]),{rect:x,node:D,isOver:A,setNodeRef:T}=Wr({id:s,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:I,activatorEvent:H,activeNodeRect:K,attributes:q,setNodeRef:De,listeners:Xe,isDragging:F,over:Ye,setActivatorNodeRef:Z,transform:Ce}=Xr({id:s,data:S,attributes:{...Zr,...n},disabled:b.draggable}),je=Rn(T,De),z=!!I,ee=z&&!C&&Ke(g)&&Ke(p),de=!m&&F,Re=de&&ee?Ce:null,Ue=ee?Re??(a??y)({rects:v,activeNodeRect:K,activeIndex:g,overIndex:p,index:R}):null,oe=Ke(g)&&Ke(p)?i({id:s,items:f,activeIndex:g,overIndex:p}):R,te=I?.id,M=c.useRef({activeId:te,items:f,newIndex:oe,containerId:d}),Se=f!==M.current.items,G=t({active:I,containerId:d,isDragging:F,isSorting:z,id:s,index:R,items:f,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:u,wasDragging:M.current.activeId!=null}),fe=eo({disabled:!G,index:R,node:D,rect:x});return c.useEffect(()=>{z&&M.current.newIndex!==oe&&(M.current.newIndex=oe),d!==M.current.containerId&&(M.current.containerId=d),f!==M.current.items&&(M.current.items=f)},[z,oe,d,f]),c.useEffect(()=>{if(te===M.current.activeId)return;if(te!=null&&M.current.activeId==null){M.current.activeId=te;return}const he=setTimeout(()=>{M.current.activeId=te},50);return()=>clearTimeout(he)},[te]),{active:I,activeIndex:g,attributes:q,data:S,rect:x,index:R,newIndex:oe,items:f,isOver:A,isSorting:z,isDragging:F,listeners:Xe,node:D,overIndex:p,over:Ye,setNodeRef:je,setActivatorNodeRef:Z,setDroppableNodeRef:T,setDraggableNodeRef:De,transform:fe??Ue,transition:ne()};function ne(){if(fe||Se&&M.current.newIndex===R)return Qr;if(!(de&&!mt(H)||!u)&&(z||G))return Je.Transition.toString({...u,property:gn})}}function to(e,t){var n,r;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(n=e?.draggable)!=null?n:t.draggable,droppable:(r=e?.droppable)!=null?r:t.droppable}}function Ze(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const no=[w.Down,w.Right,w.Up,w.Left],ho=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=t;if(no.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const g=o.get(d.id);if(g)switch(e.code){case w.Down:r.top<g.top&&l.push(d);break;case w.Up:r.top>g.top&&l.push(d);break;case w.Left:r.left>g.left&&l.push(d);break;case w.Right:r.left<g.left&&l.push(d);break}});const u=$n({collisionRect:r,droppableRects:o,droppableContainers:l});let f=qt(u,"id");if(f===s?.id&&u.length>1&&(f=u[1].id),f!=null){const d=i.get(n.id),g=i.get(f),h=g?o.get(g.id):null,C=g?.node.current;if(C&&h&&d&&g){const p=tt(C).some((E,x)=>a[x]!==E),m=vn(d,g),y=ro(d,g),b=p||!m?{x:0,y:0}:{x:y?r.width-h.width:0,y:y?r.height-h.height:0},R={x:h.left,y:h.top};return b.x&&b.y?R:ze(R,b)}}}};function vn(e,t){return!Ze(e)||!Ze(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function ro(e,t){return!Ze(e)||!Ze(t)||!vn(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}export{Je as C,co as D,rn as K,on as P,uo as S,io as a,un as b,ao as c,fo as d,lo as h,ho as s,so as u};
|