@lacneu/atrium 0.7.0 → 0.8.0

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.
@@ -159,6 +159,6 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
159
159
  To pick up a draggable item, press the space bar.
160
160
  While dragging, use the arrow keys to move the item.
161
161
  Press space again to drop the item in its new position, or press escape to cancel.
162
- `},Jtt={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 Ytt(e){let{announcements:t=Jtt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=qtt}=e,{announce:a,announcement:o}=Wtt(),s=v6(`DndLiveRegion`),[c,l]=(0,N.useState)(!1);if((0,N.useEffect)(()=>{l(!0)},[]),Gtt((0,N.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=N.createElement(N.Fragment,null,N.createElement(Htt,{id:r,value:i.draggable}),N.createElement(Utt,{id:s,announcement:o}));return n?(0,ls.createPortal)(u,n):u}var D6;(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`})(D6||={});function O6(){}function k6(e,t){return(0,N.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function A6(){var e=[...arguments];return(0,N.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var j6=Object.freeze({x:0,y:0});function M6(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Xtt(e,t){let n=C6(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function N6(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Ztt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function P6(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 F6(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function I6(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}}var Qtt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=I6(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=M6(I6(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(N6)},L6=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=P6(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=P6(r),o=i.reduce((e,t,r)=>e+M6(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(N6)};function $tt(e,t){let 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),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var ent=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=$tt(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Ztt)};function tnt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function R6(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:j6}function nnt(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var rnt=nnt(1);function z6(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function int(e,t,n){let r=z6(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var ant={ignoreTransform:!1};function B6(e,t){t===void 0&&(t=ant);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=o6(e).getComputedStyle(e);t&&(n=int(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function V6(e){return B6(e,{ignoreTransform:!0})}function ont(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function snt(e,t){return t===void 0&&(t=o6(e).getComputedStyle(e)),t.position===`fixed`}function cnt(e,t){t===void 0&&(t=o6(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function H6(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(s6(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!c6(i)||l6(i)||n.includes(i))return n;let a=o6(e).getComputedStyle(i);return i!==e&&cnt(i,a)&&n.push(i),snt(i,a)?n:r(i.parentNode)}return e?r(e):n}function U6(e){let[t]=H6(e,1);return t??null}function W6(e){return!r6||!e?null:i6(e)?e:a6(e)?s6(e)||e===u6(e).scrollingElement?window:c6(e)?e:null:null}function G6(e){return i6(e)?e.scrollX:e.scrollLeft}function K6(e){return i6(e)?e.scrollY:e.scrollTop}function q6(e){return{x:G6(e),y:K6(e)}}var J6;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J6||={});function Y6(e){return!r6||!e?!1:e===document.scrollingElement}function X6(e){let t={x:0,y:0},n=Y6(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var lnt={x:.2,y:.2};function unt(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=lnt);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=X6(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J6.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J6.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J6.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J6.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function dnt(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{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 Z6(e){return e.reduce((e,t)=>b6(e,q6(t)),j6)}function fnt(e){return e.reduce((e,t)=>e+G6(t),0)}function pnt(e){return e.reduce((e,t)=>e+K6(t),0)}function Q6(e,t){if(t===void 0&&(t=B6),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);U6(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var mnt=[[`x`,[`left`,`right`],fnt],[`y`,[`top`,`bottom`],pnt]],$6=class{constructor(e,t){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;let n=H6(t),r=Z6(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of mnt)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},e8=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function hnt(e){let{EventTarget:t}=o6(e);return e instanceof t?e:u6(e)}function t8(e,t){let 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 n8;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(n8||={});function r8(e){e.preventDefault()}function gnt(e){e.stopPropagation()}var i8;(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`})(i8||={});var a8={start:[i8.Space,i8.Enter],cancel:[i8.Esc],end:[i8.Space,i8.Enter,i8.Tab]},_nt=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case i8.Right:return{...n,x:n.x+25};case i8.Left:return{...n,x:n.x-25};case i8.Down:return{...n,y:n.y+25};case i8.Up:return{...n,y:n.y-25}}},o8=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new e8(u6(t)),this.windowListeners=new e8(o6(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(n8.Resize,this.handleCancel),this.windowListeners.add(n8.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(n8.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Q6(n),t(j6)}handleKeyDown(e){if(S6(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=a8,coordinateGetter:a=_nt,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:j6;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=x6(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=X6(n),p=dnt(n),m={x:Math.min(i===i8.Right?p.right-p.width/2:p.right,Math.max(i===i8.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===i8.Down?p.bottom-p.height/2:p.bottom,Math.max(i===i8.Down?p.top:p.top+p.height/2,u.y))},h=i===i8.Right&&!s||i===i8.Left&&!c,g=i===i8.Down&&!l||i===i8.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===i8.Right&&e<=d.x||i===i8.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===i8.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===i8.Down&&e<=d.y||i===i8.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===i8.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,b6(x6(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};o8.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=a8,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function s8(e){return!!(e&&`distance`in e)}function c8(e){return!!(e&&`delay`in e)}var l8=class{constructor(e,t,n){n===void 0&&(n=hnt(e.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=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=u6(i),this.documentListeners=new e8(this.document),this.listeners=new e8(n),this.windowListeners=new e8(o6(i)),this.initialCoordinates=C6(r)??j6,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(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(n8.Resize,this.handleCancel),this.windowListeners.add(n8.DragStart,r8),this.windowListeners.add(n8.VisibilityChange,this.handleCancel),this.windowListeners.add(n8.ContextMenu,r8),this.documentListeners.add(n8.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(c8(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(s8(t)){this.handlePending(t);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(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(n8.Click,gnt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(n8.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=C6(e)??j6,s=x6(n,o);if(!t&&a){if(s8(a)){if(a.tolerance!=null&&t8(s,a.tolerance))return this.handleCancel();if(t8(s,a.distance))return this.handleStart()}if(c8(a)&&t8(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===i8.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},vnt={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},u8=class extends l8{constructor(e){let{event:t}=e,n=u6(t.target);super(e,vnt,n)}};u8.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var ynt={move:{name:`mousemove`},end:{name:`mouseup`}},d8;(function(e){e[e.RightClick=2]=`RightClick`})(d8||={});var bnt=class extends l8{constructor(e){super(e,ynt,u6(e.event.target))}};bnt.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===d8.RightClick?!1:(r?.({event:n}),!0)}}];var f8={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},xnt=class extends l8{constructor(e){super(e,f8)}static setup(){return window.addEventListener(f8.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(f8.move.name,e)};function e(){}}};xnt.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var p8;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(p8||={});var m8;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(m8||={});function Snt(e){let{acceleration:t,activator:n=p8.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=m8.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=wnt({delta:d,disabled:!a}),[m,h]=Ltt(),g=(0,N.useRef)({x:0,y:0}),_=(0,N.useRef)({x:0,y:0}),v=(0,N.useMemo)(()=>{switch(n){case p8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case p8.DraggableRect:return i}},[n,i,c]),y=(0,N.useRef)(null),b=(0,N.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,N.useMemo)(()=>s===m8.TreeOrder?[...l].reverse():l,[s,l]);(0,N.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=unt(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Cnt={x:{[J6.Backward]:!1,[J6.Forward]:!1},y:{[J6.Backward]:!1,[J6.Forward]:!1}};function wnt(e){let{delta:t,disabled:n}=e,r=g6(t);return m6(e=>{if(n||!r||!e)return Cnt;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J6.Backward]:e.x[J6.Backward]||i.x===-1,[J6.Forward]:e.x[J6.Forward]||i.x===1},y:{[J6.Backward]:e.y[J6.Backward]||i.y===-1,[J6.Forward]:e.y[J6.Forward]||i.y===1}}},[n,t,r])}function Tnt(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return m6(e=>t==null?null:r??e??null,[r,t])}function Ent(e,t){return(0,N.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var h8;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(h8||={});var g8;(function(e){e.Optimized=`optimized`})(g8||={});var _8=new Map;function Dnt(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,N.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,N.useRef)(e),d=g(),f=p6(d),p=(0,N.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,N.useRef)(null),h=m6(t=>{if(d&&!n)return _8;if(!t||t===_8||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new $6(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,N.useEffect)(()=>{u.current=e},[e]),(0,N.useEffect)(()=>{d||p()},[n,d]),(0,N.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,N.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case h8.Always:return!1;case h8.BeforeDragging:return n;default:return!n}}}function v8(e,t){return m6(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Ont(e,t){return v8(e,t)}function knt(e){let{callback:t,disabled:n}=e,r=f6(t),i=(0,N.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,N.useEffect)(()=>()=>i?.disconnect(),[i]),i}function y8(e){let{callback:t,disabled:n}=e,r=f6(t),i=(0,N.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,N.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ant(e){return new $6(B6(e),e)}function b8(e,t,n){t===void 0&&(t=Ant);let[r,i]=(0,N.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=knt({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=y8({callback:a});return d6(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function jnt(e){return R6(e,v8(e))}var x8=[];function Mnt(e){let t=(0,N.useRef)(e),n=m6(n=>e?n&&n!==x8&&e&&t.current&&e.parentNode===t.current.parentNode?n:H6(e):x8,[e]);return(0,N.useEffect)(()=>{t.current=e},[e]),n}function Nnt(e){let[t,n]=(0,N.useState)(null),r=(0,N.useRef)(e),i=(0,N.useCallback)(e=>{let t=W6(e.target);t&&n(e=>e?(e.set(t,q6(t)),new Map(e)):null)},[]);return(0,N.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=W6(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,q6(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{W6(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,N.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>b6(e,t),j6):Z6(e):j6,[e,t])}function S8(e,t){t===void 0&&(t=[]);let n=(0,N.useRef)(null);return(0,N.useEffect)(()=>{n.current=null},t),(0,N.useEffect)(()=>{let t=e!==j6;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?x6(e,n.current):j6}function Pnt(e){(0,N.useEffect)(()=>{if(!r6)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Fnt(e,t){return(0,N.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function C8(e){return(0,N.useMemo)(()=>e?ont(e):null,[e])}var w8=[];function Int(e,t){t===void 0&&(t=B6);let[n]=e,r=C8(n?o6(n):null),[i,a]=(0,N.useState)(w8);function o(){a(()=>e.length?e.map(e=>Y6(e)?r:new $6(t(e),e)):w8)}let s=y8({callback:o});return d6(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function T8(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return c6(t)?t:e}function Lnt(e){let{measure:t}=e,[n,r]=(0,N.useState)(null),i=y8({callback:(0,N.useCallback)(e=>{for(let{target:n}of e)if(c6(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=h6((0,N.useCallback)(e=>{let n=T8(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,N.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Rnt=[{sensor:u8,options:{}},{sensor:o8,options:{}}],znt={current:{}},E8={draggable:{measure:V6},droppable:{measure:V6,strategy:h8.WhileDragging,frequency:g8.Optimized},dragOverlay:{measure:B6}},D8=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Bnt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new D8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:O6},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:E8,measureDroppableContainers:O6,windowRect:null,measuringScheduled:!1},O8={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:O6,draggableNodes:new Map,over:null,measureDroppableContainers:O6},k8=(0,N.createContext)(O8),A8=(0,N.createContext)(Bnt);function Vnt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new D8}}}function Hnt(e,t){switch(t.type){case D6.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case D6.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 D6.DragEnd:case D6.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case D6.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new D8(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case D6.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new D8(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case D6.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new D8(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Unt(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,N.useContext)(k8),a=g6(r),o=g6(n?.id);return(0,N.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!S6(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Btt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function j8(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Wnt(e){return(0,N.useMemo)(()=>({draggable:{...E8.draggable,...e?.draggable},droppable:{...E8.droppable,...e?.droppable},dragOverlay:{...E8.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Gnt(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,N.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;d6(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=R6(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=U6(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var M8=(0,N.createContext)({...j6,scaleX:1,scaleY:1}),N8;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(N8||={});var P8=(0,N.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Rnt,collisionDetection:o=ent,measuring:s,modifiers:c,...l}=e,[u,d]=(0,N.useReducer)(Hnt,void 0,Vnt),[f,p]=Ktt(),[m,h]=(0,N.useState)(N8.Uninitialized),g=m===N8.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,N.useRef)({initial:null,translated:null}),C=(0,N.useMemo)(()=>_==null?null:{id:_,data:x?.data??znt,rect:S},[_,x]),w=(0,N.useRef)(null),[T,E]=(0,N.useState)(null),[D,O]=(0,N.useState)(null),ee=p6(l,Object.values(l)),te=v6(`DndDescribedBy`,t),k=(0,N.useMemo)(()=>b.getEnabled(),[b]),A=Wnt(s),{droppableRects:j,measureDroppableContainers:ne,measuringScheduled:re}=Dnt(k,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),M=Tnt(v,_),ie=(0,N.useMemo)(()=>D?C6(D):null,[D]),ae=Ie(),oe=Ont(M,A.draggable.measure);Gnt({activeNode:_==null?null:v.get(_),config:ae.layoutShiftCompensation,initialRect:oe,measure:A.draggable.measure});let se=b8(M,A.draggable.measure,oe),ce=b8(M?M.parentElement:null),le=(0,N.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ue=b.getNodeFor(le.current.over?.id),de=Lnt({measure:A.dragOverlay.measure}),fe=de.nodeRef.current??M,pe=g?de.rect??se:null,me=!!(de.nodeRef.current&&de.rect),he=jnt(me?null:se),ge=C8(fe?o6(fe):null),_e=Mnt(g?ue??M:null),ve=Int(_e),ye=j8(c,{transform:{x:y.x-he.x,y:y.y-he.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:se,containerNodeRect:ce,draggingNodeRect:pe,over:le.current.over,overlayNodeRect:de.rect,scrollableAncestors:_e,scrollableAncestorRects:ve,windowRect:ge}),be=ie?b6(ie,y):null,xe=Nnt(_e),Se=S8(xe),Ce=S8(xe,[se]),we=b6(ye,Se),Te=pe?rnt(pe,ye):null,Ee=C&&Te?o({active:C,collisionRect:Te,droppableRects:j,droppableContainers:k,pointerCoordinates:be}):null,De=F6(Ee,`id`),[Oe,ke]=(0,N.useState)(null),Ae=tnt(me?ye:b6(ye,Ce),Oe?.rect??null,se),je=(0,N.useRef)(null),Me=(0,N.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;je.current=new n({active:w.current,activeNode:i,event:a,options:r,context:le,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=ee.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=ee.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=ee.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ls.unstable_batchedUpdates)(()=>{r?.(i),h(N8.Initializing),d({type:D6.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(je.current),O(a)})},onMove(e){d({type:D6.DragMove,coordinates:e})},onEnd:o(D6.DragEnd),onCancel:o(D6.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=le.current,o=null;if(t&&i){let{cancelDrop:s}=ee.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===D6.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=D6.DragCancel)}w.current=null,(0,ls.unstable_batchedUpdates)(()=>{d({type:e}),h(N8.Uninitialized),ke(null),E(null),O(null),je.current=null;let t=e===D6.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=ee.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ne=Ent(a,(0,N.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Me(n,t))},[v,Me]));Pnt(a),d6(()=>{se&&m===N8.Initializing&&h(N8.Initialized)},[se,m]),(0,N.useEffect)(()=>{let{onDragMove:e}=ee.current,{active:t,activatorEvent:n,collisions:r,over:i}=le.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:we.x,y:we.y},over:i};(0,ls.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[we.x,we.y]),(0,N.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=le.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=ee.current,o=r.get(De),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ls.unstable_batchedUpdates)(()=>{ke(s),a?.(c),f({type:`onDragOver`,event:c})})},[De]),d6(()=>{le.current={activatorEvent:D,active:C,activeNode:M,collisionRect:Te,collisions:Ee,droppableRects:j,draggableNodes:v,draggingNode:fe,draggingNodeRect:pe,droppableContainers:b,over:Oe,scrollableAncestors:_e,scrollAdjustedTranslate:we},S.current={initial:pe,translated:Te}},[C,M,Ee,Te,v,fe,pe,j,b,Oe,_e,we]),Snt({...ae,delta:y,draggingRect:Te,pointerCoordinates:be,scrollableAncestors:_e,scrollableAncestorRects:ve});let Pe=(0,N.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:se,activatorEvent:D,collisions:Ee,containerNodeRect:ce,dragOverlay:de,draggableNodes:v,droppableContainers:b,droppableRects:j,over:Oe,measureDroppableContainers:ne,scrollableAncestors:_e,scrollableAncestorRects:ve,measuringConfiguration:A,measuringScheduled:re,windowRect:ge}),[C,M,se,D,Ee,ce,de,v,b,j,Oe,ne,_e,ve,A,re,ge]),Fe=(0,N.useMemo)(()=>({activatorEvent:D,activators:Ne,active:C,activeNodeRect:se,ariaDescribedById:{draggable:te},dispatch:d,draggableNodes:v,over:Oe,measureDroppableContainers:ne}),[D,Ne,C,se,d,te,v,Oe,ne]);return N.createElement(E6.Provider,{value:p},N.createElement(k8.Provider,{value:Fe},N.createElement(A8.Provider,{value:Pe},N.createElement(M8.Provider,{value:Ae},i)),N.createElement(Unt,{disabled:n?.restoreFocus===!1})),N.createElement(Ytt,{...n,hiddenTextDescribedById:te}));function Ie(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Knt=(0,N.createContext)(null),F8=`button`,qnt=`Draggable`;function Jnt(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=v6(qnt),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,N.useContext)(k8),{role:p=F8,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,N.useContext)(g?M8:Knt),[v,y]=h6(),[b,x]=h6(),S=Fnt(o,t),C=p6(n);return d6(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,N.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===F8?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function I8(){return(0,N.useContext)(A8)}var Ynt=`Droppable`,Xnt={timeout:25};function L8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=v6(Ynt),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,N.useContext)(k8),u=(0,N.useRef)({disabled:n}),d=(0,N.useRef)(!1),f=(0,N.useRef)(null),p=(0,N.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Xnt,...i},_=p6(h??r),v=y8({callback:(0,N.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=h6((0,N.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=p6(t);return(0,N.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,N.useEffect)(()=>(s({type:D6.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:D6.UnregisterDroppable,key:a,id:r})),[r]),(0,N.useEffect)(()=>{n!==u.current.disabled&&(s({type:D6.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Znt(e){let{animation:t,children:n}=e,[r,i]=(0,N.useState)(null),[a,o]=(0,N.useState)(null),s=g6(n);return!n&&!r&&s&&i(s),d6(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),N.createElement(N.Fragment,null,n,r?(0,N.cloneElement)(r,{ref:o}):null)}var Qnt={x:0,y:0,scaleX:1,scaleY:1};function $nt(e){let{children:t}=e;return N.createElement(k8.Provider,{value:O8},N.createElement(M8.Provider,{value:Qnt},t))}var ert={position:`fixed`,touchAction:`none`},trt=e=>S6(e)?`transform 250ms ease`:void 0,nrt=(0,N.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=trt}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...ert,width:s.width,height:s.height,top:s.top,left:s.left,transform:w6.Transform.toString(d),transformOrigin:i&&r?Xtt(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return N.createElement(n,{className:o,style:f,ref:t},a)}),rrt={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:w6.Transform.toString(t)},{transform:w6.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function irt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return f6((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=T8(a);if(!c)return;let{transform:l}=o6(a).getComputedStyle(a),u=z6(l);if(!u)return;let d=typeof t==`function`?t:art(t);return Q6(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function art(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...rrt,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var R8=0;function ort(e){return(0,N.useMemo)(()=>{if(e!=null)return R8++,R8},[e])}var srt=N.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=I8(),S=(0,N.useContext)(M8),C=ort(d?.id),w=j8(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=v8(f),E=irt({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return N.createElement($nt,null,N.createElement(Znt,{animation:E},d&&C?N.createElement(nrt,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),crt=e=>{let{transform:t}=e;return{...t,y:0}};function lrt(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var urt=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e,i=r[0];return!t||!i?n:lrt(n,t,i)},drt=e=>{let{transform:t}=e;return{...t,x:0}};function z8(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function frt(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function B8(e){return e!==null&&e>=0}function prt(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 mrt(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var V8={scaleX:1,scaleY:1},hrt=e=>{let{rects:t,activeNodeRect:n,activeIndex:r,overIndex:i,index:a}=e,o=t[r]??n;if(!o)return null;let s=grt(t,a,r);if(a===r){let e=t[i];return e?{x:r<i?e.left+e.width-(o.left+o.width):e.left-o.left,y:0,...V8}:null}return a>r&&a<=i?{x:-o.width-s,y:0,...V8}:a<r&&a>=i?{x:o.width+s,y:0,...V8}:{x:0,y:0,...V8}};function grt(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return!r||!i&&!a?0:n<t?i?r.left-(i.left+i.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(i.left+i.width)}var H8=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=z8(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},U8={scaleX:1,scaleY:1},_rt=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...U8}:null}let s=vrt(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...U8}:r<t&&r>=a?{x:0,y:o.height+s,...U8}:{x:0,y:0,...U8}};function vrt(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var W8=`Sortable`,G8=N.createContext({activeIndex:-1,containerId:W8,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:H8,disabled:{draggable:!1,droppable:!1}});function K8(e){let{children:t,id:n,items:r,strategy:i=H8,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=I8(),d=v6(W8,n),f=s.rect!==null,p=(0,N.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,N.useRef)(p),v=!prt(p,_.current),y=g!==-1&&h===-1||v,b=mrt(a);d6(()=>{v&&m&&u(p)},[v,p,m,u]),(0,N.useEffect)(()=>{_.current=p},[p]);let x=(0,N.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:frt(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return N.createElement(G8.Provider,{value:x},t)}var yrt=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return z8(n,r,i).indexOf(t)},brt=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},xrt={duration:200,easing:`ease`},q8=`transform`,Srt=w6.Transition.toString({property:q8,duration:0,easing:`linear`}),Crt={roleDescription:`sortable`};function wrt(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,N.useState)(null),s=(0,N.useRef)(n);return d6(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=B6(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,N.useEffect)(()=>{a&&o(null)},[a]),a}function J8(e){let{animateLayoutChanges:t=brt,attributes:n,disabled:r,data:i,getNewIndex:a=yrt,id:o,strategy:s,resizeObserverConfig:c,transition:l=xrt}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,N.useContext)(G8),y=Trt(r,p),b=u.indexOf(o),x=(0,N.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,N.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=L8({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:ee,attributes:te,setNodeRef:k,listeners:A,isDragging:j,over:ne,setActivatorNodeRef:re,transform:M}=Jnt({id:o,data:x,attributes:{...Crt,...n},disabled:y.draggable}),ie=Itt(E,k),ae=!!D,oe=ae&&!m&&B8(f)&&B8(g),se=!_&&j,ce=oe?(se&&oe?M:null)??(s??v)({rects:h,activeNodeRect:ee,activeIndex:f,overIndex:g,index:b}):null,le=B8(f)&&B8(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ue=D?.id,de=(0,N.useRef)({activeId:ue,items:u,newIndex:le,containerId:d}),fe=u!==de.current.items,pe=t({active:D,containerId:d,isDragging:j,isSorting:ae,id:o,index:b,items:u,newIndex:de.current.newIndex,previousItems:de.current.items,previousContainerId:de.current.containerId,transition:l,wasDragging:de.current.activeId!=null}),me=wrt({disabled:!pe,index:b,node:w,rect:C});return(0,N.useEffect)(()=>{ae&&de.current.newIndex!==le&&(de.current.newIndex=le),d!==de.current.containerId&&(de.current.containerId=d),u!==de.current.items&&(de.current.items=u)},[ae,le,d,u]),(0,N.useEffect)(()=>{if(ue===de.current.activeId)return;if(ue!=null&&de.current.activeId==null){de.current.activeId=ue;return}let e=setTimeout(()=>{de.current.activeId=ue},50);return()=>clearTimeout(e)},[ue]),{active:D,activeIndex:f,attributes:te,data:x,rect:C,index:b,newIndex:le,items:u,isOver:T,isSorting:ae,isDragging:j,listeners:A,node:w,overIndex:g,over:ne,setNodeRef:ie,setActivatorNodeRef:re,setDroppableNodeRef:E,setDraggableNodeRef:k,transform:me??ce,transition:he()};function he(){if(me||fe&&de.current.newIndex===b)return Srt;if(!(se&&!S6(O)||!l)&&(ae||pe))return w6.Transition.toString({...l,property:q8})}}function Trt(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Y8(e){if(!e)return!1;let 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)}var Ert=[i8.Down,i8.Right,i8.Up,i8.Left],X8=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Ert.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case i8.Down:r.top<a.top&&t.push(n);break;case i8.Up:r.top>a.top&&t.push(n);break;case i8.Left:r.left>a.left&&t.push(n);break;case i8.Right:r.left<a.left&&t.push(n);break}});let c=L6({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=F6(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=H6(c).some((e,t)=>s[t]!==e),i=Z8(e,t),a=Drt(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:x6(u,l)}}}};function Z8(e,t){return!Y8(e)||!Y8(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Drt(e,t){return!Y8(e)||!Y8(t)||!Z8(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Q8({open:e,onOpenChange:t,title:n,description:r,children:i,onSubmit:a,submitLabel:o=`Enregistrer`,submitting:s=!1,canSubmit:c=!0}){let[l,u]=(0,N.useState)(!1),d=s||l;async function f(){if(!(!c||d))try{u(!0),await a()}finally{u(!1)}}return(0,I.jsx)(K1,{open:e,onOpenChange:t,children:(0,I.jsxs)(q1,{side:`right`,className:`w-4/5 sm:max-w-none gap-0 p-0`,children:[(0,I.jsxs)(J1,{className:`border-b px-6 py-4`,children:[(0,I.jsx)(X1,{children:n}),r?(0,I.jsx)(Z1,{children:r}):null]}),(0,I.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,I.jsx)(`div`,{className:`oc-sheet__body flex-1 overflow-y-auto px-6 py-4`,children:i}),(0,I.jsxs)(Y1,{className:`border-t px-6 py-4`,children:[(0,I.jsxs)(X,{type:`submit`,disabled:!c||d,children:[d?(0,I.jsx)(Cm,{className:`size-4 animate-spin`}):null,o]}),(0,I.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:`Annuler`})]})]})]})})}var $8=6e4,e5=60*$8,t5=24*e5,n5=7*t5,r5=30*t5,i5=365*t5;function Ort(e,t){let n=t-e;if(n<$8)return`maintenant`;if(n<e5)return`${Math.floor(n/$8)}min`;if(n<t5)return`${Math.floor(n/e5)}h`;if(n<n5)return`${Math.floor(n/t5)}j`;if(n<r5)return`${Math.floor(n/n5)}sem`;if(n<i5)return`${Math.floor(n/r5)}mois`;let r=Math.floor(n/i5);return`${r}an${r>1?`s`:``}`}var a5=[{value:`red`,hue:`oklch(0.63 0.21 25)`},{value:`orange`,hue:`oklch(0.7 0.17 50)`},{value:`amber`,hue:`oklch(0.8 0.15 85)`},{value:`green`,hue:`oklch(0.7 0.16 150)`},{value:`teal`,hue:`oklch(0.7 0.12 190)`},{value:`blue`,hue:`oklch(0.62 0.19 250)`},{value:`violet`,hue:`oklch(0.6 0.2 300)`},{value:`pink`,hue:`oklch(0.7 0.2 350)`}],o5=e=>a5.find(t=>t.value===e)?.hue??null,s5=`project:none`,krt=e=>`project:${e}`,c5=`oc.noproject.collapsed`;function Art({activeChatId:e,onSelect:t,onNewChat:n,newChatShortcut:r}){let i=P(V.messages.listChats,{}),a=P(V.projects.listProjects,{}),o=P(V.me.getMe,{host:xO})?.ui?.effective,s=o?.showChatProvider??!0,c=o?.showChatAge??!0,l=new Set((i??[]).map(e=>e.providerKind).filter(e=>e!=null)),u=s&&l.size>1,[,d]=(0,N.useState)(0);(0,N.useEffect)(()=>{if(!c)return;let e=window.setInterval(()=>d(e=>e+1),6e4);return()=>window.clearInterval(e)},[c]);let f=F(V.projects.createProject),p=F(V.projects.setProjectCollapsed),m=F(V.chats.reorderChat),h=F(V.chats.moveChatToProject),g=w1(),_=qLe(),v=(0,N.useRef)(null),y=(0,N.useRef)(null),b=(0,N.useRef)(null),[x,S]=(0,N.useState)(`full`);(0,N.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=y.current?.offsetWidth??0,r=b.current?.offsetWidth??0,i=n===0||t>=n?`full`:t>=r?`label`:`icon`;S(e=>e===i?e:i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[_,r]);let[C,w]=(0,N.useState)(null),T=(0,N.useRef)(!1);(0,N.useEffect)(()=>{!T.current&&i&&w(i)},[i]);let E=C??i??[],[D,O]=(0,N.useState)(null),[ee,te]=(0,N.useState)(()=>localStorage.getItem(c5)===`1`);function k(){te(e=>(localStorage.setItem(c5,e?`0`:`1`),!e))}let A=A6(k6(u8,{activationConstraint:{distance:4}}),k6(o8,{coordinateGetter:X8})),j=E.filter(e=>e.pinned),ne=E.filter(e=>!e.pinned),re=e=>ne.filter(t=>(t.projectId??null)===e);function M(e){return E.find(t=>t._id===e)}async function ie(e){O(null);let{active:t,over:n}=e;if(!n)return;let r=M(String(t.id));if(!r)return;let i=String(n.id);if(i.startsWith(`project:`)){let e=i===s5?null:i.slice(8);if((r.projectId??null)===e)return;T.current=!0,w(t=>(t??E).map(t=>t._id===r._id?{...t,projectId:e}:t));try{await h({chatId:r._id,projectId:e})}finally{T.current=!1}return}let a=M(i);if(!a||t.id===n.id)return;if((a.projectId??null)!==(r.projectId??null)||a.pinned!==r.pinned){if(r.pinned||a.pinned)return;T.current=!0,w(e=>(e??E).map(e=>e._id===r._id?{...e,projectId:a.projectId??null}:e));try{await h({chatId:r._id,projectId:a.projectId??null})}finally{T.current=!1}return}let o=a.pinned?j:re(a.projectId??null),s=o.map(e=>e._id),c=s.indexOf(r._id),l=s.indexOf(a._id);if(c<0||l<0)return;let u=[...o];u.splice(c,1),u.splice(l,0,r);let d=u[l-1]??null,f=u[l+1]??null;T.current=!0,w(e=>[...(e??E).filter(e=>!o.some(t=>t._id===e._id)),...u]);try{await m({chatId:r._id,prevKey:d?d.sortKey:null,nextKey:f?f.sortKey:null})}finally{T.current=!1}}let ae=D?M(D):null;return(0,I.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,I.jsxs)(`div`,{className:`oc-sidebar__top`,ref:v,children:[(0,I.jsxs)(X,{className:x===`icon`?`oc-newchat flex-1 justify-center`:`oc-newchat flex-1 justify-start`,onClick:n,title:`${_} (${r})`,"aria-label":_,children:[(0,I.jsx)(Pm,{}),x===`icon`?null:(0,I.jsx)(`span`,{className:`oc-newchat__label`,children:_}),x===`full`?(0,I.jsx)(`kbd`,{className:`oc-newchat__kbd`,"aria-hidden":!0,children:r}):null]}),(0,I.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,I.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:y,children:[(0,I.jsxs)(X,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,I.jsx)(Pm,{}),(0,I.jsx)(`span`,{className:`oc-newchat__label`,children:_}),(0,I.jsx)(`kbd`,{className:`oc-newchat__kbd`,children:r})]}),(0,I.jsx)(X,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,I.jsx)(xm,{})})]})}),(0,I.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,I.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:b,children:[(0,I.jsxs)(X,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,I.jsx)(Pm,{}),(0,I.jsx)(`span`,{className:`oc-newchat__label`,children:_})]}),(0,I.jsx)(X,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,I.jsx)(xm,{})})]})}),(0,I.jsx)(X,{className:`oc-newproject`,variant:`outline`,size:`icon`,"aria-label":TQ(),title:TQ(),onClick:async()=>{let e=await g({title:TQ(),label:QLe(),placeholder:tRe(),confirmLabel:iRe()});e&&await f({name:e})},children:(0,I.jsx)(xm,{})})]}),(0,I.jsxs)(P8,{sensors:A,collisionDetection:L6,modifiers:[drt,urt],onDragStart:e=>O(e.active.id),onDragCancel:()=>O(null),onDragEnd:ie,children:[(0,I.jsxs)(`div`,{className:`oc-sidebar__scroll`,children:[j.length>0?(0,I.jsx)(l5,{label:sRe(),chats:j,children:j.map(n=>(0,I.jsx)(d5,{chat:n,active:n._id===e,projects:a??[],onSelect:t,showProviderBadge:u},n._id))}):null,(a??[]).map(n=>{let r=re(n._id);return(0,I.jsx)(l5,{label:n.name,dropId:krt(n._id),projectId:n._id,chats:r,collapsible:!0,collapsed:n.collapsed,onToggle:()=>void p({projectId:n._id,collapsed:!n.collapsed}),children:n.collapsed?null:r.length===0?(0,I.jsx)(`div`,{className:`oc-sidebar__empty`,children:uRe()}):r.map(n=>(0,I.jsx)(d5,{chat:n,active:n._id===e,projects:a??[],onSelect:t,showProviderBadge:u},n._id))},n._id)}),(0,I.jsx)(l5,{label:pRe(),dropId:s5,chats:re(null),collapsible:!0,collapsed:ee,onToggle:k,children:ee?null:re(null).map(n=>(0,I.jsx)(d5,{chat:n,active:n._id===e,projects:a??[],onSelect:t,showProviderBadge:u},n._id))})]}),(0,I.jsx)(srt,{children:ae?(0,I.jsxs)(`div`,{className:`oc-chatitem oc-chatitem--overlay`,children:[(0,I.jsx)(Sm,{className:`size-3.5 opacity-60`}),o5(ae.color)?(0,I.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:o5(ae.color)}}):(0,I.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,I.jsx)(`span`,{className:`oc-chatitem__label`,children:ae.title||EQ()})]}):null})]})]})}function l5({label:e,dropId:t,projectId:n,chats:r,collapsible:i,collapsed:a,onToggle:o,children:s}){let c=F(V.projects.deleteProject),l=C1(),u=P(V.projects.projectChatCount,n?{projectId:n}:`skip`),{setNodeRef:d,isOver:f}=L8({id:t??`static:${e}`});return(0,I.jsxs)(`div`,{ref:t?d:void 0,className:`oc-sidebar__group`+(f?` oc-sidebar__group--over`:``),children:[(0,I.jsxs)(`div`,{className:`oc-sidebar__group-head`+(i?` oc-sidebar__group-head--btn`:``),...i?{role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{i&&o&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())}}:{},children:[i?a?(0,I.jsx)(fm,{className:`size-3.5`}):(0,I.jsx)(dm,{className:`size-3.5`}):null,(0,I.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e}),n?(0,I.jsx)(`button`,{className:`oc-sidebar__group-del`,"aria-label":OQ(),onClick:async t=>{t.stopPropagation();let r=u??0;await l({title:SRe({name:e}),description:r>0?TRe({count:r}):ORe(),confirmWord:kQ(),confirmLabel:OQ(),destructive:!0})&&await c({projectId:n})},children:(0,I.jsx)(Vm,{className:`size-3.5`})}):null]}),(0,I.jsx)(K8,{items:r.map(e=>e._id),strategy:_rt,children:s})]})}var u5={openclaw:`OpenClaw`,hermes:`Hermes`};function d5({chat:e,active:t,projects:n,onSelect:r,showProviderBadge:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=J8({id:e._id}),d=F(V.chats.renameChat),f=F(V.chats.deleteChat),p=F(V.chats.pinChat),m=F(V.chats.setChatColor),h=P(V.me.getMe,{host:xO})?.ui?.effective?.showChatAge??!0,g=C1(),[_,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(e.title??``),x={transform:w6.Transform.toString(c),transition:l,opacity:+!u},S=o5(e.color);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{ref:s,style:x,className:`oc-chatitem group/row`+(t?` oc-chatitem--active`:``),children:[(0,I.jsx)(`button`,{className:`oc-chatitem__grip`,"aria-label":NRe(),...a,...o,children:(0,I.jsx)(Sm,{className:`size-3.5`})}),S?(0,I.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:S}}):(0,I.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,I.jsx)(`button`,{className:`oc-chatitem__label`,onClick:()=>r(e._id),children:e.title||EQ()}),e.readOnly?(0,I.jsx)(`span`,{className:`oc-chatitem__readonly`,title:DQ(),children:(0,I.jsx)(wm,{size:12,"aria-label":DQ()})}):null,i&&e.providerKind?(0,I.jsx)(`span`,{className:`oc-chatitem__bridge oc-chatitem__bridge--${e.providerKind} group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:oze({provider:u5[e.providerKind]}),children:u5[e.providerKind]}):null,h?(0,I.jsx)(`span`,{className:`oc-chatitem__age group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:new Date(e.updatedAt).toLocaleString(`fr-FR`),children:Ort(e.updatedAt,Date.now())}):null,(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":IRe(),className:`opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,I.jsx)(ym,{})})}),(0,I.jsxs)(J$,{align:`end`,className:`w-48`,children:[(0,I.jsxs)(Y$,{onSelect:()=>{b(e.title??``),v(!0)},children:[(0,I.jsx)(Mee,{}),` `,zRe()]}),(0,I.jsxs)(Y$,{onSelect:()=>void p({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,I.jsx)(Pee,{}):(0,I.jsx)(Nee,{}),e.pinned?HRe():GRe()]}),(0,I.jsx)(X$,{children:JRe()}),(0,I.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,I.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void m({chatId:e._id,color:null}),"aria-label":ZRe(),children:`✕`}),a5.map(t=>(0,I.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void m({chatId:e._id,color:t.value})},t.value))]}),(0,I.jsx)(Z$,{}),(0,I.jsxs)(Y$,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await g({title:eze(),description:rze(),confirmLabel:kQ(),destructive:!0})&&await f({chatId:e._id})})},children:[(0,I.jsx)(Vm,{}),` `,kQ()]})]})]})]}),(0,I.jsx)(Q8,{open:_,onOpenChange:v,title:lze(),canSubmit:y.trim().length>0,onSubmit:async()=>{await d({chatId:e._id,title:y.trim()}),v(!1)},children:(0,I.jsx)(`div`,{className:`oc-form`,children:(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:fze()}),(0,I.jsx)(o1,{value:y,onChange:e=>b(e.target.value),autoFocus:!0})]})})})]})}var jrt=i1(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function $({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,I.jsx)(n?Cy:`span`,{"data-slot":`badge`,"data-variant":t,className:G$(jrt({variant:t}),e),...r})}function Mrt(e){let t=new Map;for(let n of e){let e=t.get(n.instanceName);e||(e={instanceName:n.instanceName,kind:n.kind,agents:[]},t.set(n.instanceName,e)),e.agents.push(n)}let n=e=>(e.displayName??e.agentId).toLowerCase();for(let e of t.values())e.agents.sort((e,t)=>e.isDefault===t.isDefault?n(e).localeCompare(n(t)):e.isDefault?-1:1);let r=[...t.values()],i=e=>e.agents.some(e=>e.isDefault);return r.sort((e,t)=>i(e)===i(t)?e.instanceName.localeCompare(t.instanceName):i(e)?-1:1),r}function Nrt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.displayName,e.agentId,e.instanceName,e.model].filter(Boolean).some(e=>e.toLowerCase().includes(n))):e}function Prt({open:e,onOpenChange:t,agents:n,onPick:r}){let[i,a]=(0,N.useState)(``),o=(0,N.useMemo)(()=>Mrt(Nrt(n??[],i)),[n,i]);return(0,I.jsx)(h1,{open:e,onOpenChange:t,children:(0,I.jsxs)(g1,{className:`oc-agentpicker`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:_Ve()}),(0,I.jsx)(b1,{children:bVe()})]}),n===void 0?(0,I.jsx)(`p`,{className:`oc-agentpicker__hint`,children:CVe()}):n.length===0?(0,I.jsx)(`p`,{className:`oc-agentpicker__hint`,children:EVe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o1,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:kVe(),className:`oc-agentpicker__search`,"aria-label":MVe()}),(0,I.jsx)(`div`,{className:`oc-agentpicker__list`,role:`listbox`,children:o.map(e=>(0,I.jsxs)(`div`,{className:`oc-agentpicker__group`,children:[(0,I.jsxs)(`div`,{className:`oc-agentpicker__instance`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),(0,I.jsx)(`span`,{children:e.instanceName}),(0,I.jsx)($,{variant:`outline`,className:`oc-agentpicker__kind`,children:e.kind})]}),e.agents.map(e=>(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,className:`oc-agentpicker__item`,onClick:()=>r(e.instanceName,e.agentId),disabled:e.state===`deleted`,title:e.state===`deleted`?FVe():void 0,children:[(0,I.jsx)(lm,{size:15,"aria-hidden":!0,className:`oc-agentpicker__icon`}),(0,I.jsxs)(`span`,{className:`oc-agentpicker__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,I.jsx)(`span`,{className:`oc-agentpicker__model`,children:e.model}):null,e.isDefault?(0,I.jsx)(Bm,{size:13,"aria-label":RVe(),className:`oc-agentpicker__default`}):null]},`${e.instanceName}/${e.agentId}`))]},e.instanceName))})]})]})})}function Frt(e){let t=F(V.chats.createChat),n=P(V.agents.listMyAgents),[r,i]=(0,N.useState)(!1),a=(0,N.useCallback)(async(n,r)=>{e(await t({title:`New chat`,instanceName:n,agentId:r}))},[t,e]);return{startNewChat:(0,N.useCallback)(async()=>{let e=n;if(e&&e.length===1&&e[0].state!==`deleted`){await a(e[0].instanceName,e[0].agentId);return}i(!0)},[n,a]),picker:(0,I.jsx)(Prt,{open:r,onOpenChange:i,agents:n,onPick:(e,t)=>{i(!1),a(e,t)}})}}var f5=[`admin`,`user`,`pending`];function p5(){let e=P(V.me.authProviders)?.anonymous===!0,[t,n]=(0,N.useState)(!1),r=P(V.dev.listUsersDev,e?{}:`skip`),i=P(V.me.getImpersonation),a=F(V.dev.setMyRole),o=F(V.dev.setRole),s=F(V.admin.startImpersonation),c=F(V.admin.stopImpersonation);if(!e)return null;let l=r?.find(e=>e.isMe),u=l?.role===`admin`,d=i?.impersonating===!0,f=(r??[]).filter(e=>!e.isMe);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-devfab`,onClick:()=>n(!0),title:aLe(),children:[(0,I.jsx)(Gm,{size:13}),`DEV`]}),(0,I.jsx)(h1,{open:t,onOpenChange:n,children:(0,I.jsxs)(g1,{children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:cLe()}),(0,I.jsx)(b1,{children:dLe()})]}),(0,I.jsxs)(`div`,{className:`oc-devsw__me`,children:[(0,I.jsxs)(`span`,{className:`oc-devsw__melabel`,children:[mLe({canonical:l?.canonical??`…`}),` `,(0,I.jsx)($,{variant:`outline`,children:l?.role??`…`})]}),(0,I.jsx)(`div`,{className:`oc-devsw__roles`,children:f5.map(e=>(0,I.jsx)(X,{type:`button`,size:`xs`,variant:l?.role===e?`secondary`:`ghost`,disabled:l?.role===e,onClick:()=>void a({role:e}),children:e===`admin`?_Le():e===`user`?bLe():CLe()},e))})]}),d?(0,I.jsxs)(`div`,{className:`oc-devsw__imp`,children:[ELe(),` `,(0,I.jsx)(`strong`,{children:i.targetLabel}),`.`,(0,I.jsx)(X,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>void c(),children:kLe()})]}):null,(0,I.jsx)(`div`,{className:`oc-devsw__list`,children:f.length===0?(0,I.jsx)(`p`,{className:`oc-devsw__empty`,children:MLe()}):f.map(e=>(0,I.jsxs)(`div`,{className:`oc-devsw__row`,children:[(0,I.jsx)(`span`,{className:`oc-devsw__label`,children:e.name||e.email||e.canonical||e.userId.slice(0,8)}),(0,I.jsx)(`select`,{className:`oc-devsw__select`,value:e.role,disabled:!e.canonical,onChange:t=>e.canonical&&void o({canonical:e.canonical,role:t.target.value}),children:f5.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))}),(0,I.jsx)(X,{type:`button`,size:`xs`,variant:`ghost`,disabled:!u||e.role===`pending`,title:u?e.role===`pending`?RLe():VLe():FLe(),onClick:()=>{s({profileId:e.profileId}),n(!1)},children:WLe()})]},e.profileId))})]})})]})}function m5({label:e,mode:t,minimal:n=!1}){let{signOut:r}=Ir(),i=F(V.me.setThemeMode).withOptimisticUpdate((e,{mode:t})=>{let n=e.getQuery(V.me.getMe,{host:xO});if(!n)return;let r=t===null?n.defaultThemeMode??`system`:t;e.setQuery(V.me.getMe,{host:xO},{...n,themeMode:t,resolvedThemeMode:r})}),a=t??`default`;return(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsxs)(X,{variant:`ghost`,size:`sm`,className:`gap-1.5`,children:[e,(0,I.jsx)(dm,{className:`opacity-60`})]})}),(0,I.jsx)(J$,{align:`end`,className:`w-52`,children:n?(0,I.jsxs)(Y$,{onClick:()=>void r(),children:[(0,I.jsx)(Tm,{}),` `,uk()]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X$,{children:YO()}),(0,I.jsxs)(Q2e,{value:a,onValueChange:e=>void i({mode:e==="default"?null:e}),children:[(0,I.jsxs)(Q$,{value:`light`,children:[(0,I.jsx)(Ree,{}),` `,QO()]}),(0,I.jsxs)(Q$,{value:`dark`,children:[(0,I.jsx)(Am,{}),` `,tk()]}),(0,I.jsxs)(Q$,{value:`system`,children:[(0,I.jsx)(km,{}),` `,ik()]}),(0,I.jsx)(Q$,{value:`default`,children:sk()})]}),(0,I.jsx)(Z$,{}),(0,I.jsxs)(Y$,{onClick:()=>void r(),children:[(0,I.jsx)(Tm,{}),` `,uk()]})]})})]})}var Irt={altered_words:()=>$We(),incorrect:()=>nGe(),incoherence:()=>aGe(),formatting:()=>cGe(),latency:()=>dGe(),api_error:()=>mGe(),other:()=>_Ge()},Lrt=e=>Irt[e]?.()??e,Rrt={anomaly_open:Hm,anomaly_resolved:gm,feedback_reply:Em};function zrt(e){return e.kind===`feedback_reply`?{title:qWe(),body:XWe()}:{title:e.title,body:e.body}}function h5(){let e=P(V.notifications.myUnreadCount)??0,t=P(V.notifications.myNotifications),n=P(V.feedback.myFeedback),r=F(V.notifications.markRead),i=F(V.notifications.markAllRead),a=F(V.notifications.clearOne),o=F(V.notifications.clearAll),s=F(V.feedback.closeMyFeedback),c=ss(),[l,u]=(0,N.useState)(!1),d=e=>{if(e.unread&&r({notificationId:e._id}),!e.href)return;if(u(!1),e.href.startsWith(`/chat/`)){c({to:`/chat/$chatId`,params:{chatId:e.href.slice(6)}});return}let[t,n]=e.href.split(`?`);c({to:t,search:Object.fromEntries(new URLSearchParams(n??``))})};return(0,I.jsxs)(K$,{open:l,onOpenChange:u,children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-bell`,"aria-label":e>0?qUe({count:e}):XUe(),children:[(0,I.jsx)(cm,{size:18,"aria-hidden":!0}),e>0?(0,I.jsx)(`span`,{className:`oc-bell__badge`,"aria-hidden":!0,children:e>9?`9+`:e}):null]})}),(0,I.jsxs)(J$,{align:`end`,className:`oc-notif`,children:[(0,I.jsxs)(`div`,{className:`oc-notif__head`,children:[(0,I.jsx)(`span`,{children:$Ue()}),t&&t.length>0?(0,I.jsxs)(`span`,{className:`oc-notif__bulk`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__act`,disabled:e===0,onClick:()=>void i({}),children:nWe()}),(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__act`,onClick:()=>void o({}),children:aWe()})]}):null]}),t===void 0?(0,I.jsx)(`div`,{className:`oc-notif__empty`,children:KO()}):t.length===0?(0,I.jsx)(`div`,{className:`oc-notif__empty`,children:cWe()}):(0,I.jsx)(`div`,{className:`oc-notif__list`,children:t.map(e=>{let t=Rrt[e.kind]??cm,{title:n,body:i}=zrt(e);return(0,I.jsxs)(`div`,{className:`oc-notif__item${e.unread?` is-unread`:``}${e.href?` is-link`:``}`,role:e.href?`button`:void 0,tabIndex:e.href?0:void 0,onClick:e.href?()=>d(e):void 0,children:[(0,I.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,I.jsx)(t,{size:14,className:`oc-notif__kind oc-notif__kind--${e.kind}`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`oc-notif__title`,children:n}),(0,I.jsxs)(`span`,{className:`oc-notif__row-actions`,children:[e.unread?(0,I.jsx)(`button`,{type:`button`,title:jQ(),"aria-label":jQ(),onClick:t=>{t.stopPropagation(),r({notificationId:e._id})},children:(0,I.jsx)(um,{size:13})}):null,(0,I.jsx)(`button`,{type:`button`,title:MQ(),"aria-label":MQ(),onClick:t=>{t.stopPropagation(),a({notificationId:e._id})},children:(0,I.jsx)(Km,{size:13})})]})]}),(0,I.jsx)(`p`,{className:`oc-notif__body`,children:i}),(0,I.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.createdAt).toLocaleString(q())})]},e._id)})}),n&&n.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-notif__head oc-notif__head--sub`,children:hWe()}),(0,I.jsx)(`div`,{className:`oc-notif__list`,children:n.map(e=>(0,I.jsx)(Brt,{it:e,onClose:t=>s({feedbackId:e._id,reason:t}),onNavigate:()=>u(!1)},e._id))})]}):null]})]})}function Brt({it:e,onClose:t,onNavigate:n}){let r=D1(),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(!1);async function f(){d(!0);try{await t(c.trim()||void 0)}catch(e){r.error(NQ(),e)}finally{d(!1)}}return(0,I.jsxs)(`div`,{className:`oc-notif__item`,children:[(0,I.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,I.jsx)(`span`,{className:`oc-notif__title`,children:Lrt(e.category)}),(0,I.jsx)(`span`,{className:`oc-notif__status${e.answered?` is-answered`:``}`,children:e.answered?vWe():xWe()})]}),e.thread.length>0?(0,I.jsx)(`div`,{className:`oc-notif__thread`,children:e.thread.map((e,t)=>(0,I.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,I.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?wWe():DWe()}),(0,I.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):null,e.messageText?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-notif__report-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,I.jsx)(dm,{size:13,"aria-hidden":!0}):(0,I.jsx)(fm,{size:13,"aria-hidden":!0}),NWe()]}),i?(0,I.jsx)(`div`,{className:`oc-notif__report-msg`,children:e.messageText}):null]}):null,(0,I.jsxs)(`div`,{className:`oc-notif__report-actions`,children:[(0,I.jsx)(xs,{to:`/chat/$chatId`,params:{chatId:e.chatId},search:{m:e.messageId},className:`oc-notif__link`,onClick:n,children:AWe()}),o?null:(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__link oc-notif__link--muted`,onClick:()=>s(!0),children:NQ()})]}),o?(0,I.jsxs)(`div`,{className:`oc-notif__close-form`,children:[(0,I.jsx)(`textarea`,{className:`oc-notif__close-input`,rows:2,value:c,onChange:e=>l(e.target.value),placeholder:RWe()}),(0,I.jsxs)(`div`,{className:`oc-notif__close-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__close-confirm`,disabled:u,onClick:()=>void f(),children:VWe()}),(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__close-cancel`,onClick:()=>{s(!1),l(``)},children:WWe()})]})]}):null]})}var g5={mod:!0,key:`k`},_5={mod:!0,shift:!0,key:`o`};function Vrt(e){return/mac/i.test(e)}function Hrt(){if(typeof navigator>`u`)return``;let e=navigator;return e.userAgentData?.platform||e.platform||e.userAgent||``}var v5=null;function y5(){return v5===null&&(v5=Vrt(Hrt())),v5}function b5(e,t){let n=e.key.toUpperCase();if(t){let t=``;return e.alt&&(t+=`⌥`),e.shift&&(t+=`⇧`),e.mod&&(t+=`⌘`),t+n}let r=[];return e.mod&&r.push(`Ctrl`),e.shift&&r.push(`Shift`),e.alt&&r.push(`Alt`),r.push(n),r.join(`+`)}function x5(e,t){let n=e.metaKey||e.ctrlKey;return!!t.mod!==n||!!t.shift!==e.shiftKey||!!t.alt!==e.altKey?!1:e.key.toLowerCase()===t.key.toLowerCase()}var S5=2,Urt=180;function Wrt(){let e=ss(),t=(0,N.useRef)(null),n=(0,N.useRef)(null),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(``),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(0),d=(0,N.useMemo)(()=>b5(g5,y5()),[]);(0,N.useEffect)(()=>{let e=setTimeout(()=>c(a),Urt);return()=>clearTimeout(e)},[a]);let f=s.trim(),p=P(V.search.searchConversations,f.length>=S5?{query:f}:`skip`),m=p??[],h=f.length>=S5&&p===void 0;(0,N.useEffect)(()=>{let e=e=>{x5(e,g5)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,N.useEffect)(()=>{r&&(o(``),c(``),u(0))},[r]),(0,N.useEffect)(()=>{u(0)},[p]),(0,N.useEffect)(()=>{(n.current?.querySelector(`[data-index="${l}"]`))?.scrollIntoView({block:`nearest`})},[l]);let g=(0,N.useCallback)(t=>{i(!1),e({to:`/chat/$chatId`,params:{chatId:t}})},[e]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-search-trigger`,onClick:()=>i(!0),"aria-label":EBe(),children:[(0,I.jsx)(Im,{className:`oc-search-trigger__icon`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`oc-search-trigger__label`,children:kBe()}),(0,I.jsx)(`kbd`,{className:`oc-search-trigger__kbd`,children:d})]}),(0,I.jsx)(h1,{open:r,onOpenChange:i,children:(0,I.jsxs)(g1,{showCloseButton:!1,className:`oc-search-palette top-[12vh] translate-y-0 max-w-xl gap-0 overflow-hidden p-0`,onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,I.jsx)(y1,{className:`sr-only`,children:MBe()}),(0,I.jsxs)(`div`,{className:`oc-search-palette__head`,children:[(0,I.jsx)(Im,{className:`oc-search-palette__head-icon`,"aria-hidden":!0}),(0,I.jsx)(`input`,{ref:t,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),u(e=>Math.min(e+1,m.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),u(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=m[l];t&&g(t.chatId)}},placeholder:FBe(),className:`oc-search-palette__field`,autoComplete:`off`,spellCheck:!1,"aria-label":RBe()})]}),(0,I.jsx)(`div`,{className:`oc-search-palette__results`,ref:n,role:`listbox`,children:f.length<S5?(0,I.jsx)(`div`,{className:`oc-search-palette__hint`,children:VBe({count:S5})}):h?(0,I.jsx)(`div`,{className:`oc-search-palette__hint`,children:WBe()}):m.length===0?(0,I.jsx)(`div`,{className:`oc-search-palette__hint`,children:qBe({term:f})}):m.map((e,t)=>(0,I.jsxs)(`button`,{type:`button`,"data-index":t,role:`option`,"aria-selected":t===l,className:G$(`oc-search-result`,t===l&&`is-active`),onMouseMove:()=>u(t),onClick:()=>g(e.chatId),children:[(0,I.jsx)(`span`,{className:`oc-search-result__icon`,"aria-hidden":!0,children:e.matchedIn===`title`?(0,I.jsx)(kee,{size:15}):(0,I.jsx)(Em,{size:15})}),(0,I.jsxs)(`span`,{className:`oc-search-result__body`,children:[(0,I.jsx)(`span`,{className:`oc-search-result__title`,children:e.title||XBe()}),e.snippet?(0,I.jsx)(`span`,{className:`oc-search-result__snippet`,children:e.snippet}):null]}),(0,I.jsx)(`span`,{className:`oc-search-result__tag`,children:e.matchedIn===`title`?$Be():nVe()})]},e.chatId))}),(0,I.jsxs)(`div`,{className:`oc-search-palette__footer`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:`↑`}),(0,I.jsx)(`kbd`,{children:`↓`}),` `,aVe()]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:`↵`}),` `,cVe()]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:dVe()}),` `,mVe()]})]})]})})]})}var C5=[`conversational`,`documentary`],Grt=new Set(C5),Krt=`conversational`;function qrt(e){let t=new Set((e??[]).filter(e=>Grt.has(e)));return t.size===0?[Krt]:C5.filter(e=>t.has(e))}function Jrt({profileId:e,userLabel:t,open:n,onOpenChange:r}){let i=P(V.agents.listAgentPoolForUser,n&&e?{profileId:e}:`skip`),a=P(V.agents.listUserAgents,n&&e?{profileId:e}:`skip`),o=new Set((a??[]).map(e=>`${e.instanceName}/${e.agentId}`)),s=(a??[]).find(e=>e.isDefault)??null,c=s?`${s.instanceName}/${s.agentId}`:null,l=new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),u=[...(i?.agents??[]).map(e=>({...e,outOfPool:!1})),...(a??[]).filter(e=>!l.has(`${e.instanceName}/${e.agentId}`)).map(e=>({instanceName:e.instanceName,agentId:e.agentId,displayName:e.displayName,emoji:e.emoji,model:e.model,kind:e.kind,state:e.state,outOfPool:!0}))],d=new Map;for(let e of u){let t=d.get(e.instanceName)??[];t.push(e),d.set(e.instanceName,t)}return(0,I.jsx)(h1,{open:n,onOpenChange:r,children:(0,I.jsxs)(g1,{className:`oc-access`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:Yje({user:t})}),(0,I.jsx)(b1,{children:Qje()})]}),i?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:i.inGroup?tMe():iMe()}):null,(0,I.jsx)(`div`,{className:`oc-access__list`,children:i===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:sMe()}):u.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:gMe()}):[...d.entries()].map(([t,n])=>(0,I.jsx)(Yrt,{profileId:e,instanceName:t,kind:n[0].kind,agents:n,assigned:o,defaultKey:c},t))})]})})}function Yrt({profileId:e,instanceName:t,kind:n,agents:r,assigned:i,defaultKey:a}){let o=F(V.agents.assignAgent),s=F(V.agents.removeAgent),c=F(V.agents.setDefaultAgent),l=D1();if(!e)return null;async function u(n,r){try{r?await s({profileId:e,instanceName:t,agentId:n}):await o({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(uMe(),e)}}async function d(n){try{await c({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(pMe(),e)}}return(0,I.jsxs)(`div`,{className:`oc-access__group`,children:[(0,I.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),(0,I.jsx)(`span`,{children:t}),(0,I.jsx)($,{variant:`outline`,className:`oc-access__kind`,children:n})]}),r.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),o=a===n,s=e.state===`deleted`;return(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:r,disabled:s&&!r,onCheckedChange:()=>void u(e.agentId,r),"aria-label":yMe({name:e.displayName??e.agentId})}),(0,I.jsxs)(`span`,{className:`oc-access__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,I.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,s?(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:SMe()}):null,e.outOfPool?(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:TMe()}):null,r?o?(0,I.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":_Q(),title:_Q(),children:(0,I.jsx)(Bm,{size:14,fill:`currentColor`})}):(0,I.jsx)(X,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":vQ(),title:vQ(),onClick:()=>void d(e.agentId),children:(0,I.jsx)(Bm,{size:14})}):null]},e.agentId)})]})}function Xrt(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function Zrt(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=Xrt(i,a);return n===`asc`?c:-c})}function w5({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,I.jsx)(`table`,{"data-slot":`table`,className:G$(`w-full caption-bottom text-sm`,e),...t})})}function T5({className:e,...t}){return(0,I.jsx)(`thead`,{"data-slot":`table-header`,className:G$(`[&_tr]:border-b`,e),...t})}function E5({className:e,...t}){return(0,I.jsx)(`tbody`,{"data-slot":`table-body`,className:G$(`[&_tr:last-child]:border-0`,e),...t})}function D5({className:e,...t}){return(0,I.jsx)(`tr`,{"data-slot":`table-row`,className:G$(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function O5({className:e,...t}){return(0,I.jsx)(`th`,{"data-slot":`table-head`,className:G$(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function k5({className:e,...t}){return(0,I.jsx)(`td`,{"data-slot":`table-cell`,className:G$(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function A5({title:e,rows:t,columns:n,rowActions:r,onAdd:i,addLabel:a=qVe(),bulkActions:o,emptyHint:s=XVe(),isExpanded:c,renderExpanded:l}){let[u,d]=(0,N.useState)(new Set),[f,p]=(0,N.useState)(null),m=t??[],h=f?n[f.index]:void 0,g=f&&h?.sort?Zrt(m,h.sort,f.dir):m;function _(e){p(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let v=+!!o+n.length+ +!!r,y=m.length>0&&u.size===m.length,b=u.size>0&&!y;function x(){d(y?new Set:new Set(m.map(e=>e._id)))}function S(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,I.jsxs)(`div`,{className:`oc-dt`,children:[(0,I.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,I.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,I.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[u.size>0&&o?o.map(e=>(0,I.jsxs)(X,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...u]),d(new Set)},children:[e.variant===`destructive`?(0,I.jsx)(Vm,{}):null,e.label,` (`,u.size,`)`]},e.label)):null,i?(0,I.jsxs)(X,{size:`sm`,onClick:i,children:[(0,I.jsx)(Pm,{}),` `,a]}):null]})]}),t===void 0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:$Ve()}):m.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:s}):(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[o?(0,I.jsx)(O5,{className:`w-8`,children:(0,I.jsx)(A1,{"aria-label":nHe(),checked:y?!0:b?`indeterminate`:!1,onCheckedChange:x})}):null,n.map((e,t)=>{let n=f?.index===t;return e.sort?(0,I.jsx)(O5,{className:e.className,"aria-sort":n?f.dir===`asc`?`ascending`:`descending`:`none`,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>_(t),"aria-label":dHe({column:e.header}),children:[e.header,n?f.dir===`asc`?(0,I.jsx)(pm,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,I.jsx)(dm,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,I.jsx)(mm,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,I.jsx)(O5,{className:e.className,children:e.header},e.header)}),r?(0,I.jsx)(O5,{className:`w-8`}):null]})}),(0,I.jsx)(E5,{children:g.map(e=>{let t=r?.(e)??[],i=c?.(e)??!1;return(0,I.jsxs)(N.Fragment,{children:[(0,I.jsxs)(D5,{className:`group/row`,children:[o?(0,I.jsx)(k5,{children:(0,I.jsx)(A1,{"aria-label":aHe(),checked:u.has(e._id),onCheckedChange:()=>S(e._id)})}):null,n.map(t=>(0,I.jsx)(k5,{className:t.className,children:t.cell(e)},t.header)),r?(0,I.jsx)(k5,{children:t.length>0?(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":cHe(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,I.jsx)(ym,{})})}),(0,I.jsx)(J$,{align:`end`,children:t.map((t,n)=>(0,I.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,I.jsx)(Z$,{}):null,(0,I.jsx)(Y$,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),i&&l?(0,I.jsx)(D5,{className:`oc-dt__expansion`,children:(0,I.jsx)(k5,{colSpan:v,className:`oc-dt__expansion-cell`,children:l(e)})}):null]},e._id)})})]})]})}function j5({delayDuration:e=0,...t}){return(0,I.jsx)(_ue,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function M5({...e}){return(0,I.jsx)(vue,{"data-slot":`tooltip`,...e})}function N5({...e}){return(0,I.jsx)(yue,{"data-slot":`tooltip-trigger`,...e})}function P5({className:e,sideOffset:t=0,children:n,...r}){return(0,I.jsx)(bue,{children:(0,I.jsxs)(xue,{"data-slot":`tooltip-content`,sideOffset:t,className:G$(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,I.jsx)(Sue,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}var F5={AGENT_NOT_FOUND:()=>({label:mHe(),hint:_He()}),AUTH_TOKEN_MISMATCH:()=>({label:bHe(),hint:CHe()}),DEVICE_SIGNING_FAILED:()=>({label:EHe(),hint:kHe()}),SESSION_SCOPE_DENIED:()=>({label:MHe(),hint:FHe()}),GATEWAY_TIMEOUT:()=>({label:RHe(),hint:VHe()}),GATEWAY_DISCONNECTED:()=>({label:WHe(),hint:qHe()}),ATTACHMENT_TOO_LARGE:()=>({label:nUe(),hint:aUe()}),ATTACHMENT_REJECTED:()=>({label:cUe(),hint:dUe()}),BRIDGE_UNREACHABLE:()=>({label:XHe(),hint:$He()}),INVALID_REQUEST:()=>({label:mUe(),hint:_Ue()}),NOT_CONFIGURED:()=>({label:bUe(),hint:CUe()}),UNROUTED:()=>({label:EUe(),hint:kUe()}),UPSTREAM_ERROR:()=>({label:MUe(),hint:FUe()}),UNKNOWN:()=>({label:RUe(),hint:VUe()})};function I5(e){return e?F5[e]?.()??{label:e,hint:WUe()}:F5.UNKNOWN()}var Qrt=[`gateway-http`,`shared-fs`,`off`],$rt=[`inline`,`shared-fs`];He.object({mediaMode:He.optional(He.union(He.literal(`gateway-http`),He.literal(`shared-fs`),He.literal(`off`))),inboundMediaMode:He.optional(He.union(He.literal(`inline`),He.literal(`shared-fs`))),rehydration:He.optional(He.boolean()),mediaMaxMb:He.optional(He.number()),inboundAgentMount:He.optional(He.string()),outboundAgentMount:He.optional(He.string())});var L5={mediaMode:`gateway-http`,inboundMediaMode:`inline`,rehydration:!0,mediaMaxMb:1024,inboundAgentMount:`/home/node/.openclaw/media/inbound`,outboundAgentMount:`/home/node/.openclaw/media/outbound`};function eit(e){return{mediaMode:e.mediaMode??L5.mediaMode,inboundMediaMode:e.inboundMediaMode??L5.inboundMediaMode,rehydration:e.rehydration??L5.rehydration,mediaMaxMb:e.mediaMaxMb??L5.mediaMaxMb,inboundAgentMount:e.inboundAgentMount??L5.inboundAgentMount,outboundAgentMount:e.outboundAgentMount??L5.outboundAgentMount}}function tit(e,t){let n={},r=r=>{(e[r]!==L5[r]||t[r]!==void 0)&&(n[r]=e[r])};return r(`mediaMode`),r(`inboundMediaMode`),r(`rehydration`),r(`mediaMaxMb`),r(`inboundAgentMount`),r(`outboundAgentMount`),n}var R5=e=>typeof e==`string`?e:null;function z5(e){return/^\d+\.\d+\.\d+$/.test(e)?e.split(`.`).map(e=>Number.parseInt(e,10)):null}function B5(e,t){let n=z5(e),r=z5(t);if(n===null||r===null)return null;for(let e=0;e<3;e++){let t=n[e]-r[e];if(t!==0)return t}return 0}function nit(e,t){if(e===null||t===null)return!1;let n=B5(t,e.min);return n!==null&&n>=0}function V5(e,t){let n={range:null,validatedVersions:[]};if(typeof e!=`object`||!e)return n;let r=e.providers;if(typeof r!=`object`||!r)return n;let i=r[t];if(typeof i!=`object`||!i)return n;let a=i,o=null;if(typeof a.supportedRange==`object`&&a.supportedRange!==null){let e=a.supportedRange,t=R5(e.min),n=R5(e.maxValidated);t!==null&&n!==null&&(o={min:t,maxValidated:n})}let s=Array.isArray(a.validatedVersions)?a.validatedVersions.filter(e=>typeof e==`string`):[];return{range:o,validatedVersions:s}}function rit(e,t,n){if(e===null)return`unknown`;let{range:r}=V5(n,t);return nit(r,e)?r!==null&&(B5(e,r.maxValidated)??0)>0?`beyond`:`supported`:`unknown`}function H5(e){return e===`supported`?z0e():e===`beyond`?H0e():G0e()}function U5(e){return e??n$()}function W5(e){return e===null?e2e():Z0e({version:e})}function iit(e,t){if(typeof e!=`object`||!e)return!1;let n=e.providers;return typeof n!=`object`||!n?!1:t in n}function G5(e){return e.filter(e=>e.state===`error`)}function ait(e){return e.reachable&&G5(e.targets).length===0}function oit(e){return e.state===`error`&&e.lastErrorCode!==null}function sit(e){return!!e.lastDownstreamRejectCode}function K5(e){return e.kind??`openclaw`}function cit(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function lit(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,K5(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(K5(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cit(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>K5(e)===r)}))}function uit(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var q5={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function J5(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=q5[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function Y5(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:J5(e.from,t)??t-q5.h,to:J5(e.to,t)??t}}var X5=[{label:FFe(),from:`now-5m`},{label:RFe(),from:`now-15m`},{label:VFe(),from:`now-30m`},{label:WFe(),from:`now-1h`},{label:qFe(),from:`now-3h`},{label:XFe(),from:`now-6h`},{label:$Fe(),from:`now-12h`},{label:nIe(),from:`now-24h`},{label:aIe(),from:`now-2d`},{label:cIe(),from:`now-7d`},{label:dIe(),from:`now-30d`},{label:mIe(),from:`now-90d`}];function Z5(e){return new Date(e).toLocaleString(`fr-FR`,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function dit(e){if(e.kind===`relative`){let t=X5.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${Z5(e.from)} → ${Z5(e.to)}`}function Q5(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function $5(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function fit(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}function e7(e){let[t,n]=(0,N.useState)(0);return(0,N.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,N.useMemo)(()=>{let{from:t,to:n}=Y5(e);return e.kind===`absolute`?{from:t,to:n}:{from:t7(t),to:t7(n)}},[e,t])}function t7(e){return Math.floor(e/6e4)*6e4}function n7({value:e,onChange:t}){let[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(``),o=Y5(e),[s,c]=(0,N.useState)(()=>Q5(o.from)),[l,u]=(0,N.useState)(()=>Q5(o.to));function d(t){if(t){let t=Y5(e);c(Q5(t.from)),u(Q5(t.to)),a(``)}r(t)}function f(e){t({kind:`relative`,from:e,to:`now`}),r(!1)}function p(){let e=$5(s),n=$5(l);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),r(!1))}let m=(0,N.useMemo)(()=>{let e=i.trim().toLowerCase();return e===``?X5:X5.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[i]),h=$5(s)!==null&&$5(l)!==null;return(0,I.jsxs)(CT,{open:n,onOpenChange:d,children:[(0,I.jsx)(wT,{asChild:!0,children:(0,I.jsxs)(X,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,I.jsx)(wee,{}),dit(e)]})}),(0,I.jsx)(TT,{children:(0,I.jsx)(ET,{align:`end`,sideOffset:6,className:`oc-timerange__panel z-50 rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,I.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,I.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,I.jsx)(`div`,{className:`oc-timerange__section-title`,children:`Plage absolue`}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:`De`}),(0,I.jsx)(o1,{type:`datetime-local`,value:s,onChange:e=>c(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:`À`}),(0,I.jsx)(o1,{type:`datetime-local`,value:l,onChange:e=>u(e.target.value)})]}),(0,I.jsx)(X,{size:`sm`,className:`oc-timerange__apply`,disabled:!h,onClick:p,children:`Appliquer`})]}),(0,I.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,I.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,I.jsx)(Im,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,I.jsx)(o1,{value:i,onChange:e=>a(e.target.value),placeholder:`Rechercher une plage`,"aria-label":`Rechercher une plage relative`})]}),(0,I.jsx)(`ul`,{className:`oc-timerange__list`,children:m.length===0?(0,I.jsx)(`li`,{className:`oc-timerange__empty`,children:`Aucune plage.`}):m.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>f(t.from),children:t.label})},t.from))})]})]})})})]})}var pit=250;function r7({q:e,onQChange:t,searchPlaceholder:n=VVe(),children:r,timeRange:i,onTimeRangeChange:a,onReset:o,canReset:s=!0}){let[c,l]=(0,N.useState)(e);(0,N.useEffect)(()=>{l(e)},[e]);let u=(0,N.useRef)(null);function d(e){l(e),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>t(e),pit)}(0,N.useEffect)(()=>()=>{u.current!==null&&window.clearTimeout(u.current)},[]);function f(){u.current!==null&&window.clearTimeout(u.current),o()}return(0,I.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,I.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,I.jsx)(Im,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,I.jsx)(o1,{value:c,onChange:e=>d(e.target.value),placeholder:n,"aria-label":n})]}),r?(0,I.jsx)(`div`,{className:`oc-filterbar__quick`,children:r}):null,i&&a?(0,I.jsx)(n7,{value:i,onChange:a}):null,(0,I.jsxs)(X,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:f,disabled:!s,children:[(0,I.jsx)(Fm,{}),WVe()]})]})}var i7=`__all__`,a7={q:``,state:i7,instance:i7,version:i7},o7={connected:0,error:1,idle:2};function mit(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function hit(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function s7(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function c7(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function git(e,t,n){switch(e){case`state`:return(o7[t.state]??99)-(o7[n.state]??99);case`instance`:return s7(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return s7(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return B5(e,r)??s7(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return s7(t.targetLabel,n.targetLabel)}}function _it(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=c7(t.key,e),a=c7(t.key,r);return i&&a?0:i?1:a?-1:n*git(t.key,e,r)})}function vit(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(o7[e]??99)-(o7[t]??99))}function yit(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>s7(e.label,t.label))}function bit(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>B5(e,t)??s7(e,t))}function xit({connections:e,displayByInstance:t}){let[n,r]=(0,N.useState)(a7),[i,a]=(0,N.useState)(null),o=(0,N.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount,attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,N.useMemo)(()=>vit(o),[o]),c=(0,N.useMemo)(()=>yit(o),[o]),l=(0,N.useMemo)(()=>bit(o),[o]),u=(0,N.useMemo)(()=>_it(hit(o,n),i),[o,n,i]);function d(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:IPe()}):(0,I.jsxs)(`div`,{className:`oc-conn`,children:[(0,I.jsxs)(r7,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:GPe(),onReset:()=>r(a7),canReset:mit(n),children:[(0,I.jsxs)(C3,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:XPe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:i7,children:xQ()}),s.map(e=>(0,I.jsx)(Q,{value:e,children:Cit(e)},e))]})]}),(0,I.jsxs)(C3,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:$Pe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:i7,children:xQ()}),c.map(e=>(0,I.jsx)(Q,{value:e.name,children:e.label},e.name))]})]}),(0,I.jsxs)(C3,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:nFe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:i7,children:xQ()}),l.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})]}),u.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:aFe()}):(0,I.jsxs)(w5,{className:`oc-conn__table`,children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[(0,I.jsx)(l7,{label:cFe(),sortKey:`target`,sort:i,onSort:d}),(0,I.jsx)(l7,{label:dFe(),sortKey:`state`,sort:i,onSort:d}),(0,I.jsx)(l7,{label:mFe(),sortKey:`instance`,sort:i,onSort:d}),(0,I.jsx)(l7,{label:_Fe(),sortKey:`host`,sort:i,onSort:d}),(0,I.jsx)(l7,{label:bFe(),sortKey:`version`,sort:i,onSort:d}),(0,I.jsx)(O5,{children:CFe()}),(0,I.jsx)(l7,{label:EFe(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,I.jsx)(E5,{children:u.map(e=>(0,I.jsx)(Sit,{r:e},e._id))})]})]})}function l7({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,I.jsx)(O5,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,I.jsx)(pm,{size:13,"aria-hidden":!0}):(0,I.jsx)(dm,{size:13,"aria-hidden":!0}):(0,I.jsx)(mm,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function Sit({r:e}){let t=oit(e)?I5(e.lastErrorCode):null,n=sit(e)?I5(e.lastDownstreamRejectCode):null;return(0,I.jsxs)(N.Fragment,{children:[(0,I.jsxs)(D5,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,I.jsx)(k5,{children:(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,I.jsx)(k5,{children:(0,I.jsx)(wit,{state:e.state})}),(0,I.jsx)(k5,{children:e.instanceLabel?(0,I.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,I.jsx)(k5,{children:(0,I.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,I.jsx)(k5,{children:e.gatewayVersion?(0,I.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,I.jsx)(k5,{children:(0,I.jsx)(`span`,{className:`oc-conn__stats`,children:zPe({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,I.jsx)(k5,{children:e.lastOkAt?(0,I.jsx)(`span`,{className:`oc-traces__mono`,children:new Date(e.lastOkAt).toLocaleTimeString(`fr-FR`)}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,I.jsx)(D5,{className:`oc-conn__detail-row`,children:(0,I.jsxs)(k5,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,I.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,I.jsx)(`strong`,{children:t.label}),` `,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${new Date(e.lastErrorAt).toLocaleTimeString(`fr-FR`)}`:``,(0,I.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,I.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[HPe({label:n.label}),` `,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${new Date(e.lastDownstreamRejectAt).toLocaleTimeString(`fr-FR`)}`:``]}):null]})}):null]})}function Cit(e){return e===`connected`?SQ():e===`error`?CQ():wQ()}function wit({state:e}){return e===`connected`?(0,I.jsx)($,{variant:`secondary`,children:SQ()}):e===`error`?(0,I.jsx)($,{variant:`destructive`,children:CQ()}):(0,I.jsx)($,{variant:`outline`,children:wQ()})}function Tit(){return P(V.bridgeHealth.getBridgeHealth,{})}function Eit(){let e=Tit(),t=P(V.compat.getBridgeCompat,{}),n=P(V.me.getMe,{host:xO})?.role===`admin`,r=P(V.admin.listInstances,n?{}:`skip`),i=ss(),a=()=>void i({to:`/settings/anomalies`,search:{status:`open`}}),o=lit(e?e.targets:[],t?t.targets:[],r??[]),s=t?.compat??null,c=t===void 0?`loading`:t===null?`nodata`:`ready`,l=s!==null&&iit(s,`hermes`)&&!o.some(e=>e.key===`hermes`);return(0,I.jsxs)(`div`,{className:`oc-bridge`,children:[(0,I.jsx)(Dit,{health:e,compat:t,onSeeAnomalies:a}),(0,I.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:sPe()}),o.map(e=>(0,I.jsx)(Oit,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:s,compatStatus:c,compatReachable:t?.reachable??!0},e.key)),l?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:J0e()}):null]})}function Dit({health:e,compat:t,onSeeAnomalies:n}){let r=t&&t!==null?(0,I.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:U5(t.bridgeVersion)}),` · `,u0e(),` `,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?n$():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:bQ()});if(e===null)return(0,I.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:fPe()});let i=G5(e.targets),a=!e.reachable,o=ait(e),s=o?`ok`:`error`,c=new Date(e.checkedAt).toLocaleString(`fr-FR`),l=e.startedAt==null?null:new Date(e.startedAt).toLocaleString(`fr-FR`);return(0,I.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${s}`,children:[(0,I.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:o?(0,I.jsx)(gm,{size:22}):a?(0,I.jsx)(zee,{size:22}):(0,I.jsx)(Hm,{size:22})}),(0,I.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,I.jsx)(`div`,{className:`oc-bridge-card__title`,children:o?hPe():a?vPe():xPe({count:i.length})}),(0,I.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(Fee,{size:12,"aria-hidden":!0}),` `,wPe({time:c})]}),l?(0,I.jsx)(`span`,{children:DPe({time:l})}):null,r]}),a?(0,I.jsx)(`p`,{className:`oc-bridge-card__hint`,children:I5(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,I.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:APe()})]})}function Oit({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a}){let o=r?V5(r,e):null,s=new Map;for(let e of n)s.set(e.name,e.displayName??e.name);let c=[],l=new Set;for(let n of t){if(!n.instanceName||l.has(n.instanceName))continue;l.add(n.instanceName);let t=n.gatewayVersion??null;c.push({instanceName:n.instanceName,displayName:s.get(n.instanceName)??n.instanceName,version:t,state:rit(t,e,r)})}let u=c.map(e=>e.state),d=u.includes(`beyond`)?`beyond`:u.length>0&&u.every(e=>e===`supported`)?`supported`:null,[f,p]=(0,N.useState)(!1),[m,h]=(0,N.useState)(null),g=m===null?null:n.find(e=>e.name===m)??null,_=new Set(n.map(e=>e.name));return(0,I.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,I.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,I.jsx)(Lm,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,I.jsx)(`span`,{className:`oc-bridge-provider__name`,children:uit(e)}),d?(0,I.jsx)($,{variant:d===`beyond`?`destructive`:`secondary`,children:H5(d)}):null]}),(0,I.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:i0e()}),(0,I.jsx)(kit,{support:o,compatStatus:i,compatReachable:a,manifest:r,instanceRows:c,canConfigure:e=>_.has(e),onConfigure:h}),(0,I.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,I.jsx)(dm,{size:13,"aria-hidden":!0}):(0,I.jsx)(fm,{size:13,"aria-hidden":!0}),NPe({count:t.length})]}),f?(0,I.jsx)(xit,{connections:t,displayByInstance:s}):null,g?(0,I.jsx)(u7,{instance:g,onClose:()=>h(null)},g._id):null]})}function kit({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,canConfigure:a,onConfigure:o}){return t===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:bQ()}):t===`nodata`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:s0e()}):(0,I.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:h0e()}),r===null?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:v0e()}):(0,I.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,I.jsx)(`span`,{className:`oc-compat__label`,children:x0e()}),e&&e.range!==null?(0,I.jsx)(`span`,{children:w0e({min:e.range.min,max:e.range.maxValidated})}):(0,I.jsx)(`span`,{children:n$()}),e?(0,I.jsx)(Mit,{versions:e.validatedVersions}):null]}),i.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:I0e()}):(0,I.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,I.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,I.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:U5(e.version)}),(0,I.jsx)($,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:H5(e.state)}),a(e.instanceName)?(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon`,className:`oc-compat__target-menu`,"aria-label":yQ(),children:(0,I.jsx)(ym,{size:16,"aria-hidden":!0})})}),(0,I.jsx)(J$,{align:`end`,children:(0,I.jsx)(Y$,{onSelect:()=>o(e.instanceName),children:yQ()})})]}):null]},e.instanceName))})]})}function u7({instance:e,onClose:t}){return(0,I.jsx)(h1,{open:!0,onOpenChange:e=>!e&&t(),children:(0,I.jsxs)(g1,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:MMe({instance:e.displayName??e.name})}),(0,I.jsx)(b1,{children:LMe()})]}),(0,I.jsx)(jit,{instance:e,onClose:t})]})})}function Ait({text:e}){return(0,I.jsx)(j5,{delayDuration:150,children:(0,I.jsxs)(M5,{children:[(0,I.jsx)(N5,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`oc-field__help`,"aria-label":e,onClick:e=>e.preventDefault(),children:(0,I.jsx)(See,{"aria-hidden":!0})})}),(0,I.jsx)(P5,{className:`max-w-xs text-pretty`,children:e})]})})}function d7({label:e,help:t}){return(0,I.jsxs)(`span`,{className:`oc-field__label`,children:[e,(0,I.jsx)(Ait,{text:t})]})}function f7({label:e,result:t}){return t?t.checked?(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,I.jsx)(gm,{"aria-hidden":!0}):(0,I.jsx)(Hm,{"aria-hidden":!0}),(0,I.jsxs)(`span`,{children:[e,` — `,t.ok?YNe():t.detail]})]}):(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,QNe()]}):null}function jit({instance:e,onClose:t}){let n=F(V.admin.upsertInstanceConfig),r=$n(V.bridge.validateMediaPaths),i=D1(),[a,o]=(0,N.useState)(()=>eit(e.config??{})),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null),p=a.inboundMediaMode===`shared-fs`,m=a.mediaMode===`shared-fs`,h=p||m;async function g(){u(!0),f(null);try{f(await r({instanceName:e.name,inboundMediaMode:a.inboundMediaMode,mediaMode:a.mediaMode}))}catch(e){i.error(LNe(),e)}finally{u(!1)}}async function _(){c(!0);try{let r=e.config??{};await n({instanceId:e._id,config:tit(a,r)}),t()}catch(e){i.error(iNe(),e)}finally{c(!1)}}return(0,I.jsx)(`div`,{className:`oc-bridge-config`,children:(0,I.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,I.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(d7,{label:UMe(),help:sNe()}),(0,I.jsxs)(C3,{value:a.mediaMode,onValueChange:e=>o({...a,mediaMode:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-full`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:Qrt.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))})]})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(d7,{label:KMe(),help:uNe()}),(0,I.jsxs)(C3,{value:a.inboundMediaMode,onValueChange:e=>o({...a,inboundMediaMode:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-full`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:$rt.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))})]})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(d7,{label:YMe(),help:pNe()}),(0,I.jsx)(o1,{type:`number`,min:1,max:4096,className:`w-full`,value:a.mediaMaxMb,onChange:e=>o({...a,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),h&&(0,I.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[p&&(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(d7,{label:yNe(),help:SNe()}),(0,I.jsx)(o1,{className:`w-full`,spellCheck:!1,value:a.inboundAgentMount,onChange:e=>o({...a,inboundAgentMount:e.target.value})})]}),m&&(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(d7,{label:TNe(),help:ONe()}),(0,I.jsx)(o1,{className:`w-full`,spellCheck:!1,value:a.outboundAgentMount,onChange:e=>o({...a,outboundAgentMount:e.target.value})})]})]}),(0,I.jsxs)(`label`,{className:`oc-field--row`,children:[(0,I.jsx)(A1,{checked:a.rehydration,onCheckedChange:e=>o({...a,rehydration:e===!0})}),(0,I.jsx)(d7,{label:QMe(),help:gNe()})]}),h&&d!==null&&(0,I.jsx)(`div`,{className:`oc-bridge-config__check`,children:d.reachable?!d.inbound&&!d.outbound?(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,I.jsx)(Hm,{"aria-hidden":!0}),iPe({reason:d.reason??`?`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(f7,{label:UNe(),result:d.inbound}),(0,I.jsx)(f7,{label:KNe(),result:d.outbound}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:BNe()})]}):(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,I.jsx)(Hm,{"aria-hidden":!0}),tPe()]})}),(0,I.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[h&&(0,I.jsxs)(X,{variant:`outline`,size:`sm`,onClick:()=>void g(),disabled:l,children:[l?(0,I.jsx)(Cm,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,l?PNe():jNe()]}),(0,I.jsx)(X,{size:`sm`,onClick:()=>void _(),disabled:s,children:tNe()})]})]})})}function Mit({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,I.jsxs)($$,{children:[(0,I.jsx)(e1,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?D0e():A0e({count:e.length}),(0,I.jsx)(dm,{size:13,"aria-hidden":!0})]})}),(0,I.jsxs)(t1,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,I.jsx)(`p`,{className:`oc-compat__versions-title`,children:N0e()}),(0,I.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,I.jsx)($,{variant:`secondary`,children:e},e))})]})]})}var Nit=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:Aze()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],p7=1;function Pit(){return{id:p7++,field:``,op:`eq`,value:``}}function Fit(e){return e.map(e=>({id:p7++,field:e.field,op:e.op,value:String(e.value)}))}function m7({fields:e,seed:t,onChange:n}){let r=(0,N.useRef)(t),i=!!(r.current&&r.current.length>0),[a,o]=(0,N.useState)(i),[s,c]=(0,N.useState)(()=>i?Fit(r.current):[]);function l(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:fit(e.value)})))}function u(e,t){let n=s.map(n=>n.id===e?{...n,...t}:n);c(n),l(n)}function d(){c(e=>[...e,Pit()])}function f(e){let t=s.filter(t=>t.id!==e);c(t),l(t)}let p=s.filter(e=>e.field!==``&&e.value!==``).length;return(0,I.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,I.jsx)(dm,{className:`oc-advfilter__chevron`+(a?` is-open`:``),"aria-hidden":!0}),Nze(),p>0?(0,I.jsx)(`span`,{className:`oc-advfilter__count`,children:p}):null]}),a?(0,I.jsxs)(`div`,{className:`oc-advfilter__body`,children:[s.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Ize()}):(0,I.jsx)(`ul`,{className:`oc-advfilter__rows`,children:s.map(t=>(0,I.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,I.jsxs)(C3,{value:t.field||void 0,onValueChange:e=>u(t.id,{field:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:zze()})}),(0,I.jsx)(E3,{children:e.map(e=>(0,I.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),(0,I.jsxs)(C3,{value:t.op,onValueChange:e=>u(t.id,{op:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-28`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:Nit.map(e=>(0,I.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),(0,I.jsx)(o1,{className:`oc-advfilter__value`,value:t.value,onChange:e=>u(t.id,{value:e.target.value}),placeholder:Hze()}),(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":Gze(),onClick:()=>f(t.id),children:(0,I.jsx)(Km,{})})]},t.id))}),(0,I.jsxs)(X,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:d,children:[(0,I.jsx)(Pm,{}),Jze()]})]}):null]})}var Iit=[`eq`,`neq`,`contains`,`gt`,`gte`,`lt`,`lte`],h7=[50,100,200,500],g7=`now-30d`,Lit=`now-24h`;function _7(e,t,n=g7,r=`now`){let i=e??n,a=t??r,o=Number(i),s=Number(a);return i!==``&&a!==``&&Number.isFinite(o)&&Number.isFinite(s)?{kind:`absolute`,from:o,to:s}:{kind:`relative`,from:i,to:a}}function v7(e){return e.kind===`absolute`?{from:String(e.from),to:String(e.to)}:{from:e.from,to:e.to}}function y7(e){if(e.length!==0)return JSON.stringify(e)}function b7(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e,r=t.field,i=t.op,a=t.value;typeof r!=`string`||r===``||typeof i!=`string`||!Iit.includes(i)||typeof a!=`string`&&typeof a!=`number`&&typeof a!=`boolean`||n.push({field:r,op:i,value:a})}return n}var x7=sp().optional(),S7=sp().optional(),C7=sp().optional(),w7=sp().optional().catch(void 0),Rit=Rp({q:x7,kind:sp().default(`all`).catch(`all`),limit:fee().pipe(Bp([Kp(h7[0]),Kp(h7[1]),Kp(h7[2]),Kp(h7[3])])).catch(100),statusClass:Wp([`2xx`,`4xx`,`5xx`]).optional().catch(void 0),principalType:Wp([`user`,`service`,`system`]).optional().catch(void 0),direction:Wp([`inbound`,`outbound`,`internal`]).optional().catch(void 0),roleKey:w7,from:S7,to:S7,adv:C7}),zit=Rp({q:x7,action:w7,impersonated:Wp([`yes`,`no`]).optional().catch(void 0),resource:w7,from:S7,to:S7,adv:C7}),Bit=Rp({q:x7,status:Wp([`open`,`acknowledged`,`resolved`,`all`]).default(`open`).catch(`open`),severity:Wp([`info`,`warn`,`critical`]).optional().catch(void 0),kind:w7,from:S7,to:S7}),Vit=Rp({from:S7,to:S7}),Hit=Rp({q:x7,status:Wp([`active`,`disabled`]).optional().catch(void 0)}),Uit=Rp({q:x7,role:w7});Rp({q:x7,mode:Wp([`per-user`,`shared`]).optional().catch(void 0)});var Wit={kind:`relative`,from:g7,to:`now`},T7=`__all__`,E7=[`users`,`groups`,`instances`,`bridge`,`serviceAccounts`,`roles`,`access`,`traces`,`kpi`,`anomalies`,`files`,`agentFiles`,`preferences`,`integrations`,`theme`,`chatDefaults`,`audit`,`feedbacks`],D7=[`groups`,`access`,`roles`,`integrations`,`instances`,`bridge`,`theme`,`feedbacks`,`files`,`agentFiles`,`preferences`,`chatDefaults`],O7={groups:`Groupes`,access:`Accès`,serviceAccounts:`Comptes de service`,roles:`Rôles`,traces:`Traces`,kpi:`KPI`,anomalies:`Anomalies`,integrations:`Intégrations`,feedbacks:`Feedbacks`,bridge:`Bridge`,files:`Fichiers`,agentFiles:`Fichiers d'agent`,theme:`Apparence`,preferences:`Préférences`},k7={users:`admin.manage`,groups:`groups.manage`,instances:`admin.manage`,bridge:`bridge.read`,serviceAccounts:`admin.manage`,roles:`admin.manage`,access:`admin.manage`,traces:`traces.read`,kpi:`kpi.read`,anomalies:`anomalies.read`,files:`chats.read`,agentFiles:`agents.files.read`,preferences:`chats.read`,integrations:`admin.manage`,theme:`chats.read`,chatDefaults:`admin.manage`,audit:`admin.manage`,feedbacks:`admin.manage`},A7=[`traces`,`kpi`,`anomalies`,`bridge`,`agentFiles`,`groups`];function j7(e){let t=new Set(e);return E7.filter(e=>t.has(k7[e]))}function M7(e){return`/settings/${e}`}function N7(e){let t=e.split(`/`)[2];return E7.includes(t)?t:void 0}var Git={uiprefs:`preferences`};function Kit({granted:e,onToggle:t}){let n=new Set(e),r=A7.filter(e=>n.has(k7[e])).length;return(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`outline`,size:`sm`,className:`h-8 w-36 justify-start font-normal`,children:r===0?Vme():Wme({count:r})})}),(0,I.jsxs)(J$,{align:`start`,className:`w-52`,children:[(0,I.jsx)(X$,{children:qme()}),A7.map(e=>{let r=k7[e];return(0,I.jsxs)(Y$,{className:`gap-2`,onSelect:e=>{e.preventDefault(),t(r)},children:[(0,I.jsx)(A1,{checked:n.has(r),"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none`}),(0,I.jsx)(`span`,{children:O7[e]??e})]},e)})]})]})}function qit(){let e=os({from:`/settings/users`}),t=ss({from:`/settings/users`}),n=e.q??``,r=e.role??T7,i=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),a=e=>void t({search:t=>({...t,role:e===T7?void 0:e})}),o=P(V.admin.listUsers,{filter:{q:n||void 0,role:r===T7?void 0:r}}),s=P(V.me.getMe,{host:xO}),c=F(V.admin.setRole),l=F(V.admin.setUserPermissions),u=F(V.admin.startImpersonation),d=F(V.admin.deleteUser),f=F(V.admin.setUserName),p=C1(),m=w1(),h=D1(),[g,_]=(0,N.useState)(null),v=(0,N.useMemo)(()=>{let e=new Set([`pending`,`user`,`admin`]);for(let t of o??[])e.add(t.role);return[...e]},[o]),y=n!==``||r!==T7;function b(){t({search:{},replace:!0})}async function x(e){try{await c(e)}catch(e){h.error(Xme(),e)}}async function S(e){try{await l(e)}catch(e){h.error($me(),e)}}async function C(e){let t=e.email||e.name||e.canonical||e.userId.slice(0,8);if(await p({title:bhe(),description:Che({user:t}),confirmWord:Ehe(),confirmLabel:khe(),destructive:!0}))try{await d({profileId:e._id}),h.success(Fhe({user:t}))}catch(e){h.error(Mhe(),e)}}async function w(e){let t=e.email||e.name||e.userId.slice(0,8),n=await m({title:Vhe(),label:Whe({user:t}),placeholder:qhe(),defaultValue:e.name??``,confirmLabel:QZ()});if(n!==null)try{await f({profileId:e._id,name:n}),h.success(Xhe())}catch(e){h.error($he(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(r7,{q:n,onQChange:i,searchPlaceholder:nhe(),onReset:b,canReset:y,children:(0,I.jsxs)(C3,{value:r,onValueChange:a,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:T7,children:ahe()}),v.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})}),(0,I.jsx)(A5,{title:che(),rows:o,emptyHint:dhe(),rowActions:e=>{let t=[{label:Rhe(),onSelect:()=>void w(e)}];return e.userId!==s?.userId&&t.push({label:mhe(),onSelect:()=>void u({profileId:e._id})},{label:_he(),variant:`destructive`,onSelect:()=>void C(e)}),t},columns:[{header:nge(),cell:e=>{let t=e.email||e.name||e.canonical||e.userId.slice(0,8),n=e.email&&e.name&&e.name!==e.email?e.name:null;return(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{children:t}),n?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n}):null]})},sort:e=>e.email||e.name||e.canonical||e.userId},{header:age(),sort:e=>e.role===`admin`?2:+(e.role===`user`),cell:e=>(0,I.jsxs)(C3,{value:e.role,onValueChange:t=>void x({profileId:e._id,role:t}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-28`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`pending`,children:`pending`}),(0,I.jsx)(Q,{value:`user`,children:`user`}),(0,I.jsx)(Q,{value:`admin`,children:`admin`})]})]})},{header:cge(),sort:e=>e.role===`admin`?9999:e.extraPermissions?.length??0,cell:e=>e.role===`admin`?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:dge()}):(0,I.jsx)(Kit,{granted:e.extraPermissions??[],onToggle:t=>{let n=new Set(e.extraPermissions??[]);n.has(t)?n.delete(t):n.add(t),S({profileId:e._id,permissions:[...n]})}})},{header:YZ(),cell:e=>(0,I.jsx)(X,{variant:`outline`,size:`sm`,className:`h-8 font-normal`,onClick:()=>_({profileId:e._id,label:e.email||e.name||e.canonical||e.userId.slice(0,8)}),children:XZ()})}]}),(0,I.jsx)(Jrt,{profileId:g?.profileId??null,userLabel:g?.label??``,open:g!==null,onOpenChange:e=>{e||_(null)}})]})}var P7={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,gatewayVersion:``,gatewayHttpUrl:``},Jit={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Yit(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``}}function Xit(){let e=P(V.admin.listInstances,{}),t=P(V.agents.listAllInstanceAgents,{}),n=F(V.admin.upsertInstance),r=F(V.admin.deleteInstance),i=D1(),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(P7),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(null);async function _(){try{await n({instanceId:h??void 0,name:s.name,gatewayUrl:s.gatewayUrl,bridgeUrl:s.bridgeUrl||void 0,displayName:s.displayName||void 0,kind:s.kind,gatewayVersion:s.gatewayVersion||void 0,gatewayHttpUrl:s.gatewayHttpUrl||void 0}),c(P7),g(null),o(!1)}catch(e){i.error(vge(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[xge(),(0,I.jsx)(`strong`,{children:wge()}),Dge()]}),(0,I.jsx)(A5,{title:Age(),rows:e,addLabel:Nge(),onAdd:()=>{g(null),c(P7),o(!0)},emptyHint:Ige(),columns:[{header:zge(),cell:e=>e.name,sort:e=>e.name},{header:Hge(),cell:e=>(0,I.jsx)($,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Gge(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Jge(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:YZ(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,I.jsxs)($,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?oQ():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:a_e(),onSelect:()=>{g(e._id),c(Yit(e)),o(!0)}},{label:XZ(),onSelect:()=>u(e.name)},{label:Y_e(),onSelect:()=>m(e)},{label:Zge(),onSelect:()=>f(e)},{label:ZZ(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:ZZ(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,I.jsx)(Q8,{open:a,onOpenChange:o,title:h?c_e():n_e(),description:m_e(),canSubmit:!!(s.name&&s.gatewayUrl),onSubmit:_,submitLabel:QZ(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(L7,{label:y_e(),children:[(0,I.jsx)(o1,{value:s.name,disabled:h!==null,onChange:e=>c({...s,name:e.target.value})}),h?(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d_e()}):null]}),(0,I.jsx)(L7,{label:S_e(),children:(0,I.jsxs)(C3,{value:s.kind,onValueChange:e=>c({...s,kind:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`openclaw`,children:`OpenClaw`}),(0,I.jsx)(Q,{value:`hermes`,children:`Hermes`})]})]})}),(0,I.jsx)(L7,{label:T_e(),children:(0,I.jsx)(o1,{value:s.gatewayUrl,onChange:e=>c({...s,gatewayUrl:e.target.value})})}),(0,I.jsx)(L7,{label:O_e(),children:(0,I.jsx)(o1,{value:s.bridgeUrl,placeholder:j_e(),onChange:e=>c({...s,bridgeUrl:e.target.value})})}),(0,I.jsx)(L7,{label:P_e(),children:(0,I.jsx)(o1,{value:s.displayName,onChange:e=>c({...s,displayName:e.target.value})})}),(0,I.jsx)(L7,{label:L_e(),children:(0,I.jsx)(o1,{value:s.gatewayVersion,placeholder:B_e(),onChange:e=>c({...s,gatewayVersion:e.target.value})})}),(0,I.jsx)(L7,{label:U_e(),children:(0,I.jsx)(o1,{value:s.gatewayHttpUrl,placeholder:K_e(),onChange:e=>c({...s,gatewayHttpUrl:e.target.value})})})]})}),(0,I.jsx)(iat,{instanceName:l,open:l!==null,onOpenChange:e=>{e||u(null)}}),d?(0,I.jsx)(u7,{instance:d,onClose:()=>f(null)},d._id):null,p?(0,I.jsx)(Zit,{instance:p,onClose:()=>m(null)},p._id):null]})}function Zit({instance:e,onClose:t}){let n=P(V.instanceSecrets.listInstanceSecretStatus,{}),r=Jit[e.kind??`openclaw`],i=(0,N.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,I.jsx)(h1,{open:!0,onOpenChange:e=>!e&&t(),children:(0,I.jsxs)(g1,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:Q_e({instance:e.displayName??e.name})}),(0,I.jsx)(b1,{children:tve()})]}),(0,I.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,I.jsx)(eat,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,I.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,I.jsx)($it,{instance:e})}),(0,I.jsx)(Qit,{instance:e})]})})}function Qit({instance:e}){let t=$n(V.instanceSync.forceInstanceSync),n=D1(),[r,i]=(0,N.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(rye());break;case`no_agents`:n.success(lye());break;case`no_bridge_url`:n.error(fye());break;case`deploy_misconfigured`:n.error(hye());break;case`unauthorized`:n.error(xye());break;case`not_served`:n.error(wye());break;default:n.error(vye());break}}catch(e){n.error(oye(),e)}finally{i(!1)}}}return(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Dye()}),(0,I.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,I.jsx)(X,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?eye():Zve()})})]})}function $it({instance:e}){let t=P(V.bridgeAuth.listBridgeAuthStatus,{}),n=$n(V.bridgeAuth.mintBridgeSecret),r=F(V.bridgeAuth.revokeBridgeSecret),i=D1(),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(rQ(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Gye())}catch(e){i.error(rQ(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,I.jsxs)(L7,{label:Aye(),children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Nye()}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)($,{variant:f?`outline`:`secondary`,children:f?`${$Z()} · ${d.prefix}…${d.lastFour}`:eQ()}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(X,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?zye():Iye()}),f?(0,I.jsx)(X,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:Hye()}):null]})]}),s?(0,I.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,I.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Xye()}),(0,I.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,I.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?YV():QV()})]}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:iQ()})]}):null]})}function eat({instanceId:e,field:t,updatedAt:n}){let r=$n(V.instanceSecrets.setInstanceSecret),i=F(V.instanceSecrets.clearInstanceSecret),a=$n(V.deviceIdentity.generateDeviceIdentity),o=D1(),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(!1),h=n!==null,g=t===`deviceIdentity`,_=t===`token`?ive():t===`deviceIdentity`?sve():uve();async function v(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),f(null),m(!1),o.success(kve())}catch(e){o.error(tQ(),e)}finally{u(!1)}}}async function y(){if(!l){u(!0);try{await i({instanceId:e,field:t}),f(null),m(!1),o.success(Pve())}catch(e){o.error(tQ(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{f(await a({instanceId:e})),m(!1),o.success(nQ())}catch(e){o.error(Jve(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),m(!0)}catch{}}return(0,I.jsxs)(L7,{label:_,children:[g?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Bve()}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)($,{variant:h?`outline`:`secondary`,children:h?$Z():eQ()}),(0,I.jsx)(o1,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:h?bve():_ve(),onChange:e=>c(e.target.value)}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(X,{size:`sm`,onClick:()=>void v(),disabled:l||s.trim().length===0,children:Cve()}),g?(0,I.jsx)(X,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:l,children:Lve()}):null,h?(0,I.jsx)(X,{size:`sm`,variant:`destructive`,onClick:()=>void y(),disabled:l,children:Eve()}):null]})]}),d?(0,I.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:nQ()}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Gve()}),(0,I.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,I.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:p?YV():QV()})]}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>{f(null),m(!1)},children:iQ()})]}):null]})}var tat={conversational:xbe,documentary:Dbe},nat={conversational:wbe,documentary:Abe},F7=e=>(tat[e]??(()=>e))(),I7=e=>(nat[e]??(()=>``))();function rat({agentId:e,types:t,onToggle:n}){return(0,I.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,I.jsx)(`span`,{className:`oc-agentcard__types-label`,children:lbe()}),t.map(e=>(0,I.jsx)($,{variant:`secondary`,className:`oc-agenttype__chip`,title:I7(e),children:F7(e)},e)),(0,I.jsxs)($$,{children:[(0,I.jsx)(e1,{asChild:!0,children:(0,I.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:fbe()})}),(0,I.jsxs)(t1,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,I.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:hbe()}),(0,I.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:vbe()}),(0,I.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:C5.map(r=>{let i=`agtype-${e}-${r}`;return(0,I.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,I.jsx)(A1,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,I.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,I.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:F7(r)}),(0,I.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:I7(r)})]})]},r)})})]})]})]})}function iat({instanceName:e,open:t,onOpenChange:n}){let r=P(V.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=F(V.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(V.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(V.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=F(V.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(V.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(V.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=F(V.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(V.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=qrt(r);e.setQuery(V.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=F(V.agents.removeInstanceAgent),c=C1(),l=D1();async function u(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){l.error(aQ(),e)}}async function d(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){l.error(aQ(),e)}}async function f(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){l.error(aQ(),e)}}async function p(t,n){if(e&&await c({title:zbe({name:n}),description:Hbe(),confirmLabel:Gbe(),destructive:!0}))try{await s({instanceName:e,agentId:t}),l.success(Jbe())}catch(e){l.error(aQ(),e)}}return(0,I.jsx)(h1,{open:t,onOpenChange:n,children:(0,I.jsxs)(g1,{className:`oc-access`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:tbe({name:e??``})}),(0,I.jsx)(b1,{children:ibe()})]}),r===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:Zbe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?exe():r.discovery.lastPollOk?rxe():oxe({error:r.discovery.error??`?`})}),r.agents.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:lxe()}):(0,I.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(e=>{let t=e.presentInLastOk===!1,n=r.defaultAgentId===e.agentId,i=e.displayName??e.agentId,a=e.types??[];return(0,I.jsxs)(`div`,{className:`oc-agentcard`+(e.enabled?``:` oc-agentcard--off`),children:[(0,I.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,I.jsx)(A1,{checked:e.enabled,disabled:t,"aria-label":i,onCheckedChange:t=>void u(e.agentId,t===!0)}),(0,I.jsxs)(`span`,{className:`oc-agentcard__name`,title:i,children:[e.emoji?`${e.emoji} `:``,i]}),e.model?(0,I.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:mxe()}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void p(e.agentId,i),children:Ibe()})]}):n?(0,I.jsx)($,{variant:`default`,children:oQ()}):(0,I.jsx)(X,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!e.enabled,onClick:()=>void d(e.agentId),children:Nbe()})]}),e.enabled?(0,I.jsx)(rat,{agentId:e.agentId,types:a,onToggle:t=>void f(e.agentId,t,a)}):null]},e.agentId)})})]})]})})}function L7({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}var aat=[{value:`action`,label:`action`},{value:`realLabel`,label:`acteur réel`},{value:`targetLabel`,label:`au nom de`},{value:`impersonated`,label:`usurpation`},{value:`resource`,label:`ressource`},{value:`resourceId`,label:`id ressource`}];function oat(){let e=os({from:`/settings/audit`}),t=ss({from:`/settings/audit`}),n=e.q??``,r=e.action??T7,i=e.impersonated??T7,a=e.resource??T7,o=_7(e.from,e.to),s=(0,N.useMemo)(()=>b7(e.adv),[e.adv]),{from:c,to:l}=e7(o),u=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),d=e=>void t({search:t=>({...t,action:e===T7?void 0:e})}),f=e=>void t({search:t=>({...t,impersonated:e===T7?void 0:e})}),p=e=>void t({search:t=>({...t,resource:e===T7?void 0:e})}),m=e=>void t({search:t=>({...t,...v7(e)})}),h=e=>void t({search:t=>({...t,adv:y7(e)}),replace:!0}),g=P(V.admin.listAudit,{filter:{q:n||void 0,from:c,to:l,action:r===T7?void 0:r,resource:a===T7?void 0:a,impersonated:i===T7?void 0:i===`yes`,advanced:s.length>0?s:void 0}}),_=(0,N.useMemo)(()=>{let e=new Set;for(let t of g??[])e.add(t.action);return[...e].sort()},[g]),v=(0,N.useMemo)(()=>{let e=new Set;for(let t of g??[])t.resource&&e.add(t.resource);return[...e].sort()},[g]),y=n!==``||r!==T7||i!==T7||a!==T7||s.length>0||o.kind!==`relative`||o.from!==Wit.from;function b(){t({search:{},replace:!0})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[_xe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:bxe()})]}),(0,I.jsxs)(r7,{q:n,onQChange:u,searchPlaceholder:Cxe(),timeRange:o,onTimeRangeChange:m,onReset:b,canReset:y,children:[(0,I.jsxs)(C3,{value:r,onValueChange:d,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:sQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:T7,children:Oxe()}),_.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:i,onValueChange:f,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:T7,children:jxe()}),(0,I.jsx)(Q,{value:`yes`,children:Pxe()}),(0,I.jsx)(Q,{value:`no`,children:Lxe()})]})]}),(0,I.jsxs)(C3,{value:a,onValueChange:p,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:cQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:T7,children:Hxe()}),v.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})]}),(0,I.jsx)(m7,{fields:aat,seed:s,onChange:h}),(0,I.jsx)(A5,{title:Gxe(),rows:g,emptyHint:Jxe(),columns:[{header:Zxe(),cell:e=>new Date(e.at).toLocaleString(`fr-FR`),sort:e=>e.at},{header:sQ(),cell:e=>e.action,sort:e=>e.action},{header:eSe(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:rSe(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:cQ(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}var sat={pending:BCe,user:UCe,admin:KCe,observer:YCe,agent:QCe};function R7(e){if(e.builtin){let t=sat[e.key];if(t)return t()}return e.description}var z7=[{value:`never`,label:()=>iH(),days:null},{value:`30`,label:()=>sH(),days:30},{value:`90`,label:()=>uH(),days:90}],cat=720*60*60*1e3,B7=`__all__`,V7={name:``,roleKey:``,description:``};function lat(){let e=os({from:`/settings/serviceAccounts`}),t=ss({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??B7,[i,a]=(0,N.useState)(B7),o=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),s=e=>void t({search:t=>({...t,status:e===B7?void 0:e})}),c=P(V.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:i===B7?void 0:i,disabled:r===B7?void 0:r===`disabled`}}),l=P(V.apiKeys.listKeys,{}),u=P(V.apiKeys.listRoles,{}),d=F(V.apiKeys.createServiceAccount),f=F(V.apiKeys.updateServiceAccount),p=F(V.apiKeys.deleteServiceAccount),m=$n(V.apiKeys.mintApiKey),h=F(V.apiKeys.revokeApiKey),g=C1(),_=D1(),v=n!==``||i!==B7||r!==B7;function y(){a(B7),t({search:{},replace:!0})}let[b,x]=(0,N.useState)(!1),[S,C]=(0,N.useState)(V7),[w,T]=(0,N.useState)(null),[E,D]=(0,N.useState)(new Set),[O,ee]=(0,N.useState)(null),te=(0,N.useRef)(!1),[k,A]=(0,N.useState)(new Set),[j,ne]=(0,N.useState)({}),[re,M]=(0,N.useState)(null),ie=(0,N.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[l]);function ae(e){D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function oe(){try{w?(await f({serviceAccountId:w,name:S.name,roleKey:S.roleKey,description:S.description}),_.success(gB())):await d({name:S.name,roleKey:S.roleKey,description:S.description||void 0}),C(V7),T(null),x(!1)}catch(e){_.error(w?pB():uB(),e)}}function se(e){C({name:e.name,roleKey:e.roleKey,description:e.description??``}),T(e._id),x(!0)}async function ce(e){if(te.current)return;te.current=!0;let t=j[e._id]??`never`,n=z7.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;ee(e._id);try{let t=await m({serviceAccountId:e._id,expiresAt:r});M({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(yB(),e)}finally{te.current=!1,ee(null)}}async function le(e){if(await g({title:SB(),description:(0,I.jsxs)(I.Fragment,{children:[TB(),` `,(0,I.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,OB(),` `,(0,I.jsx)(`strong`,{children:jB()}),` `,PB()]}),confirmWord:e.name,confirmLabel:LB(),destructive:!0}))try{await p({serviceAccountId:e._id}),_.success(BB(),e.name)}catch(e){_.error(UB(),e)}}async function ue(e){if(await g({title:KB(),description:(0,I.jsxs)(I.Fragment,{children:[YB(),` `,(0,I.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,QB()]}),confirmLabel:tV(),destructive:!0})&&!k.has(e._id)){A(t=>new Set(t).add(e._id));try{await h({keyId:e._id})}catch(e){_.error(iV(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:gR()}),(0,I.jsxs)(r7,{q:n,onQChange:o,searchPlaceholder:yR(),onReset:y,canReset:v,children:[(0,I.jsxs)(C3,{value:i,onValueChange:a,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:SR()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:B7,children:TR()}),(u??[]).map(e=>(0,I.jsx)(Q,{value:e.key,children:e.key},e._id))]})]}),(0,I.jsxs)(C3,{value:r,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:B7,children:OR()}),(0,I.jsx)(Q,{value:`active`,children:jR()}),(0,I.jsx)(Q,{value:`disabled`,children:PR()})]})]})]}),(0,I.jsx)(A5,{title:LR(),rows:c,addLabel:BR(),onAdd:()=>{C(V7),T(null),x(!0)},emptyHint:UR(),isExpanded:e=>E.has(e._id),renderExpanded:e=>(0,I.jsx)(uat,{account:e,keys:ie.get(e._id)??[],onRevoke:ue,revoking:k}),rowActions:e=>[{label:tz(),onSelect:()=>se(e)},{label:KR(),onSelect:()=>void ce(e)},{label:E.has(e._id)?YR():QR(),onSelect:()=>ae(e._id)},{label:iz(),variant:`destructive`,onSelect:()=>void le(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":E.has(e._id)?sz():uz(),onClick:()=>ae(e._id),children:E.has(e._id)?(0,I.jsx)(dm,{}):(0,I.jsx)(fm,{})})},{header:pz(),sort:e=>e.name,cell:e=>(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{children:e.name}),e.description?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:gz(),sort:e=>e.roleKey,cell:e=>(0,I.jsx)($,{variant:`secondary`,children:e.roleKey})},{header:yz(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,I.jsx)($,{variant:`destructive`,children:PR()}):(0,I.jsx)($,{variant:`outline`,children:jR()})},{header:Sz(),cell:e=>(0,I.jsxs)(C3,{value:j[e._id]??`never`,onValueChange:t=>ne(n=>({...n,[e._id]:t})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:z7.map(e=>(0,I.jsx)(Q,{value:e.value,children:e.label()},e.value))})]})},{header:Tz(),sort:e=>(ie.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(ie.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,I.jsx)(`span`,{className:`oc-sa__keycount`,children:O===e._id?Oz():jz({count:t})})}}]}),(0,I.jsx)(Q8,{open:b,onOpenChange:e=>{x(e),e||T(null)},title:w?Pz():Uz(),description:w?Lz():Kz(),canSubmit:!!(S.name&&S.roleKey),onSubmit:oe,submitLabel:w?Bz():Yz(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Qz()}),(0,I.jsx)(o1,{value:S.name,onChange:e=>C({...S,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:tB()}),(0,I.jsxs)(C3,{value:S.roleKey||void 0,onValueChange:e=>C({...S,roleKey:e}),children:[(0,I.jsx)(T3,{className:`w-full`,children:(0,I.jsx)(w3,{placeholder:iB()})}),(0,I.jsx)(E3,{children:(u??[]).map(e=>(0,I.jsxs)(Q,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(u??[]).find(e=>e.key===S.roleKey),t=e?R7(e):null;return t?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:sB()}),(0,I.jsx)(o1,{value:S.description,onChange:e=>C({...S,description:e.target.value})})]})]})}),(0,I.jsx)(dat,{minted:re,onClose:()=>M(null)})]})}function uat({account:e,keys:t,onRevoke:n,revoking:r}){return(0,I.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,I.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[sV(),` `,(0,I.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:uV()}):(0,I.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:pV()}),(0,I.jsx)(`th`,{children:gV()}),(0,I.jsx)(`th`,{children:yV()}),(0,I.jsx)(`th`,{children:SV()}),(0,I.jsx)(`th`,{children:TV()}),(0,I.jsx)(`th`,{children:OV()}),(0,I.jsx)(`th`,{})]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,I.jsx)(`td`,{children:(0,I.jsx)($,{variant:`secondary`,children:e.roleKey})}),(0,I.jsx)(`td`,{children:fat(t.createdAt)}),(0,I.jsx)(`td`,{className:pat(t.lastUsedAt)?`oc-sa__stale`:``,children:mat(t.lastUsedAt)}),(0,I.jsx)(`td`,{children:hat(t.expiresAt)}),(0,I.jsx)(`td`,{children:gat(t)}),(0,I.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,I.jsx)(X,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?jV():PV()})})]},t._id))})]})]})}function dat({minted:e,onClose:t}){let[n,r]=(0,N.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,I.jsx)(h1,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,I.jsxs)(g1,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:LV()}),(0,I.jsx)(b1,{children:BV({name:e.accountName})})]}),(0,I.jsx)(`div`,{className:`oc-sa__minted-warning`,children:UV()}),(0,I.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,I.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,I.jsxs)(X,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":KV(),children:[n?(0,I.jsx)(um,{}):(0,I.jsx)(_m,{}),n?YV():QV()]})]}),(0,I.jsx)(v1,{children:(0,I.jsx)(X,{onClick:()=>{r(!1),t()},children:tH()})})]}):null})}function fat(e){return new Date(e).toLocaleString(`fr-FR`)}function pat(e){return e===null?!1:Date.now()-e>cat}function mat(e){return e===null?pH():new Date(e).toLocaleString(`fr-FR`)}function hat(e){return e===null?`—`:new Date(e).toLocaleDateString(`fr-FR`)}function gat(e){return e.disabled?(0,I.jsx)($,{variant:`destructive`,children:gH()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,I.jsx)($,{variant:`outline`,children:yH()}):(0,I.jsx)($,{variant:`outline`,children:SH()})}var H7=[{group:()=>oSe(),keys:[{key:`traces.read`,label:()=>lQ()},{key:`traces.read.content`,label:()=>CSe(),phi:!0},{key:`traces.write`,label:()=>uQ()}]},{group:()=>lSe(),keys:[{key:`kpi.read`,label:()=>lQ()},{key:`kpi.write`,label:()=>uQ()}]},{group:()=>fSe(),keys:[{key:`openclaw.query`,label:()=>OSe()},{key:`anomalies.read`,label:()=>jSe()},{key:`anomalies.report`,label:()=>PSe()}]},{group:()=>hSe(),keys:[{key:`chats.read`,label:()=>lQ()},{key:`selfheal`,label:()=>BSe()}]},{group:()=>vSe(),keys:[{key:`admin.manage`,label:()=>LSe()}]}],_at=H7.flatMap(e=>e.keys.map(e=>e.key));function U7(e){return e.includes(`*`)}var W7={key:``,name:``,description:``};function vat(){let e=P(V.apiKeys.listRoles,{}),t=F(V.apiKeys.createRole),n=F(V.apiKeys.ensureRolesSeeded),r=F(V.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(V.apiKeys.listRoles,{});r&&e.setQuery(V.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),i=C1(),a=D1(),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(W7),[u,d]=(0,N.useState)(new Set);(0,N.useEffect)(()=>{n({}).catch(e=>{a.error(KSe(),e)})},[n,a]);let f=e??[];async function p(e,t){if(U7(e.permissions)||u.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];if(!(e.builtin&&!await i({title:YSe({name:e.name}),description:QSe(),confirmLabel:tCe()}))){d(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){a.error(iCe(),e)}finally{d(t=>{let n=new Set(t);return n.delete(e._id),n})}}}async function m(){try{await t({key:c.key,name:c.name,description:c.description||void 0,permissions:[]}),l(W7),s(!1)}catch(e){a.error(sCe(),e)}}let h=e===void 0,g=!h&&f.length===0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[uCe(),` `,(0,I.jsx)(`code`,{children:`admin`}),` `,pCe(),` `,(0,I.jsx)(`code`,{children:`traces.read.content`}),` `,gCe()]}),(0,I.jsxs)(`div`,{className:`oc-dt`,children:[(0,I.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,I.jsx)(`h2`,{className:`oc-dt__title`,children:yCe()}),(0,I.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,I.jsx)(X,{size:`sm`,onClick:()=>{l(W7),s(!0)},children:SCe()})})]}),h?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:TCe()}):g?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:OCe()}):(0,I.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,I.jsxs)(`table`,{className:`oc-matrix`,children:[(0,I.jsxs)(`thead`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:jCe()}),H7.map(e=>(0,I.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,I.jsx)(`tr`,{children:H7.flatMap(e=>e.keys.map(e=>(0,I.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?USe({key:e.key}):e.key,children:[e.label(),e.phi?(0,I.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,I.jsx)(`tbody`,{children:f.map(e=>{let t=U7(e.permissions),n=u.has(e._id);return(0,I.jsxs)(`tr`,{children:[(0,I.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,I.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,I.jsx)(`span`,{children:e.name}),(0,I.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,I.jsxs)($,{variant:`outline`,className:`gap-1`,children:[(0,I.jsx)(wm,{}),` `,PCe()]}):(0,I.jsx)($,{variant:`secondary`,children:LCe()})]}),R7(e)?(0,I.jsx)(`p`,{className:`oc-matrix__roledesc`,children:R7(e)}):null]}),_at.map(r=>(0,I.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,I.jsx)(A1,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?twe():n?iwe():r,onCheckedChange:()=>void p(e,r)})},r))]},e.key)})})]})})]}),(0,I.jsx)(Q8,{open:o,onOpenChange:s,title:swe(),description:uwe(),canSubmit:!!(c.key&&c.name),onSubmit:m,submitLabel:pwe(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:gwe()}),(0,I.jsx)(o1,{value:c.key,placeholder:ywe(),onChange:e=>l({...c,key:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Swe()}),(0,I.jsx)(o1,{value:c.name,onChange:e=>l({...c,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Twe()}),(0,I.jsx)(o1,{value:c.description,onChange:e=>l({...c,description:e.target.value})})]})]})})]})}function yat(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function bat(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function xat(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function Sat(e){switch(e){case`admin`:return LJe();case`user`:return BJe();case`pending`:return UJe();default:return e}}function G7(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function K7(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}function Cat({className:e,orientation:t=`horizontal`,...n}){return(0,I.jsx)(Zle,{"data-slot":`tabs`,"data-orientation":t,className:G$(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var wat=i1(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Tat({className:e,variant:t=`default`,...n}){return(0,I.jsx)(Qle,{"data-slot":`tabs-list`,"data-variant":t,className:G$(wat({variant:t}),e),...n})}function q7({className:e,...t}){return(0,I.jsx)($le,{"data-slot":`tabs-trigger`,className:G$(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function J7({className:e,...t}){return(0,I.jsx)(eue,{"data-slot":`tabs-content`,className:G$(`flex-1 text-sm outline-none`,e),...t})}var Y7={name:``,description:``};function X7({icon:e,total:t,items:n}){if(t===0)return(0,I.jsxs)($,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let r=t-n.length;return(0,I.jsxs)(`div`,{className:`oc-group-detail`,children:[n.map((e,t)=>(0,I.jsxs)($,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,I.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},t)),r>0?(0,I.jsxs)($,{variant:`outline`,className:`oc-group-chip`,children:[`+`,r]}):null]})}function Eat(){let e=P(V.groups.listGroups,{}),t=P(V.me.getMe,{host:xO})?.role===`admin`,n=F(V.groups.createGroup),r=F(V.groups.updateGroup),i=F(V.groups.deleteGroup),a=C1(),o=D1(),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(Y7),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(``),_=(0,N.useMemo)(()=>{if(!e)return e;let t=h.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,h]);function v(){u(null),f(Y7),c(!0)}function y(e){u(e),f({name:e.name,description:e.description??``}),c(!0)}async function b(){try{l?await r({groupId:l._id,name:d.name,description:d.description}):await n({name:d.name,description:d.description||void 0}),f(Y7),u(null),c(!1)}catch(e){o.error(nXe(),e)}}async function x(e){if(await a({title:Xqe({name:e.name}),description:$qe(),confirmWord:e.name,confirmLabel:nJe(),cancelLabel:Mqe(),destructive:!0}))try{await i({groupId:e._id})}catch(e){o.error(aXe(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:XKe()}),(0,I.jsx)(r7,{q:h,onQChange:g,onReset:()=>g(``),canReset:h!==``,searchPlaceholder:_qe()}),(0,I.jsx)(A5,{title:qKe(),rows:_,addLabel:$Ke(),onAdd:t?v:void 0,emptyHint:nqe(),columns:[{header:aqe(),cell:e=>e.name,sort:e=>e.name},{header:cqe(),cell:e=>(0,I.jsx)(X7,{icon:(0,I.jsx)(Wm,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,I.jsx)(Rm,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:dqe(),cell:e=>(0,I.jsx)(X7,{icon:(0,I.jsx)(Lm,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:mqe(),cell:e=>(0,I.jsx)(X7,{icon:(0,I.jsx)(jm,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,I.jsx)(Bm,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:bqe(),onSelect:()=>m({groupId:e._id,name:e.name})},...t?[{label:Cqe(),onSelect:()=>y(e)},{label:Eqe(),variant:`destructive`,onSelect:()=>void x(e)}]:[]]}),(0,I.jsx)(Q8,{open:s,onOpenChange:c,title:l?Rqe():Fqe(),description:Vqe(),canSubmit:!!d.name.trim(),onSubmit:b,submitLabel:kqe(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Wqe()}),(0,I.jsx)(o1,{value:d.name,onChange:e=>f({...d,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:qqe()}),(0,I.jsx)(o1,{value:d.description,onChange:e=>f({...d,description:e.target.value})})]})]})}),(0,I.jsx)(Dat,{groupId:p?.groupId??null,groupName:p?.name??``,open:p!==null,onOpenChange:e=>{e||m(null)}})]})}var Z7=8;function Q7({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,I.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,I.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,I.jsx)(bee,{size:14,"aria-hidden":!0}),OJe()]}),(0,I.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":PJe({page:e,pages:t}),children:[e,` / `,t]}),(0,I.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[jJe(),(0,I.jsx)(fm,{size:14,"aria-hidden":!0})]})]})}function Dat({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=P(V.groups.getGroup,n&&e?{groupId:e}:`skip`),a=P(V.groups.listAssignableInstances,n?{}:`skip`),o=P(V.groups.listAssignableUsers,n?{}:`skip`),s=F(V.groups.addMember),c=F(V.groups.removeMember),l=F(V.groups.bulkSetMembers),u=F(V.groups.setGroupManager),d=D1(),[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(``),[g,_]=(0,N.useState)(`members`),[v,y]=(0,N.useState)(1),[b,x]=(0,N.useState)(new Set),S=(0,N.useRef)(null),C=(0,N.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),w=(0,N.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),T=i?.viewerIsAdmin===!0,E=(0,N.useMemo)(()=>new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[i]);(0,N.useEffect)(()=>{p(``),h(``),_(`members`),y(1),S.current=null},[n,e]),(0,N.useEffect)(()=>{y(1)},[f]),(0,N.useEffect)(()=>{n&&i&&e&&S.current!==e&&(S.current=e,x(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let D=(0,N.useMemo)(()=>o?yat(o,f,b):[],[o,f,b]);async function O(t,n){if(e)try{n?await c({groupId:e,userId:t}):await s({groupId:e,userId:t})}catch(e){d.error(KQ(),e)}}async function ee(t,n){if(e)try{await u({groupId:e,userId:t,manager:!n})}catch(e){d.error(ZYe(),e)}}let te=G7(D,e=>C.has(e.userId)),k=D.filter(e=>C.has(e.userId)).length,A=K7(D,v,Z7);async function j(){if(!e||D.length===0)return;let t=D.map(e=>e.userId);try{await l({groupId:e,userIds:t,member:te!==`all`})}catch(e){d.error(KQ(),e)}}return(0,I.jsx)(h1,{open:n,onOpenChange:r,children:(0,I.jsxs)(g1,{className:`oc-access`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:aJe({name:t})}),(0,I.jsx)(b1,{children:cJe()})]}),(0,I.jsxs)(Cat,{value:g,onValueChange:_,className:`oc-access__tabs`,children:[(0,I.jsxs)(Tat,{className:`w-full`,children:[(0,I.jsxs)(q7,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,I.jsx)(Wm,{size:13,"aria-hidden":!0}),dJe(),i?(0,I.jsx)($,{variant:`secondary`,className:`oc-access__tabcount`,children:C.size}):null]}),(0,I.jsxs)(q7,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),_Je(),i?(0,I.jsx)($,{variant:`secondary`,className:`oc-access__tabcount`,children:E.size}):null]}),(0,I.jsxs)(q7,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,I.jsx)(jm,{size:13,"aria-hidden":!0}),CYe(),i?(0,I.jsx)($,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,I.jsx)(J7,{value:`members`,children:o===void 0||i===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:RQ()}):o.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:rYe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o1,{value:f,onChange:e=>p(e.target.value),placeholder:mJe(),className:`oc-access__search`}),D.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:CJe()}):(0,I.jsxs)(I.Fragment,{children:[D.length>1?(0,I.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,I.jsx)(A1,{checked:te===`all`?!0:te===`some`?`indeterminate`:!1,onCheckedChange:()=>void j(),"aria-label":LQ()}),(0,I.jsx)(`span`,{className:`oc-access__label`,children:LQ()}),(0,I.jsxs)($,{variant:`outline`,className:`oc-access__count`,children:[k,` / `,D.length]})]}):null,(0,I.jsx)(`div`,{className:`oc-access__list`,children:A.pageItems.map(e=>{let t=C.has(e.userId),n=xat(e),r=w.has(e.userId);return(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:t,onCheckedChange:()=>void O(e.userId,t),"aria-label":KJe({user:n.primary})}),(0,I.jsxs)(`span`,{className:`oc-access__who`,children:[(0,I.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,I.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,I.jsx)($,{variant:`outline`,className:`oc-access__role`,children:Sat(e.role)}),(0,I.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&T?(0,I.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?WQ():UQ(),title:r?WQ():UQ(),onClick:()=>void ee(e.userId,r),children:(0,I.jsx)(Rm,{size:15,"aria-hidden":!0})}):t&&r?(0,I.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":HQ(),title:HQ(),children:(0,I.jsx)(Rm,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,I.jsx)(Q7,{page:A.page,pageCount:A.pageCount,onPage:y})]})]})}),(0,I.jsx)(J7,{value:`agents`,children:a===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:RQ()}):a.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:oYe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o1,{value:m,onChange:e=>h(e.target.value),placeholder:bJe(),className:`oc-access__search`}),(0,I.jsx)(`div`,{className:`oc-access__list`,children:a.map(t=>(0,I.jsx)(Oat,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:E,query:m},`${e}-${t._id}`))})]})}),(0,I.jsx)(J7,{value:`charts`,children:(0,I.jsx)(kat,{groupId:e})})]})]})})}function Oat({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=P(V.groups.listAssignableAgents,{instanceName:t}),o=F(V.groups.assignAgentToGroup),s=F(V.groups.removeAgentFromGroup),c=F(V.groups.bulkSetGroupAgents),l=D1(),[u,d]=(0,N.useState)(1);if((0,N.useEffect)(()=>{d(1)},[i]),!e)return null;let f=bat(a?.agents??[],i),p=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&f.length===0)return null;let m=f.filter(e=>e.presentInLastOk!==!1),h=G7(m,e=>r.has(`${t}/${e.agentId}`)),g=K7(f,u,Z7);async function _(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){l.error(qQ(),e)}}async function v(){if(m.length===0)return;let n=m.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:h!==`all`})}catch(e){l.error(qQ(),e)}}return(0,I.jsxs)(`div`,{className:`oc-access__group`,children:[(0,I.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),(0,I.jsx)(`span`,{children:t}),(0,I.jsx)($,{variant:`outline`,className:`oc-access__kind`,children:n}),p?(0,I.jsx)($,{variant:`outline`,className:`oc-access__stale`,children:hYe()}):null]}),a===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:eYe()}):f.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:p?fYe():lYe()}):(0,I.jsxs)(I.Fragment,{children:[m.length>1?(0,I.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,I.jsx)(A1,{checked:h===`all`?!0:h===`some`?`indeterminate`:!1,onCheckedChange:()=>void v(),"aria-label":LQ()}),(0,I.jsx)(`span`,{className:`oc-access__label`,children:LQ()})]}):null,g.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1;return(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:i,disabled:a&&!i,onCheckedChange:()=>void _(e.agentId,i),"aria-label":YJe({name:e.displayName??e.agentId})}),(0,I.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,I.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,I.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":zQ(),title:zQ(),children:(0,I.jsx)(Bm,{size:14,fill:`currentColor`})}):null,a?(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:vYe()}):null]},e.agentId)}),(0,I.jsx)(Q7,{page:g.page,pageCount:g.pageCount,onPage:d})]})]})}function kat({groupId:e}){let t=P(V.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=F(V.charts.assignChartToGroup),r=F(V.charts.removeChartFromGroup),i=F(V.charts.setGroupDefaultChart),a=F(V.charts.addChartToGroupPool),o=F(V.charts.removeChartFromGroupPool),s=D1();if(!e)return null;if(t===void 0)return(0,I.jsx)(`p`,{className:`oc-access__hint`,children:RQ()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,I.jsx)(`p`,{className:`oc-access__hint`,children:EYe()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}async function f(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":LYe({name:e.name})}),(0,I.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,I.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":VQ(),title:VQ(),children:(0,I.jsx)(Bm,{size:14,fill:`currentColor`})}):(0,I.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void f(e.chartKey),children:HYe()}):null,u?(0,I.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":BQ({name:e.name}),title:BQ({name:e.name}),onClick:()=>void m(e.chartKey),children:(0,I.jsx)(Km,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,I.jsxs)(C3,{value:``,onValueChange:e=>void p(e),children:[(0,I.jsx)(T3,{size:`sm`,className:`oc-access__search`,children:(0,I.jsx)(w3,{placeholder:MYe()})}),(0,I.jsx)(E3,{children:l.map(e=>(0,I.jsx)(Q,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:kYe()}):null:null]})}var Aat=[50,100,200,500],$7=`all`,e9=`__all__`,jat=[`2xx`,`4xx`,`5xx`],Mat=[`user`,`service`,`system`],Nat=[`inbound`,`outbound`,`internal`],Pat={kind:`relative`,from:`now-30d`,to:`now`},Fat=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:`latence (ms)`},{value:`principalType`,label:`principal`},{value:`direction`,label:`direction`},{value:`roleKey`,label:`rôle`},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function Iat(){let e=os({from:`/settings/traces`}),t=ss({from:`/settings/traces`}),n=e.limit,r=e.kind,i=e.statusClass??e9,a=e.principalType??e9,o=e.direction??e9,s=e.roleKey??e9,c=e.q??``,l=_7(e.from,e.to),u=(0,N.useMemo)(()=>b7(e.adv),[e.adv]),{from:d,to:f}=e7(l),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(null),_=e=>void t({search:t=>({...t,limit:e})}),v=e=>void t({search:t=>({...t,kind:e})}),y=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),b=e=>void t({search:t=>({...t,statusClass:e===e9?void 0:e})}),x=e=>void t({search:t=>({...t,principalType:e===e9?void 0:e})}),S=e=>void t({search:t=>({...t,direction:e===e9?void 0:e})}),C=e=>void t({search:t=>({...t,roleKey:e===e9?void 0:e})}),w=e=>void t({search:t=>({...t,...v7(e)})}),T=e=>void t({search:t=>({...t,adv:y7(e)}),replace:!0}),E=P(V.observability.listEvents,{limit:n}),D=P(V.observability.listEvents,{limit:n,kind:r===$7?void 0:r,filter:{q:c||void 0,from:d,to:f,statusClass:i===e9?void 0:i,principalType:a===e9?void 0:a,direction:o===e9?void 0:o,roleKey:s===e9?void 0:s,advanced:u.length>0?u:void 0}}),O=(0,N.useMemo)(()=>{let e=new Set;for(let t of E??[])e.add(t.kind);return[...e].sort()},[E]),ee=(0,N.useMemo)(()=>{let e=new Set;for(let t of E??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[E]),te=c!==``||i!==e9||a!==e9||o!==e9||s!==e9||u.length>0||l.kind!==`relative`||l.from!==Pat.from;function k(){t({search:{limit:100,kind:`all`},replace:!0})}let A=p?E?.filter(e=>e.correlationId===p):D;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[vOe(),(0,I.jsx)(`strong`,{children:xOe()}),wOe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:DOe()})]}),(0,I.jsxs)(r7,{q:c,onQChange:y,searchPlaceholder:AOe(),timeRange:l,onTimeRangeChange:w,onReset:k,canReset:te,children:[(0,I.jsxs)(C3,{value:i,onValueChange:b,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:NOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:IOe()}),jat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:a,onValueChange:x,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:zOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:HOe()}),Mat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:o,onValueChange:S,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:GOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:JOe()}),Nat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:s,onValueChange:C,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:ZOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:eke()}),ee.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:r,onValueChange:v,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-44`,children:(0,I.jsx)(w3,{placeholder:rke()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:$7,children:oke()}),O.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:String(n),onValueChange:e=>_(Number(e)),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-28`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:Aat.map(e=>(0,I.jsx)(Q,{value:String(e),children:lke({count:e})},e))})]})]}),(0,I.jsx)(m7,{fields:Fat,seed:u,onChange:T}),p?(0,I.jsx)(`div`,{className:`oc-traces__followline`,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>m(null),title:fke(),children:[(0,I.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[hke(),(0,I.jsx)(`code`,{children:t9(p)})]}),(0,I.jsx)(Km,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`sr-only`,children:vke()})]})}):null,(0,I.jsx)(A5,{title:xke(),rows:A,emptyHint:p?wke():Dke(),columns:[{header:Ake(),sort:e=>e.at,cell:e=>(0,I.jsx)(`span`,{className:`oc-traces__time`,children:new Date(e.at).toLocaleString(`fr-FR`)})},{header:Nke(),sort:e=>e.kind,cell:e=>(0,I.jsx)($,{variant:`secondary`,children:e.kind})},{header:Ike(),sort:e=>n9(e)??null,cell:e=>{let t=n9(e);return t?(0,I.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,I.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":zke(),children:`✓`})}},{header:Hke(),sort:e=>e.direction,cell:e=>e.direction?(0,I.jsx)($,{variant:`outline`,children:e.direction}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Gke(),sort:e=>e.principalType,cell:e=>(0,I.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,I.jsx)($,{variant:`outline`,children:e.principalType}),e.principalId?(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:t9(e.principalId)}):null]})},{header:Jke(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,I.jsx)($,{variant:`secondary`,children:e.roleKey}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Zke(),sort:e=>e.route,cell:e=>e.route?(0,I.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,I.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:eAe(),sort:e=>e.status,cell:e=>e.status===null?(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,I.jsx)(`span`,{className:`oc-traces__status ${Lat(e.status)}`,children:e.status})},{header:rAe(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,I.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:oAe(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,I.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:lAe(),onClick:()=>m(e.correlationId),children:t9(e.correlationId)}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:fAe(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>g(e),children:hAe()}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,I.jsx)(Rat,{row:h,onClose:()=>g(null)})]})}function Lat(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function t9(e){return e.length>8?e.slice(0,8):e}function n9(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function Rat({row:e,onClose:t}){let n=(0,N.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,I.jsx)(h1,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,I.jsxs)(g1,{className:`max-w-lg`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsxs)(y1,{className:`oc-traces__meta-title`,children:[vAe(),` `,(0,I.jsx)(`code`,{children:e.kind}),(0,I.jsx)($,{variant:`outline`,children:xAe()})]}),(0,I.jsx)(b1,{children:wAe()})]}),(0,I.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}function r9({className:e,size:t=`default`,...n}){return(0,I.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:G$(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function i9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-header`,className:G$(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t})}function a9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-title`,className:G$(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function o9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-description`,className:G$(`text-sm text-muted-foreground`,e),...t})}function s9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-content`,className:G$(`px-4 group-data-[size=sm]/card:px-3`,e),...t})}function zat({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-footer`,className:G$(`flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3`,e),...t})}var c9=[{metric:`api.calls`,label:_Ie(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:bIe(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:CIe(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:EIe(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:kIe(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:MIe(),unit:`/h`,group:`Assistant`,isError:!0}],l9=c9.length,Bat=[`API`,`OpenClaw`,`Chat`,`Assistant`],Vat=1e3,Hat=36e5;function Uat(e,t){let n=Math.max(1,Math.ceil((t-e)/Hat)),r=Math.min(n*l9,Vat);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/l9))}}function Wat(){let e=os({from:`/settings/kpi`}),t=ss({from:`/settings/kpi`}),n=_7(e.from,e.to,Lit,`now`),r=e=>void t({search:t=>({...t,...v7(e)})}),{from:i,to:a}=e7(n),{rowLimit:o,buckets:s}=Uat(i,a),c=P(V.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),l=(0,N.useMemo)(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),u=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[FIe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:RIe()})]}),(0,I.jsx)(Gat,{value:n,onChange:r})]});return c===void 0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:VIe()})]}):c.length===0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:WIe()})]}):(0,I.jsxs)(I.Fragment,{children:[u,Bat.map(e=>{let t=c9.filter(t=>t.group===e);return t.some(e=>(l.get(e.metric)??[]).length>0)?(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,I.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,I.jsx)(Kat,{config:e,series:l.get(e.metric)??[]},e.metric))})]},e):null})]})}function Gat({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(n7,{value:e,onChange:t})})}function Kat({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(r9,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(i9,{children:[(0,I.jsx)(a9,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(o9,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(s9,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:f9(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(Jat,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:qIe({value:p9(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:XIe()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:$Ie({count:t.length})})]})]})]})}var u9=240,d9=48,qat=1;function Jat({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=u9/e.length,a=Math.max(i-qat,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${u9} ${d9}`,preserveAspectRatio:`none`,role:`img`,"aria-label":nLe({max:f9(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(d9-1):0,c=o*i,l=d9-s;return(0,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.jsxs)(`title`,{children:[p9(e.bucket),` · `,f9(e.value),` `,n]})},e.bucket)})})}function f9(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function p9(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}var m9=`__all__`,Yat=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Xat(e){return e===`open`?Owe():e===`acknowledged`?jwe():Pwe()}var Zat=[`info`,`warn`,`critical`],Qat=[`detector`,`agent`],$at={kind:`relative`,from:`now-30d`,to:`now`},eot=200,h9=`all`;function tot(){let e=os({from:`/settings/anomalies`}),t=ss({from:`/settings/anomalies`}),n=e.q??``,r=e.status===h9?m9:e.status,i=e.severity??m9,a=e.kind??m9,[o,s]=(0,N.useState)(m9),c=_7(e.from,e.to),{from:l,to:u}=e7(c),d=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),f=e=>void t({search:t=>({...t,status:e===m9?h9:e})}),p=e=>void t({search:t=>({...t,severity:e===m9?void 0:e})}),m=e=>void t({search:t=>({...t,kind:e===m9?void 0:e})}),h=e=>void t({search:t=>({...t,...v7(e)})}),g=C1(),_=D1(),v=F(V.anomalies.resolveAnomaly),y=(P(V.me.getMe,{host:xO})?.permissions??[]).includes(`admin.manage`),b=P(V.anomalies.listAnomalies,{limit:eot,filter:{q:n||void 0,from:l,to:u,anomalyStatus:r===m9?void 0:r,severity:i===m9?void 0:i,source:o===m9?void 0:o,kind:a===m9?void 0:a}}),x=(0,N.useMemo)(()=>{let e=new Set;for(let t of b??[])e.add(t.kind);return[...e].sort()},[b]),S=n!==``||r!==`open`||i!==m9||o!==m9||a!==m9||c.kind!==`relative`||c.from!==$at.from;function C(){s(m9),t({search:{status:`open`},replace:!0})}async function w(e){if(await g({title:Lwe(),description:(0,I.jsxs)(I.Fragment,{children:[Bwe(),` `,(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,Uwe(),` `,(0,I.jsx)(`strong`,{children:Kwe()}),`.`,` `,Ywe()]}),confirmLabel:Qwe()}))try{await v({anomalyId:e._id,status:`resolved`}),_.success(tTe(),e.kind)}catch(e){_.error(iTe(),e)}}async function T(e){try{await v({anomalyId:e._id,status:`acknowledged`}),_.success(sTe(),e.kind)}catch(e){_.error(uTe(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[pTe(),` `,(0,I.jsx)(`strong`,{children:gTe()}),` `,yTe(),` `,(0,I.jsx)(`strong`,{children:STe()}),` `,TTe(),` `,(0,I.jsx)(`strong`,{children:OTe()}),` `,jTe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:PTe()})]}),(0,I.jsxs)(r7,{q:n,onQChange:d,searchPlaceholder:LTe(),timeRange:c,onTimeRangeChange:h,onReset:C,canReset:S,children:[(0,I.jsxs)(C3,{value:r,onValueChange:f,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:BTe()}),Yat.map(e=>(0,I.jsx)(Q,{value:e.value,children:Xat(e.value)},e.value))]})]}),(0,I.jsxs)(C3,{value:i,onValueChange:p,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:dQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:GTe()}),Zat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:o,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:fQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:XTe()}),Qat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:a,onValueChange:m,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:pQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:tEe()}),x.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})]}),(0,I.jsx)(A5,{title:iEe(),rows:b,emptyHint:r===`open`?sEe():uEe(),rowActions:e=>y&&e.status===`open`?[{label:pEe(),onSelect:()=>void w(e)},{label:gEe(),onSelect:()=>void T(e)}]:[],columns:[{header:yEe(),cell:e=>(0,I.jsx)(`span`,{className:`oc-traces__time`,children:new Date(e.at).toLocaleString(`fr-FR`)}),sort:e=>e.at},{header:pQ(),cell:e=>(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:dQ(),cell:e=>(0,I.jsx)(iot,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:SEe(),cell:e=>(0,I.jsx)(aot,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:fQ(),cell:e=>(0,I.jsx)($,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:TEe(),cell:e=>(0,I.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),sort:e=>e.message},{header:OEe(),cell:e=>(0,I.jsx)(rot,{row:e}),sort:e=>e.evidence??null},{header:jEe(),cell:e=>e.correlationId?(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:oot(e.correlationId)}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function not(e){if(e.kind!==`openclaw.dispatch_failures`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function rot({row:e}){let t=ss(),n=not(e);if(!n.dominantCode)return(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`});let r=I5(n.dominantCode),i=n.sampleCorrelationId;return(0,I.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,I.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,I.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,I.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,I.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:i,limit:100}}),children:[`↗ `,PEe()]}):null]})}function iot({severity:e}){return(0,I.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function aot({status:e}){return e===`open`?(0,I.jsx)($,{variant:`destructive`,children:LEe()}):e===`acknowledged`?(0,I.jsx)($,{variant:`secondary`,children:BEe()}):(0,I.jsx)($,{variant:`outline`,children:UEe()})}function oot(e){return e.length>8?e.slice(0,8):e}function sot(){let e=P(V.integrations.status.status,{}),t=F(V.admin.setIntegrationConfig),[n,r]=(0,N.useState)(null);if((0,N.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:LJ()});let i=n,a=(e,t,n)=>r({...i,[e]:{...i[e],[t]:n}}),o=(e,n)=>void t({[e]:n});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[BJ(),` `,(0,I.jsx)(`strong`,{children:UJ()}),` `,KJ()]}),(0,I.jsxs)(g9,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,I.jsx)($,{variant:`secondary`,children:YJ()}):(0,I.jsx)($,{variant:`outline`,children:QJ()}):(0,I.jsx)($,{variant:`outline`,children:tY()}),note:sY(),children:[(0,I.jsx)(_9,{label:pY(),children:(0,I.jsx)(o1,{value:i.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>a(`langfuse`,`host`,e.target.value),onBlur:()=>o(`langfuse`,{host:i.langfuse.host??``})})}),(0,I.jsx)(v9,{label:TY(),checked:i.langfuse.enabled??!0,onChange:e=>{a(`langfuse`,`enabled`,e),o(`langfuse`,{enabled:e})}})]}),(0,I.jsxs)(g9,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,I.jsx)($,{variant:`secondary`,children:YJ()}):(0,I.jsx)($,{variant:`outline`,children:QJ()}):(0,I.jsx)($,{variant:`outline`,children:tY()}),note:uY(),children:[(0,I.jsx)(_9,{label:gY(),children:(0,I.jsx)(o1,{value:i.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>a(`opik`,`baseUrl`,e.target.value),onBlur:()=>o(`opik`,{baseUrl:i.opik.baseUrl??``})})}),(0,I.jsx)(_9,{label:yY(),children:(0,I.jsx)(o1,{value:i.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||SY(),onChange:e=>a(`opik`,`workspace`,e.target.value),onBlur:()=>o(`opik`,{workspace:i.opik.workspace??``})})}),(0,I.jsx)(v9,{label:TY(),checked:i.opik.enabled??!0,onChange:e=>{a(`opik`,`enabled`,e),o(`opik`,{enabled:e})}})]}),(0,I.jsxs)(g9,{title:OY(),status:(0,I.jsx)($,{variant:`outline`,children:iY()}),note:jY(),children:[(0,I.jsx)(_9,{label:PY(),children:(0,I.jsx)(y9,{value:i.tts.auto??`off`,options:[[`off`,LY()],[`always`,BY()],[`inbound`,UY()],[`tagged`,KY()]],onChange:e=>{a(`tts`,`auto`,e),o(`tts`,{auto:e})}})}),(0,I.jsx)(_9,{label:YY(),children:(0,I.jsx)(y9,{value:i.tts.provider??`openai`,options:[[`openai`,`OpenAI`],[`elevenlabs`,`ElevenLabs`],[`microsoft`,QY()],[`azure`,`Azure Speech`],[`google`,`Google Gemini`]],onChange:e=>{a(`tts`,`provider`,e),o(`tts`,{provider:e})}})}),(0,I.jsx)(_9,{label:tX(),children:(0,I.jsx)(o1,{value:i.tts.model??``,placeholder:`eleven_multilingual_v2`,onChange:e=>a(`tts`,`model`,e.target.value),onBlur:()=>o(`tts`,{model:i.tts.model??``})})}),(0,I.jsx)(_9,{label:iX(),children:(0,I.jsx)(o1,{value:i.tts.voice??``,placeholder:sX(),onChange:e=>a(`tts`,`voice`,e.target.value),onBlur:()=>o(`tts`,{voice:i.tts.voice??``})})})]}),(0,I.jsxs)(g9,{title:uX(),status:(0,I.jsx)($,{variant:`outline`,children:iY()}),note:e.secrets.openai?pX():gX(),children:[(0,I.jsx)(v9,{label:yX(),checked:i.talk.enabled??!1,onChange:e=>{a(`talk`,`enabled`,e),o(`talk`,{enabled:e})}}),(0,I.jsx)(_9,{label:SX(),children:(0,I.jsx)(y9,{value:i.talk.realtimeProvider??`openai`,options:[[`openai`,`OpenAI (gpt-realtime)`],[`google`,`Google`]],onChange:e=>{a(`talk`,`realtimeProvider`,e),o(`talk`,{realtimeProvider:e})}})}),(0,I.jsx)(_9,{label:TX(),children:(0,I.jsx)(o1,{value:i.talk.realtimeModel??``,placeholder:`gpt-realtime-2`,onChange:e=>a(`talk`,`realtimeModel`,e.target.value),onBlur:()=>o(`talk`,{realtimeModel:i.talk.realtimeModel??``})})}),(0,I.jsx)(_9,{label:iX(),children:(0,I.jsx)(o1,{value:i.talk.voice??``,placeholder:`cedar / marin`,onChange:e=>a(`talk`,`voice`,e.target.value),onBlur:()=>o(`talk`,{voice:i.talk.voice??``})})}),(0,I.jsx)(_9,{label:OX(),children:(0,I.jsx)(y9,{value:i.talk.transport??`webrtc`,options:[[`webrtc`,jX()],[`provider-websocket`,`Provider WebSocket`],[`gateway-relay`,`Gateway relay`]],onChange:e=>{a(`talk`,`transport`,e),o(`talk`,{transport:e})}})}),(0,I.jsx)(_9,{label:PX(),children:(0,I.jsx)(o1,{value:i.talk.speechLocale??``,placeholder:`fr-CA`,onChange:e=>a(`talk`,`speechLocale`,e.target.value),onBlur:()=>o(`talk`,{speechLocale:i.talk.speechLocale??``})})}),(0,I.jsx)(v9,{label:LX(),checked:i.talk.interruptOnSpeech??!0,onChange:e=>{a(`talk`,`interruptOnSpeech`,e),o(`talk`,{interruptOnSpeech:e})}})]}),(0,I.jsxs)(`section`,{className:`oc-int__section`,children:[(0,I.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,I.jsx)(`h3`,{className:`oc-uipa__h`,children:BX()}),(0,I.jsx)($,{variant:`outline`,children:UX()})]}),(0,I.jsxs)(`p`,{className:`oc-uipa__note`,children:[KX(),(0,I.jsx)(`code`,{children:` voicewake.get/set`}),`.`]})]}),(0,I.jsx)(A5,{title:YX(),rows:e.cursors.map(e=>({...e,_id:e.vendor})),emptyHint:QX(),columns:[{header:tZ(),cell:e=>(0,I.jsx)($,{variant:`secondary`,children:e.vendor}),sort:e=>e.vendor},{header:iZ(),cell:e=>e.lastAt>0?new Date(e.lastAt).toLocaleString(`fr-FR`):`—`,sort:e=>e.lastAt>0?e.lastAt:null},{header:sZ(),cell:e=>String(e.failureCount),sort:e=>e.failureCount},{header:uZ(),cell:e=>e.lastErrorStatus??`—`,sort:e=>e.lastErrorStatus??null},{header:pZ(),cell:e=>e.lastError??`—`,sort:e=>e.lastError??null}]})]})}function g9({title:e,status:t,note:n,children:r}){return(0,I.jsxs)(`section`,{className:`oc-int__section`,children:[(0,I.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,I.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,I.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,I.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function _9({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`oc-int__field`,children:[(0,I.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function v9({label:e,checked:t,onChange:n}){return(0,I.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,I.jsx)(A1,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,I.jsx)(`span`,{children:e})]})}function y9({value:e,options:t,onChange:n}){return(0,I.jsxs)(C3,{value:e,onValueChange:n,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-full`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:t.map(([e,t])=>(0,I.jsx)(Q,{value:e,children:t},e))})]})}var cot={altered_words:()=>gZ(),incorrect:()=>yZ(),incoherence:()=>SZ(),formatting:()=>TZ(),latency:()=>OZ(),api_error:()=>jZ(),other:()=>PZ()},b9=e=>cot[e]?.()??e;function x9({matches:e,sourceWasOpen:t}){return t?e===!0?(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:BZ()}):e===!1?(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:UZ()}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill`,children:LZ()})}function lot({data:e,closeReason:t}){let n=e.snapshot,r=F(V.feedback.respondToFeedback),[i,a]=(0,N.useState)(e.thread),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(!1);async function u(){let t=o.trim();if(!(!t||c)){l(!0);try{await r({feedbackId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),s(``)}finally{l(!1)}}}let d=[];try{d=n.contextJson?JSON.parse(n.contextJson):[]}catch{d=[]}return(0,I.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,I.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,I.jsx)(x9,{matches:n.displayedMatchesStored,sourceWasOpen:n.clientInfo?.sourceWasOpen??!1}),(0,I.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[b9(e.category),` · `,n.messageRole,n.isRegeneration?` · ${KZ()}`:``,n.openclawModel?` · ${n.openclawModel}`:``,n.openclawRuntime?` (${n.openclawRuntime})`:``]})]}),e.comment?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:hfe()}),(0,I.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,t?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:bme()}),(0,I.jsx)(`p`,{className:`oc-fbadmin__comment`,children:t})]}):null,(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:vfe()}),i.length>0?(0,I.jsx)(`div`,{className:`oc-fbadmin__thread`,children:i.map((e,t)=>(0,I.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,I.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?xfe():wfe()}),(0,I.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,I.jsx)(`p`,{className:`oc-fbadmin__meta`,children:Dfe()}),(0,I.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:Afe(),value:o,maxLength:2e3,rows:3,onChange:e=>s(e.target.value.slice(0,2e3))}),(0,I.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,I.jsx)(X,{size:`sm`,onClick:()=>void u(),disabled:!o.trim()||c,children:c?Nfe():Ife()})})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:zfe()}),(0,I.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.messageText||JZ()})]}),n.clientInfo?.sourceWasOpen&&n.displayedText!==void 0?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:Wfe()}),(0,I.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.displayedText||JZ()})]}):null,n.promptText?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:qfe()}),(0,I.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.promptText})]}):null,d.length>0?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:Xfe({count:n.contextCount??d.length,truncated:n.contextTruncated?$fe():``})}),(0,I.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:d.map((e,t)=>(0,I.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,I.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,I.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,n.outboxAvailable?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:npe()}),(0,I.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[n.outboxText??``,n.outboxStatus?`\n[status: ${n.outboxStatus}]`:``]})]}):null,n.clientInfo?.extensionsDetected&&n.clientInfo.extensionsDetected.length>0?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ape()}),(0,I.jsx)(`div`,{className:`oc-fbadmin__row`,children:n.clientInfo.extensionsDetected.map(e=>(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:cpe()}),(0,I.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[n.clientInfo?.language,n.clientInfo?.timezone,n.clientInfo?.theme?dpe({theme:n.clientInfo.theme}):null,n.runId?`run ${n.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,n.clientInfo?.plugins&&n.clientInfo.plugins.length>0?(0,I.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[mpe(),` `,n.clientInfo.plugins.join(`, `),(0,I.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,_pe()]})]}):null,n.clientInfo?.userAgent?(0,I.jsx)(`span`,{className:`oc-fbadmin__ua`,children:n.clientInfo.userAgent}):null]})]})]})}function uot(){let e=P(V.feedback.listForAdmin,{}),t=F(V.feedback.readSnapshot),n=F(V.feedback.deleteFeedback),r=C1(),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)({});async function c(e){if(i===e._id){a(null);return}if(!o[e._id]){let n=await t({feedbackId:e._id});s(t=>({...t,[e._id]:n}))}a(e._id)}async function l(e){await r({title:Mme(),description:Fme(),confirmLabel:Rme(),destructive:!0})&&(await n({feedbackId:e._id}),i===e._id&&a(null))}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[bpe(),` `,(0,I.jsx)(`strong`,{children:Cpe()}),` `,Epe()]}),(0,I.jsx)(A5,{title:kpe(),rows:e,emptyHint:Mpe(),isExpanded:e=>i===e._id&&!!o[e._id],renderExpanded:e=>o[e._id]?(0,I.jsx)(lot,{data:o[e._id],closeReason:e.userCloseReason}):null,columns:[{header:Fpe(),cell:e=>new Date(e.at).toLocaleString(`fr-FR`),sort:e=>e.at},{header:Rpe(),cell:e=>b9(e.category),sort:e=>b9(e.category)},{header:Vpe(),cell:e=>e.messageRole===`user`?Wpe():qpe(),sort:e=>e.messageRole},{header:Xpe(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${$pe({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:nme(),cell:e=>(0,I.jsx)(x9,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:ame(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:cme(),cell:e=>e.userClosedAt==null?e.answered?(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:dme()}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill`,children:mme()}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:_me()}),sort:e=>e.userClosedAt==null?+!!e.answered:2}],rowActions:e=>[{label:i===e._id?Cme():Eme(),onSelect:()=>void c(e)},{label:kme(),onSelect:()=>void l(e),variant:`destructive`}]})]})}var S9=`all`;function C9(e){switch(e){case`image`:return LA();case`audio`:return BA();case`video`:return UA();case`pdf`:return KA();case`document`:return YA();case`archive`:return QA();default:return tj()}}function dot(){let[e,t]=(0,N.useState)(S9),[n,r]=(0,N.useState)(S9),[i,a]=(0,N.useState)(S9),[o,s]=(0,N.useState)(S9),[c,l]=(0,N.useState)(null),u=F(V.files.softDelete),d=D1();function f(){t(S9),r(S9),a(S9),s(S9)}async function p(){let e=c;if(l(null),e)try{await u({fileId:e.id}),d.success(Pj())}catch(e){d.error(Lj(),e)}}let m=P(V.files.listMine,{direction:e===S9?void 0:e,chatId:n===S9?void 0:n,instanceName:i===S9?void 0:i,category:o===S9?void 0:o}),h=(0,N.useMemo)(()=>new Intl.DateTimeFormat(q(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(m===void 0)return(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()});let{files:g,facets:_,truncated:v,cap:y}=m,b=e!==S9||n!==S9||i!==S9||o!==S9;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:iA()}),(0,I.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,I.jsxs)(C3,{value:e,onValueChange:t,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":sA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:uA()}),(0,I.jsx)(Q,{value:`inbound`,children:pA()}),(0,I.jsx)(Q,{value:`outbound`,children:gA()})]})]}),(0,I.jsxs)(C3,{value:n,onValueChange:r,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":yA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:SA()}),_.chats.map(e=>(0,I.jsx)(Q,{value:e.id,children:e.title},e.id))]})]}),_.multiProvider?(0,I.jsxs)(C3,{value:i,onValueChange:a,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":TA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:OA()}),_.instances.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}):null,(0,I.jsxs)(C3,{value:o,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":jA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:PA()}),_.categories.map(e=>(0,I.jsx)(Q,{value:e,children:C9(e)},e))]})]}),b?(0,I.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:f,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,I.jsx)(Fm,{size:14,"aria-hidden":!0}),Tj()]}):null]}),g.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:b?Qj():Yj()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[(0,I.jsx)(O5,{children:ij()}),(0,I.jsx)(O5,{children:sj()}),(0,I.jsx)(O5,{children:uj()}),(0,I.jsx)(O5,{children:pj()}),(0,I.jsx)(O5,{children:gj()}),(0,I.jsx)(O5,{className:`text-right`,children:yj()})]})}),(0,I.jsx)(E5,{children:g.map(e=>(0,I.jsxs)(D5,{children:[(0,I.jsx)(k5,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:e.filename}),(0,I.jsx)(k5,{title:e.mimeType,children:C9(e.category)}),(0,I.jsx)(k5,{children:(0,I.jsx)($,{variant:`secondary`,children:e.direction===`inbound`?pA():gA()})}),(0,I.jsx)(k5,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,I.jsx)(k5,{className:`whitespace-nowrap text-muted-foreground`,children:h.format(e.createdAt)}),(0,I.jsx)(k5,{className:`text-right`,children:(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":Oj(),children:(0,I.jsx)(ym,{size:16})})}),(0,I.jsxs)(J$,{align:`end`,children:[e.url?(0,I.jsx)(Y$,{asChild:!0,children:(0,I.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(vm,{size:14}),Sj()]})}):(0,I.jsxs)(Y$,{disabled:!0,children:[(0,I.jsx)(vm,{size:14}),Kj()]}),(0,I.jsxs)(Y$,{variant:`destructive`,onSelect:()=>l({id:e._id,filename:e.filename}),children:[(0,I.jsx)(Vm,{size:14}),jj()]})]})]})})]},e._id))})]}),v?(0,I.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:tM({cap:y})}):null]}),(0,I.jsx)(s1,{open:c!==null,onOpenChange:e=>!e&&l(null),children:(0,I.jsxs)(c1,{children:[(0,I.jsxs)(l1,{children:[(0,I.jsx)(d1,{children:Bj()}),(0,I.jsx)(f1,{children:Uj()})]}),(0,I.jsxs)(u1,{children:[(0,I.jsx)(m1,{children:pW()}),(0,I.jsx)(p1,{onClick:()=>void p(),children:jj()})]})]})})]})}var w9=2e4,T9=6e4;function fot(e){return typeof e!=`number`||e<=0?0:Math.round(e/w9*100)}function pot(e){return e<=0?0:Math.round(e/T9*100)}function E9(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function D9(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var O9=3;function mot(e,t){let n=new Map;for(let t of e.split(`
162
+ `},Jtt={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 Ytt(e){let{announcements:t=Jtt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=qtt}=e,{announce:a,announcement:o}=Wtt(),s=v6(`DndLiveRegion`),[c,l]=(0,N.useState)(!1);if((0,N.useEffect)(()=>{l(!0)},[]),Gtt((0,N.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=N.createElement(N.Fragment,null,N.createElement(Htt,{id:r,value:i.draggable}),N.createElement(Utt,{id:s,announcement:o}));return n?(0,ls.createPortal)(u,n):u}var D6;(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`})(D6||={});function O6(){}function k6(e,t){return(0,N.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function A6(){var e=[...arguments];return(0,N.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var j6=Object.freeze({x:0,y:0});function M6(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Xtt(e,t){let n=C6(e);if(!n)return`0 0`;let r={x:(n.x-t.left)/t.width*100,y:(n.y-t.top)/t.height*100};return r.x+`% `+r.y+`%`}function N6(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Ztt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function P6(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 F6(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function I6(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}}var Qtt=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=I6(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=M6(I6(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(N6)},L6=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=P6(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=P6(r),o=i.reduce((e,t,r)=>e+M6(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(N6)};function $tt(e,t){let 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),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var ent=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=$tt(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Ztt)};function tnt(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function R6(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:j6}function nnt(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var rnt=nnt(1);function z6(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function int(e,t,n){let r=z6(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var ant={ignoreTransform:!1};function B6(e,t){t===void 0&&(t=ant);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=o6(e).getComputedStyle(e);t&&(n=int(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function V6(e){return B6(e,{ignoreTransform:!0})}function ont(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function snt(e,t){return t===void 0&&(t=o6(e).getComputedStyle(e)),t.position===`fixed`}function cnt(e,t){t===void 0&&(t=o6(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function H6(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(s6(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!c6(i)||l6(i)||n.includes(i))return n;let a=o6(e).getComputedStyle(i);return i!==e&&cnt(i,a)&&n.push(i),snt(i,a)?n:r(i.parentNode)}return e?r(e):n}function U6(e){let[t]=H6(e,1);return t??null}function W6(e){return!r6||!e?null:i6(e)?e:a6(e)?s6(e)||e===u6(e).scrollingElement?window:c6(e)?e:null:null}function G6(e){return i6(e)?e.scrollX:e.scrollLeft}function K6(e){return i6(e)?e.scrollY:e.scrollTop}function q6(e){return{x:G6(e),y:K6(e)}}var J6;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J6||={});function Y6(e){return!r6||!e?!1:e===document.scrollingElement}function X6(e){let t={x:0,y:0},n=Y6(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var lnt={x:.2,y:.2};function unt(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=lnt);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=X6(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J6.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J6.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J6.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J6.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function dnt(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{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 Z6(e){return e.reduce((e,t)=>b6(e,q6(t)),j6)}function fnt(e){return e.reduce((e,t)=>e+G6(t),0)}function pnt(e){return e.reduce((e,t)=>e+K6(t),0)}function Q6(e,t){if(t===void 0&&(t=B6),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);U6(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var mnt=[[`x`,[`left`,`right`],fnt],[`y`,[`top`,`bottom`],pnt]],$6=class{constructor(e,t){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;let n=H6(t),r=Z6(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of mnt)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},e8=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function hnt(e){let{EventTarget:t}=o6(e);return e instanceof t?e:u6(e)}function t8(e,t){let 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 n8;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(n8||={});function r8(e){e.preventDefault()}function gnt(e){e.stopPropagation()}var i8;(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`})(i8||={});var a8={start:[i8.Space,i8.Enter],cancel:[i8.Esc],end:[i8.Space,i8.Enter,i8.Tab]},_nt=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case i8.Right:return{...n,x:n.x+25};case i8.Left:return{...n,x:n.x-25};case i8.Down:return{...n,y:n.y+25};case i8.Up:return{...n,y:n.y-25}}},o8=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new e8(u6(t)),this.windowListeners=new e8(o6(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(n8.Resize,this.handleCancel),this.windowListeners.add(n8.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(n8.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Q6(n),t(j6)}handleKeyDown(e){if(S6(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=a8,coordinateGetter:a=_nt,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:j6;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=x6(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=X6(n),p=dnt(n),m={x:Math.min(i===i8.Right?p.right-p.width/2:p.right,Math.max(i===i8.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===i8.Down?p.bottom-p.height/2:p.bottom,Math.max(i===i8.Down?p.top:p.top+p.height/2,u.y))},h=i===i8.Right&&!s||i===i8.Left&&!c,g=i===i8.Down&&!l||i===i8.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===i8.Right&&e<=d.x||i===i8.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===i8.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===i8.Down&&e<=d.y||i===i8.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===i8.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,b6(x6(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};o8.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=a8,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function s8(e){return!!(e&&`distance`in e)}function c8(e){return!!(e&&`delay`in e)}var l8=class{constructor(e,t,n){n===void 0&&(n=hnt(e.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=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=u6(i),this.documentListeners=new e8(this.document),this.listeners=new e8(n),this.windowListeners=new e8(o6(i)),this.initialCoordinates=C6(r)??j6,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(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(n8.Resize,this.handleCancel),this.windowListeners.add(n8.DragStart,r8),this.windowListeners.add(n8.VisibilityChange,this.handleCancel),this.windowListeners.add(n8.ContextMenu,r8),this.documentListeners.add(n8.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(c8(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(s8(t)){this.handlePending(t);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(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(n8.Click,gnt,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(n8.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=C6(e)??j6,s=x6(n,o);if(!t&&a){if(s8(a)){if(a.tolerance!=null&&t8(s,a.tolerance))return this.handleCancel();if(t8(s,a.distance))return this.handleStart()}if(c8(a)&&t8(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===i8.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},vnt={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},u8=class extends l8{constructor(e){let{event:t}=e,n=u6(t.target);super(e,vnt,n)}};u8.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var ynt={move:{name:`mousemove`},end:{name:`mouseup`}},d8;(function(e){e[e.RightClick=2]=`RightClick`})(d8||={});var bnt=class extends l8{constructor(e){super(e,ynt,u6(e.event.target))}};bnt.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===d8.RightClick?!1:(r?.({event:n}),!0)}}];var f8={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},xnt=class extends l8{constructor(e){super(e,f8)}static setup(){return window.addEventListener(f8.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(f8.move.name,e)};function e(){}}};xnt.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var p8;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(p8||={});var m8;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(m8||={});function Snt(e){let{acceleration:t,activator:n=p8.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=m8.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=wnt({delta:d,disabled:!a}),[m,h]=Ltt(),g=(0,N.useRef)({x:0,y:0}),_=(0,N.useRef)({x:0,y:0}),v=(0,N.useMemo)(()=>{switch(n){case p8.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case p8.DraggableRect:return i}},[n,i,c]),y=(0,N.useRef)(null),b=(0,N.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,N.useMemo)(()=>s===m8.TreeOrder?[...l].reverse():l,[s,l]);(0,N.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=u[l.indexOf(e)];if(!n)continue;let{direction:i,speed:a}=unt(e,n,v,t,f);for(let e of[`x`,`y`])p[e][i[e]]||(a[e]=0,i[e]=0);if(a.x>0||a.y>0){h(),y.current=e,m(b,o),g.current=a,_.current=i;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var Cnt={x:{[J6.Backward]:!1,[J6.Forward]:!1},y:{[J6.Backward]:!1,[J6.Forward]:!1}};function wnt(e){let{delta:t,disabled:n}=e,r=g6(t);return m6(e=>{if(n||!r||!e)return Cnt;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J6.Backward]:e.x[J6.Backward]||i.x===-1,[J6.Forward]:e.x[J6.Forward]||i.x===1},y:{[J6.Backward]:e.y[J6.Backward]||i.y===-1,[J6.Forward]:e.y[J6.Forward]||i.y===1}}},[n,t,r])}function Tnt(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return m6(e=>t==null?null:r??e??null,[r,t])}function Ent(e,t){return(0,N.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var h8;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(h8||={});var g8;(function(e){e.Optimized=`optimized`})(g8||={});var _8=new Map;function Dnt(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,N.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,N.useRef)(e),d=g(),f=p6(d),p=(0,N.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,N.useRef)(null),h=m6(t=>{if(d&&!n)return _8;if(!t||t===_8||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new $6(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,N.useEffect)(()=>{u.current=e},[e]),(0,N.useEffect)(()=>{d||p()},[n,d]),(0,N.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,N.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case h8.Always:return!1;case h8.BeforeDragging:return n;default:return!n}}}function v8(e,t){return m6(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function Ont(e,t){return v8(e,t)}function knt(e){let{callback:t,disabled:n}=e,r=f6(t),i=(0,N.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,N.useEffect)(()=>()=>i?.disconnect(),[i]),i}function y8(e){let{callback:t,disabled:n}=e,r=f6(t),i=(0,N.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,N.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Ant(e){return new $6(B6(e),e)}function b8(e,t,n){t===void 0&&(t=Ant);let[r,i]=(0,N.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=knt({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=y8({callback:a});return d6(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function jnt(e){return R6(e,v8(e))}var x8=[];function Mnt(e){let t=(0,N.useRef)(e),n=m6(n=>e?n&&n!==x8&&e&&t.current&&e.parentNode===t.current.parentNode?n:H6(e):x8,[e]);return(0,N.useEffect)(()=>{t.current=e},[e]),n}function Nnt(e){let[t,n]=(0,N.useState)(null),r=(0,N.useRef)(e),i=(0,N.useCallback)(e=>{let t=W6(e.target);t&&n(e=>e?(e.set(t,q6(t)),new Map(e)):null)},[]);return(0,N.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=W6(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,q6(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{W6(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,N.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>b6(e,t),j6):Z6(e):j6,[e,t])}function S8(e,t){t===void 0&&(t=[]);let n=(0,N.useRef)(null);return(0,N.useEffect)(()=>{n.current=null},t),(0,N.useEffect)(()=>{let t=e!==j6;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?x6(e,n.current):j6}function Pnt(e){(0,N.useEffect)(()=>{if(!r6)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Fnt(e,t){return(0,N.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function C8(e){return(0,N.useMemo)(()=>e?ont(e):null,[e])}var w8=[];function Int(e,t){t===void 0&&(t=B6);let[n]=e,r=C8(n?o6(n):null),[i,a]=(0,N.useState)(w8);function o(){a(()=>e.length?e.map(e=>Y6(e)?r:new $6(t(e),e)):w8)}let s=y8({callback:o});return d6(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function T8(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return c6(t)?t:e}function Lnt(e){let{measure:t}=e,[n,r]=(0,N.useState)(null),i=y8({callback:(0,N.useCallback)(e=>{for(let{target:n}of e)if(c6(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=h6((0,N.useCallback)(e=>{let n=T8(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,N.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Rnt=[{sensor:u8,options:{}},{sensor:o8,options:{}}],znt={current:{}},E8={draggable:{measure:V6},droppable:{measure:V6,strategy:h8.WhileDragging,frequency:g8.Optimized},dragOverlay:{measure:B6}},D8=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Bnt={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new D8,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:O6},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:E8,measureDroppableContainers:O6,windowRect:null,measuringScheduled:!1},O8={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:O6,draggableNodes:new Map,over:null,measureDroppableContainers:O6},k8=(0,N.createContext)(O8),A8=(0,N.createContext)(Bnt);function Vnt(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new D8}}}function Hnt(e,t){switch(t.type){case D6.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case D6.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 D6.DragEnd:case D6.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case D6.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new D8(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case D6.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new D8(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case D6.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new D8(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Unt(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,N.useContext)(k8),a=g6(r),o=g6(n?.id);return(0,N.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!S6(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Btt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function j8(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Wnt(e){return(0,N.useMemo)(()=>({draggable:{...E8.draggable,...e?.draggable},droppable:{...E8.droppable,...e?.droppable},dragOverlay:{...E8.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Gnt(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,N.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;d6(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=R6(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=U6(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var M8=(0,N.createContext)({...j6,scaleX:1,scaleY:1}),N8;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(N8||={});var P8=(0,N.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Rnt,collisionDetection:o=ent,measuring:s,modifiers:c,...l}=e,[u,d]=(0,N.useReducer)(Hnt,void 0,Vnt),[f,p]=Ktt(),[m,h]=(0,N.useState)(N8.Uninitialized),g=m===N8.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,N.useRef)({initial:null,translated:null}),C=(0,N.useMemo)(()=>_==null?null:{id:_,data:x?.data??znt,rect:S},[_,x]),w=(0,N.useRef)(null),[T,E]=(0,N.useState)(null),[D,O]=(0,N.useState)(null),ee=p6(l,Object.values(l)),te=v6(`DndDescribedBy`,t),k=(0,N.useMemo)(()=>b.getEnabled(),[b]),A=Wnt(s),{droppableRects:j,measureDroppableContainers:ne,measuringScheduled:re}=Dnt(k,{dragging:g,dependencies:[y.x,y.y],config:A.droppable}),M=Tnt(v,_),ie=(0,N.useMemo)(()=>D?C6(D):null,[D]),ae=Ie(),oe=Ont(M,A.draggable.measure);Gnt({activeNode:_==null?null:v.get(_),config:ae.layoutShiftCompensation,initialRect:oe,measure:A.draggable.measure});let se=b8(M,A.draggable.measure,oe),ce=b8(M?M.parentElement:null),le=(0,N.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:j,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ue=b.getNodeFor(le.current.over?.id),de=Lnt({measure:A.dragOverlay.measure}),fe=de.nodeRef.current??M,pe=g?de.rect??se:null,me=!!(de.nodeRef.current&&de.rect),he=jnt(me?null:se),ge=C8(fe?o6(fe):null),_e=Mnt(g?ue??M:null),ve=Int(_e),ye=j8(c,{transform:{x:y.x-he.x,y:y.y-he.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:se,containerNodeRect:ce,draggingNodeRect:pe,over:le.current.over,overlayNodeRect:de.rect,scrollableAncestors:_e,scrollableAncestorRects:ve,windowRect:ge}),be=ie?b6(ie,y):null,xe=Nnt(_e),Se=S8(xe),Ce=S8(xe,[se]),we=b6(ye,Se),Te=pe?rnt(pe,ye):null,Ee=C&&Te?o({active:C,collisionRect:Te,droppableRects:j,droppableContainers:k,pointerCoordinates:be}):null,De=F6(Ee,`id`),[Oe,ke]=(0,N.useState)(null),Ae=tnt(me?ye:b6(ye,Ce),Oe?.rect??null,se),je=(0,N.useRef)(null),Me=(0,N.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent;je.current=new n({active:w.current,activeNode:i,event:a,options:r,context:le,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=ee.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=ee.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=ee.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ls.unstable_batchedUpdates)(()=>{r?.(i),h(N8.Initializing),d({type:D6.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(je.current),O(a)})},onMove(e){d({type:D6.DragMove,coordinates:e})},onEnd:o(D6.DragEnd),onCancel:o(D6.DragCancel)});function o(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=le.current,o=null;if(t&&i){let{cancelDrop:s}=ee.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===D6.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=D6.DragCancel)}w.current=null,(0,ls.unstable_batchedUpdates)(()=>{d({type:e}),h(N8.Uninitialized),ke(null),E(null),O(null),je.current=null;let t=e===D6.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=ee.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ne=Ent(a,(0,N.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Me(n,t))},[v,Me]));Pnt(a),d6(()=>{se&&m===N8.Initializing&&h(N8.Initialized)},[se,m]),(0,N.useEffect)(()=>{let{onDragMove:e}=ee.current,{active:t,activatorEvent:n,collisions:r,over:i}=le.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:we.x,y:we.y},over:i};(0,ls.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[we.x,we.y]),(0,N.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=le.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=ee.current,o=r.get(De),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ls.unstable_batchedUpdates)(()=>{ke(s),a?.(c),f({type:`onDragOver`,event:c})})},[De]),d6(()=>{le.current={activatorEvent:D,active:C,activeNode:M,collisionRect:Te,collisions:Ee,droppableRects:j,draggableNodes:v,draggingNode:fe,draggingNodeRect:pe,droppableContainers:b,over:Oe,scrollableAncestors:_e,scrollAdjustedTranslate:we},S.current={initial:pe,translated:Te}},[C,M,Ee,Te,v,fe,pe,j,b,Oe,_e,we]),Snt({...ae,delta:y,draggingRect:Te,pointerCoordinates:be,scrollableAncestors:_e,scrollableAncestorRects:ve});let Pe=(0,N.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:se,activatorEvent:D,collisions:Ee,containerNodeRect:ce,dragOverlay:de,draggableNodes:v,droppableContainers:b,droppableRects:j,over:Oe,measureDroppableContainers:ne,scrollableAncestors:_e,scrollableAncestorRects:ve,measuringConfiguration:A,measuringScheduled:re,windowRect:ge}),[C,M,se,D,Ee,ce,de,v,b,j,Oe,ne,_e,ve,A,re,ge]),Fe=(0,N.useMemo)(()=>({activatorEvent:D,activators:Ne,active:C,activeNodeRect:se,ariaDescribedById:{draggable:te},dispatch:d,draggableNodes:v,over:Oe,measureDroppableContainers:ne}),[D,Ne,C,se,d,te,v,Oe,ne]);return N.createElement(E6.Provider,{value:p},N.createElement(k8.Provider,{value:Fe},N.createElement(A8.Provider,{value:Pe},N.createElement(M8.Provider,{value:Ae},i)),N.createElement(Unt,{disabled:n?.restoreFocus===!1})),N.createElement(Ytt,{...n,hiddenTextDescribedById:te}));function Ie(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Knt=(0,N.createContext)(null),F8=`button`,qnt=`Draggable`;function Jnt(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=v6(qnt),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,N.useContext)(k8),{role:p=F8,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,N.useContext)(g?M8:Knt),[v,y]=h6(),[b,x]=h6(),S=Fnt(o,t),C=p6(n);return d6(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,N.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===F8?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function I8(){return(0,N.useContext)(A8)}var Ynt=`Droppable`,Xnt={timeout:25};function L8(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=v6(Ynt),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,N.useContext)(k8),u=(0,N.useRef)({disabled:n}),d=(0,N.useRef)(!1),f=(0,N.useRef)(null),p=(0,N.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...Xnt,...i},_=p6(h??r),v=y8({callback:(0,N.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=h6((0,N.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=p6(t);return(0,N.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,N.useEffect)(()=>(s({type:D6.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:D6.UnregisterDroppable,key:a,id:r})),[r]),(0,N.useEffect)(()=>{n!==u.current.disabled&&(s({type:D6.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function Znt(e){let{animation:t,children:n}=e,[r,i]=(0,N.useState)(null),[a,o]=(0,N.useState)(null),s=g6(n);return!n&&!r&&s&&i(s),d6(()=>{if(!a)return;let e=r?.key,n=r?.props.id;if(e==null||n==null){i(null);return}Promise.resolve(t(n,a)).then(()=>{i(null)})},[t,r,a]),N.createElement(N.Fragment,null,n,r?(0,N.cloneElement)(r,{ref:o}):null)}var Qnt={x:0,y:0,scaleX:1,scaleY:1};function $nt(e){let{children:t}=e;return N.createElement(k8.Provider,{value:O8},N.createElement(M8.Provider,{value:Qnt},t))}var ert={position:`fixed`,touchAction:`none`},trt=e=>S6(e)?`transform 250ms ease`:void 0,nrt=(0,N.forwardRef)((e,t)=>{let{as:n,activatorEvent:r,adjustScale:i,children:a,className:o,rect:s,style:c,transform:l,transition:u=trt}=e;if(!s)return null;let d=i?l:{...l,scaleX:1,scaleY:1},f={...ert,width:s.width,height:s.height,top:s.top,left:s.left,transform:w6.Transform.toString(d),transformOrigin:i&&r?Xtt(r,s):void 0,transition:typeof u==`function`?u(r):u,...c};return N.createElement(n,{className:o,style:f,ref:t},a)}),rrt={duration:250,easing:`ease`,keyframes:e=>{let{transform:{initial:t,final:n}}=e;return[{transform:w6.Transform.toString(t)},{transform:w6.Transform.toString(n)}]},sideEffects:(e=>t=>{let{active:n,dragOverlay:r}=t,i={},{styles:a,className:o}=e;if(a!=null&&a.active)for(let[e,t]of Object.entries(a.active))t!==void 0&&(i[e]=n.node.style.getPropertyValue(e),n.node.style.setProperty(e,t));if(a!=null&&a.dragOverlay)for(let[e,t]of Object.entries(a.dragOverlay))t!==void 0&&r.node.style.setProperty(e,t);return o!=null&&o.active&&n.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(let[e,t]of Object.entries(i))n.node.style.setProperty(e,t);o!=null&&o.active&&n.node.classList.remove(o.active)}})({styles:{active:{opacity:`0`}}})};function irt(e){let{config:t,draggableNodes:n,droppableContainers:r,measuringConfiguration:i}=e;return f6((e,a)=>{if(t===null)return;let o=n.get(e);if(!o)return;let s=o.node.current;if(!s)return;let c=T8(a);if(!c)return;let{transform:l}=o6(a).getComputedStyle(a),u=z6(l);if(!u)return;let d=typeof t==`function`?t:art(t);return Q6(s,i.draggable.measure),d({active:{id:e,data:o.data,node:s,rect:i.draggable.measure(s)},draggableNodes:n,dragOverlay:{node:a,rect:i.dragOverlay.measure(c)},droppableContainers:r,measuringConfiguration:i,transform:u})})}function art(e){let{duration:t,easing:n,sideEffects:r,keyframes:i}={...rrt,...e};return e=>{let{active:a,dragOverlay:o,transform:s,...c}=e;if(!t)return;let l={x:o.rect.left-a.rect.left,y:o.rect.top-a.rect.top},u={scaleX:s.scaleX===1?1:a.rect.width*s.scaleX/o.rect.width,scaleY:s.scaleY===1?1:a.rect.height*s.scaleY/o.rect.height},d={x:s.x-l.x,y:s.y-l.y,...u},f=i({...c,active:a,dragOverlay:o,transform:{initial:s,final:d}}),[p]=f,m=f[f.length-1];if(JSON.stringify(p)===JSON.stringify(m))return;let h=r?.({active:a,dragOverlay:o,...c}),g=o.node.animate(f,{duration:t,easing:n,fill:`forwards`});return new Promise(e=>{g.onfinish=()=>{h?.(),e()}})}}var R8=0;function ort(e){return(0,N.useMemo)(()=>{if(e!=null)return R8++,R8},[e])}var srt=N.memo(e=>{let{adjustScale:t=!1,children:n,dropAnimation:r,style:i,transition:a,modifiers:o,wrapperElement:s=`div`,className:c,zIndex:l=999}=e,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggableNodes:m,droppableContainers:h,dragOverlay:g,over:_,measuringConfiguration:v,scrollableAncestors:y,scrollableAncestorRects:b,windowRect:x}=I8(),S=(0,N.useContext)(M8),C=ort(d?.id),w=j8(o,{activatorEvent:u,active:d,activeNodeRect:f,containerNodeRect:p,draggingNodeRect:g.rect,over:_,overlayNodeRect:g.rect,scrollableAncestors:y,scrollableAncestorRects:b,transform:S,windowRect:x}),T=v8(f),E=irt({config:r,draggableNodes:m,droppableContainers:h,measuringConfiguration:v}),D=T?g.setRef:void 0;return N.createElement($nt,null,N.createElement(Znt,{animation:E},d&&C?N.createElement(nrt,{key:C,id:d.id,ref:D,as:s,activatorEvent:u,adjustScale:t,className:c,transition:a,rect:T,style:{zIndex:l,...i},transform:w},n):null))}),crt=e=>{let{transform:t}=e;return{...t,y:0}};function lrt(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var urt=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e,i=r[0];return!t||!i?n:lrt(n,t,i)},drt=e=>{let{transform:t}=e;return{...t,x:0}};function z8(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function frt(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function B8(e){return e!==null&&e>=0}function prt(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 mrt(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var V8={scaleX:1,scaleY:1},hrt=e=>{let{rects:t,activeNodeRect:n,activeIndex:r,overIndex:i,index:a}=e,o=t[r]??n;if(!o)return null;let s=grt(t,a,r);if(a===r){let e=t[i];return e?{x:r<i?e.left+e.width-(o.left+o.width):e.left-o.left,y:0,...V8}:null}return a>r&&a<=i?{x:-o.width-s,y:0,...V8}:a<r&&a>=i?{x:o.width+s,y:0,...V8}:{x:0,y:0,...V8}};function grt(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return!r||!i&&!a?0:n<t?i?r.left-(i.left+i.width):a.left-(r.left+r.width):a?a.left-(r.left+r.width):r.left-(i.left+i.width)}var H8=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=z8(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},U8={scaleX:1,scaleY:1},_rt=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...U8}:null}let s=vrt(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...U8}:r<t&&r>=a?{x:0,y:o.height+s,...U8}:{x:0,y:0,...U8}};function vrt(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var W8=`Sortable`,G8=N.createContext({activeIndex:-1,containerId:W8,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:H8,disabled:{draggable:!1,droppable:!1}});function K8(e){let{children:t,id:n,items:r,strategy:i=H8,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=I8(),d=v6(W8,n),f=s.rect!==null,p=(0,N.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,N.useRef)(p),v=!prt(p,_.current),y=g!==-1&&h===-1||v,b=mrt(a);d6(()=>{v&&m&&u(p)},[v,p,m,u]),(0,N.useEffect)(()=>{_.current=p},[p]);let x=(0,N.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:frt(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return N.createElement(G8.Provider,{value:x},t)}var yrt=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return z8(n,r,i).indexOf(t)},brt=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},xrt={duration:200,easing:`ease`},q8=`transform`,Srt=w6.Transition.toString({property:q8,duration:0,easing:`linear`}),Crt={roleDescription:`sortable`};function wrt(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,N.useState)(null),s=(0,N.useRef)(n);return d6(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=B6(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,N.useEffect)(()=>{a&&o(null)},[a]),a}function J8(e){let{animateLayoutChanges:t=brt,attributes:n,disabled:r,data:i,getNewIndex:a=yrt,id:o,strategy:s,resizeObserverConfig:c,transition:l=xrt}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,N.useContext)(G8),y=Trt(r,p),b=u.indexOf(o),x=(0,N.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,N.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=L8({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:O,activeNodeRect:ee,attributes:te,setNodeRef:k,listeners:A,isDragging:j,over:ne,setActivatorNodeRef:re,transform:M}=Jnt({id:o,data:x,attributes:{...Crt,...n},disabled:y.draggable}),ie=Itt(E,k),ae=!!D,oe=ae&&!m&&B8(f)&&B8(g),se=!_&&j,ce=oe?(se&&oe?M:null)??(s??v)({rects:h,activeNodeRect:ee,activeIndex:f,overIndex:g,index:b}):null,le=B8(f)&&B8(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ue=D?.id,de=(0,N.useRef)({activeId:ue,items:u,newIndex:le,containerId:d}),fe=u!==de.current.items,pe=t({active:D,containerId:d,isDragging:j,isSorting:ae,id:o,index:b,items:u,newIndex:de.current.newIndex,previousItems:de.current.items,previousContainerId:de.current.containerId,transition:l,wasDragging:de.current.activeId!=null}),me=wrt({disabled:!pe,index:b,node:w,rect:C});return(0,N.useEffect)(()=>{ae&&de.current.newIndex!==le&&(de.current.newIndex=le),d!==de.current.containerId&&(de.current.containerId=d),u!==de.current.items&&(de.current.items=u)},[ae,le,d,u]),(0,N.useEffect)(()=>{if(ue===de.current.activeId)return;if(ue!=null&&de.current.activeId==null){de.current.activeId=ue;return}let e=setTimeout(()=>{de.current.activeId=ue},50);return()=>clearTimeout(e)},[ue]),{active:D,activeIndex:f,attributes:te,data:x,rect:C,index:b,newIndex:le,items:u,isOver:T,isSorting:ae,isDragging:j,listeners:A,node:w,overIndex:g,over:ne,setNodeRef:ie,setActivatorNodeRef:re,setDroppableNodeRef:E,setDraggableNodeRef:k,transform:me??ce,transition:he()};function he(){if(me||fe&&de.current.newIndex===b)return Srt;if(!(se&&!S6(O)||!l)&&(ae||pe))return w6.Transition.toString({...l,property:q8})}}function Trt(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Y8(e){if(!e)return!1;let 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)}var Ert=[i8.Down,i8.Right,i8.Up,i8.Left],X8=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Ert.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case i8.Down:r.top<a.top&&t.push(n);break;case i8.Up:r.top>a.top&&t.push(n);break;case i8.Left:r.left>a.left&&t.push(n);break;case i8.Right:r.left<a.left&&t.push(n);break}});let c=L6({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=F6(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=H6(c).some((e,t)=>s[t]!==e),i=Z8(e,t),a=Drt(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:x6(u,l)}}}};function Z8(e,t){return!Y8(e)||!Y8(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Drt(e,t){return!Y8(e)||!Y8(t)||!Z8(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}function Q8({open:e,onOpenChange:t,title:n,description:r,children:i,onSubmit:a,submitLabel:o=`Enregistrer`,submitting:s=!1,canSubmit:c=!0}){let[l,u]=(0,N.useState)(!1),d=s||l;async function f(){if(!(!c||d))try{u(!0),await a()}finally{u(!1)}}return(0,I.jsx)(K1,{open:e,onOpenChange:t,children:(0,I.jsxs)(q1,{side:`right`,className:`w-4/5 sm:max-w-none gap-0 p-0`,children:[(0,I.jsxs)(J1,{className:`border-b px-6 py-4`,children:[(0,I.jsx)(X1,{children:n}),r?(0,I.jsx)(Z1,{children:r}):null]}),(0,I.jsxs)(`form`,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:e=>{e.preventDefault(),f()},children:[(0,I.jsx)(`div`,{className:`oc-sheet__body flex-1 overflow-y-auto px-6 py-4`,children:i}),(0,I.jsxs)(Y1,{className:`border-t px-6 py-4`,children:[(0,I.jsxs)(X,{type:`submit`,disabled:!c||d,children:[d?(0,I.jsx)(Cm,{className:`size-4 animate-spin`}):null,o]}),(0,I.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>t(!1),children:`Annuler`})]})]})]})})}var $8=6e4,e5=60*$8,t5=24*e5,n5=7*t5,r5=30*t5,i5=365*t5;function Ort(e,t){let n=t-e;if(n<$8)return`maintenant`;if(n<e5)return`${Math.floor(n/$8)}min`;if(n<t5)return`${Math.floor(n/e5)}h`;if(n<n5)return`${Math.floor(n/t5)}j`;if(n<r5)return`${Math.floor(n/n5)}sem`;if(n<i5)return`${Math.floor(n/r5)}mois`;let r=Math.floor(n/i5);return`${r}an${r>1?`s`:``}`}var a5=[{value:`red`,hue:`oklch(0.63 0.21 25)`},{value:`orange`,hue:`oklch(0.7 0.17 50)`},{value:`amber`,hue:`oklch(0.8 0.15 85)`},{value:`green`,hue:`oklch(0.7 0.16 150)`},{value:`teal`,hue:`oklch(0.7 0.12 190)`},{value:`blue`,hue:`oklch(0.62 0.19 250)`},{value:`violet`,hue:`oklch(0.6 0.2 300)`},{value:`pink`,hue:`oklch(0.7 0.2 350)`}],o5=e=>a5.find(t=>t.value===e)?.hue??null,s5=`project:none`,krt=e=>`project:${e}`,c5=`oc.noproject.collapsed`;function Art({activeChatId:e,onSelect:t,onNewChat:n,newChatShortcut:r}){let i=P(V.messages.listChats,{}),a=P(V.projects.listProjects,{}),o=P(V.me.getMe,{host:xO})?.ui?.effective,s=o?.showChatProvider??!0,c=o?.showChatAge??!0,l=new Set((i??[]).map(e=>e.providerKind).filter(e=>e!=null)),u=s&&l.size>1,[,d]=(0,N.useState)(0);(0,N.useEffect)(()=>{if(!c)return;let e=window.setInterval(()=>d(e=>e+1),6e4);return()=>window.clearInterval(e)},[c]);let f=F(V.projects.createProject),p=F(V.projects.setProjectCollapsed),m=F(V.chats.reorderChat),h=F(V.chats.moveChatToProject),g=w1(),_=qLe(),v=(0,N.useRef)(null),y=(0,N.useRef)(null),b=(0,N.useRef)(null),[x,S]=(0,N.useState)(`full`);(0,N.useLayoutEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=y.current?.offsetWidth??0,r=b.current?.offsetWidth??0,i=n===0||t>=n?`full`:t>=r?`label`:`icon`;S(e=>e===i?e:i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[_,r]);let[C,w]=(0,N.useState)(null),T=(0,N.useRef)(!1);(0,N.useEffect)(()=>{!T.current&&i&&w(i)},[i]);let E=C??i??[],[D,O]=(0,N.useState)(null),[ee,te]=(0,N.useState)(()=>localStorage.getItem(c5)===`1`);function k(){te(e=>(localStorage.setItem(c5,e?`0`:`1`),!e))}let A=A6(k6(u8,{activationConstraint:{distance:4}}),k6(o8,{coordinateGetter:X8})),j=E.filter(e=>e.pinned),ne=E.filter(e=>!e.pinned),re=e=>ne.filter(t=>(t.projectId??null)===e);function M(e){return E.find(t=>t._id===e)}async function ie(e){O(null);let{active:t,over:n}=e;if(!n)return;let r=M(String(t.id));if(!r)return;let i=String(n.id);if(i.startsWith(`project:`)){let e=i===s5?null:i.slice(8);if((r.projectId??null)===e)return;T.current=!0,w(t=>(t??E).map(t=>t._id===r._id?{...t,projectId:e}:t));try{await h({chatId:r._id,projectId:e})}finally{T.current=!1}return}let a=M(i);if(!a||t.id===n.id)return;if((a.projectId??null)!==(r.projectId??null)||a.pinned!==r.pinned){if(r.pinned||a.pinned)return;T.current=!0,w(e=>(e??E).map(e=>e._id===r._id?{...e,projectId:a.projectId??null}:e));try{await h({chatId:r._id,projectId:a.projectId??null})}finally{T.current=!1}return}let o=a.pinned?j:re(a.projectId??null),s=o.map(e=>e._id),c=s.indexOf(r._id),l=s.indexOf(a._id);if(c<0||l<0)return;let u=[...o];u.splice(c,1),u.splice(l,0,r);let d=u[l-1]??null,f=u[l+1]??null;T.current=!0,w(e=>[...(e??E).filter(e=>!o.some(t=>t._id===e._id)),...u]);try{await m({chatId:r._id,prevKey:d?d.sortKey:null,nextKey:f?f.sortKey:null})}finally{T.current=!1}}let ae=D?M(D):null;return(0,I.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,I.jsxs)(`div`,{className:`oc-sidebar__top`,ref:v,children:[(0,I.jsxs)(X,{className:x===`icon`?`oc-newchat flex-1 justify-center`:`oc-newchat flex-1 justify-start`,onClick:n,title:`${_} (${r})`,"aria-label":_,children:[(0,I.jsx)(Pm,{}),x===`icon`?null:(0,I.jsx)(`span`,{className:`oc-newchat__label`,children:_}),x===`full`?(0,I.jsx)(`kbd`,{className:`oc-newchat__kbd`,"aria-hidden":!0,children:r}):null]}),(0,I.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,I.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:y,children:[(0,I.jsxs)(X,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,I.jsx)(Pm,{}),(0,I.jsx)(`span`,{className:`oc-newchat__label`,children:_}),(0,I.jsx)(`kbd`,{className:`oc-newchat__kbd`,children:r})]}),(0,I.jsx)(X,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,I.jsx)(xm,{})})]})}),(0,I.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,I.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:b,children:[(0,I.jsxs)(X,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,I.jsx)(Pm,{}),(0,I.jsx)(`span`,{className:`oc-newchat__label`,children:_})]}),(0,I.jsx)(X,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,I.jsx)(xm,{})})]})}),(0,I.jsx)(X,{className:`oc-newproject`,variant:`outline`,size:`icon`,"aria-label":TQ(),title:TQ(),onClick:async()=>{let e=await g({title:TQ(),label:QLe(),placeholder:tRe(),confirmLabel:iRe()});e&&await f({name:e})},children:(0,I.jsx)(xm,{})})]}),(0,I.jsxs)(P8,{sensors:A,collisionDetection:L6,modifiers:[drt,urt],onDragStart:e=>O(e.active.id),onDragCancel:()=>O(null),onDragEnd:ie,children:[(0,I.jsxs)(`div`,{className:`oc-sidebar__scroll`,children:[j.length>0?(0,I.jsx)(l5,{label:sRe(),chats:j,children:j.map(n=>(0,I.jsx)(d5,{chat:n,active:n._id===e,projects:a??[],onSelect:t,showProviderBadge:u},n._id))}):null,(a??[]).map(n=>{let r=re(n._id);return(0,I.jsx)(l5,{label:n.name,dropId:krt(n._id),projectId:n._id,chats:r,collapsible:!0,collapsed:n.collapsed,onToggle:()=>void p({projectId:n._id,collapsed:!n.collapsed}),children:n.collapsed?null:r.length===0?(0,I.jsx)(`div`,{className:`oc-sidebar__empty`,children:uRe()}):r.map(n=>(0,I.jsx)(d5,{chat:n,active:n._id===e,projects:a??[],onSelect:t,showProviderBadge:u},n._id))},n._id)}),(0,I.jsx)(l5,{label:pRe(),dropId:s5,chats:re(null),collapsible:!0,collapsed:ee,onToggle:k,children:ee?null:re(null).map(n=>(0,I.jsx)(d5,{chat:n,active:n._id===e,projects:a??[],onSelect:t,showProviderBadge:u},n._id))})]}),(0,I.jsx)(srt,{children:ae?(0,I.jsxs)(`div`,{className:`oc-chatitem oc-chatitem--overlay`,children:[(0,I.jsx)(Sm,{className:`size-3.5 opacity-60`}),o5(ae.color)?(0,I.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:o5(ae.color)}}):(0,I.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,I.jsx)(`span`,{className:`oc-chatitem__label`,children:ae.title||EQ()})]}):null})]})]})}function l5({label:e,dropId:t,projectId:n,chats:r,collapsible:i,collapsed:a,onToggle:o,children:s}){let c=F(V.projects.deleteProject),l=C1(),u=P(V.projects.projectChatCount,n?{projectId:n}:`skip`),{setNodeRef:d,isOver:f}=L8({id:t??`static:${e}`});return(0,I.jsxs)(`div`,{ref:t?d:void 0,className:`oc-sidebar__group`+(f?` oc-sidebar__group--over`:``),children:[(0,I.jsxs)(`div`,{className:`oc-sidebar__group-head`+(i?` oc-sidebar__group-head--btn`:``),...i?{role:`button`,tabIndex:0,onClick:o,onKeyDown:e=>{i&&o&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())}}:{},children:[i?a?(0,I.jsx)(fm,{className:`size-3.5`}):(0,I.jsx)(dm,{className:`size-3.5`}):null,(0,I.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e}),n?(0,I.jsx)(`button`,{className:`oc-sidebar__group-del`,"aria-label":OQ(),onClick:async t=>{t.stopPropagation();let r=u??0;await l({title:SRe({name:e}),description:r>0?TRe({count:r}):ORe(),confirmWord:kQ(),confirmLabel:OQ(),destructive:!0})&&await c({projectId:n})},children:(0,I.jsx)(Vm,{className:`size-3.5`})}):null]}),(0,I.jsx)(K8,{items:r.map(e=>e._id),strategy:_rt,children:s})]})}var u5={openclaw:`OpenClaw`,hermes:`Hermes`};function d5({chat:e,active:t,projects:n,onSelect:r,showProviderBadge:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u}=J8({id:e._id}),d=F(V.chats.renameChat),f=F(V.chats.deleteChat),p=F(V.chats.pinChat),m=F(V.chats.setChatColor),h=P(V.me.getMe,{host:xO})?.ui?.effective?.showChatAge??!0,g=C1(),[_,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(e.title??``),x={transform:w6.Transform.toString(c),transition:l,opacity:+!u},S=o5(e.color);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{ref:s,style:x,className:`oc-chatitem group/row`+(t?` oc-chatitem--active`:``),children:[(0,I.jsx)(`button`,{className:`oc-chatitem__grip`,"aria-label":NRe(),...a,...o,children:(0,I.jsx)(Sm,{className:`size-3.5`})}),S?(0,I.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:S}}):(0,I.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,I.jsx)(`button`,{className:`oc-chatitem__label`,onClick:()=>r(e._id),children:e.title||EQ()}),e.readOnly?(0,I.jsx)(`span`,{className:`oc-chatitem__readonly`,title:DQ(),children:(0,I.jsx)(wm,{size:12,"aria-label":DQ()})}):null,i&&e.providerKind?(0,I.jsx)(`span`,{className:`oc-chatitem__bridge oc-chatitem__bridge--${e.providerKind} group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:oze({provider:u5[e.providerKind]}),children:u5[e.providerKind]}):null,h?(0,I.jsx)(`span`,{className:`oc-chatitem__age group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:new Date(e.updatedAt).toLocaleString(`fr-FR`),children:Ort(e.updatedAt,Date.now())}):null,(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon-xs`,"aria-label":IRe(),className:`opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,I.jsx)(ym,{})})}),(0,I.jsxs)(J$,{align:`end`,className:`w-48`,children:[(0,I.jsxs)(Y$,{onSelect:()=>{b(e.title??``),v(!0)},children:[(0,I.jsx)(Mee,{}),` `,zRe()]}),(0,I.jsxs)(Y$,{onSelect:()=>void p({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,I.jsx)(Pee,{}):(0,I.jsx)(Nee,{}),e.pinned?HRe():GRe()]}),(0,I.jsx)(X$,{children:JRe()}),(0,I.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,I.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void m({chatId:e._id,color:null}),"aria-label":ZRe(),children:`✕`}),a5.map(t=>(0,I.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void m({chatId:e._id,color:t.value})},t.value))]}),(0,I.jsx)(Z$,{}),(0,I.jsxs)(Y$,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await g({title:eze(),description:rze(),confirmLabel:kQ(),destructive:!0})&&await f({chatId:e._id})})},children:[(0,I.jsx)(Vm,{}),` `,kQ()]})]})]})]}),(0,I.jsx)(Q8,{open:_,onOpenChange:v,title:lze(),canSubmit:y.trim().length>0,onSubmit:async()=>{await d({chatId:e._id,title:y.trim()}),v(!1)},children:(0,I.jsx)(`div`,{className:`oc-form`,children:(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:fze()}),(0,I.jsx)(o1,{value:y,onChange:e=>b(e.target.value),autoFocus:!0})]})})})]})}var jrt=i1(`group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,secondary:`bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80`,destructive:`bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20`,outline:`border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground`,ghost:`hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50`,link:`text-primary underline-offset-4 hover:underline`}},defaultVariants:{variant:`default`}});function $({className:e,variant:t=`default`,asChild:n=!1,...r}){return(0,I.jsx)(n?Cy:`span`,{"data-slot":`badge`,"data-variant":t,className:G$(jrt({variant:t}),e),...r})}function Mrt(e){let t=new Map;for(let n of e){let e=t.get(n.instanceName);e||(e={instanceName:n.instanceName,kind:n.kind,agents:[]},t.set(n.instanceName,e)),e.agents.push(n)}let n=e=>(e.displayName??e.agentId).toLowerCase();for(let e of t.values())e.agents.sort((e,t)=>e.isDefault===t.isDefault?n(e).localeCompare(n(t)):e.isDefault?-1:1);let r=[...t.values()],i=e=>e.agents.some(e=>e.isDefault);return r.sort((e,t)=>i(e)===i(t)?e.instanceName.localeCompare(t.instanceName):i(e)?-1:1),r}function Nrt(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>[e.displayName,e.agentId,e.instanceName,e.model].filter(Boolean).some(e=>e.toLowerCase().includes(n))):e}function Prt({open:e,onOpenChange:t,agents:n,onPick:r}){let[i,a]=(0,N.useState)(``),o=(0,N.useMemo)(()=>Mrt(Nrt(n??[],i)),[n,i]);return(0,I.jsx)(h1,{open:e,onOpenChange:t,children:(0,I.jsxs)(g1,{className:`oc-agentpicker`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:_Ve()}),(0,I.jsx)(b1,{children:bVe()})]}),n===void 0?(0,I.jsx)(`p`,{className:`oc-agentpicker__hint`,children:CVe()}):n.length===0?(0,I.jsx)(`p`,{className:`oc-agentpicker__hint`,children:EVe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o1,{autoFocus:!0,value:i,onChange:e=>a(e.target.value),placeholder:kVe(),className:`oc-agentpicker__search`,"aria-label":MVe()}),(0,I.jsx)(`div`,{className:`oc-agentpicker__list`,role:`listbox`,children:o.map(e=>(0,I.jsxs)(`div`,{className:`oc-agentpicker__group`,children:[(0,I.jsxs)(`div`,{className:`oc-agentpicker__instance`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),(0,I.jsx)(`span`,{children:e.instanceName}),(0,I.jsx)($,{variant:`outline`,className:`oc-agentpicker__kind`,children:e.kind})]}),e.agents.map(e=>(0,I.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":!1,className:`oc-agentpicker__item`,onClick:()=>r(e.instanceName,e.agentId),disabled:e.state===`deleted`,title:e.state===`deleted`?FVe():void 0,children:[(0,I.jsx)(lm,{size:15,"aria-hidden":!0,className:`oc-agentpicker__icon`}),(0,I.jsxs)(`span`,{className:`oc-agentpicker__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,I.jsx)(`span`,{className:`oc-agentpicker__model`,children:e.model}):null,e.isDefault?(0,I.jsx)(Bm,{size:13,"aria-label":RVe(),className:`oc-agentpicker__default`}):null]},`${e.instanceName}/${e.agentId}`))]},e.instanceName))})]})]})})}function Frt(e){let t=F(V.chats.createChat),n=P(V.agents.listMyAgents),[r,i]=(0,N.useState)(!1),a=(0,N.useCallback)(async(n,r)=>{e(await t({title:`New chat`,instanceName:n,agentId:r}))},[t,e]);return{startNewChat:(0,N.useCallback)(async()=>{let e=n;if(e&&e.length===1&&e[0].state!==`deleted`){await a(e[0].instanceName,e[0].agentId);return}i(!0)},[n,a]),picker:(0,I.jsx)(Prt,{open:r,onOpenChange:i,agents:n,onPick:(e,t)=>{i(!1),a(e,t)}})}}var f5=[`admin`,`user`,`pending`];function p5(){let e=P(V.me.authProviders)?.anonymous===!0,[t,n]=(0,N.useState)(!1),r=P(V.dev.listUsersDev,e?{}:`skip`),i=P(V.me.getImpersonation),a=F(V.dev.setMyRole),o=F(V.dev.setRole),s=F(V.admin.startImpersonation),c=F(V.admin.stopImpersonation);if(!e)return null;let l=r?.find(e=>e.isMe),u=l?.role===`admin`,d=i?.impersonating===!0,f=(r??[]).filter(e=>!e.isMe);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-devfab`,onClick:()=>n(!0),title:aLe(),children:[(0,I.jsx)(Gm,{size:13}),`DEV`]}),(0,I.jsx)(h1,{open:t,onOpenChange:n,children:(0,I.jsxs)(g1,{children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:cLe()}),(0,I.jsx)(b1,{children:dLe()})]}),(0,I.jsxs)(`div`,{className:`oc-devsw__me`,children:[(0,I.jsxs)(`span`,{className:`oc-devsw__melabel`,children:[mLe({canonical:l?.canonical??`…`}),` `,(0,I.jsx)($,{variant:`outline`,children:l?.role??`…`})]}),(0,I.jsx)(`div`,{className:`oc-devsw__roles`,children:f5.map(e=>(0,I.jsx)(X,{type:`button`,size:`xs`,variant:l?.role===e?`secondary`:`ghost`,disabled:l?.role===e,onClick:()=>void a({role:e}),children:e===`admin`?_Le():e===`user`?bLe():CLe()},e))})]}),d?(0,I.jsxs)(`div`,{className:`oc-devsw__imp`,children:[ELe(),` `,(0,I.jsx)(`strong`,{children:i.targetLabel}),`.`,(0,I.jsx)(X,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>void c(),children:kLe()})]}):null,(0,I.jsx)(`div`,{className:`oc-devsw__list`,children:f.length===0?(0,I.jsx)(`p`,{className:`oc-devsw__empty`,children:MLe()}):f.map(e=>(0,I.jsxs)(`div`,{className:`oc-devsw__row`,children:[(0,I.jsx)(`span`,{className:`oc-devsw__label`,children:e.name||e.email||e.canonical||e.userId.slice(0,8)}),(0,I.jsx)(`select`,{className:`oc-devsw__select`,value:e.role,disabled:!e.canonical,onChange:t=>e.canonical&&void o({canonical:e.canonical,role:t.target.value}),children:f5.map(e=>(0,I.jsx)(`option`,{value:e,children:e},e))}),(0,I.jsx)(X,{type:`button`,size:`xs`,variant:`ghost`,disabled:!u||e.role===`pending`,title:u?e.role===`pending`?RLe():VLe():FLe(),onClick:()=>{s({profileId:e.profileId}),n(!1)},children:WLe()})]},e.profileId))})]})})]})}function m5({label:e,mode:t,minimal:n=!1}){let{signOut:r}=Ir(),i=F(V.me.setThemeMode).withOptimisticUpdate((e,{mode:t})=>{let n=e.getQuery(V.me.getMe,{host:xO});if(!n)return;let r=t===null?n.defaultThemeMode??`system`:t;e.setQuery(V.me.getMe,{host:xO},{...n,themeMode:t,resolvedThemeMode:r})}),a=t??`default`;return(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsxs)(X,{variant:`ghost`,size:`sm`,className:`gap-1.5`,children:[e,(0,I.jsx)(dm,{className:`opacity-60`})]})}),(0,I.jsx)(J$,{align:`end`,className:`w-52`,children:n?(0,I.jsxs)(Y$,{onClick:()=>void r(),children:[(0,I.jsx)(Tm,{}),` `,uk()]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X$,{children:YO()}),(0,I.jsxs)(Q2e,{value:a,onValueChange:e=>void i({mode:e==="default"?null:e}),children:[(0,I.jsxs)(Q$,{value:`light`,children:[(0,I.jsx)(Ree,{}),` `,QO()]}),(0,I.jsxs)(Q$,{value:`dark`,children:[(0,I.jsx)(Am,{}),` `,tk()]}),(0,I.jsxs)(Q$,{value:`system`,children:[(0,I.jsx)(km,{}),` `,ik()]}),(0,I.jsx)(Q$,{value:`default`,children:sk()})]}),(0,I.jsx)(Z$,{}),(0,I.jsxs)(Y$,{onClick:()=>void r(),children:[(0,I.jsx)(Tm,{}),` `,uk()]})]})})]})}var Irt={altered_words:()=>$We(),incorrect:()=>nGe(),incoherence:()=>aGe(),formatting:()=>cGe(),latency:()=>dGe(),api_error:()=>mGe(),other:()=>_Ge()},Lrt=e=>Irt[e]?.()??e,Rrt={anomaly_open:Hm,anomaly_resolved:gm,feedback_reply:Em};function zrt(e){return e.kind===`feedback_reply`?{title:qWe(),body:XWe()}:{title:e.title,body:e.body}}function h5(){let e=P(V.notifications.myUnreadCount)??0,t=P(V.notifications.myNotifications),n=P(V.feedback.myFeedback),r=F(V.notifications.markRead),i=F(V.notifications.markAllRead),a=F(V.notifications.clearOne),o=F(V.notifications.clearAll),s=F(V.feedback.closeMyFeedback),c=ss(),[l,u]=(0,N.useState)(!1),d=e=>{if(e.unread&&r({notificationId:e._id}),!e.href)return;if(u(!1),e.href.startsWith(`/chat/`)){c({to:`/chat/$chatId`,params:{chatId:e.href.slice(6)}});return}let[t,n]=e.href.split(`?`);c({to:t,search:Object.fromEntries(new URLSearchParams(n??``))})};return(0,I.jsxs)(K$,{open:l,onOpenChange:u,children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-bell`,"aria-label":e>0?qUe({count:e}):XUe(),children:[(0,I.jsx)(cm,{size:18,"aria-hidden":!0}),e>0?(0,I.jsx)(`span`,{className:`oc-bell__badge`,"aria-hidden":!0,children:e>9?`9+`:e}):null]})}),(0,I.jsxs)(J$,{align:`end`,className:`oc-notif`,children:[(0,I.jsxs)(`div`,{className:`oc-notif__head`,children:[(0,I.jsx)(`span`,{children:$Ue()}),t&&t.length>0?(0,I.jsxs)(`span`,{className:`oc-notif__bulk`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__act`,disabled:e===0,onClick:()=>void i({}),children:nWe()}),(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__act`,onClick:()=>void o({}),children:aWe()})]}):null]}),t===void 0?(0,I.jsx)(`div`,{className:`oc-notif__empty`,children:KO()}):t.length===0?(0,I.jsx)(`div`,{className:`oc-notif__empty`,children:cWe()}):(0,I.jsx)(`div`,{className:`oc-notif__list`,children:t.map(e=>{let t=Rrt[e.kind]??cm,{title:n,body:i}=zrt(e);return(0,I.jsxs)(`div`,{className:`oc-notif__item${e.unread?` is-unread`:``}${e.href?` is-link`:``}`,role:e.href?`button`:void 0,tabIndex:e.href?0:void 0,onClick:e.href?()=>d(e):void 0,children:[(0,I.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,I.jsx)(t,{size:14,className:`oc-notif__kind oc-notif__kind--${e.kind}`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`oc-notif__title`,children:n}),(0,I.jsxs)(`span`,{className:`oc-notif__row-actions`,children:[e.unread?(0,I.jsx)(`button`,{type:`button`,title:jQ(),"aria-label":jQ(),onClick:t=>{t.stopPropagation(),r({notificationId:e._id})},children:(0,I.jsx)(um,{size:13})}):null,(0,I.jsx)(`button`,{type:`button`,title:MQ(),"aria-label":MQ(),onClick:t=>{t.stopPropagation(),a({notificationId:e._id})},children:(0,I.jsx)(Km,{size:13})})]})]}),(0,I.jsx)(`p`,{className:`oc-notif__body`,children:i}),(0,I.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.createdAt).toLocaleString(q())})]},e._id)})}),n&&n.length>0?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-notif__head oc-notif__head--sub`,children:hWe()}),(0,I.jsx)(`div`,{className:`oc-notif__list`,children:n.map(e=>(0,I.jsx)(Brt,{it:e,onClose:t=>s({feedbackId:e._id,reason:t}),onNavigate:()=>u(!1)},e._id))})]}):null]})]})}function Brt({it:e,onClose:t,onNavigate:n}){let r=D1(),[i,a]=(0,N.useState)(!1),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(``),[u,d]=(0,N.useState)(!1);async function f(){d(!0);try{await t(c.trim()||void 0)}catch(e){r.error(NQ(),e)}finally{d(!1)}}return(0,I.jsxs)(`div`,{className:`oc-notif__item`,children:[(0,I.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,I.jsx)(`span`,{className:`oc-notif__title`,children:Lrt(e.category)}),(0,I.jsx)(`span`,{className:`oc-notif__status${e.answered?` is-answered`:``}`,children:e.answered?vWe():xWe()})]}),e.thread.length>0?(0,I.jsx)(`div`,{className:`oc-notif__thread`,children:e.thread.map((e,t)=>(0,I.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,I.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?wWe():DWe()}),(0,I.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):null,e.messageText?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-notif__report-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,I.jsx)(dm,{size:13,"aria-hidden":!0}):(0,I.jsx)(fm,{size:13,"aria-hidden":!0}),NWe()]}),i?(0,I.jsx)(`div`,{className:`oc-notif__report-msg`,children:e.messageText}):null]}):null,(0,I.jsxs)(`div`,{className:`oc-notif__report-actions`,children:[(0,I.jsx)(xs,{to:`/chat/$chatId`,params:{chatId:e.chatId},search:{m:e.messageId},className:`oc-notif__link`,onClick:n,children:AWe()}),o?null:(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__link oc-notif__link--muted`,onClick:()=>s(!0),children:NQ()})]}),o?(0,I.jsxs)(`div`,{className:`oc-notif__close-form`,children:[(0,I.jsx)(`textarea`,{className:`oc-notif__close-input`,rows:2,value:c,onChange:e=>l(e.target.value),placeholder:RWe()}),(0,I.jsxs)(`div`,{className:`oc-notif__close-actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__close-confirm`,disabled:u,onClick:()=>void f(),children:VWe()}),(0,I.jsx)(`button`,{type:`button`,className:`oc-notif__close-cancel`,onClick:()=>{s(!1),l(``)},children:WWe()})]})]}):null]})}var g5={mod:!0,key:`k`},_5={mod:!0,shift:!0,key:`o`};function Vrt(e){return/mac/i.test(e)}function Hrt(){if(typeof navigator>`u`)return``;let e=navigator;return e.userAgentData?.platform||e.platform||e.userAgent||``}var v5=null;function y5(){return v5===null&&(v5=Vrt(Hrt())),v5}function b5(e,t){let n=e.key.toUpperCase();if(t){let t=``;return e.alt&&(t+=`⌥`),e.shift&&(t+=`⇧`),e.mod&&(t+=`⌘`),t+n}let r=[];return e.mod&&r.push(`Ctrl`),e.shift&&r.push(`Shift`),e.alt&&r.push(`Alt`),r.push(n),r.join(`+`)}function x5(e,t){let n=e.metaKey||e.ctrlKey;return!!t.mod!==n||!!t.shift!==e.shiftKey||!!t.alt!==e.altKey?!1:e.key.toLowerCase()===t.key.toLowerCase()}var S5=2,Urt=180;function Wrt(){let e=ss(),t=(0,N.useRef)(null),n=(0,N.useRef)(null),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(``),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(0),d=(0,N.useMemo)(()=>b5(g5,y5()),[]);(0,N.useEffect)(()=>{let e=setTimeout(()=>c(a),Urt);return()=>clearTimeout(e)},[a]);let f=s.trim(),p=P(V.search.searchConversations,f.length>=S5?{query:f}:`skip`),m=p??[],h=f.length>=S5&&p===void 0;(0,N.useEffect)(()=>{let e=e=>{x5(e,g5)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,N.useEffect)(()=>{r&&(o(``),c(``),u(0))},[r]),(0,N.useEffect)(()=>{u(0)},[p]),(0,N.useEffect)(()=>{(n.current?.querySelector(`[data-index="${l}"]`))?.scrollIntoView({block:`nearest`})},[l]);let g=(0,N.useCallback)(t=>{i(!1),e({to:`/chat/$chatId`,params:{chatId:t}})},[e]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-search-trigger`,onClick:()=>i(!0),"aria-label":EBe(),children:[(0,I.jsx)(Im,{className:`oc-search-trigger__icon`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`oc-search-trigger__label`,children:kBe()}),(0,I.jsx)(`kbd`,{className:`oc-search-trigger__kbd`,children:d})]}),(0,I.jsx)(h1,{open:r,onOpenChange:i,children:(0,I.jsxs)(g1,{showCloseButton:!1,className:`oc-search-palette top-[12vh] translate-y-0 max-w-xl gap-0 overflow-hidden p-0`,onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,I.jsx)(y1,{className:`sr-only`,children:MBe()}),(0,I.jsxs)(`div`,{className:`oc-search-palette__head`,children:[(0,I.jsx)(Im,{className:`oc-search-palette__head-icon`,"aria-hidden":!0}),(0,I.jsx)(`input`,{ref:t,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),u(e=>Math.min(e+1,m.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),u(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=m[l];t&&g(t.chatId)}},placeholder:FBe(),className:`oc-search-palette__field`,autoComplete:`off`,spellCheck:!1,"aria-label":RBe()})]}),(0,I.jsx)(`div`,{className:`oc-search-palette__results`,ref:n,role:`listbox`,children:f.length<S5?(0,I.jsx)(`div`,{className:`oc-search-palette__hint`,children:VBe({count:S5})}):h?(0,I.jsx)(`div`,{className:`oc-search-palette__hint`,children:WBe()}):m.length===0?(0,I.jsx)(`div`,{className:`oc-search-palette__hint`,children:qBe({term:f})}):m.map((e,t)=>(0,I.jsxs)(`button`,{type:`button`,"data-index":t,role:`option`,"aria-selected":t===l,className:G$(`oc-search-result`,t===l&&`is-active`),onMouseMove:()=>u(t),onClick:()=>g(e.chatId),children:[(0,I.jsx)(`span`,{className:`oc-search-result__icon`,"aria-hidden":!0,children:e.matchedIn===`title`?(0,I.jsx)(kee,{size:15}):(0,I.jsx)(Em,{size:15})}),(0,I.jsxs)(`span`,{className:`oc-search-result__body`,children:[(0,I.jsx)(`span`,{className:`oc-search-result__title`,children:e.title||XBe()}),e.snippet?(0,I.jsx)(`span`,{className:`oc-search-result__snippet`,children:e.snippet}):null]}),(0,I.jsx)(`span`,{className:`oc-search-result__tag`,children:e.matchedIn===`title`?$Be():nVe()})]},e.chatId))}),(0,I.jsxs)(`div`,{className:`oc-search-palette__footer`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:`↑`}),(0,I.jsx)(`kbd`,{children:`↓`}),` `,aVe()]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:`↵`}),` `,cVe()]}),(0,I.jsxs)(`span`,{children:[(0,I.jsx)(`kbd`,{children:dVe()}),` `,mVe()]})]})]})})]})}var C5=[`conversational`,`documentary`],Grt=new Set(C5),Krt=`conversational`;function qrt(e){let t=new Set((e??[]).filter(e=>Grt.has(e)));return t.size===0?[Krt]:C5.filter(e=>t.has(e))}function Jrt({profileId:e,userLabel:t,open:n,onOpenChange:r}){let i=P(V.agents.listAgentPoolForUser,n&&e?{profileId:e}:`skip`),a=P(V.agents.listUserAgents,n&&e?{profileId:e}:`skip`),o=new Set((a??[]).map(e=>`${e.instanceName}/${e.agentId}`)),s=(a??[]).find(e=>e.isDefault)??null,c=s?`${s.instanceName}/${s.agentId}`:null,l=new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),u=[...(i?.agents??[]).map(e=>({...e,outOfPool:!1})),...(a??[]).filter(e=>!l.has(`${e.instanceName}/${e.agentId}`)).map(e=>({instanceName:e.instanceName,agentId:e.agentId,displayName:e.displayName,emoji:e.emoji,model:e.model,kind:e.kind,state:e.state,outOfPool:!0}))],d=new Map;for(let e of u){let t=d.get(e.instanceName)??[];t.push(e),d.set(e.instanceName,t)}return(0,I.jsx)(h1,{open:n,onOpenChange:r,children:(0,I.jsxs)(g1,{className:`oc-access`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:Yje({user:t})}),(0,I.jsx)(b1,{children:Qje()})]}),i?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:i.inGroup?tMe():iMe()}):null,(0,I.jsx)(`div`,{className:`oc-access__list`,children:i===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:sMe()}):u.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:gMe()}):[...d.entries()].map(([t,n])=>(0,I.jsx)(Yrt,{profileId:e,instanceName:t,kind:n[0].kind,agents:n,assigned:o,defaultKey:c},t))})]})})}function Yrt({profileId:e,instanceName:t,kind:n,agents:r,assigned:i,defaultKey:a}){let o=F(V.agents.assignAgent),s=F(V.agents.removeAgent),c=F(V.agents.setDefaultAgent),l=D1();if(!e)return null;async function u(n,r){try{r?await s({profileId:e,instanceName:t,agentId:n}):await o({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(uMe(),e)}}async function d(n){try{await c({profileId:e,instanceName:t,agentId:n})}catch(e){l.error(pMe(),e)}}return(0,I.jsxs)(`div`,{className:`oc-access__group`,children:[(0,I.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),(0,I.jsx)(`span`,{children:t}),(0,I.jsx)($,{variant:`outline`,className:`oc-access__kind`,children:n})]}),r.map(e=>{let n=`${t}/${e.agentId}`,r=i.has(n),o=a===n,s=e.state===`deleted`;return(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:r,disabled:s&&!r,onCheckedChange:()=>void u(e.agentId,r),"aria-label":yMe({name:e.displayName??e.agentId})}),(0,I.jsxs)(`span`,{className:`oc-access__label`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,I.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,s?(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:SMe()}):null,e.outOfPool?(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:TMe()}):null,r?o?(0,I.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":_Q(),title:_Q(),children:(0,I.jsx)(Bm,{size:14,fill:`currentColor`})}):(0,I.jsx)(X,{type:`button`,size:`icon-sm`,variant:`ghost`,className:`oc-access__setdefault`,"aria-label":vQ(),title:vQ(),onClick:()=>void d(e.agentId),children:(0,I.jsx)(Bm,{size:14})}):null]},e.agentId)})]})}function Xrt(e,t){return typeof e==`number`&&typeof t==`number`?e-t:typeof e==`boolean`&&typeof t==`boolean`?!!e-+!!t:String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})}function Zrt(e,t,n){return[...e].sort((e,r)=>{let i=t(e),a=t(r),o=i==null,s=a==null;if(o||s)return o&&s?0:o?1:-1;let c=Xrt(i,a);return n===`asc`?c:-c})}function w5({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,I.jsx)(`table`,{"data-slot":`table`,className:G$(`w-full caption-bottom text-sm`,e),...t})})}function T5({className:e,...t}){return(0,I.jsx)(`thead`,{"data-slot":`table-header`,className:G$(`[&_tr]:border-b`,e),...t})}function E5({className:e,...t}){return(0,I.jsx)(`tbody`,{"data-slot":`table-body`,className:G$(`[&_tr:last-child]:border-0`,e),...t})}function D5({className:e,...t}){return(0,I.jsx)(`tr`,{"data-slot":`table-row`,className:G$(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function O5({className:e,...t}){return(0,I.jsx)(`th`,{"data-slot":`table-head`,className:G$(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function k5({className:e,...t}){return(0,I.jsx)(`td`,{"data-slot":`table-cell`,className:G$(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function A5({title:e,rows:t,columns:n,rowActions:r,onAdd:i,addLabel:a=qVe(),bulkActions:o,emptyHint:s=XVe(),isExpanded:c,renderExpanded:l}){let[u,d]=(0,N.useState)(new Set),[f,p]=(0,N.useState)(null),m=t??[],h=f?n[f.index]:void 0,g=f&&h?.sort?Zrt(m,h.sort,f.dir):m;function _(e){p(t=>!t||t.index!==e?{index:e,dir:`asc`}:t.dir===`asc`?{index:e,dir:`desc`}:null)}let v=+!!o+n.length+ +!!r,y=m.length>0&&u.size===m.length,b=u.size>0&&!y;function x(){d(y?new Set:new Set(m.map(e=>e._id)))}function S(e){d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return(0,I.jsxs)(`div`,{className:`oc-dt`,children:[(0,I.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,I.jsx)(`h2`,{className:`oc-dt__title`,children:e}),(0,I.jsxs)(`div`,{className:`oc-dt__bar-actions`,children:[u.size>0&&o?o.map(e=>(0,I.jsxs)(X,{size:`sm`,variant:e.variant===`destructive`?`destructive`:`outline`,onClick:()=>{e.onSelect([...u]),d(new Set)},children:[e.variant===`destructive`?(0,I.jsx)(Vm,{}):null,e.label,` (`,u.size,`)`]},e.label)):null,i?(0,I.jsxs)(X,{size:`sm`,onClick:i,children:[(0,I.jsx)(Pm,{}),` `,a]}):null]})]}),t===void 0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:$Ve()}):m.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:s}):(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[o?(0,I.jsx)(O5,{className:`w-8`,children:(0,I.jsx)(A1,{"aria-label":nHe(),checked:y?!0:b?`indeterminate`:!1,onCheckedChange:x})}):null,n.map((e,t)=>{let n=f?.index===t;return e.sort?(0,I.jsx)(O5,{className:e.className,"aria-sort":n?f.dir===`asc`?`ascending`:`descending`:`none`,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-dt__sort`,onClick:()=>_(t),"aria-label":dHe({column:e.header}),children:[e.header,n?f.dir===`asc`?(0,I.jsx)(pm,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,I.jsx)(dm,{className:`oc-dt__sort-icon`,"aria-hidden":!0}):(0,I.jsx)(mm,{className:`oc-dt__sort-icon oc-dt__sort-icon--idle`,"aria-hidden":!0})]})},e.header):(0,I.jsx)(O5,{className:e.className,children:e.header},e.header)}),r?(0,I.jsx)(O5,{className:`w-8`}):null]})}),(0,I.jsx)(E5,{children:g.map(e=>{let t=r?.(e)??[],i=c?.(e)??!1;return(0,I.jsxs)(N.Fragment,{children:[(0,I.jsxs)(D5,{className:`group/row`,children:[o?(0,I.jsx)(k5,{children:(0,I.jsx)(A1,{"aria-label":aHe(),checked:u.has(e._id),onCheckedChange:()=>S(e._id)})}):null,n.map(t=>(0,I.jsx)(k5,{className:t.className,children:t.cell(e)},t.header)),r?(0,I.jsx)(k5,{children:t.length>0?(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":cHe(),className:`opacity-0 transition-opacity group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,children:(0,I.jsx)(ym,{})})}),(0,I.jsx)(J$,{align:`end`,children:t.map((t,n)=>(0,I.jsxs)(`div`,{children:[t.variant===`destructive`&&n>0?(0,I.jsx)(Z$,{}):null,(0,I.jsx)(Y$,{variant:t.variant,onSelect:()=>t.onSelect(e),children:t.label})]},t.label))})]}):null}):null]}),i&&l?(0,I.jsx)(D5,{className:`oc-dt__expansion`,children:(0,I.jsx)(k5,{colSpan:v,className:`oc-dt__expansion-cell`,children:l(e)})}):null]},e._id)})})]})]})}function j5({icon:e,total:t,items:n}){if(t===0)return(0,I.jsxs)($,{variant:`outline`,className:`oc-group-chip oc-group-chip--empty gap-1`,children:[e,`0`]});let r=t-n.length;return(0,I.jsxs)(`div`,{className:`oc-group-detail`,children:[n.map((e,t)=>(0,I.jsxs)($,{variant:e.highlight?`secondary`:`outline`,className:`oc-group-chip gap-1`,title:e.label,children:[e.marker,(0,I.jsx)(`span`,{className:`oc-group-chip__txt`,children:e.label})]},t)),r>0?(0,I.jsxs)($,{variant:`outline`,className:`oc-group-chip`,children:[`+`,r]}):null]})}function M5({delayDuration:e=0,...t}){return(0,I.jsx)(_ue,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function N5({...e}){return(0,I.jsx)(vue,{"data-slot":`tooltip`,...e})}function P5({...e}){return(0,I.jsx)(yue,{"data-slot":`tooltip-trigger`,...e})}function F5({className:e,sideOffset:t=0,children:n,...r}){return(0,I.jsx)(bue,{children:(0,I.jsxs)(xue,{"data-slot":`tooltip-content`,sideOffset:t,className:G$(`z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...r,children:[n,(0,I.jsx)(Sue,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground`})]})})}var I5={AGENT_NOT_FOUND:()=>({label:mHe(),hint:_He()}),AUTH_TOKEN_MISMATCH:()=>({label:bHe(),hint:CHe()}),DEVICE_SIGNING_FAILED:()=>({label:EHe(),hint:kHe()}),SESSION_SCOPE_DENIED:()=>({label:MHe(),hint:FHe()}),GATEWAY_TIMEOUT:()=>({label:RHe(),hint:VHe()}),GATEWAY_DISCONNECTED:()=>({label:WHe(),hint:qHe()}),ATTACHMENT_TOO_LARGE:()=>({label:nUe(),hint:aUe()}),ATTACHMENT_REJECTED:()=>({label:cUe(),hint:dUe()}),BRIDGE_UNREACHABLE:()=>({label:XHe(),hint:$He()}),INVALID_REQUEST:()=>({label:mUe(),hint:_Ue()}),NOT_CONFIGURED:()=>({label:bUe(),hint:CUe()}),UNROUTED:()=>({label:EUe(),hint:kUe()}),UPSTREAM_ERROR:()=>({label:MUe(),hint:FUe()}),UNKNOWN:()=>({label:RUe(),hint:VUe()})};function L5(e){return e?I5[e]?.()??{label:e,hint:WUe()}:I5.UNKNOWN()}var Qrt=[`gateway-http`,`shared-fs`,`off`],$rt=[`inline`,`shared-fs`];He.object({mediaMode:He.optional(He.union(He.literal(`gateway-http`),He.literal(`shared-fs`),He.literal(`off`))),inboundMediaMode:He.optional(He.union(He.literal(`inline`),He.literal(`shared-fs`))),rehydration:He.optional(He.boolean()),mediaMaxMb:He.optional(He.number()),inboundAgentMount:He.optional(He.string()),outboundAgentMount:He.optional(He.string())});var R5={mediaMode:`gateway-http`,inboundMediaMode:`inline`,rehydration:!0,mediaMaxMb:1024,inboundAgentMount:`/home/node/.openclaw/media/inbound`,outboundAgentMount:`/home/node/.openclaw/media/outbound`};function eit(e){return{mediaMode:e.mediaMode??R5.mediaMode,inboundMediaMode:e.inboundMediaMode??R5.inboundMediaMode,rehydration:e.rehydration??R5.rehydration,mediaMaxMb:e.mediaMaxMb??R5.mediaMaxMb,inboundAgentMount:e.inboundAgentMount??R5.inboundAgentMount,outboundAgentMount:e.outboundAgentMount??R5.outboundAgentMount}}function tit(e,t){let n={},r=r=>{(e[r]!==R5[r]||t[r]!==void 0)&&(n[r]=e[r])};return r(`mediaMode`),r(`inboundMediaMode`),r(`rehydration`),r(`mediaMaxMb`),r(`inboundAgentMount`),r(`outboundAgentMount`),n}var z5=e=>typeof e==`string`?e:null;function B5(e){return/^\d+\.\d+\.\d+$/.test(e)?e.split(`.`).map(e=>Number.parseInt(e,10)):null}function V5(e,t){let n=B5(e),r=B5(t);if(n===null||r===null)return null;for(let e=0;e<3;e++){let t=n[e]-r[e];if(t!==0)return t}return 0}function nit(e,t){if(e===null||t===null)return!1;let n=V5(t,e.min);return n!==null&&n>=0}function H5(e,t){let n={range:null,validatedVersions:[]};if(typeof e!=`object`||!e)return n;let r=e.providers;if(typeof r!=`object`||!r)return n;let i=r[t];if(typeof i!=`object`||!i)return n;let a=i,o=null;if(typeof a.supportedRange==`object`&&a.supportedRange!==null){let e=a.supportedRange,t=z5(e.min),n=z5(e.maxValidated);t!==null&&n!==null&&(o={min:t,maxValidated:n})}let s=Array.isArray(a.validatedVersions)?a.validatedVersions.filter(e=>typeof e==`string`):[];return{range:o,validatedVersions:s}}function rit(e,t,n){if(e===null)return`unknown`;let{range:r}=H5(n,t);return nit(r,e)?r!==null&&(V5(e,r.maxValidated)??0)>0?`beyond`:`supported`:`unknown`}function U5(e){return e===`supported`?z0e():e===`beyond`?H0e():G0e()}function W5(e){return e??n$()}function G5(e){return e===null?e2e():Z0e({version:e})}function iit(e,t){if(typeof e!=`object`||!e)return!1;let n=e.providers;return typeof n!=`object`||!n?!1:t in n}function K5(e){return e.filter(e=>e.state===`error`)}function ait(e){return e.reachable&&K5(e.targets).length===0}function oit(e){return e.state===`error`&&e.lastErrorCode!==null}function sit(e){return!!e.lastDownstreamRejectCode}function q5(e){return e.kind??`openclaw`}function cit(e){return[...e].sort((e,t)=>e===`openclaw`?-1:t===`openclaw`?1:e.localeCompare(t))}function lit(e,t,n){let r=new Map;for(let e of t)e.instanceName&&r.set(e.instanceName,e.provider);for(let e of n)r.set(e.name,q5(e));let i=e=>(e.instanceName?r.get(e.instanceName):void 0)??`openclaw`,a=new Set;for(let e of n)a.add(q5(e));for(let e of t)a.add(e.provider);for(let t of e)a.add(i(t));return cit(a).map(r=>({key:r,connections:e.filter(e=>i(e)===r),compatTargets:t.filter(e=>e.provider===r),instances:n.filter(e=>q5(e)===r)}))}function uit(e){return e===`openclaw`?`OpenClaw`:e===`hermes`?`Hermes`:e.charAt(0).toUpperCase()+e.slice(1)}var J5={s:1e3,m:6e4,h:36e5,d:864e5,w:6048e5};function Y5(e,t){let n=e.trim();if(n===`now`)return t;let r=/^now-(\d+)([smhdw])$/.exec(n);if(r===null)return null;let i=Number(r[1]),a=J5[r[2]];return!Number.isFinite(i)||a===void 0?null:t-i*a}function X5(e,t=Date.now()){return e.kind===`absolute`?{from:e.from,to:e.to}:{from:Y5(e.from,t)??t-J5.h,to:Y5(e.to,t)??t}}var Z5=[{label:FFe(),from:`now-5m`},{label:RFe(),from:`now-15m`},{label:VFe(),from:`now-30m`},{label:WFe(),from:`now-1h`},{label:qFe(),from:`now-3h`},{label:XFe(),from:`now-6h`},{label:$Fe(),from:`now-12h`},{label:nIe(),from:`now-24h`},{label:aIe(),from:`now-2d`},{label:cIe(),from:`now-7d`},{label:dIe(),from:`now-30d`},{label:mIe(),from:`now-90d`}];function Q5(e){return new Date(e).toLocaleString(`fr-FR`,{day:`2-digit`,month:`2-digit`,hour:`2-digit`,minute:`2-digit`})}function dit(e){if(e.kind===`relative`){let t=Z5.find(t=>t.from===e.from&&e.to===`now`);return t?t.label:`${e.from} → ${e.to}`}return`${Q5(e.from)} → ${Q5(e.to)}`}function $5(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function e7(e){if(e===``)return null;let t=new Date(e).getTime();return Number.isNaN(t)?null:t}function fit(e){let t=e.trim();return t===`true`?!0:t===`false`?!1:t!==``&&Number.isFinite(Number(t))?Number(t):e}function t7(e){let[t,n]=(0,N.useState)(0);return(0,N.useEffect)(()=>{if(e.kind!==`relative`)return;let t=window.setInterval(()=>n(e=>e+1),3e4);return()=>window.clearInterval(t)},[e.kind]),(0,N.useMemo)(()=>{let{from:t,to:n}=X5(e);return e.kind===`absolute`?{from:t,to:n}:{from:n7(t),to:n7(n)}},[e,t])}function n7(e){return Math.floor(e/6e4)*6e4}function r7({value:e,onChange:t}){let[n,r]=(0,N.useState)(!1),[i,a]=(0,N.useState)(``),o=X5(e),[s,c]=(0,N.useState)(()=>$5(o.from)),[l,u]=(0,N.useState)(()=>$5(o.to));function d(t){if(t){let t=X5(e);c($5(t.from)),u($5(t.to)),a(``)}r(t)}function f(e){t({kind:`relative`,from:e,to:`now`}),r(!1)}function p(){let e=e7(s),n=e7(l);e===null||n===null||(t({kind:`absolute`,from:e,to:n}),r(!1))}let m=(0,N.useMemo)(()=>{let e=i.trim().toLowerCase();return e===``?Z5:Z5.filter(t=>t.label.toLowerCase().includes(e)||t.from.toLowerCase().includes(e))},[i]),h=e7(s)!==null&&e7(l)!==null;return(0,I.jsxs)(CT,{open:n,onOpenChange:d,children:[(0,I.jsx)(wT,{asChild:!0,children:(0,I.jsxs)(X,{variant:`outline`,size:`sm`,className:`oc-timerange__trigger`,children:[(0,I.jsx)(wee,{}),dit(e)]})}),(0,I.jsx)(TT,{children:(0,I.jsx)(ET,{align:`end`,sideOffset:6,className:`oc-timerange__panel z-50 rounded-lg border border-border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95`,children:(0,I.jsxs)(`div`,{className:`oc-timerange__cols`,children:[(0,I.jsxs)(`div`,{className:`oc-timerange__absolute`,children:[(0,I.jsx)(`div`,{className:`oc-timerange__section-title`,children:`Plage absolue`}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:`De`}),(0,I.jsx)(o1,{type:`datetime-local`,value:s,onChange:e=>c(e.target.value)})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:`À`}),(0,I.jsx)(o1,{type:`datetime-local`,value:l,onChange:e=>u(e.target.value)})]}),(0,I.jsx)(X,{size:`sm`,className:`oc-timerange__apply`,disabled:!h,onClick:p,children:`Appliquer`})]}),(0,I.jsxs)(`div`,{className:`oc-timerange__relative`,children:[(0,I.jsxs)(`div`,{className:`oc-timerange__search`,children:[(0,I.jsx)(Im,{className:`oc-timerange__search-icon`,"aria-hidden":!0}),(0,I.jsx)(o1,{value:i,onChange:e=>a(e.target.value),placeholder:`Rechercher une plage`,"aria-label":`Rechercher une plage relative`})]}),(0,I.jsx)(`ul`,{className:`oc-timerange__list`,children:m.length===0?(0,I.jsx)(`li`,{className:`oc-timerange__empty`,children:`Aucune plage.`}):m.map(t=>(0,I.jsx)(`li`,{children:(0,I.jsx)(`button`,{type:`button`,className:`oc-timerange__option`+(e.kind===`relative`&&e.from===t.from&&e.to===`now`?` is-active`:``),onClick:()=>f(t.from),children:t.label})},t.from))})]})]})})})]})}var pit=250;function i7({q:e,onQChange:t,searchPlaceholder:n=VVe(),children:r,timeRange:i,onTimeRangeChange:a,onReset:o,canReset:s=!0}){let[c,l]=(0,N.useState)(e);(0,N.useEffect)(()=>{l(e)},[e]);let u=(0,N.useRef)(null);function d(e){l(e),u.current!==null&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>t(e),pit)}(0,N.useEffect)(()=>()=>{u.current!==null&&window.clearTimeout(u.current)},[]);function f(){u.current!==null&&window.clearTimeout(u.current),o()}return(0,I.jsxs)(`div`,{className:`oc-filterbar`,children:[(0,I.jsxs)(`div`,{className:`oc-filterbar__search`,children:[(0,I.jsx)(Im,{className:`oc-filterbar__search-icon`,"aria-hidden":!0}),(0,I.jsx)(o1,{value:c,onChange:e=>d(e.target.value),placeholder:n,"aria-label":n})]}),r?(0,I.jsx)(`div`,{className:`oc-filterbar__quick`,children:r}):null,i&&a?(0,I.jsx)(r7,{value:i,onChange:a}):null,(0,I.jsxs)(X,{variant:`ghost`,size:`sm`,className:`oc-filterbar__reset`,onClick:f,disabled:!s,children:[(0,I.jsx)(Fm,{}),WVe()]})]})}var a7=`__all__`,o7={q:``,state:a7,instance:a7,version:a7},s7={connected:0,error:1,idle:2};function mit(e){return e.q.trim()!==``||e.state!==`__all__`||e.instance!==`__all__`||e.version!==`__all__`}function hit(e,t){let n=t.q.trim().toLowerCase();return e.filter(e=>!(n&&!`${e.targetLabel} ${e.gatewayHost}`.toLowerCase().includes(n)||t.state!==`__all__`&&e.state!==t.state||t.instance!==`__all__`&&(e.instanceName??``)!==t.instance||t.version!==`__all__`&&(e.gatewayVersion??``)!==t.version))}function c7(e,t){return e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function l7(e,t){return e===`version`?t.gatewayVersion===null:e===`lastOk`?t.lastOkAt===null:!1}function git(e,t,n){switch(e){case`state`:return(s7[t.state]??99)-(s7[n.state]??99);case`instance`:return c7(t.instanceLabel??t.instanceName??``,n.instanceLabel??n.instanceName??``);case`host`:return c7(t.gatewayHost,n.gatewayHost);case`version`:{let e=t.gatewayVersion,r=n.gatewayVersion;return V5(e,r)??c7(e,r)}case`lastOk`:return t.lastOkAt-n.lastOkAt;default:return c7(t.targetLabel,n.targetLabel)}}function _it(e,t){if(!t)return e;let n=t.dir===`asc`?1:-1;return[...e].sort((e,r)=>{let i=l7(t.key,e),a=l7(t.key,r);return i&&a?0:i?1:a?-1:n*git(t.key,e,r)})}function vit(e){let t=new Set;for(let n of e)t.add(n.state);return[...t].sort((e,t)=>(s7[e]??99)-(s7[t]??99))}function yit(e){let t=new Map;for(let n of e)n.instanceName!==null&&(t.has(n.instanceName)||t.set(n.instanceName,n.instanceLabel??n.instanceName));return[...t.entries()].map(([e,t])=>({name:e,label:t})).sort((e,t)=>c7(e.label,t.label))}function bit(e){let t=new Set;for(let n of e)n.gatewayVersion!==null&&t.add(n.gatewayVersion);return[...t].sort((e,t)=>V5(e,t)??c7(e,t))}function xit({connections:e,displayByInstance:t}){let[n,r]=(0,N.useState)(o7),[i,a]=(0,N.useState)(null),o=(0,N.useMemo)(()=>e.map((e,n)=>({_id:`${e.key}:${e.canonical}/${e.agentId}:${n}`,targetLabel:`${e.canonical}/${e.agentId}`,state:e.state,instanceName:e.instanceName??null,instanceLabel:e.instanceName?t.get(e.instanceName)??e.instanceName:null,gatewayHost:e.gatewayHost,gatewayVersion:e.gatewayVersion??null,okCount:e.okCount,errorCount:e.errorCount,attempts:e.attempts,lastOkAt:e.lastOkAt??null,lastErrorCode:e.lastErrorCode??null,lastErrorAt:e.lastErrorAt??null,lastDownstreamRejectCode:e.lastDownstreamRejectCode??null,lastDownstreamRejectAt:e.lastDownstreamRejectAt??null})),[e,t]),s=(0,N.useMemo)(()=>vit(o),[o]),c=(0,N.useMemo)(()=>yit(o),[o]),l=(0,N.useMemo)(()=>bit(o),[o]),u=(0,N.useMemo)(()=>_it(hit(o,n),i),[o,n,i]);function d(e){a(t=>t?.key===e?t.dir===`asc`?{key:e,dir:`desc`}:null:{key:e,dir:`asc`})}return e.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:IPe()}):(0,I.jsxs)(`div`,{className:`oc-conn`,children:[(0,I.jsxs)(i7,{q:n.q,onQChange:e=>r(t=>({...t,q:e})),searchPlaceholder:GPe(),onReset:()=>r(o7),canReset:mit(n),children:[(0,I.jsxs)(C3,{value:n.state,onValueChange:e=>r(t=>({...t,state:e})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:XPe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:a7,children:xQ()}),s.map(e=>(0,I.jsx)(Q,{value:e,children:Cit(e)},e))]})]}),(0,I.jsxs)(C3,{value:n.instance,onValueChange:e=>r(t=>({...t,instance:e})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:$Pe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:a7,children:xQ()}),c.map(e=>(0,I.jsx)(Q,{value:e.name,children:e.label},e.name))]})]}),(0,I.jsxs)(C3,{value:n.version,onValueChange:e=>r(t=>({...t,version:e})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:nFe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:a7,children:xQ()}),l.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})]}),u.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:aFe()}):(0,I.jsxs)(w5,{className:`oc-conn__table`,children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[(0,I.jsx)(u7,{label:cFe(),sortKey:`target`,sort:i,onSort:d}),(0,I.jsx)(u7,{label:dFe(),sortKey:`state`,sort:i,onSort:d}),(0,I.jsx)(u7,{label:mFe(),sortKey:`instance`,sort:i,onSort:d}),(0,I.jsx)(u7,{label:_Fe(),sortKey:`host`,sort:i,onSort:d}),(0,I.jsx)(u7,{label:bFe(),sortKey:`version`,sort:i,onSort:d}),(0,I.jsx)(O5,{children:CFe()}),(0,I.jsx)(u7,{label:EFe(),sortKey:`lastOk`,sort:i,onSort:d})]})}),(0,I.jsx)(E5,{children:u.map(e=>(0,I.jsx)(Sit,{r:e},e._id))})]})]})}function u7({label:e,sortKey:t,sort:n,onSort:r}){let i=n?.key===t,a=i?n.dir:null;return(0,I.jsx)(O5,{"aria-sort":i?a===`asc`?`ascending`:`descending`:`none`,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-conn__sort`,onClick:()=>r(t),children:[e,i?a===`asc`?(0,I.jsx)(pm,{size:13,"aria-hidden":!0}):(0,I.jsx)(dm,{size:13,"aria-hidden":!0}):(0,I.jsx)(mm,{size:13,"aria-hidden":!0,className:`oc-conn__sort-idle`})]})})}function Sit({r:e}){let t=oit(e)?L5(e.lastErrorCode):null,n=sit(e)?L5(e.lastDownstreamRejectCode):null;return(0,I.jsxs)(N.Fragment,{children:[(0,I.jsxs)(D5,{className:`oc-conn__row oc-conn__row--${e.state}`,children:[(0,I.jsx)(k5,{children:(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.targetLabel})}),(0,I.jsx)(k5,{children:(0,I.jsx)(wit,{state:e.state})}),(0,I.jsx)(k5,{children:e.instanceLabel?(0,I.jsx)(`span`,{className:`oc-bridge-target__instance`,children:e.instanceLabel}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,I.jsx)(k5,{children:(0,I.jsx)(`span`,{className:`oc-bridge-target__host`,children:e.gatewayHost})}),(0,I.jsx)(k5,{children:e.gatewayVersion?(0,I.jsx)(`span`,{className:`oc-bridge-target__version`,children:e.gatewayVersion}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}),(0,I.jsx)(k5,{children:(0,I.jsx)(`span`,{className:`oc-conn__stats`,children:zPe({ok:e.okCount,errors:e.errorCount,attempts:e.attempts})})}),(0,I.jsx)(k5,{children:e.lastOkAt?(0,I.jsx)(`span`,{className:`oc-traces__mono`,children:new Date(e.lastOkAt).toLocaleTimeString(`fr-FR`)}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})})]}),t||n?(0,I.jsx)(D5,{className:`oc-conn__detail-row`,children:(0,I.jsxs)(k5,{colSpan:7,className:`oc-conn__detail-cell`,children:[t?(0,I.jsxs)(`div`,{className:`oc-bridge-target__error`,children:[(0,I.jsx)(`strong`,{children:t.label}),` `,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastErrorCode}),e.lastErrorAt?` · ${new Date(e.lastErrorAt).toLocaleTimeString(`fr-FR`)}`:``,(0,I.jsx)(`p`,{className:`oc-bridge-card__hint`,children:t.hint})]}):null,n?(0,I.jsxs)(`div`,{className:`oc-bridge-target__downstream`,children:[HPe({label:n.label}),` `,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.lastDownstreamRejectCode}),e.lastDownstreamRejectAt?` · ${new Date(e.lastDownstreamRejectAt).toLocaleTimeString(`fr-FR`)}`:``]}):null]})}):null]})}function Cit(e){return e===`connected`?SQ():e===`error`?CQ():wQ()}function wit({state:e}){return e===`connected`?(0,I.jsx)($,{variant:`secondary`,children:SQ()}):e===`error`?(0,I.jsx)($,{variant:`destructive`,children:CQ()}):(0,I.jsx)($,{variant:`outline`,children:wQ()})}function Tit(){return P(V.bridgeHealth.getBridgeHealth,{})}function Eit(){let e=Tit(),t=P(V.compat.getBridgeCompat,{}),n=P(V.me.getMe,{host:xO})?.role===`admin`,r=P(V.admin.listInstances,n?{}:`skip`),i=ss(),a=()=>void i({to:`/settings/anomalies`,search:{status:`open`}}),o=lit(e?e.targets:[],t?t.targets:[],r??[]),s=t?.compat??null,c=t===void 0?`loading`:t===null?`nodata`:`ready`,l=s!==null&&iit(s,`hermes`)&&!o.some(e=>e.key===`hermes`);return(0,I.jsxs)(`div`,{className:`oc-bridge`,children:[(0,I.jsx)(Dit,{health:e,compat:t,onSeeAnomalies:a}),(0,I.jsx)(`p`,{className:`oc-admin__hint oc-bridge__caption`,children:sPe()}),o.map(e=>(0,I.jsx)(Oit,{providerKey:e.key,connections:e.connections,instances:e.instances,manifest:s,compatStatus:c,compatReachable:t?.reachable??!0},e.key)),l?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:J0e()}):null]})}function Dit({health:e,compat:t,onSeeAnomalies:n}){let r=t&&t!==null?(0,I.jsxs)(`span`,{className:`oc-bridge-card__ver`,children:[(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:W5(t.bridgeVersion)}),` · `,u0e(),` `,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:t.protocolVersion===null?n$():String(t.protocolVersion)})]}):null;if(e===void 0)return(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:bQ()});if(e===null)return(0,I.jsx)(`div`,{className:`oc-bridge-card oc-bridge-card--idle`,children:fPe()});let i=K5(e.targets),a=!e.reachable,o=ait(e),s=o?`ok`:`error`,c=new Date(e.checkedAt).toLocaleString(`fr-FR`),l=e.startedAt==null?null:new Date(e.startedAt).toLocaleString(`fr-FR`);return(0,I.jsxs)(`div`,{className:`oc-bridge-card oc-bridge-card--${s}`,children:[(0,I.jsx)(`div`,{className:`oc-bridge-card__icon`,"aria-hidden":!0,children:o?(0,I.jsx)(gm,{size:22}):a?(0,I.jsx)(zee,{size:22}):(0,I.jsx)(Hm,{size:22})}),(0,I.jsxs)(`div`,{className:`oc-bridge-card__body`,children:[(0,I.jsx)(`div`,{className:`oc-bridge-card__title`,children:o?hPe():a?vPe():xPe({count:i.length})}),(0,I.jsxs)(`div`,{className:`oc-bridge-card__meta`,children:[(0,I.jsxs)(`span`,{children:[(0,I.jsx)(Fee,{size:12,"aria-hidden":!0}),` `,wPe({time:c})]}),l?(0,I.jsx)(`span`,{children:DPe({time:l})}):null,r]}),a?(0,I.jsx)(`p`,{className:`oc-bridge-card__hint`,children:L5(e.lastError===`not_configured`?`NOT_CONFIGURED`:`BRIDGE_UNREACHABLE`).hint}):null]}),(0,I.jsx)(`button`,{type:`button`,className:`oc-bridgebar__drill`,onClick:n,children:APe()})]})}function Oit({providerKey:e,connections:t,instances:n,manifest:r,compatStatus:i,compatReachable:a}){let o=r?H5(r,e):null,s=new Map;for(let e of n)s.set(e.name,e.displayName??e.name);let c=[],l=new Set;for(let n of t){if(!n.instanceName||l.has(n.instanceName))continue;l.add(n.instanceName);let t=n.gatewayVersion??null;c.push({instanceName:n.instanceName,displayName:s.get(n.instanceName)??n.instanceName,version:t,state:rit(t,e,r)})}let u=c.map(e=>e.state),d=u.includes(`beyond`)?`beyond`:u.length>0&&u.every(e=>e===`supported`)?`supported`:null,[f,p]=(0,N.useState)(!1),[m,h]=(0,N.useState)(null),g=m===null?null:n.find(e=>e.name===m)??null,_=new Set(n.map(e=>e.name));return(0,I.jsxs)(`section`,{className:`oc-bridge-provider`,children:[(0,I.jsxs)(`header`,{className:`oc-bridge-provider__head`,children:[(0,I.jsx)(Lm,{size:15,"aria-hidden":!0,className:`oc-bridge-provider__icon`}),(0,I.jsx)(`span`,{className:`oc-bridge-provider__name`,children:uit(e)}),d?(0,I.jsx)($,{variant:d===`beyond`?`destructive`:`secondary`,children:U5(d)}):null]}),(0,I.jsx)(`h4`,{className:`oc-bridge-provider__sub`,children:i0e()}),(0,I.jsx)(kit,{support:o,compatStatus:i,compatReachable:a,manifest:r,instanceRows:c,canConfigure:e=>_.has(e),onConfigure:h}),(0,I.jsxs)(`button`,{type:`button`,className:`oc-bridge-provider__sub oc-bridge-provider__sub--toggle`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,I.jsx)(dm,{size:13,"aria-hidden":!0}):(0,I.jsx)(fm,{size:13,"aria-hidden":!0}),NPe({count:t.length})]}),f?(0,I.jsx)(xit,{connections:t,displayByInstance:s}):null,g?(0,I.jsx)(d7,{instance:g,onClose:()=>h(null)},g._id):null]})}function kit({support:e,compatStatus:t,compatReachable:n,manifest:r,instanceRows:i,canConfigure:a,onConfigure:o}){return t===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:bQ()}):t===`nodata`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:s0e()}):(0,I.jsxs)(`div`,{className:`oc-compat`,children:[n?null:(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:h0e()}),r===null?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:v0e()}):(0,I.jsxs)(`div`,{className:`oc-compat__support`,children:[(0,I.jsx)(`span`,{className:`oc-compat__label`,children:x0e()}),e&&e.range!==null?(0,I.jsx)(`span`,{children:w0e({min:e.range.min,max:e.range.maxValidated})}):(0,I.jsx)(`span`,{children:n$()}),e?(0,I.jsx)(Mit,{versions:e.validatedVersions}):null]}),i.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:I0e()}):(0,I.jsx)(`div`,{className:`oc-compat__targets`,children:i.map(e=>(0,I.jsxs)(`div`,{className:`oc-compat__target`,children:[(0,I.jsx)(`span`,{className:`oc-compat__instance`,children:e.displayName}),(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:W5(e.version)}),(0,I.jsx)($,{variant:e.state===`supported`?`secondary`:e.state===`beyond`?`destructive`:`outline`,children:U5(e.state)}),a(e.instanceName)?(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon`,className:`oc-compat__target-menu`,"aria-label":yQ(),children:(0,I.jsx)(ym,{size:16,"aria-hidden":!0})})}),(0,I.jsx)(J$,{align:`end`,children:(0,I.jsx)(Y$,{onSelect:()=>o(e.instanceName),children:yQ()})})]}):null]},e.instanceName))})]})}function d7({instance:e,onClose:t}){return(0,I.jsx)(h1,{open:!0,onOpenChange:e=>!e&&t(),children:(0,I.jsxs)(g1,{className:`oc-bridge-config-dialog`,onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:MMe({instance:e.displayName??e.name})}),(0,I.jsx)(b1,{children:LMe()})]}),(0,I.jsx)(jit,{instance:e,onClose:t})]})})}function Ait({text:e}){return(0,I.jsx)(M5,{delayDuration:150,children:(0,I.jsxs)(N5,{children:[(0,I.jsx)(P5,{asChild:!0,children:(0,I.jsx)(`button`,{type:`button`,className:`oc-field__help`,"aria-label":e,onClick:e=>e.preventDefault(),children:(0,I.jsx)(See,{"aria-hidden":!0})})}),(0,I.jsx)(F5,{className:`max-w-xs text-pretty`,children:e})]})})}function f7({label:e,help:t}){return(0,I.jsxs)(`span`,{className:`oc-field__label`,children:[e,(0,I.jsx)(Ait,{text:t})]})}function p7({label:e,result:t}){return t?t.checked?(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row `+(t.ok?`oc-bridge-config__check-row--ok`:`oc-bridge-config__check-row--err`),children:[t.ok?(0,I.jsx)(gm,{"aria-hidden":!0}):(0,I.jsx)(Hm,{"aria-hidden":!0}),(0,I.jsxs)(`span`,{children:[e,` — `,t.ok?YNe():t.detail]})]}):(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--skip`,children:[e,` — `,QNe()]}):null}function jit({instance:e,onClose:t}){let n=F(V.admin.upsertInstanceConfig),r=$n(V.bridge.validateMediaPaths),i=D1(),[a,o]=(0,N.useState)(()=>eit(e.config??{})),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null),p=a.inboundMediaMode===`shared-fs`,m=a.mediaMode===`shared-fs`,h=p||m;async function g(){u(!0),f(null);try{f(await r({instanceName:e.name,inboundMediaMode:a.inboundMediaMode,mediaMode:a.mediaMode}))}catch(e){i.error(LNe(),e)}finally{u(!1)}}async function _(){c(!0);try{let r=e.config??{};await n({instanceId:e._id,config:tit(a,r)}),t()}catch(e){i.error(iNe(),e)}finally{c(!1)}}return(0,I.jsx)(`div`,{className:`oc-bridge-config`,children:(0,I.jsxs)(`div`,{className:`oc-bridge-config__form`,children:[(0,I.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(f7,{label:UMe(),help:sNe()}),(0,I.jsxs)(C3,{value:a.mediaMode,onValueChange:e=>o({...a,mediaMode:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-full`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:Qrt.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))})]})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(f7,{label:KMe(),help:uNe()}),(0,I.jsxs)(C3,{value:a.inboundMediaMode,onValueChange:e=>o({...a,inboundMediaMode:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-full`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:$rt.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))})]})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(f7,{label:YMe(),help:pNe()}),(0,I.jsx)(o1,{type:`number`,min:1,max:4096,className:`w-full`,value:a.mediaMaxMb,onChange:e=>o({...a,mediaMaxMb:Math.trunc(Number(e.target.value)||0)})})]})]}),h&&(0,I.jsxs)(`div`,{className:`oc-bridge-config__grid`,children:[p&&(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(f7,{label:yNe(),help:SNe()}),(0,I.jsx)(o1,{className:`w-full`,spellCheck:!1,value:a.inboundAgentMount,onChange:e=>o({...a,inboundAgentMount:e.target.value})})]}),m&&(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(f7,{label:TNe(),help:ONe()}),(0,I.jsx)(o1,{className:`w-full`,spellCheck:!1,value:a.outboundAgentMount,onChange:e=>o({...a,outboundAgentMount:e.target.value})})]})]}),(0,I.jsxs)(`label`,{className:`oc-field--row`,children:[(0,I.jsx)(A1,{checked:a.rehydration,onCheckedChange:e=>o({...a,rehydration:e===!0})}),(0,I.jsx)(f7,{label:QMe(),help:gNe()})]}),h&&d!==null&&(0,I.jsx)(`div`,{className:`oc-bridge-config__check`,children:d.reachable?!d.inbound&&!d.outbound?(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,I.jsx)(Hm,{"aria-hidden":!0}),iPe({reason:d.reason??`?`})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(p7,{label:UNe(),result:d.inbound}),(0,I.jsx)(p7,{label:KNe(),result:d.outbound}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:BNe()})]}):(0,I.jsxs)(`p`,{className:`oc-bridge-config__check-row oc-bridge-config__check-row--err`,children:[(0,I.jsx)(Hm,{"aria-hidden":!0}),tPe()]})}),(0,I.jsxs)(`div`,{className:`oc-bridge-config__actions`,children:[h&&(0,I.jsxs)(X,{variant:`outline`,size:`sm`,onClick:()=>void g(),disabled:l,children:[l?(0,I.jsx)(Cm,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,l?PNe():jNe()]}),(0,I.jsx)(X,{size:`sm`,onClick:()=>void _(),disabled:s,children:tNe()})]})]})})}function Mit({versions:e}){if(e.length===0)return null;let t=[...e].reverse();return(0,I.jsxs)($$,{children:[(0,I.jsx)(e1,{asChild:!0,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-compat__versions-btn`,children:[e.length===1?D0e():A0e({count:e.length}),(0,I.jsx)(dm,{size:13,"aria-hidden":!0})]})}),(0,I.jsxs)(t1,{className:`oc-compat__versions-pop`,align:`start`,children:[(0,I.jsx)(`p`,{className:`oc-compat__versions-title`,children:N0e()}),(0,I.jsx)(`div`,{className:`oc-compat__versions-list`,children:t.map(e=>(0,I.jsx)($,{variant:`secondary`,children:e},e))})]})]})}var Nit=[{value:`eq`,label:`=`},{value:`neq`,label:`≠`},{value:`contains`,label:Aze()},{value:`gt`,label:`>`},{value:`gte`,label:`≥`},{value:`lt`,label:`<`},{value:`lte`,label:`≤`}],m7=1;function Pit(){return{id:m7++,field:``,op:`eq`,value:``}}function Fit(e){return e.map(e=>({id:m7++,field:e.field,op:e.op,value:String(e.value)}))}function h7({fields:e,seed:t,onChange:n}){let r=(0,N.useRef)(t),i=!!(r.current&&r.current.length>0),[a,o]=(0,N.useState)(i),[s,c]=(0,N.useState)(()=>i?Fit(r.current):[]);function l(e){n(e.filter(e=>e.field!==``&&e.value!==``).map(e=>({field:e.field,op:e.op,value:fit(e.value)})))}function u(e,t){let n=s.map(n=>n.id===e?{...n,...t}:n);c(n),l(n)}function d(){c(e=>[...e,Pit()])}function f(e){let t=s.filter(t=>t.id!==e);c(t),l(t)}let p=s.filter(e=>e.field!==``&&e.value!==``).length;return(0,I.jsxs)(`div`,{className:`oc-advfilter`,children:[(0,I.jsxs)(`button`,{type:`button`,className:`oc-advfilter__toggle`,"aria-expanded":a,onClick:()=>o(e=>!e),children:[(0,I.jsx)(dm,{className:`oc-advfilter__chevron`+(a?` is-open`:``),"aria-hidden":!0}),Nze(),p>0?(0,I.jsx)(`span`,{className:`oc-advfilter__count`,children:p}):null]}),a?(0,I.jsxs)(`div`,{className:`oc-advfilter__body`,children:[s.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Ize()}):(0,I.jsx)(`ul`,{className:`oc-advfilter__rows`,children:s.map(t=>(0,I.jsxs)(`li`,{className:`oc-advfilter__row`,children:[(0,I.jsxs)(C3,{value:t.field||void 0,onValueChange:e=>u(t.id,{field:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:zze()})}),(0,I.jsx)(E3,{children:e.map(e=>(0,I.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),(0,I.jsxs)(C3,{value:t.op,onValueChange:e=>u(t.id,{op:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-28`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:Nit.map(e=>(0,I.jsx)(Q,{value:e.value,children:e.label},e.value))})]}),(0,I.jsx)(o1,{className:`oc-advfilter__value`,value:t.value,onChange:e=>u(t.id,{value:e.target.value}),placeholder:Hze()}),(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":Gze(),onClick:()=>f(t.id),children:(0,I.jsx)(Km,{})})]},t.id))}),(0,I.jsxs)(X,{variant:`outline`,size:`sm`,className:`oc-advfilter__add`,onClick:d,children:[(0,I.jsx)(Pm,{}),Jze()]})]}):null]})}var Iit=[`eq`,`neq`,`contains`,`gt`,`gte`,`lt`,`lte`],g7=[50,100,200,500],_7=`now-30d`,Lit=`now-24h`;function v7(e,t,n=_7,r=`now`){let i=e??n,a=t??r,o=Number(i),s=Number(a);return i!==``&&a!==``&&Number.isFinite(o)&&Number.isFinite(s)?{kind:`absolute`,from:o,to:s}:{kind:`relative`,from:i,to:a}}function y7(e){return e.kind===`absolute`?{from:String(e.from),to:String(e.to)}:{from:e.from,to:e.to}}function b7(e){if(e.length!==0)return JSON.stringify(e)}function x7(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e!=`object`||!e)continue;let t=e,r=t.field,i=t.op,a=t.value;typeof r!=`string`||r===``||typeof i!=`string`||!Iit.includes(i)||typeof a!=`string`&&typeof a!=`number`&&typeof a!=`boolean`||n.push({field:r,op:i,value:a})}return n}var S7=sp().optional(),C7=sp().optional(),w7=sp().optional(),T7=sp().optional().catch(void 0),Rit=Rp({q:S7,kind:sp().default(`all`).catch(`all`),limit:fee().pipe(Bp([Kp(g7[0]),Kp(g7[1]),Kp(g7[2]),Kp(g7[3])])).catch(100),statusClass:Wp([`2xx`,`4xx`,`5xx`]).optional().catch(void 0),principalType:Wp([`user`,`service`,`system`]).optional().catch(void 0),direction:Wp([`inbound`,`outbound`,`internal`]).optional().catch(void 0),roleKey:T7,from:C7,to:C7,adv:w7}),zit=Rp({q:S7,action:T7,impersonated:Wp([`yes`,`no`]).optional().catch(void 0),resource:T7,from:C7,to:C7,adv:w7}),Bit=Rp({q:S7,status:Wp([`open`,`acknowledged`,`resolved`,`all`]).default(`open`).catch(`open`),severity:Wp([`info`,`warn`,`critical`]).optional().catch(void 0),kind:T7,from:C7,to:C7}),Vit=Rp({from:C7,to:C7}),Hit=Rp({q:S7,status:Wp([`active`,`disabled`]).optional().catch(void 0)}),Uit=Rp({q:S7,role:T7});Rp({q:S7,mode:Wp([`per-user`,`shared`]).optional().catch(void 0)});var Wit={kind:`relative`,from:_7,to:`now`},E7=`__all__`,D7=[`users`,`groups`,`instances`,`bridge`,`serviceAccounts`,`roles`,`access`,`traces`,`kpi`,`anomalies`,`files`,`agentFiles`,`preferences`,`integrations`,`theme`,`chatDefaults`,`audit`,`feedbacks`],O7=[`groups`,`access`,`roles`,`integrations`,`instances`,`bridge`,`theme`,`feedbacks`,`files`,`agentFiles`,`preferences`,`chatDefaults`],k7={groups:`Groupes`,access:`Accès`,serviceAccounts:`Comptes de service`,roles:`Rôles`,traces:`Traces`,kpi:`KPI`,anomalies:`Anomalies`,integrations:`Intégrations`,feedbacks:`Feedbacks`,bridge:`Bridge`,files:`Fichiers`,agentFiles:`Fichiers d'agent`,theme:`Apparence`,preferences:`Préférences`},A7={users:`admin.manage`,groups:`groups.manage`,instances:`admin.manage`,bridge:`bridge.read`,serviceAccounts:`admin.manage`,roles:`admin.manage`,access:`admin.manage`,traces:`traces.read`,kpi:`kpi.read`,anomalies:`anomalies.read`,files:`chats.read`,agentFiles:`agents.files.read`,preferences:`chats.read`,integrations:`admin.manage`,theme:`chats.read`,chatDefaults:`admin.manage`,audit:`admin.manage`,feedbacks:`admin.manage`},j7=[`traces`,`kpi`,`anomalies`,`bridge`,`agentFiles`,`groups`];function M7(e){let t=new Set(e);return D7.filter(e=>t.has(A7[e]))}function N7(e){return`/settings/${e}`}function P7(e){let t=e.split(`/`)[2];return D7.includes(t)?t:void 0}var Git={uiprefs:`preferences`};function Kit({granted:e,onToggle:t}){let n=new Set(e),r=j7.filter(e=>n.has(A7[e])).length;return(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`outline`,size:`sm`,className:`h-8 w-36 justify-start font-normal`,children:r===0?Vme():Wme({count:r})})}),(0,I.jsxs)(J$,{align:`start`,className:`w-52`,children:[(0,I.jsx)(X$,{children:qme()}),j7.map(e=>{let r=A7[e];return(0,I.jsxs)(Y$,{className:`gap-2`,onSelect:e=>{e.preventDefault(),t(r)},children:[(0,I.jsx)(A1,{checked:n.has(r),"aria-hidden":!0,tabIndex:-1,className:`pointer-events-none`}),(0,I.jsx)(`span`,{children:k7[e]??e})]},e)})]})]})}function qit(){let e=os({from:`/settings/users`}),t=ss({from:`/settings/users`}),n=e.q??``,r=e.role??E7,i=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),a=e=>void t({search:t=>({...t,role:e===E7?void 0:e})}),o=P(V.admin.listUsers,{filter:{q:n||void 0,role:r===E7?void 0:r},withAgents:!0}),s=P(V.me.getMe,{host:xO}),c=F(V.admin.setRole),l=F(V.admin.setUserPermissions),u=F(V.admin.startImpersonation),d=F(V.admin.deleteUser),f=F(V.admin.setUserName),p=C1(),m=w1(),h=D1(),[g,_]=(0,N.useState)(null),v=(0,N.useMemo)(()=>{let e=new Set([`pending`,`user`,`admin`]);for(let t of o??[])e.add(t.role);return[...e]},[o]),y=n!==``||r!==E7;function b(){t({search:{},replace:!0})}async function x(e){try{await c(e)}catch(e){h.error(Xme(),e)}}async function S(e){try{await l(e)}catch(e){h.error($me(),e)}}async function C(e){let t=e.email||e.name||e.canonical||e.userId.slice(0,8);if(await p({title:bhe(),description:Che({user:t}),confirmWord:Ehe(),confirmLabel:khe(),destructive:!0}))try{await d({profileId:e._id}),h.success(Fhe({user:t}))}catch(e){h.error(Mhe(),e)}}async function w(e){let t=e.email||e.name||e.userId.slice(0,8),n=await m({title:Vhe(),label:Whe({user:t}),placeholder:qhe(),defaultValue:e.name??``,confirmLabel:QZ()});if(n!==null)try{await f({profileId:e._id,name:n}),h.success(Xhe())}catch(e){h.error($he(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(i7,{q:n,onQChange:i,searchPlaceholder:nhe(),onReset:b,canReset:y,children:(0,I.jsxs)(C3,{value:r,onValueChange:a,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:E7,children:ahe()}),v.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})}),(0,I.jsx)(A5,{title:che(),rows:o,emptyHint:dhe(),rowActions:e=>{let t=[{label:XZ(),onSelect:()=>_({profileId:e._id,label:e.email||e.name||e.canonical||e.userId.slice(0,8)})},{label:Rhe(),onSelect:()=>void w(e)}];return e.userId!==s?.userId&&t.push({label:mhe(),onSelect:()=>void u({profileId:e._id})},{label:_he(),variant:`destructive`,onSelect:()=>void C(e)}),t},columns:[{header:nge(),cell:e=>{let t=e.email||e.name||e.canonical||e.userId.slice(0,8),n=e.email&&e.name&&e.name!==e.email?e.name:null;return(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{children:t}),n?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:n}):null]})},sort:e=>e.email||e.name||e.canonical||e.userId},{header:age(),sort:e=>e.role===`admin`?2:+(e.role===`user`),cell:e=>(0,I.jsxs)(C3,{value:e.role,onValueChange:t=>void x({profileId:e._id,role:t}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-28`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`pending`,children:`pending`}),(0,I.jsx)(Q,{value:`user`,children:`user`}),(0,I.jsx)(Q,{value:`admin`,children:`admin`})]})]})},{header:cge(),sort:e=>e.role===`admin`?9999:e.extraPermissions?.length??0,cell:e=>e.role===`admin`?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:dge()}):(0,I.jsx)(Kit,{granted:e.extraPermissions??[],onToggle:t=>{let n=new Set(e.extraPermissions??[]);n.has(t)?n.delete(t):n.add(t),S({profileId:e._id,permissions:[...n]})}})},{header:YZ(),cell:e=>(0,I.jsx)(j5,{icon:(0,I.jsx)(Lm,{size:12,"aria-hidden":!0}),total:e.agentCount??0,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount??0}]}),(0,I.jsx)(Jrt,{profileId:g?.profileId??null,userLabel:g?.label??``,open:g!==null,onOpenChange:e=>{e||_(null)}})]})}var F7={name:``,gatewayUrl:``,bridgeUrl:``,displayName:``,kind:`openclaw`,gatewayVersion:``,gatewayHttpUrl:``},Jit={openclaw:[`token`,`deviceIdentity`],hermes:[`apiKey`]};function Yit(e){return{name:e.name,gatewayUrl:e.gatewayUrl,bridgeUrl:e.bridgeUrl??``,displayName:e.displayName??``,kind:e.kind??`openclaw`,gatewayVersion:e.gatewayVersion??``,gatewayHttpUrl:e.gatewayHttpUrl??``}}function Xit(){let e=P(V.admin.listInstances,{}),t=P(V.agents.listAllInstanceAgents,{}),n=F(V.admin.upsertInstance),r=F(V.admin.deleteInstance),i=D1(),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(F7),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(null);async function _(){try{await n({instanceId:h??void 0,name:s.name,gatewayUrl:s.gatewayUrl,bridgeUrl:s.bridgeUrl||void 0,displayName:s.displayName||void 0,kind:s.kind,gatewayVersion:s.gatewayVersion||void 0,gatewayHttpUrl:s.gatewayHttpUrl||void 0}),c(F7),g(null),o(!1)}catch(e){i.error(vge(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[xge(),(0,I.jsx)(`strong`,{children:wge()}),Dge()]}),(0,I.jsx)(A5,{title:Age(),rows:e,addLabel:Nge(),onAdd:()=>{g(null),c(F7),o(!0)},emptyHint:Ige(),columns:[{header:zge(),cell:e=>e.name,sort:e=>e.name},{header:Hge(),cell:e=>(0,I.jsx)($,{variant:`outline`,children:e.kind??`openclaw`}),sort:e=>e.kind??`openclaw`},{header:Gge(),cell:e=>e.gatewayUrl,sort:e=>e.gatewayUrl},{header:Jge(),cell:e=>e.displayName??`—`,sort:e=>e.displayName??null},{header:YZ(),cell:e=>{let n=(t?.[e.name]??[]).filter(e=>e.presentInLastOk!==!1&&e.enabled);if(n.length===0)return(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let r=t=>e.defaultAgentId===t;return(0,I.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[...n].sort((e,t)=>Number(r(t.agentId))-Number(r(e.agentId))).map(e=>(0,I.jsxs)($,{variant:r(e.agentId)?`default`:`outline`,title:r(e.agentId)?oQ():void 0,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]},e.agentId))})}}],rowActions:e=>[{label:a_e(),onSelect:()=>{g(e._id),c(Yit(e)),o(!0)}},{label:XZ(),onSelect:()=>u(e.name)},{label:Y_e(),onSelect:()=>m(e)},{label:Zge(),onSelect:()=>f(e)},{label:ZZ(),variant:`destructive`,onSelect:()=>void r({instanceId:e._id})}],bulkActions:[{label:ZZ(),variant:`destructive`,onSelect:e=>e.forEach(e=>void r({instanceId:e}))}]}),(0,I.jsx)(Q8,{open:a,onOpenChange:o,title:h?c_e():n_e(),description:m_e(),canSubmit:!!(s.name&&s.gatewayUrl),onSubmit:_,submitLabel:QZ(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(R7,{label:y_e(),children:[(0,I.jsx)(o1,{value:s.name,disabled:h!==null,onChange:e=>c({...s,name:e.target.value})}),h?(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:d_e()}):null]}),(0,I.jsx)(R7,{label:S_e(),children:(0,I.jsxs)(C3,{value:s.kind,onValueChange:e=>c({...s,kind:e}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`openclaw`,children:`OpenClaw`}),(0,I.jsx)(Q,{value:`hermes`,children:`Hermes`})]})]})}),(0,I.jsx)(R7,{label:T_e(),children:(0,I.jsx)(o1,{value:s.gatewayUrl,onChange:e=>c({...s,gatewayUrl:e.target.value})})}),(0,I.jsx)(R7,{label:O_e(),children:(0,I.jsx)(o1,{value:s.bridgeUrl,placeholder:j_e(),onChange:e=>c({...s,bridgeUrl:e.target.value})})}),(0,I.jsx)(R7,{label:P_e(),children:(0,I.jsx)(o1,{value:s.displayName,onChange:e=>c({...s,displayName:e.target.value})})}),(0,I.jsx)(R7,{label:L_e(),children:(0,I.jsx)(o1,{value:s.gatewayVersion,placeholder:B_e(),onChange:e=>c({...s,gatewayVersion:e.target.value})})}),(0,I.jsx)(R7,{label:U_e(),children:(0,I.jsx)(o1,{value:s.gatewayHttpUrl,placeholder:K_e(),onChange:e=>c({...s,gatewayHttpUrl:e.target.value})})})]})}),(0,I.jsx)(iat,{instanceName:l,open:l!==null,onOpenChange:e=>{e||u(null)}}),d?(0,I.jsx)(d7,{instance:d,onClose:()=>f(null)},d._id):null,p?(0,I.jsx)(Zit,{instance:p,onClose:()=>m(null)},p._id):null]})}function Zit({instance:e,onClose:t}){let n=P(V.instanceSecrets.listInstanceSecretStatus,{}),r=Jit[e.kind??`openclaw`],i=(0,N.useMemo)(()=>{let t={};for(let r of n??[])r.instanceId===e._id&&(t[r.field]=r.updatedAt);return t},[n,e._id]);return(0,I.jsx)(h1,{open:!0,onOpenChange:e=>!e&&t(),children:(0,I.jsxs)(g1,{onOpenAutoFocus:e=>e.preventDefault(),children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:Q_e({instance:e.displayName??e.name})}),(0,I.jsx)(b1,{children:tve()})]}),(0,I.jsx)(`div`,{className:`oc-form`,children:r.map(t=>(0,I.jsx)(eat,{instanceId:e._id,field:t,updatedAt:i[t]??null},t))}),(0,I.jsx)(`div`,{className:`oc-bridgesecret`,children:(0,I.jsx)($it,{instance:e})}),(0,I.jsx)(Qit,{instance:e})]})})}function Qit({instance:e}){let t=$n(V.instanceSync.forceInstanceSync),n=D1(),[r,i]=(0,N.useState)(!1);async function a(){if(!r){i(!0);try{switch((await t({instanceId:e._id})).status){case`synced`:n.success(rye());break;case`no_agents`:n.success(lye());break;case`no_bridge_url`:n.error(fye());break;case`deploy_misconfigured`:n.error(hye());break;case`unauthorized`:n.error(xye());break;case`not_served`:n.error(wye());break;default:n.error(vye());break}}catch(e){n.error(oye(),e)}finally{i(!1)}}}return(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Dye()}),(0,I.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,I.jsx)(X,{size:`sm`,variant:`outline`,onClick:()=>void a(),disabled:r,children:r?eye():Zve()})})]})}function $it({instance:e}){let t=P(V.bridgeAuth.listBridgeAuthStatus,{}),n=$n(V.bridgeAuth.mintBridgeSecret),r=F(V.bridgeAuth.revokeBridgeSecret),i=D1(),[a,o]=(0,N.useState)(!1),[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(!1),d=(t??[]).find(t=>t.instanceId===e._id),f=d!==void 0;async function p(){if(!a){o(!0);try{c((await n({instanceId:e._id})).plaintext),u(!1)}catch(e){i.error(rQ(),e)}finally{o(!1)}}}async function m(){if(!a){o(!0);try{await r({instanceId:e._id}),c(null),i.success(Gye())}catch(e){i.error(rQ(),e)}finally{o(!1)}}}async function h(){if(s)try{await navigator.clipboard.writeText(s),u(!0)}catch{}}return(0,I.jsxs)(R7,{label:Aye(),children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Nye()}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)($,{variant:f?`outline`:`secondary`,children:f?`${$Z()} · ${d.prefix}…${d.lastFour}`:eQ()}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(X,{size:`sm`,onClick:()=>void p(),disabled:a,children:f?zye():Iye()}),f?(0,I.jsx)(X,{size:`sm`,variant:`destructive`,onClick:()=>void m(),disabled:a,children:Hye()}):null]})]}),s?(0,I.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,I.jsx)(`p`,{className:`oc-sa__minted-warning`,children:Xye()}),(0,I.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,I.jsx)(`code`,{className:`oc-sa__minted-plain`,children:s}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void h(),children:l?YV():QV()})]}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>{c(null),u(!1)},children:iQ()})]}):null]})}function eat({instanceId:e,field:t,updatedAt:n}){let r=$n(V.instanceSecrets.setInstanceSecret),i=F(V.instanceSecrets.clearInstanceSecret),a=$n(V.deviceIdentity.generateDeviceIdentity),o=D1(),[s,c]=(0,N.useState)(``),[l,u]=(0,N.useState)(!1),[d,f]=(0,N.useState)(null),[p,m]=(0,N.useState)(!1),h=n!==null,g=t===`deviceIdentity`,_=t===`token`?ive():t===`deviceIdentity`?sve():uve();async function v(){if(!(!s.trim()||l)){u(!0);try{await r({instanceId:e,field:t,plaintext:s}),c(``),f(null),m(!1),o.success(kve())}catch(e){o.error(tQ(),e)}finally{u(!1)}}}async function y(){if(!l){u(!0);try{await i({instanceId:e,field:t}),f(null),m(!1),o.success(Pve())}catch(e){o.error(tQ(),e)}finally{u(!1)}}}async function b(){if(!l){u(!0);try{f(await a({instanceId:e})),m(!1),o.success(nQ())}catch(e){o.error(Jve(),e)}finally{u(!1)}}}let x=d?`openclaw devices approve ${d.id}`:``;async function S(){if(x)try{await navigator.clipboard.writeText(x),m(!0)}catch{}}return(0,I.jsxs)(R7,{label:_,children:[g?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Bve()}):null,(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)($,{variant:h?`outline`:`secondary`,children:h?$Z():eQ()}),(0,I.jsx)(o1,{type:`password`,autoComplete:`off`,className:`flex-1 min-w-32`,value:s,placeholder:h?bve():_ve(),onChange:e=>c(e.target.value)}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(X,{size:`sm`,onClick:()=>void v(),disabled:l||s.trim().length===0,children:Cve()}),g?(0,I.jsx)(X,{size:`sm`,variant:`outline`,onClick:()=>void b(),disabled:l,children:Lve()}):null,h?(0,I.jsx)(X,{size:`sm`,variant:`destructive`,onClick:()=>void y(),disabled:l,children:Eve()}):null]})]}),d?(0,I.jsxs)(`div`,{className:`oc-bridgesecret__reveal`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:nQ()}),(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:Gve()}),(0,I.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,I.jsx)(`code`,{className:`oc-sa__minted-plain`,children:x}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void S(),children:p?YV():QV()})]}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,onClick:()=>{f(null),m(!1)},children:iQ()})]}):null]})}var tat={conversational:xbe,documentary:Dbe},nat={conversational:wbe,documentary:Abe},I7=e=>(tat[e]??(()=>e))(),L7=e=>(nat[e]??(()=>``))();function rat({agentId:e,types:t,onToggle:n}){return(0,I.jsxs)(`div`,{className:`oc-agentcard__types`,children:[(0,I.jsx)(`span`,{className:`oc-agentcard__types-label`,children:lbe()}),t.map(e=>(0,I.jsx)($,{variant:`secondary`,className:`oc-agenttype__chip`,title:L7(e),children:I7(e)},e)),(0,I.jsxs)($$,{children:[(0,I.jsx)(e1,{asChild:!0,children:(0,I.jsx)(X,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,children:fbe()})}),(0,I.jsxs)(t1,{align:`start`,className:`oc-agenttypes-pop`,children:[(0,I.jsx)(`p`,{className:`oc-agenttypes-pop__title`,children:hbe()}),(0,I.jsx)(`p`,{className:`oc-agenttypes-pop__hint`,children:vbe()}),(0,I.jsx)(`div`,{className:`oc-agenttypes-pop__list`,children:C5.map(r=>{let i=`agtype-${e}-${r}`;return(0,I.jsxs)(`div`,{className:`oc-agenttypes-pop__item`,children:[(0,I.jsx)(A1,{id:i,checked:t.includes(r),onCheckedChange:()=>n(r)}),(0,I.jsxs)(`label`,{htmlFor:i,className:`oc-agenttypes-pop__text`,children:[(0,I.jsx)(`span`,{className:`oc-agenttypes-pop__name`,children:I7(r)}),(0,I.jsx)(`span`,{className:`oc-agenttypes-pop__desc`,children:L7(r)})]})]},r)})})]})]})]})}function iat({instanceName:e,open:t,onOpenChange:n}){let r=P(V.agents.listAgentsForInstance,t&&e?{instanceName:e}:`skip`),i=F(V.agents.setAgentEnabled).withOptimisticUpdate((e,{instanceName:t,agentId:n,enabled:r})=>{let i=e.getQuery(V.agents.listAgentsForInstance,{instanceName:t});i&&e.setQuery(V.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,enabled:r}:e)})}),a=F(V.agents.setInstanceDefaultAgent).withOptimisticUpdate((e,{instanceName:t,agentId:n})=>{let r=e.getQuery(V.agents.listAgentsForInstance,{instanceName:t});r&&e.setQuery(V.agents.listAgentsForInstance,{instanceName:t},{...r,defaultAgentId:n})}),o=F(V.agents.setAgentTypes).withOptimisticUpdate((e,{instanceName:t,agentId:n,types:r})=>{let i=e.getQuery(V.agents.listAgentsForInstance,{instanceName:t});if(!i)return;let a=qrt(r);e.setQuery(V.agents.listAgentsForInstance,{instanceName:t},{...i,agents:i.agents.map(e=>e.agentId===n?{...e,types:a}:e)})}),s=F(V.agents.removeInstanceAgent),c=C1(),l=D1();async function u(t,n){if(e)try{await i({instanceName:e,agentId:t,enabled:n})}catch(e){l.error(aQ(),e)}}async function d(t){if(e)try{await a({instanceName:e,agentId:t})}catch(e){l.error(aQ(),e)}}async function f(t,n,r){if(!e)return;let i=r.includes(n)?r.filter(e=>e!==n):[...r,n];try{await o({instanceName:e,agentId:t,types:i})}catch(e){l.error(aQ(),e)}}async function p(t,n){if(e&&await c({title:zbe({name:n}),description:Hbe(),confirmLabel:Gbe(),destructive:!0}))try{await s({instanceName:e,agentId:t}),l.success(Jbe())}catch(e){l.error(aQ(),e)}}return(0,I.jsx)(h1,{open:t,onOpenChange:n,children:(0,I.jsxs)(g1,{className:`oc-access`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:tbe({name:e??``})}),(0,I.jsx)(b1,{children:ibe()})]}),r===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:Zbe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-access__poll`,children:r.discovery===null?exe():r.discovery.lastPollOk?rxe():oxe({error:r.discovery.error??`?`})}),r.agents.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:lxe()}):(0,I.jsx)(`div`,{className:`oc-access__list`,children:r.agents.map(e=>{let t=e.presentInLastOk===!1,n=r.defaultAgentId===e.agentId,i=e.displayName??e.agentId,a=e.types??[];return(0,I.jsxs)(`div`,{className:`oc-agentcard`+(e.enabled?``:` oc-agentcard--off`),children:[(0,I.jsxs)(`div`,{className:`oc-agentcard__head`,children:[(0,I.jsx)(A1,{checked:e.enabled,disabled:t,"aria-label":i,onCheckedChange:t=>void u(e.agentId,t===!0)}),(0,I.jsxs)(`span`,{className:`oc-agentcard__name`,title:i,children:[e.emoji?`${e.emoji} `:``,i]}),e.model?(0,I.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,t?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:mxe()}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,className:`h-7 text-destructive`,onClick:()=>void p(e.agentId,i),children:Ibe()})]}):n?(0,I.jsx)($,{variant:`default`,children:oQ()}):(0,I.jsx)(X,{size:`sm`,variant:`outline`,className:`h-7`,disabled:!e.enabled,onClick:()=>void d(e.agentId),children:Nbe()})]}),e.enabled?(0,I.jsx)(rat,{agentId:e.agentId,types:a,onToggle:t=>void f(e.agentId,t,a)}):null]},e.agentId)})})]})]})})}function R7({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:e}),t]})}var aat=[{value:`action`,label:`action`},{value:`realLabel`,label:`acteur réel`},{value:`targetLabel`,label:`au nom de`},{value:`impersonated`,label:`usurpation`},{value:`resource`,label:`ressource`},{value:`resourceId`,label:`id ressource`}];function oat(){let e=os({from:`/settings/audit`}),t=ss({from:`/settings/audit`}),n=e.q??``,r=e.action??E7,i=e.impersonated??E7,a=e.resource??E7,o=v7(e.from,e.to),s=(0,N.useMemo)(()=>x7(e.adv),[e.adv]),{from:c,to:l}=t7(o),u=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),d=e=>void t({search:t=>({...t,action:e===E7?void 0:e})}),f=e=>void t({search:t=>({...t,impersonated:e===E7?void 0:e})}),p=e=>void t({search:t=>({...t,resource:e===E7?void 0:e})}),m=e=>void t({search:t=>({...t,...y7(e)})}),h=e=>void t({search:t=>({...t,adv:b7(e)}),replace:!0}),g=P(V.admin.listAudit,{filter:{q:n||void 0,from:c,to:l,action:r===E7?void 0:r,resource:a===E7?void 0:a,impersonated:i===E7?void 0:i===`yes`,advanced:s.length>0?s:void 0}}),_=(0,N.useMemo)(()=>{let e=new Set;for(let t of g??[])e.add(t.action);return[...e].sort()},[g]),v=(0,N.useMemo)(()=>{let e=new Set;for(let t of g??[])t.resource&&e.add(t.resource);return[...e].sort()},[g]),y=n!==``||r!==E7||i!==E7||a!==E7||s.length>0||o.kind!==`relative`||o.from!==Wit.from;function b(){t({search:{},replace:!0})}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[_xe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:bxe()})]}),(0,I.jsxs)(i7,{q:n,onQChange:u,searchPlaceholder:Cxe(),timeRange:o,onTimeRangeChange:m,onReset:b,canReset:y,children:[(0,I.jsxs)(C3,{value:r,onValueChange:d,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:sQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:E7,children:Oxe()}),_.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:i,onValueChange:f,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:E7,children:jxe()}),(0,I.jsx)(Q,{value:`yes`,children:Pxe()}),(0,I.jsx)(Q,{value:`no`,children:Lxe()})]})]}),(0,I.jsxs)(C3,{value:a,onValueChange:p,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:cQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:E7,children:Hxe()}),v.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})]}),(0,I.jsx)(h7,{fields:aat,seed:s,onChange:h}),(0,I.jsx)(A5,{title:Gxe(),rows:g,emptyHint:Jxe(),columns:[{header:Zxe(),cell:e=>new Date(e.at).toLocaleString(`fr-FR`),sort:e=>e.at},{header:sQ(),cell:e=>e.action,sort:e=>e.action},{header:eSe(),cell:e=>e.realLabel,sort:e=>e.realLabel},{header:rSe(),cell:e=>e.targetLabel??`—`,sort:e=>e.targetLabel??null},{header:cQ(),cell:e=>e.resource?e.resource+(e.resourceId?` · ${e.resourceId.slice(0,8)}`:``):`—`,sort:e=>e.resource??null}]})]})}var sat={pending:BCe,user:UCe,admin:KCe,observer:YCe,agent:QCe};function z7(e){if(e.builtin){let t=sat[e.key];if(t)return t()}return e.description}var B7=[{value:`never`,label:()=>iH(),days:null},{value:`30`,label:()=>sH(),days:30},{value:`90`,label:()=>uH(),days:90}],cat=720*60*60*1e3,V7=`__all__`,H7={name:``,roleKey:``,description:``};function lat(){let e=os({from:`/settings/serviceAccounts`}),t=ss({from:`/settings/serviceAccounts`}),n=e.q??``,r=e.status??V7,[i,a]=(0,N.useState)(V7),o=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),s=e=>void t({search:t=>({...t,status:e===V7?void 0:e})}),c=P(V.apiKeys.listServiceAccounts,{filter:{q:n||void 0,role:i===V7?void 0:i,disabled:r===V7?void 0:r===`disabled`}}),l=P(V.apiKeys.listKeys,{}),u=P(V.apiKeys.listRoles,{}),d=F(V.apiKeys.createServiceAccount),f=F(V.apiKeys.updateServiceAccount),p=F(V.apiKeys.deleteServiceAccount),m=$n(V.apiKeys.mintApiKey),h=F(V.apiKeys.revokeApiKey),g=C1(),_=D1(),v=n!==``||i!==V7||r!==V7;function y(){a(V7),t({search:{},replace:!0})}let[b,x]=(0,N.useState)(!1),[S,C]=(0,N.useState)(H7),[w,T]=(0,N.useState)(null),[E,D]=(0,N.useState)(new Set),[O,ee]=(0,N.useState)(null),te=(0,N.useRef)(!1),[k,A]=(0,N.useState)(new Set),[j,ne]=(0,N.useState)({}),[re,M]=(0,N.useState)(null),ie=(0,N.useMemo)(()=>{let e=new Map;for(let t of l??[]){let n=e.get(t.serviceAccountId)??[];n.push(t),e.set(t.serviceAccountId,n)}return e},[l]);function ae(e){D(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function oe(){try{w?(await f({serviceAccountId:w,name:S.name,roleKey:S.roleKey,description:S.description}),_.success(gB())):await d({name:S.name,roleKey:S.roleKey,description:S.description||void 0}),C(H7),T(null),x(!1)}catch(e){_.error(w?pB():uB(),e)}}function se(e){C({name:e.name,roleKey:e.roleKey,description:e.description??``}),T(e._id),x(!0)}async function ce(e){if(te.current)return;te.current=!0;let t=j[e._id]??`never`,n=B7.find(e=>e.value===t)?.days??null,r=n?Date.now()+n*24*60*60*1e3:void 0;ee(e._id);try{let t=await m({serviceAccountId:e._id,expiresAt:r});M({accountName:e.name,plaintext:t.plaintext,prefix:t.prefix,lastFour:t.lastFour})}catch(e){_.error(yB(),e)}finally{te.current=!1,ee(null)}}async function le(e){if(await g({title:SB(),description:(0,I.jsxs)(I.Fragment,{children:[TB(),` `,(0,I.jsx)(`span`,{className:`font-mono`,children:e.name}),` `,OB(),` `,(0,I.jsx)(`strong`,{children:jB()}),` `,PB()]}),confirmWord:e.name,confirmLabel:LB(),destructive:!0}))try{await p({serviceAccountId:e._id}),_.success(BB(),e.name)}catch(e){_.error(UB(),e)}}async function ue(e){if(await g({title:KB(),description:(0,I.jsxs)(I.Fragment,{children:[YB(),` `,(0,I.jsxs)(`span`,{className:`font-mono`,children:[e.prefix,`…`,e.lastFour]}),` `,QB()]}),confirmLabel:tV(),destructive:!0})&&!k.has(e._id)){A(t=>new Set(t).add(e._id));try{await h({keyId:e._id})}catch(e){_.error(iV(),e)}finally{A(t=>{let n=new Set(t);return n.delete(e._id),n})}}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:gR()}),(0,I.jsxs)(i7,{q:n,onQChange:o,searchPlaceholder:yR(),onReset:y,canReset:v,children:[(0,I.jsxs)(C3,{value:i,onValueChange:a,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-40`,children:(0,I.jsx)(w3,{placeholder:SR()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:V7,children:TR()}),(u??[]).map(e=>(0,I.jsx)(Q,{value:e.key,children:e.key},e._id))]})]}),(0,I.jsxs)(C3,{value:r,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:V7,children:OR()}),(0,I.jsx)(Q,{value:`active`,children:jR()}),(0,I.jsx)(Q,{value:`disabled`,children:PR()})]})]})]}),(0,I.jsx)(A5,{title:LR(),rows:c,addLabel:BR(),onAdd:()=>{C(H7),T(null),x(!0)},emptyHint:UR(),isExpanded:e=>E.has(e._id),renderExpanded:e=>(0,I.jsx)(uat,{account:e,keys:ie.get(e._id)??[],onRevoke:ue,revoking:k}),rowActions:e=>[{label:tz(),onSelect:()=>se(e)},{label:KR(),onSelect:()=>void ce(e)},{label:E.has(e._id)?YR():QR(),onSelect:()=>ae(e._id)},{label:iz(),variant:`destructive`,onSelect:()=>void le(e)}],columns:[{header:``,className:`w-8`,cell:e=>(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":E.has(e._id)?sz():uz(),onClick:()=>ae(e._id),children:E.has(e._id)?(0,I.jsx)(dm,{}):(0,I.jsx)(fm,{})})},{header:pz(),sort:e=>e.name,cell:e=>(0,I.jsxs)(`div`,{className:`flex flex-col`,children:[(0,I.jsx)(`span`,{children:e.name}),e.description?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:e.description}):null]})},{header:gz(),sort:e=>e.roleKey,cell:e=>(0,I.jsx)($,{variant:`secondary`,children:e.roleKey})},{header:yz(),sort:e=>+!!e.disabled,cell:e=>e.disabled?(0,I.jsx)($,{variant:`destructive`,children:PR()}):(0,I.jsx)($,{variant:`outline`,children:jR()})},{header:Sz(),cell:e=>(0,I.jsxs)(C3,{value:j[e._id]??`never`,onValueChange:t=>ne(n=>({...n,[e._id]:t})),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:B7.map(e=>(0,I.jsx)(Q,{value:e.value,children:e.label()},e.value))})]})},{header:Tz(),sort:e=>(ie.get(e._id)??[]).filter(e=>!e.disabled).length,cell:e=>{let t=(ie.get(e._id)??[]).filter(e=>!e.disabled).length;return(0,I.jsx)(`span`,{className:`oc-sa__keycount`,children:O===e._id?Oz():jz({count:t})})}}]}),(0,I.jsx)(Q8,{open:b,onOpenChange:e=>{x(e),e||T(null)},title:w?Pz():Uz(),description:w?Lz():Kz(),canSubmit:!!(S.name&&S.roleKey),onSubmit:oe,submitLabel:w?Bz():Yz(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Qz()}),(0,I.jsx)(o1,{value:S.name,onChange:e=>C({...S,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:tB()}),(0,I.jsxs)(C3,{value:S.roleKey||void 0,onValueChange:e=>C({...S,roleKey:e}),children:[(0,I.jsx)(T3,{className:`w-full`,children:(0,I.jsx)(w3,{placeholder:iB()})}),(0,I.jsx)(E3,{children:(u??[]).map(e=>(0,I.jsxs)(Q,{value:e.key,children:[e.name,` (`,e.key,`)`]},e._id))})]}),(()=>{let e=(u??[]).find(e=>e.key===S.roleKey),t=e?z7(e):null;return t?(0,I.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t}):null})()]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:sB()}),(0,I.jsx)(o1,{value:S.description,onChange:e=>C({...S,description:e.target.value})})]})]})}),(0,I.jsx)(dat,{minted:re,onClose:()=>M(null)})]})}function uat({account:e,keys:t,onRevoke:n,revoking:r}){return(0,I.jsxs)(`div`,{className:`oc-sa__keys`,children:[(0,I.jsxs)(`div`,{className:`oc-sa__keys-head`,children:[sV(),` `,(0,I.jsx)(`span`,{className:`font-medium`,children:e.name})]}),t.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:uV()}):(0,I.jsxs)(`table`,{className:`oc-sa__keytable`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{children:pV()}),(0,I.jsx)(`th`,{children:gV()}),(0,I.jsx)(`th`,{children:yV()}),(0,I.jsx)(`th`,{children:SV()}),(0,I.jsx)(`th`,{children:TV()}),(0,I.jsx)(`th`,{children:OV()}),(0,I.jsx)(`th`,{})]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`td`,{children:(0,I.jsxs)(`code`,{className:`oc-sa__keyid`,children:[t.prefix,`…`,t.lastFour]})}),(0,I.jsx)(`td`,{children:(0,I.jsx)($,{variant:`secondary`,children:e.roleKey})}),(0,I.jsx)(`td`,{children:fat(t.createdAt)}),(0,I.jsx)(`td`,{className:pat(t.lastUsedAt)?`oc-sa__stale`:``,children:mat(t.lastUsedAt)}),(0,I.jsx)(`td`,{children:hat(t.expiresAt)}),(0,I.jsx)(`td`,{children:gat(t)}),(0,I.jsx)(`td`,{className:`text-right`,children:t.disabled?null:(0,I.jsx)(X,{variant:`destructive`,size:`sm`,disabled:r.has(t._id),onClick:()=>n(t),children:r.has(t._id)?jV():PV()})})]},t._id))})]})]})}function dat({minted:e,onClose:t}){let[n,r]=(0,N.useState)(!1);async function i(){if(e)try{await navigator.clipboard.writeText(e.plaintext),r(!0),window.setTimeout(()=>r(!1),2e3)}catch{}}return(0,I.jsx)(h1,{open:e!==null,onOpenChange:e=>{e||(r(!1),t())},children:e?(0,I.jsxs)(g1,{className:`max-w-lg`,showCloseButton:!1,onInteractOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:LV()}),(0,I.jsx)(b1,{children:BV({name:e.accountName})})]}),(0,I.jsx)(`div`,{className:`oc-sa__minted-warning`,children:UV()}),(0,I.jsxs)(`div`,{className:`oc-sa__minted-box`,children:[(0,I.jsx)(`code`,{className:`oc-sa__minted-plain`,children:e.plaintext}),(0,I.jsxs)(X,{variant:`outline`,size:`sm`,onClick:()=>void i(),"aria-label":KV(),children:[n?(0,I.jsx)(um,{}):(0,I.jsx)(_m,{}),n?YV():QV()]})]}),(0,I.jsx)(v1,{children:(0,I.jsx)(X,{onClick:()=>{r(!1),t()},children:tH()})})]}):null})}function fat(e){return new Date(e).toLocaleString(`fr-FR`)}function pat(e){return e===null?!1:Date.now()-e>cat}function mat(e){return e===null?pH():new Date(e).toLocaleString(`fr-FR`)}function hat(e){return e===null?`—`:new Date(e).toLocaleDateString(`fr-FR`)}function gat(e){return e.disabled?(0,I.jsx)($,{variant:`destructive`,children:gH()}):e.expiresAt!==null&&e.expiresAt<Date.now()?(0,I.jsx)($,{variant:`outline`,children:yH()}):(0,I.jsx)($,{variant:`outline`,children:SH()})}var U7=[{group:()=>oSe(),keys:[{key:`traces.read`,label:()=>lQ()},{key:`traces.read.content`,label:()=>CSe(),phi:!0},{key:`traces.write`,label:()=>uQ()}]},{group:()=>lSe(),keys:[{key:`kpi.read`,label:()=>lQ()},{key:`kpi.write`,label:()=>uQ()}]},{group:()=>fSe(),keys:[{key:`openclaw.query`,label:()=>OSe()},{key:`anomalies.read`,label:()=>jSe()},{key:`anomalies.report`,label:()=>PSe()}]},{group:()=>hSe(),keys:[{key:`chats.read`,label:()=>lQ()},{key:`selfheal`,label:()=>BSe()}]},{group:()=>vSe(),keys:[{key:`admin.manage`,label:()=>LSe()}]}],_at=U7.flatMap(e=>e.keys.map(e=>e.key));function W7(e){return e.includes(`*`)}var G7={key:``,name:``,description:``};function vat(){let e=P(V.apiKeys.listRoles,{}),t=F(V.apiKeys.createRole),n=F(V.apiKeys.ensureRolesSeeded),r=F(V.apiKeys.updateRolePermissions).withOptimisticUpdate((e,{roleId:t,permissions:n})=>{let r=e.getQuery(V.apiKeys.listRoles,{});r&&e.setQuery(V.apiKeys.listRoles,{},r.map(e=>e._id===t?{...e,permissions:n}:e))}),i=C1(),a=D1(),[o,s]=(0,N.useState)(!1),[c,l]=(0,N.useState)(G7),[u,d]=(0,N.useState)(new Set);(0,N.useEffect)(()=>{n({}).catch(e=>{a.error(KSe(),e)})},[n,a]);let f=e??[];async function p(e,t){if(W7(e.permissions)||u.has(e._id))return;let n=e.permissions.includes(t)?e.permissions.filter(e=>e!==t):[...e.permissions,t];if(!(e.builtin&&!await i({title:YSe({name:e.name}),description:QSe(),confirmLabel:tCe()}))){d(t=>new Set(t).add(e._id));try{await r({roleId:e._id,permissions:n})}catch(e){a.error(iCe(),e)}finally{d(t=>{let n=new Set(t);return n.delete(e._id),n})}}}async function m(){try{await t({key:c.key,name:c.name,description:c.description||void 0,permissions:[]}),l(G7),s(!1)}catch(e){a.error(sCe(),e)}}let h=e===void 0,g=!h&&f.length===0;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[uCe(),` `,(0,I.jsx)(`code`,{children:`admin`}),` `,pCe(),` `,(0,I.jsx)(`code`,{children:`traces.read.content`}),` `,gCe()]}),(0,I.jsxs)(`div`,{className:`oc-dt`,children:[(0,I.jsxs)(`div`,{className:`oc-dt__bar`,children:[(0,I.jsx)(`h2`,{className:`oc-dt__title`,children:yCe()}),(0,I.jsx)(`div`,{className:`oc-dt__bar-actions`,children:(0,I.jsx)(X,{size:`sm`,onClick:()=>{l(G7),s(!0)},children:SCe()})})]}),h?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:TCe()}):g?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:OCe()}):(0,I.jsx)(`div`,{className:`oc-matrix__scroll`,children:(0,I.jsxs)(`table`,{className:`oc-matrix`,children:[(0,I.jsxs)(`thead`,{children:[(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:`oc-matrix__corner`,rowSpan:2,children:jCe()}),U7.map(e=>(0,I.jsx)(`th`,{className:`oc-matrix__group`,colSpan:e.keys.length,children:e.group()},e.group()))]}),(0,I.jsx)(`tr`,{children:U7.flatMap(e=>e.keys.map(e=>(0,I.jsxs)(`th`,{className:`oc-matrix__perm`,title:e.phi?USe({key:e.key}):e.key,children:[e.label(),e.phi?(0,I.jsx)(`span`,{className:`oc-matrix__phi`,children:` ⚠`}):null]},e.key)))})]}),(0,I.jsx)(`tbody`,{children:f.map(e=>{let t=W7(e.permissions),n=u.has(e._id);return(0,I.jsxs)(`tr`,{children:[(0,I.jsxs)(`th`,{className:`oc-matrix__rolecell`,children:[(0,I.jsxs)(`div`,{className:`oc-matrix__rolename`,children:[(0,I.jsx)(`span`,{children:e.name}),(0,I.jsx)(`code`,{className:`oc-matrix__rolekey`,children:e.key}),e.builtin?(0,I.jsxs)($,{variant:`outline`,className:`gap-1`,children:[(0,I.jsx)(wm,{}),` `,PCe()]}):(0,I.jsx)($,{variant:`secondary`,children:LCe()})]}),z7(e)?(0,I.jsx)(`p`,{className:`oc-matrix__roledesc`,children:z7(e)}):null]}),_at.map(r=>(0,I.jsx)(`td`,{className:`oc-matrix__cell`,children:(0,I.jsx)(A1,{checked:t||e.permissions.includes(r),disabled:t||n,"aria-label":`${e.key} · ${r}`,title:t?twe():n?iwe():r,onCheckedChange:()=>void p(e,r)})},r))]},e.key)})})]})})]}),(0,I.jsx)(Q8,{open:o,onOpenChange:s,title:swe(),description:uwe(),canSubmit:!!(c.key&&c.name),onSubmit:m,submitLabel:pwe(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:gwe()}),(0,I.jsx)(o1,{value:c.key,placeholder:ywe(),onChange:e=>l({...c,key:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Swe()}),(0,I.jsx)(o1,{value:c.name,onChange:e=>l({...c,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Twe()}),(0,I.jsx)(o1,{value:c.description,onChange:e=>l({...c,description:e.target.value})})]})]})})]})}function yat(e,t,n){let r=t.trim().toLowerCase();return[...r?e.filter(e=>[e.email,e.name,e.canonical].some(e=>e!=null&&e.toLowerCase().includes(r))):e.slice()].sort((e,t)=>!n.has(e.userId)-+!n.has(t.userId))}function bat(e,t){let n=e.filter(e=>e.source===`discovered`),r=t.trim().toLowerCase();return r?n.filter(e=>(e.displayName??e.agentId).toLowerCase().includes(r)||e.agentId.toLowerCase().includes(r)):n}function xat(e){let t=e.name?.trim()??``,n=e.email?.trim()??``,r=e.canonical?.trim()||`u-${e.userId.slice(0,8)}`;return t?{primary:t,secondary:n||`@${r}`}:n?{primary:n,secondary:null}:{primary:`@${r}`,secondary:null}}function Sat(e){switch(e){case`admin`:return LJe();case`user`:return BJe();case`pending`:return UJe();default:return e}}function K7(e,t){if(e.length===0)return`none`;let n=0;for(let r of e)t(r)&&n++;return n===0?`none`:n===e.length?`all`:`some`}function q7(e,t,n){let r=Math.max(1,Math.ceil(e.length/n)),i=Math.min(Math.max(1,Math.floor(t)),r),a=(i-1)*n;return{pageItems:e.slice(a,a+n),page:i,pageCount:r}}function Cat({className:e,orientation:t=`horizontal`,...n}){return(0,I.jsx)(Zle,{"data-slot":`tabs`,"data-orientation":t,className:G$(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var wat=i1(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function Tat({className:e,variant:t=`default`,...n}){return(0,I.jsx)(Qle,{"data-slot":`tabs-list`,"data-variant":t,className:G$(wat({variant:t}),e),...n})}function J7({className:e,...t}){return(0,I.jsx)($le,{"data-slot":`tabs-trigger`,className:G$(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function Y7({className:e,...t}){return(0,I.jsx)(eue,{"data-slot":`tabs-content`,className:G$(`flex-1 text-sm outline-none`,e),...t})}var X7={name:``,description:``};function Eat(){let e=P(V.groups.listGroups,{}),t=P(V.me.getMe,{host:xO})?.role===`admin`,n=F(V.groups.createGroup),r=F(V.groups.updateGroup),i=F(V.groups.deleteGroup),a=C1(),o=D1(),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(X7),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(``),_=(0,N.useMemo)(()=>{if(!e)return e;let t=h.trim().toLowerCase();return t?e.filter(e=>e.name.toLowerCase().includes(t)||(e.description??``).toLowerCase().includes(t)||e.members.some(e=>e.label.toLowerCase().includes(t))||e.agents.some(e=>e.toLowerCase().includes(t))||e.charts.some(e=>e.name.toLowerCase().includes(t))):e},[e,h]);function v(){u(null),f(X7),c(!0)}function y(e){u(e),f({name:e.name,description:e.description??``}),c(!0)}async function b(){try{l?await r({groupId:l._id,name:d.name,description:d.description}):await n({name:d.name,description:d.description||void 0}),f(X7),u(null),c(!1)}catch(e){o.error(nXe(),e)}}async function x(e){if(await a({title:Xqe({name:e.name}),description:$qe(),confirmWord:e.name,confirmLabel:nJe(),cancelLabel:Mqe(),destructive:!0}))try{await i({groupId:e._id})}catch(e){o.error(aXe(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:XKe()}),(0,I.jsx)(i7,{q:h,onQChange:g,onReset:()=>g(``),canReset:h!==``,searchPlaceholder:_qe()}),(0,I.jsx)(A5,{title:qKe(),rows:_,addLabel:$Ke(),onAdd:t?v:void 0,emptyHint:nqe(),columns:[{header:aqe(),cell:e=>e.name,sort:e=>e.name},{header:cqe(),cell:e=>(0,I.jsx)(j5,{icon:(0,I.jsx)(Wm,{size:12,"aria-hidden":!0}),total:e.memberCount,items:e.members.map(e=>({label:e.label,marker:e.manager?(0,I.jsx)(Rm,{size:11,"aria-hidden":!0}):null,highlight:e.manager}))}),sort:e=>e.memberCount},{header:dqe(),cell:e=>(0,I.jsx)(j5,{icon:(0,I.jsx)(Lm,{size:12,"aria-hidden":!0}),total:e.agentCount,items:e.agents.map(e=>({label:e}))}),sort:e=>e.agentCount},{header:mqe(),cell:e=>(0,I.jsx)(j5,{icon:(0,I.jsx)(jm,{size:12,"aria-hidden":!0}),total:e.chartCount,items:e.charts.map(e=>({label:e.name,marker:e.isDefault?(0,I.jsx)(Bm,{size:11,fill:`currentColor`,"aria-hidden":!0}):null,highlight:e.isDefault}))}),sort:e=>e.chartCount}],rowActions:e=>[{label:bqe(),onSelect:()=>m({groupId:e._id,name:e.name})},...t?[{label:Cqe(),onSelect:()=>y(e)},{label:Eqe(),variant:`destructive`,onSelect:()=>void x(e)}]:[]]}),(0,I.jsx)(Q8,{open:s,onOpenChange:c,title:l?Rqe():Fqe(),description:Vqe(),canSubmit:!!d.name.trim(),onSubmit:b,submitLabel:kqe(),children:(0,I.jsxs)(`div`,{className:`oc-form`,children:[(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:Wqe()}),(0,I.jsx)(o1,{value:d.name,onChange:e=>f({...d,name:e.target.value})})]}),(0,I.jsxs)(`label`,{className:`oc-field`,children:[(0,I.jsx)(`span`,{className:`oc-field__label`,children:qqe()}),(0,I.jsx)(o1,{value:d.description,onChange:e=>f({...d,description:e.target.value})})]})]})}),(0,I.jsx)(Dat,{groupId:p?.groupId??null,groupName:p?.name??``,open:p!==null,onOpenChange:e=>{e||m(null)}})]})}var Z7=8;function Q7({page:e,pageCount:t,onPage:n}){return t<=1?null:(0,I.jsxs)(`div`,{className:`oc-access__pager`,children:[(0,I.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,disabled:e<=1,onClick:()=>n(e-1),children:[(0,I.jsx)(bee,{size:14,"aria-hidden":!0}),OJe()]}),(0,I.jsxs)(`span`,{className:`oc-access__pageinfo`,"aria-label":PJe({page:e,pages:t}),children:[e,` / `,t]}),(0,I.jsxs)(X,{type:`button`,variant:`ghost`,size:`sm`,disabled:e>=t,onClick:()=>n(e+1),children:[jJe(),(0,I.jsx)(fm,{size:14,"aria-hidden":!0})]})]})}function Dat({groupId:e,groupName:t,open:n,onOpenChange:r}){let i=P(V.groups.getGroup,n&&e?{groupId:e}:`skip`),a=P(V.groups.listAssignableInstances,n?{}:`skip`),o=P(V.groups.listAssignableUsers,n?{}:`skip`),s=F(V.groups.addMember),c=F(V.groups.removeMember),l=F(V.groups.bulkSetMembers),u=F(V.groups.setGroupManager),d=D1(),[f,p]=(0,N.useState)(``),[m,h]=(0,N.useState)(``),[g,_]=(0,N.useState)(`members`),[v,y]=(0,N.useState)(1),[b,x]=(0,N.useState)(new Set),S=(0,N.useRef)(null),C=(0,N.useMemo)(()=>new Set((i?.members??[]).map(e=>e.userId)),[i]),w=(0,N.useMemo)(()=>new Set((i?.members??[]).filter(e=>e.manager).map(e=>e.userId)),[i]),T=i?.viewerIsAdmin===!0,E=(0,N.useMemo)(()=>new Set((i?.agents??[]).map(e=>`${e.instanceName}/${e.agentId}`)),[i]);(0,N.useEffect)(()=>{p(``),h(``),_(`members`),y(1),S.current=null},[n,e]),(0,N.useEffect)(()=>{y(1)},[f]),(0,N.useEffect)(()=>{n&&i&&e&&S.current!==e&&(S.current=e,x(new Set((i.members??[]).map(e=>e.userId))))},[n,i,e]);let D=(0,N.useMemo)(()=>o?yat(o,f,b):[],[o,f,b]);async function O(t,n){if(e)try{n?await c({groupId:e,userId:t}):await s({groupId:e,userId:t})}catch(e){d.error(KQ(),e)}}async function ee(t,n){if(e)try{await u({groupId:e,userId:t,manager:!n})}catch(e){d.error(ZYe(),e)}}let te=K7(D,e=>C.has(e.userId)),k=D.filter(e=>C.has(e.userId)).length,A=q7(D,v,Z7);async function j(){if(!e||D.length===0)return;let t=D.map(e=>e.userId);try{await l({groupId:e,userIds:t,member:te!==`all`})}catch(e){d.error(KQ(),e)}}return(0,I.jsx)(h1,{open:n,onOpenChange:r,children:(0,I.jsxs)(g1,{className:`oc-access`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:aJe({name:t})}),(0,I.jsx)(b1,{children:cJe()})]}),(0,I.jsxs)(Cat,{value:g,onValueChange:_,className:`oc-access__tabs`,children:[(0,I.jsxs)(Tat,{className:`w-full`,children:[(0,I.jsxs)(J7,{value:`members`,className:`flex-1 gap-1.5`,children:[(0,I.jsx)(Wm,{size:13,"aria-hidden":!0}),dJe(),i?(0,I.jsx)($,{variant:`secondary`,className:`oc-access__tabcount`,children:C.size}):null]}),(0,I.jsxs)(J7,{value:`agents`,className:`flex-1 gap-1.5`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),_Je(),i?(0,I.jsx)($,{variant:`secondary`,className:`oc-access__tabcount`,children:E.size}):null]}),(0,I.jsxs)(J7,{value:`charts`,className:`flex-1 gap-1.5`,children:[(0,I.jsx)(jm,{size:13,"aria-hidden":!0}),CYe(),i?(0,I.jsx)($,{variant:`secondary`,className:`oc-access__tabcount`,children:i.chartCount}):null]})]}),(0,I.jsx)(Y7,{value:`members`,children:o===void 0||i===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:RQ()}):o.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:rYe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o1,{value:f,onChange:e=>p(e.target.value),placeholder:mJe(),className:`oc-access__search`}),D.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:CJe()}):(0,I.jsxs)(I.Fragment,{children:[D.length>1?(0,I.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,I.jsx)(A1,{checked:te===`all`?!0:te===`some`?`indeterminate`:!1,onCheckedChange:()=>void j(),"aria-label":LQ()}),(0,I.jsx)(`span`,{className:`oc-access__label`,children:LQ()}),(0,I.jsxs)($,{variant:`outline`,className:`oc-access__count`,children:[k,` / `,D.length]})]}):null,(0,I.jsx)(`div`,{className:`oc-access__list`,children:A.pageItems.map(e=>{let t=C.has(e.userId),n=xat(e),r=w.has(e.userId);return(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:t,onCheckedChange:()=>void O(e.userId,t),"aria-label":KJe({user:n.primary})}),(0,I.jsxs)(`span`,{className:`oc-access__who`,children:[(0,I.jsx)(`span`,{className:`oc-access__label`,title:n.primary,children:n.primary}),n.secondary?(0,I.jsx)(`span`,{className:`oc-access__sub`,title:n.secondary,children:n.secondary}):null]}),(0,I.jsx)($,{variant:`outline`,className:`oc-access__role`,children:Sat(e.role)}),(0,I.jsx)(`span`,{className:`oc-access__mgrslot`,children:t&&T?(0,I.jsx)(X,{type:`button`,variant:`ghost`,size:`icon`,className:`shrink-0 oc-access__mgr${r?` oc-access__mgr--on`:``}`,"aria-pressed":r,"aria-label":r?WQ():UQ(),title:r?WQ():UQ(),onClick:()=>void ee(e.userId,r),children:(0,I.jsx)(Rm,{size:15,"aria-hidden":!0})}):t&&r?(0,I.jsx)(`span`,{className:`oc-access__mgr oc-access__mgr--on`,role:`img`,"aria-label":HQ(),title:HQ(),children:(0,I.jsx)(Rm,{size:15,"aria-hidden":!0})}):null})]},e._id)})}),(0,I.jsx)(Q7,{page:A.page,pageCount:A.pageCount,onPage:y})]})]})}),(0,I.jsx)(Y7,{value:`agents`,children:a===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:RQ()}):a.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:oYe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(o1,{value:m,onChange:e=>h(e.target.value),placeholder:bJe(),className:`oc-access__search`}),(0,I.jsx)(`div`,{className:`oc-access__list`,children:a.map(t=>(0,I.jsx)(Oat,{groupId:e,instanceName:t.name,kind:t.kind??`openclaw`,assigned:E,query:m},`${e}-${t._id}`))})]})}),(0,I.jsx)(Y7,{value:`charts`,children:(0,I.jsx)(kat,{groupId:e})})]})]})})}function Oat({groupId:e,instanceName:t,kind:n,assigned:r,query:i}){let a=P(V.groups.listAssignableAgents,{instanceName:t}),o=F(V.groups.assignAgentToGroup),s=F(V.groups.removeAgentFromGroup),c=F(V.groups.bulkSetGroupAgents),l=D1(),[u,d]=(0,N.useState)(1);if((0,N.useEffect)(()=>{d(1)},[i]),!e)return null;let f=bat(a?.agents??[],i),p=a?.discovery&&!a.discovery.lastPollOk;if(i.trim()&&f.length===0)return null;let m=f.filter(e=>e.presentInLastOk!==!1),h=K7(m,e=>r.has(`${t}/${e.agentId}`)),g=q7(f,u,Z7);async function _(n,r){try{r?await s({groupId:e,instanceName:t,agentId:n}):await o({groupId:e,instanceName:t,agentId:n})}catch(e){l.error(qQ(),e)}}async function v(){if(m.length===0)return;let n=m.map(e=>e.agentId);try{await c({groupId:e,instanceName:t,agentIds:n,assigned:h!==`all`})}catch(e){l.error(qQ(),e)}}return(0,I.jsxs)(`div`,{className:`oc-access__group`,children:[(0,I.jsxs)(`div`,{className:`oc-access__instance`,children:[(0,I.jsx)(Lm,{size:13,"aria-hidden":!0}),(0,I.jsx)(`span`,{children:t}),(0,I.jsx)($,{variant:`outline`,className:`oc-access__kind`,children:n}),p?(0,I.jsx)($,{variant:`outline`,className:`oc-access__stale`,children:hYe()}):null]}),a===void 0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:eYe()}):f.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:p?fYe():lYe()}):(0,I.jsxs)(I.Fragment,{children:[m.length>1?(0,I.jsxs)(`div`,{className:`oc-access__row oc-access__selectall`,children:[(0,I.jsx)(A1,{checked:h===`all`?!0:h===`some`?`indeterminate`:!1,onCheckedChange:()=>void v(),"aria-label":LQ()}),(0,I.jsx)(`span`,{className:`oc-access__label`,children:LQ()})]}):null,g.pageItems.map(e=>{let n=`${t}/${e.agentId}`,i=r.has(n),a=e.presentInLastOk===!1;return(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:i,disabled:a&&!i,onCheckedChange:()=>void _(e.agentId,i),"aria-label":YJe({name:e.displayName??e.agentId})}),(0,I.jsxs)(`span`,{className:`oc-access__label`,title:e.displayName??e.agentId,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),e.model?(0,I.jsx)(`span`,{className:`oc-access__model`,children:e.model}):null,e.isDefaultOnInstance?(0,I.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":zQ(),title:zQ(),children:(0,I.jsx)(Bm,{size:14,fill:`currentColor`})}):null,a?(0,I.jsx)($,{variant:`outline`,className:`oc-access__gone`,children:vYe()}):null]},e.agentId)}),(0,I.jsx)(Q7,{page:g.page,pageCount:g.pageCount,onPage:d})]})]})}function kat({groupId:e}){let t=P(V.charts.listGroupChartSelection,e?{groupId:e}:`skip`),n=F(V.charts.assignChartToGroup),r=F(V.charts.removeChartFromGroup),i=F(V.charts.setGroupDefaultChart),a=F(V.charts.addChartToGroupPool),o=F(V.charts.removeChartFromGroupPool),s=D1();if(!e)return null;if(t===void 0)return(0,I.jsx)(`p`,{className:`oc-access__hint`,children:RQ()});let{pool:c,addable:l,canManagePool:u}=t;if(c.length===0&&!u)return(0,I.jsx)(`p`,{className:`oc-access__hint`,children:EYe()});async function d(t,i){try{i?await r({groupId:e,chartKey:t}):await n({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}async function f(t){try{await i({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}async function p(t){try{await a({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}async function m(t){try{await o({groupId:e,chartKey:t})}catch(e){s.error(GQ(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-access__list`,children:c.map(e=>(0,I.jsxs)(`div`,{className:`oc-access__row`,children:[(0,I.jsx)(A1,{checked:e.selected,onCheckedChange:()=>void d(e.chartKey,e.selected),"aria-label":LYe({name:e.name})}),(0,I.jsx)(`span`,{className:`oc-access__label`,title:e.name,children:e.name}),e.selected?e.isDefault?(0,I.jsx)(`span`,{className:`oc-access__fav`,role:`img`,"aria-label":VQ(),title:VQ(),children:(0,I.jsx)(Bm,{size:14,fill:`currentColor`})}):(0,I.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void f(e.chartKey),children:HYe()}):null,u?(0,I.jsx)(X,{type:`button`,variant:`ghost`,size:`sm`,"aria-label":BQ({name:e.name}),title:BQ({name:e.name}),onClick:()=>void m(e.chartKey),children:(0,I.jsx)(Km,{size:14,"aria-hidden":!0})}):null]},e.chartKey))}),u?l.length>0?(0,I.jsxs)(C3,{value:``,onValueChange:e=>void p(e),children:[(0,I.jsx)(T3,{size:`sm`,className:`oc-access__search`,children:(0,I.jsx)(w3,{placeholder:MYe()})}),(0,I.jsx)(E3,{children:l.map(e=>(0,I.jsx)(Q,{value:e.chartKey,children:e.name},e.chartKey))})]}):c.length===0?(0,I.jsx)(`p`,{className:`oc-access__hint`,children:kYe()}):null:null]})}var Aat=[50,100,200,500],$7=`all`,e9=`__all__`,jat=[`2xx`,`4xx`,`5xx`],Mat=[`user`,`service`,`system`],Nat=[`inbound`,`outbound`,`internal`],Pat={kind:`relative`,from:`now-30d`,to:`now`},Fat=[{value:`kind`,label:`kind`},{value:`status`,label:`status`},{value:`latencyMs`,label:`latence (ms)`},{value:`principalType`,label:`principal`},{value:`direction`,label:`direction`},{value:`roleKey`,label:`rôle`},{value:`route`,label:`route`},{value:`correlationId`,label:`correlationId`}];function Iat(){let e=os({from:`/settings/traces`}),t=ss({from:`/settings/traces`}),n=e.limit,r=e.kind,i=e.statusClass??e9,a=e.principalType??e9,o=e.direction??e9,s=e.roleKey??e9,c=e.q??``,l=v7(e.from,e.to),u=(0,N.useMemo)(()=>x7(e.adv),[e.adv]),{from:d,to:f}=t7(l),[p,m]=(0,N.useState)(null),[h,g]=(0,N.useState)(null),_=e=>void t({search:t=>({...t,limit:e})}),v=e=>void t({search:t=>({...t,kind:e})}),y=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),b=e=>void t({search:t=>({...t,statusClass:e===e9?void 0:e})}),x=e=>void t({search:t=>({...t,principalType:e===e9?void 0:e})}),S=e=>void t({search:t=>({...t,direction:e===e9?void 0:e})}),C=e=>void t({search:t=>({...t,roleKey:e===e9?void 0:e})}),w=e=>void t({search:t=>({...t,...y7(e)})}),T=e=>void t({search:t=>({...t,adv:b7(e)}),replace:!0}),E=P(V.observability.listEvents,{limit:n}),D=P(V.observability.listEvents,{limit:n,kind:r===$7?void 0:r,filter:{q:c||void 0,from:d,to:f,statusClass:i===e9?void 0:i,principalType:a===e9?void 0:a,direction:o===e9?void 0:o,roleKey:s===e9?void 0:s,advanced:u.length>0?u:void 0}}),O=(0,N.useMemo)(()=>{let e=new Set;for(let t of E??[])e.add(t.kind);return[...e].sort()},[E]),ee=(0,N.useMemo)(()=>{let e=new Set;for(let t of E??[])t.roleKey&&e.add(t.roleKey);return[...e].sort()},[E]),te=c!==``||i!==e9||a!==e9||o!==e9||s!==e9||u.length>0||l.kind!==`relative`||l.from!==Pat.from;function k(){t({search:{limit:100,kind:`all`},replace:!0})}let A=p?E?.filter(e=>e.correlationId===p):D;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[vOe(),(0,I.jsx)(`strong`,{children:xOe()}),wOe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:DOe()})]}),(0,I.jsxs)(i7,{q:c,onQChange:y,searchPlaceholder:AOe(),timeRange:l,onTimeRangeChange:w,onReset:k,canReset:te,children:[(0,I.jsxs)(C3,{value:i,onValueChange:b,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:NOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:IOe()}),jat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:a,onValueChange:x,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:zOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:HOe()}),Mat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:o,onValueChange:S,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:GOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:JOe()}),Nat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:s,onValueChange:C,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:ZOe()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:e9,children:eke()}),ee.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:r,onValueChange:v,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-44`,children:(0,I.jsx)(w3,{placeholder:rke()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:$7,children:oke()}),O.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:String(n),onValueChange:e=>_(Number(e)),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-28`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:Aat.map(e=>(0,I.jsx)(Q,{value:String(e),children:lke({count:e})},e))})]})]}),(0,I.jsx)(h7,{fields:Fat,seed:u,onChange:T}),p?(0,I.jsx)(`div`,{className:`oc-traces__followline`,children:(0,I.jsxs)(`button`,{type:`button`,className:`oc-traces__chip`,onClick:()=>m(null),title:fke(),children:[(0,I.jsxs)(`span`,{className:`oc-traces__chip-label`,children:[hke(),(0,I.jsx)(`code`,{children:t9(p)})]}),(0,I.jsx)(Km,{className:`oc-traces__chip-x`,"aria-hidden":!0}),(0,I.jsx)(`span`,{className:`sr-only`,children:vke()})]})}):null,(0,I.jsx)(A5,{title:xke(),rows:A,emptyHint:p?wke():Dke(),columns:[{header:Ake(),sort:e=>e.at,cell:e=>(0,I.jsx)(`span`,{className:`oc-traces__time`,children:new Date(e.at).toLocaleString(`fr-FR`)})},{header:Nke(),sort:e=>e.kind,cell:e=>(0,I.jsx)($,{variant:`secondary`,children:e.kind})},{header:Ike(),sort:e=>n9(e)??null,cell:e=>{let t=n9(e);return t?(0,I.jsxs)(`span`,{className:`oc-traces__fail`,title:t,children:[`✕ `,t]}):(0,I.jsx)(`span`,{className:`oc-traces__ok`,"aria-label":zke(),children:`✓`})}},{header:Hke(),sort:e=>e.direction,cell:e=>e.direction?(0,I.jsx)($,{variant:`outline`,children:e.direction}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Gke(),sort:e=>e.principalType,cell:e=>(0,I.jsxs)(`span`,{className:`oc-traces__principal`,children:[(0,I.jsx)($,{variant:`outline`,children:e.principalType}),e.principalId?(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:t9(e.principalId)}):null]})},{header:Jke(),sort:e=>e.roleKey,cell:e=>e.roleKey?(0,I.jsx)($,{variant:`secondary`,children:e.roleKey}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:Zke(),sort:e=>e.route,cell:e=>e.route?(0,I.jsxs)(`span`,{className:`oc-traces__route`,children:[e.method?(0,I.jsx)(`span`,{className:`oc-traces__method`,children:e.method}):null,(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.route})]}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:eAe(),sort:e=>e.status,cell:e=>e.status===null?(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,I.jsx)(`span`,{className:`oc-traces__status ${Lat(e.status)}`,children:e.status})},{header:rAe(),sort:e=>e.latencyMs,cell:e=>e.latencyMs===null?(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}):(0,I.jsxs)(`span`,{className:`oc-traces__mono`,children:[e.latencyMs,` ms`]})},{header:oAe(),sort:e=>e.correlationId,cell:e=>e.correlationId?(0,I.jsx)(`button`,{type:`button`,className:`oc-traces__corr`,title:lAe(),onClick:()=>m(e.correlationId),children:t9(e.correlationId)}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})},{header:fAe(),sort:e=>+!!e.meta,cell:e=>e.meta?(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>g(e),children:hAe()}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`})}]}),(0,I.jsx)(Rat,{row:h,onClose:()=>g(null)})]})}function Lat(e){return e>=500?`oc-traces__status--5xx`:e>=400?`oc-traces__status--4xx`:e>=200&&e<300?`oc-traces__status--2xx`:`oc-traces__status--other`}function t9(e){return e.length>8?e.slice(0,8):e}function n9(e){if(typeof e.status==`number`&&e.status>=400)return String(e.status);if(!e.meta)return null;try{let t=JSON.parse(e.meta);if(e.kind===`openclaw.dispatch`&&t.dispatchStatus===`failed`)return t.errorCode??`failed`;if(e.kind===`assistant.stream`&&t.phase===`finalize`&&(t.streamStatus===`error`||t.streamStatus===`aborted`))return t.streamStatus;if(e.kind===`openclaw.ingest.denied`)return`denied`}catch{}return null}function Rat({row:e,onClose:t}){let n=(0,N.useMemo)(()=>{if(!e?.meta)return``;try{return JSON.stringify(JSON.parse(e.meta),null,2)}catch{return e.meta}},[e]);return(0,I.jsx)(h1,{open:e!==null,onOpenChange:e=>{e||t()},children:e?(0,I.jsxs)(g1,{className:`max-w-lg`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsxs)(y1,{className:`oc-traces__meta-title`,children:[vAe(),` `,(0,I.jsx)(`code`,{children:e.kind}),(0,I.jsx)($,{variant:`outline`,children:xAe()})]}),(0,I.jsx)(b1,{children:wAe()})]}),(0,I.jsx)(`pre`,{className:`oc-traces__meta-json`,children:n})]}):null})}function r9({className:e,size:t=`default`,...n}){return(0,I.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:G$(`group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl`,e),...n})}function i9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-header`,className:G$(`group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3`,e),...t})}function a9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-title`,className:G$(`font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm`,e),...t})}function o9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-description`,className:G$(`text-sm text-muted-foreground`,e),...t})}function s9({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-content`,className:G$(`px-4 group-data-[size=sm]/card:px-3`,e),...t})}function zat({className:e,...t}){return(0,I.jsx)(`div`,{"data-slot":`card-footer`,className:G$(`flex items-center rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/card:p-3`,e),...t})}var c9=[{metric:`api.calls`,label:_Ie(),unit:`/h`,group:`API`,isError:!1},{metric:`api.errors`,label:bIe(),unit:`/h`,group:`API`,isError:!0},{metric:`api.latency.avg_ms`,label:CIe(),unit:`ms`,group:`API`,isError:!1},{metric:`openclaw.ingest`,label:EIe(),unit:`/h`,group:`OpenClaw`,isError:!1},{metric:`chat.send`,label:kIe(),unit:`/h`,group:`Chat`,isError:!1},{metric:`assistant.stream.errors`,label:MIe(),unit:`/h`,group:`Assistant`,isError:!0}],l9=c9.length,Bat=[`API`,`OpenClaw`,`Chat`,`Assistant`],Vat=1e3,Hat=36e5;function Uat(e,t){let n=Math.max(1,Math.ceil((t-e)/Hat)),r=Math.min(n*l9,Vat);return{rowLimit:r,buckets:Math.max(1,Math.floor(r/l9))}}function Wat(){let e=os({from:`/settings/kpi`}),t=ss({from:`/settings/kpi`}),n=v7(e.from,e.to,Lit,`now`),r=e=>void t({search:t=>({...t,...y7(e)})}),{from:i,to:a}=t7(n),{rowLimit:o,buckets:s}=Uat(i,a),c=P(V.kpi.listKpis,{limit:o,filter:{from:i,to:a}}),l=(0,N.useMemo)(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.metric)??[];n.push({bucket:t.bucket,value:t.value}),e.set(t.metric,n)}for(let[t,n]of e)n.sort((e,t)=>e.bucket<t.bucket?-1:+(e.bucket>t.bucket)),n.length>s&&e.set(t,n.slice(n.length-s));return e},[c,s]),u=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[FIe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:RIe()})]}),(0,I.jsx)(Gat,{value:n,onChange:r})]});return c===void 0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:VIe()})]}):c.length===0?(0,I.jsxs)(I.Fragment,{children:[u,(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:WIe()})]}):(0,I.jsxs)(I.Fragment,{children:[u,Bat.map(e=>{let t=c9.filter(t=>t.group===e);return t.some(e=>(l.get(e.metric)??[]).length>0)?(0,I.jsxs)(`section`,{className:`oc-kpi__group`,children:[(0,I.jsx)(`h2`,{className:`oc-kpi__group-title`,children:e}),(0,I.jsx)(`div`,{className:`oc-kpi__grid`,children:t.map(e=>(0,I.jsx)(Kat,{config:e,series:l.get(e.metric)??[]},e.metric))})]},e):null})]})}function Gat({value:e,onChange:t}){return(0,I.jsx)(`div`,{className:`oc-kpi__toolbar`,children:(0,I.jsx)(r7,{value:e,onChange:t})})}function Kat({config:e,series:t}){let n=t.length>0?t[t.length-1]:null,r=n?n.value:0;return(0,I.jsxs)(r9,{size:`sm`,className:`oc-kpi__card`,children:[(0,I.jsxs)(i9,{children:[(0,I.jsx)(a9,{className:`oc-kpi__card-title`,children:e.label}),(0,I.jsx)(o9,{className:`oc-kpi__card-metric`,children:(0,I.jsx)(`code`,{children:e.metric})})]}),(0,I.jsxs)(s9,{className:`oc-kpi__card-body`,children:[(0,I.jsxs)(`div`,{className:`oc-kpi__value-row`,children:[(0,I.jsx)(`span`,{className:`oc-kpi__value`+(e.isError&&r>0?` oc-kpi__value--error`:``),children:f9(r)}),(0,I.jsx)(`span`,{className:`oc-kpi__unit`,children:e.unit})]}),(0,I.jsx)(Jat,{series:t,isError:e.isError,unit:e.unit}),(0,I.jsxs)(`div`,{className:`oc-kpi__axis`,children:[n?(0,I.jsx)(`span`,{className:`oc-kpi__axis-latest`,children:qIe({value:p9(n.bucket)})}):(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:XIe()}),(0,I.jsx)(`span`,{className:`oc-kpi__muted`,children:$Ie({count:t.length})})]})]})]})}var u9=240,d9=48,qat=1;function Jat({series:e,isError:t,unit:n}){if(e.length===0)return(0,I.jsx)(`div`,{className:`oc-kpi__chart oc-kpi__chart--empty`,"aria-hidden":!0});let r=e.reduce((e,t)=>t.value>e?t.value:e,0),i=u9/e.length,a=Math.max(i-qat,1);return(0,I.jsx)(`svg`,{className:`oc-kpi__chart`,viewBox:`0 0 ${u9} ${d9}`,preserveAspectRatio:`none`,role:`img`,"aria-label":nLe({max:f9(r),unit:n}),children:e.map((e,o)=>{let s=r>0?e.value/r*(d9-1):0,c=o*i,l=d9-s;return(0,I.jsx)(`rect`,{className:`oc-kpi__bar`+(t&&e.value>0?` oc-kpi__bar--error`:``),x:c,y:l,width:a,height:s,children:(0,I.jsxs)(`title`,{children:[p9(e.bucket),` · `,f9(e.value),` `,n]})},e.bucket)})})}function f9(e){return Number.isFinite(e)?Math.abs(e)>=1e3?(e/1e3).toFixed(e%1e3==0?0:1)+`k`:String(e):`0`}function p9(e){let t=new Date(`${e}:00:00Z`);return Number.isNaN(t.getTime())?e:`${String(t.getUTCDate()).padStart(2,`0`)}/${String(t.getUTCMonth()+1).padStart(2,`0`)} ${String(t.getUTCHours()).padStart(2,`0`)}h`}var m9=`__all__`,Yat=[{value:`open`},{value:`acknowledged`},{value:`resolved`}];function Xat(e){return e===`open`?Owe():e===`acknowledged`?jwe():Pwe()}var Zat=[`info`,`warn`,`critical`],Qat=[`detector`,`agent`],$at={kind:`relative`,from:`now-30d`,to:`now`},eot=200,h9=`all`;function tot(){let e=os({from:`/settings/anomalies`}),t=ss({from:`/settings/anomalies`}),n=e.q??``,r=e.status===h9?m9:e.status,i=e.severity??m9,a=e.kind??m9,[o,s]=(0,N.useState)(m9),c=v7(e.from,e.to),{from:l,to:u}=t7(c),d=e=>void t({search:t=>({...t,q:e||void 0}),replace:!0}),f=e=>void t({search:t=>({...t,status:e===m9?h9:e})}),p=e=>void t({search:t=>({...t,severity:e===m9?void 0:e})}),m=e=>void t({search:t=>({...t,kind:e===m9?void 0:e})}),h=e=>void t({search:t=>({...t,...y7(e)})}),g=C1(),_=D1(),v=F(V.anomalies.resolveAnomaly),y=(P(V.me.getMe,{host:xO})?.permissions??[]).includes(`admin.manage`),b=P(V.anomalies.listAnomalies,{limit:eot,filter:{q:n||void 0,from:l,to:u,anomalyStatus:r===m9?void 0:r,severity:i===m9?void 0:i,source:o===m9?void 0:o,kind:a===m9?void 0:a}}),x=(0,N.useMemo)(()=>{let e=new Set;for(let t of b??[])e.add(t.kind);return[...e].sort()},[b]),S=n!==``||r!==`open`||i!==m9||o!==m9||a!==m9||c.kind!==`relative`||c.from!==$at.from;function C(){s(m9),t({search:{status:`open`},replace:!0})}async function w(e){if(await g({title:Lwe(),description:(0,I.jsxs)(I.Fragment,{children:[Bwe(),` `,(0,I.jsx)(`span`,{className:`font-mono`,children:e.kind}),` `,Uwe(),` `,(0,I.jsx)(`strong`,{children:Kwe()}),`.`,` `,Ywe()]}),confirmLabel:Qwe()}))try{await v({anomalyId:e._id,status:`resolved`}),_.success(tTe(),e.kind)}catch(e){_.error(iTe(),e)}}async function T(e){try{await v({anomalyId:e._id,status:`acknowledged`}),_.success(sTe(),e.kind)}catch(e){_.error(uTe(),e)}}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[pTe(),` `,(0,I.jsx)(`strong`,{children:gTe()}),` `,yTe(),` `,(0,I.jsx)(`strong`,{children:STe()}),` `,TTe(),` `,(0,I.jsx)(`strong`,{children:OTe()}),` `,jTe(),` `,(0,I.jsx)(`span`,{className:`oc-filter__window`,children:PTe()})]}),(0,I.jsxs)(i7,{q:n,onQChange:d,searchPlaceholder:LTe(),timeRange:c,onTimeRangeChange:h,onReset:C,canReset:S,children:[(0,I.jsxs)(C3,{value:r,onValueChange:f,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:BTe()}),Yat.map(e=>(0,I.jsx)(Q,{value:e.value,children:Xat(e.value)},e.value))]})]}),(0,I.jsxs)(C3,{value:i,onValueChange:p,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:dQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:GTe()}),Zat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:o,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-32`,children:(0,I.jsx)(w3,{placeholder:fQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:XTe()}),Qat.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}),(0,I.jsxs)(C3,{value:a,onValueChange:m,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{placeholder:pQ()})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:m9,children:tEe()}),x.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]})]}),(0,I.jsx)(A5,{title:iEe(),rows:b,emptyHint:r===`open`?sEe():uEe(),rowActions:e=>y&&e.status===`open`?[{label:pEe(),onSelect:()=>void w(e)},{label:gEe(),onSelect:()=>void T(e)}]:[],columns:[{header:yEe(),cell:e=>(0,I.jsx)(`span`,{className:`oc-traces__time`,children:new Date(e.at).toLocaleString(`fr-FR`)}),sort:e=>e.at},{header:pQ(),cell:e=>(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:e.kind}),sort:e=>e.kind},{header:dQ(),cell:e=>(0,I.jsx)(iot,{severity:e.severity}),sort:e=>e.severity===`critical`?2:+(e.severity===`warn`)},{header:SEe(),cell:e=>(0,I.jsx)(aot,{status:e.status}),sort:e=>e.status===`resolved`?2:+(e.status===`acknowledged`)},{header:fQ(),cell:e=>(0,I.jsx)($,{variant:`outline`,children:e.source}),sort:e=>e.source},{header:TEe(),cell:e=>(0,I.jsx)(`span`,{className:`oc-anomaly__msg`,children:e.message}),sort:e=>e.message},{header:OEe(),cell:e=>(0,I.jsx)(rot,{row:e}),sort:e=>e.evidence??null},{header:jEe(),cell:e=>e.correlationId?(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:oot(e.correlationId)}):(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`}),sort:e=>e.correlationId}]})]})}function not(e){if(e.kind!==`openclaw.dispatch_failures`||!e.evidence)return{};try{let t=JSON.parse(e.evidence);return{dominantCode:t.dominantCode,sampleCorrelationId:t.sampleCorrelationId}}catch{return{}}}function rot({row:e}){let t=ss(),n=not(e);if(!n.dominantCode)return(0,I.jsx)(`span`,{className:`oc-traces__muted`,children:`—`});let r=L5(n.dominantCode),i=n.sampleCorrelationId;return(0,I.jsxs)(`div`,{className:`oc-anomaly__cause`,children:[(0,I.jsxs)(`div`,{className:`oc-anomaly__cause-head`,children:[(0,I.jsx)(`span`,{className:`oc-anomaly__cause-label`,children:r.label}),(0,I.jsx)(`code`,{className:`oc-traces__mono`,children:n.dominantCode})]}),(0,I.jsx)(`p`,{className:`oc-anomaly__cause-hint`,children:r.hint}),i?(0,I.jsxs)(`button`,{type:`button`,className:`oc-anomaly__drill`,onClick:()=>void t({to:`/settings/traces`,search:{q:i,limit:100}}),children:[`↗ `,PEe()]}):null]})}function iot({severity:e}){return(0,I.jsx)(`span`,{className:`oc-anomaly__sev oc-anomaly__sev--${e}`,children:e})}function aot({status:e}){return e===`open`?(0,I.jsx)($,{variant:`destructive`,children:LEe()}):e===`acknowledged`?(0,I.jsx)($,{variant:`secondary`,children:BEe()}):(0,I.jsx)($,{variant:`outline`,children:UEe()})}function oot(e){return e.length>8?e.slice(0,8):e}function sot(){let e=P(V.integrations.status.status,{}),t=F(V.admin.setIntegrationConfig),[n,r]=(0,N.useState)(null);if((0,N.useEffect)(()=>{e&&n===null&&r(e.config)},[e,n]),!e||!n)return(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:LJ()});let i=n,a=(e,t,n)=>r({...i,[e]:{...i[e],[t]:n}}),o=(e,n)=>void t({[e]:n});return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[BJ(),` `,(0,I.jsx)(`strong`,{children:UJ()}),` `,KJ()]}),(0,I.jsxs)(g9,{title:`Langfuse`,status:e.langfuse.configured?e.langfuse.enabled?(0,I.jsx)($,{variant:`secondary`,children:YJ()}):(0,I.jsx)($,{variant:`outline`,children:QJ()}):(0,I.jsx)($,{variant:`outline`,children:tY()}),note:sY(),children:[(0,I.jsx)(_9,{label:pY(),children:(0,I.jsx)(o1,{value:i.langfuse.host??``,placeholder:e.langfuse.effectiveHost,onChange:e=>a(`langfuse`,`host`,e.target.value),onBlur:()=>o(`langfuse`,{host:i.langfuse.host??``})})}),(0,I.jsx)(v9,{label:TY(),checked:i.langfuse.enabled??!0,onChange:e=>{a(`langfuse`,`enabled`,e),o(`langfuse`,{enabled:e})}})]}),(0,I.jsxs)(g9,{title:`Opik`,status:e.opik.configured?e.opik.enabled?(0,I.jsx)($,{variant:`secondary`,children:YJ()}):(0,I.jsx)($,{variant:`outline`,children:QJ()}):(0,I.jsx)($,{variant:`outline`,children:tY()}),note:uY(),children:[(0,I.jsx)(_9,{label:gY(),children:(0,I.jsx)(o1,{value:i.opik.baseUrl??``,placeholder:e.opik.effectiveBaseUrl,onChange:e=>a(`opik`,`baseUrl`,e.target.value),onBlur:()=>o(`opik`,{baseUrl:i.opik.baseUrl??``})})}),(0,I.jsx)(_9,{label:yY(),children:(0,I.jsx)(o1,{value:i.opik.workspace??``,placeholder:e.opik.effectiveWorkspace||SY(),onChange:e=>a(`opik`,`workspace`,e.target.value),onBlur:()=>o(`opik`,{workspace:i.opik.workspace??``})})}),(0,I.jsx)(v9,{label:TY(),checked:i.opik.enabled??!0,onChange:e=>{a(`opik`,`enabled`,e),o(`opik`,{enabled:e})}})]}),(0,I.jsxs)(g9,{title:OY(),status:(0,I.jsx)($,{variant:`outline`,children:iY()}),note:jY(),children:[(0,I.jsx)(_9,{label:PY(),children:(0,I.jsx)(y9,{value:i.tts.auto??`off`,options:[[`off`,LY()],[`always`,BY()],[`inbound`,UY()],[`tagged`,KY()]],onChange:e=>{a(`tts`,`auto`,e),o(`tts`,{auto:e})}})}),(0,I.jsx)(_9,{label:YY(),children:(0,I.jsx)(y9,{value:i.tts.provider??`openai`,options:[[`openai`,`OpenAI`],[`elevenlabs`,`ElevenLabs`],[`microsoft`,QY()],[`azure`,`Azure Speech`],[`google`,`Google Gemini`]],onChange:e=>{a(`tts`,`provider`,e),o(`tts`,{provider:e})}})}),(0,I.jsx)(_9,{label:tX(),children:(0,I.jsx)(o1,{value:i.tts.model??``,placeholder:`eleven_multilingual_v2`,onChange:e=>a(`tts`,`model`,e.target.value),onBlur:()=>o(`tts`,{model:i.tts.model??``})})}),(0,I.jsx)(_9,{label:iX(),children:(0,I.jsx)(o1,{value:i.tts.voice??``,placeholder:sX(),onChange:e=>a(`tts`,`voice`,e.target.value),onBlur:()=>o(`tts`,{voice:i.tts.voice??``})})})]}),(0,I.jsxs)(g9,{title:uX(),status:(0,I.jsx)($,{variant:`outline`,children:iY()}),note:e.secrets.openai?pX():gX(),children:[(0,I.jsx)(v9,{label:yX(),checked:i.talk.enabled??!1,onChange:e=>{a(`talk`,`enabled`,e),o(`talk`,{enabled:e})}}),(0,I.jsx)(_9,{label:SX(),children:(0,I.jsx)(y9,{value:i.talk.realtimeProvider??`openai`,options:[[`openai`,`OpenAI (gpt-realtime)`],[`google`,`Google`]],onChange:e=>{a(`talk`,`realtimeProvider`,e),o(`talk`,{realtimeProvider:e})}})}),(0,I.jsx)(_9,{label:TX(),children:(0,I.jsx)(o1,{value:i.talk.realtimeModel??``,placeholder:`gpt-realtime-2`,onChange:e=>a(`talk`,`realtimeModel`,e.target.value),onBlur:()=>o(`talk`,{realtimeModel:i.talk.realtimeModel??``})})}),(0,I.jsx)(_9,{label:iX(),children:(0,I.jsx)(o1,{value:i.talk.voice??``,placeholder:`cedar / marin`,onChange:e=>a(`talk`,`voice`,e.target.value),onBlur:()=>o(`talk`,{voice:i.talk.voice??``})})}),(0,I.jsx)(_9,{label:OX(),children:(0,I.jsx)(y9,{value:i.talk.transport??`webrtc`,options:[[`webrtc`,jX()],[`provider-websocket`,`Provider WebSocket`],[`gateway-relay`,`Gateway relay`]],onChange:e=>{a(`talk`,`transport`,e),o(`talk`,{transport:e})}})}),(0,I.jsx)(_9,{label:PX(),children:(0,I.jsx)(o1,{value:i.talk.speechLocale??``,placeholder:`fr-CA`,onChange:e=>a(`talk`,`speechLocale`,e.target.value),onBlur:()=>o(`talk`,{speechLocale:i.talk.speechLocale??``})})}),(0,I.jsx)(v9,{label:LX(),checked:i.talk.interruptOnSpeech??!0,onChange:e=>{a(`talk`,`interruptOnSpeech`,e),o(`talk`,{interruptOnSpeech:e})}})]}),(0,I.jsxs)(`section`,{className:`oc-int__section`,children:[(0,I.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,I.jsx)(`h3`,{className:`oc-uipa__h`,children:BX()}),(0,I.jsx)($,{variant:`outline`,children:UX()})]}),(0,I.jsxs)(`p`,{className:`oc-uipa__note`,children:[KX(),(0,I.jsx)(`code`,{children:` voicewake.get/set`}),`.`]})]}),(0,I.jsx)(A5,{title:YX(),rows:e.cursors.map(e=>({...e,_id:e.vendor})),emptyHint:QX(),columns:[{header:tZ(),cell:e=>(0,I.jsx)($,{variant:`secondary`,children:e.vendor}),sort:e=>e.vendor},{header:iZ(),cell:e=>e.lastAt>0?new Date(e.lastAt).toLocaleString(`fr-FR`):`—`,sort:e=>e.lastAt>0?e.lastAt:null},{header:sZ(),cell:e=>String(e.failureCount),sort:e=>e.failureCount},{header:uZ(),cell:e=>e.lastErrorStatus??`—`,sort:e=>e.lastErrorStatus??null},{header:pZ(),cell:e=>e.lastError??`—`,sort:e=>e.lastError??null}]})]})}function g9({title:e,status:t,note:n,children:r}){return(0,I.jsxs)(`section`,{className:`oc-int__section`,children:[(0,I.jsxs)(`div`,{className:`oc-int__section-head`,children:[(0,I.jsx)(`h3`,{className:`oc-uipa__h`,children:e}),t]}),n?(0,I.jsx)(`p`,{className:`oc-uipa__note`,children:n}):null,(0,I.jsx)(`div`,{className:`oc-int__fields`,children:r})]})}function _9({label:e,children:t}){return(0,I.jsxs)(`label`,{className:`oc-int__field`,children:[(0,I.jsx)(`span`,{className:`oc-int__field-label`,children:e}),t]})}function v9({label:e,checked:t,onChange:n}){return(0,I.jsxs)(`label`,{className:`oc-int__toggle`,children:[(0,I.jsx)(A1,{checked:t,onCheckedChange:e=>n(e===!0)}),(0,I.jsx)(`span`,{children:e})]})}function y9({value:e,options:t,onChange:n}){return(0,I.jsxs)(C3,{value:e,onValueChange:n,children:[(0,I.jsx)(T3,{size:`sm`,className:`w-full`,children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:t.map(([e,t])=>(0,I.jsx)(Q,{value:e,children:t},e))})]})}var cot={altered_words:()=>gZ(),incorrect:()=>yZ(),incoherence:()=>SZ(),formatting:()=>TZ(),latency:()=>OZ(),api_error:()=>jZ(),other:()=>PZ()},b9=e=>cot[e]?.()??e;function x9({matches:e,sourceWasOpen:t}){return t?e===!0?(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:BZ()}):e===!1?(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:UZ()}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill`,children:`—`}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill`,children:LZ()})}function lot({data:e,closeReason:t}){let n=e.snapshot,r=F(V.feedback.respondToFeedback),[i,a]=(0,N.useState)(e.thread),[o,s]=(0,N.useState)(``),[c,l]=(0,N.useState)(!1);async function u(){let t=o.trim();if(!(!t||c)){l(!0);try{await r({feedbackId:e._id,text:t}),a(e=>[...e,{authorRole:`admin`,text:t,at:Date.now()}]),s(``)}finally{l(!1)}}}let d=[];try{d=n.contextJson?JSON.parse(n.contextJson):[]}catch{d=[]}return(0,I.jsxs)(`div`,{className:`oc-fbadmin__detail`,children:[(0,I.jsxs)(`div`,{className:`oc-fbadmin__row`,children:[(0,I.jsx)(x9,{matches:n.displayedMatchesStored,sourceWasOpen:n.clientInfo?.sourceWasOpen??!1}),(0,I.jsxs)(`span`,{className:`oc-fbadmin__meta`,children:[b9(e.category),` · `,n.messageRole,n.isRegeneration?` · ${KZ()}`:``,n.openclawModel?` · ${n.openclawModel}`:``,n.openclawRuntime?` (${n.openclawRuntime})`:``]})]}),e.comment?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:hfe()}),(0,I.jsx)(`p`,{className:`oc-fbadmin__comment`,children:e.comment})]}):null,t?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:bme()}),(0,I.jsx)(`p`,{className:`oc-fbadmin__comment`,children:t})]}):null,(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:vfe()}),i.length>0?(0,I.jsx)(`div`,{className:`oc-fbadmin__thread`,children:i.map((e,t)=>(0,I.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,I.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?xfe():wfe()}),(0,I.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):(0,I.jsx)(`p`,{className:`oc-fbadmin__meta`,children:Dfe()}),(0,I.jsx)(`textarea`,{className:`oc-feedback__textarea`,placeholder:Afe(),value:o,maxLength:2e3,rows:3,onChange:e=>s(e.target.value.slice(0,2e3))}),(0,I.jsx)(`div`,{className:`oc-fbadmin__row`,style:{justifyContent:`flex-end`},children:(0,I.jsx)(X,{size:`sm`,onClick:()=>void u(),disabled:!o.trim()||c,children:c?Nfe():Ife()})})]}),(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:zfe()}),(0,I.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.messageText||JZ()})]}),n.clientInfo?.sourceWasOpen&&n.displayedText!==void 0?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:Wfe()}),(0,I.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.displayedText||JZ()})]}):null,n.promptText?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:qfe()}),(0,I.jsx)(`pre`,{className:`oc-msg__source-pre`,children:n.promptText})]}):null,d.length>0?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:Xfe({count:n.contextCount??d.length,truncated:n.contextTruncated?$fe():``})}),(0,I.jsx)(`div`,{className:`oc-fbadmin__ctx`,children:d.map((e,t)=>(0,I.jsxs)(`div`,{className:`oc-fbadmin__ctx-turn`,children:[(0,I.jsx)(`span`,{className:`oc-fbadmin__ctx-role`,children:e.role}),(0,I.jsx)(`span`,{className:`oc-fbadmin__ctx-text`,children:e.text})]},t))})]}):null,n.outboxAvailable?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:npe()}),(0,I.jsxs)(`pre`,{className:`oc-msg__source-pre`,children:[n.outboxText??``,n.outboxStatus?`\n[status: ${n.outboxStatus}]`:``]})]}):null,n.clientInfo?.extensionsDetected&&n.clientInfo.extensionsDetected.length>0?(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:ape()}),(0,I.jsx)(`div`,{className:`oc-fbadmin__row`,children:n.clientInfo.extensionsDetected.map(e=>(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-warn`,children:e},e))})]}):null,(0,I.jsxs)(`section`,{children:[(0,I.jsx)(`h4`,{className:`oc-fbadmin__h`,children:cpe()}),(0,I.jsxs)(`p`,{className:`oc-fbadmin__env`,children:[[n.clientInfo?.language,n.clientInfo?.timezone,n.clientInfo?.theme?dpe({theme:n.clientInfo.theme}):null,n.runId?`run ${n.runId.slice(0,12)}…`:null].filter(Boolean).join(` · `)||`—`,n.clientInfo?.plugins&&n.clientInfo.plugins.length>0?(0,I.jsxs)(`span`,{className:`oc-fbadmin__plugins`,children:[mpe(),` `,n.clientInfo.plugins.join(`, `),(0,I.jsxs)(`span`,{className:`oc-fbadmin__note`,children:[` `,_pe()]})]}):null,n.clientInfo?.userAgent?(0,I.jsx)(`span`,{className:`oc-fbadmin__ua`,children:n.clientInfo.userAgent}):null]})]})]})}function uot(){let e=P(V.feedback.listForAdmin,{}),t=F(V.feedback.readSnapshot),n=F(V.feedback.deleteFeedback),r=C1(),[i,a]=(0,N.useState)(null),[o,s]=(0,N.useState)({});async function c(e){if(i===e._id){a(null);return}if(!o[e._id]){let n=await t({feedbackId:e._id});s(t=>({...t,[e._id]:n}))}a(e._id)}async function l(e){await r({title:Mme(),description:Fme(),confirmLabel:Rme(),destructive:!0})&&(await n({feedbackId:e._id}),i===e._id&&a(null))}return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`oc-admin__hint`,children:[bpe(),` `,(0,I.jsx)(`strong`,{children:Cpe()}),` `,Epe()]}),(0,I.jsx)(A5,{title:kpe(),rows:e,emptyHint:Mpe(),isExpanded:e=>i===e._id&&!!o[e._id],renderExpanded:e=>o[e._id]?(0,I.jsx)(lot,{data:o[e._id],closeReason:e.userCloseReason}):null,columns:[{header:Fpe(),cell:e=>new Date(e.at).toLocaleString(`fr-FR`),sort:e=>e.at},{header:Rpe(),cell:e=>b9(e.category),sort:e=>b9(e.category)},{header:Vpe(),cell:e=>e.messageRole===`user`?Wpe():qpe(),sort:e=>e.messageRole},{header:Xpe(),cell:e=>(e.reporterEmail||e.reporterName||`—`)+(e.impersonated&&e.realOperatorEmail?` ${$pe({operator:e.realOperatorEmail})}`:``),sort:e=>e.reporterEmail||e.reporterName||null},{header:nme(),cell:e=>(0,I.jsx)(x9,{matches:e.displayedMatchesStored,sourceWasOpen:e.sourceWasOpen}),sort:e=>e.displayedMatchesStored===!1?0:e.displayedMatchesStored===!0?1:2},{header:ame(),cell:e=>e.hasComment?`✎`:`—`,sort:e=>+!!e.hasComment},{header:cme(),cell:e=>e.userClosedAt==null?e.answered?(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-ok`,children:dme()}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill`,children:mme()}):(0,I.jsx)(`span`,{className:`oc-fbadmin__pill is-closed`,children:_me()}),sort:e=>e.userClosedAt==null?+!!e.answered:2}],rowActions:e=>[{label:i===e._id?Cme():Eme(),onSelect:()=>void c(e)},{label:kme(),onSelect:()=>void l(e),variant:`destructive`}]})]})}var S9=`all`;function C9(e){switch(e){case`image`:return LA();case`audio`:return BA();case`video`:return UA();case`pdf`:return KA();case`document`:return YA();case`archive`:return QA();default:return tj()}}function dot(){let[e,t]=(0,N.useState)(S9),[n,r]=(0,N.useState)(S9),[i,a]=(0,N.useState)(S9),[o,s]=(0,N.useState)(S9),[c,l]=(0,N.useState)(null),u=F(V.files.softDelete),d=D1();function f(){t(S9),r(S9),a(S9),s(S9)}async function p(){let e=c;if(l(null),e)try{await u({fileId:e.id}),d.success(Pj())}catch(e){d.error(Lj(),e)}}let m=P(V.files.listMine,{direction:e===S9?void 0:e,chatId:n===S9?void 0:n,instanceName:i===S9?void 0:i,category:o===S9?void 0:o}),h=(0,N.useMemo)(()=>new Intl.DateTimeFormat(q(),{dateStyle:`medium`,timeStyle:`short`}),[]);if(m===void 0)return(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()});let{files:g,facets:_,truncated:v,cap:y}=m,b=e!==S9||n!==S9||i!==S9||o!==S9;return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:iA()}),(0,I.jsxs)(`div`,{className:`oc-files__filters`,style:{display:`flex`,flexWrap:`wrap`,gap:8,margin:`12px 0`},children:[(0,I.jsxs)(C3,{value:e,onValueChange:t,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":sA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:uA()}),(0,I.jsx)(Q,{value:`inbound`,children:pA()}),(0,I.jsx)(Q,{value:`outbound`,children:gA()})]})]}),(0,I.jsxs)(C3,{value:n,onValueChange:r,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":yA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:SA()}),_.chats.map(e=>(0,I.jsx)(Q,{value:e.id,children:e.title},e.id))]})]}),_.multiProvider?(0,I.jsxs)(C3,{value:i,onValueChange:a,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":TA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:OA()}),_.instances.map(e=>(0,I.jsx)(Q,{value:e,children:e},e))]})]}):null,(0,I.jsxs)(C3,{value:o,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":jA(),children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:S9,children:PA()}),_.categories.map(e=>(0,I.jsx)(Q,{value:e,children:C9(e)},e))]})]}),b?(0,I.jsxs)(X,{variant:`ghost`,size:`sm`,onClick:f,style:{display:`inline-flex`,alignItems:`center`,gap:4,marginLeft:`auto`},children:[(0,I.jsx)(Fm,{size:14,"aria-hidden":!0}),Tj()]}):null]}),g.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:b?Qj():Yj()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[(0,I.jsx)(O5,{children:ij()}),(0,I.jsx)(O5,{children:sj()}),(0,I.jsx)(O5,{children:uj()}),(0,I.jsx)(O5,{children:pj()}),(0,I.jsx)(O5,{children:gj()}),(0,I.jsx)(O5,{className:`text-right`,children:yj()})]})}),(0,I.jsx)(E5,{children:g.map(e=>(0,I.jsxs)(D5,{children:[(0,I.jsx)(k5,{className:`font-medium`,style:{maxWidth:280,overflow:`hidden`,textOverflow:`ellipsis`},title:e.filename,children:e.filename}),(0,I.jsx)(k5,{title:e.mimeType,children:C9(e.category)}),(0,I.jsx)(k5,{children:(0,I.jsx)($,{variant:`secondary`,children:e.direction===`inbound`?pA():gA()})}),(0,I.jsx)(k5,{style:{maxWidth:220,overflow:`hidden`,textOverflow:`ellipsis`},title:e.chatTitle,children:e.chatTitle}),(0,I.jsx)(k5,{className:`whitespace-nowrap text-muted-foreground`,children:h.format(e.createdAt)}),(0,I.jsx)(k5,{className:`text-right`,children:(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":Oj(),children:(0,I.jsx)(ym,{size:16})})}),(0,I.jsxs)(J$,{align:`end`,children:[e.url?(0,I.jsx)(Y$,{asChild:!0,children:(0,I.jsxs)(`a`,{href:e.url,download:e.filename,target:`_blank`,rel:`noopener noreferrer`,children:[(0,I.jsx)(vm,{size:14}),Sj()]})}):(0,I.jsxs)(Y$,{disabled:!0,children:[(0,I.jsx)(vm,{size:14}),Kj()]}),(0,I.jsxs)(Y$,{variant:`destructive`,onSelect:()=>l({id:e._id,filename:e.filename}),children:[(0,I.jsx)(Vm,{size:14}),jj()]})]})]})})]},e._id))})]}),v?(0,I.jsx)(`p`,{className:`oc-admin__hint`,style:{marginTop:8},children:tM({cap:y})}):null]}),(0,I.jsx)(s1,{open:c!==null,onOpenChange:e=>!e&&l(null),children:(0,I.jsxs)(c1,{children:[(0,I.jsxs)(l1,{children:[(0,I.jsx)(d1,{children:Bj()}),(0,I.jsx)(f1,{children:Uj()})]}),(0,I.jsxs)(u1,{children:[(0,I.jsx)(m1,{children:pW()}),(0,I.jsx)(p1,{onClick:()=>void p(),children:jj()})]})]})})]})}var w9=2e4,T9=6e4;function fot(e){return typeof e!=`number`||e<=0?0:Math.round(e/w9*100)}function pot(e){return e<=0?0:Math.round(e/T9*100)}function E9(e,t){let n=(typeof e==`number`&&e>0?e:0)/1e3;return new Intl.NumberFormat(t,{minimumFractionDigits:1,maximumFractionDigits:1}).format(n)}function D9(e){return e.reduce((e,t)=>e+(typeof t.size==`number`&&t.size>0?t.size:0),0)}var O9=3;function mot(e,t){let n=new Map;for(let t of e.split(`
163
163
  `))n.set(t,(n.get(t)??0)+1);for(let e of t.split(`
164
- `))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<O9&&a.push(e)):t>0&&(i+=t,o.length<O9&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function hot(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var k9=e=>`${e.instanceName}::${e.agentId}`;function got(){let e=P(V.me.getMe,{host:xO}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=P(V.admin.listInstances,e!==void 0&&t?{}:`skip`),[i,a]=(0,N.useState)(null);(0,N.useEffect)(()=>{!t||!r||r.length===0||(!i||!r.some(e=>e.name===i))&&a(r[0].name)},[t,r,i]);let o=P(V.agents.listAgentsForInstance,t&&i?{instanceName:i}:`skip`),s=P(V.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),c=(0,N.useMemo)(()=>{if(e!==void 0){if(t)return i===null||o===void 0?r!==void 0&&r.length===0?[]:void 0:o.agents.map(e=>({instanceName:i,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(s!==void 0)return s.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,i,o,r,s]),[l,u]=(0,N.useState)(null);(0,N.useEffect)(()=>{!c||c.length===0||(!l||!c.some(e=>k9(e)===l))&&u(k9(c[0]))},[c,l]);let d=c?.find(e=>k9(e)===l)??null,f=$n(V.agentFiles.listAgentFiles),[p,m]=(0,N.useState)({status:`idle`}),h=d?.instanceName??null,g=d?.agentId??null,_=P(V.compat.forInstance,n&&h!==null?{instanceName:h}:`skip`),v=n&&h!==null?F3(_,`agentFiles`):null,y=v===null?!1:v===`loading`?null:v.blocked,b=(0,N.useCallback)(async()=>{if(!(h===null||g===null)){m({status:`loading`});try{m({status:`done`,files:(await f({instanceName:h,agentId:g})).files})}catch{m({status:`error`})}}},[f,h,g]);(0,N.useEffect)(()=>{y===!1&&b()},[b,y]);let[x,S]=(0,N.useState)(null),C=q(),w=(0,N.useMemo)(()=>new Intl.NumberFormat(C,{maximumFractionDigits:0}),[C]);return e===void 0||c===void 0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):(0,I.jsxs)(`div`,{className:`oc-afiles`,children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:IQe()}),(0,I.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,I.jsxs)(C3,{value:i??``,onValueChange:e=>a(e),children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":e$(),children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:(r??[]).map(e=>(0,I.jsx)(Q,{value:e.name,children:e.name},e.name))})]}):null,c.length>0?(0,I.jsxs)(C3,{value:l??``,onValueChange:e=>u(e),children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":VQe(),children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:c.map(e=>(0,I.jsx)(Q,{value:k9(e),children:e.label},k9(e)))})]}):(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:WQe()})]}),d===null?null:v===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):v!==null&&v.blocked?(0,I.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,I.jsx)(Hm,{size:14,"aria-hidden":!0}),` `,W5(v.gatewayVersion)]}):p.status===`loading`||p.status===`idle`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):p.status===`error`?(0,I.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[XQe(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:ZQ()})]}):p.files.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:qQe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-afiles__list`,children:p.files.map(e=>{let n=fot(e.size),r=n>=80;return(0,I.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,I.jsx)($,{variant:`outline`,children:$Qe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`oc-afiles__size`,children:n$e({size:E9(e.size,C)})}),(0,I.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,I.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,I.jsx)(`span`,{className:`oc-afiles__pct`,children:a$e({pct:w.format(n)})}),r?(0,I.jsx)(Hm,{size:14,className:`oc-afiles__warn`,"aria-label":c$e()}):(0,I.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>S(e),children:t?m$e():_$e()})]},e.name)})}),(0,I.jsx)(`p`,{className:`oc-afiles__budget`,children:d$e({used:E9(D9(p.files),C),total:E9(T9,C),pct:w.format(pot(D9(p.files)))})})]}),x&&d?(0,I.jsx)(_ot,{instanceName:d.instanceName,agentId:d.agentId,name:x.name,isAdmin:t,onClose:()=>S(null),onSaved:()=>void b()}):null]})}function _ot({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:a}){let o=$n(V.agentFiles.getAgentFile),s=$n(V.agentFiles.setAgentFile),c=D1(),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(``),[h,g]=(0,N.useState)(!1),[_,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(!1),[x,S]=(0,N.useState)(!1),C=(0,N.useCallback)(async r=>{f(!1);try{let i=await o({instanceName:e,agentId:t,name:n});u({content:i.content,updatedAtMs:i.updatedAtMs}),r||m(i.content),b(!1)}catch{f(!0)}},[o,e,t,n]);(0,N.useEffect)(()=>{C(!1)},[C]);async function w(){if(l!==null){v(!0),S(!1);try{await s({instanceName:e,agentId:t,name:n,content:p,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(L$e({name:n})),a(),await C(!1)}catch(e){hot(e)?b(!0):S(!0)}finally{v(!1)}}}let T=l!==null&&p!==l.content,E=(0,N.useMemo)(()=>l===null?null:mot(l.content,p),[l,p]),D=p.length>w9,O=q(),ee=(0,N.useMemo)(()=>new Intl.NumberFormat(O),[O]);return(0,I.jsx)(h1,{open:!0,onOpenChange:e=>!e&&i(),children:(0,I.jsxs)(g1,{className:`oc-afiles__editor`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:t$({name:n})}),(0,I.jsxs)(b1,{children:[S$e({agent:t,instance:e}),r?null:(0,I.jsxs)(I.Fragment,{children:[` · `,T$e()]})]})]}),d?(0,I.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[U$e(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void C(!1),children:ZQ()})]}):l===null?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`textarea`,{className:`oc-afiles__source`,value:p,readOnly:!r,spellCheck:!1,onChange:e=>m(e.target.value),"aria-label":t$({name:n})}),(0,I.jsx)(`p`,{className:`oc-afiles__hint`,children:O$e()}),y?(0,I.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[K$e(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void C(!0),children:Y$e()})]}):null,x?(0,I.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:B$e()}):null,(0,I.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__count${D?` is-over`:``}`,children:j$e({count:ee.format(p.length),max:ee.format(w9)})}),r?(0,I.jsx)(X,{size:`sm`,disabled:!T||_||y,onClick:()=>g(!0),children:_?XQ():P$e()}):null]})]}),(0,I.jsx)(s1,{open:h,onOpenChange:g,children:(0,I.jsxs)(c1,{children:[(0,I.jsxs)(l1,{children:[(0,I.jsx)(d1,{children:Q$e({name:n})}),(0,I.jsx)(f1,{children:t1e({agent:t})})]}),E?(0,I.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,I.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:i1e({added:E.added,removed:E.removed})}),E.sampleAdded.length>0?(0,I.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__diff-label`,children:s1e()}),E.sampleAdded.map((e,t)=>(0,I.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,E.sampleRemoved.length>0?(0,I.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__diff-label`,children:u1e()}),E.sampleRemoved.map((e,t)=>(0,I.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,I.jsxs)(u1,{children:[(0,I.jsx)(m1,{children:pW()}),(0,I.jsx)(p1,{onClick:()=>void w(),children:p1e()})]})]})})]})})}var A9=[{id:`messages`,label:()=>SI()},{id:`composer`,label:()=>TI()},{id:`sidebar`,label:()=>OI()},{id:`other`,label:()=>jI()}],j9={showSource:{category:`messages`,label:()=>PI(),help:()=>LI()},showReport:{category:`messages`,label:()=>BI(),help:()=>UI()},copyAssistant:{category:`messages`,label:()=>KI()},copyUser:{category:`messages`,label:()=>YI()},showDelete:{category:`messages`,label:()=>QI()},showTools:{category:`messages`,label:()=>tL(),help:()=>iL()},voiceInput:{category:`composer`,label:()=>sL(),help:()=>uL()},showChatAge:{category:`sidebar`,label:()=>pL(),help:()=>gL()},showChatProvider:{category:`sidebar`,label:()=>yL(),help:()=>SL()}};function M9(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function vot(e,t){let n=M9(t.trim()),r=new Map(A9.map(e=>[e.id,e.label()])),i=new Map(A9.map(e=>[e.id,[]]));for(let t of e){let e=j9[t],a=e?.category??`other`;n&&!M9(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return A9.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var yot=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showChatProvider`],bot={voiceInput:`voiceInput`};function xot(e){return yot.includes(e)}function N9(e){return e===`admin`}function Sot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function Cot(e){return e===`on`?!0:e===`off`?!1:null}function wot(e){return xot(e)?bot[e]:void 0}var Tot={voiceInput:()=>tR()};function Eot({prefKey:e,ui:t}){let n=F(V.admin.setUiPrefDefault),r=F(V.admin.setFeatureEnabled),i=wot(e),a=i?Tot[e]?.():void 0;return(0,I.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,I.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,I.jsx)(`span`,{className:`oc-prefs__gov-label`,children:UL()}),(0,I.jsxs)(C3,{value:Sot(t.defaults[e]),onValueChange:t=>void n({key:e,value:Cot(t)}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`on`,children:sR()}),(0,I.jsx)(Q,{value:`off`,children:uR()}),(0,I.jsx)(Q,{value:`inherit`,children:pR()})]})]}),i?(0,I.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,I.jsx)(A1,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":KL()}),KL()]}):null]}),a?(0,I.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function Dot(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(!1),i=P(V.me.getMe,{host:xO}),a=i?.ui,o=N9(i?.role)&&n,s=F(V.me.setUiPref).withOptimisticUpdate(O1),c=(0,N.useMemo)(()=>a?vot(Object.keys(a.effective),e):[],[a,e]);return a?(0,I.jsxs)(`div`,{className:`oc-prefs-panel`,children:[N9(i?.role)?(0,I.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,I.jsx)(A1,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":BL()}),BL()]}):null,o?(0,I.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,I.jsx)(`p`,{children:YL()}),(0,I.jsx)(`p`,{children:QL()}),(0,I.jsx)(`p`,{children:iR()})]}):null,(0,I.jsx)(o1,{value:e,onChange:e=>t(e.target.value),placeholder:TL(),"aria-label":TL(),className:`mb-2`}),c.length===0?(0,I.jsx)(`div`,{className:`oc-prefs__empty`,children:OL()}):(0,I.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,I.jsxs)(`div`,{className:`oc-prefs__group`,children:[(0,I.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=j9[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,I.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}${l&&!i?` is-overridden`:``}`,children:[(0,I.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,I.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,I.jsx)(`span`,{className:`oc-prefs__lock`,children:jL()}):l?null:(0,I.jsx)(`span`,{className:`oc-prefs__def`,children:PL()})]}),r?(0,I.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,I.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,I.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void s({key:e,value:null}),children:LL()}):null,(0,I.jsx)(A1,{checked:c,disabled:i,onCheckedChange:t=>void s({key:e,value:t===!0}),"aria-label":n})]}),o?(0,I.jsx)(Eot,{prefKey:e,ui:a}):null]},e)})]},e.id))})]}):(0,I.jsx)(`div`,{className:`oc-prefs__empty`,children:KO()})}function Oot(){let e=P(V.me.getMe,{host:xO}),t=F(V.me.setLocale),n=F(V.me.setMyName),r=D1(),i=e?.locale??`default`,a=e?.name??``,[o,s]=(0,N.useState)(null),c=o??a,l=c.trim()!==a.trim();async function u(){try{await n({name:c}),s(null),r.success(Ok())}catch(e){r.error(jk(),e)}}return(0,I.jsxs)(`div`,{className:`oc-appearance`,children:[(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:gk()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:yk()})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(o1,{className:`max-w-xs`,value:c,maxLength:120,placeholder:Sk(),onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l&&(e.preventDefault(),u())}}),(0,I.jsx)(X,{size:`sm`,disabled:!l,onClick:()=>void u(),children:QZ()})]}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Tk()})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:Pk()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Lk()})]}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`,`default`].map(e=>(0,I.jsx)(X,{variant:i===e?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e==="default"?null:e}),children:e===`fr`?Yk():e===`en`?Qk():sk()},e))}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Bk()})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:Uk()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Kk()})]}),(0,I.jsx)(Dot,{})]})]})}var kot=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Aot(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}function jot(){let e=$n(V.agentFiles.getChatDefaults),t=$n(V.agentFiles.setChatDefaults),n=D1(),[r,i]=(0,N.useState)({status:`loading`}),[a,o]=(0,N.useState)({thinkingDefault:null,fastModeDefault:null}),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),d=P(V.admin.listInstances,{}),[f,p]=(0,N.useState)(null);(0,N.useEffect)(()=>{!d||d.length===0||(!f||!d.some(e=>e.name===f))&&p(d[0].name)},[d,f]);let m=(d?.length??0)>1,h=d!==void 0&&d.length===0,g=P(V.compat.forInstance,f?{instanceName:f}:`skip`),_=f?F3(g,`configDefaults`):`loading`,v=_===`loading`?null:_.blocked,y=(0,N.useMemo)(()=>m&&f?{instanceName:f}:{},[m,f]),b=(0,N.useRef)(0),x=(0,N.useCallback)(async()=>{let t=++b.current;i({status:`loading`});try{let n=Aot(await e(y));if(b.current!==t)return;i({status:`done`,current:n}),o(n)}catch{if(b.current!==t)return;i({status:`error`})}},[e,y]);(0,N.useEffect)(()=>{v===!1&&(m&&!f||x())},[x,v,m,f]);let S=r.status===`done`?r.current:null,C=S!==null&&a.thinkingDefault!==null&&a.thinkingDefault!==S.thinkingDefault,w=S!==null&&a.fastModeDefault!==null&&a.fastModeDefault!==S.fastModeDefault,T=C||w;async function E(){u(!0);try{await t({...y,...C?{thinkingDefault:a.thinkingDefault}:{},...w?{fastModeDefault:a.fastModeDefault}:{}}),n.success(B1e()),await x()}catch(e){n.error(U1e(),e)}finally{u(!1)}}let D=(0,N.useMemo)(()=>kot.map(e=>({id:e,label:M3(e)})),[]),O=(0,N.useMemo)(()=>[{id:`fast`,label:QQ()},{id:`standard`,label:$Q()}],[]);return(0,I.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:y1e()}),m&&f?(0,I.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,I.jsx)(`span`,{className:`oc-cdefaults__label`,children:e$()}),(0,I.jsxs)(C3,{value:f,onValueChange:e=>p(e),disabled:l,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":e$(),children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:(d??[]).map(e=>(0,I.jsx)(Q,{value:e.name,children:e.name},e.name))})]})]}):null,h?(0,I.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:BMe()}):_===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):_.blocked?(0,I.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,I.jsx)(Hm,{size:14,"aria-hidden":!0}),` `,W5(_.gatewayVersion)]}):r.status===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):r.status===`error`?(0,I.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[P1e(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void x(),children:ZQ()})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,I.jsx)(`span`,{className:`oc-cdefaults__label`,children:S1e()}),(0,I.jsx)(R3,{options:D,value:a.thinkingDefault,onChange:e=>o({...a,thinkingDefault:e}),disabled:l}),(0,I.jsx)(`p`,{className:`oc-cdefaults__help`,children:T1e()})]}),(0,I.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,I.jsx)(`span`,{className:`oc-cdefaults__label`,children:O1e()}),(0,I.jsx)(R3,{options:O,value:a.fastModeDefault===null?null:a.fastModeDefault?`fast`:`standard`,onChange:e=>o({...a,fastModeDefault:e===`fast`}),disabled:l}),(0,I.jsx)(`p`,{className:`oc-cdefaults__help`,children:j1e()})]}),(0,I.jsx)(`div`,{className:`oc-cdefaults__actions`,children:(0,I.jsx)(X,{size:`sm`,disabled:!T||l,onClick:()=>c(!0),children:l?XQ():L1e()})}),(0,I.jsx)(`p`,{className:`oc-cdefaults__note`,children:K1e()})]}),(0,I.jsx)(s1,{open:s,onOpenChange:c,children:(0,I.jsxs)(c1,{children:[(0,I.jsxs)(l1,{children:[(0,I.jsx)(d1,{children:Y1e()}),(0,I.jsx)(f1,{children:Q1e()})]}),(0,I.jsxs)(u1,{children:[(0,I.jsx)(m1,{children:pW()}),(0,I.jsx)(p1,{onClick:()=>void E(),children:t0e()})]})]})})]})}function Mot(e){return e===`user`?NKe():e===`all`?IKe():IQ({group:e.group})}function Not(e){return e===`common`?VKe():e===`owner`?WKe():IQ({group:e.group})}function Pot(e){return e.name||e.email||e.userId.slice(0,8)}function Fot(){let e=P(V.admin.listUsers,{}),[t,n]=(0,N.useState)(``),r=P(V.introspect.introspectUser,t?{userId:t}:`skip`);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:aKe()}),(0,I.jsxs)(C3,{value:t,onValueChange:n,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":PQ(),children:(0,I.jsx)(w3,{placeholder:PQ()})}),(0,I.jsx)(E3,{children:(e??[]).map(e=>(0,I.jsx)(Q,{value:e.userId,children:Pot(e)},e._id))})]}),t===``?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:uKe()}):r===void 0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):(0,I.jsxs)(`div`,{className:`oc-introspect`,children:[(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:pKe()}),(0,I.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,I.jsx)(`strong`,{children:r.user.label}),(0,I.jsx)($,{variant:`secondary`,children:r.role})]})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:gKe()}),r.groups.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`div`,{className:`oc-introspect__chips`,children:r.groups.map(e=>(0,I.jsx)($,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:yKe()}),r.agents.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`ul`,{className:`oc-introspect__list`,children:r.agents.map(e=>(0,I.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,I.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,I.jsx)($,{variant:`default`,children:AKe()}):null,(0,I.jsx)($,{variant:`outline`,children:Mot(e.via)}),(0,I.jsx)($,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:SKe()}),r.charts.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`ul`,{className:`oc-introspect__list`,children:r.charts.map(e=>(0,I.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,I.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,I.jsx)($,{variant:`outline`,children:Not(e.via)})]},e.key))})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:TKe()}),r.permissions.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`div`,{className:`oc-introspect__chips`,children:r.permissions.map(e=>(0,I.jsx)($,{variant:`secondary`,children:e},e))})]})]})]})}var P9=[{id:`personal`,label:()=>wXe(),tabs:[`preferences`,`theme`,`files`]},{id:`agents`,label:()=>DXe(),tabs:[`instances`,`agentFiles`,`chatDefaults`,`bridge`]},{id:`access`,label:()=>AXe(),tabs:[`users`,`groups`,`access`,`roles`,`serviceAccounts`]},{id:`observability`,label:()=>NXe(),tabs:[`traces`,`kpi`,`anomalies`,`audit`,`feedbacks`,`integrations`]}],Iot=new Map(P9.flatMap(e=>e.tabs.map(t=>[t,e.id])));function F9(e){let t=Iot.get(e);if(!t)throw Error(`Settings tab "${e}" belongs to no group`);return t}function Lot(e,t){return e.find(e=>F9(e)===t)}P9.flatMap(e=>[...e.tabs]);function Rot(){let e=P(V.bridgeHealth.getBridgeAvailability,{});if(e===void 0)return null;let t=e.known?e.available?`ok`:`error`:`idle`,n=e.known?e.available?`${eBe()}${e.checkedAt?rBe({time:new Date(e.checkedAt).toLocaleTimeString(`fr-FR`)}):``}`:oBe({reason:e.reason??`?`}):Zze();return(0,I.jsx)(j5,{delayDuration:150,children:(0,I.jsxs)(M5,{children:[(0,I.jsx)(N5,{asChild:!0,children:(0,I.jsx)(`span`,{className:`oc-bridge-dot oc-bridge-dot--${t}`,role:`img`,"aria-label":n})}),(0,I.jsx)(P5,{children:n})]})})}var zot={users:()=>bGe(),groups:()=>$Ge(),instances:()=>CGe(),bridge:()=>EGe(),serviceAccounts:()=>kGe(),roles:()=>MGe(),traces:()=>FGe(),kpi:()=>RGe(),anomalies:()=>VGe(),files:()=>tA(),agentFiles:()=>NQe(),preferences:()=>pk(),chatDefaults:()=>g1e(),access:()=>nKe(),integrations:()=>WGe(),theme:()=>iM(),audit:()=>qGe(),feedbacks:()=>XGe()};function I9(e){let t=new Set(E7),n=new Set,r=[];for(let i of e??[])t.has(i)&&!n.has(i)&&(r.push(i),n.add(i));for(let e of E7)n.has(e)||r.push(e);return r}function Bot(e,t){let n=new Set(t),r=[...t];return e.map(e=>n.has(e)?r.shift():e)}function Vot({tab:e,active:t}){let n=zot[e]?.()??O7[e]??e,r=`oc-settings-tabs__tab`+(t?` is-active`:``),i=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`oc-settings-tabs__label`,children:n}),e===`bridge`?(0,I.jsx)(Rot,{}):null]});return D7.includes(e)?(0,I.jsx)(xs,{to:`/settings/$tab`,params:{tab:e},className:r,role:`tab`,"aria-selected":t,children:i}):(0,I.jsx)(xs,{to:`/settings/${e}`,className:r,role:`tab`,"aria-selected":t,children:i})}function Hot({tab:e,active:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=J8({id:e});return(0,I.jsxs)(`div`,{ref:i,style:{transform:w6.Transform.toString(a),transition:o,opacity:s?.5:1},className:`oc-settings-tabs__item`,role:`presentation`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-settings-tabs__grip`,"aria-label":fXe(),...n,...r,children:(0,I.jsx)(Sm,{size:14,"aria-hidden":!0})}),(0,I.jsx)(Vot,{tab:e,active:t})]})}function Uot(){let e=P(V.me.getMe,{host:xO}),t=F(V.me.setSettingsTabOrder),n=N7(Gs({select:e=>e.pathname})),r=n===void 0?void 0:F9(n),i=(0,N.useMemo)(()=>I9(e?.settingsTabOrder??null),[e?.settingsTabOrder]),[a,o]=(0,N.useState)(i);(0,N.useEffect)(()=>o(i),[i]);let s=(0,N.useMemo)(()=>new Set(j7(e?.permissions??[])),[e?.permissions]),c=(0,N.useMemo)(()=>r===void 0?[]:a.filter(e=>s.has(e)&&F9(e)===r),[a,s,r]),l=A6(k6(u8,{activationConstraint:{distance:5}}),k6(o8,{coordinateGetter:X8}));if(r===void 0||c.length===0)return null;let u=P9.find(e=>e.id===r);function d(e){let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=c.indexOf(n.id),s=c.indexOf(r.id);if(i<0||s<0)return;let l=Bot(a,z8(c,i,s));o(l),t({order:l})}return(0,I.jsx)(`div`,{className:`oc-settings-tabs`,role:`tablist`,"aria-label":u?.label(),children:(0,I.jsx)(P8,{sensors:l,collisionDetection:Qtt,modifiers:[crt],onDragEnd:d,children:(0,I.jsx)(K8,{items:c,strategy:hrt,children:c.map(e=>(0,I.jsx)(Hot,{tab:e,active:e===n},e))})})})}function Wot(){let e=P(V.me.getMe,{host:xO}),t=ss(),n=N7(Gs({select:e=>e.pathname})),r=n===void 0?void 0:F9(n),i=(0,N.useMemo)(()=>new Set(j7(e?.permissions??[])),[e?.permissions]),a=(0,N.useMemo)(()=>I9(e?.settingsTabOrder??null).filter(e=>i.has(e)),[e?.settingsTabOrder,i]),o=P9.filter(e=>e.tabs.some(e=>i.has(e)));function s(e){let n=Lot(a,e.id);n&&t({to:M7(n)})}return(0,I.jsxs)(`nav`,{className:`oc-settings-nav`,"aria-label":hXe(),children:[(0,I.jsx)(xs,{to:`/`,className:`oc-settings-nav__back`,children:vXe()}),(0,I.jsx)(`div`,{className:`oc-settings-nav__title`,children:xXe()}),(0,I.jsx)(`div`,{className:`oc-settings-nav__list`,children:o.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`oc-settings-nav__group`+(e.id===r?` is-active`:``),"aria-current":e.id===r?`true`:void 0,onClick:()=>s(e),children:e.label()},e.id))})]})}var Got=12*1024*1024,Kot=480,qot=160,Jot=.92;async function Yot(e,t={}){if(!e.type.startsWith(`image/`))throw Error(iF());if(e.size>Got)throw Error(sF());let{source:n,width:r,height:i,cleanup:a}=await Xot(e);try{let a=e.type===`image/svg+xml`,o=Math.min(Kot/r,qot/i,a?1/0:1),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o)),l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u)throw Error(pF());if(u.imageSmoothingEnabled=!0,u.imageSmoothingQuality=`high`,u.drawImage(n,0,0,s,c),t.invert){let e=u.getImageData(0,0,s,c),t=e.data;for(let e=0;e<t.length;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2];u.putImageData(e,0,0)}let d=await R9(l,`image/webp`,Jot)??await R9(l,`image/png`);if(!d)throw Error(gF());return d}finally{a()}}async function Xot(e){if(e.type===`image/svg+xml`)return L9(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return L9(e)}async function L9(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(uF())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function R9(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var z9=`__all__`,B9={kind:`relative`,from:`now-24h`,to:`now`},Zot=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function V9({title:e,description:t,children:n}){return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,I.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function Qot(e){return e===`light`?QO():e===`dark`?tk():ik()}var $ot=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function est({tokens:e,mode:t}){let n=e.colors[t];return(0,I.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:$ot.map(e=>{let t=n[e];return(0,I.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function H9({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a}){return(0,I.jsxs)(`button`,{type:`button`,className:G$(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,I.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,I.jsx)(um,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,I.jsx)(est,{tokens:r,mode:i}):(0,I.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,I.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,I.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]})}function tst({selectedKey:e,resolvedMode:t}){let n=P(V.charts.listMyCharts),r=F(V.charts.setMyChart);async function i(e){try{await r({name:e})}catch{}}return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:jM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:PM()})]}),(0,I.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,I.jsx)(H9,{selected:e===null,title:LM(),subtitle:BM(),tokens:null,mode:t,onSelect:()=>void i(null)}),(n??[]).map(n=>{let r=n.via===`common`?UM():n.via===`owner`?KM():YM({group:n.via.group});return(0,I.jsx)(H9,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void i(n.key)},n.key)})]}),n!==void 0&&n.length===0?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:QM()}):null]})}function nst(){let e=F(V.charts.importChart),[t,n]=(0,N.useState)(``),[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1);async function d(e){let t=e.target.files?.[0];if(e.target.value=``,t){o(null),c(!1);try{i(await t.text())}catch{o(uP())}}}async function f(){if(o(null),c(!1),t.trim()===``){o(gP());return}let a;try{a=JSON.parse(r)}catch{o(uP());return}u(!0);try{await e({name:t.trim(),tokens:a}),c(!0),n(``),i(``)}catch(e){o(e instanceof Error?e.message:String(e))}finally{u(!1)}}return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:BN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:UN()})]}),(0,I.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:KN()}),(0,I.jsx)(o1,{value:t,onChange:e=>n(e.target.value),placeholder:YN(),maxLength:60})]}),(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:QN()}),(0,I.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:r,onChange:e=>i(e.target.value),placeholder:tP(),rows:8,spellCheck:!1})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{variant:`outline`,size:`sm`,asChild:!0,children:(0,I.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,I.jsx)(Um,{className:`size-4`}),iP(),(0,I.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void d(e)})]})}),(0,I.jsx)(X,{size:`sm`,disabled:l,onClick:()=>void f(),children:sP()})]}),a?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null,s?(0,I.jsx)(`p`,{className:`oc-chart-import__ok`,children:pP()}):null]})]})}function rst({chart:e}){let t=$n(V.charts.setChartLogo),n=F(V.charts.removeChartLogo),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(null),s=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function c(n,r,a=!1){if(e.chartId!==void 0){o(null),i(!0);try{let i=await(await Yot(r,{invert:a})).arrayBuffer();await t({chartId:e.chartId,bytes:i,mode:n})}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function l(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await c(e,n)}async function u(t){if(e.chartId!==void 0){o(null),i(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function d(e){let t=s(e===`light`?`dark`:`light`);if(t){o(null),i(!0);try{await c(e,await(await fetch(t)).blob(),!0)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}function f({mode:e}){let t=s(e),n=s(e===`light`?`dark`:`light`);return(0,I.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?LP():BP()}),(0,I.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,I.jsx)(`img`,{src:t,alt:``}):null}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,asChild:!0,children:(0,I.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,I.jsx)(Um,{className:`size-4`}),t?KP():UP(),(0,I.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void l(e,t)})]})}),!t&&n?(0,I.jsx)(X,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void d(e),children:QP()}):null,t?(0,I.jsx)(X,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void u(e),children:YP()}):null]})}return(0,I.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:PP()}),(0,I.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,I.jsx)(f,{mode:`light`}),(0,I.jsx)(f,{mode:`dark`})]}),r?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:tF()}):null,a?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null]})}function U9({chart:e}){let t=P(V.me.getMe,{host:xO}),n=F(V.charts.addChartDomain),r=F(V.charts.removeChartDomain),[i,a]=(0,N.useState)(``),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(!1);if(t?.role!==`admin`)return null;let u=e.domains??[];async function d(){let t=i.trim();if(t!==``){s(null),l(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}async function f(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:yF()}),(0,I.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,I.jsx)(`div`,{className:`oc-chart-avail__groups`,children:u.length===0?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:jF()}):u.map(e=>(0,I.jsxs)($,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,I.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":PF({domain:e}),onClick:()=>void f(e),children:(0,I.jsx)(Km,{className:`size-3`})})]},e))}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(o1,{value:i,onChange:e=>a(e.target.value),placeholder:TF(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&d()}}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,disabled:c,onClick:()=>void d(),children:OF()})]}),(0,I.jsx)(`span`,{className:`oc-show__desc`,children:SF()}),o?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function ist({chart:e}){let t=F(V.charts.updateChart),n=F(V.charts.deleteChart),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(e.name),[s,c]=(0,N.useState)(()=>JSON.stringify(e.tokens,null,2)),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(!1);function p(){o(e.name),c(JSON.stringify(e.tokens,null,2)),u(null),i(!0)}async function m(){if(e.chartId===void 0)return;u(null);let n;try{n=JSON.parse(s)}catch{u(uP());return}f(!0);try{await t({chartId:e.chartId,name:a.trim(),tokens:n}),i(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}async function h(){if(e.chartId!==void 0&&window.confirm(YF()))try{await n({chartId:e.chartId})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,I.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:r?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:p,children:OP()}),(0,I.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>void h(),children:jP()})]})})]}),r?(0,I.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:UF()}),(0,I.jsx)(o1,{value:a,onChange:e=>o(e.target.value),maxLength:60})]}),(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:KF()}),(0,I.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:s,onChange:e=>c(e.target.value),rows:10,spellCheck:!1})]}),l?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:l}):null,(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{size:`sm`,disabled:d,onClick:()=>void m(),children:LF()}),(0,I.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>i(!1),children:BF()})]})]}):null,(0,I.jsx)(rst,{chart:e}),(0,I.jsx)(U9,{chart:e})]})}function ast(){let e=P(V.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:yP()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:SP()})]}),e!==void 0&&t.length===0?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:TP()}):(0,I.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,I.jsx)(ist,{chart:e},e.key))})]})}function ost({chart:e,groups:t}){let n=F(V.charts.addChartToGroupPool),r=F(V.charts.removeChartFromGroupPool),i=e.restrictedToGroups,a=e.poolGroups,o=new Set((a??[]).map(e=>e.groupId)),s=t.filter(e=>!o.has(e._id));async function c(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function l(t){try{await r({groupId:t,chartKey:e.key})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,I.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,I.jsx)($,{variant:i?`secondary`:`outline`,className:`oc-chart-avail__state`,children:i?SN():e.kind===`custom`&&e.scope===`personal`?sI():yN()}),e.isGlobalDefault?(0,I.jsx)($,{variant:`default`,children:TN()}):null]}),(0,I.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:jN()}),(a??[]).map(e=>(0,I.jsxs)($,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,I.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":LN({group:e.name}),onClick:()=>void l(e.groupId),children:(0,I.jsx)(Km,{className:`size-3`})})]},e.groupId)),s.length>0?(0,I.jsxs)(C3,{value:``,onValueChange:e=>void c(e),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-56`,children:(0,I.jsx)(w3,{placeholder:PN()})}),(0,I.jsx)(E3,{children:s.map(e=>(0,I.jsx)(Q,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:ON()}):null]})]})}function sst({chart:e}){let t=F(V.charts.promoteChartToCommon),n=F(V.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(YF()))try{await n({chartId:e.chartId})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,I.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,I.jsx)($,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?uI():sI()}),e.ownerLabel?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:iI({owner:e.ownerLabel})}):null]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:pI()}):null,(0,I.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:gI()})]})]})}function cst({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=F(V.admin.setDefaultThemeMode),i=F(V.admin.setDefaultLocale),a=F(V.charts.setDefaultChart),o=P(V.charts.listChartsAdmin),s=P(V.groups.listGroups,{}),c=e??`system`,l=t??`fr`;return(0,I.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:TM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:OM()})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:tN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:iN()})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void a({name:null}),children:LM()}),CO.map(e=>(0,I.jsx)(X,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key)),(o??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,I.jsx)(X,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key))]})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:sN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:uN()})]}),(0,I.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,I.jsx)(ost,{chart:e,groups:s??[]},e.key))})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:pN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:gN()})]}),(0,I.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,I.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,I.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,I.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,I.jsx)(U9,{chart:e})]},e.key))})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:QF()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:tI()})]}),(()=>{let e=(o??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:yI()}):(0,I.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,I.jsx)(sst,{chart:e},e.key))})})()]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:sM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:uM()})]}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,I.jsx)(X,{variant:c===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:Qot(e)},e))})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:pM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:gM()})]}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`].map(e=>(0,I.jsx)(X,{variant:l===e?`default`:`outline`,size:`sm`,onClick:()=>void i({locale:e}),children:e===`fr`?Yk():Qk()},e))}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:yM()})]})]})}function lst(){let e=P(V.me.getMe,{host:xO}),t=wO(e?.resolvedThemeMode);return(0,I.jsxs)(`div`,{className:`oc-appearance`,children:[(0,I.jsx)(tst,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,I.jsx)(nst,{}),(0,I.jsx)(ast,{}),e?.role===`admin`?(0,I.jsx)(cst,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function ust(){let[e,t]=(0,N.useState)(!0),[n,r]=(0,N.useState)(`per-user`),[i,a]=(0,N.useState)(``),[o,s]=(0,N.useState)(z9),[c,l]=(0,N.useState)(z9),[u,d]=(0,N.useState)(B9),f=i!==``||o!==z9||c!==z9;function p(){a(``),s(z9),l(z9),d(B9)}return(0,I.jsxs)(`div`,{className:`oc-show`,children:[(0,I.jsx)(lst,{}),(0,I.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,I.jsx)(`summary`,{className:`oc-show__title`,children:SM()}),(0,I.jsxs)(V9,{title:`Buttons`,description:`Variants`,children:[(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{children:`Default`}),(0,I.jsx)(X,{variant:`secondary`,children:`Secondary`}),(0,I.jsx)(X,{variant:`outline`,children:`Outline`}),(0,I.jsx)(X,{variant:`ghost`,children:`Ghost`}),(0,I.jsx)(X,{variant:`destructive`,children:`Destructive`}),(0,I.jsx)(X,{variant:`link`,children:`Link`})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{size:`sm`,children:`Small`}),(0,I.jsx)(X,{children:`Default`}),(0,I.jsx)(X,{size:`lg`,children:`Large`}),(0,I.jsx)(X,{size:`icon`,"aria-label":`more`,children:(0,I.jsx)(ym,{})}),(0,I.jsx)(X,{disabled:!0,children:`Disabled`})]})]}),(0,I.jsx)(V9,{title:`Badges`,children:(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)($,{children:`Default`}),(0,I.jsx)($,{variant:`secondary`,children:`Secondary`}),(0,I.jsx)($,{variant:`outline`,children:`Outline`}),(0,I.jsx)($,{variant:`destructive`,children:`Destructive`})]})}),(0,I.jsx)(V9,{title:`Inputs & selection`,children:(0,I.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,I.jsx)(o1,{placeholder:`Text input…`}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsxs)(C3,{value:n,onValueChange:r,children:[(0,I.jsx)(T3,{className:`w-56`,children:(0,I.jsx)(w3,{placeholder:`Select…`})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,I.jsx)(Q,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,I.jsxs)(`label`,{className:`oc-show__check`,children:[(0,I.jsx)(A1,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,I.jsx)(V9,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,I.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,I.jsxs)(r7,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:u,onTimeRangeChange:d,onReset:p,canReset:f,children:[(0,I.jsxs)(C3,{value:o,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:z9,children:`Toutes directions`}),(0,I.jsx)(Q,{value:`inbound`,children:`inbound`}),(0,I.jsx)(Q,{value:`outbound`,children:`outbound`}),(0,I.jsx)(Q,{value:`internal`,children:`internal`})]})]}),(0,I.jsxs)(C3,{value:c,onValueChange:l,children:[(0,I.jsx)(T3,{size:`sm`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:z9,children:`Toutes sévérités`}),(0,I.jsx)(Q,{value:`info`,children:`info`}),(0,I.jsx)(Q,{value:`warn`,children:`warn`}),(0,I.jsx)(Q,{value:`critical`,children:`critical`})]})]})]}),(0,I.jsx)(m7,{fields:Zot,onChange:()=>{}}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,I.jsx)(n7,{value:u,onChange:d})]})]})}),(0,I.jsx)(V9,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,I.jsx)(ym,{})})}),(0,I.jsxs)(J$,{align:`start`,children:[(0,I.jsx)(X$,{children:`Actions`}),(0,I.jsx)(Z$,{}),(0,I.jsx)(Y$,{children:`Edit`}),(0,I.jsx)(Y$,{children:`Duplicate`}),(0,I.jsx)(Z$,{}),(0,I.jsx)(Y$,{variant:`destructive`,children:`Delete`})]})]})}),(0,I.jsx)(V9,{title:`Card`,children:(0,I.jsxs)(r9,{className:`w-80`,children:[(0,I.jsxs)(i9,{children:[(0,I.jsx)(a9,{children:`Instance`}),(0,I.jsx)(o9,{children:`Non-secret metadata only.`})]}),(0,I.jsx)(s9,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,I.jsxs)(zat,{className:`gap-2`,children:[(0,I.jsx)(X,{size:`sm`,children:`Save`}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,I.jsx)(V9,{title:`Table`,children:(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[(0,I.jsx)(O5,{className:`w-8`,children:(0,I.jsx)(A1,{"aria-label":`select all`})}),(0,I.jsx)(O5,{children:`Name`}),(0,I.jsx)(O5,{children:`Mode`}),(0,I.jsx)(O5,{className:`text-right`,children:`Status`}),(0,I.jsx)(O5,{className:`w-8`})]})}),(0,I.jsx)(E5,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,I.jsxs)(D5,{children:[(0,I.jsx)(k5,{children:(0,I.jsx)(A1,{"aria-label":`select ${e.n}`})}),(0,I.jsx)(k5,{className:`font-medium`,children:e.n}),(0,I.jsx)(k5,{children:(0,I.jsx)($,{variant:`secondary`,children:e.m})}),(0,I.jsx)(k5,{className:`text-right`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,I.jsx)(um,{className:`size-3.5`}),` `,e.s]})}),(0,I.jsx)(k5,{children:(0,I.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,I.jsx)(ym,{})})})]},e.n))})]})}),(0,I.jsx)(V9,{title:`App fragments`,description:`Chat-specific components`,children:(0,I.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,I.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,I.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,I.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,I.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,I.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,I.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,I.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,I.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,I.jsx)(`span`,{className:`oc-run-status__dot`}),(0,I.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}var W9=`oc.theme`;function G9(e){let t=e===`dark`||e===`system`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}function K9(e){(0,N.useEffect)(()=>{let t=e??localStorage.getItem(W9)??`system`;if(localStorage.setItem(W9,t),G9(t),t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>G9(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}function dst(e){(0,N.useEffect)(()=>{if(!e)return;document.documentElement.lang=e;let t;try{t=q()}catch{t=void 0}t!==e&&VO(e)},[e])}function fst(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mr,{children:(0,I.jsx)(`div`,{className:`oc-boot`,children:hQ()})}),(0,I.jsx)(pr,{children:(0,I.jsx)(mst,{})}),(0,I.jsx)(fr,{children:(0,I.jsx)(a4e,{children:(0,I.jsx)(hst,{})})})]})}function pst(){return(0,I.jsxs)(`svg`,{className:`oc-provider__logo`,viewBox:`0 0 48 48`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,I.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,I.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,I.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`})]})}function mst(){let{signIn:e}=Ir();K9(void 0);let t=P(V.charts.brandForHost,{host:xO}),n=$de(xO),r=t??n??null,i=wO(void 0);TO(r?.tokens??null,i),(0,N.useEffect)(()=>{t&&efe(xO,t)},[t]);let a=r?.brand,o=a&&!a.isDefault?jO(a,i):null,s=a?.label??`Atrium`,c=P(V.me.authProviders),[l,u]=(0,N.useState)(null);async function d(t){u(null);try{await e(t)}catch{u(kAe())}}let f=c!==void 0&&!c.google&&!c.microsoft&&!c.anonymous;return(0,I.jsxs)(`div`,{className:`oc-signin`,children:[(0,I.jsxs)(`svg`,{className:`oc-signin__motif`,viewBox:`0 0 1200 1000`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,I.jsx)(`polyline`,{className:`oc-signin__line`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,vectorEffect:`non-scaling-stroke`}),(0,I.jsx)(`polyline`,{className:`oc-signin__pulse`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,pathLength:`100`,vectorEffect:`non-scaling-stroke`})]}),(0,I.jsxs)(`div`,{className:`oc-signin__brand`,children:[o?(0,I.jsx)(`img`,{className:`oc-signin__brandlogo`,src:o,alt:``}):null,(0,I.jsx)(`span`,{className:`oc-signin__wordmark`,children:s})]}),(0,I.jsxs)(`div`,{className:`oc-signin__card`,children:[(0,I.jsx)(`h1`,{className:`oc-signin__title`,children:MAe()}),(0,I.jsx)(`p`,{className:`oc-signin__subtitle`,children:FAe()}),(0,I.jsx)(`div`,{className:`oc-signin__providers`,children:c?.google?(0,I.jsxs)(`button`,{type:`button`,className:`oc-provider oc-provider--google`,onClick:()=>void d(`google`),children:[(0,I.jsx)(pst,{}),(0,I.jsx)(`span`,{children:RAe()})]}):null}),l?(0,I.jsx)(`p`,{className:`oc-signin__error`,children:l}):null,f?(0,I.jsx)(`p`,{className:`oc-signin__error`,children:VAe()}):null,c?.anonymous?(0,I.jsx)(`button`,{type:`button`,className:`oc-signin__dev`,onClick:()=>void e(`anonymous`),children:WAe()}):null]})]})}function hst(){let e=P(V.me.getMe,{host:xO}),t=F(V.me.bootstrap),n=ss();(0,N.useEffect)(()=>{e&&!e.hasProfile&&t()},[e,t]),K9(e?.resolvedThemeMode);let r=wO(e?.resolvedThemeMode);TO(e?.resolvedChartTokens,r),dst(e?.resolvedLocale);let i=(0,N.useRef)(null);if((0,N.useEffect)(()=>{e&&(i.current!==null&&i.current!==e.userId&&n({to:`/`}),i.current=e.userId)},[e,n]),e===void 0)return(0,I.jsx)(`div`,{className:`oc-boot`,children:hQ()});let a=e.name||e.email||qAe();return e.role===`pending`?(0,I.jsxs)(`div`,{className:`oc-shell`,children:[(0,I.jsx)(q9,{}),(0,I.jsx)(p5,{}),(0,I.jsxs)(`header`,{className:`oc-topbar`,children:[(0,I.jsx)(`span`,{className:`oc-topbar__brand`,children:(0,I.jsx)(J9,{brand:e.resolvedChartBrand,resolvedThemeMode:e.resolvedThemeMode})}),(0,I.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,I.jsx)(m5,{label:a,mode:e.themeMode,minimal:!0})})]}),(0,I.jsxs)(`div`,{className:`oc-pending`,children:[(0,I.jsx)(`h1`,{className:`oc-pending__title`,children:XAe()}),(0,I.jsx)(`p`,{className:`oc-pending__body`,children:$Ae()})]})]}):(0,I.jsx)(_st,{canOpenSettings:j7(e.permissions??[]).length>0,userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand},e.userId)}function q9(){let e=P(V.me.getImpersonation),t=F(V.admin.stopImpersonation);return!e||!e.impersonating?null:(0,I.jsxs)(`div`,{className:`oc-imp`,role:`alert`,children:[(0,I.jsx)(Dee,{className:`size-4 shrink-0`}),(0,I.jsxs)(`span`,{className:`oc-imp__text`,children:[nje(),` `,(0,I.jsx)(`strong`,{children:e.targetLabel}),aje(),(0,I.jsx)(`strong`,{children:e.realLabel}),cje()]}),(0,I.jsx)(X,{size:`sm`,variant:`outline`,className:`oc-imp__exit`,onClick:()=>void t(),children:dje()})]})}function J9({brand:e,resolvedThemeMode:t}){let n=wO(t),r=e?.label??`Atrium`,i=e?.isDefault??!0,a=jO(e,n),[o,s]=(0,N.useState)(!1);return(0,N.useEffect)(()=>s(!1),[a]),(0,I.jsxs)(I.Fragment,{children:[a!==null&&!o?(0,I.jsx)(`img`,{className:`oc-brand__logo`,src:a,alt:``,"aria-hidden":`true`,onError:()=>s(!0)}):i?(0,I.jsx)(MO,{className:`oc-brand__logo`}):null,(0,I.jsx)(`span`,{className:`oc-brand__label`,children:r})]})}function gst({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r,collapsed:i,onToggleSidebar:a}){return(0,I.jsxs)(`header`,{className:`oc-topbar`,children:[(0,I.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":i?mje():_je(),onClick:a,children:i?(0,I.jsx)(Nm,{}):(0,I.jsx)(Mm,{})}),(0,I.jsx)(xs,{to:`/`,className:`oc-topbar__brand`,children:(0,I.jsx)(J9,{brand:r,resolvedThemeMode:n})})]}),(0,I.jsx)(`div`,{className:`oc-topbar__search`,children:(0,I.jsx)(Wrt,{})}),(0,I.jsxs)(`div`,{className:`oc-topbar__actions`,children:[(0,I.jsx)(h5,{}),(0,I.jsx)(m5,{label:e,mode:t})]})]})}function _st({canOpenSettings:e,userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i}){let{width:a,collapsed:o,toggleCollapsed:s,collapse:c,startResize:l,isMobile:u}=e3e(),d=zs(),f=as({strict:!1}),p=ss(),m=!!d({to:`/settings`,fuzzy:!0});(0,N.useEffect)(()=>{u&&c()},[Gs({select:e=>e.pathname}),u,c]);let h=(0,N.useCallback)(e=>{p({to:`/chat/$chatId`,params:{chatId:e}})},[p]),{startNewChat:g,picker:_}=Frt(h),v=(0,N.useMemo)(()=>b5(_5,y5()),[]);return(0,N.useEffect)(()=>{let e=e=>{x5(e,_5)&&(e.preventDefault(),g())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]),(0,I.jsxs)(`div`,{className:`oc-shell`,children:[_,(0,I.jsx)(q9,{}),(0,I.jsx)(p5,{}),(0,I.jsx)(gst,{userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i,collapsed:o,onToggleSidebar:s}),(0,I.jsxs)(`div`,{className:u?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[u&&!o?(0,I.jsx)(`div`,{className:`oc-sidebar-backdrop`,onClick:c,"aria-hidden":!0}):null,o?null:(0,I.jsxs)(`div`,{className:`oc-sidebar-col`,style:u?void 0:{width:a,flex:`0 0 ${a}px`},children:[m?(0,I.jsx)(Wot,{}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Art,{activeChatId:f.chatId??null,onSelect:h,onNewChat:()=>void g(),newChatShortcut:v}),e?(0,I.jsx)(X,{variant:`ghost`,className:`m-2 justify-start`,asChild:!0,children:(0,I.jsx)(xs,{to:`/settings`,children:bje()})}):null]}),(0,I.jsx)(`div`,{className:`oc-sidebar-resizer`,onPointerDown:l,role:`separator`,"aria-orientation":`vertical`,"aria-label":Cje()})]}),(0,I.jsx)(`main`,{className:`oc-main`,children:(0,I.jsx)(Fs,{})})]})]})}function vst(){let e=P(V.me.getMe,{host:xO}),t=ss(),n=Gs({select:e=>e.pathname}),r=(0,N.useMemo)(()=>e?j7(e.permissions??[]):[],[e]),i=e!==void 0&&r.length===0;if((0,N.useEffect)(()=>{i&&t({to:`/`})},[i,t]),e===void 0)return(0,I.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:hQ()});if(i)return null;let a=N7(n),o=a!==void 0&&!r.includes(a);return(0,I.jsxs)(`div`,{className:`oc-admin`,children:[(0,I.jsx)(Uot,{}),(0,I.jsx)(`div`,{className:`oc-admin__body`,children:o?(0,I.jsx)(yst,{}):(0,I.jsx)(Fs,{})})]})}function yst(){return(0,I.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,I.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,I.jsx)(Hm,{size:28})}),(0,I.jsx)(`h2`,{className:`oc-route-error__title`,children:Eje()}),(0,I.jsx)(`p`,{className:`oc-route-error__body`,children:kje()})]})}function bst(){let e=P(V.me.getMe,{host:xO}),t=ss();return(0,N.useEffect)(()=>{if(e===void 0)return;let n=j7(e.permissions??[]);t({to:n.length>0?M7(n[0]):`/`,replace:!0})},[e,t]),(0,I.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:hQ()})}function xst(){let{tab:e}=as({from:`/settings/$tab`});switch(e){case`groups`:return(0,I.jsx)(Eat,{});case`integrations`:return(0,I.jsx)(sot,{});case`instances`:return(0,I.jsx)(Xit,{});case`bridge`:return(0,I.jsx)(Eit,{});case`theme`:return(0,I.jsx)(ust,{});case`feedbacks`:return(0,I.jsx)(uot,{});case`files`:return(0,I.jsx)(dot,{});case`agentFiles`:return(0,I.jsx)(got,{});case`preferences`:return(0,I.jsx)(Oot,{});case`chatDefaults`:return(0,I.jsx)(jot,{});case`access`:return(0,I.jsx)(Fot,{});default:return(0,I.jsx)(vat,{})}}function Sst(){let{chatId:e}=as({from:`/chat/$chatId`}),{m:t}=os({from:`/chat/$chatId`});return(0,I.jsx)(q3,{chatId:e,focusMessageId:t??null})}function Cst(){return(0,I.jsx)(q3,{chatId:null})}var Y9=Es({component:fst}),wst=ws({getParentRoute:()=>Y9,path:`/`,component:Cst}),Tst=ws({getParentRoute:()=>Y9,path:`chat/$chatId`,component:Sst,validateSearch:e=>({m:typeof e.m==`string`?e.m:void 0})}),X9=ws({getParentRoute:()=>Y9,path:`settings`,component:vst}),Est=ws({getParentRoute:()=>X9,path:`/`,component:bst}),Dst=ws({getParentRoute:()=>X9,path:`traces`,validateSearch:Rit,component:Iat}),Ost=ws({getParentRoute:()=>X9,path:`audit`,validateSearch:zit,component:oat}),kst=ws({getParentRoute:()=>X9,path:`anomalies`,validateSearch:Bit,component:tot}),Ast=ws({getParentRoute:()=>X9,path:`kpi`,validateSearch:Vit,component:Wat}),jst=ws({getParentRoute:()=>X9,path:`serviceAccounts`,validateSearch:Hit,component:lat}),Mst=ws({getParentRoute:()=>X9,path:`users`,validateSearch:Uit,component:qit}),Nst=ws({getParentRoute:()=>X9,path:`uiprefs`,beforeLoad:()=>{throw ia({to:`/settings/$tab`,params:{tab:Git.uiprefs},replace:!0})}}),Pst=ws({getParentRoute:()=>X9,path:`$tab`,parseParams:e=>({tab:Wp([...D7]).catch(`roles`).parse(e.tab)}),component:xst});function Fst({reset:e}){let t=ss();return(0,I.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,I.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,I.jsx)(Hm,{size:28})}),(0,I.jsx)(`h2`,{className:`oc-route-error__title`,children:Mje()}),(0,I.jsx)(`p`,{className:`oc-route-error__body`,children:Fje()}),(0,I.jsxs)(`div`,{className:`oc-route-error__actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>e(),children:Rje()}),(0,I.jsx)(`button`,{type:`button`,className:`oc-route-error__cta oc-route-error__cta--ghost`,onClick:()=>void t({to:`/`}),children:gQ()})]})]})}function Ist(){let e=ss();return(0,I.jsxs)(`div`,{className:`oc-route-error`,role:`status`,children:[(0,I.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,I.jsx)(Eee,{size:28})}),(0,I.jsx)(`h2`,{className:`oc-route-error__title`,children:Uje()}),(0,I.jsx)(`p`,{className:`oc-route-error__body`,children:Kje()}),(0,I.jsx)(`div`,{className:`oc-route-error__actions`,children:(0,I.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>void e({to:`/`}),children:gQ()})})]})}var Z9=Vs({routeTree:Y9.addChildren([wst,Tst,X9.addChildren([Est,Dst,Ost,kst,Ast,jst,Mst,Nst,Pst])]),defaultPreload:`intent`,defaultErrorComponent:Fst,defaultNotFoundComponent:Ist});async function Lst(){try{let e=await fetch(`/config.json`,{cache:`no-store`});if(e.ok){let t=(await e.json())?.convexUrl;if(typeof t==`string`&&t.trim())return t.trim()}}catch{}throw Error(`No Convex URL configured: serve /config.json {"convexUrl":"…"} (production) or set VITE_CONVEX_URL (local dev).`)}var Rst=()=>null;function Q9({children:e}){return(0,I.jsx)(`div`,{style:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,textAlign:`center`,font:`14px system-ui, sans-serif`,opacity:.6},children:e})}var $9=_r.createRoot(document.getElementById(`root`));$9.render((0,I.jsx)(N.StrictMode,{children:(0,I.jsx)(Q9,{children:`Chargement…`})})),Lst().then(e=>{let t=new Yn(e);$9.render((0,I.jsx)(N.StrictMode,{children:(0,I.jsx)(Lr,{client:t,children:(0,I.jsxs)(r4e,{children:[(0,I.jsx)(Zet,{children:(0,I.jsx)(Ws,{router:Z9})}),(0,I.jsx)(N.Suspense,{fallback:null,children:(0,I.jsx)(Rst,{router:Z9,position:`bottom-right`})})]})})}))}).catch(e=>{console.error(`Boot failed:`,e),$9.render((0,I.jsx)(N.StrictMode,{children:(0,I.jsxs)(Q9,{children:[`Configuration manquante\xA0:`,` `,e instanceof Error?e.message:String(e)]})}))});
164
+ `))n.set(e,(n.get(e)??0)-1);let r=0,i=0,a=[],o=[];for(let[e,t]of n)t<0?(r+=-t,a.length<O9&&a.push(e)):t>0&&(i+=t,o.length<O9&&o.push(e));return{added:r,removed:i,sampleAdded:a,sampleRemoved:o}}function hot(e){return e instanceof Error?e.message.includes(`conflict:`):String(e).includes(`conflict:`)}var k9=e=>`${e.instanceName}::${e.agentId}`;function got(){let e=P(V.me.getMe,{host:xO}),t=e?.role===`admin`,n=(e?.permissions??[]).includes(`bridge.read`),r=P(V.admin.listInstances,e!==void 0&&t?{}:`skip`),[i,a]=(0,N.useState)(null);(0,N.useEffect)(()=>{!t||!r||r.length===0||(!i||!r.some(e=>e.name===i))&&a(r[0].name)},[t,r,i]);let o=P(V.agents.listAgentsForInstance,t&&i?{instanceName:i}:`skip`),s=P(V.agents.listMyAgents,e!==void 0&&!t?{}:`skip`),c=(0,N.useMemo)(()=>{if(e!==void 0){if(t)return i===null||o===void 0?r!==void 0&&r.length===0?[]:void 0:o.agents.map(e=>({instanceName:i,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}));if(s!==void 0)return s.map(e=>({instanceName:e.instanceName,agentId:e.agentId,label:`${e.emoji?`${e.emoji} `:``}${e.displayName??e.agentId}`}))}},[e,t,i,o,r,s]),[l,u]=(0,N.useState)(null);(0,N.useEffect)(()=>{!c||c.length===0||(!l||!c.some(e=>k9(e)===l))&&u(k9(c[0]))},[c,l]);let d=c?.find(e=>k9(e)===l)??null,f=$n(V.agentFiles.listAgentFiles),[p,m]=(0,N.useState)({status:`idle`}),h=d?.instanceName??null,g=d?.agentId??null,_=P(V.compat.forInstance,n&&h!==null?{instanceName:h}:`skip`),v=n&&h!==null?F3(_,`agentFiles`):null,y=v===null?!1:v===`loading`?null:v.blocked,b=(0,N.useCallback)(async()=>{if(!(h===null||g===null)){m({status:`loading`});try{m({status:`done`,files:(await f({instanceName:h,agentId:g})).files})}catch{m({status:`error`})}}},[f,h,g]);(0,N.useEffect)(()=>{y===!1&&b()},[b,y]);let[x,S]=(0,N.useState)(null),C=q(),w=(0,N.useMemo)(()=>new Intl.NumberFormat(C,{maximumFractionDigits:0}),[C]);return e===void 0||c===void 0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):(0,I.jsxs)(`div`,{className:`oc-afiles`,children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:IQe()}),(0,I.jsxs)(`div`,{className:`oc-afiles__picker`,children:[t&&(r?.length??0)>1?(0,I.jsxs)(C3,{value:i??``,onValueChange:e=>a(e),children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":e$(),children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:(r??[]).map(e=>(0,I.jsx)(Q,{value:e.name,children:e.name},e.name))})]}):null,c.length>0?(0,I.jsxs)(C3,{value:l??``,onValueChange:e=>u(e),children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":VQe(),children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:c.map(e=>(0,I.jsx)(Q,{value:k9(e),children:e.label},k9(e)))})]}):(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:WQe()})]}),d===null?null:v===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):v!==null&&v.blocked?(0,I.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,I.jsx)(Hm,{size:14,"aria-hidden":!0}),` `,G5(v.gatewayVersion)]}):p.status===`loading`||p.status===`idle`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):p.status===`error`?(0,I.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[XQe(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void b(),children:ZQ()})]}):p.files.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:qQe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`oc-afiles__list`,children:p.files.map(e=>{let n=fot(e.size),r=n>=80;return(0,I.jsxs)(`div`,{className:`oc-afiles__row`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__name`,title:e.name,children:e.name}),e.missing?(0,I.jsx)($,{variant:`outline`,children:$Qe()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`oc-afiles__size`,children:n$e({size:E9(e.size,C)})}),(0,I.jsx)(`span`,{className:`oc-afiles__gauge${r?` is-warn`:``}`,"aria-hidden":!0,children:(0,I.jsx)(`span`,{className:`oc-afiles__gauge-fill`,style:{width:`${Math.min(n,100)}%`}})}),(0,I.jsx)(`span`,{className:`oc-afiles__pct`,children:a$e({pct:w.format(n)})}),r?(0,I.jsx)(Hm,{size:14,className:`oc-afiles__warn`,"aria-label":c$e()}):(0,I.jsx)(`span`,{className:`oc-afiles__warn-slot`,"aria-hidden":!0})]}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,className:`oc-afiles__open`,onClick:()=>S(e),children:t?m$e():_$e()})]},e.name)})}),(0,I.jsx)(`p`,{className:`oc-afiles__budget`,children:d$e({used:E9(D9(p.files),C),total:E9(T9,C),pct:w.format(pot(D9(p.files)))})})]}),x&&d?(0,I.jsx)(_ot,{instanceName:d.instanceName,agentId:d.agentId,name:x.name,isAdmin:t,onClose:()=>S(null),onSaved:()=>void b()}):null]})}function _ot({instanceName:e,agentId:t,name:n,isAdmin:r,onClose:i,onSaved:a}){let o=$n(V.agentFiles.getAgentFile),s=$n(V.agentFiles.setAgentFile),c=D1(),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(!1),[p,m]=(0,N.useState)(``),[h,g]=(0,N.useState)(!1),[_,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(!1),[x,S]=(0,N.useState)(!1),C=(0,N.useCallback)(async r=>{f(!1);try{let i=await o({instanceName:e,agentId:t,name:n});u({content:i.content,updatedAtMs:i.updatedAtMs}),r||m(i.content),b(!1)}catch{f(!0)}},[o,e,t,n]);(0,N.useEffect)(()=>{C(!1)},[C]);async function w(){if(l!==null){v(!0),S(!1);try{await s({instanceName:e,agentId:t,name:n,content:p,baseUpdatedAtMs:l.updatedAtMs??void 0}),c.success(L$e({name:n})),a(),await C(!1)}catch(e){hot(e)?b(!0):S(!0)}finally{v(!1)}}}let T=l!==null&&p!==l.content,E=(0,N.useMemo)(()=>l===null?null:mot(l.content,p),[l,p]),D=p.length>w9,O=q(),ee=(0,N.useMemo)(()=>new Intl.NumberFormat(O),[O]);return(0,I.jsx)(h1,{open:!0,onOpenChange:e=>!e&&i(),children:(0,I.jsxs)(g1,{className:`oc-afiles__editor`,children:[(0,I.jsxs)(_1,{children:[(0,I.jsx)(y1,{children:t$({name:n})}),(0,I.jsxs)(b1,{children:[S$e({agent:t,instance:e}),r?null:(0,I.jsxs)(I.Fragment,{children:[` · `,T$e()]})]})]}),d?(0,I.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[U$e(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void C(!1),children:ZQ()})]}):l===null?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`textarea`,{className:`oc-afiles__source`,value:p,readOnly:!r,spellCheck:!1,onChange:e=>m(e.target.value),"aria-label":t$({name:n})}),(0,I.jsx)(`p`,{className:`oc-afiles__hint`,children:O$e()}),y?(0,I.jsxs)(`p`,{className:`oc-afiles__error`,role:`alert`,children:[K$e(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void C(!0),children:Y$e()})]}):null,x?(0,I.jsx)(`p`,{className:`oc-afiles__error`,role:`alert`,children:B$e()}):null,(0,I.jsxs)(`div`,{className:`oc-afiles__editor-foot`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__count${D?` is-over`:``}`,children:j$e({count:ee.format(p.length),max:ee.format(w9)})}),r?(0,I.jsx)(X,{size:`sm`,disabled:!T||_||y,onClick:()=>g(!0),children:_?XQ():P$e()}):null]})]}),(0,I.jsx)(s1,{open:h,onOpenChange:g,children:(0,I.jsxs)(c1,{children:[(0,I.jsxs)(l1,{children:[(0,I.jsx)(d1,{children:Q$e({name:n})}),(0,I.jsx)(f1,{children:t1e({agent:t})})]}),E?(0,I.jsxs)(`div`,{className:`oc-afiles__diff`,children:[(0,I.jsx)(`p`,{className:`oc-afiles__diff-counts`,children:i1e({added:E.added,removed:E.removed})}),E.sampleAdded.length>0?(0,I.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__diff-label`,children:s1e()}),E.sampleAdded.map((e,t)=>(0,I.jsx)(`code`,{className:`oc-afiles__diff-line is-add`,children:e||` `},t))]}):null,E.sampleRemoved.length>0?(0,I.jsxs)(`div`,{className:`oc-afiles__diff-block`,children:[(0,I.jsx)(`span`,{className:`oc-afiles__diff-label`,children:u1e()}),E.sampleRemoved.map((e,t)=>(0,I.jsx)(`code`,{className:`oc-afiles__diff-line is-del`,children:e||` `},t))]}):null]}):null,(0,I.jsxs)(u1,{children:[(0,I.jsx)(m1,{children:pW()}),(0,I.jsx)(p1,{onClick:()=>void w(),children:p1e()})]})]})})]})})}var A9=[{id:`messages`,label:()=>SI()},{id:`composer`,label:()=>TI()},{id:`sidebar`,label:()=>OI()},{id:`other`,label:()=>jI()}],j9={showSource:{category:`messages`,label:()=>PI(),help:()=>LI()},showReport:{category:`messages`,label:()=>BI(),help:()=>UI()},copyAssistant:{category:`messages`,label:()=>KI()},copyUser:{category:`messages`,label:()=>YI()},showDelete:{category:`messages`,label:()=>QI()},showTools:{category:`messages`,label:()=>tL(),help:()=>iL()},voiceInput:{category:`composer`,label:()=>sL(),help:()=>uL()},showChatAge:{category:`sidebar`,label:()=>pL(),help:()=>gL()},showChatProvider:{category:`sidebar`,label:()=>yL(),help:()=>SL()}};function M9(e){return e.toLowerCase().normalize(`NFD`).replace(/\p{Diacritic}/gu,``)}function vot(e,t){let n=M9(t.trim()),r=new Map(A9.map(e=>[e.id,e.label()])),i=new Map(A9.map(e=>[e.id,[]]));for(let t of e){let e=j9[t],a=e?.category??`other`;n&&!M9(`${e?e.label():t} ${e?.help?e.help():``} ${t} ${r.get(a)??``}`).includes(n)||i.get(a).push(t)}return A9.map(e=>({id:e.id,label:r.get(e.id),keys:i.get(e.id)})).filter(e=>e.keys.length>0)}var yot=[`showSource`,`showReport`,`copyAssistant`,`copyUser`,`showDelete`,`showTools`,`voiceInput`,`showChatAge`,`showChatProvider`],bot={voiceInput:`voiceInput`};function xot(e){return yot.includes(e)}function N9(e){return e===`admin`}function Sot(e){return e===!0?`on`:e===!1?`off`:`inherit`}function Cot(e){return e===`on`?!0:e===`off`?!1:null}function wot(e){return xot(e)?bot[e]:void 0}var Tot={voiceInput:()=>tR()};function Eot({prefKey:e,ui:t}){let n=F(V.admin.setUiPrefDefault),r=F(V.admin.setFeatureEnabled),i=wot(e),a=i?Tot[e]?.():void 0;return(0,I.jsxs)(`div`,{className:`oc-prefs__gov`,children:[(0,I.jsxs)(`div`,{className:`oc-prefs__gov-row`,children:[(0,I.jsx)(`span`,{className:`oc-prefs__gov-label`,children:UL()}),(0,I.jsxs)(C3,{value:Sot(t.defaults[e]),onValueChange:t=>void n({key:e,value:Cot(t)}),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-36`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`on`,children:sR()}),(0,I.jsx)(Q,{value:`off`,children:uR()}),(0,I.jsx)(Q,{value:`inherit`,children:pR()})]})]}),i?(0,I.jsxs)(`span`,{className:`oc-prefs__gov-gate`,children:[(0,I.jsx)(A1,{checked:t.featuresEnabled[i]===!0,onCheckedChange:e=>void r({key:i,enabled:e===!0}),"aria-label":KL()}),KL()]}):null]}),a?(0,I.jsx)(`span`,{className:`oc-prefs__gov-help`,children:a}):null]})}function Dot(){let[e,t]=(0,N.useState)(``),[n,r]=(0,N.useState)(!1),i=P(V.me.getMe,{host:xO}),a=i?.ui,o=N9(i?.role)&&n,s=F(V.me.setUiPref).withOptimisticUpdate(O1),c=(0,N.useMemo)(()=>a?vot(Object.keys(a.effective),e):[],[a,e]);return a?(0,I.jsxs)(`div`,{className:`oc-prefs-panel`,children:[N9(i?.role)?(0,I.jsxs)(`label`,{className:`oc-prefs__gov-toggle`,children:[(0,I.jsx)(A1,{checked:n,onCheckedChange:e=>r(e===!0),"aria-label":BL()}),BL()]}):null,o?(0,I.jsxs)(`div`,{className:`oc-prefs__gov-head`,children:[(0,I.jsx)(`p`,{children:YL()}),(0,I.jsx)(`p`,{children:QL()}),(0,I.jsx)(`p`,{children:iR()})]}):null,(0,I.jsx)(o1,{value:e,onChange:e=>t(e.target.value),placeholder:TL(),"aria-label":TL(),className:`mb-2`}),c.length===0?(0,I.jsx)(`div`,{className:`oc-prefs__empty`,children:OL()}):(0,I.jsx)(`div`,{className:`oc-prefs`,children:c.map(e=>(0,I.jsxs)(`div`,{className:`oc-prefs__group`,children:[(0,I.jsx)(`h4`,{className:`oc-prefs__cat`,children:e.label}),e.keys.map(e=>{let t=j9[e],n=t?t.label():e,r=t?.help?.(),i=a.locked[e],c=a.effective[e],l=a.userOverrides[e]!==void 0;return(0,I.jsxs)(`div`,{className:`oc-prefs__row${i?` is-locked`:``}${l&&!i?` is-overridden`:``}`,children:[(0,I.jsxs)(`div`,{className:`oc-prefs__info`,children:[(0,I.jsxs)(`span`,{className:`oc-prefs__label`,children:[n,i?(0,I.jsx)(`span`,{className:`oc-prefs__lock`,children:jL()}):l?null:(0,I.jsx)(`span`,{className:`oc-prefs__def`,children:PL()})]}),r?(0,I.jsx)(`span`,{className:`oc-prefs__help`,children:r}):null]}),(0,I.jsxs)(`div`,{className:`oc-prefs__ctl`,children:[!i&&l?(0,I.jsx)(`button`,{type:`button`,className:`oc-prefs__reset`,onClick:()=>void s({key:e,value:null}),children:LL()}):null,(0,I.jsx)(A1,{checked:c,disabled:i,onCheckedChange:t=>void s({key:e,value:t===!0}),"aria-label":n})]}),o?(0,I.jsx)(Eot,{prefKey:e,ui:a}):null]},e)})]},e.id))})]}):(0,I.jsx)(`div`,{className:`oc-prefs__empty`,children:KO()})}function Oot(){let e=P(V.me.getMe,{host:xO}),t=F(V.me.setLocale),n=F(V.me.setMyName),r=D1(),i=e?.locale??`default`,a=e?.name??``,[o,s]=(0,N.useState)(null),c=o??a,l=c.trim()!==a.trim();async function u(){try{await n({name:c}),s(null),r.success(Ok())}catch(e){r.error(jk(),e)}}return(0,I.jsxs)(`div`,{className:`oc-appearance`,children:[(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:gk()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:yk()})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(o1,{className:`max-w-xs`,value:c,maxLength:120,placeholder:Sk(),onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&l&&(e.preventDefault(),u())}}),(0,I.jsx)(X,{size:`sm`,disabled:!l,onClick:()=>void u(),children:QZ()})]}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Tk()})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:Pk()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Lk()})]}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`,`default`].map(e=>(0,I.jsx)(X,{variant:i===e?`default`:`outline`,size:`sm`,onClick:()=>void t({locale:e==="default"?null:e}),children:e===`fr`?Yk():e===`en`?Qk():sk()},e))}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Bk()})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:Uk()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:Kk()})]}),(0,I.jsx)(Dot,{})]})]})}var kot=[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`];function Aot(e){let t=typeof e==`object`&&e?e:{},n=t.defaults!==null&&typeof t.defaults==`object`?t.defaults:{},r=n.thinkingDefault??t.thinkingDefault,i=n.fastModeDefault??t.fastModeDefault;return{thinkingDefault:typeof r==`string`?r:null,fastModeDefault:typeof i==`boolean`?i:null}}function jot(){let e=$n(V.agentFiles.getChatDefaults),t=$n(V.agentFiles.setChatDefaults),n=D1(),[r,i]=(0,N.useState)({status:`loading`}),[a,o]=(0,N.useState)({thinkingDefault:null,fastModeDefault:null}),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1),d=P(V.admin.listInstances,{}),[f,p]=(0,N.useState)(null);(0,N.useEffect)(()=>{!d||d.length===0||(!f||!d.some(e=>e.name===f))&&p(d[0].name)},[d,f]);let m=(d?.length??0)>1,h=d!==void 0&&d.length===0,g=P(V.compat.forInstance,f?{instanceName:f}:`skip`),_=f?F3(g,`configDefaults`):`loading`,v=_===`loading`?null:_.blocked,y=(0,N.useMemo)(()=>m&&f?{instanceName:f}:{},[m,f]),b=(0,N.useRef)(0),x=(0,N.useCallback)(async()=>{let t=++b.current;i({status:`loading`});try{let n=Aot(await e(y));if(b.current!==t)return;i({status:`done`,current:n}),o(n)}catch{if(b.current!==t)return;i({status:`error`})}},[e,y]);(0,N.useEffect)(()=>{v===!1&&(m&&!f||x())},[x,v,m,f]);let S=r.status===`done`?r.current:null,C=S!==null&&a.thinkingDefault!==null&&a.thinkingDefault!==S.thinkingDefault,w=S!==null&&a.fastModeDefault!==null&&a.fastModeDefault!==S.fastModeDefault,T=C||w;async function E(){u(!0);try{await t({...y,...C?{thinkingDefault:a.thinkingDefault}:{},...w?{fastModeDefault:a.fastModeDefault}:{}}),n.success(B1e()),await x()}catch(e){n.error(U1e(),e)}finally{u(!1)}}let D=(0,N.useMemo)(()=>kot.map(e=>({id:e,label:M3(e)})),[]),O=(0,N.useMemo)(()=>[{id:`fast`,label:QQ()},{id:`standard`,label:$Q()}],[]);return(0,I.jsxs)(`div`,{className:`oc-cdefaults`,children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:y1e()}),m&&f?(0,I.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,I.jsx)(`span`,{className:`oc-cdefaults__label`,children:e$()}),(0,I.jsxs)(C3,{value:f,onValueChange:e=>p(e),disabled:l,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":e$(),children:(0,I.jsx)(w3,{})}),(0,I.jsx)(E3,{children:(d??[]).map(e=>(0,I.jsx)(Q,{value:e.name,children:e.name},e.name))})]})]}):null,h?(0,I.jsx)(`p`,{className:`oc-admin__hint`,role:`status`,children:BMe()}):_===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):_.blocked?(0,I.jsxs)(`p`,{className:`oc-compat__blocked`,role:`status`,children:[(0,I.jsx)(Hm,{size:14,"aria-hidden":!0}),` `,G5(_.gatewayVersion)]}):r.status===`loading`?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):r.status===`error`?(0,I.jsxs)(`p`,{className:`oc-cdefaults__error`,role:`alert`,children:[P1e(),` `,(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void x(),children:ZQ()})]}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,I.jsx)(`span`,{className:`oc-cdefaults__label`,children:S1e()}),(0,I.jsx)(R3,{options:D,value:a.thinkingDefault,onChange:e=>o({...a,thinkingDefault:e}),disabled:l}),(0,I.jsx)(`p`,{className:`oc-cdefaults__help`,children:T1e()})]}),(0,I.jsxs)(`div`,{className:`oc-cdefaults__row`,children:[(0,I.jsx)(`span`,{className:`oc-cdefaults__label`,children:O1e()}),(0,I.jsx)(R3,{options:O,value:a.fastModeDefault===null?null:a.fastModeDefault?`fast`:`standard`,onChange:e=>o({...a,fastModeDefault:e===`fast`}),disabled:l}),(0,I.jsx)(`p`,{className:`oc-cdefaults__help`,children:j1e()})]}),(0,I.jsx)(`div`,{className:`oc-cdefaults__actions`,children:(0,I.jsx)(X,{size:`sm`,disabled:!T||l,onClick:()=>c(!0),children:l?XQ():L1e()})}),(0,I.jsx)(`p`,{className:`oc-cdefaults__note`,children:K1e()})]}),(0,I.jsx)(s1,{open:s,onOpenChange:c,children:(0,I.jsxs)(c1,{children:[(0,I.jsxs)(l1,{children:[(0,I.jsx)(d1,{children:Y1e()}),(0,I.jsx)(f1,{children:Q1e()})]}),(0,I.jsxs)(u1,{children:[(0,I.jsx)(m1,{children:pW()}),(0,I.jsx)(p1,{onClick:()=>void E(),children:t0e()})]})]})})]})}function Mot(e){return e===`user`?NKe():e===`all`?IKe():IQ({group:e.group})}function Not(e){return e===`common`?VKe():e===`owner`?WKe():IQ({group:e.group})}function Pot(e){return e.name||e.email||e.userId.slice(0,8)}function Fot(){let e=P(V.admin.listUsers,{}),[t,n]=(0,N.useState)(``),r=P(V.introspect.introspectUser,t?{userId:t}:`skip`);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:aKe()}),(0,I.jsxs)(C3,{value:t,onValueChange:n,children:[(0,I.jsx)(T3,{size:`sm`,"aria-label":PQ(),children:(0,I.jsx)(w3,{placeholder:PQ()})}),(0,I.jsx)(E3,{children:(e??[]).map(e=>(0,I.jsx)(Q,{value:e.userId,children:Pot(e)},e._id))})]}),t===``?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:uKe()}):r===void 0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:KO()}):(0,I.jsxs)(`div`,{className:`oc-introspect`,children:[(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:pKe()}),(0,I.jsxs)(`div`,{className:`oc-introspect__id`,children:[(0,I.jsx)(`strong`,{children:r.user.label}),(0,I.jsx)($,{variant:`secondary`,children:r.role})]})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:gKe()}),r.groups.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`div`,{className:`oc-introspect__chips`,children:r.groups.map(e=>(0,I.jsx)($,{variant:`secondary`,children:e.name},e.groupId))})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:yKe()}),r.agents.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`ul`,{className:`oc-introspect__list`,children:r.agents.map(e=>(0,I.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,I.jsx)(`span`,{className:`oc-introspect__name`,children:e.displayName||e.agentId}),e.isDefault?(0,I.jsx)($,{variant:`default`,children:AKe()}):null,(0,I.jsx)($,{variant:`outline`,children:Mot(e.via)}),(0,I.jsx)($,{variant:`secondary`,children:e.state})]},`${e.instanceName} ${e.agentId}`))})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:SKe()}),r.charts.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`ul`,{className:`oc-introspect__list`,children:r.charts.map(e=>(0,I.jsxs)(`li`,{className:`oc-introspect__row`,children:[(0,I.jsx)(`span`,{className:`oc-introspect__name`,children:e.name}),(0,I.jsx)($,{variant:`outline`,children:Not(e.via)})]},e.key))})]}),(0,I.jsxs)(`section`,{className:`oc-introspect__section`,children:[(0,I.jsx)(`h3`,{className:`oc-introspect__title`,children:TKe()}),r.permissions.length===0?(0,I.jsx)(`p`,{className:`oc-admin__hint`,children:FQ()}):(0,I.jsx)(`div`,{className:`oc-introspect__chips`,children:r.permissions.map(e=>(0,I.jsx)($,{variant:`secondary`,children:e},e))})]})]})]})}var P9=[{id:`personal`,label:()=>wXe(),tabs:[`preferences`,`theme`,`files`]},{id:`agents`,label:()=>DXe(),tabs:[`instances`,`agentFiles`,`chatDefaults`,`bridge`]},{id:`access`,label:()=>AXe(),tabs:[`users`,`groups`,`access`,`roles`,`serviceAccounts`]},{id:`observability`,label:()=>NXe(),tabs:[`traces`,`kpi`,`anomalies`,`audit`,`feedbacks`,`integrations`]}],Iot=new Map(P9.flatMap(e=>e.tabs.map(t=>[t,e.id])));function F9(e){let t=Iot.get(e);if(!t)throw Error(`Settings tab "${e}" belongs to no group`);return t}function Lot(e,t){return e.find(e=>F9(e)===t)}P9.flatMap(e=>[...e.tabs]);function Rot(){let e=P(V.bridgeHealth.getBridgeAvailability,{});if(e===void 0)return null;let t=e.known?e.available?`ok`:`error`:`idle`,n=e.known?e.available?`${eBe()}${e.checkedAt?rBe({time:new Date(e.checkedAt).toLocaleTimeString(`fr-FR`)}):``}`:oBe({reason:e.reason??`?`}):Zze();return(0,I.jsx)(M5,{delayDuration:150,children:(0,I.jsxs)(N5,{children:[(0,I.jsx)(P5,{asChild:!0,children:(0,I.jsx)(`span`,{className:`oc-bridge-dot oc-bridge-dot--${t}`,role:`img`,"aria-label":n})}),(0,I.jsx)(F5,{children:n})]})})}var zot={users:()=>bGe(),groups:()=>$Ge(),instances:()=>CGe(),bridge:()=>EGe(),serviceAccounts:()=>kGe(),roles:()=>MGe(),traces:()=>FGe(),kpi:()=>RGe(),anomalies:()=>VGe(),files:()=>tA(),agentFiles:()=>NQe(),preferences:()=>pk(),chatDefaults:()=>g1e(),access:()=>nKe(),integrations:()=>WGe(),theme:()=>iM(),audit:()=>qGe(),feedbacks:()=>XGe()};function I9(e){let t=new Set(D7),n=new Set,r=[];for(let i of e??[])t.has(i)&&!n.has(i)&&(r.push(i),n.add(i));for(let e of D7)n.has(e)||r.push(e);return r}function Bot(e,t){let n=new Set(t),r=[...t];return e.map(e=>n.has(e)?r.shift():e)}function Vot({tab:e,active:t}){let n=zot[e]?.()??k7[e]??e,r=`oc-settings-tabs__tab`+(t?` is-active`:``),i=(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`oc-settings-tabs__label`,children:n}),e===`bridge`?(0,I.jsx)(Rot,{}):null]});return O7.includes(e)?(0,I.jsx)(xs,{to:`/settings/$tab`,params:{tab:e},className:r,role:`tab`,"aria-selected":t,children:i}):(0,I.jsx)(xs,{to:`/settings/${e}`,className:r,role:`tab`,"aria-selected":t,children:i})}function Hot({tab:e,active:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=J8({id:e});return(0,I.jsxs)(`div`,{ref:i,style:{transform:w6.Transform.toString(a),transition:o,opacity:s?.5:1},className:`oc-settings-tabs__item`,role:`presentation`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-settings-tabs__grip`,"aria-label":fXe(),...n,...r,children:(0,I.jsx)(Sm,{size:14,"aria-hidden":!0})}),(0,I.jsx)(Vot,{tab:e,active:t})]})}function Uot(){let e=P(V.me.getMe,{host:xO}),t=F(V.me.setSettingsTabOrder),n=P7(Gs({select:e=>e.pathname})),r=n===void 0?void 0:F9(n),i=(0,N.useMemo)(()=>I9(e?.settingsTabOrder??null),[e?.settingsTabOrder]),[a,o]=(0,N.useState)(i);(0,N.useEffect)(()=>o(i),[i]);let s=(0,N.useMemo)(()=>new Set(M7(e?.permissions??[])),[e?.permissions]),c=(0,N.useMemo)(()=>r===void 0?[]:a.filter(e=>s.has(e)&&F9(e)===r),[a,s,r]),l=A6(k6(u8,{activationConstraint:{distance:5}}),k6(o8,{coordinateGetter:X8}));if(r===void 0||c.length===0)return null;let u=P9.find(e=>e.id===r);function d(e){let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=c.indexOf(n.id),s=c.indexOf(r.id);if(i<0||s<0)return;let l=Bot(a,z8(c,i,s));o(l),t({order:l})}return(0,I.jsx)(`div`,{className:`oc-settings-tabs`,role:`tablist`,"aria-label":u?.label(),children:(0,I.jsx)(P8,{sensors:l,collisionDetection:Qtt,modifiers:[crt],onDragEnd:d,children:(0,I.jsx)(K8,{items:c,strategy:hrt,children:c.map(e=>(0,I.jsx)(Hot,{tab:e,active:e===n},e))})})})}function Wot(){let e=P(V.me.getMe,{host:xO}),t=ss(),n=P7(Gs({select:e=>e.pathname})),r=n===void 0?void 0:F9(n),i=(0,N.useMemo)(()=>new Set(M7(e?.permissions??[])),[e?.permissions]),a=(0,N.useMemo)(()=>I9(e?.settingsTabOrder??null).filter(e=>i.has(e)),[e?.settingsTabOrder,i]),o=P9.filter(e=>e.tabs.some(e=>i.has(e)));function s(e){let n=Lot(a,e.id);n&&t({to:N7(n)})}return(0,I.jsxs)(`nav`,{className:`oc-settings-nav`,"aria-label":hXe(),children:[(0,I.jsx)(xs,{to:`/`,className:`oc-settings-nav__back`,children:vXe()}),(0,I.jsx)(`div`,{className:`oc-settings-nav__title`,children:xXe()}),(0,I.jsx)(`div`,{className:`oc-settings-nav__list`,children:o.map(e=>(0,I.jsx)(`button`,{type:`button`,className:`oc-settings-nav__group`+(e.id===r?` is-active`:``),"aria-current":e.id===r?`true`:void 0,onClick:()=>s(e),children:e.label()},e.id))})]})}var Got=12*1024*1024,Kot=480,qot=160,Jot=.92;async function Yot(e,t={}){if(!e.type.startsWith(`image/`))throw Error(iF());if(e.size>Got)throw Error(sF());let{source:n,width:r,height:i,cleanup:a}=await Xot(e);try{let a=e.type===`image/svg+xml`,o=Math.min(Kot/r,qot/i,a?1/0:1),s=Math.max(1,Math.round(r*o)),c=Math.max(1,Math.round(i*o)),l=document.createElement(`canvas`);l.width=s,l.height=c;let u=l.getContext(`2d`);if(!u)throw Error(pF());if(u.imageSmoothingEnabled=!0,u.imageSmoothingQuality=`high`,u.drawImage(n,0,0,s,c),t.invert){let e=u.getImageData(0,0,s,c),t=e.data;for(let e=0;e<t.length;e+=4)t[e]=255-t[e],t[e+1]=255-t[e+1],t[e+2]=255-t[e+2];u.putImageData(e,0,0)}let d=await R9(l,`image/webp`,Jot)??await R9(l,`image/png`);if(!d)throw Error(gF());return d}finally{a()}}async function Xot(e){if(e.type===`image/svg+xml`)return L9(e);if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e);return{source:t,width:t.width,height:t.height,cleanup:()=>t.close()}}catch{}return L9(e)}async function L9(e){let t=URL.createObjectURL(e);try{let e=new Image;return e.decoding=`async`,await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(uF())),e.src=t}),{source:e,width:e.naturalWidth||300,height:e.naturalHeight||150,cleanup:()=>URL.revokeObjectURL(t)}}catch(e){throw URL.revokeObjectURL(t),e}}function R9(e,t,n){return new Promise(r=>e.toBlob(e=>r(e),t,n))}var z9=`__all__`,B9={kind:`relative`,from:`now-24h`,to:`now`},Zot=[{value:`status`,label:`Statut`},{value:`latencyMs`,label:`Latence (ms)`},{value:`route`,label:`Route`},{value:`roleKey`,label:`Rôle`},{value:`correlationId`,label:`Corrélation`}];function V9({title:e,description:t,children:n}){return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:e}),t?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:t}):null]}),(0,I.jsx)(`div`,{className:`oc-show__demo`,children:n})]})}function Qot(e){return e===`light`?QO():e===`dark`?tk():ik()}var $ot=[`primary`,`secondary`,`accent`,`muted`,`chart-1`,`chart-2`];function est({tokens:e,mode:t}){let n=e.colors[t];return(0,I.jsx)(`div`,{className:`oc-chart-swatches`,"aria-hidden":!0,children:$ot.map(e=>{let t=n[e];return(0,I.jsx)(`span`,{className:`oc-chart-swatch`,style:t?{background:t}:void 0},e)})})}function H9({selected:e,title:t,subtitle:n,tokens:r,mode:i,onSelect:a}){return(0,I.jsxs)(`button`,{type:`button`,className:G$(`oc-chart-card`,e&&`oc-chart-card--selected`),"aria-pressed":e,onClick:a,children:[(0,I.jsxs)(`div`,{className:`oc-chart-card__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-card__title`,children:t}),e?(0,I.jsx)(um,{className:`size-4 text-primary`,"aria-hidden":!0}):null]}),r?(0,I.jsx)(est,{tokens:r,mode:i}):(0,I.jsx)(`div`,{className:`oc-chart-swatches oc-chart-swatches--native`,"aria-hidden":!0}),(0,I.jsx)(`div`,{className:`oc-chart-card__meta`,children:(0,I.jsx)(`span`,{className:`oc-chart-card__subtitle`,children:n})})]})}function tst({selectedKey:e,resolvedMode:t}){let n=P(V.charts.listMyCharts),r=F(V.charts.setMyChart);async function i(e){try{await r({name:e})}catch{}}return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:jM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:PM()})]}),(0,I.jsxs)(`div`,{className:`oc-chart-grid`,children:[(0,I.jsx)(H9,{selected:e===null,title:LM(),subtitle:BM(),tokens:null,mode:t,onSelect:()=>void i(null)}),(n??[]).map(n=>{let r=n.via===`common`?UM():n.via===`owner`?KM():YM({group:n.via.group});return(0,I.jsx)(H9,{selected:e===n.key,title:n.name,subtitle:r,tokens:n.tokens,mode:t,onSelect:()=>void i(n.key)},n.key)})]}),n!==void 0&&n.length===0?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:QM()}):null]})}function nst(){let e=F(V.charts.importChart),[t,n]=(0,N.useState)(``),[r,i]=(0,N.useState)(``),[a,o]=(0,N.useState)(null),[s,c]=(0,N.useState)(!1),[l,u]=(0,N.useState)(!1);async function d(e){let t=e.target.files?.[0];if(e.target.value=``,t){o(null),c(!1);try{i(await t.text())}catch{o(uP())}}}async function f(){if(o(null),c(!1),t.trim()===``){o(gP());return}let a;try{a=JSON.parse(r)}catch{o(uP());return}u(!0);try{await e({name:t.trim(),tokens:a}),c(!0),n(``),i(``)}catch(e){o(e instanceof Error?e.message:String(e))}finally{u(!1)}}return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:BN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:UN()})]}),(0,I.jsxs)(`div`,{className:`oc-chart-import`,children:[(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:KN()}),(0,I.jsx)(o1,{value:t,onChange:e=>n(e.target.value),placeholder:YN(),maxLength:60})]}),(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:QN()}),(0,I.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:r,onChange:e=>i(e.target.value),placeholder:tP(),rows:8,spellCheck:!1})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{variant:`outline`,size:`sm`,asChild:!0,children:(0,I.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,I.jsx)(Um,{className:`size-4`}),iP(),(0,I.jsx)(`input`,{type:`file`,accept:`application/json,.json`,className:`oc-chart-import__file-input`,onChange:e=>void d(e)})]})}),(0,I.jsx)(X,{size:`sm`,disabled:l,onClick:()=>void f(),children:sP()})]}),a?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null,s?(0,I.jsx)(`p`,{className:`oc-chart-import__ok`,children:pP()}):null]})]})}function rst({chart:e}){let t=$n(V.charts.setChartLogo),n=F(V.charts.removeChartLogo),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(null),s=t=>t===`light`?e.logoLightUrl:e.logoDarkUrl;async function c(n,r,a=!1){if(e.chartId!==void 0){o(null),i(!0);try{let i=await(await Yot(r,{invert:a})).arrayBuffer();await t({chartId:e.chartId,bytes:i,mode:n})}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function l(e,t){let n=t.target.files?.[0];t.target.value=``,n&&await c(e,n)}async function u(t){if(e.chartId!==void 0){o(null),i(!0);try{await n({chartId:e.chartId,mode:t})}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}async function d(e){let t=s(e===`light`?`dark`:`light`);if(t){o(null),i(!0);try{await c(e,await(await fetch(t)).blob(),!0)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}}}function f({mode:e}){let t=s(e),n=s(e===`light`?`dark`:`light`);return(0,I.jsxs)(`div`,{className:`oc-chart-mine__logo-slot`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__logo-mode`,children:e===`light`?LP():BP()}),(0,I.jsx)(`span`,{className:`oc-chart-mine__logo-preview`,"data-mode":e,"data-empty":t?void 0:`1`,children:t?(0,I.jsx)(`img`,{src:t,alt:``}):null}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,asChild:!0,children:(0,I.jsxs)(`label`,{className:`oc-chart-import__file`,children:[(0,I.jsx)(Um,{className:`size-4`}),t?KP():UP(),(0,I.jsx)(`input`,{type:`file`,accept:`image/*`,className:`oc-chart-import__file-input`,onChange:t=>void l(e,t)})]})}),!t&&n?(0,I.jsx)(X,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void d(e),children:QP()}):null,t?(0,I.jsx)(X,{variant:`ghost`,size:`sm`,disabled:r,onClick:()=>void u(e),children:YP()}):null]})}return(0,I.jsxs)(`div`,{className:`oc-chart-mine__logo`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:PP()}),(0,I.jsxs)(`div`,{className:`oc-chart-mine__logo-slots`,children:[(0,I.jsx)(f,{mode:`light`}),(0,I.jsx)(f,{mode:`dark`})]}),r?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:tF()}):null,a?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:a}):null]})}function U9({chart:e}){let t=P(V.me.getMe,{host:xO}),n=F(V.charts.addChartDomain),r=F(V.charts.removeChartDomain),[i,a]=(0,N.useState)(``),[o,s]=(0,N.useState)(null),[c,l]=(0,N.useState)(!1);if(t?.role!==`admin`)return null;let u=e.domains??[];async function d(){let t=i.trim();if(t!==``){s(null),l(!0);try{await n({chartKey:e.key,domain:t}),a(``)}catch(e){s(e instanceof Error?e.message:String(e))}finally{l(!1)}}}async function f(t){s(null);try{await r({chartKey:e.key,domain:t})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-mine__domains`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:yF()}),(0,I.jsxs)(`div`,{className:`oc-chart-mine__domains-body`,children:[(0,I.jsx)(`div`,{className:`oc-chart-avail__groups`,children:u.length===0?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:jF()}):u.map(e=>(0,I.jsxs)($,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e,(0,I.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":PF({domain:e}),onClick:()=>void f(e),children:(0,I.jsx)(Km,{className:`size-3`})})]},e))}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(o1,{value:i,onChange:e=>a(e.target.value),placeholder:TF(),className:`oc-chart-mine__domains-input`,onKeyDown:e=>{e.key===`Enter`&&d()}}),(0,I.jsx)(X,{variant:`outline`,size:`sm`,disabled:c,onClick:()=>void d(),children:OF()})]}),(0,I.jsx)(`span`,{className:`oc-show__desc`,children:SF()}),o?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:o}):null]})]})}function ist({chart:e}){let t=F(V.charts.updateChart),n=F(V.charts.deleteChart),[r,i]=(0,N.useState)(!1),[a,o]=(0,N.useState)(e.name),[s,c]=(0,N.useState)(()=>JSON.stringify(e.tokens,null,2)),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)(!1);function p(){o(e.name),c(JSON.stringify(e.tokens,null,2)),u(null),i(!0)}async function m(){if(e.chartId===void 0)return;u(null);let n;try{n=JSON.parse(s)}catch{u(uP());return}f(!0);try{await t({chartId:e.chartId,name:a.trim(),tokens:n}),i(!1)}catch(e){u(e instanceof Error?e.message:String(e))}finally{f(!1)}}async function h(){if(e.chartId!==void 0&&window.confirm(YF()))try{await n({chartId:e.chartId})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-mine__row`,children:[(0,I.jsxs)(`div`,{className:`oc-chart-mine__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__name`,children:e.name}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:r?null:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:p,children:OP()}),(0,I.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>void h(),children:jP()})]})})]}),r?(0,I.jsxs)(`div`,{className:`oc-chart-mine__editor`,children:[(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:UF()}),(0,I.jsx)(o1,{value:a,onChange:e=>o(e.target.value),maxLength:60})]}),(0,I.jsxs)(`label`,{className:`oc-chart-import__field`,children:[(0,I.jsx)(`span`,{className:`oc-chart-import__label`,children:KF()}),(0,I.jsx)(`textarea`,{className:`oc-chart-import__textarea`,value:s,onChange:e=>c(e.target.value),rows:10,spellCheck:!1})]}),l?(0,I.jsx)(`p`,{className:`oc-chart-import__error`,children:l}):null,(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{size:`sm`,disabled:d,onClick:()=>void m(),children:LF()}),(0,I.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>i(!1),children:BF()})]})]}):null,(0,I.jsx)(rst,{chart:e}),(0,I.jsx)(U9,{chart:e})]})}function ast(){let e=P(V.charts.listMyCharts),t=(e??[]).filter(e=>e.via===`owner`);return(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:yP()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:SP()})]}),e!==void 0&&t.length===0?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:TP()}):(0,I.jsx)(`div`,{className:`oc-chart-mine-list`,children:t.map(e=>(0,I.jsx)(ist,{chart:e},e.key))})]})}function ost({chart:e,groups:t}){let n=F(V.charts.addChartToGroupPool),r=F(V.charts.removeChartFromGroupPool),i=e.restrictedToGroups,a=e.poolGroups,o=new Set((a??[]).map(e=>e.groupId)),s=t.filter(e=>!o.has(e._id));async function c(t){try{await n({groupId:t,chartKey:e.key})}catch{}}async function l(t){try{await r({groupId:t,chartKey:e.key})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,I.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,I.jsx)($,{variant:i?`secondary`:`outline`,className:`oc-chart-avail__state`,children:i?SN():e.kind===`custom`&&e.scope===`personal`?sI():yN()}),e.isGlobalDefault?(0,I.jsx)($,{variant:`default`,children:TN()}):null]}),(0,I.jsxs)(`div`,{className:`oc-chart-avail__groups`,children:[(0,I.jsx)(`span`,{className:`oc-chart-mine__groups-label`,children:jN()}),(a??[]).map(e=>(0,I.jsxs)($,{variant:`secondary`,className:`oc-chart-avail__chip`,children:[e.name,(0,I.jsx)(`button`,{type:`button`,className:`oc-chart-avail__chip-x`,"aria-label":LN({group:e.name}),onClick:()=>void l(e.groupId),children:(0,I.jsx)(Km,{className:`size-3`})})]},e.groupId)),s.length>0?(0,I.jsxs)(C3,{value:``,onValueChange:e=>void c(e),children:[(0,I.jsx)(T3,{size:`sm`,className:`w-56`,children:(0,I.jsx)(w3,{placeholder:PN()})}),(0,I.jsx)(E3,{children:s.map(e=>(0,I.jsx)(Q,{value:e._id,children:e.name},e._id))})]}):t.length===0?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:ON()}):null]})]})}function sst({chart:e}){let t=F(V.charts.promoteChartToCommon),n=F(V.charts.deleteChart);async function r(){if(e.chartId!==void 0)try{await t({chartId:e.chartId})}catch{}}async function i(){if(e.chartId!==void 0&&window.confirm(YF()))try{await n({chartId:e.chartId})}catch{}}return(0,I.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,I.jsxs)(`div`,{className:`oc-chart-avail__head`,children:[(0,I.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name}),(0,I.jsx)($,{variant:e.scope===`common`?`outline`:`secondary`,children:e.scope===`common`?uI():sI()}),e.ownerLabel?(0,I.jsx)(`span`,{className:`oc-show__desc`,children:iI({owner:e.ownerLabel})}):null]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[e.scope===`personal`?(0,I.jsx)(X,{variant:`outline`,size:`sm`,onClick:()=>void r(),children:pI()}):null,(0,I.jsx)(X,{variant:`ghost`,size:`sm`,onClick:()=>void i(),children:gI()})]})]})}function cst({defaultThemeMode:e,defaultLocale:t,defaultChartKey:n}){let r=F(V.admin.setDefaultThemeMode),i=F(V.admin.setDefaultLocale),a=F(V.charts.setDefaultChart),o=P(V.charts.listChartsAdmin),s=P(V.groups.listGroups,{}),c=e??`system`,l=t??`fr`;return(0,I.jsxs)(`div`,{className:`oc-appearance-admin`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h2`,{className:`oc-show__title`,children:TM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:OM()})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:tN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:iN()})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{variant:n===null?`default`:`outline`,size:`sm`,onClick:()=>void a({name:null}),children:LM()}),CO.map(e=>(0,I.jsx)(X,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key)),(o??[]).filter(e=>e.kind===`custom`&&e.scope===`common`).map(e=>(0,I.jsx)(X,{variant:n===e.key?`default`:`outline`,size:`sm`,onClick:()=>void a({name:e.key}),children:e.name},e.key))]})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:sN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:uN()})]}),(0,I.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>!(e.kind===`custom`&&e.scope===`common`)).map(e=>(0,I.jsx)(ost,{chart:e,groups:s??[]},e.key))})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:pN()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:gN()})]}),(0,I.jsx)(`div`,{className:`oc-chart-avail-list`,children:(o??[]).filter(e=>e.kind===`builtin`||e.scope===`common`).map(e=>(0,I.jsxs)(`div`,{className:`oc-chart-avail`,children:[(0,I.jsx)(`div`,{className:`oc-chart-avail__head`,children:(0,I.jsx)(`span`,{className:`oc-chart-avail__name`,children:e.name})}),(0,I.jsx)(U9,{chart:e})]},e.key))})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:QF()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:tI()})]}),(()=>{let e=(o??[]).filter(e=>e.kind===`custom`);return e.length===0?(0,I.jsx)(`p`,{className:`oc-show__desc`,children:yI()}):(0,I.jsx)(`div`,{className:`oc-chart-avail-list`,children:e.map(e=>(0,I.jsx)(sst,{chart:e},e.key))})})()]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:sM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:uM()})]}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:[`light`,`dark`,`system`].map(e=>(0,I.jsx)(X,{variant:c===e?`default`:`outline`,size:`sm`,onClick:()=>void r({mode:e}),children:Qot(e)},e))})]}),(0,I.jsxs)(`section`,{className:`oc-show__section`,children:[(0,I.jsxs)(`div`,{className:`oc-show__heading`,children:[(0,I.jsx)(`h3`,{className:`oc-show__title`,children:pM()}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:gM()})]}),(0,I.jsx)(`div`,{className:`oc-show__row`,children:[`fr`,`en`].map(e=>(0,I.jsx)(X,{variant:l===e?`default`:`outline`,size:`sm`,onClick:()=>void i({locale:e}),children:e===`fr`?Yk():Qk()},e))}),(0,I.jsx)(`p`,{className:`oc-show__desc`,children:yM()})]})]})}function lst(){let e=P(V.me.getMe,{host:xO}),t=wO(e?.resolvedThemeMode);return(0,I.jsxs)(`div`,{className:`oc-appearance`,children:[(0,I.jsx)(tst,{selectedKey:e?.chartKey??null,resolvedMode:t}),(0,I.jsx)(nst,{}),(0,I.jsx)(ast,{}),e?.role===`admin`?(0,I.jsx)(cst,{defaultThemeMode:e.defaultThemeMode,defaultLocale:e.defaultLocale,defaultChartKey:e.defaultChartKey}):null]})}function ust(){let[e,t]=(0,N.useState)(!0),[n,r]=(0,N.useState)(`per-user`),[i,a]=(0,N.useState)(``),[o,s]=(0,N.useState)(z9),[c,l]=(0,N.useState)(z9),[u,d]=(0,N.useState)(B9),f=i!==``||o!==z9||c!==z9;function p(){a(``),s(z9),l(z9),d(B9)}return(0,I.jsxs)(`div`,{className:`oc-show`,children:[(0,I.jsx)(lst,{}),(0,I.jsxs)(`details`,{className:`oc-show__ref`,children:[(0,I.jsx)(`summary`,{className:`oc-show__title`,children:SM()}),(0,I.jsxs)(V9,{title:`Buttons`,description:`Variants`,children:[(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{children:`Default`}),(0,I.jsx)(X,{variant:`secondary`,children:`Secondary`}),(0,I.jsx)(X,{variant:`outline`,children:`Outline`}),(0,I.jsx)(X,{variant:`ghost`,children:`Ghost`}),(0,I.jsx)(X,{variant:`destructive`,children:`Destructive`}),(0,I.jsx)(X,{variant:`link`,children:`Link`})]}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(X,{size:`sm`,children:`Small`}),(0,I.jsx)(X,{children:`Default`}),(0,I.jsx)(X,{size:`lg`,children:`Large`}),(0,I.jsx)(X,{size:`icon`,"aria-label":`more`,children:(0,I.jsx)(ym,{})}),(0,I.jsx)(X,{disabled:!0,children:`Disabled`})]})]}),(0,I.jsx)(V9,{title:`Badges`,children:(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)($,{children:`Default`}),(0,I.jsx)($,{variant:`secondary`,children:`Secondary`}),(0,I.jsx)($,{variant:`outline`,children:`Outline`}),(0,I.jsx)($,{variant:`destructive`,children:`Destructive`})]})}),(0,I.jsx)(V9,{title:`Inputs & selection`,children:(0,I.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,I.jsx)(o1,{placeholder:`Text input…`}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsxs)(C3,{value:n,onValueChange:r,children:[(0,I.jsx)(T3,{className:`w-56`,children:(0,I.jsx)(w3,{placeholder:`Select…`})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:`per-user`,children:`per-user (chacun son agent)`}),(0,I.jsx)(Q,{value:`shared`,children:`shared (agent commun)`})]})]}),(0,I.jsxs)(`label`,{className:`oc-show__check`,children:[(0,I.jsx)(A1,{checked:e,onCheckedChange:e=>t(!!e)}),`Checkbox`]})]})]})}),(0,I.jsx)(V9,{title:`Filtres & plage temporelle`,description:`Barre réutilisable (recherche debouncée + selects rapides à largeur auto + plage façon Grafana) et constructeur de filtre avancé. Câblée dans Users, Groups, Comptes de service, Traces, Anomalies, Audit et KPI.`,children:(0,I.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,I.jsxs)(i7,{q:i,onQChange:a,searchPlaceholder:`Rechercher (kind, principal, rôle, route…)`,timeRange:u,onTimeRangeChange:d,onReset:p,canReset:f,children:[(0,I.jsxs)(C3,{value:o,onValueChange:s,children:[(0,I.jsx)(T3,{size:`sm`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:z9,children:`Toutes directions`}),(0,I.jsx)(Q,{value:`inbound`,children:`inbound`}),(0,I.jsx)(Q,{value:`outbound`,children:`outbound`}),(0,I.jsx)(Q,{value:`internal`,children:`internal`})]})]}),(0,I.jsxs)(C3,{value:c,onValueChange:l,children:[(0,I.jsx)(T3,{size:`sm`,children:(0,I.jsx)(w3,{})}),(0,I.jsxs)(E3,{children:[(0,I.jsx)(Q,{value:z9,children:`Toutes sévérités`}),(0,I.jsx)(Q,{value:`info`,children:`info`}),(0,I.jsx)(Q,{value:`warn`,children:`warn`}),(0,I.jsx)(Q,{value:`critical`,children:`critical`})]})]})]}),(0,I.jsx)(h7,{fields:Zot,onChange:()=>{}}),(0,I.jsxs)(`div`,{className:`oc-show__row`,children:[(0,I.jsx)(`span`,{className:`oc-show__desc`,children:`Sélecteur de plage seul :`}),(0,I.jsx)(r7,{value:u,onChange:d})]})]})}),(0,I.jsx)(V9,{title:`Dropdown menu`,description:`Row actions / kebab`,children:(0,I.jsxs)(K$,{children:[(0,I.jsx)(q$,{asChild:!0,children:(0,I.jsx)(X,{variant:`outline`,size:`icon`,"aria-label":`Open menu`,children:(0,I.jsx)(ym,{})})}),(0,I.jsxs)(J$,{align:`start`,children:[(0,I.jsx)(X$,{children:`Actions`}),(0,I.jsx)(Z$,{}),(0,I.jsx)(Y$,{children:`Edit`}),(0,I.jsx)(Y$,{children:`Duplicate`}),(0,I.jsx)(Z$,{}),(0,I.jsx)(Y$,{variant:`destructive`,children:`Delete`})]})]})}),(0,I.jsx)(V9,{title:`Card`,children:(0,I.jsxs)(r9,{className:`w-80`,children:[(0,I.jsxs)(i9,{children:[(0,I.jsx)(a9,{children:`Instance`}),(0,I.jsx)(o9,{children:`Non-secret metadata only.`})]}),(0,I.jsx)(s9,{className:`text-sm text-muted-foreground`,children:`ws://gateway.example.org:18789`}),(0,I.jsxs)(zat,{className:`gap-2`,children:[(0,I.jsx)(X,{size:`sm`,children:`Save`}),(0,I.jsx)(X,{size:`sm`,variant:`ghost`,children:`Cancel`})]})]})}),(0,I.jsx)(V9,{title:`Table`,children:(0,I.jsxs)(w5,{children:[(0,I.jsx)(T5,{children:(0,I.jsxs)(D5,{children:[(0,I.jsx)(O5,{className:`w-8`,children:(0,I.jsx)(A1,{"aria-label":`select all`})}),(0,I.jsx)(O5,{children:`Name`}),(0,I.jsx)(O5,{children:`Mode`}),(0,I.jsx)(O5,{className:`text-right`,children:`Status`}),(0,I.jsx)(O5,{className:`w-8`})]})}),(0,I.jsx)(E5,{children:[{n:`admins`,m:`per-user`,s:`active`},{n:`family`,m:`shared`,s:`active`}].map(e=>(0,I.jsxs)(D5,{children:[(0,I.jsx)(k5,{children:(0,I.jsx)(A1,{"aria-label":`select ${e.n}`})}),(0,I.jsx)(k5,{className:`font-medium`,children:e.n}),(0,I.jsx)(k5,{children:(0,I.jsx)($,{variant:`secondary`,children:e.m})}),(0,I.jsx)(k5,{className:`text-right`,children:(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,I.jsx)(um,{className:`size-3.5`}),` `,e.s]})}),(0,I.jsx)(k5,{children:(0,I.jsx)(X,{variant:`ghost`,size:`icon`,"aria-label":`row actions`,children:(0,I.jsx)(ym,{})})})]},e.n))})]})}),(0,I.jsx)(V9,{title:`App fragments`,description:`Chat-specific components`,children:(0,I.jsxs)(`div`,{className:`oc-show__row oc-show__row--col`,children:[(0,I.jsx)(`div`,{className:`oc-msg oc-msg--assistant`,children:(0,I.jsx)(`div`,{className:`oc-msg__body`,children:`Assistant message bubble.`})}),(0,I.jsx)(`div`,{className:`oc-tool oc-tool--completed`,children:(0,I.jsxs)(`div`,{className:`oc-tool__header`,children:[(0,I.jsx)(`span`,{className:`oc-tool__icon`,children:`✓`}),(0,I.jsx)(`span`,{className:`oc-tool__name`,children:`write-file`}),(0,I.jsx)(`span`,{className:`oc-tool__phase`,children:`completed`})]})}),(0,I.jsxs)(`div`,{className:`oc-run-status oc-run-status--streaming`,children:[(0,I.jsx)(`span`,{className:`oc-run-status__dot`}),(0,I.jsx)(`span`,{className:`oc-run-status__label`,children:`Running`})]})]})})]})]})}var W9=`oc.theme`;function G9(e){let t=e===`dark`||e===`system`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}function K9(e){(0,N.useEffect)(()=>{let t=e??localStorage.getItem(W9)??`system`;if(localStorage.setItem(W9,t),G9(t),t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>G9(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}function dst(e){(0,N.useEffect)(()=>{if(!e)return;document.documentElement.lang=e;let t;try{t=q()}catch{t=void 0}t!==e&&VO(e)},[e])}function fst(){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(mr,{children:(0,I.jsx)(`div`,{className:`oc-boot`,children:hQ()})}),(0,I.jsx)(pr,{children:(0,I.jsx)(mst,{})}),(0,I.jsx)(fr,{children:(0,I.jsx)(a4e,{children:(0,I.jsx)(hst,{})})})]})}function pst(){return(0,I.jsxs)(`svg`,{className:`oc-provider__logo`,viewBox:`0 0 48 48`,"aria-hidden":`true`,children:[(0,I.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,I.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,I.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,I.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`})]})}function mst(){let{signIn:e}=Ir();K9(void 0);let t=P(V.charts.brandForHost,{host:xO}),n=$de(xO),r=t??n??null,i=wO(void 0);TO(r?.tokens??null,i),(0,N.useEffect)(()=>{t&&efe(xO,t)},[t]);let a=r?.brand,o=a&&!a.isDefault?jO(a,i):null,s=a?.label??`Atrium`,c=P(V.me.authProviders),[l,u]=(0,N.useState)(null);async function d(t){u(null);try{await e(t)}catch{u(kAe())}}let f=c!==void 0&&!c.google&&!c.microsoft&&!c.anonymous;return(0,I.jsxs)(`div`,{className:`oc-signin`,children:[(0,I.jsxs)(`svg`,{className:`oc-signin__motif`,viewBox:`0 0 1200 1000`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,I.jsx)(`polyline`,{className:`oc-signin__line`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,vectorEffect:`non-scaling-stroke`}),(0,I.jsx)(`polyline`,{className:`oc-signin__pulse`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,pathLength:`100`,vectorEffect:`non-scaling-stroke`})]}),(0,I.jsxs)(`div`,{className:`oc-signin__brand`,children:[o?(0,I.jsx)(`img`,{className:`oc-signin__brandlogo`,src:o,alt:``}):null,(0,I.jsx)(`span`,{className:`oc-signin__wordmark`,children:s})]}),(0,I.jsxs)(`div`,{className:`oc-signin__card`,children:[(0,I.jsx)(`h1`,{className:`oc-signin__title`,children:MAe()}),(0,I.jsx)(`p`,{className:`oc-signin__subtitle`,children:FAe()}),(0,I.jsx)(`div`,{className:`oc-signin__providers`,children:c?.google?(0,I.jsxs)(`button`,{type:`button`,className:`oc-provider oc-provider--google`,onClick:()=>void d(`google`),children:[(0,I.jsx)(pst,{}),(0,I.jsx)(`span`,{children:RAe()})]}):null}),l?(0,I.jsx)(`p`,{className:`oc-signin__error`,children:l}):null,f?(0,I.jsx)(`p`,{className:`oc-signin__error`,children:VAe()}):null,c?.anonymous?(0,I.jsx)(`button`,{type:`button`,className:`oc-signin__dev`,onClick:()=>void e(`anonymous`),children:WAe()}):null]})]})}function hst(){let e=P(V.me.getMe,{host:xO}),t=F(V.me.bootstrap),n=ss();(0,N.useEffect)(()=>{e&&!e.hasProfile&&t()},[e,t]),K9(e?.resolvedThemeMode);let r=wO(e?.resolvedThemeMode);TO(e?.resolvedChartTokens,r),dst(e?.resolvedLocale);let i=(0,N.useRef)(null);if((0,N.useEffect)(()=>{e&&(i.current!==null&&i.current!==e.userId&&n({to:`/`}),i.current=e.userId)},[e,n]),e===void 0)return(0,I.jsx)(`div`,{className:`oc-boot`,children:hQ()});let a=e.name||e.email||qAe();return e.role===`pending`?(0,I.jsxs)(`div`,{className:`oc-shell`,children:[(0,I.jsx)(q9,{}),(0,I.jsx)(p5,{}),(0,I.jsxs)(`header`,{className:`oc-topbar`,children:[(0,I.jsx)(`span`,{className:`oc-topbar__brand`,children:(0,I.jsx)(J9,{brand:e.resolvedChartBrand,resolvedThemeMode:e.resolvedThemeMode})}),(0,I.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,I.jsx)(m5,{label:a,mode:e.themeMode,minimal:!0})})]}),(0,I.jsxs)(`div`,{className:`oc-pending`,children:[(0,I.jsx)(`h1`,{className:`oc-pending__title`,children:XAe()}),(0,I.jsx)(`p`,{className:`oc-pending__body`,children:$Ae()})]})]}):(0,I.jsx)(_st,{canOpenSettings:M7(e.permissions??[]).length>0,userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand},e.userId)}function q9(){let e=P(V.me.getImpersonation),t=F(V.admin.stopImpersonation);return!e||!e.impersonating?null:(0,I.jsxs)(`div`,{className:`oc-imp`,role:`alert`,children:[(0,I.jsx)(Dee,{className:`size-4 shrink-0`}),(0,I.jsxs)(`span`,{className:`oc-imp__text`,children:[nje(),` `,(0,I.jsx)(`strong`,{children:e.targetLabel}),aje(),(0,I.jsx)(`strong`,{children:e.realLabel}),cje()]}),(0,I.jsx)(X,{size:`sm`,variant:`outline`,className:`oc-imp__exit`,onClick:()=>void t(),children:dje()})]})}function J9({brand:e,resolvedThemeMode:t}){let n=wO(t),r=e?.label??`Atrium`,i=e?.isDefault??!0,a=jO(e,n),[o,s]=(0,N.useState)(!1);return(0,N.useEffect)(()=>s(!1),[a]),(0,I.jsxs)(I.Fragment,{children:[a!==null&&!o?(0,I.jsx)(`img`,{className:`oc-brand__logo`,src:a,alt:``,"aria-hidden":`true`,onError:()=>s(!0)}):i?(0,I.jsx)(MO,{className:`oc-brand__logo`}):null,(0,I.jsx)(`span`,{className:`oc-brand__label`,children:r})]})}function gst({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r,collapsed:i,onToggleSidebar:a}){return(0,I.jsxs)(`header`,{className:`oc-topbar`,children:[(0,I.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,I.jsx)(X,{variant:`ghost`,size:`icon-sm`,"aria-label":i?mje():_je(),onClick:a,children:i?(0,I.jsx)(Nm,{}):(0,I.jsx)(Mm,{})}),(0,I.jsx)(xs,{to:`/`,className:`oc-topbar__brand`,children:(0,I.jsx)(J9,{brand:r,resolvedThemeMode:n})})]}),(0,I.jsx)(`div`,{className:`oc-topbar__search`,children:(0,I.jsx)(Wrt,{})}),(0,I.jsxs)(`div`,{className:`oc-topbar__actions`,children:[(0,I.jsx)(h5,{}),(0,I.jsx)(m5,{label:e,mode:t})]})]})}function _st({canOpenSettings:e,userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i}){let{width:a,collapsed:o,toggleCollapsed:s,collapse:c,startResize:l,isMobile:u}=e3e(),d=zs(),f=as({strict:!1}),p=ss(),m=!!d({to:`/settings`,fuzzy:!0});(0,N.useEffect)(()=>{u&&c()},[Gs({select:e=>e.pathname}),u,c]);let h=(0,N.useCallback)(e=>{p({to:`/chat/$chatId`,params:{chatId:e}})},[p]),{startNewChat:g,picker:_}=Frt(h),v=(0,N.useMemo)(()=>b5(_5,y5()),[]);return(0,N.useEffect)(()=>{let e=e=>{x5(e,_5)&&(e.preventDefault(),g())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[g]),(0,I.jsxs)(`div`,{className:`oc-shell`,children:[_,(0,I.jsx)(q9,{}),(0,I.jsx)(p5,{}),(0,I.jsx)(gst,{userLabel:t,themeMode:n,resolvedThemeMode:r,brand:i,collapsed:o,onToggleSidebar:s}),(0,I.jsxs)(`div`,{className:u?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[u&&!o?(0,I.jsx)(`div`,{className:`oc-sidebar-backdrop`,onClick:c,"aria-hidden":!0}):null,o?null:(0,I.jsxs)(`div`,{className:`oc-sidebar-col`,style:u?void 0:{width:a,flex:`0 0 ${a}px`},children:[m?(0,I.jsx)(Wot,{}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Art,{activeChatId:f.chatId??null,onSelect:h,onNewChat:()=>void g(),newChatShortcut:v}),e?(0,I.jsx)(X,{variant:`ghost`,className:`m-2 justify-start`,asChild:!0,children:(0,I.jsx)(xs,{to:`/settings`,children:bje()})}):null]}),(0,I.jsx)(`div`,{className:`oc-sidebar-resizer`,onPointerDown:l,role:`separator`,"aria-orientation":`vertical`,"aria-label":Cje()})]}),(0,I.jsx)(`main`,{className:`oc-main`,children:(0,I.jsx)(Fs,{})})]})]})}function vst(){let e=P(V.me.getMe,{host:xO}),t=ss(),n=Gs({select:e=>e.pathname}),r=(0,N.useMemo)(()=>e?M7(e.permissions??[]):[],[e]),i=e!==void 0&&r.length===0;if((0,N.useEffect)(()=>{i&&t({to:`/`})},[i,t]),e===void 0)return(0,I.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:hQ()});if(i)return null;let a=P7(n),o=a!==void 0&&!r.includes(a);return(0,I.jsxs)(`div`,{className:`oc-admin`,children:[(0,I.jsx)(Uot,{}),(0,I.jsx)(`div`,{className:`oc-admin__body`,children:o?(0,I.jsx)(yst,{}):(0,I.jsx)(Fs,{})})]})}function yst(){return(0,I.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,I.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,I.jsx)(Hm,{size:28})}),(0,I.jsx)(`h2`,{className:`oc-route-error__title`,children:Eje()}),(0,I.jsx)(`p`,{className:`oc-route-error__body`,children:kje()})]})}function bst(){let e=P(V.me.getMe,{host:xO}),t=ss();return(0,N.useEffect)(()=>{if(e===void 0)return;let n=M7(e.permissions??[]);t({to:n.length>0?N7(n[0]):`/`,replace:!0})},[e,t]),(0,I.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:hQ()})}function xst(){let{tab:e}=as({from:`/settings/$tab`});switch(e){case`groups`:return(0,I.jsx)(Eat,{});case`integrations`:return(0,I.jsx)(sot,{});case`instances`:return(0,I.jsx)(Xit,{});case`bridge`:return(0,I.jsx)(Eit,{});case`theme`:return(0,I.jsx)(ust,{});case`feedbacks`:return(0,I.jsx)(uot,{});case`files`:return(0,I.jsx)(dot,{});case`agentFiles`:return(0,I.jsx)(got,{});case`preferences`:return(0,I.jsx)(Oot,{});case`chatDefaults`:return(0,I.jsx)(jot,{});case`access`:return(0,I.jsx)(Fot,{});default:return(0,I.jsx)(vat,{})}}function Sst(){let{chatId:e}=as({from:`/chat/$chatId`}),{m:t}=os({from:`/chat/$chatId`});return(0,I.jsx)(q3,{chatId:e,focusMessageId:t??null})}function Cst(){return(0,I.jsx)(q3,{chatId:null})}var Y9=Es({component:fst}),wst=ws({getParentRoute:()=>Y9,path:`/`,component:Cst}),Tst=ws({getParentRoute:()=>Y9,path:`chat/$chatId`,component:Sst,validateSearch:e=>({m:typeof e.m==`string`?e.m:void 0})}),X9=ws({getParentRoute:()=>Y9,path:`settings`,component:vst}),Est=ws({getParentRoute:()=>X9,path:`/`,component:bst}),Dst=ws({getParentRoute:()=>X9,path:`traces`,validateSearch:Rit,component:Iat}),Ost=ws({getParentRoute:()=>X9,path:`audit`,validateSearch:zit,component:oat}),kst=ws({getParentRoute:()=>X9,path:`anomalies`,validateSearch:Bit,component:tot}),Ast=ws({getParentRoute:()=>X9,path:`kpi`,validateSearch:Vit,component:Wat}),jst=ws({getParentRoute:()=>X9,path:`serviceAccounts`,validateSearch:Hit,component:lat}),Mst=ws({getParentRoute:()=>X9,path:`users`,validateSearch:Uit,component:qit}),Nst=ws({getParentRoute:()=>X9,path:`uiprefs`,beforeLoad:()=>{throw ia({to:`/settings/$tab`,params:{tab:Git.uiprefs},replace:!0})}}),Pst=ws({getParentRoute:()=>X9,path:`$tab`,parseParams:e=>({tab:Wp([...O7]).catch(`roles`).parse(e.tab)}),component:xst});function Fst({reset:e}){let t=ss();return(0,I.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,I.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,I.jsx)(Hm,{size:28})}),(0,I.jsx)(`h2`,{className:`oc-route-error__title`,children:Mje()}),(0,I.jsx)(`p`,{className:`oc-route-error__body`,children:Fje()}),(0,I.jsxs)(`div`,{className:`oc-route-error__actions`,children:[(0,I.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>e(),children:Rje()}),(0,I.jsx)(`button`,{type:`button`,className:`oc-route-error__cta oc-route-error__cta--ghost`,onClick:()=>void t({to:`/`}),children:gQ()})]})]})}function Ist(){let e=ss();return(0,I.jsxs)(`div`,{className:`oc-route-error`,role:`status`,children:[(0,I.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,I.jsx)(Eee,{size:28})}),(0,I.jsx)(`h2`,{className:`oc-route-error__title`,children:Uje()}),(0,I.jsx)(`p`,{className:`oc-route-error__body`,children:Kje()}),(0,I.jsx)(`div`,{className:`oc-route-error__actions`,children:(0,I.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>void e({to:`/`}),children:gQ()})})]})}var Z9=Vs({routeTree:Y9.addChildren([wst,Tst,X9.addChildren([Est,Dst,Ost,kst,Ast,jst,Mst,Nst,Pst])]),defaultPreload:`intent`,defaultErrorComponent:Fst,defaultNotFoundComponent:Ist});async function Lst(){try{let e=await fetch(`/config.json`,{cache:`no-store`});if(e.ok){let t=(await e.json())?.convexUrl;if(typeof t==`string`&&t.trim())return t.trim()}}catch{}throw Error(`No Convex URL configured: serve /config.json {"convexUrl":"…"} (production) or set VITE_CONVEX_URL (local dev).`)}var Rst=()=>null;function Q9({children:e}){return(0,I.jsx)(`div`,{style:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,textAlign:`center`,font:`14px system-ui, sans-serif`,opacity:.6},children:e})}var $9=_r.createRoot(document.getElementById(`root`));$9.render((0,I.jsx)(N.StrictMode,{children:(0,I.jsx)(Q9,{children:`Chargement…`})})),Lst().then(e=>{let t=new Yn(e);$9.render((0,I.jsx)(N.StrictMode,{children:(0,I.jsx)(Lr,{client:t,children:(0,I.jsxs)(r4e,{children:[(0,I.jsx)(Zet,{children:(0,I.jsx)(Ws,{router:Z9})}),(0,I.jsx)(N.Suspense,{fallback:null,children:(0,I.jsx)(Rst,{router:Z9,position:`bottom-right`})})]})})}))}).catch(e=>{console.error(`Boot failed:`,e),$9.render((0,I.jsx)(N.StrictMode,{children:(0,I.jsxs)(Q9,{children:[`Configuration manquante\xA0:`,` `,e instanceof Error?e.message:String(e)]})}))});