@riddix/hamh 4.1.0-testing.23 → 4.1.0-testing.25

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/README.md CHANGED
@@ -454,6 +454,7 @@ Thank you to everyone who helps improve this project by reporting issues!
454
454
  | [@JRCondat](https://github.com/JRCondat) | 💎 Thank you for your generous support! |
455
455
  | Bonjon | 💎 Thank you for your generous support! |
456
456
  | TobiR | 💎 Thank you for your generous support! |
457
+ | [@d3rby91](https://github.com/d3rby91) | 💎 Thank you for your generous support! |
457
458
  | *Anonymous supporters* | 🙏 Thank you to those who prefer not to be named - your support is equally appreciated! |
458
459
 
459
460
  ### 🌟 Original Author
@@ -496,4 +496,4 @@ ${n.comment}`:n.comment}this.doc.range[2]=n.offset;break}default:this.errors.pus
496
496
  To pick up a draggable item, press the space bar.
497
497
  While dragging, use the arrow keys to move the item.
498
498
  Press space again to drop the item in its new position, or press escape to cancel.
499
- `},elt={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 tlt(e){let{announcements:t=elt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Qat}=e;const{announce:o,announcement:s}=Xat(),a=cv("DndLiveRegion"),[l,c]=_.useState(!1);if(_.useEffect(()=>{c(!0)},[]),Zat(_.useMemo(()=>({onDragStart(f){let{active:h}=f;o(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:g}=f;t.onDragMove&&o(t.onDragMove({active:h,over:g}))},onDragOver(f){let{active:h,over:g}=f;o(t.onDragOver({active:h,over:g}))},onDragEnd(f){let{active:h,over:g}=f;o(t.onDragEnd({active:h,over:g}))},onDragCancel(f){let{active:h,over:g}=f;o(t.onDragCancel({active:h,over:g}))}}),[o,t])),!l)return null;const u=qt.createElement(qt.Fragment,null,qt.createElement(Kat,{id:r,value:i.draggable}),qt.createElement(Yat,{id:a,announcement:s}));return n?Td.createPortal(u,n):u}var Li;(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"})(Li||(Li={}));function _S(){}function kK(e,t){return _.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function nlt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const al=Object.freeze({x:0,y:0});function kle(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function _le(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function rlt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function _K(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function Dle(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function DK(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 ilt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=DK(t,t.left,t.top),o=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=kle(DK(l),i);o.push({id:a,data:{droppableContainer:s,value:c}})}}return o.sort(_le)},olt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=_K(t),o=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=_K(l),u=i.reduce((h,g,y)=>h+kle(c[y],g),0),f=Number((u/4).toFixed(4));o.push({id:a,data:{droppableContainer:s,value:f}})}}return o.sort(_le)};function slt(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),s=i-r,a=o-n;if(r<i&&n<o){const l=t.width*t.height,c=e.width*e.height,u=s*a,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const alt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=[];for(const o of r){const{id:s}=o,a=n.get(s);if(a){const l=slt(a,t);l>0&&i.push({id:s,data:{droppableContainer:o,value:l}})}}return i.sort(rlt)};function llt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Ole(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:al}function clt(e){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return i.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 ult=clt(1);function dlt(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 flt(e,t,n){const r=dlt(t);if(!r)return e;const{scaleX:i,scaleY:o,x:s,y:a}=r,l=e.left-s-(1-i)*parseFloat(n),c=e.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?e.width/i:e.width,f=o?e.height/o:e.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const hlt={ignoreTransform:!1};function yg(e,t){t===void 0&&(t=hlt);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=fs(e).getComputedStyle(e);c&&(n=flt(n,c,u))}const{top:r,left:i,width:o,height:s,bottom:a,right:l}=n;return{top:r,left:i,width:o,height:s,bottom:a,right:l}}function OK(e){return yg(e,{ignoreTransform:!0})}function plt(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mlt(e,t){return t===void 0&&(t=fs(e).getComputedStyle(e)),t.position==="fixed"}function glt(e,t){t===void 0&&(t=fs(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const o=t[i];return typeof o=="string"?n.test(o):!1})}function JC(e,t){const n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(SI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!av(i)||Cle(i)||n.includes(i))return n;const o=fs(e).getComputedStyle(i);return i!==e&&glt(i,o)&&n.push(i),mlt(i,o)?n:r(i.parentNode)}return e?r(e):n}function Tle(e){const[t]=JC(e,1);return t??null}function nk(e){return!ZC||!e?null:mg(e)?e:xI(e)?SI(e)||e===gg(e).scrollingElement?window:av(e)?e:null:null}function Mle(e){return mg(e)?e.scrollX:e.scrollLeft}function Rle(e){return mg(e)?e.scrollY:e.scrollTop}function iO(e){return{x:Mle(e),y:Rle(e)}}var Xi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Xi||(Xi={}));function Ile(e){return!ZC||!e?!1:e===document.scrollingElement}function jle(e){const t={x:0,y:0},n=Ile(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},i=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:i,isLeft:o,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const ylt={x:.2,y:.2};function blt(e,t,n,r,i){let{top:o,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=ylt);const{isTop:c,isBottom:u,isLeft:f,isRight:h}=jle(e),g={x:0,y:0},y={x:0,y:0},b={height:t.height*i.y,width:t.width*i.x};return!c&&o<=t.top+b.height?(g.y=Xi.Backward,y.y=r*Math.abs((t.top+b.height-o)/b.height)):!u&&l>=t.bottom-b.height&&(g.y=Xi.Forward,y.y=r*Math.abs((t.bottom-b.height-l)/b.height)),!h&&a>=t.right-b.width?(g.x=Xi.Forward,y.x=r*Math.abs((t.right-b.width-a)/b.width)):!f&&s<=t.left+b.width&&(g.x=Xi.Backward,y.x=r*Math.abs((t.left+b.width-s)/b.width)),{direction:g,speed:y}}function vlt(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:s}=window;return{top:0,left:0,right:o,bottom:s,width:o,height:s}}const{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Ple(e){return e.reduce((t,n)=>rm(t,iO(n)),al)}function xlt(e){return e.reduce((t,n)=>t+Mle(n),0)}function Slt(e){return e.reduce((t,n)=>t+Rle(n),0)}function wlt(e,t){if(t===void 0&&(t=yg),!e)return;const{top:n,left:r,bottom:i,right:o}=t(e);Tle(e)&&(i<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Clt=[["x",["left","right"],xlt],["y",["top","bottom"],Slt]];class EI{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=JC(n),i=Ple(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[o,s,a]of Clt)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=i[o]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ly{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 i;(i=this.target)==null||i.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function Elt(e){const{EventTarget:t}=fs(e);return e instanceof t?e:gg(e)}function rk(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 ta;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ta||(ta={}));function TK(e){e.preventDefault()}function Alt(e){e.stopPropagation()}var Ln;(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"})(Ln||(Ln={}));const $le={start:[Ln.Space,Ln.Enter],cancel:[Ln.Esc],end:[Ln.Space,Ln.Enter,Ln.Tab]},klt=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Ln.Right:return{...n,x:n.x+25};case Ln.Left:return{...n,x:n.x-25};case Ln.Down:return{...n,y:n.y+25};case Ln.Up:return{...n,y:n.y-25}}};class AI{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 Ly(gg(n)),this.windowListeners=new Ly(fs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ta.Resize,this.handleCancel),this.windowListeners.add(ta.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ta.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&wlt(r),n(al)}handleKeyDown(t){if(CI(t)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:o=$le,coordinateGetter:s=klt,scrollBehavior:a="smooth"}=i,{code:l}=t;if(o.end.includes(l)){this.handleEnd(t);return}if(o.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:al;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(t,{active:n,context:r.current,currentCoordinates:u});if(f){const h=sb(f,u),g={x:0,y:0},{scrollableAncestors:y}=r.current;for(const b of y){const v=t.code,{isTop:S,isRight:C,isLeft:w,isBottom:A,maxScroll:E,minScroll:O}=jle(b),D=vlt(b),T={x:Math.min(v===Ln.Right?D.right-D.width/2:D.right,Math.max(v===Ln.Right?D.left:D.left+D.width/2,f.x)),y:Math.min(v===Ln.Down?D.bottom-D.height/2:D.bottom,Math.max(v===Ln.Down?D.top:D.top+D.height/2,f.y))},I=v===Ln.Right&&!C||v===Ln.Left&&!w,N=v===Ln.Down&&!A||v===Ln.Up&&!S;if(I&&T.x!==f.x){const $=b.scrollLeft+h.x,R=v===Ln.Right&&$<=E.x||v===Ln.Left&&$>=O.x;if(R&&!h.y){b.scrollTo({left:$,behavior:a});return}R?g.x=b.scrollLeft-$:g.x=v===Ln.Right?b.scrollLeft-E.x:b.scrollLeft-O.x,g.x&&b.scrollBy({left:-g.x,behavior:a});break}else if(N&&T.y!==f.y){const $=b.scrollTop+h.y,R=v===Ln.Down&&$<=E.y||v===Ln.Up&&$>=O.y;if(R&&!h.x){b.scrollTo({top:$,behavior:a});return}R?g.y=b.scrollTop-$:g.y=v===Ln.Down?b.scrollTop-E.y:b.scrollTop-O.y,g.y&&b.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,rm(sb(f,this.referenceCoordinates),g))}}}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()}}AI.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=$le,onActivation:i}=t,{active:o}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=o.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function MK(e){return!!(e&&"distance"in e)}function RK(e){return!!(e&&"delay"in e)}class kI{constructor(t,n,r){var i;r===void 0&&(r=Elt(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:o}=t,{target:s}=o;this.props=t,this.events=n,this.document=gg(s),this.documentListeners=new Ly(this.document),this.listeners=new Ly(r),this.windowListeners=new Ly(fs(s)),this.initialCoordinates=(i=rO(o))!=null?i:al,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(ta.Resize,this.handleCancel),this.windowListeners.add(ta.DragStart,TK),this.windowListeners.add(ta.VisibilityChange,this.handleCancel),this.windowListeners.add(ta.ContextMenu,TK),this.documentListeners.add(ta.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(RK(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(MK(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:i}=this.props;i(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(ta.Click,Alt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ta.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:i,props:o}=this,{onMove:s,options:{activationConstraint:a}}=o;if(!i)return;const l=(n=rO(t))!=null?n:al,c=sb(i,l);if(!r&&a){if(MK(a)){if(a.tolerance!=null&&rk(c,a.tolerance))return this.handleCancel();if(rk(c,a.distance))return this.handleStart()}if(RK(a)&&rk(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);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===Ln.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const _lt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class _I extends kI{constructor(t){const{event:n}=t,r=gg(n.target);super(t,_lt,r)}}_I.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 Dlt={move:{name:"mousemove"},end:{name:"mouseup"}};var oO;(function(e){e[e.RightClick=2]="RightClick"})(oO||(oO={}));class Olt extends kI{constructor(t){super(t,Dlt,gg(t.event.target))}}Olt.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===oO.RightClick?!1:(r?.({event:n}),!0)}}];const ik={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Tlt extends kI{constructor(t){super(t,ik)}static setup(){return window.addEventListener(ik.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ik.move.name,t)};function t(){}}}Tlt.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Ny;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ny||(Ny={}));var DS;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(DS||(DS={}));function Mlt(e){let{acceleration:t,activator:n=Ny.Pointer,canScroll:r,draggingRect:i,enabled:o,interval:s=5,order:a=DS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:h}=e;const g=Ilt({delta:f,disabled:!o}),[y,b]=Uat(),v=_.useRef({x:0,y:0}),S=_.useRef({x:0,y:0}),C=_.useMemo(()=>{switch(n){case Ny.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Ny.DraggableRect:return i}},[n,i,l]),w=_.useRef(null),A=_.useCallback(()=>{const O=w.current;if(!O)return;const D=v.current.x*S.current.x,T=v.current.y*S.current.y;O.scrollBy(D,T)},[]),E=_.useMemo(()=>a===DS.TreeOrder?[...c].reverse():c,[a,c]);_.useEffect(()=>{if(!o||!c.length||!C){b();return}for(const O of E){if(r?.(O)===!1)continue;const D=c.indexOf(O),T=u[D];if(!T)continue;const{direction:I,speed:N}=blt(O,T,C,t,h);for(const $ of["x","y"])g[$][I[$]]||(N[$]=0,I[$]=0);if(N.x>0||N.y>0){b(),w.current=O,y(A,s),v.current=N,S.current=I;return}}v.current={x:0,y:0},S.current={x:0,y:0},b()},[t,A,r,b,o,s,JSON.stringify(C),JSON.stringify(g),y,c,E,u,JSON.stringify(h)])}const Rlt={x:{[Xi.Backward]:!1,[Xi.Forward]:!1},y:{[Xi.Backward]:!1,[Xi.Forward]:!1}};function Ilt(e){let{delta:t,disabled:n}=e;const r=nO(t);return lv(i=>{if(n||!r||!i)return Rlt;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Xi.Backward]:i.x[Xi.Backward]||o.x===-1,[Xi.Forward]:i.x[Xi.Forward]||o.x===1},y:{[Xi.Backward]:i.y[Xi.Backward]||o.y===-1,[Xi.Forward]:i.y[Xi.Forward]||o.y===1}}},[n,t,r])}function jlt(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return lv(i=>{var o;return t==null?null:(o=r??i)!=null?o:null},[r,t])}function Plt(e,t){return _.useMemo(()=>e.reduce((n,r)=>{const{sensor:i}=r,o=i.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...o]},[]),[e,t])}var lb;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(lb||(lb={}));var sO;(function(e){e.Optimized="optimized"})(sO||(sO={}));const IK=new Map;function $lt(e,t){let{dragging:n,dependencies:r,config:i}=t;const[o,s]=_.useState(null),{frequency:a,measure:l,strategy:c}=i,u=_.useRef(e),f=v(),h=ob(f),g=_.useCallback(function(S){S===void 0&&(S=[]),!h.current&&s(C=>C===null?S:C.concat(S.filter(w=>!C.includes(w))))},[h]),y=_.useRef(null),b=lv(S=>{if(f&&!n)return IK;if(!S||S===IK||u.current!==e||o!=null){const C=new Map;for(let w of e){if(!w)continue;if(o&&o.length>0&&!o.includes(w.id)&&w.rect.current){C.set(w.id,w.rect.current);continue}const A=w.node.current,E=A?new EI(l(A),A):null;w.rect.current=E,E&&C.set(w.id,E)}return C}return S},[e,o,n,f,l]);return _.useEffect(()=>{u.current=e},[e]),_.useEffect(()=>{f||g()},[n,f]),_.useEffect(()=>{o&&o.length>0&&s(null)},[JSON.stringify(o)]),_.useEffect(()=>{f||typeof a!="number"||y.current!==null||(y.current=setTimeout(()=>{g(),y.current=null},a))},[a,f,g,...r]),{droppableRects:b,measureDroppableContainers:g,measuringScheduled:o!=null};function v(){switch(c){case lb.Always:return!1;case lb.BeforeDragging:return n;default:return!n}}}function Lle(e,t){return lv(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Llt(e,t){return Lle(e,t)}function Nlt(e){let{callback:t,disabled:n}=e;const r=wI(t),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function QC(e){let{callback:t,disabled:n}=e;const r=wI(t),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function Flt(e){return new EI(yg(e),e)}function jK(e,t,n){t===void 0&&(t=Flt);const[r,i]=_.useState(null);function o(){i(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=Nlt({callback(l){if(e)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){o();break}}}}),a=QC({callback:o});return bc(()=>{o(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function Blt(e){const t=Lle(e);return Ole(e,t)}const PK=[];function zlt(e){const t=_.useRef(e),n=lv(r=>e?r&&r!==PK&&e&&t.current&&e.parentNode===t.current.parentNode?r:JC(e):PK,[e]);return _.useEffect(()=>{t.current=e},[e]),n}function Hlt(e){const[t,n]=_.useState(null),r=_.useRef(e),i=_.useCallback(o=>{const s=nk(o.target);s&&n(a=>a?(a.set(s,iO(s)),new Map(a)):null)},[]);return _.useEffect(()=>{const o=r.current;if(e!==o){s(o);const a=e.map(l=>{const c=nk(l);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,iO(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(o)};function s(a){a.forEach(l=>{const c=nk(l);c?.removeEventListener("scroll",i)})}},[i,e]),_.useMemo(()=>e.length?t?Array.from(t.values()).reduce((o,s)=>rm(o,s),al):Ple(e):al,[e,t])}function $K(e,t){t===void 0&&(t=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},t),_.useEffect(()=>{const r=e!==al;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?sb(e,n.current):al}function Ult(e){_.useEffect(()=>{if(!ZC)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 Vlt(e,t){return _.useMemo(()=>e.reduce((n,r)=>{let{eventName:i,handler:o}=r;return n[i]=s=>{o(s,t)},n},{}),[e,t])}function Nle(e){return _.useMemo(()=>e?plt(e):null,[e])}const LK=[];function Wlt(e,t){t===void 0&&(t=yg);const[n]=e,r=Nle(n?fs(n):null),[i,o]=_.useState(LK);function s(){o(()=>e.length?e.map(l=>Ile(l)?r:new EI(t(l),l)):LK)}const a=QC({callback:s});return bc(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),i}function qlt(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return av(t)?t:e}function Glt(e){let{measure:t}=e;const[n,r]=_.useState(null),i=_.useCallback(c=>{for(const{target:u}of c)if(av(u)){r(f=>{const h=t(u);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),o=QC({callback:i}),s=_.useCallback(c=>{const u=qlt(c);o?.disconnect(),u&&o?.observe(u),r(u?t(u):null)},[t,o]),[a,l]=kS(s);return _.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Klt=[{sensor:_I,options:{}},{sensor:AI,options:{}}],Ylt={current:{}},D4={draggable:{measure:OK},droppable:{measure:OK,strategy:lb.WhileDragging,frequency:sO.Optimized},dragOverlay:{measure:yg}};class Fy 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 Xlt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Fy,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_S},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:D4,measureDroppableContainers:_S,windowRect:null,measuringScheduled:!1},Zlt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_S,draggableNodes:new Map,over:null,measureDroppableContainers:_S},e8=_.createContext(Zlt),Fle=_.createContext(Xlt);function Jlt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Fy}}}function Qlt(e,t){switch(t.type){case Li.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Li.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 Li.DragEnd:case Li.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Li.RegisterDroppable:{const{element:n}=t,{id:r}=n,i=new Fy(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Li.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new Fy(e.droppable.containers);return s.set(n,{...o,disabled:i}),{...e,droppable:{...e.droppable,containers:s}}}case Li.UnregisterDroppable:{const{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new Fy(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function ect(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext(e8),o=nO(r),s=nO(n?.id);return _.useEffect(()=>{if(!t&&!r&&o&&s!=null){if(!CI(o)||document.activeElement===o.target)return;const a=i.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=qat(u);if(f){f.focus();break}}})}},[r,t,i,s,o]),null}function tct(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((i,o)=>o({transform:i,...r}),n):n}function nct(e){return _.useMemo(()=>({draggable:{...D4.draggable,...e?.draggable},droppable:{...D4.droppable,...e?.droppable},dragOverlay:{...D4.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function rct(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e;const o=_.useRef(!1),{x:s,y:a}=typeof i=="boolean"?{x:i,y:i}:i;bc(()=>{if(!s&&!a||!t){o.current=!1;return}if(o.current||!r)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=Ole(u,r);if(s||(f.x=0),a||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const h=Tle(c);h&&h.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const Ble=_.createContext({...al,scaleX:1,scaleY:1});var wd;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(wd||(wd={}));const ict=_.memo(function(t){var n,r,i,o;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=Klt,collisionDetection:f=alt,measuring:h,modifiers:g,...y}=t;const b=_.useReducer(Qlt,void 0,Jlt),[v,S]=b,[C,w]=Jat(),[A,E]=_.useState(wd.Uninitialized),O=A===wd.Initialized,{draggable:{active:D,nodes:T,translate:I},droppable:{containers:N}}=v,$=D!=null?T.get(D):null,R=_.useRef({initial:null,translated:null}),L=_.useMemo(()=>{var Dt;return D!=null?{id:D,data:(Dt=$?.data)!=null?Dt:Ylt,rect:R}:null},[D,$]),P=_.useRef(null),[z,F]=_.useState(null),[W,H]=_.useState(null),U=ob(y,Object.values(y)),K=cv("DndDescribedBy",s),B=_.useMemo(()=>N.getEnabled(),[N]),q=nct(h),{droppableRects:X,measureDroppableContainers:V,measuringScheduled:Y}=$lt(B,{dragging:O,dependencies:[I.x,I.y],config:q.droppable}),J=jlt(T,D),ne=_.useMemo(()=>W?rO(W):null,[W]),ee=yr(),ae=Llt(J,q.draggable.measure);rct({activeNode:D!=null?T.get(D):null,config:ee.layoutShiftCompensation,initialRect:ae,measure:q.draggable.measure});const ue=jK(J,q.draggable.measure,ae),te=jK(J?J.parentElement:null),Z=_.useRef({activatorEvent:null,active:null,activeNode:J,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=N.getNodeFor((n=Z.current.over)==null?void 0:n.id),se=Glt({measure:q.dragOverlay.measure}),de=(r=se.nodeRef.current)!=null?r:J,be=O?(i=se.rect)!=null?i:ue:null,Pe=!!(se.nodeRef.current&&se.rect),De=Blt(Pe?null:ue),Ke=Nle(de?fs(de):null),xe=zlt(O?ie??J:null),Le=Wlt(xe),Te=tct(g,{transform:{x:I.x-De.x,y:I.y-De.y,scaleX:1,scaleY:1},activatorEvent:W,active:L,activeNodeRect:ue,containerNodeRect:te,draggingNodeRect:be,over:Z.current.over,overlayNodeRect:se.rect,scrollableAncestors:xe,scrollableAncestorRects:Le,windowRect:Ke}),ht=ne?rm(ne,I):null,mt=Hlt(xe),ze=$K(mt),Ie=$K(mt,[ue]),He=rm(Te,ze),Je=be?ult(be,Te):null,rt=L&&Je?f({active:L,collisionRect:Je,droppableRects:X,droppableContainers:B,pointerCoordinates:ht}):null,st=Dle(rt,"id"),[Xe,Lt]=_.useState(null),Nt=Pe?Te:rm(Te,Ie),Ot=llt(Nt,(o=Xe?.rect)!=null?o:null,ue),Jn=_.useRef(null),sn=_.useCallback((Dt,Pt)=>{let{sensor:en,options:Pn}=Pt;if(P.current==null)return;const an=T.get(P.current);if(!an)return;const wt=Dt.nativeEvent,yn=new en({active:P.current,activeNode:an,event:wt,options:Pn,context:Z,onAbort(br){if(!T.get(br))return;const{onDragAbort:ce}=U.current,pe={id:br};ce?.(pe),C({type:"onDragAbort",event:pe})},onPending(br,ti,ce,pe){if(!T.get(br))return;const{onDragPending:Fe}=U.current,Ue={id:br,constraint:ti,initialCoordinates:ce,offset:pe};Fe?.(Ue),C({type:"onDragPending",event:Ue})},onStart(br){const ti=P.current;if(ti==null)return;const ce=T.get(ti);if(!ce)return;const{onDragStart:pe}=U.current,Se={activatorEvent:wt,active:{id:ti,data:ce.data,rect:R}};Td.unstable_batchedUpdates(()=>{pe?.(Se),E(wd.Initializing),S({type:Li.DragStart,initialCoordinates:br,active:ti}),C({type:"onDragStart",event:Se}),F(Jn.current),H(wt)})},onMove(br){S({type:Li.DragMove,coordinates:br})},onEnd:ei(Li.DragEnd),onCancel:ei(Li.DragCancel)});Jn.current=yn;function ei(br){return async function(){const{active:ce,collisions:pe,over:Se,scrollAdjustedTranslate:Fe}=Z.current;let Ue=null;if(ce&&Fe){const{cancelDrop:yt}=U.current;Ue={activatorEvent:wt,active:ce,collisions:pe,delta:Fe,over:Se},br===Li.DragEnd&&typeof yt=="function"&&await Promise.resolve(yt(Ue))&&(br=Li.DragCancel)}P.current=null,Td.unstable_batchedUpdates(()=>{S({type:br}),E(wd.Uninitialized),Lt(null),F(null),H(null),Jn.current=null;const yt=br===Li.DragEnd?"onDragEnd":"onDragCancel";if(Ue){const it=U.current[yt];it?.(Ue),C({type:yt,event:Ue})}})}}},[T]),lt=_.useCallback((Dt,Pt)=>(en,Pn)=>{const an=en.nativeEvent,wt=T.get(Pn);if(P.current!==null||!wt||an.dndKit||an.defaultPrevented)return;const yn={active:wt};Dt(en,Pt.options,yn)===!0&&(an.dndKit={capturedBy:Pt.sensor},P.current=Pn,sn(en,Pt))},[T,sn]),Ht=Plt(u,lt);Ult(u),bc(()=>{ue&&A===wd.Initializing&&E(wd.Initialized)},[ue,A]),_.useEffect(()=>{const{onDragMove:Dt}=U.current,{active:Pt,activatorEvent:en,collisions:Pn,over:an}=Z.current;if(!Pt||!en)return;const wt={active:Pt,activatorEvent:en,collisions:Pn,delta:{x:He.x,y:He.y},over:an};Td.unstable_batchedUpdates(()=>{Dt?.(wt),C({type:"onDragMove",event:wt})})},[He.x,He.y]),_.useEffect(()=>{const{active:Dt,activatorEvent:Pt,collisions:en,droppableContainers:Pn,scrollAdjustedTranslate:an}=Z.current;if(!Dt||P.current==null||!Pt||!an)return;const{onDragOver:wt}=U.current,yn=Pn.get(st),ei=yn&&yn.rect.current?{id:yn.id,rect:yn.rect.current,data:yn.data,disabled:yn.disabled}:null,br={active:Dt,activatorEvent:Pt,collisions:en,delta:{x:an.x,y:an.y},over:ei};Td.unstable_batchedUpdates(()=>{Lt(ei),wt?.(br),C({type:"onDragOver",event:br})})},[st]),bc(()=>{Z.current={activatorEvent:W,active:L,activeNode:J,collisionRect:Je,collisions:rt,droppableRects:X,draggableNodes:T,draggingNode:de,draggingNodeRect:be,droppableContainers:N,over:Xe,scrollableAncestors:xe,scrollAdjustedTranslate:He},R.current={initial:be,translated:Je}},[L,J,rt,Je,T,de,be,X,N,Xe,xe,He]),Mlt({...ee,delta:I,draggingRect:Je,pointerCoordinates:ht,scrollableAncestors:xe,scrollableAncestorRects:Le});const Dn=_.useMemo(()=>({active:L,activeNode:J,activeNodeRect:ue,activatorEvent:W,collisions:rt,containerNodeRect:te,dragOverlay:se,draggableNodes:T,droppableContainers:N,droppableRects:X,over:Xe,measureDroppableContainers:V,scrollableAncestors:xe,scrollableAncestorRects:Le,measuringConfiguration:q,measuringScheduled:Y,windowRect:Ke}),[L,J,ue,W,rt,te,se,T,N,X,Xe,V,xe,Le,q,Y,Ke]),Kn=_.useMemo(()=>({activatorEvent:W,activators:Ht,active:L,activeNodeRect:ue,ariaDescribedById:{draggable:K},dispatch:S,draggableNodes:T,over:Xe,measureDroppableContainers:V}),[W,Ht,L,ue,S,K,T,Xe,V]);return qt.createElement(Ale.Provider,{value:w},qt.createElement(e8.Provider,{value:Kn},qt.createElement(Fle.Provider,{value:Dn},qt.createElement(Ble.Provider,{value:Ot},c)),qt.createElement(ect,{disabled:a?.restoreFocus===!1})),qt.createElement(tlt,{...a,hiddenTextDescribedById:K}));function yr(){const Dt=z?.autoScrollEnabled===!1,Pt=typeof l=="object"?l.enabled===!1:l===!1,en=O&&!Dt&&!Pt;return typeof l=="object"?{...l,enabled:en}:{enabled:en}}}),oct=_.createContext(null),NK="button",sct="Draggable";function act(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e;const o=cv(sct),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:h}=_.useContext(e8),{role:g=NK,roleDescription:y="draggable",tabIndex:b=0}=i??{},v=l?.id===t,S=_.useContext(v?Ble:oct),[C,w]=kS(),[A,E]=kS(),O=Vlt(s,t),D=ob(n);bc(()=>(f.set(t,{id:t,key:o,node:C,activatorNode:A,data:D}),()=>{const I=f.get(t);I&&I.key===o&&f.delete(t)}),[f,t]);const T=_.useMemo(()=>({role:g,tabIndex:b,"aria-disabled":r,"aria-pressed":v&&g===NK?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[r,g,b,v,y,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:T,isDragging:v,listeners:r?void 0:O,node:C,over:h,setNodeRef:w,setActivatorNodeRef:E,transform:S}}function lct(){return _.useContext(Fle)}const cct="Droppable",uct={timeout:25};function dct(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e;const o=cv(cct),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=_.useContext(e8),u=_.useRef({disabled:n}),f=_.useRef(!1),h=_.useRef(null),g=_.useRef(null),{disabled:y,updateMeasurementsFor:b,timeout:v}={...uct,...i},S=ob(b??r),C=_.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(S.current)?S.current:[S.current]),g.current=null},v)},[v]),w=QC({callback:C,disabled:y||!s}),A=_.useCallback((T,I)=>{w&&(I&&(w.unobserve(I),f.current=!1),T&&w.observe(T))},[w]),[E,O]=kS(A),D=ob(t);return _.useEffect(()=>{!w||!E.current||(w.disconnect(),f.current=!1,w.observe(E.current))},[E,w]),_.useEffect(()=>(a({type:Li.RegisterDroppable,element:{id:r,key:o,disabled:n,node:E,rect:h,data:D}}),()=>a({type:Li.UnregisterDroppable,key:o,id:r})),[r]),_.useEffect(()=>{n!==u.current.disabled&&(a({type:Li.SetDroppableDisabled,id:r,key:o,disabled:n}),u.current.disabled=n)},[r,o,n,a]),{active:s,rect:h,isOver:l?.id===r,node:E,over:l,setNodeRef:O}}function DI(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function fct(e,t){return e.reduce((n,r,i)=>{const o=t.get(r);return o&&(n[i]=o),n},Array(e.length))}function _5(e){return e!==null&&e>=0}function hct(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 pct(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const zle=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e;const o=DI(t,r,n),s=t[i],a=o[i];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},D5={scaleX:1,scaleY:1},mct=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:i,rects:o,overIndex:s}=e;const a=(t=o[n])!=null?t:r;if(!a)return null;if(i===n){const c=o[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...D5}:null}const l=gct(o,i,n);return i>n&&i<=s?{x:0,y:-a.height-l,...D5}:i<n&&i>=s?{x:0,y:a.height+l,...D5}:{x:0,y:0,...D5}};function gct(e,t,n){const r=e[t],i=e[t-1],o=e[t+1];return r?n<t?i?r.top-(i.top+i.height):o?o.top-(r.top+r.height):0:o?o.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const Hle="Sortable",Ule=qt.createContext({activeIndex:-1,containerId:Hle,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:zle,disabled:{draggable:!1,droppable:!1}});function yct(e){let{children:t,id:n,items:r,strategy:i=zle,disabled:o=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=lct(),f=cv(Hle,n),h=a.rect!==null,g=_.useMemo(()=>r.map(O=>typeof O=="object"&&"id"in O?O.id:O),[r]),y=s!=null,b=s?g.indexOf(s.id):-1,v=c?g.indexOf(c.id):-1,S=_.useRef(g),C=!hct(g,S.current),w=v!==-1&&b===-1||C,A=pct(o);bc(()=>{C&&y&&u(g)},[C,g,y,u]),_.useEffect(()=>{S.current=g},[g]);const E=_.useMemo(()=>({activeIndex:b,containerId:f,disabled:A,disableTransforms:w,items:g,overIndex:v,useDragOverlay:h,sortedRects:fct(g,l),strategy:i}),[b,f,A.draggable,A.droppable,w,g,v,l,h,i]);return qt.createElement(Ule.Provider,{value:E},t)}const bct=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return DI(n,r,i).indexOf(t)},vct=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:o,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==o&&i===s?!1:n?!0:s!==i&&t===l},xct={duration:200,easing:"ease"},Vle="transform",Sct=ab.Transition.toString({property:Vle,duration:0,easing:"linear"}),wct={roleDescription:"sortable"};function Cct(e){let{disabled:t,index:n,node:r,rect:i}=e;const[o,s]=_.useState(null),a=_.useRef(n);return bc(()=>{if(!t&&n!==a.current&&r.current){const l=i.current;if(l){const c=yg(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,i]),_.useEffect(()=>{o&&s(null)},[o]),o}function Ect(e){let{animateLayoutChanges:t=vct,attributes:n,disabled:r,data:i,getNewIndex:o=bct,id:s,strategy:a,resizeObserverConfig:l,transition:c=xct}=e;const{items:u,containerId:f,activeIndex:h,disabled:g,disableTransforms:y,sortedRects:b,overIndex:v,useDragOverlay:S,strategy:C}=_.useContext(Ule),w=Act(r,g),A=u.indexOf(s),E=_.useMemo(()=>({sortable:{containerId:f,index:A,items:u},...i}),[f,i,A,u]),O=_.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:D,node:T,isOver:I,setNodeRef:N}=dct({id:s,data:E,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...l}}),{active:$,activatorEvent:R,activeNodeRect:L,attributes:P,setNodeRef:z,listeners:F,isDragging:W,over:H,setActivatorNodeRef:U,transform:K}=act({id:s,data:E,attributes:{...wct,...n},disabled:w.draggable}),B=Hat(N,z),q=!!$,X=q&&!y&&_5(h)&&_5(v),V=!S&&W,Y=V&&X?K:null,ne=X?Y??(a??C)({rects:b,activeNodeRect:L,activeIndex:h,overIndex:v,index:A}):null,ee=_5(h)&&_5(v)?o({id:s,items:u,activeIndex:h,overIndex:v}):A,ae=$?.id,ue=_.useRef({activeId:ae,items:u,newIndex:ee,containerId:f}),te=u!==ue.current.items,Z=t({active:$,containerId:f,isDragging:W,isSorting:q,id:s,index:A,items:u,newIndex:ue.current.newIndex,previousItems:ue.current.items,previousContainerId:ue.current.containerId,transition:c,wasDragging:ue.current.activeId!=null}),ie=Cct({disabled:!Z,index:A,node:T,rect:D});return _.useEffect(()=>{q&&ue.current.newIndex!==ee&&(ue.current.newIndex=ee),f!==ue.current.containerId&&(ue.current.containerId=f),u!==ue.current.items&&(ue.current.items=u)},[q,ee,f,u]),_.useEffect(()=>{if(ae===ue.current.activeId)return;if(ae!=null&&ue.current.activeId==null){ue.current.activeId=ae;return}const de=setTimeout(()=>{ue.current.activeId=ae},50);return()=>clearTimeout(de)},[ae]),{active:$,activeIndex:h,attributes:P,data:E,rect:D,index:A,newIndex:ee,items:u,isOver:I,isSorting:q,isDragging:W,listeners:F,node:T,overIndex:v,over:H,setNodeRef:B,setActivatorNodeRef:U,setDroppableNodeRef:N,setDraggableNodeRef:z,transform:ie??ne,transition:se()};function se(){if(ie||te&&ue.current.newIndex===A)return Sct;if(!(V&&!CI(R)||!c)&&(q||Z))return ab.Transition.toString({...c,property:Vle})}}function Act(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 OS(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 kct=[Ln.Down,Ln.Right,Ln.Up,Ln.Left],_ct=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:o,over:s,scrollableAncestors:a}}=t;if(kct.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=i.get(f.id);if(h)switch(e.code){case Ln.Down:r.top<h.top&&l.push(f);break;case Ln.Up:r.top>h.top&&l.push(f);break;case Ln.Left:r.left>h.left&&l.push(f);break;case Ln.Right:r.left<h.left&&l.push(f);break}});const c=olt({collisionRect:r,droppableRects:i,droppableContainers:l});let u=Dle(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const f=o.get(n.id),h=o.get(u),g=h?i.get(h.id):null,y=h?.node.current;if(y&&g&&f&&h){const v=JC(y).some((O,D)=>a[D]!==O),S=Wle(f,h),C=Dct(f,h),w=v||!S?{x:0,y:0}:{x:C?r.width-g.width:0,y:C?r.height-g.height:0},A={x:g.left,y:g.top};return w.x&&w.y?A:sb(A,w)}}}};function Wle(e,t){return!OS(e)||!OS(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Dct(e,t){return!OS(e)||!OS(t)||!Wle(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const Oct=({bridge:e,index:t})=>{const{attributes:n,listeners:r,setNodeRef:i,transform:o,transition:s,isDragging:a}=Ect({id:e.id}),[l,c]=_.useState(!1);_.useEffect(()=>{Iw(e.id).then(c)},[e.id]);const u={transform:ab.Transform.toString(o),transition:s,opacity:a?.5:1};return p.jsx(Bn,{ref:i,style:u,variant:"outlined",sx:{cursor:"grab","&:active":{cursor:"grabbing"},bgcolor:a?"action.selected":"background.paper",width:"fit-content"},children:p.jsxs(Zn,{sx:{display:"flex",alignItems:"center",gap:1.5,py:1,"&:last-child":{pb:1}},children:[p.jsx(oe,{...n,...r,sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:p.jsx(e8e,{})}),p.jsx(xt,{label:t+1,size:"small",color:"primary",sx:{minWidth:32,fontWeight:"bold"}}),l?p.jsx(oe,{component:"img",src:o2(e.id),alt:e.name,sx:{width:40,height:40,borderRadius:"50%",objectFit:"cover",boxShadow:2}}):p.jsx(il,{sx:{bgcolor:RT(e),width:40,height:40,boxShadow:2},children:(()=>{const f=MT(e);return p.jsx(f,{sx:{fontSize:24}})})()}),p.jsxs(oe,{sx:{flex:1},children:[p.jsx(re,{variant:"subtitle1",fontWeight:500,children:e.name}),p.jsxs(re,{variant:"caption",color:"text.secondary",children:["Port: ",e.port," • Priority: ",e.priority??100]})]})]})})},Tct=()=>{const e=Ru(),{content:t,isLoading:n}=Gm(),r=CCe(),[i,o]=_.useState([]),[s,a]=_.useState(!1);_.useEffect(()=>{if(t){const h=[...t].sort((g,y)=>{const b=g.priority??100,v=y.priority??100;return b-v});o(h),a(!1)}},[t]);const l=nlt(kK(_I),kK(AI,{coordinateGetter:_ct})),c=_.useCallback(h=>{const{active:g,over:y}=h;y&&g.id!==y.id&&(o(b=>{const v=b.findIndex(C=>C.id===g.id),S=b.findIndex(C=>C.id===y.id);return DI(b,v,S)}),a(!0))},[]),u=_.useCallback(async()=>{const h=i.map((g,y)=>({id:g.id,priority:(y+1)*10}));try{await r(h),e.show({message:"Startup order saved successfully",severity:"success"}),a(!1)}catch(g){e.show({message:g instanceof Error?g.message:"Failed to save startup order",severity:"error"})}},[i,r,e]),f=_.useMemo(()=>i.map(h=>h.id),[i]);return n?p.jsx(re,{children:"Loading..."}):p.jsxs(Bt,{spacing:3,children:[p.jsx(fw,{items:[{name:"Bridges",to:jt.bridges},{name:"Startup Order",to:jt.startup}]}),p.jsxs(oe,{display:"flex",alignItems:"center",gap:2,children:[p.jsx(am,{color:"primary",fontSize:"large"}),p.jsxs(oe,{children:[p.jsx(re,{variant:"h5",fontWeight:600,children:"Startup Order"}),p.jsx(re,{variant:"body2",color:"text.secondary",children:"Drag and drop bridges to set the startup order. Lower positions start first."})]})]}),s&&p.jsx(Qt,{severity:"info",action:p.jsx(At,{color:"inherit",size:"small",startIcon:p.jsx(s6,{}),onClick:u,children:"Save Changes"}),children:"You have unsaved changes to the startup order."}),p.jsx(ict,{sensors:l,collisionDetection:ilt,onDragEnd:c,children:p.jsx(yct,{items:f,strategy:mct,children:p.jsx(Bt,{spacing:1,children:i.map((h,g)=>p.jsx(Oct,{bridge:h,index:g},h.id))})})}),i.length===0&&p.jsx(re,{color:"text.secondary",textAlign:"center",py:4,children:"No bridges configured yet."}),s&&i.length>0&&p.jsx(oe,{display:"flex",justifyContent:"flex-end",children:p.jsx(At,{variant:"contained",startIcon:p.jsx(s6,{}),onClick:u,children:"Save Startup Order"})})]})},ok="https://riddix.github.io/home-assistant-matter-hub",jt={dashboard:"/",bridges:"/bridges",bridge:e=>`/bridges/${e}`,createBridge:"/bridges/create",editBridge:e=>`/bridges/${e}/edit`,devices:"/devices",networkMap:"/network-map",health:"/health",labels:"/labels",lockCredentials:"/lock-credentials",plugins:"/plugins",settings:"/settings",startup:"/startup",githubRepository:"https://github.com/riddix/home-assistant-matter-hub/",documentation:ok,faq:{multiFabric:`${ok}/connect-multiple-fabrics`,bridgeConfig:`${ok}/bridge-configuration`}},Mct=[{path:"",element:p.jsx(T2e,{}),children:[{path:"",element:p.jsx(c9e,{})},{path:jt.bridges,element:p.jsx(s9e,{})},{path:jt.createBridge,element:p.jsx(ZQe,{})},{path:jt.bridge(":bridgeId"),element:p.jsx(PCe,{})},{path:jt.editBridge(":bridgeId"),element:p.jsx(JQe,{})},{path:jt.devices,element:p.jsx(_9e,{})},{path:jt.networkMap,element:p.jsx(Dat,{})},{path:jt.health,element:p.jsx(set,{})},{path:jt.labels,element:p.jsx(det,{})},{path:jt.lockCredentials,element:p.jsx(yet,{})},{path:jt.plugins,element:p.jsx($at,{})},{path:jt.settings,element:p.jsx(zat,{})},{path:jt.startup,element:p.jsx(Tct,{})}]}],Rct={items:{isInitialized:!1,isLoading:!1}},Ict=GO(Rct,e=>{e.addCase(Fo.pending,t=>{t.items.isLoading=!0}).addCase(Fo.rejected,(t,n)=>{t.items.isInitialized=!0,t.items.isLoading=!1,t.items.content=void 0,t.items.error=n.error}).addCase(Fo.fulfilled,(t,n)=>{t.items.isInitialized=!0,t.items.isLoading=!1,t.items.content=n.payload,t.items.error=void 0}).addCase(zX.fulfilled,(t,n)=>{t.items.content?.push(n.payload)}).addCase(UX.fulfilled,(t,n)=>{const r=t.items.content?.findIndex(i=>i.id===n.payload.id)??-1;r!==-1&&(t.items.content[r]=n.payload)}).addCase(VX.fulfilled,(t,n)=>{const r=t.items.content?.findIndex(i=>i.id===n.payload.id)??-1;r!==-1&&(t.items.content[r]=n.payload)}).addCase(HX.fulfilled,(t,n)=>{if(t.items.content){const r=t.items.content.findIndex(i=>i.id===n.meta.arg);r!==-1&&t.items.content.splice(r,1)}}).addCase(WX,(t,n)=>{t.items.isInitialized=!0,t.items.isLoading=!1,t.items.content=n.payload,t.items.error=void 0}).addCase(qX,(t,n)=>{if(t.items.content){const r=t.items.content.findIndex(i=>i.id===n.payload.id);r!==-1?t.items.content[r]=n.payload:t.items.content.push(n.payload)}})}),jct={byBridge:{}},Pct=GO(jct,e=>{e.addCase(fu.pending,(t,n)=>{t.byBridge[n.meta.arg]=sk(t.byBridge[n.meta.arg],n)}).addCase(fu.rejected,(t,n)=>{t.byBridge[n.meta.arg]=sk(t.byBridge[n.meta.arg],n)}).addCase(fu.fulfilled,(t,n)=>{t.byBridge[n.meta.arg]=sk(t.byBridge[n.meta.arg],n)})}),$ct={isInitialized:!1,isLoading:!1,content:void 0,error:void 0},sk=GO($ct,e=>{e.addCase(fu.pending,t=>{t.isLoading=!0}).addCase(fu.rejected,(t,n)=>{t.isInitialized=!0,t.isLoading=!1,t.content=void 0,t.error=n.error}).addCase(fu.fulfilled,(t,n)=>{t.isInitialized=!0,t.isLoading=!1,t.content=n.payload,t.error=void 0})}),Lct=d2e({reducer:{bridges:Ict,devices:Pct}}),OI=Kme({createStyledComponent:me("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[`maxWidth${ye(String(n.maxWidth))}`],n.fixed&&t.fixed,n.disableGutters&&t.disableGutters]}}),useThemeProps:e=>ot({props:e,name:"MuiContainer"})});function Nct(e){return et("MuiToolbar",e)}nt("MuiToolbar",["root","gutters","regular","dense"]);const Fct=e=>{const{classes:t,disableGutters:n,variant:r}=e;return tt({root:["root",!n&&"gutters",r]},Nct,t)},Bct=me("div",{name:"MuiToolbar",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(Ge(({theme:e})=>({position:"relative",display:"flex",alignItems:"center",variants:[{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up("sm")]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:"dense"},style:{minHeight:48}},{props:{variant:"regular"},style:e.mixins.toolbar}]}))),qle=_.forwardRef(function(t,n){const r=ot({props:t,name:"MuiToolbar"}),{className:i,component:o="div",disableGutters:s=!1,variant:a="regular",...l}=r,c={...r,component:o,disableGutters:s,variant:a},u=Fct(c);return p.jsx(Bct,{as:o,className:Oe(u.root,i),ref:n,ownerState:c,...l})}),zct=[{name:"GitHub",url:jt.githubRepository},{name:"Documentation",url:jt.documentation}],Hct=()=>p.jsxs(OI,{sx:{mt:16,mb:4},children:[p.jsx(Jr,{sx:{mt:4,mb:4}}),p.jsx(Qe,{container:!0,spacing:2,justifyContent:"center",children:zct.map((e,t)=>p.jsx(Qe,{size:{xs:12,sm:"auto"},children:p.jsx(At,{fullWidth:!0,size:"small",variant:"outlined",component:dw,href:e.url,target:"_blank",children:e.name})},t.toString()))})]});function Uct(e){return et("MuiAppBar",e)}nt("MuiAppBar",["root","positionFixed","positionAbsolute","positionSticky","positionStatic","positionRelative","colorDefault","colorPrimary","colorSecondary","colorInherit","colorTransparent","colorError","colorInfo","colorSuccess","colorWarning"]);const Vct=e=>{const{color:t,position:n,classes:r}=e,i={root:["root",`color${ye(t)}`,`position${ye(n)}`]};return tt(i,Uct,r)},FK=(e,t)=>e?`${e.replace(")","")}, ${t})`:t,Wct=me(Fr,{name:"MuiAppBar",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[`position${ye(n.position)}`],t[`color${ye(n.color)}`]]}})(Ge(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%",boxSizing:"border-box",flexShrink:0,variants:[{props:{position:"fixed"},style:{position:"fixed",zIndex:(e.vars||e).zIndex.appBar,top:0,left:"auto",right:0,"@media print":{position:"absolute"}}},{props:{position:"absolute"},style:{position:"absolute",zIndex:(e.vars||e).zIndex.appBar,top:0,left:"auto",right:0}},{props:{position:"sticky"},style:{position:"sticky",zIndex:(e.vars||e).zIndex.appBar,top:0,left:"auto",right:0}},{props:{position:"static"},style:{position:"static"}},{props:{position:"relative"},style:{position:"relative"}},{props:{color:"inherit"},style:{"--AppBar-color":"inherit",color:"var(--AppBar-color)"}},{props:{color:"default"},style:{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[100],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[100]),...e.applyStyles("dark",{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[900],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[900])})}},...Object.entries(e.palette).filter(Fn(["contrastText"])).map(([t])=>({props:{color:t},style:{"--AppBar-background":(e.vars??e).palette[t].main,"--AppBar-color":(e.vars??e).palette[t].contrastText}})),{props:t=>t.enableColorOnDark===!0&&!["inherit","transparent"].includes(t.color),style:{backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)"}},{props:t=>t.enableColorOnDark===!1&&!["inherit","transparent"].includes(t.color),style:{backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)",...e.applyStyles("dark",{backgroundColor:e.vars?FK(e.vars.palette.AppBar.darkBg,"var(--AppBar-background)"):null,color:e.vars?FK(e.vars.palette.AppBar.darkColor,"var(--AppBar-color)"):null})}},{props:{color:"transparent"},style:{"--AppBar-background":"transparent","--AppBar-color":"inherit",backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)",...e.applyStyles("dark",{backgroundImage:"none"})}}]}))),qct=_.forwardRef(function(t,n){const r=ot({props:t,name:"MuiAppBar"}),{className:i,color:o="primary",enableColorOnDark:s=!1,position:a="fixed",...l}=r,c={...r,color:o,position:a,enableColorOnDark:s},u=Vct(c);return p.jsx(Wct,{square:!0,component:"header",ownerState:c,elevation:4,className:Oe(u.root,i,a==="fixed"&&"mui-fixed"),ref:n,...l})});function Gct(e,t,n){const r=t.getBoundingClientRect(),i=n&&n.getBoundingClientRect(),o=tl(t);let s;if(t.fakeTransform)s=t.fakeTransform;else{const c=o.getComputedStyle(t);s=c.getPropertyValue("-webkit-transform")||c.getPropertyValue("transform")}let a=0,l=0;if(s&&s!=="none"&&typeof s=="string"){const c=s.split("(")[1].split(")")[0].split(",");a=parseInt(c[4],10),l=parseInt(c[5],10)}return e==="left"?i?`translateX(${i.right+a-r.left}px)`:`translateX(${o.innerWidth+a-r.left}px)`:e==="right"?i?`translateX(-${r.right-i.left-a}px)`:`translateX(-${r.left+r.width-a}px)`:e==="up"?i?`translateY(${i.bottom+l-r.top}px)`:`translateY(${o.innerHeight+l-r.top}px)`:i?`translateY(-${r.top-i.top+r.height-l}px)`:`translateY(-${r.top+r.height-l}px)`}function Kct(e){return typeof e=="function"?e():e}function O5(e,t,n){const r=Kct(n),i=Gct(e,t,r);i&&(t.style.webkitTransform=i,t.style.transform=i)}const Yct=_.forwardRef(function(t,n){const r=Oa(),i={enter:r.transitions.easing.easeOut,exit:r.transitions.easing.sharp},o={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{addEndListener:s,appear:a=!0,children:l,container:c,direction:u="down",easing:f=i,in:h,onEnter:g,onEntered:y,onEntering:b,onExit:v,onExited:S,onExiting:C,style:w,timeout:A=o,TransitionComponent:E=Ta,...O}=t,D=_.useRef(null),T=Rr(gf(l),D,n),I=H=>U=>{H&&(U===void 0?H(D.current):H(D.current,U))},N=I((H,U)=>{O5(u,H,c),zO(H),g&&g(H,U)}),$=I((H,U)=>{const K=Xd({timeout:A,style:w,easing:f},{mode:"enter"});H.style.webkitTransition=r.transitions.create("-webkit-transform",{...K}),H.style.transition=r.transitions.create("transform",{...K}),H.style.webkitTransform="none",H.style.transform="none",b&&b(H,U)}),R=I(y),L=I(C),P=I(H=>{const U=Xd({timeout:A,style:w,easing:f},{mode:"exit"});H.style.webkitTransition=r.transitions.create("-webkit-transform",U),H.style.transition=r.transitions.create("transform",U),O5(u,H,c),v&&v(H)}),z=I(H=>{H.style.webkitTransition="",H.style.transition="",S&&S(H)}),F=H=>{s&&s(D.current,H)},W=_.useCallback(()=>{D.current&&O5(u,D.current,c)},[u,c]);return _.useEffect(()=>{if(h||u==="down"||u==="right")return;const H=LO(()=>{D.current&&O5(u,D.current,c)}),U=tl(D.current);return U.addEventListener("resize",H),()=>{H.clear(),U.removeEventListener("resize",H)}},[u,h,c]),_.useEffect(()=>{h||W()},[h,W]),p.jsx(E,{nodeRef:D,onEnter:N,onEntered:R,onEntering:$,onExit:P,onExited:z,onExiting:L,addEndListener:F,appear:a,in:h,timeout:A,...O,children:(H,{ownerState:U,...K})=>_.cloneElement(l,{ref:T,style:{visibility:H==="exited"&&!h?"hidden":void 0,...w,...l.props.style},...K})})});function Xct(e){return et("MuiDrawer",e)}nt("MuiDrawer",["root","docked","paper","anchorLeft","anchorRight","anchorTop","anchorBottom","paperAnchorLeft","paperAnchorRight","paperAnchorTop","paperAnchorBottom","paperAnchorDockedLeft","paperAnchorDockedRight","paperAnchorDockedTop","paperAnchorDockedBottom","modal"]);const Gle=(e,t)=>{const{ownerState:n}=e;return[t.root,(n.variant==="permanent"||n.variant==="persistent")&&t.docked,n.variant==="temporary"&&t.modal]},Zct=e=>{const{classes:t,anchor:n,variant:r}=e,i={root:["root",`anchor${ye(n)}`],docked:[(r==="permanent"||r==="persistent")&&"docked"],modal:["modal"],paper:["paper",`paperAnchor${ye(n)}`,r!=="temporary"&&`paperAnchorDocked${ye(n)}`]};return tt(i,Xct,t)},Jct=me(rT,{name:"MuiDrawer",slot:"Root",overridesResolver:Gle})(Ge(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),Qct=me("div",{shouldForwardProp:ro,name:"MuiDrawer",slot:"Docked",skipVariantsResolver:!1,overridesResolver:Gle})({flex:"0 0 auto"}),eut=me(Fr,{name:"MuiDrawer",slot:"Paper",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.paper,t[`paperAnchor${ye(n.anchor)}`],n.variant!=="temporary"&&t[`paperAnchorDocked${ye(n.anchor)}`]]}})(Ge(({theme:e})=>({overflowY:"auto",display:"flex",flexDirection:"column",height:"100%",flex:"1 0 auto",zIndex:(e.vars||e).zIndex.drawer,WebkitOverflowScrolling:"touch",position:"fixed",top:0,outline:0,variants:[{props:{anchor:"left"},style:{left:0}},{props:{anchor:"top"},style:{top:0,left:0,right:0,height:"auto",maxHeight:"100%"}},{props:{anchor:"right"},style:{right:0}},{props:{anchor:"bottom"},style:{top:"auto",left:0,bottom:0,right:0,height:"auto",maxHeight:"100%"}},{props:({ownerState:t})=>t.anchor==="left"&&t.variant!=="temporary",style:{borderRight:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>t.anchor==="top"&&t.variant!=="temporary",style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>t.anchor==="right"&&t.variant!=="temporary",style:{borderLeft:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>t.anchor==="bottom"&&t.variant!=="temporary",style:{borderTop:`1px solid ${(e.vars||e).palette.divider}`}}]}))),Kle={left:"right",right:"left",top:"down",bottom:"up"};function tut(e){return["left","right"].includes(e)}function nut({direction:e},t){return e==="rtl"&&tut(t)?Kle[t]:t}const rut=_.forwardRef(function(t,n){const r=ot({props:t,name:"MuiDrawer"}),i=Oa(),o=mf(),s={enter:i.transitions.duration.enteringScreen,exit:i.transitions.duration.leavingScreen},{anchor:a="left",BackdropProps:l,children:c,className:u,elevation:f=16,hideBackdrop:h=!1,ModalProps:{BackdropProps:g,...y}={},onClose:b,open:v=!1,PaperProps:S={},SlideProps:C,TransitionComponent:w,transitionDuration:A=s,variant:E="temporary",slots:O={},slotProps:D={},...T}=r,I=_.useRef(!1);_.useEffect(()=>{I.current=!0},[]);const N=nut({direction:o?"rtl":"ltr"},a),R={...r,anchor:a,elevation:f,open:v,variant:E,...T},L=Zct(R),P={slots:{transition:w,...O},slotProps:{paper:S,transition:C,...D,backdrop:NO(D.backdrop||{...l,...g},{transitionDuration:A})}},[z,F]=ct("root",{ref:n,elementType:Jct,className:Oe(L.root,L.modal,u),shouldForwardComponentProp:!0,ownerState:R,externalForwardedProps:{...P,...T,...y},additionalProps:{open:v,onClose:b,hideBackdrop:h,slots:{backdrop:P.slots.backdrop},slotProps:{backdrop:P.slotProps.backdrop}}}),[W,H]=ct("paper",{elementType:eut,shouldForwardComponentProp:!0,className:Oe(L.paper,S.className),ownerState:R,externalForwardedProps:P,additionalProps:{elevation:E==="temporary"?f:0,square:!0,...E==="temporary"&&{role:"dialog","aria-modal":"true"}}}),[U,K]=ct("docked",{elementType:Qct,ref:n,className:Oe(L.root,L.docked,u),ownerState:R,externalForwardedProps:P,additionalProps:T}),[B,q]=ct("transition",{elementType:Yct,ownerState:R,externalForwardedProps:P,additionalProps:{in:v,direction:Kle[N],timeout:A,appear:I.current}}),X=p.jsx(W,{...H,children:c});if(E==="permanent")return p.jsx(U,{...K,children:X});const V=p.jsx(B,{...q,children:X});return E==="persistent"?p.jsx(U,{...K,children:V}):p.jsx(z,{...F,children:V})}),iut=XY({themeId:ua}),ak={error:"#d32f2f",warn:"#ed6c02",info:"#0288d1",debug:"#7b1fa2"},out={error:Iu,warn:lw,info:mw,debug:Tw},sut=({open:e,onClose:t})=>{const[n,r]=_.useState([]),[i,o]=_.useState(!0),[s,a]=_.useState("error,warn,info".split(",")),[l,c]=_.useState(""),[u,f]=_.useState(!0),h=_.useCallback(async()=>{try{const S=new URLSearchParams({level:s.join(","),limit:"500",...l&&{search:l}}),C=await fetch(`api/logs?${S}`);if(C.ok){const w=await C.json();r(w.entries)}}catch(S){console.error("Failed to fetch logs:",S)}finally{o(!1)}},[s,l]);_.useEffect(()=>{e&&h()},[e,h]),_.useEffect(()=>{if(!u||!e)return;const S=setInterval(h,5e3);return()=>clearInterval(S)},[u,e,h]);const g=S=>{a(Array.isArray(S.target.value)?S.target.value:[S.target.value])},y=S=>{c(S.target.value)},b=async()=>{try{await fetch("api/logs",{method:"DELETE"}),r([])}catch(S){console.error("Failed to clear logs:",S)}},v=S=>{const C=out[S]||mw;return p.jsx(C,{sx:{fontSize:16,color:ak[S]}})};return p.jsxs(xu,{open:e,onClose:t,maxWidth:"lg",fullWidth:!0,children:[p.jsxs(wu,{sx:{display:"flex",alignItems:"center",gap:1},children:[p.jsx(Tw,{}),"System Logs",p.jsx(oe,{sx:{flexGrow:1}}),p.jsx(Jt,{title:"Auto Refresh",children:p.jsx(xt,{label:u?"Auto":"Manual",color:u?"success":"default",size:"small",onClick:()=>f(!u),sx:{cursor:"pointer"}})}),p.jsx(mn,{onClick:t,children:p.jsx(KCe,{})})]}),p.jsxs(Su,{children:[p.jsx(Bt,{spacing:2,sx:{mb:2},children:p.jsxs(Bt,{direction:"row",spacing:2,alignItems:"center",children:[p.jsxs(ha,{size:"small",sx:{minWidth:200},children:[p.jsx(ac,{children:"Log Level"}),p.jsxs(oa,{value:s,label:"Log Level",onChange:g,multiple:!0,renderValue:S=>p.jsx(oe,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:(Array.isArray(S)?S:[S]).map(C=>p.jsx(xt,{label:C.toUpperCase(),size:"small",sx:{backgroundColor:ak[C],color:"white"}},C))}),children:[p.jsx(nr,{value:"error",children:"Error"}),p.jsx(nr,{value:"warn",children:"Warning"}),p.jsx(nr,{value:"info",children:"Info"}),p.jsx(nr,{value:"debug",children:"Debug"})]})]}),p.jsx(Tr,{size:"small",placeholder:"Search logs...",value:l,onChange:y,sx:{flexGrow:1}}),p.jsx(At,{variant:"outlined",onClick:h,children:"Refresh"}),p.jsx(At,{variant:"outlined",color:"error",onClick:b,children:"Clear"})]})}),p.jsx(oe,{sx:{height:400,overflow:"auto",backgroundColor:"background.paper",border:1,borderColor:"divider",borderRadius:1,p:1},children:i?p.jsx(oe,{sx:{display:"flex",justifyContent:"center",p:4},children:p.jsx(re,{children:"Loading logs..."})}):n.length===0?p.jsx(oe,{sx:{display:"flex",justifyContent:"center",p:4},children:p.jsx(re,{color:"text.secondary",children:"No logs found"})}):p.jsx(Bt,{spacing:1,children:n.map((S,C)=>p.jsxs(oe,{sx:{p:1,borderRadius:1,backgroundColor:"action.hover",fontFamily:"monospace",fontSize:"0.875rem",wordBreak:"break-all"},children:[p.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[v(S.level),p.jsx(re,{variant:"caption",color:"text.secondary",children:new Date(S.timestamp).toLocaleString()}),p.jsx(xt,{label:S.level.toUpperCase(),size:"small",sx:{backgroundColor:ak[S.level],color:"white",fontSize:"0.7rem",height:20}})]}),p.jsx(re,{sx:{ml:3},children:S.message}),S.context&&p.jsx(re,{sx:{ml:3,color:"text.secondary",fontSize:"0.8rem"},children:JSON.stringify(S.context,null,2)})]},`${S.timestamp}-${S.level}-${C}`))})})]}),p.jsx(Jd,{children:p.jsx(At,{onClick:t,children:"Close"})})]})};function BK(){const{isConnected:e}=D2e(),[t,n]=_.useState(null),[r,i]=_.useState(!1);_.useEffect(()=>{const y=async()=>{try{const v=await fetch("api/health");if(v.ok){const S=await v.json();n(S),i(!1)}else i(!0)}catch{i(!0)}};y();const b=setInterval(y,3e4);return()=>clearInterval(b)},[]);const o=y=>{const b=Math.floor(y/3600),v=Math.floor(y%3600/60);return b>0?`${b}h ${v}m`:`${v}m`},s=t?.status==="healthy"&&!r,a=t?.services?.bridges,l=a&&a.total>0&&a.running===a.total,c=a&&a.total===0,u=t?p.jsxs(oe,{sx:{p:.5},children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Version:"})," ",t.version??"Unknown"]}),p.jsxs("div",{children:[p.jsx("strong",{children:"Uptime:"})," ",o(t.uptime??0)]}),t.services?.bridges&&p.jsxs("div",{children:[p.jsx("strong",{children:"Bridges:"})," ",t.services.bridges.running??0,"/",t.services.bridges.total??0," running",(t.services.bridges.stopped??0)>0&&` (${t.services.bridges.stopped} stopped)`]}),t.services?.homeAssistant&&p.jsxs("div",{children:[p.jsx("strong",{children:"Home Assistant:"})," ",t.services.homeAssistant.connected?"Connected":"Disconnected"]}),p.jsxs("div",{children:[p.jsx("strong",{children:"WebSocket:"})," ",e?"Connected":"Disconnected"]})]}):"Loading health status...",f=()=>r||!s?p.jsx(Iu,{fontSize:"small"}):l?p.jsx(xc,{fontSize:"small"}):p.jsx(gw,{fontSize:"small"}),h=()=>r||!s?"error":!l||!e?"warning":"success",g=()=>r?"Error":s?e?c?"No Bridges":l?"Online":"Starting":"Offline":"Unhealthy";return p.jsx(Jt,{title:u,arrow:!0,children:p.jsx(xt,{icon:f(),label:g(),color:h(),size:"small",variant:"filled",sx:{borderRadius:1,fontWeight:600,"& .MuiChip-icon":{color:"inherit"}}})})}const aut=e=>_.createElement("svg",{viewBox:"0 0 91 89",xmlSpace:"preserve",xmlns:"http://www.w3.org/2000/svg",...e},_.createElement("g",{style:{display:"inline"}},_.createElement("path",{style:{fill:"#18bcf2",fillOpacity:1,strokeWidth:.266194},d:"m 49.149143,1.473171 38.513568,38.536435 c 0,0 1.248354,1.186052 2.207681,3.092371 0.959329,1.906323 1.10864,4.600698 1.10864,4.600698 v 36.786372 c 0,0 -0.01549,1.748506 -1.49842,3.050572 -1.482931,1.302064 -3.333077,1.362947 -3.333077,1.362947 l -81.325658,7.7e-5 c 0,0 -1.7523855,-0.0091 -3.17112,-1.352526 C -0.07808495,85.913164 0.05953025,84.487808 0.05953025,84.487808 V 47.704546 c 0,0 -0.0018381,-2.218618 0.95921785,-4.315832 0.9610554,-2.097209 2.3010618,-3.355005 2.3010618,-3.355005 L 41.545959,1.4719546 c 0,0 1.465224,-1.46837077 3.753488,-1.46837077 2.288268,0 3.849696,1.46958717 3.849696,1.46958717 z"}),_.createElement("path",{style:{fill:"#ffffff",fillOpacity:1,strokeWidth:.175841},d:"m 31.689717,32.051124 c 2.813363,2.331095 6.157331,3.89845 9.721813,4.556421 V 17.180647 l 3.873694,-2.282955 3.870527,2.282955 V 36.60772 c 3.565364,-0.658847 6.910387,-2.226204 9.725159,-4.556417 l 7.032345,4.154609 c -11.437354,11.557779 -29.852321,11.557779 -41.290025,0 z m 8.546732,49.60988 C 44.314996,65.760441 35.09933,49.470196 19.574984,45.139543 v 8.312381 c 3.383916,1.32244 6.386113,3.496288 8.728705,6.320026 L 11.83076,69.485301 v 4.56907 l 3.873697,2.270836 16.469936,-9.713534 c 1.224356,3.48294 1.56683,7.225375 0.996449,10.879778 z M 70.977694,45.139543 c -15.515726,4.34014 -24.72189,20.626696 -20.643519,36.521461 l 7.047658,-4.15742 c -0.569325,-3.654411 -0.2265,-7.3965 0.996449,-10.87979 l 16.457611,9.701233 3.870711,-2.283125 v -4.55677 L 62.233673,59.77195 c 2.342772,-2.822684 5.34497,-4.996533 8.728708,-6.320026 z"}))),lut="home-assistant-matter-hub",cut={name:lut};function uut(){const[e,t]=_.useState("4.1.0-testing.23");return _.useEffect(()=>{fetch("api/health").then(n=>n.ok?n.json():null).then(n=>{n?.version&&t(n.version)}).catch(()=>{})},[]),_.useMemo(()=>({name:cut.name,version:e}),[e])}const dut=e=>{const t=uut();return p.jsxs(oe,{component:Tu,to:jt.dashboard,sx:{display:"flex",alignItems:"center",justifyContent:e.large?"flex-start":"center",flexGrow:1,textDecoration:"none",color:"inherit"},children:[p.jsx(aut,{style:{height:"40px"}}),p.jsx(re,{variant:"inherit",component:"span",sx:{mr:1,ml:1},children:t.name.split("-").map(ye).join("-")}),e.large&&p.jsx(re,{variant:"caption",component:"span",children:t.version})]})},fut=()=>{const e=iut("(min-width:600px)"),{mode:t,setMode:n}=JS(),[r,i]=_.useState(!1),[o,s]=_.useState(!1),a=Jh(),l=()=>{n(t==="dark"?"light":"dark")},c=[{label:"Dashboard",icon:p.jsx(r_,{}),to:jt.dashboard},{label:"Bridges",icon:p.jsx(my,{}),to:jt.bridges},{label:"All Devices",icon:p.jsx(Bo,{}),to:jt.devices},{label:"Network Map",icon:p.jsx(i6,{}),to:jt.networkMap},{label:"Startup Order",icon:p.jsx(am,{}),to:jt.startup},{label:"Lock Credentials",icon:p.jsx(lc,{}),to:jt.lockCredentials},{label:"Filter Reference",icon:p.jsx(o6,{}),to:jt.labels},{label:"Plugins",icon:p.jsx(N0,{}),to:jt.plugins},{label:"Settings",icon:p.jsx(mm,{}),to:jt.settings},{label:t==="dark"?"Light Mode":"Dark Mode",icon:t==="dark"?p.jsx(a8e,{}):p.jsx(ZCe,{}),onClick:l},{label:"System Logs",icon:p.jsx(Tw,{}),onClick:()=>i(!0)},{label:"Health Dashboard",icon:p.jsx(Z4,{}),to:jt.health}],u=f=>{s(!1),f.onClick?f.onClick():f.to&&a(f.to)};return p.jsxs(oe,{children:[p.jsx(qct,{sx:{height:"72px"},children:p.jsx(qle,{sx:{paddingLeft:"0 !important",paddingRight:"0 !important"},children:p.jsxs(OI,{sx:{padding:2,height:"100%",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsx(dut,{large:e}),e?p.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:1},children:[c.map(f=>f.to?p.jsx(Jt,{title:f.label,children:p.jsx(mn,{component:Tu,to:f.to,sx:{color:"inherit"},children:f.icon})},f.label):p.jsx(Jt,{title:f.label,children:p.jsx(mn,{onClick:f.onClick,sx:{color:"inherit"},children:f.icon})},f.label)),p.jsx(BK,{})]}):p.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:.5},children:[p.jsx(BK,{}),p.jsx(mn,{onClick:()=>s(!0),sx:{color:"inherit"},children:p.jsx(l8e,{})})]})]})})}),p.jsx(rut,{anchor:"right",open:o,onClose:()=>s(!1),children:p.jsx(vc,{sx:{width:250},children:c.map(f=>p.jsxs(lbe,{onClick:()=>u(f),children:[p.jsx(Vl,{children:f.icon}),p.jsx(Va,{primary:f.label})]},f.label))})}),p.jsx(sut,{open:r,onClose:()=>i(!1)})]})},hut=()=>p.jsxs(oe,{children:[p.jsx(fut,{}),p.jsx(qle,{}),p.jsx(OI,{sx:{p:2},children:p.jsx(yY,{})}),p.jsx(Hct,{})]}),put=YS({colorSchemes:{light:{palette:{primary:{main:"#1976d2",light:"#42a5f5",dark:"#1565c0"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2"},background:{default:"#f5f5f5",paper:"#ffffff"}}},dark:{palette:{primary:{main:"#90caf9",light:"#e3f2fd",dark:"#42a5f5"},secondary:{main:"#ce93d8",light:"#f3e5f5",dark:"#ab47bc"},background:{default:"#121212",paper:"#1e1e1e"}}}},typography:{fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',h1:{fontSize:"2.5rem",fontWeight:500},h2:{fontSize:"2rem",fontWeight:500},h3:{fontSize:"1.75rem",fontWeight:500},h4:{fontSize:"1.5rem",fontWeight:500},h5:{fontSize:"1.25rem",fontWeight:500},h6:{fontSize:"1rem",fontWeight:500}},shape:{borderRadius:8},components:{MuiCard:{styleOverrides:{root:{transition:"transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out","&:hover":{transform:"translateY(-2px)",boxShadow:"0 4px 20px rgba(0,0,0,0.12)"}}}},MuiButton:{styleOverrides:{root:{textTransform:"none",fontWeight:500}}},MuiChip:{styleOverrides:{root:{fontWeight:500}}},MuiAppBar:{styleOverrides:{root:{backgroundImage:"none"}}}}});let O4=document.getElementsByTagName("base")[0]?.href?.replace(/\/$/,"");O4?.startsWith("http")&&(O4=new URL(O4).pathname);const mut=Whe([{path:"/",element:p.jsx(hut,{}),children:Mct}],{basename:O4});cde.createRoot(document.getElementById("root")).render(p.jsx(_.StrictMode,{children:p.jsx(kde,{store:Lct,children:p.jsxs(o1e,{theme:put,children:[p.jsx(e1e,{}),p.jsx(dX,{styles:{".rjsf-field-array > .MuiFormControl-root > .MuiPaper-root > .MuiBox-root > .MuiGrid-root > .MuiGrid-root:has(> .MuiBox-root > .MuiPaper-root > .MuiBox-root > .rjsf-field)":{overflow:"initial !important",flexGrow:1}}}),p.jsx(O2e,{children:p.jsx(xye,{children:p.jsx(rpe,{router:mut})})})]})})}));
499
+ `},elt={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 tlt(e){let{announcements:t=elt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Qat}=e;const{announce:o,announcement:s}=Xat(),a=cv("DndLiveRegion"),[l,c]=_.useState(!1);if(_.useEffect(()=>{c(!0)},[]),Zat(_.useMemo(()=>({onDragStart(f){let{active:h}=f;o(t.onDragStart({active:h}))},onDragMove(f){let{active:h,over:g}=f;t.onDragMove&&o(t.onDragMove({active:h,over:g}))},onDragOver(f){let{active:h,over:g}=f;o(t.onDragOver({active:h,over:g}))},onDragEnd(f){let{active:h,over:g}=f;o(t.onDragEnd({active:h,over:g}))},onDragCancel(f){let{active:h,over:g}=f;o(t.onDragCancel({active:h,over:g}))}}),[o,t])),!l)return null;const u=qt.createElement(qt.Fragment,null,qt.createElement(Kat,{id:r,value:i.draggable}),qt.createElement(Yat,{id:a,announcement:s}));return n?Td.createPortal(u,n):u}var Li;(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"})(Li||(Li={}));function _S(){}function kK(e,t){return _.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function nlt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return _.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const al=Object.freeze({x:0,y:0});function kle(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function _le(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function rlt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function _K(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function Dle(e,t){if(!e||e.length===0)return null;const[n]=e;return n[t]}function DK(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 ilt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=DK(t,t.left,t.top),o=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=kle(DK(l),i);o.push({id:a,data:{droppableContainer:s,value:c}})}}return o.sort(_le)},olt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=_K(t),o=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=_K(l),u=i.reduce((h,g,y)=>h+kle(c[y],g),0),f=Number((u/4).toFixed(4));o.push({id:a,data:{droppableContainer:s,value:f}})}}return o.sort(_le)};function slt(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),o=Math.min(t.top+t.height,e.top+e.height),s=i-r,a=o-n;if(r<i&&n<o){const l=t.width*t.height,c=e.width*e.height,u=s*a,f=u/(l+c-u);return Number(f.toFixed(4))}return 0}const alt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const i=[];for(const o of r){const{id:s}=o,a=n.get(s);if(a){const l=slt(a,t);l>0&&i.push({id:s,data:{droppableContainer:o,value:l}})}}return i.sort(rlt)};function llt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function Ole(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:al}function clt(e){return function(n){for(var r=arguments.length,i=new Array(r>1?r-1:0),o=1;o<r;o++)i[o-1]=arguments[o];return i.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 ult=clt(1);function dlt(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 flt(e,t,n){const r=dlt(t);if(!r)return e;const{scaleX:i,scaleY:o,x:s,y:a}=r,l=e.left-s-(1-i)*parseFloat(n),c=e.top-a-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),u=i?e.width/i:e.width,f=o?e.height/o:e.height;return{width:u,height:f,top:c,right:l+u,bottom:c+f,left:l}}const hlt={ignoreTransform:!1};function yg(e,t){t===void 0&&(t=hlt);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:u}=fs(e).getComputedStyle(e);c&&(n=flt(n,c,u))}const{top:r,left:i,width:o,height:s,bottom:a,right:l}=n;return{top:r,left:i,width:o,height:s,bottom:a,right:l}}function OK(e){return yg(e,{ignoreTransform:!0})}function plt(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function mlt(e,t){return t===void 0&&(t=fs(e).getComputedStyle(e)),t.position==="fixed"}function glt(e,t){t===void 0&&(t=fs(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(i=>{const o=t[i];return typeof o=="string"?n.test(o):!1})}function JC(e,t){const n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(SI(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!av(i)||Cle(i)||n.includes(i))return n;const o=fs(e).getComputedStyle(i);return i!==e&&glt(i,o)&&n.push(i),mlt(i,o)?n:r(i.parentNode)}return e?r(e):n}function Tle(e){const[t]=JC(e,1);return t??null}function nk(e){return!ZC||!e?null:mg(e)?e:xI(e)?SI(e)||e===gg(e).scrollingElement?window:av(e)?e:null:null}function Mle(e){return mg(e)?e.scrollX:e.scrollLeft}function Rle(e){return mg(e)?e.scrollY:e.scrollTop}function iO(e){return{x:Mle(e),y:Rle(e)}}var Xi;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(Xi||(Xi={}));function Ile(e){return!ZC||!e?!1:e===document.scrollingElement}function jle(e){const t={x:0,y:0},n=Ile(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height},i=e.scrollTop<=t.y,o=e.scrollLeft<=t.x,s=e.scrollTop>=r.y,a=e.scrollLeft>=r.x;return{isTop:i,isLeft:o,isBottom:s,isRight:a,maxScroll:r,minScroll:t}}const ylt={x:.2,y:.2};function blt(e,t,n,r,i){let{top:o,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),i===void 0&&(i=ylt);const{isTop:c,isBottom:u,isLeft:f,isRight:h}=jle(e),g={x:0,y:0},y={x:0,y:0},b={height:t.height*i.y,width:t.width*i.x};return!c&&o<=t.top+b.height?(g.y=Xi.Backward,y.y=r*Math.abs((t.top+b.height-o)/b.height)):!u&&l>=t.bottom-b.height&&(g.y=Xi.Forward,y.y=r*Math.abs((t.bottom-b.height-l)/b.height)),!h&&a>=t.right-b.width?(g.x=Xi.Forward,y.x=r*Math.abs((t.right-b.width-a)/b.width)):!f&&s<=t.left+b.width&&(g.x=Xi.Backward,y.x=r*Math.abs((t.left+b.width-s)/b.width)),{direction:g,speed:y}}function vlt(e){if(e===document.scrollingElement){const{innerWidth:o,innerHeight:s}=window;return{top:0,left:0,right:o,bottom:s,width:o,height:s}}const{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function Ple(e){return e.reduce((t,n)=>rm(t,iO(n)),al)}function xlt(e){return e.reduce((t,n)=>t+Mle(n),0)}function Slt(e){return e.reduce((t,n)=>t+Rle(n),0)}function wlt(e,t){if(t===void 0&&(t=yg),!e)return;const{top:n,left:r,bottom:i,right:o}=t(e);Tle(e)&&(i<=0||o<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Clt=[["x",["left","right"],xlt],["y",["top","bottom"],Slt]];class EI{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=JC(n),i=Ple(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[o,s,a]of Clt)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=i[o]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Ly{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 i;(i=this.target)==null||i.addEventListener(t,n,r),this.listeners.push([t,n,r])}}function Elt(e){const{EventTarget:t}=fs(e);return e instanceof t?e:gg(e)}function rk(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 ta;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(ta||(ta={}));function TK(e){e.preventDefault()}function Alt(e){e.stopPropagation()}var Ln;(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"})(Ln||(Ln={}));const $le={start:[Ln.Space,Ln.Enter],cancel:[Ln.Esc],end:[Ln.Space,Ln.Enter,Ln.Tab]},klt=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Ln.Right:return{...n,x:n.x+25};case Ln.Left:return{...n,x:n.x-25};case Ln.Down:return{...n,y:n.y+25};case Ln.Up:return{...n,y:n.y-25}}};class AI{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 Ly(gg(n)),this.windowListeners=new Ly(fs(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ta.Resize,this.handleCancel),this.windowListeners.add(ta.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(ta.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:n}=this.props,r=t.node.current;r&&wlt(r),n(al)}handleKeyDown(t){if(CI(t)){const{active:n,context:r,options:i}=this.props,{keyboardCodes:o=$le,coordinateGetter:s=klt,scrollBehavior:a="smooth"}=i,{code:l}=t;if(o.end.includes(l)){this.handleEnd(t);return}if(o.cancel.includes(l)){this.handleCancel(t);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:al;this.referenceCoordinates||(this.referenceCoordinates=u);const f=s(t,{active:n,context:r.current,currentCoordinates:u});if(f){const h=sb(f,u),g={x:0,y:0},{scrollableAncestors:y}=r.current;for(const b of y){const v=t.code,{isTop:S,isRight:C,isLeft:w,isBottom:A,maxScroll:E,minScroll:O}=jle(b),D=vlt(b),T={x:Math.min(v===Ln.Right?D.right-D.width/2:D.right,Math.max(v===Ln.Right?D.left:D.left+D.width/2,f.x)),y:Math.min(v===Ln.Down?D.bottom-D.height/2:D.bottom,Math.max(v===Ln.Down?D.top:D.top+D.height/2,f.y))},I=v===Ln.Right&&!C||v===Ln.Left&&!w,N=v===Ln.Down&&!A||v===Ln.Up&&!S;if(I&&T.x!==f.x){const $=b.scrollLeft+h.x,R=v===Ln.Right&&$<=E.x||v===Ln.Left&&$>=O.x;if(R&&!h.y){b.scrollTo({left:$,behavior:a});return}R?g.x=b.scrollLeft-$:g.x=v===Ln.Right?b.scrollLeft-E.x:b.scrollLeft-O.x,g.x&&b.scrollBy({left:-g.x,behavior:a});break}else if(N&&T.y!==f.y){const $=b.scrollTop+h.y,R=v===Ln.Down&&$<=E.y||v===Ln.Up&&$>=O.y;if(R&&!h.x){b.scrollTo({top:$,behavior:a});return}R?g.y=b.scrollTop-$:g.y=v===Ln.Down?b.scrollTop-E.y:b.scrollTop-O.y,g.y&&b.scrollBy({top:-g.y,behavior:a});break}}this.handleMove(t,rm(sb(f,this.referenceCoordinates),g))}}}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()}}AI.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=$le,onActivation:i}=t,{active:o}=n;const{code:s}=e.nativeEvent;if(r.start.includes(s)){const a=o.activatorNode.current;return a&&e.target!==a?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function MK(e){return!!(e&&"distance"in e)}function RK(e){return!!(e&&"delay"in e)}class kI{constructor(t,n,r){var i;r===void 0&&(r=Elt(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:o}=t,{target:s}=o;this.props=t,this.events=n,this.document=gg(s),this.documentListeners=new Ly(this.document),this.listeners=new Ly(r),this.windowListeners=new Ly(fs(s)),this.initialCoordinates=(i=rO(o))!=null?i:al,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(ta.Resize,this.handleCancel),this.windowListeners.add(ta.DragStart,TK),this.windowListeners.add(ta.VisibilityChange,this.handleCancel),this.windowListeners.add(ta.ContextMenu,TK),this.documentListeners.add(ta.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(RK(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(MK(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:i}=this.props;i(r,t,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:t}=this,{onStart:n}=this.props;t&&(this.activated=!0,this.documentListeners.add(ta.Click,Alt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ta.SelectionChange,this.removeTextSelection),n(t))}handleMove(t){var n;const{activated:r,initialCoordinates:i,props:o}=this,{onMove:s,options:{activationConstraint:a}}=o;if(!i)return;const l=(n=rO(t))!=null?n:al,c=sb(i,l);if(!r&&a){if(MK(a)){if(a.tolerance!=null&&rk(c,a.tolerance))return this.handleCancel();if(rk(c,a.distance))return this.handleStart()}if(RK(a)&&rk(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);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===Ln.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const _lt={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class _I extends kI{constructor(t){const{event:n}=t,r=gg(n.target);super(t,_lt,r)}}_I.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 Dlt={move:{name:"mousemove"},end:{name:"mouseup"}};var oO;(function(e){e[e.RightClick=2]="RightClick"})(oO||(oO={}));class Olt extends kI{constructor(t){super(t,Dlt,gg(t.event.target))}}Olt.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===oO.RightClick?!1:(r?.({event:n}),!0)}}];const ik={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Tlt extends kI{constructor(t){super(t,ik)}static setup(){return window.addEventListener(ik.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(ik.move.name,t)};function t(){}}}Tlt.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var Ny;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(Ny||(Ny={}));var DS;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(DS||(DS={}));function Mlt(e){let{acceleration:t,activator:n=Ny.Pointer,canScroll:r,draggingRect:i,enabled:o,interval:s=5,order:a=DS.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:f,threshold:h}=e;const g=Ilt({delta:f,disabled:!o}),[y,b]=Uat(),v=_.useRef({x:0,y:0}),S=_.useRef({x:0,y:0}),C=_.useMemo(()=>{switch(n){case Ny.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Ny.DraggableRect:return i}},[n,i,l]),w=_.useRef(null),A=_.useCallback(()=>{const O=w.current;if(!O)return;const D=v.current.x*S.current.x,T=v.current.y*S.current.y;O.scrollBy(D,T)},[]),E=_.useMemo(()=>a===DS.TreeOrder?[...c].reverse():c,[a,c]);_.useEffect(()=>{if(!o||!c.length||!C){b();return}for(const O of E){if(r?.(O)===!1)continue;const D=c.indexOf(O),T=u[D];if(!T)continue;const{direction:I,speed:N}=blt(O,T,C,t,h);for(const $ of["x","y"])g[$][I[$]]||(N[$]=0,I[$]=0);if(N.x>0||N.y>0){b(),w.current=O,y(A,s),v.current=N,S.current=I;return}}v.current={x:0,y:0},S.current={x:0,y:0},b()},[t,A,r,b,o,s,JSON.stringify(C),JSON.stringify(g),y,c,E,u,JSON.stringify(h)])}const Rlt={x:{[Xi.Backward]:!1,[Xi.Forward]:!1},y:{[Xi.Backward]:!1,[Xi.Forward]:!1}};function Ilt(e){let{delta:t,disabled:n}=e;const r=nO(t);return lv(i=>{if(n||!r||!i)return Rlt;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Xi.Backward]:i.x[Xi.Backward]||o.x===-1,[Xi.Forward]:i.x[Xi.Forward]||o.x===1},y:{[Xi.Backward]:i.y[Xi.Backward]||o.y===-1,[Xi.Forward]:i.y[Xi.Forward]||o.y===1}}},[n,t,r])}function jlt(e,t){const n=t!=null?e.get(t):void 0,r=n?n.node.current:null;return lv(i=>{var o;return t==null?null:(o=r??i)!=null?o:null},[r,t])}function Plt(e,t){return _.useMemo(()=>e.reduce((n,r)=>{const{sensor:i}=r,o=i.activators.map(s=>({eventName:s.eventName,handler:t(s.handler,r)}));return[...n,...o]},[]),[e,t])}var lb;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(lb||(lb={}));var sO;(function(e){e.Optimized="optimized"})(sO||(sO={}));const IK=new Map;function $lt(e,t){let{dragging:n,dependencies:r,config:i}=t;const[o,s]=_.useState(null),{frequency:a,measure:l,strategy:c}=i,u=_.useRef(e),f=v(),h=ob(f),g=_.useCallback(function(S){S===void 0&&(S=[]),!h.current&&s(C=>C===null?S:C.concat(S.filter(w=>!C.includes(w))))},[h]),y=_.useRef(null),b=lv(S=>{if(f&&!n)return IK;if(!S||S===IK||u.current!==e||o!=null){const C=new Map;for(let w of e){if(!w)continue;if(o&&o.length>0&&!o.includes(w.id)&&w.rect.current){C.set(w.id,w.rect.current);continue}const A=w.node.current,E=A?new EI(l(A),A):null;w.rect.current=E,E&&C.set(w.id,E)}return C}return S},[e,o,n,f,l]);return _.useEffect(()=>{u.current=e},[e]),_.useEffect(()=>{f||g()},[n,f]),_.useEffect(()=>{o&&o.length>0&&s(null)},[JSON.stringify(o)]),_.useEffect(()=>{f||typeof a!="number"||y.current!==null||(y.current=setTimeout(()=>{g(),y.current=null},a))},[a,f,g,...r]),{droppableRects:b,measureDroppableContainers:g,measuringScheduled:o!=null};function v(){switch(c){case lb.Always:return!1;case lb.BeforeDragging:return n;default:return!n}}}function Lle(e,t){return lv(n=>e?n||(typeof t=="function"?t(e):e):null,[t,e])}function Llt(e,t){return Lle(e,t)}function Nlt(e){let{callback:t,disabled:n}=e;const r=wI(t),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:o}=window;return new o(r)},[r,n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function QC(e){let{callback:t,disabled:n}=e;const r=wI(t),i=_.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return _.useEffect(()=>()=>i?.disconnect(),[i]),i}function Flt(e){return new EI(yg(e),e)}function jK(e,t,n){t===void 0&&(t=Flt);const[r,i]=_.useState(null);function o(){i(l=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=t(e);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=Nlt({callback(l){if(e)for(const c of l){const{type:u,target:f}=c;if(u==="childList"&&f instanceof HTMLElement&&f.contains(e)){o();break}}}}),a=QC({callback:o});return bc(()=>{o(),e?(a?.observe(e),s?.observe(document.body,{childList:!0,subtree:!0})):(a?.disconnect(),s?.disconnect())},[e]),r}function Blt(e){const t=Lle(e);return Ole(e,t)}const PK=[];function zlt(e){const t=_.useRef(e),n=lv(r=>e?r&&r!==PK&&e&&t.current&&e.parentNode===t.current.parentNode?r:JC(e):PK,[e]);return _.useEffect(()=>{t.current=e},[e]),n}function Hlt(e){const[t,n]=_.useState(null),r=_.useRef(e),i=_.useCallback(o=>{const s=nk(o.target);s&&n(a=>a?(a.set(s,iO(s)),new Map(a)):null)},[]);return _.useEffect(()=>{const o=r.current;if(e!==o){s(o);const a=e.map(l=>{const c=nk(l);return c?(c.addEventListener("scroll",i,{passive:!0}),[c,iO(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=e}return()=>{s(e),s(o)};function s(a){a.forEach(l=>{const c=nk(l);c?.removeEventListener("scroll",i)})}},[i,e]),_.useMemo(()=>e.length?t?Array.from(t.values()).reduce((o,s)=>rm(o,s),al):Ple(e):al,[e,t])}function $K(e,t){t===void 0&&(t=[]);const n=_.useRef(null);return _.useEffect(()=>{n.current=null},t),_.useEffect(()=>{const r=e!==al;r&&!n.current&&(n.current=e),!r&&n.current&&(n.current=null)},[e]),n.current?sb(e,n.current):al}function Ult(e){_.useEffect(()=>{if(!ZC)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 Vlt(e,t){return _.useMemo(()=>e.reduce((n,r)=>{let{eventName:i,handler:o}=r;return n[i]=s=>{o(s,t)},n},{}),[e,t])}function Nle(e){return _.useMemo(()=>e?plt(e):null,[e])}const LK=[];function Wlt(e,t){t===void 0&&(t=yg);const[n]=e,r=Nle(n?fs(n):null),[i,o]=_.useState(LK);function s(){o(()=>e.length?e.map(l=>Ile(l)?r:new EI(t(l),l)):LK)}const a=QC({callback:s});return bc(()=>{a?.disconnect(),s(),e.forEach(l=>a?.observe(l))},[e]),i}function qlt(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return av(t)?t:e}function Glt(e){let{measure:t}=e;const[n,r]=_.useState(null),i=_.useCallback(c=>{for(const{target:u}of c)if(av(u)){r(f=>{const h=t(u);return f?{...f,width:h.width,height:h.height}:h});break}},[t]),o=QC({callback:i}),s=_.useCallback(c=>{const u=qlt(c);o?.disconnect(),u&&o?.observe(u),r(u?t(u):null)},[t,o]),[a,l]=kS(s);return _.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const Klt=[{sensor:_I,options:{}},{sensor:AI,options:{}}],Ylt={current:{}},D4={draggable:{measure:OK},droppable:{measure:OK,strategy:lb.WhileDragging,frequency:sO.Optimized},dragOverlay:{measure:yg}};class Fy 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 Xlt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Fy,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_S},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:D4,measureDroppableContainers:_S,windowRect:null,measuringScheduled:!1},Zlt={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_S,draggableNodes:new Map,over:null,measureDroppableContainers:_S},e8=_.createContext(Zlt),Fle=_.createContext(Xlt);function Jlt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Fy}}}function Qlt(e,t){switch(t.type){case Li.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Li.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 Li.DragEnd:case Li.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Li.RegisterDroppable:{const{element:n}=t,{id:r}=n,i=new Fy(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Li.SetDroppableDisabled:{const{id:n,key:r,disabled:i}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new Fy(e.droppable.containers);return s.set(n,{...o,disabled:i}),{...e,droppable:{...e.droppable,containers:s}}}case Li.UnregisterDroppable:{const{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;const o=new Fy(e.droppable.containers);return o.delete(n),{...e,droppable:{...e.droppable,containers:o}}}default:return e}}function ect(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:i}=_.useContext(e8),o=nO(r),s=nO(n?.id);return _.useEffect(()=>{if(!t&&!r&&o&&s!=null){if(!CI(o)||document.activeElement===o.target)return;const a=i.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const f=qat(u);if(f){f.focus();break}}})}},[r,t,i,s,o]),null}function tct(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((i,o)=>o({transform:i,...r}),n):n}function nct(e){return _.useMemo(()=>({draggable:{...D4.draggable,...e?.draggable},droppable:{...D4.droppable,...e?.droppable},dragOverlay:{...D4.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function rct(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e;const o=_.useRef(!1),{x:s,y:a}=typeof i=="boolean"?{x:i,y:i}:i;bc(()=>{if(!s&&!a||!t){o.current=!1;return}if(o.current||!r)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const u=n(c),f=Ole(u,r);if(s||(f.x=0),a||(f.y=0),o.current=!0,Math.abs(f.x)>0||Math.abs(f.y)>0){const h=Tle(c);h&&h.scrollBy({top:f.y,left:f.x})}},[t,s,a,r,n])}const Ble=_.createContext({...al,scaleX:1,scaleY:1});var wd;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(wd||(wd={}));const ict=_.memo(function(t){var n,r,i,o;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=Klt,collisionDetection:f=alt,measuring:h,modifiers:g,...y}=t;const b=_.useReducer(Qlt,void 0,Jlt),[v,S]=b,[C,w]=Jat(),[A,E]=_.useState(wd.Uninitialized),O=A===wd.Initialized,{draggable:{active:D,nodes:T,translate:I},droppable:{containers:N}}=v,$=D!=null?T.get(D):null,R=_.useRef({initial:null,translated:null}),L=_.useMemo(()=>{var Dt;return D!=null?{id:D,data:(Dt=$?.data)!=null?Dt:Ylt,rect:R}:null},[D,$]),P=_.useRef(null),[z,F]=_.useState(null),[W,H]=_.useState(null),U=ob(y,Object.values(y)),K=cv("DndDescribedBy",s),B=_.useMemo(()=>N.getEnabled(),[N]),q=nct(h),{droppableRects:X,measureDroppableContainers:V,measuringScheduled:Y}=$lt(B,{dragging:O,dependencies:[I.x,I.y],config:q.droppable}),J=jlt(T,D),ne=_.useMemo(()=>W?rO(W):null,[W]),ee=yr(),ae=Llt(J,q.draggable.measure);rct({activeNode:D!=null?T.get(D):null,config:ee.layoutShiftCompensation,initialRect:ae,measure:q.draggable.measure});const ue=jK(J,q.draggable.measure,ae),te=jK(J?J.parentElement:null),Z=_.useRef({activatorEvent:null,active:null,activeNode:J,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:T,draggingNode:null,draggingNodeRect:null,droppableContainers:N,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ie=N.getNodeFor((n=Z.current.over)==null?void 0:n.id),se=Glt({measure:q.dragOverlay.measure}),de=(r=se.nodeRef.current)!=null?r:J,be=O?(i=se.rect)!=null?i:ue:null,Pe=!!(se.nodeRef.current&&se.rect),De=Blt(Pe?null:ue),Ke=Nle(de?fs(de):null),xe=zlt(O?ie??J:null),Le=Wlt(xe),Te=tct(g,{transform:{x:I.x-De.x,y:I.y-De.y,scaleX:1,scaleY:1},activatorEvent:W,active:L,activeNodeRect:ue,containerNodeRect:te,draggingNodeRect:be,over:Z.current.over,overlayNodeRect:se.rect,scrollableAncestors:xe,scrollableAncestorRects:Le,windowRect:Ke}),ht=ne?rm(ne,I):null,mt=Hlt(xe),ze=$K(mt),Ie=$K(mt,[ue]),He=rm(Te,ze),Je=be?ult(be,Te):null,rt=L&&Je?f({active:L,collisionRect:Je,droppableRects:X,droppableContainers:B,pointerCoordinates:ht}):null,st=Dle(rt,"id"),[Xe,Lt]=_.useState(null),Nt=Pe?Te:rm(Te,Ie),Ot=llt(Nt,(o=Xe?.rect)!=null?o:null,ue),Jn=_.useRef(null),sn=_.useCallback((Dt,Pt)=>{let{sensor:en,options:Pn}=Pt;if(P.current==null)return;const an=T.get(P.current);if(!an)return;const wt=Dt.nativeEvent,yn=new en({active:P.current,activeNode:an,event:wt,options:Pn,context:Z,onAbort(br){if(!T.get(br))return;const{onDragAbort:ce}=U.current,pe={id:br};ce?.(pe),C({type:"onDragAbort",event:pe})},onPending(br,ti,ce,pe){if(!T.get(br))return;const{onDragPending:Fe}=U.current,Ue={id:br,constraint:ti,initialCoordinates:ce,offset:pe};Fe?.(Ue),C({type:"onDragPending",event:Ue})},onStart(br){const ti=P.current;if(ti==null)return;const ce=T.get(ti);if(!ce)return;const{onDragStart:pe}=U.current,Se={activatorEvent:wt,active:{id:ti,data:ce.data,rect:R}};Td.unstable_batchedUpdates(()=>{pe?.(Se),E(wd.Initializing),S({type:Li.DragStart,initialCoordinates:br,active:ti}),C({type:"onDragStart",event:Se}),F(Jn.current),H(wt)})},onMove(br){S({type:Li.DragMove,coordinates:br})},onEnd:ei(Li.DragEnd),onCancel:ei(Li.DragCancel)});Jn.current=yn;function ei(br){return async function(){const{active:ce,collisions:pe,over:Se,scrollAdjustedTranslate:Fe}=Z.current;let Ue=null;if(ce&&Fe){const{cancelDrop:yt}=U.current;Ue={activatorEvent:wt,active:ce,collisions:pe,delta:Fe,over:Se},br===Li.DragEnd&&typeof yt=="function"&&await Promise.resolve(yt(Ue))&&(br=Li.DragCancel)}P.current=null,Td.unstable_batchedUpdates(()=>{S({type:br}),E(wd.Uninitialized),Lt(null),F(null),H(null),Jn.current=null;const yt=br===Li.DragEnd?"onDragEnd":"onDragCancel";if(Ue){const it=U.current[yt];it?.(Ue),C({type:yt,event:Ue})}})}}},[T]),lt=_.useCallback((Dt,Pt)=>(en,Pn)=>{const an=en.nativeEvent,wt=T.get(Pn);if(P.current!==null||!wt||an.dndKit||an.defaultPrevented)return;const yn={active:wt};Dt(en,Pt.options,yn)===!0&&(an.dndKit={capturedBy:Pt.sensor},P.current=Pn,sn(en,Pt))},[T,sn]),Ht=Plt(u,lt);Ult(u),bc(()=>{ue&&A===wd.Initializing&&E(wd.Initialized)},[ue,A]),_.useEffect(()=>{const{onDragMove:Dt}=U.current,{active:Pt,activatorEvent:en,collisions:Pn,over:an}=Z.current;if(!Pt||!en)return;const wt={active:Pt,activatorEvent:en,collisions:Pn,delta:{x:He.x,y:He.y},over:an};Td.unstable_batchedUpdates(()=>{Dt?.(wt),C({type:"onDragMove",event:wt})})},[He.x,He.y]),_.useEffect(()=>{const{active:Dt,activatorEvent:Pt,collisions:en,droppableContainers:Pn,scrollAdjustedTranslate:an}=Z.current;if(!Dt||P.current==null||!Pt||!an)return;const{onDragOver:wt}=U.current,yn=Pn.get(st),ei=yn&&yn.rect.current?{id:yn.id,rect:yn.rect.current,data:yn.data,disabled:yn.disabled}:null,br={active:Dt,activatorEvent:Pt,collisions:en,delta:{x:an.x,y:an.y},over:ei};Td.unstable_batchedUpdates(()=>{Lt(ei),wt?.(br),C({type:"onDragOver",event:br})})},[st]),bc(()=>{Z.current={activatorEvent:W,active:L,activeNode:J,collisionRect:Je,collisions:rt,droppableRects:X,draggableNodes:T,draggingNode:de,draggingNodeRect:be,droppableContainers:N,over:Xe,scrollableAncestors:xe,scrollAdjustedTranslate:He},R.current={initial:be,translated:Je}},[L,J,rt,Je,T,de,be,X,N,Xe,xe,He]),Mlt({...ee,delta:I,draggingRect:Je,pointerCoordinates:ht,scrollableAncestors:xe,scrollableAncestorRects:Le});const Dn=_.useMemo(()=>({active:L,activeNode:J,activeNodeRect:ue,activatorEvent:W,collisions:rt,containerNodeRect:te,dragOverlay:se,draggableNodes:T,droppableContainers:N,droppableRects:X,over:Xe,measureDroppableContainers:V,scrollableAncestors:xe,scrollableAncestorRects:Le,measuringConfiguration:q,measuringScheduled:Y,windowRect:Ke}),[L,J,ue,W,rt,te,se,T,N,X,Xe,V,xe,Le,q,Y,Ke]),Kn=_.useMemo(()=>({activatorEvent:W,activators:Ht,active:L,activeNodeRect:ue,ariaDescribedById:{draggable:K},dispatch:S,draggableNodes:T,over:Xe,measureDroppableContainers:V}),[W,Ht,L,ue,S,K,T,Xe,V]);return qt.createElement(Ale.Provider,{value:w},qt.createElement(e8.Provider,{value:Kn},qt.createElement(Fle.Provider,{value:Dn},qt.createElement(Ble.Provider,{value:Ot},c)),qt.createElement(ect,{disabled:a?.restoreFocus===!1})),qt.createElement(tlt,{...a,hiddenTextDescribedById:K}));function yr(){const Dt=z?.autoScrollEnabled===!1,Pt=typeof l=="object"?l.enabled===!1:l===!1,en=O&&!Dt&&!Pt;return typeof l=="object"?{...l,enabled:en}:{enabled:en}}}),oct=_.createContext(null),NK="button",sct="Draggable";function act(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e;const o=cv(sct),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:f,over:h}=_.useContext(e8),{role:g=NK,roleDescription:y="draggable",tabIndex:b=0}=i??{},v=l?.id===t,S=_.useContext(v?Ble:oct),[C,w]=kS(),[A,E]=kS(),O=Vlt(s,t),D=ob(n);bc(()=>(f.set(t,{id:t,key:o,node:C,activatorNode:A,data:D}),()=>{const I=f.get(t);I&&I.key===o&&f.delete(t)}),[f,t]);const T=_.useMemo(()=>({role:g,tabIndex:b,"aria-disabled":r,"aria-pressed":v&&g===NK?!0:void 0,"aria-roledescription":y,"aria-describedby":u.draggable}),[r,g,b,v,y,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:T,isDragging:v,listeners:r?void 0:O,node:C,over:h,setNodeRef:w,setActivatorNodeRef:E,transform:S}}function lct(){return _.useContext(Fle)}const cct="Droppable",uct={timeout:25};function dct(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e;const o=cv(cct),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=_.useContext(e8),u=_.useRef({disabled:n}),f=_.useRef(!1),h=_.useRef(null),g=_.useRef(null),{disabled:y,updateMeasurementsFor:b,timeout:v}={...uct,...i},S=ob(b??r),C=_.useCallback(()=>{if(!f.current){f.current=!0;return}g.current!=null&&clearTimeout(g.current),g.current=setTimeout(()=>{c(Array.isArray(S.current)?S.current:[S.current]),g.current=null},v)},[v]),w=QC({callback:C,disabled:y||!s}),A=_.useCallback((T,I)=>{w&&(I&&(w.unobserve(I),f.current=!1),T&&w.observe(T))},[w]),[E,O]=kS(A),D=ob(t);return _.useEffect(()=>{!w||!E.current||(w.disconnect(),f.current=!1,w.observe(E.current))},[E,w]),_.useEffect(()=>(a({type:Li.RegisterDroppable,element:{id:r,key:o,disabled:n,node:E,rect:h,data:D}}),()=>a({type:Li.UnregisterDroppable,key:o,id:r})),[r]),_.useEffect(()=>{n!==u.current.disabled&&(a({type:Li.SetDroppableDisabled,id:r,key:o,disabled:n}),u.current.disabled=n)},[r,o,n,a]),{active:s,rect:h,isOver:l?.id===r,node:E,over:l,setNodeRef:O}}function DI(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function fct(e,t){return e.reduce((n,r,i)=>{const o=t.get(r);return o&&(n[i]=o),n},Array(e.length))}function _5(e){return e!==null&&e>=0}function hct(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 pct(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const zle=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e;const o=DI(t,r,n),s=t[i],a=o[i];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},D5={scaleX:1,scaleY:1},mct=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:i,rects:o,overIndex:s}=e;const a=(t=o[n])!=null?t:r;if(!a)return null;if(i===n){const c=o[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...D5}:null}const l=gct(o,i,n);return i>n&&i<=s?{x:0,y:-a.height-l,...D5}:i<n&&i>=s?{x:0,y:a.height+l,...D5}:{x:0,y:0,...D5}};function gct(e,t,n){const r=e[t],i=e[t-1],o=e[t+1];return r?n<t?i?r.top-(i.top+i.height):o?o.top-(r.top+r.height):0:o?o.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}const Hle="Sortable",Ule=qt.createContext({activeIndex:-1,containerId:Hle,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:zle,disabled:{draggable:!1,droppable:!1}});function yct(e){let{children:t,id:n,items:r,strategy:i=zle,disabled:o=!1}=e;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=lct(),f=cv(Hle,n),h=a.rect!==null,g=_.useMemo(()=>r.map(O=>typeof O=="object"&&"id"in O?O.id:O),[r]),y=s!=null,b=s?g.indexOf(s.id):-1,v=c?g.indexOf(c.id):-1,S=_.useRef(g),C=!hct(g,S.current),w=v!==-1&&b===-1||C,A=pct(o);bc(()=>{C&&y&&u(g)},[C,g,y,u]),_.useEffect(()=>{S.current=g},[g]);const E=_.useMemo(()=>({activeIndex:b,containerId:f,disabled:A,disableTransforms:w,items:g,overIndex:v,useDragOverlay:h,sortedRects:fct(g,l),strategy:i}),[b,f,A.draggable,A.droppable,w,g,v,l,h,i]);return qt.createElement(Ule.Provider,{value:E},t)}const bct=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return DI(n,r,i).indexOf(t)},vct=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:o,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=e;return!c||!r||a!==o&&i===s?!1:n?!0:s!==i&&t===l},xct={duration:200,easing:"ease"},Vle="transform",Sct=ab.Transition.toString({property:Vle,duration:0,easing:"linear"}),wct={roleDescription:"sortable"};function Cct(e){let{disabled:t,index:n,node:r,rect:i}=e;const[o,s]=_.useState(null),a=_.useRef(n);return bc(()=>{if(!t&&n!==a.current&&r.current){const l=i.current;if(l){const c=yg(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[t,n,r,i]),_.useEffect(()=>{o&&s(null)},[o]),o}function Ect(e){let{animateLayoutChanges:t=vct,attributes:n,disabled:r,data:i,getNewIndex:o=bct,id:s,strategy:a,resizeObserverConfig:l,transition:c=xct}=e;const{items:u,containerId:f,activeIndex:h,disabled:g,disableTransforms:y,sortedRects:b,overIndex:v,useDragOverlay:S,strategy:C}=_.useContext(Ule),w=Act(r,g),A=u.indexOf(s),E=_.useMemo(()=>({sortable:{containerId:f,index:A,items:u},...i}),[f,i,A,u]),O=_.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:D,node:T,isOver:I,setNodeRef:N}=dct({id:s,data:E,disabled:w.droppable,resizeObserverConfig:{updateMeasurementsFor:O,...l}}),{active:$,activatorEvent:R,activeNodeRect:L,attributes:P,setNodeRef:z,listeners:F,isDragging:W,over:H,setActivatorNodeRef:U,transform:K}=act({id:s,data:E,attributes:{...wct,...n},disabled:w.draggable}),B=Hat(N,z),q=!!$,X=q&&!y&&_5(h)&&_5(v),V=!S&&W,Y=V&&X?K:null,ne=X?Y??(a??C)({rects:b,activeNodeRect:L,activeIndex:h,overIndex:v,index:A}):null,ee=_5(h)&&_5(v)?o({id:s,items:u,activeIndex:h,overIndex:v}):A,ae=$?.id,ue=_.useRef({activeId:ae,items:u,newIndex:ee,containerId:f}),te=u!==ue.current.items,Z=t({active:$,containerId:f,isDragging:W,isSorting:q,id:s,index:A,items:u,newIndex:ue.current.newIndex,previousItems:ue.current.items,previousContainerId:ue.current.containerId,transition:c,wasDragging:ue.current.activeId!=null}),ie=Cct({disabled:!Z,index:A,node:T,rect:D});return _.useEffect(()=>{q&&ue.current.newIndex!==ee&&(ue.current.newIndex=ee),f!==ue.current.containerId&&(ue.current.containerId=f),u!==ue.current.items&&(ue.current.items=u)},[q,ee,f,u]),_.useEffect(()=>{if(ae===ue.current.activeId)return;if(ae!=null&&ue.current.activeId==null){ue.current.activeId=ae;return}const de=setTimeout(()=>{ue.current.activeId=ae},50);return()=>clearTimeout(de)},[ae]),{active:$,activeIndex:h,attributes:P,data:E,rect:D,index:A,newIndex:ee,items:u,isOver:I,isSorting:q,isDragging:W,listeners:F,node:T,overIndex:v,over:H,setNodeRef:B,setActivatorNodeRef:U,setDroppableNodeRef:N,setDraggableNodeRef:z,transform:ie??ne,transition:se()};function se(){if(ie||te&&ue.current.newIndex===A)return Sct;if(!(V&&!CI(R)||!c)&&(q||Z))return ab.Transition.toString({...c,property:Vle})}}function Act(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 OS(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 kct=[Ln.Down,Ln.Right,Ln.Up,Ln.Left],_ct=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:o,over:s,scrollableAncestors:a}}=t;if(kct.includes(e.code)){if(e.preventDefault(),!n||!r)return;const l=[];o.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const h=i.get(f.id);if(h)switch(e.code){case Ln.Down:r.top<h.top&&l.push(f);break;case Ln.Up:r.top>h.top&&l.push(f);break;case Ln.Left:r.left>h.left&&l.push(f);break;case Ln.Right:r.left<h.left&&l.push(f);break}});const c=olt({collisionRect:r,droppableRects:i,droppableContainers:l});let u=Dle(c,"id");if(u===s?.id&&c.length>1&&(u=c[1].id),u!=null){const f=o.get(n.id),h=o.get(u),g=h?i.get(h.id):null,y=h?.node.current;if(y&&g&&f&&h){const v=JC(y).some((O,D)=>a[D]!==O),S=Wle(f,h),C=Dct(f,h),w=v||!S?{x:0,y:0}:{x:C?r.width-g.width:0,y:C?r.height-g.height:0},A={x:g.left,y:g.top};return w.x&&w.y?A:sb(A,w)}}}};function Wle(e,t){return!OS(e)||!OS(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Dct(e,t){return!OS(e)||!OS(t)||!Wle(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const Oct=({bridge:e,index:t})=>{const{attributes:n,listeners:r,setNodeRef:i,transform:o,transition:s,isDragging:a}=Ect({id:e.id}),[l,c]=_.useState(!1);_.useEffect(()=>{Iw(e.id).then(c)},[e.id]);const u={transform:ab.Transform.toString(o),transition:s,opacity:a?.5:1};return p.jsx(Bn,{ref:i,style:u,variant:"outlined",sx:{cursor:"grab","&:active":{cursor:"grabbing"},bgcolor:a?"action.selected":"background.paper",width:"fit-content"},children:p.jsxs(Zn,{sx:{display:"flex",alignItems:"center",gap:1.5,py:1,"&:last-child":{pb:1}},children:[p.jsx(oe,{...n,...r,sx:{display:"flex",alignItems:"center",color:"text.secondary"},children:p.jsx(e8e,{})}),p.jsx(xt,{label:t+1,size:"small",color:"primary",sx:{minWidth:32,fontWeight:"bold"}}),l?p.jsx(oe,{component:"img",src:o2(e.id),alt:e.name,sx:{width:40,height:40,borderRadius:"50%",objectFit:"cover",boxShadow:2}}):p.jsx(il,{sx:{bgcolor:RT(e),width:40,height:40,boxShadow:2},children:(()=>{const f=MT(e);return p.jsx(f,{sx:{fontSize:24}})})()}),p.jsxs(oe,{sx:{flex:1},children:[p.jsx(re,{variant:"subtitle1",fontWeight:500,children:e.name}),p.jsxs(re,{variant:"caption",color:"text.secondary",children:["Port: ",e.port," • Priority: ",e.priority??100]})]})]})})},Tct=()=>{const e=Ru(),{content:t,isLoading:n}=Gm(),r=CCe(),[i,o]=_.useState([]),[s,a]=_.useState(!1);_.useEffect(()=>{if(t){const h=[...t].sort((g,y)=>{const b=g.priority??100,v=y.priority??100;return b-v});o(h),a(!1)}},[t]);const l=nlt(kK(_I),kK(AI,{coordinateGetter:_ct})),c=_.useCallback(h=>{const{active:g,over:y}=h;y&&g.id!==y.id&&(o(b=>{const v=b.findIndex(C=>C.id===g.id),S=b.findIndex(C=>C.id===y.id);return DI(b,v,S)}),a(!0))},[]),u=_.useCallback(async()=>{const h=i.map((g,y)=>({id:g.id,priority:(y+1)*10}));try{await r(h),e.show({message:"Startup order saved successfully",severity:"success"}),a(!1)}catch(g){e.show({message:g instanceof Error?g.message:"Failed to save startup order",severity:"error"})}},[i,r,e]),f=_.useMemo(()=>i.map(h=>h.id),[i]);return n?p.jsx(re,{children:"Loading..."}):p.jsxs(Bt,{spacing:3,children:[p.jsx(fw,{items:[{name:"Bridges",to:jt.bridges},{name:"Startup Order",to:jt.startup}]}),p.jsxs(oe,{display:"flex",alignItems:"center",gap:2,children:[p.jsx(am,{color:"primary",fontSize:"large"}),p.jsxs(oe,{children:[p.jsx(re,{variant:"h5",fontWeight:600,children:"Startup Order"}),p.jsx(re,{variant:"body2",color:"text.secondary",children:"Drag and drop bridges to set the startup order. Lower positions start first."})]})]}),s&&p.jsx(Qt,{severity:"info",action:p.jsx(At,{color:"inherit",size:"small",startIcon:p.jsx(s6,{}),onClick:u,children:"Save Changes"}),children:"You have unsaved changes to the startup order."}),p.jsx(ict,{sensors:l,collisionDetection:ilt,onDragEnd:c,children:p.jsx(yct,{items:f,strategy:mct,children:p.jsx(Bt,{spacing:1,children:i.map((h,g)=>p.jsx(Oct,{bridge:h,index:g},h.id))})})}),i.length===0&&p.jsx(re,{color:"text.secondary",textAlign:"center",py:4,children:"No bridges configured yet."}),s&&i.length>0&&p.jsx(oe,{display:"flex",justifyContent:"flex-end",children:p.jsx(At,{variant:"contained",startIcon:p.jsx(s6,{}),onClick:u,children:"Save Startup Order"})})]})},ok="https://riddix.github.io/home-assistant-matter-hub",jt={dashboard:"/",bridges:"/bridges",bridge:e=>`/bridges/${e}`,createBridge:"/bridges/create",editBridge:e=>`/bridges/${e}/edit`,devices:"/devices",networkMap:"/network-map",health:"/health",labels:"/labels",lockCredentials:"/lock-credentials",plugins:"/plugins",settings:"/settings",startup:"/startup",githubRepository:"https://github.com/riddix/home-assistant-matter-hub/",documentation:ok,faq:{multiFabric:`${ok}/connect-multiple-fabrics`,bridgeConfig:`${ok}/bridge-configuration`}},Mct=[{path:"",element:p.jsx(T2e,{}),children:[{path:"",element:p.jsx(c9e,{})},{path:jt.bridges,element:p.jsx(s9e,{})},{path:jt.createBridge,element:p.jsx(ZQe,{})},{path:jt.bridge(":bridgeId"),element:p.jsx(PCe,{})},{path:jt.editBridge(":bridgeId"),element:p.jsx(JQe,{})},{path:jt.devices,element:p.jsx(_9e,{})},{path:jt.networkMap,element:p.jsx(Dat,{})},{path:jt.health,element:p.jsx(set,{})},{path:jt.labels,element:p.jsx(det,{})},{path:jt.lockCredentials,element:p.jsx(yet,{})},{path:jt.plugins,element:p.jsx($at,{})},{path:jt.settings,element:p.jsx(zat,{})},{path:jt.startup,element:p.jsx(Tct,{})}]}],Rct={items:{isInitialized:!1,isLoading:!1}},Ict=GO(Rct,e=>{e.addCase(Fo.pending,t=>{t.items.isLoading=!0}).addCase(Fo.rejected,(t,n)=>{t.items.isInitialized=!0,t.items.isLoading=!1,t.items.content=void 0,t.items.error=n.error}).addCase(Fo.fulfilled,(t,n)=>{t.items.isInitialized=!0,t.items.isLoading=!1,t.items.content=n.payload,t.items.error=void 0}).addCase(zX.fulfilled,(t,n)=>{t.items.content?.push(n.payload)}).addCase(UX.fulfilled,(t,n)=>{const r=t.items.content?.findIndex(i=>i.id===n.payload.id)??-1;r!==-1&&(t.items.content[r]=n.payload)}).addCase(VX.fulfilled,(t,n)=>{const r=t.items.content?.findIndex(i=>i.id===n.payload.id)??-1;r!==-1&&(t.items.content[r]=n.payload)}).addCase(HX.fulfilled,(t,n)=>{if(t.items.content){const r=t.items.content.findIndex(i=>i.id===n.meta.arg);r!==-1&&t.items.content.splice(r,1)}}).addCase(WX,(t,n)=>{t.items.isInitialized=!0,t.items.isLoading=!1,t.items.content=n.payload,t.items.error=void 0}).addCase(qX,(t,n)=>{if(t.items.content){const r=t.items.content.findIndex(i=>i.id===n.payload.id);r!==-1?t.items.content[r]=n.payload:t.items.content.push(n.payload)}})}),jct={byBridge:{}},Pct=GO(jct,e=>{e.addCase(fu.pending,(t,n)=>{t.byBridge[n.meta.arg]=sk(t.byBridge[n.meta.arg],n)}).addCase(fu.rejected,(t,n)=>{t.byBridge[n.meta.arg]=sk(t.byBridge[n.meta.arg],n)}).addCase(fu.fulfilled,(t,n)=>{t.byBridge[n.meta.arg]=sk(t.byBridge[n.meta.arg],n)})}),$ct={isInitialized:!1,isLoading:!1,content:void 0,error:void 0},sk=GO($ct,e=>{e.addCase(fu.pending,t=>{t.isLoading=!0}).addCase(fu.rejected,(t,n)=>{t.isInitialized=!0,t.isLoading=!1,t.content=void 0,t.error=n.error}).addCase(fu.fulfilled,(t,n)=>{t.isInitialized=!0,t.isLoading=!1,t.content=n.payload,t.error=void 0})}),Lct=d2e({reducer:{bridges:Ict,devices:Pct}}),OI=Kme({createStyledComponent:me("div",{name:"MuiContainer",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[`maxWidth${ye(String(n.maxWidth))}`],n.fixed&&t.fixed,n.disableGutters&&t.disableGutters]}}),useThemeProps:e=>ot({props:e,name:"MuiContainer"})});function Nct(e){return et("MuiToolbar",e)}nt("MuiToolbar",["root","gutters","regular","dense"]);const Fct=e=>{const{classes:t,disableGutters:n,variant:r}=e;return tt({root:["root",!n&&"gutters",r]},Nct,t)},Bct=me("div",{name:"MuiToolbar",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(Ge(({theme:e})=>({position:"relative",display:"flex",alignItems:"center",variants:[{props:({ownerState:t})=>!t.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up("sm")]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:"dense"},style:{minHeight:48}},{props:{variant:"regular"},style:e.mixins.toolbar}]}))),qle=_.forwardRef(function(t,n){const r=ot({props:t,name:"MuiToolbar"}),{className:i,component:o="div",disableGutters:s=!1,variant:a="regular",...l}=r,c={...r,component:o,disableGutters:s,variant:a},u=Fct(c);return p.jsx(Bct,{as:o,className:Oe(u.root,i),ref:n,ownerState:c,...l})}),zct=[{name:"GitHub",url:jt.githubRepository},{name:"Documentation",url:jt.documentation}],Hct=()=>p.jsxs(OI,{sx:{mt:16,mb:4},children:[p.jsx(Jr,{sx:{mt:4,mb:4}}),p.jsx(Qe,{container:!0,spacing:2,justifyContent:"center",children:zct.map((e,t)=>p.jsx(Qe,{size:{xs:12,sm:"auto"},children:p.jsx(At,{fullWidth:!0,size:"small",variant:"outlined",component:dw,href:e.url,target:"_blank",children:e.name})},t.toString()))})]});function Uct(e){return et("MuiAppBar",e)}nt("MuiAppBar",["root","positionFixed","positionAbsolute","positionSticky","positionStatic","positionRelative","colorDefault","colorPrimary","colorSecondary","colorInherit","colorTransparent","colorError","colorInfo","colorSuccess","colorWarning"]);const Vct=e=>{const{color:t,position:n,classes:r}=e,i={root:["root",`color${ye(t)}`,`position${ye(n)}`]};return tt(i,Uct,r)},FK=(e,t)=>e?`${e.replace(")","")}, ${t})`:t,Wct=me(Fr,{name:"MuiAppBar",slot:"Root",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.root,t[`position${ye(n.position)}`],t[`color${ye(n.color)}`]]}})(Ge(({theme:e})=>({display:"flex",flexDirection:"column",width:"100%",boxSizing:"border-box",flexShrink:0,variants:[{props:{position:"fixed"},style:{position:"fixed",zIndex:(e.vars||e).zIndex.appBar,top:0,left:"auto",right:0,"@media print":{position:"absolute"}}},{props:{position:"absolute"},style:{position:"absolute",zIndex:(e.vars||e).zIndex.appBar,top:0,left:"auto",right:0}},{props:{position:"sticky"},style:{position:"sticky",zIndex:(e.vars||e).zIndex.appBar,top:0,left:"auto",right:0}},{props:{position:"static"},style:{position:"static"}},{props:{position:"relative"},style:{position:"relative"}},{props:{color:"inherit"},style:{"--AppBar-color":"inherit",color:"var(--AppBar-color)"}},{props:{color:"default"},style:{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[100],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[100]),...e.applyStyles("dark",{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[900],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[900])})}},...Object.entries(e.palette).filter(Fn(["contrastText"])).map(([t])=>({props:{color:t},style:{"--AppBar-background":(e.vars??e).palette[t].main,"--AppBar-color":(e.vars??e).palette[t].contrastText}})),{props:t=>t.enableColorOnDark===!0&&!["inherit","transparent"].includes(t.color),style:{backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)"}},{props:t=>t.enableColorOnDark===!1&&!["inherit","transparent"].includes(t.color),style:{backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)",...e.applyStyles("dark",{backgroundColor:e.vars?FK(e.vars.palette.AppBar.darkBg,"var(--AppBar-background)"):null,color:e.vars?FK(e.vars.palette.AppBar.darkColor,"var(--AppBar-color)"):null})}},{props:{color:"transparent"},style:{"--AppBar-background":"transparent","--AppBar-color":"inherit",backgroundColor:"var(--AppBar-background)",color:"var(--AppBar-color)",...e.applyStyles("dark",{backgroundImage:"none"})}}]}))),qct=_.forwardRef(function(t,n){const r=ot({props:t,name:"MuiAppBar"}),{className:i,color:o="primary",enableColorOnDark:s=!1,position:a="fixed",...l}=r,c={...r,color:o,position:a,enableColorOnDark:s},u=Vct(c);return p.jsx(Wct,{square:!0,component:"header",ownerState:c,elevation:4,className:Oe(u.root,i,a==="fixed"&&"mui-fixed"),ref:n,...l})});function Gct(e,t,n){const r=t.getBoundingClientRect(),i=n&&n.getBoundingClientRect(),o=tl(t);let s;if(t.fakeTransform)s=t.fakeTransform;else{const c=o.getComputedStyle(t);s=c.getPropertyValue("-webkit-transform")||c.getPropertyValue("transform")}let a=0,l=0;if(s&&s!=="none"&&typeof s=="string"){const c=s.split("(")[1].split(")")[0].split(",");a=parseInt(c[4],10),l=parseInt(c[5],10)}return e==="left"?i?`translateX(${i.right+a-r.left}px)`:`translateX(${o.innerWidth+a-r.left}px)`:e==="right"?i?`translateX(-${r.right-i.left-a}px)`:`translateX(-${r.left+r.width-a}px)`:e==="up"?i?`translateY(${i.bottom+l-r.top}px)`:`translateY(${o.innerHeight+l-r.top}px)`:i?`translateY(-${r.top-i.top+r.height-l}px)`:`translateY(-${r.top+r.height-l}px)`}function Kct(e){return typeof e=="function"?e():e}function O5(e,t,n){const r=Kct(n),i=Gct(e,t,r);i&&(t.style.webkitTransform=i,t.style.transform=i)}const Yct=_.forwardRef(function(t,n){const r=Oa(),i={enter:r.transitions.easing.easeOut,exit:r.transitions.easing.sharp},o={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{addEndListener:s,appear:a=!0,children:l,container:c,direction:u="down",easing:f=i,in:h,onEnter:g,onEntered:y,onEntering:b,onExit:v,onExited:S,onExiting:C,style:w,timeout:A=o,TransitionComponent:E=Ta,...O}=t,D=_.useRef(null),T=Rr(gf(l),D,n),I=H=>U=>{H&&(U===void 0?H(D.current):H(D.current,U))},N=I((H,U)=>{O5(u,H,c),zO(H),g&&g(H,U)}),$=I((H,U)=>{const K=Xd({timeout:A,style:w,easing:f},{mode:"enter"});H.style.webkitTransition=r.transitions.create("-webkit-transform",{...K}),H.style.transition=r.transitions.create("transform",{...K}),H.style.webkitTransform="none",H.style.transform="none",b&&b(H,U)}),R=I(y),L=I(C),P=I(H=>{const U=Xd({timeout:A,style:w,easing:f},{mode:"exit"});H.style.webkitTransition=r.transitions.create("-webkit-transform",U),H.style.transition=r.transitions.create("transform",U),O5(u,H,c),v&&v(H)}),z=I(H=>{H.style.webkitTransition="",H.style.transition="",S&&S(H)}),F=H=>{s&&s(D.current,H)},W=_.useCallback(()=>{D.current&&O5(u,D.current,c)},[u,c]);return _.useEffect(()=>{if(h||u==="down"||u==="right")return;const H=LO(()=>{D.current&&O5(u,D.current,c)}),U=tl(D.current);return U.addEventListener("resize",H),()=>{H.clear(),U.removeEventListener("resize",H)}},[u,h,c]),_.useEffect(()=>{h||W()},[h,W]),p.jsx(E,{nodeRef:D,onEnter:N,onEntered:R,onEntering:$,onExit:P,onExited:z,onExiting:L,addEndListener:F,appear:a,in:h,timeout:A,...O,children:(H,{ownerState:U,...K})=>_.cloneElement(l,{ref:T,style:{visibility:H==="exited"&&!h?"hidden":void 0,...w,...l.props.style},...K})})});function Xct(e){return et("MuiDrawer",e)}nt("MuiDrawer",["root","docked","paper","anchorLeft","anchorRight","anchorTop","anchorBottom","paperAnchorLeft","paperAnchorRight","paperAnchorTop","paperAnchorBottom","paperAnchorDockedLeft","paperAnchorDockedRight","paperAnchorDockedTop","paperAnchorDockedBottom","modal"]);const Gle=(e,t)=>{const{ownerState:n}=e;return[t.root,(n.variant==="permanent"||n.variant==="persistent")&&t.docked,n.variant==="temporary"&&t.modal]},Zct=e=>{const{classes:t,anchor:n,variant:r}=e,i={root:["root",`anchor${ye(n)}`],docked:[(r==="permanent"||r==="persistent")&&"docked"],modal:["modal"],paper:["paper",`paperAnchor${ye(n)}`,r!=="temporary"&&`paperAnchorDocked${ye(n)}`]};return tt(i,Xct,t)},Jct=me(rT,{name:"MuiDrawer",slot:"Root",overridesResolver:Gle})(Ge(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),Qct=me("div",{shouldForwardProp:ro,name:"MuiDrawer",slot:"Docked",skipVariantsResolver:!1,overridesResolver:Gle})({flex:"0 0 auto"}),eut=me(Fr,{name:"MuiDrawer",slot:"Paper",overridesResolver:(e,t)=>{const{ownerState:n}=e;return[t.paper,t[`paperAnchor${ye(n.anchor)}`],n.variant!=="temporary"&&t[`paperAnchorDocked${ye(n.anchor)}`]]}})(Ge(({theme:e})=>({overflowY:"auto",display:"flex",flexDirection:"column",height:"100%",flex:"1 0 auto",zIndex:(e.vars||e).zIndex.drawer,WebkitOverflowScrolling:"touch",position:"fixed",top:0,outline:0,variants:[{props:{anchor:"left"},style:{left:0}},{props:{anchor:"top"},style:{top:0,left:0,right:0,height:"auto",maxHeight:"100%"}},{props:{anchor:"right"},style:{right:0}},{props:{anchor:"bottom"},style:{top:"auto",left:0,bottom:0,right:0,height:"auto",maxHeight:"100%"}},{props:({ownerState:t})=>t.anchor==="left"&&t.variant!=="temporary",style:{borderRight:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>t.anchor==="top"&&t.variant!=="temporary",style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>t.anchor==="right"&&t.variant!=="temporary",style:{borderLeft:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:t})=>t.anchor==="bottom"&&t.variant!=="temporary",style:{borderTop:`1px solid ${(e.vars||e).palette.divider}`}}]}))),Kle={left:"right",right:"left",top:"down",bottom:"up"};function tut(e){return["left","right"].includes(e)}function nut({direction:e},t){return e==="rtl"&&tut(t)?Kle[t]:t}const rut=_.forwardRef(function(t,n){const r=ot({props:t,name:"MuiDrawer"}),i=Oa(),o=mf(),s={enter:i.transitions.duration.enteringScreen,exit:i.transitions.duration.leavingScreen},{anchor:a="left",BackdropProps:l,children:c,className:u,elevation:f=16,hideBackdrop:h=!1,ModalProps:{BackdropProps:g,...y}={},onClose:b,open:v=!1,PaperProps:S={},SlideProps:C,TransitionComponent:w,transitionDuration:A=s,variant:E="temporary",slots:O={},slotProps:D={},...T}=r,I=_.useRef(!1);_.useEffect(()=>{I.current=!0},[]);const N=nut({direction:o?"rtl":"ltr"},a),R={...r,anchor:a,elevation:f,open:v,variant:E,...T},L=Zct(R),P={slots:{transition:w,...O},slotProps:{paper:S,transition:C,...D,backdrop:NO(D.backdrop||{...l,...g},{transitionDuration:A})}},[z,F]=ct("root",{ref:n,elementType:Jct,className:Oe(L.root,L.modal,u),shouldForwardComponentProp:!0,ownerState:R,externalForwardedProps:{...P,...T,...y},additionalProps:{open:v,onClose:b,hideBackdrop:h,slots:{backdrop:P.slots.backdrop},slotProps:{backdrop:P.slotProps.backdrop}}}),[W,H]=ct("paper",{elementType:eut,shouldForwardComponentProp:!0,className:Oe(L.paper,S.className),ownerState:R,externalForwardedProps:P,additionalProps:{elevation:E==="temporary"?f:0,square:!0,...E==="temporary"&&{role:"dialog","aria-modal":"true"}}}),[U,K]=ct("docked",{elementType:Qct,ref:n,className:Oe(L.root,L.docked,u),ownerState:R,externalForwardedProps:P,additionalProps:T}),[B,q]=ct("transition",{elementType:Yct,ownerState:R,externalForwardedProps:P,additionalProps:{in:v,direction:Kle[N],timeout:A,appear:I.current}}),X=p.jsx(W,{...H,children:c});if(E==="permanent")return p.jsx(U,{...K,children:X});const V=p.jsx(B,{...q,children:X});return E==="persistent"?p.jsx(U,{...K,children:V}):p.jsx(z,{...F,children:V})}),iut=XY({themeId:ua}),ak={error:"#d32f2f",warn:"#ed6c02",info:"#0288d1",debug:"#7b1fa2"},out={error:Iu,warn:lw,info:mw,debug:Tw},sut=({open:e,onClose:t})=>{const[n,r]=_.useState([]),[i,o]=_.useState(!0),[s,a]=_.useState("error,warn,info".split(",")),[l,c]=_.useState(""),[u,f]=_.useState(!0),h=_.useCallback(async()=>{try{const S=new URLSearchParams({level:s.join(","),limit:"500",...l&&{search:l}}),C=await fetch(`api/logs?${S}`);if(C.ok){const w=await C.json();r(w.entries)}}catch(S){console.error("Failed to fetch logs:",S)}finally{o(!1)}},[s,l]);_.useEffect(()=>{e&&h()},[e,h]),_.useEffect(()=>{if(!u||!e)return;const S=setInterval(h,5e3);return()=>clearInterval(S)},[u,e,h]);const g=S=>{a(Array.isArray(S.target.value)?S.target.value:[S.target.value])},y=S=>{c(S.target.value)},b=async()=>{try{await fetch("api/logs",{method:"DELETE"}),r([])}catch(S){console.error("Failed to clear logs:",S)}},v=S=>{const C=out[S]||mw;return p.jsx(C,{sx:{fontSize:16,color:ak[S]}})};return p.jsxs(xu,{open:e,onClose:t,maxWidth:"lg",fullWidth:!0,children:[p.jsxs(wu,{sx:{display:"flex",alignItems:"center",gap:1},children:[p.jsx(Tw,{}),"System Logs",p.jsx(oe,{sx:{flexGrow:1}}),p.jsx(Jt,{title:"Auto Refresh",children:p.jsx(xt,{label:u?"Auto":"Manual",color:u?"success":"default",size:"small",onClick:()=>f(!u),sx:{cursor:"pointer"}})}),p.jsx(mn,{onClick:t,children:p.jsx(KCe,{})})]}),p.jsxs(Su,{children:[p.jsx(Bt,{spacing:2,sx:{mb:2},children:p.jsxs(Bt,{direction:"row",spacing:2,alignItems:"center",children:[p.jsxs(ha,{size:"small",sx:{minWidth:200},children:[p.jsx(ac,{children:"Log Level"}),p.jsxs(oa,{value:s,label:"Log Level",onChange:g,multiple:!0,renderValue:S=>p.jsx(oe,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:(Array.isArray(S)?S:[S]).map(C=>p.jsx(xt,{label:C.toUpperCase(),size:"small",sx:{backgroundColor:ak[C],color:"white"}},C))}),children:[p.jsx(nr,{value:"error",children:"Error"}),p.jsx(nr,{value:"warn",children:"Warning"}),p.jsx(nr,{value:"info",children:"Info"}),p.jsx(nr,{value:"debug",children:"Debug"})]})]}),p.jsx(Tr,{size:"small",placeholder:"Search logs...",value:l,onChange:y,sx:{flexGrow:1}}),p.jsx(At,{variant:"outlined",onClick:h,children:"Refresh"}),p.jsx(At,{variant:"outlined",color:"error",onClick:b,children:"Clear"})]})}),p.jsx(oe,{sx:{height:400,overflow:"auto",backgroundColor:"background.paper",border:1,borderColor:"divider",borderRadius:1,p:1},children:i?p.jsx(oe,{sx:{display:"flex",justifyContent:"center",p:4},children:p.jsx(re,{children:"Loading logs..."})}):n.length===0?p.jsx(oe,{sx:{display:"flex",justifyContent:"center",p:4},children:p.jsx(re,{color:"text.secondary",children:"No logs found"})}):p.jsx(Bt,{spacing:1,children:n.map((S,C)=>p.jsxs(oe,{sx:{p:1,borderRadius:1,backgroundColor:"action.hover",fontFamily:"monospace",fontSize:"0.875rem",wordBreak:"break-all"},children:[p.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:1,mb:.5},children:[v(S.level),p.jsx(re,{variant:"caption",color:"text.secondary",children:new Date(S.timestamp).toLocaleString()}),p.jsx(xt,{label:S.level.toUpperCase(),size:"small",sx:{backgroundColor:ak[S.level],color:"white",fontSize:"0.7rem",height:20}})]}),p.jsx(re,{sx:{ml:3},children:S.message}),S.context&&p.jsx(re,{sx:{ml:3,color:"text.secondary",fontSize:"0.8rem"},children:JSON.stringify(S.context,null,2)})]},`${S.timestamp}-${S.level}-${C}`))})})]}),p.jsx(Jd,{children:p.jsx(At,{onClick:t,children:"Close"})})]})};function BK(){const{isConnected:e}=D2e(),[t,n]=_.useState(null),[r,i]=_.useState(!1);_.useEffect(()=>{const y=async()=>{try{const v=await fetch("api/health");if(v.ok){const S=await v.json();n(S),i(!1)}else i(!0)}catch{i(!0)}};y();const b=setInterval(y,3e4);return()=>clearInterval(b)},[]);const o=y=>{const b=Math.floor(y/3600),v=Math.floor(y%3600/60);return b>0?`${b}h ${v}m`:`${v}m`},s=t?.status==="healthy"&&!r,a=t?.services?.bridges,l=a&&a.total>0&&a.running===a.total,c=a&&a.total===0,u=t?p.jsxs(oe,{sx:{p:.5},children:[p.jsxs("div",{children:[p.jsx("strong",{children:"Version:"})," ",t.version??"Unknown"]}),p.jsxs("div",{children:[p.jsx("strong",{children:"Uptime:"})," ",o(t.uptime??0)]}),t.services?.bridges&&p.jsxs("div",{children:[p.jsx("strong",{children:"Bridges:"})," ",t.services.bridges.running??0,"/",t.services.bridges.total??0," running",(t.services.bridges.stopped??0)>0&&` (${t.services.bridges.stopped} stopped)`]}),t.services?.homeAssistant&&p.jsxs("div",{children:[p.jsx("strong",{children:"Home Assistant:"})," ",t.services.homeAssistant.connected?"Connected":"Disconnected"]}),p.jsxs("div",{children:[p.jsx("strong",{children:"WebSocket:"})," ",e?"Connected":"Disconnected"]})]}):"Loading health status...",f=()=>r||!s?p.jsx(Iu,{fontSize:"small"}):l?p.jsx(xc,{fontSize:"small"}):p.jsx(gw,{fontSize:"small"}),h=()=>r||!s?"error":!l||!e?"warning":"success",g=()=>r?"Error":s?e?c?"No Bridges":l?"Online":"Starting":"Offline":"Unhealthy";return p.jsx(Jt,{title:u,arrow:!0,children:p.jsx(xt,{icon:f(),label:g(),color:h(),size:"small",variant:"filled",sx:{borderRadius:1,fontWeight:600,"& .MuiChip-icon":{color:"inherit"}}})})}const aut=e=>_.createElement("svg",{viewBox:"0 0 91 89",xmlSpace:"preserve",xmlns:"http://www.w3.org/2000/svg",...e},_.createElement("g",{style:{display:"inline"}},_.createElement("path",{style:{fill:"#18bcf2",fillOpacity:1,strokeWidth:.266194},d:"m 49.149143,1.473171 38.513568,38.536435 c 0,0 1.248354,1.186052 2.207681,3.092371 0.959329,1.906323 1.10864,4.600698 1.10864,4.600698 v 36.786372 c 0,0 -0.01549,1.748506 -1.49842,3.050572 -1.482931,1.302064 -3.333077,1.362947 -3.333077,1.362947 l -81.325658,7.7e-5 c 0,0 -1.7523855,-0.0091 -3.17112,-1.352526 C -0.07808495,85.913164 0.05953025,84.487808 0.05953025,84.487808 V 47.704546 c 0,0 -0.0018381,-2.218618 0.95921785,-4.315832 0.9610554,-2.097209 2.3010618,-3.355005 2.3010618,-3.355005 L 41.545959,1.4719546 c 0,0 1.465224,-1.46837077 3.753488,-1.46837077 2.288268,0 3.849696,1.46958717 3.849696,1.46958717 z"}),_.createElement("path",{style:{fill:"#ffffff",fillOpacity:1,strokeWidth:.175841},d:"m 31.689717,32.051124 c 2.813363,2.331095 6.157331,3.89845 9.721813,4.556421 V 17.180647 l 3.873694,-2.282955 3.870527,2.282955 V 36.60772 c 3.565364,-0.658847 6.910387,-2.226204 9.725159,-4.556417 l 7.032345,4.154609 c -11.437354,11.557779 -29.852321,11.557779 -41.290025,0 z m 8.546732,49.60988 C 44.314996,65.760441 35.09933,49.470196 19.574984,45.139543 v 8.312381 c 3.383916,1.32244 6.386113,3.496288 8.728705,6.320026 L 11.83076,69.485301 v 4.56907 l 3.873697,2.270836 16.469936,-9.713534 c 1.224356,3.48294 1.56683,7.225375 0.996449,10.879778 z M 70.977694,45.139543 c -15.515726,4.34014 -24.72189,20.626696 -20.643519,36.521461 l 7.047658,-4.15742 c -0.569325,-3.654411 -0.2265,-7.3965 0.996449,-10.87979 l 16.457611,9.701233 3.870711,-2.283125 v -4.55677 L 62.233673,59.77195 c 2.342772,-2.822684 5.34497,-4.996533 8.728708,-6.320026 z"}))),lut="home-assistant-matter-hub",cut={name:lut};function uut(){const[e,t]=_.useState("4.1.0-testing.25");return _.useEffect(()=>{fetch("api/health").then(n=>n.ok?n.json():null).then(n=>{n?.version&&t(n.version)}).catch(()=>{})},[]),_.useMemo(()=>({name:cut.name,version:e}),[e])}const dut=e=>{const t=uut();return p.jsxs(oe,{component:Tu,to:jt.dashboard,sx:{display:"flex",alignItems:"center",justifyContent:e.large?"flex-start":"center",flexGrow:1,textDecoration:"none",color:"inherit"},children:[p.jsx(aut,{style:{height:"40px"}}),p.jsx(re,{variant:"inherit",component:"span",sx:{mr:1,ml:1},children:t.name.split("-").map(ye).join("-")}),e.large&&p.jsx(re,{variant:"caption",component:"span",children:t.version})]})},fut=()=>{const e=iut("(min-width:600px)"),{mode:t,setMode:n}=JS(),[r,i]=_.useState(!1),[o,s]=_.useState(!1),a=Jh(),l=()=>{n(t==="dark"?"light":"dark")},c=[{label:"Dashboard",icon:p.jsx(r_,{}),to:jt.dashboard},{label:"Bridges",icon:p.jsx(my,{}),to:jt.bridges},{label:"All Devices",icon:p.jsx(Bo,{}),to:jt.devices},{label:"Network Map",icon:p.jsx(i6,{}),to:jt.networkMap},{label:"Startup Order",icon:p.jsx(am,{}),to:jt.startup},{label:"Lock Credentials",icon:p.jsx(lc,{}),to:jt.lockCredentials},{label:"Filter Reference",icon:p.jsx(o6,{}),to:jt.labels},{label:"Plugins",icon:p.jsx(N0,{}),to:jt.plugins},{label:"Settings",icon:p.jsx(mm,{}),to:jt.settings},{label:t==="dark"?"Light Mode":"Dark Mode",icon:t==="dark"?p.jsx(a8e,{}):p.jsx(ZCe,{}),onClick:l},{label:"System Logs",icon:p.jsx(Tw,{}),onClick:()=>i(!0)},{label:"Health Dashboard",icon:p.jsx(Z4,{}),to:jt.health}],u=f=>{s(!1),f.onClick?f.onClick():f.to&&a(f.to)};return p.jsxs(oe,{children:[p.jsx(qct,{sx:{height:"72px"},children:p.jsx(qle,{sx:{paddingLeft:"0 !important",paddingRight:"0 !important"},children:p.jsxs(OI,{sx:{padding:2,height:"100%",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[p.jsx(dut,{large:e}),e?p.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:1},children:[c.map(f=>f.to?p.jsx(Jt,{title:f.label,children:p.jsx(mn,{component:Tu,to:f.to,sx:{color:"inherit"},children:f.icon})},f.label):p.jsx(Jt,{title:f.label,children:p.jsx(mn,{onClick:f.onClick,sx:{color:"inherit"},children:f.icon})},f.label)),p.jsx(BK,{})]}):p.jsxs(oe,{sx:{display:"flex",alignItems:"center",gap:.5},children:[p.jsx(BK,{}),p.jsx(mn,{onClick:()=>s(!0),sx:{color:"inherit"},children:p.jsx(l8e,{})})]})]})})}),p.jsx(rut,{anchor:"right",open:o,onClose:()=>s(!1),children:p.jsx(vc,{sx:{width:250},children:c.map(f=>p.jsxs(lbe,{onClick:()=>u(f),children:[p.jsx(Vl,{children:f.icon}),p.jsx(Va,{primary:f.label})]},f.label))})}),p.jsx(sut,{open:r,onClose:()=>i(!1)})]})},hut=()=>p.jsxs(oe,{children:[p.jsx(fut,{}),p.jsx(qle,{}),p.jsx(OI,{sx:{p:2},children:p.jsx(yY,{})}),p.jsx(Hct,{})]}),put=YS({colorSchemes:{light:{palette:{primary:{main:"#1976d2",light:"#42a5f5",dark:"#1565c0"},secondary:{main:"#9c27b0",light:"#ba68c8",dark:"#7b1fa2"},background:{default:"#f5f5f5",paper:"#ffffff"}}},dark:{palette:{primary:{main:"#90caf9",light:"#e3f2fd",dark:"#42a5f5"},secondary:{main:"#ce93d8",light:"#f3e5f5",dark:"#ab47bc"},background:{default:"#121212",paper:"#1e1e1e"}}}},typography:{fontFamily:'"Roboto", "Helvetica", "Arial", sans-serif',h1:{fontSize:"2.5rem",fontWeight:500},h2:{fontSize:"2rem",fontWeight:500},h3:{fontSize:"1.75rem",fontWeight:500},h4:{fontSize:"1.5rem",fontWeight:500},h5:{fontSize:"1.25rem",fontWeight:500},h6:{fontSize:"1rem",fontWeight:500}},shape:{borderRadius:8},components:{MuiCard:{styleOverrides:{root:{transition:"transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out","&:hover":{transform:"translateY(-2px)",boxShadow:"0 4px 20px rgba(0,0,0,0.12)"}}}},MuiButton:{styleOverrides:{root:{textTransform:"none",fontWeight:500}}},MuiChip:{styleOverrides:{root:{fontWeight:500}}},MuiAppBar:{styleOverrides:{root:{backgroundImage:"none"}}}}});let O4=document.getElementsByTagName("base")[0]?.href?.replace(/\/$/,"");O4?.startsWith("http")&&(O4=new URL(O4).pathname);const mut=Whe([{path:"/",element:p.jsx(hut,{}),children:Mct}],{basename:O4});cde.createRoot(document.getElementById("root")).render(p.jsx(_.StrictMode,{children:p.jsx(kde,{store:Lct,children:p.jsxs(o1e,{theme:put,children:[p.jsx(e1e,{}),p.jsx(dX,{styles:{".rjsf-field-array > .MuiFormControl-root > .MuiPaper-root > .MuiBox-root > .MuiGrid-root > .MuiGrid-root:has(> .MuiBox-root > .MuiPaper-root > .MuiBox-root > .rjsf-field)":{overflow:"initial !important",flexGrow:1}}}),p.jsx(O2e,{children:p.jsx(xye,{children:p.jsx(rpe,{router:mut})})})]})})}));
@@ -8,7 +8,7 @@
8
8
  <!-- BASE -->
9
9
  <base href="/" />
10
10
  <!-- /BASE -->
11
- <script type="module" crossorigin src="./assets/index-B3VdeESH.js"></script>
11
+ <script type="module" crossorigin src="./assets/index-BLmxABvi.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="./assets/index-BNdBOwwe.css">
13
13
  </head>
14
14
  <body>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@riddix/hamh",
3
3
  "description": "",
4
- "version": "4.1.0-testing.23",
4
+ "version": "4.1.0-testing.25",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "bin": {
@@ -57,9 +57,9 @@
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/lodash-es": "^4.17.12",
60
- "@home-assistant-matter-hub/frontend": "4.1.0-testing.23",
61
- "@home-assistant-matter-hub/common": "4.1.0-testing.23",
62
- "@home-assistant-matter-hub/backend": "4.1.0-testing.23"
60
+ "@home-assistant-matter-hub/backend": "4.1.0-testing.25",
61
+ "@home-assistant-matter-hub/common": "4.1.0-testing.25",
62
+ "@home-assistant-matter-hub/frontend": "4.1.0-testing.25"
63
63
  },
64
64
  "nx": {
65
65
  "targets": {