@inspectr/mcplab 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.
@@ -117,7 +117,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
117
117
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function kue(e,t){if(e){if(typeof e=="string")return qS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return qS(e,t)}}function Rue(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Tue(e){if(Array.isArray(e))return qS(e)}function qS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Iue(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function LI(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,j4(r.key),r)}}function Mue(e,t,n){return t&&LI(e.prototype,t),n&&LI(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function $ue(e,t,n){return t=cm(t),Due(e,S4()?Reflect.construct(t,n||[],cm(e).constructor):t.apply(e,n))}function Due(e,t){if(t&&(pc(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Lue(e)}function Lue(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function S4(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(S4=function(){return!!e})()}function cm(e){return cm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},cm(e)}function Fue(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&WS(e,t)}function WS(e,t){return WS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},WS(e,t)}function Da(e,t,n){return t=j4(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function j4(e){var t=Bue(e,"string");return pc(t)=="symbol"?t:t+""}function Bue(e,t){if(pc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(pc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var hc=(function(e){function t(){var n;Iue(this,t);for(var r=arguments.length,a=new Array(r),i=0;i<r;i++)a[i]=arguments[i];return n=$ue(this,t,[].concat(a)),Da(n,"state",{isAnimationFinished:!0,totalLength:0}),Da(n,"generateSimpleStrokeDasharray",function(o,c){return"".concat(c,"px ").concat(o-c,"px")}),Da(n,"getStrokeDasharray",function(o,c,d){var f=d.reduce(function(j,N){return j+N});if(!f)return n.generateSimpleStrokeDasharray(c,o);for(var h=Math.floor(o/f),p=o%f,y=c-o,g=[],S=0,b=0;S<d.length;b+=d[S],++S)if(b+d[S]>p){g=[].concat(yl(d.slice(0,S)),[p-b]);break}var x=g.length%2===0?[0,y]:[y];return[].concat(yl(t.repeat(d,h)),yl(g),x).map(function(j){return"".concat(j,"px")}).join(", ")}),Da(n,"id",Tc("recharts-line-")),Da(n,"pathRef",function(o){n.mainCurve=o}),Da(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),Da(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Fue(t,e),Mue(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();this.setState({totalLength:r})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();r!==this.state.totalLength&&this.setState({totalLength:r})}}},{key:"getTotalLength",value:function(){var r=this.mainCurve;try{return r&&r.getTotalLength&&r.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(r,a){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var i=this.props,o=i.points,c=i.xAxis,d=i.yAxis,f=i.layout,h=i.children,p=ta(h,df);if(!p)return null;var y=function(b,x){return{x:b.x,y:b.y,value:b.value,errorVal:Wn(b.payload,x)}},g={clipPath:r?"url(#clipPath-".concat(a,")"):null};return q.createElement(Tt,g,p.map(function(S){return q.cloneElement(S,{key:"bar-".concat(S.props.dataKey),data:o,xAxis:c,yAxis:d,layout:f,dataPointFormatter:y})}))}},{key:"renderDots",value:function(r,a,i){var o=this.props.isAnimationActive;if(o&&!this.state.isAnimationFinished)return null;var c=this.props,d=c.dot,f=c.points,h=c.dataKey,p=ft(this.props,!1),y=ft(d,!0),g=f.map(function(b,x){var j=qr(qr(qr({key:"dot-".concat(x),r:3},p),y),{},{index:x,cx:b.x,cy:b.y,value:b.value,dataKey:h,payload:b.payload,points:f});return t.renderDotItem(d,j)}),S={clipPath:r?"url(#clipPath-".concat(a?"":"dots-").concat(i,")"):null};return q.createElement(Tt,Ju({className:"recharts-line-dots",key:"dots"},S),g)}},{key:"renderCurveStatically",value:function(r,a,i,o){var c=this.props,d=c.type,f=c.layout,h=c.connectNulls;c.ref;var p=$I(c,Aue),y=qr(qr(qr({},ft(p,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:a?"url(#clipPath-".concat(i,")"):null,points:r},o),{},{type:d,layout:f,connectNulls:h});return q.createElement(Uh,Ju({},y,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(r,a){var i=this,o=this.props,c=o.points,d=o.strokeDasharray,f=o.isAnimationActive,h=o.animationBegin,p=o.animationDuration,y=o.animationEasing,g=o.animationId,S=o.animateNewValues,b=o.width,x=o.height,j=this.state,N=j.prevPoints,_=j.totalLength;return q.createElement(ps,{begin:h,duration:p,isActive:f,easing:y,from:{t:0},to:{t:1},key:"line-".concat(g),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(P){var A=P.t;if(N){var O=N.length/c.length,k=c.map(function(L,K){var U=Math.floor(K*O);if(N[U]){var V=N[U],X=Gr(V.x,L.x),J=Gr(V.y,L.y);return qr(qr({},L),{},{x:X(A),y:J(A)})}if(S){var T=Gr(b*2,L.x),D=Gr(x/2,L.y);return qr(qr({},L),{},{x:T(A),y:D(A)})}return qr(qr({},L),{},{x:L.x,y:L.y})});return i.renderCurveStatically(k,r,a)}var R=Gr(0,_),$=R(A),z;if(d){var B="".concat(d).split(/[,\s]+/gim).map(function(L){return parseFloat(L)});z=i.getStrokeDasharray($,_,B)}else z=i.generateSimpleStrokeDasharray(_,$);return i.renderCurveStatically(c,r,a,{strokeDasharray:z})})}},{key:"renderCurve",value:function(r,a){var i=this.props,o=i.points,c=i.isAnimationActive,d=this.state,f=d.prevPoints,h=d.totalLength;return c&&o&&o.length&&(!f&&h>0||!uf(f,o))?this.renderCurveWithAnimation(r,a):this.renderCurveStatically(o,r,a)}},{key:"render",value:function(){var r,a=this.props,i=a.hide,o=a.dot,c=a.points,d=a.className,f=a.xAxis,h=a.yAxis,p=a.top,y=a.left,g=a.width,S=a.height,b=a.isAnimationActive,x=a.id;if(i||!c||!c.length)return null;var j=this.state.isAnimationFinished,N=c.length===1,_=bt("recharts-line",d),P=f&&f.allowDataOverflow,A=h&&h.allowDataOverflow,O=P||A,k=xt(x)?this.id:x,R=(r=ft(o,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},$=R.r,z=$===void 0?3:$,B=R.strokeWidth,L=B===void 0?2:B,K=OY(o)?o:{},U=K.clipDot,V=U===void 0?!0:U,X=z*2+L;return q.createElement(Tt,{className:_},P||A?q.createElement("defs",null,q.createElement("clipPath",{id:"clipPath-".concat(k)},q.createElement("rect",{x:P?y:y-g/2,y:A?p:p-S/2,width:P?g:g*2,height:A?S:S*2})),!V&&q.createElement("clipPath",{id:"clipPath-dots-".concat(k)},q.createElement("rect",{x:y-X/2,y:p-X/2,width:g+X,height:S+X}))):null,!N&&this.renderCurve(O,k),this.renderErrorBar(O,k),(N||o)&&this.renderDots(O,V,k),(!b||j)&&zs.renderCallByParent(this.props,c))}}],[{key:"getDerivedStateFromProps",value:function(r,a){return r.animationId!==a.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:a.curPoints}:r.points!==a.curPoints?{curPoints:r.points}:null}},{key:"repeat",value:function(r,a){for(var i=r.length%2!==0?[].concat(yl(r),[0]):r,o=[],c=0;c<a;++c)o=[].concat(yl(o),yl(i));return o}},{key:"renderDotItem",value:function(r,a){var i;if(q.isValidElement(r))i=q.cloneElement(r,a);else if(gt(r))i=r(a);else{var o=a.key,c=$I(a,Eue),d=bt("recharts-line-dot",typeof r!="boolean"?r.className:"");i=q.createElement(wv,Ju({key:o},c,{className:d}))}return i}}])})(v.PureComponent);Da(hc,"displayName","Line");Da(hc,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Do.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});Da(hc,"getComposedData",function(e){var t=e.props,n=e.xAxis,r=e.yAxis,a=e.xAxisTicks,i=e.yAxisTicks,o=e.dataKey,c=e.bandSize,d=e.displayedData,f=e.offset,h=t.layout,p=d.map(function(y,g){var S=Wn(y,o);return h==="horizontal"?{x:V2({axis:n,ticks:a,bandSize:c,entry:y,index:g}),y:xt(S)?null:r.scale(S),value:S,payload:y}:{x:xt(S)?null:n.scale(S),y:V2({axis:r,ticks:i,bandSize:c,entry:y,index:g}),value:S,payload:y}});return qr({points:p,layout:h},f)});function mc(e){"@babel/helpers - typeof";return mc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mc(e)}function zue(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Uue(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_4(r.key),r)}}function que(e,t,n){return t&&Uue(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Wue(e,t,n){return t=um(t),Vue(e,N4()?Reflect.construct(t,n||[],um(e).constructor):t.apply(e,n))}function Vue(e,t){if(t&&(mc(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Hue(e)}function Hue(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function N4(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(N4=function(){return!!e})()}function um(e){return um=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},um(e)}function Kue(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&VS(e,t)}function VS(e,t){return VS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},VS(e,t)}function C4(e,t,n){return t=_4(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _4(e){var t=Gue(e,"string");return mc(t)=="symbol"?t:t+""}function Gue(e,t){if(mc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(mc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function HS(){return HS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},HS.apply(this,arguments)}function Yue(e){var t=e.xAxisId,n=d4(),r=f4(),a=c4(t);return a==null?null:v.createElement(Tv,HS({},a,{className:bt("recharts-".concat(a.axisType," ").concat(a.axisType),a.className),viewBox:{x:0,y:0,width:n,height:r},ticksGenerator:function(o){return mo(o,!0)}}))}var Ao=(function(e){function t(){return zue(this,t),Wue(this,t,arguments)}return Kue(t,e),que(t,[{key:"render",value:function(){return v.createElement(Yue,this.props)}}])})(v.Component);C4(Ao,"displayName","XAxis");C4(Ao,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function vc(e){"@babel/helpers - typeof";return vc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vc(e)}function Xue(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Que(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,P4(r.key),r)}}function Jue(e,t,n){return t&&Que(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Zue(e,t,n){return t=dm(t),ede(e,A4()?Reflect.construct(t,n||[],dm(e).constructor):t.apply(e,n))}function ede(e,t){if(t&&(vc(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tde(e)}function tde(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function A4(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(A4=function(){return!!e})()}function dm(e){return dm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},dm(e)}function nde(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&KS(e,t)}function KS(e,t){return KS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},KS(e,t)}function E4(e,t,n){return t=P4(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function P4(e){var t=rde(e,"string");return vc(t)=="symbol"?t:t+""}function rde(e,t){if(vc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(vc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function GS(){return GS=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GS.apply(this,arguments)}var ade=function(t){var n=t.yAxisId,r=d4(),a=f4(),i=u4(n);return i==null?null:v.createElement(Tv,GS({},i,{className:bt("recharts-".concat(i.axisType," ").concat(i.axisType),i.className),viewBox:{x:0,y:0,width:r,height:a},ticksGenerator:function(c){return mo(c,!0)}}))},Eo=(function(e){function t(){return Xue(this,t),Zue(this,t,arguments)}return nde(t,e),Jue(t,[{key:"render",value:function(){return v.createElement(ade,this.props)}}])})(v.Component);E4(Eo,"displayName","YAxis");E4(Eo,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function FI(e){return lde(e)||ode(e)||ide(e)||sde()}function sde(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
118
118
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ide(e,t){if(e){if(typeof e=="string")return YS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return YS(e,t)}}function ode(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function lde(e){if(Array.isArray(e))return YS(e)}function YS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var XS=function(t,n,r,a,i){var o=ta(t,UN),c=ta(t,Ov),d=[].concat(FI(o),FI(c)),f=ta(t,Rv),h="".concat(a,"Id"),p=a[0],y=n;if(d.length&&(y=d.reduce(function(b,x){if(x.props[h]===r&&cs(x.props,"extendDomain")&&$e(x.props[p])){var j=x.props[p];return[Math.min(b[0],j),Math.max(b[1],j)]}return b},y)),f.length){var g="".concat(p,"1"),S="".concat(p,"2");y=f.reduce(function(b,x){if(x.props[h]===r&&cs(x.props,"extendDomain")&&$e(x.props[g])&&$e(x.props[S])){var j=x.props[g],N=x.props[S];return[Math.min(b[0],j,N),Math.max(b[1],j,N)]}return b},y)}return i&&i.length&&(y=i.reduce(function(b,x){return $e(x)?[Math.min(b[0],x),Math.max(b[1],x)]:b},y)),y},Jw={exports:{}},BI;function cde(){return BI||(BI=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function a(d,f,h){this.fn=d,this.context=f,this.once=h||!1}function i(d,f,h,p,y){if(typeof h!="function")throw new TypeError("The listener must be a function");var g=new a(h,p||d,y),S=n?n+f:f;return d._events[S]?d._events[S].fn?d._events[S]=[d._events[S],g]:d._events[S].push(g):(d._events[S]=g,d._eventsCount++),d}function o(d,f){--d._eventsCount===0?d._events=new r:delete d._events[f]}function c(){this._events=new r,this._eventsCount=0}c.prototype.eventNames=function(){var f=[],h,p;if(this._eventsCount===0)return f;for(p in h=this._events)t.call(h,p)&&f.push(n?p.slice(1):p);return Object.getOwnPropertySymbols?f.concat(Object.getOwnPropertySymbols(h)):f},c.prototype.listeners=function(f){var h=n?n+f:f,p=this._events[h];if(!p)return[];if(p.fn)return[p.fn];for(var y=0,g=p.length,S=new Array(g);y<g;y++)S[y]=p[y].fn;return S},c.prototype.listenerCount=function(f){var h=n?n+f:f,p=this._events[h];return p?p.fn?1:p.length:0},c.prototype.emit=function(f,h,p,y,g,S){var b=n?n+f:f;if(!this._events[b])return!1;var x=this._events[b],j=arguments.length,N,_;if(x.fn){switch(x.once&&this.removeListener(f,x.fn,void 0,!0),j){case 1:return x.fn.call(x.context),!0;case 2:return x.fn.call(x.context,h),!0;case 3:return x.fn.call(x.context,h,p),!0;case 4:return x.fn.call(x.context,h,p,y),!0;case 5:return x.fn.call(x.context,h,p,y,g),!0;case 6:return x.fn.call(x.context,h,p,y,g,S),!0}for(_=1,N=new Array(j-1);_<j;_++)N[_-1]=arguments[_];x.fn.apply(x.context,N)}else{var P=x.length,A;for(_=0;_<P;_++)switch(x[_].once&&this.removeListener(f,x[_].fn,void 0,!0),j){case 1:x[_].fn.call(x[_].context);break;case 2:x[_].fn.call(x[_].context,h);break;case 3:x[_].fn.call(x[_].context,h,p);break;case 4:x[_].fn.call(x[_].context,h,p,y);break;default:if(!N)for(A=1,N=new Array(j-1);A<j;A++)N[A-1]=arguments[A];x[_].fn.apply(x[_].context,N)}}return!0},c.prototype.on=function(f,h,p){return i(this,f,h,p,!1)},c.prototype.once=function(f,h,p){return i(this,f,h,p,!0)},c.prototype.removeListener=function(f,h,p,y){var g=n?n+f:f;if(!this._events[g])return this;if(!h)return o(this,g),this;var S=this._events[g];if(S.fn)S.fn===h&&(!y||S.once)&&(!p||S.context===p)&&o(this,g);else{for(var b=0,x=[],j=S.length;b<j;b++)(S[b].fn!==h||y&&!S[b].once||p&&S[b].context!==p)&&x.push(S[b]);x.length?this._events[g]=x.length===1?x[0]:x:o(this,g)}return this},c.prototype.removeAllListeners=function(f){var h;return f?(h=n?n+f:f,this._events[h]&&o(this,h)):(this._events=new r,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=n,c.EventEmitter=c,e.exports=c})(Jw)),Jw.exports}var ude=cde();const dde=Wt(ude);var Zw=new dde,e1="recharts.syncMouseEvents";function Bd(e){"@babel/helpers - typeof";return Bd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Bd(e)}function fde(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pde(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,O4(r.key),r)}}function hde(e,t,n){return t&&pde(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function t1(e,t,n){return t=O4(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function O4(e){var t=mde(e,"string");return Bd(t)=="symbol"?t:t+""}function mde(e,t){if(Bd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Bd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var vde=(function(){function e(){fde(this,e),t1(this,"activeIndex",0),t1(this,"coordinateList",[]),t1(this,"layout","horizontal")}return hde(e,[{key:"setDetails",value:function(n){var r,a=n.coordinateList,i=a===void 0?null:a,o=n.container,c=o===void 0?null:o,d=n.layout,f=d===void 0?null:d,h=n.offset,p=h===void 0?null:h,y=n.mouseHandlerCallback,g=y===void 0?null:y;this.coordinateList=(r=i??this.coordinateList)!==null&&r!==void 0?r:[],this.container=c??this.container,this.layout=f??this.layout,this.offset=p??this.offset,this.mouseHandlerCallback=g??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(n){if(this.coordinateList.length!==0)switch(n.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(n){this.activeIndex=n}},{key:"spoofMouse",value:function(){var n,r;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var a=this.container.getBoundingClientRect(),i=a.x,o=a.y,c=a.height,d=this.coordinateList[this.activeIndex].coordinate,f=((n=window)===null||n===void 0?void 0:n.scrollX)||0,h=((r=window)===null||r===void 0?void 0:r.scrollY)||0,p=i+d+f,y=o+this.offset.top+c/2+h;this.mouseHandlerCallback({pageX:p,pageY:y})}}}])})();function gde(e,t,n){if(n==="number"&&t===!0&&Array.isArray(e)){var r=e?.[0],a=e?.[1];if(r&&a&&$e(r)&&$e(a))return!0}return!1}function yde(e,t,n,r){var a=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-a:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-a,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function k4(e){var t=e.cx,n=e.cy,r=e.radius,a=e.startAngle,i=e.endAngle,o=ln(t,n,r,a),c=ln(t,n,r,i);return{points:[o,c],cx:t,cy:n,radius:r,startAngle:a,endAngle:i}}function xde(e,t,n){var r,a,i,o;if(e==="horizontal")r=t.x,i=r,a=n.top,o=n.top+n.height;else if(e==="vertical")a=t.y,o=a,r=n.left,i=n.left+n.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var c=t.cx,d=t.cy,f=t.innerRadius,h=t.outerRadius,p=t.angle,y=ln(c,d,f,p),g=ln(c,d,h,p);r=y.x,a=y.y,i=g.x,o=g.y}else return k4(t);return[{x:r,y:a},{x:i,y:o}]}function zd(e){"@babel/helpers - typeof";return zd=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zd(e)}function zI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function Vp(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?zI(Object(n),!0).forEach(function(r){bde(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zI(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function bde(e,t,n){return t=wde(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wde(e){var t=Sde(e,"string");return zd(t)=="symbol"?t:t+""}function Sde(e,t){if(zd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(zd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function jde(e){var t,n,r=e.element,a=e.tooltipEventType,i=e.isActive,o=e.activeCoordinate,c=e.activePayload,d=e.offset,f=e.activeTooltipIndex,h=e.tooltipAxisBandSize,p=e.layout,y=e.chartName,g=(t=r.props.cursor)!==null&&t!==void 0?t:(n=r.type.defaultProps)===null||n===void 0?void 0:n.cursor;if(!r||!g||!i||!o||y!=="ScatterChart"&&a!=="axis")return null;var S,b=Uh;if(y==="ScatterChart")S=o,b=ioe;else if(y==="BarChart")S=yde(p,o,d,h),b=FN;else if(p==="radial"){var x=k4(o),j=x.cx,N=x.cy,_=x.radius,P=x.startAngle,A=x.endAngle;S={cx:j,cy:N,startAngle:P,endAngle:A,innerRadius:_,outerRadius:_},b=kL}else S={points:xde(p,o,d)},b=Uh;var O=Vp(Vp(Vp(Vp({stroke:"#ccc",pointerEvents:"none"},d),S),ft(g,!1)),{},{payload:c,payloadIndex:f,className:bt("recharts-tooltip-cursor",g.className)});return v.isValidElement(g)?v.cloneElement(g,O):v.createElement(b,O)}var Nde=["item"],Cde=["children","className","width","height","style","compact","title","desc"];function gc(e){"@babel/helpers - typeof";return gc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},gc(e)}function El(){return El=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},El.apply(this,arguments)}function UI(e,t){return Ede(e)||Ade(e,t)||T4(e,t)||_de()}function _de(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
119
119
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ade(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,a,i,o,c=[],d=!0,f=!1;try{if(i=(n=n.call(e)).next,t!==0)for(;!(d=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);d=!0);}catch(h){f=!0,a=h}finally{try{if(!d&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(f)throw a}}return c}}function Ede(e){if(Array.isArray(e))return e}function qI(e,t){if(e==null)return{};var n=Pde(e,t),r,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(a=0;a<i.length;a++)r=i[a],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Pde(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Ode(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function kde(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,I4(r.key),r)}}function Rde(e,t,n){return t&&kde(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Tde(e,t,n){return t=fm(t),Ide(e,R4()?Reflect.construct(t,n||[],fm(e).constructor):t.apply(e,n))}function Ide(e,t){if(t&&(gc(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Mde(e)}function Mde(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function R4(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(R4=function(){return!!e})()}function fm(e){return fm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},fm(e)}function $de(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&QS(e,t)}function QS(e,t){return QS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,a){return r.__proto__=a,r},QS(e,t)}function yc(e){return Fde(e)||Lde(e)||T4(e)||Dde()}function Dde(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
120
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function T4(e,t){if(e){if(typeof e=="string")return JS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return JS(e,t)}}function Lde(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Fde(e){if(Array.isArray(e))return JS(e)}function JS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function WI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function we(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WI(Object(n),!0).forEach(function(r){pt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WI(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pt(e,t,n){return t=I4(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I4(e){var t=Bde(e,"string");return gc(t)=="symbol"?t:t+""}function Bde(e,t){if(gc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(gc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var zde={xAxis:["bottom","top"],yAxis:["left","right"]},Ude={width:"100%",height:"100%"},M4={x:0,y:0};function Hp(e){return e}var qde=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},Wde=function(t,n,r,a){var i=n.find(function(h){return h&&h.index===r});if(i){if(t==="horizontal")return{x:i.coordinate,y:a.y};if(t==="vertical")return{x:a.x,y:i.coordinate};if(t==="centric"){var o=i.coordinate,c=a.radius;return we(we(we({},a),ln(a.cx,a.cy,c,o)),{},{angle:o,radius:c})}var d=i.coordinate,f=a.angle;return we(we(we({},a),ln(a.cx,a.cy,d,f)),{},{angle:f,radius:d})}return M4},Iv=function(t,n){var r=n.graphicalItems,a=n.dataStartIndex,i=n.dataEndIndex,o=(r??[]).reduce(function(c,d){var f=d.props.data;return f&&f.length?[].concat(yc(c),yc(f)):c},[]);return o.length>0?o:t&&t.length&&$e(a)&&$e(i)?t.slice(a,i+1):[]};function $4(e){return e==="number"?[0,"auto"]:void 0}var ZS=function(t,n,r,a){var i=t.graphicalItems,o=t.tooltipAxis,c=Iv(n,t);return r<0||!i||!i.length||r>=c.length?null:i.reduce(function(d,f){var h,p=(h=f.props.data)!==null&&h!==void 0?h:n;p&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(p=p.slice(t.dataStartIndex,t.dataEndIndex+1));var y;if(o.dataKey&&!o.allowDuplicatedCategory){var g=p===void 0?c:p;y=ph(g,o.dataKey,a)}else y=p&&p[r]||c[r];return y?[].concat(yc(d),[CL(f,y)]):d},[])},VI=function(t,n,r,a){var i=a||{x:t.chartX,y:t.chartY},o=qde(i,r),c=t.orderedTooltipTicks,d=t.tooltipAxis,f=t.tooltipTicks,h=Are(o,c,f,d);if(h>=0&&f){var p=f[h]&&f[h].value,y=ZS(t,n,h,p),g=Wde(r,c,h,i);return{activeTooltipIndex:h,activeLabel:p,activePayload:y,activeCoordinate:g}}return null},Vde=function(t,n){var r=n.axes,a=n.graphicalItems,i=n.axisType,o=n.axisIdKey,c=n.stackGroups,d=n.dataStartIndex,f=n.dataEndIndex,h=t.layout,p=t.children,y=t.stackOffset,g=bL(h,i);return r.reduce(function(S,b){var x,j=b.type.defaultProps!==void 0?we(we({},b.type.defaultProps),b.props):b.props,N=j.type,_=j.dataKey,P=j.allowDataOverflow,A=j.allowDuplicatedCategory,O=j.scale,k=j.ticks,R=j.includeHidden,$=j[o];if(S[$])return S;var z=Iv(t.data,{graphicalItems:a.filter(function(M){var ee,W=o in M.props?M.props[o]:(ee=M.type.defaultProps)===null||ee===void 0?void 0:ee[o];return W===$}),dataStartIndex:d,dataEndIndex:f}),B=z.length,L,K,U;gde(j.domain,P,N)&&(L=pS(j.domain,null,P),g&&(N==="number"||O!=="auto")&&(U=Gu(z,_,"category")));var V=$4(N);if(!L||L.length===0){var X,J=(X=j.domain)!==null&&X!==void 0?X:V;if(_){if(L=Gu(z,_,N),N==="category"&&g){var T=bY(L);A&&T?(K=L,L=Zh(0,B)):A||(L=Y2(J,L,b).reduce(function(M,ee){return M.indexOf(ee)>=0?M:[].concat(yc(M),[ee])},[]))}else if(N==="category")A?L=L.filter(function(M){return M!==""&&!xt(M)}):L=Y2(J,L,b).reduce(function(M,ee){return M.indexOf(ee)>=0||ee===""||xt(ee)?M:[].concat(yc(M),[ee])},[]);else if(N==="number"){var D=Rre(z,a.filter(function(M){var ee,W,Z=o in M.props?M.props[o]:(ee=M.type.defaultProps)===null||ee===void 0?void 0:ee[o],ye="hide"in M.props?M.props.hide:(W=M.type.defaultProps)===null||W===void 0?void 0:W.hide;return Z===$&&(R||!ye)}),_,i,h);D&&(L=D)}g&&(N==="number"||O!=="auto")&&(U=Gu(z,_,"category"))}else g?L=Zh(0,B):c&&c[$]&&c[$].hasStack&&N==="number"?L=y==="expand"?[0,1]:NL(c[$].stackGroups,d,f):L=xL(z,a.filter(function(M){var ee=o in M.props?M.props[o]:M.type.defaultProps[o],W="hide"in M.props?M.props.hide:M.type.defaultProps.hide;return ee===$&&(R||!W)}),N,h,!0);if(N==="number")L=XS(p,L,$,i,k),J&&(L=pS(J,L,P));else if(N==="category"&&J){var Q=J,F=L.every(function(M){return Q.indexOf(M)>=0});F&&(L=Q)}}return we(we({},S),{},pt({},$,we(we({},j),{},{axisType:i,domain:L,categoricalDomain:U,duplicateDomain:K,originalDomain:(x=j.domain)!==null&&x!==void 0?x:V,isCategorical:g,layout:h})))},{})},Hde=function(t,n){var r=n.graphicalItems,a=n.Axis,i=n.axisType,o=n.axisIdKey,c=n.stackGroups,d=n.dataStartIndex,f=n.dataEndIndex,h=t.layout,p=t.children,y=Iv(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:f}),g=y.length,S=bL(h,i),b=-1;return r.reduce(function(x,j){var N=j.type.defaultProps!==void 0?we(we({},j.type.defaultProps),j.props):j.props,_=N[o],P=$4("number");if(!x[_]){b++;var A;return S?A=Zh(0,g):c&&c[_]&&c[_].hasStack?(A=NL(c[_].stackGroups,d,f),A=XS(p,A,_,i)):(A=pS(P,xL(y,r.filter(function(O){var k,R,$=o in O.props?O.props[o]:(k=O.type.defaultProps)===null||k===void 0?void 0:k[o],z="hide"in O.props?O.props.hide:(R=O.type.defaultProps)===null||R===void 0?void 0:R.hide;return $===_&&!z}),"number",h),a.defaultProps.allowDataOverflow),A=XS(p,A,_,i)),we(we({},x),{},pt({},_,we(we({axisType:i},a.defaultProps),{},{hide:!0,orientation:ea(zde,"".concat(i,".").concat(b%2),null),domain:A,originalDomain:P,isCategorical:S,layout:h})))}return x},{})},Kde=function(t,n){var r=n.axisType,a=r===void 0?"xAxis":r,i=n.AxisComp,o=n.graphicalItems,c=n.stackGroups,d=n.dataStartIndex,f=n.dataEndIndex,h=t.children,p="".concat(a,"Id"),y=ta(h,i),g={};return y&&y.length?g=Vde(t,{axes:y,graphicalItems:o,axisType:a,axisIdKey:p,stackGroups:c,dataStartIndex:d,dataEndIndex:f}):o&&o.length&&(g=Hde(t,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:p,stackGroups:c,dataStartIndex:d,dataEndIndex:f})),g},Gde=function(t){var n=wl(t),r=mo(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:fN(r,function(a){return a.coordinate}),tooltipAxis:n,tooltipAxisBandSize:Fh(n,r)}},HI=function(t){var n=t.children,r=t.defaultShowTooltip,a=Vr(n,oc),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},Yde=function(t){return!t||!t.length?!1:t.some(function(n){var r=Ls(n&&n.type);return r&&r.indexOf("Bar")>=0})},KI=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Xde=function(t,n){var r=t.props,a=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,c=t.yAxisMap,d=c===void 0?{}:c,f=r.width,h=r.height,p=r.children,y=r.margin||{},g=Vr(p,oc),S=Vr(p,$l),b=Object.keys(d).reduce(function(A,O){var k=d[O],R=k.orientation;return!k.mirror&&!k.hide?we(we({},A),{},pt({},R,A[R]+k.width)):A},{left:y.left||0,right:y.right||0}),x=Object.keys(o).reduce(function(A,O){var k=o[O],R=k.orientation;return!k.mirror&&!k.hide?we(we({},A),{},pt({},R,ea(A,"".concat(R))+k.height)):A},{top:y.top||0,bottom:y.bottom||0}),j=we(we({},x),b),N=j.bottom;g&&(j.bottom+=g.props.height||oc.defaultProps.height),S&&n&&(j=Ore(j,a,r,n));var _=f-j.left-j.right,P=h-j.top-j.bottom;return we(we({brushBottom:N},j),{},{width:Math.max(_,0),height:Math.max(P,0)})},Qde=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},WN=function(t){var n=t.chartName,r=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,o=t.validateTooltipEventTypes,c=o===void 0?["axis"]:o,d=t.axisComponents,f=t.legendContent,h=t.formatAxisMap,p=t.defaultProps,y=function(j,N){var _=N.graphicalItems,P=N.stackGroups,A=N.offset,O=N.updateId,k=N.dataStartIndex,R=N.dataEndIndex,$=j.barSize,z=j.layout,B=j.barGap,L=j.barCategoryGap,K=j.maxBarSize,U=KI(z),V=U.numericAxisName,X=U.cateAxisName,J=Yde(_),T=[];return _.forEach(function(D,Q){var F=Iv(j.data,{graphicalItems:[D],dataStartIndex:k,dataEndIndex:R}),M=D.type.defaultProps!==void 0?we(we({},D.type.defaultProps),D.props):D.props,ee=M.dataKey,W=M.maxBarSize,Z=M["".concat(V,"Id")],ye=M["".concat(X,"Id")],ae={},ue=d.reduce(function(et,dt){var Pt=N["".concat(dt.axisType,"Map")],hn=M["".concat(dt.axisType,"Id")];Pt&&Pt[hn]||dt.axisType==="zAxis"||_o();var be=Pt[hn];return we(we({},et),{},pt(pt({},dt.axisType,be),"".concat(dt.axisType,"Ticks"),mo(be)))},ae),ie=ue[X],ve=ue["".concat(X,"Ticks")],Oe=P&&P[Z]&&P[Z].hasStack&&zre(D,P[Z].stackGroups),oe=Ls(D.type).indexOf("Bar")>=0,he=Fh(ie,ve),xe=[],Ie=J&&Ere({barSize:$,stackGroups:P,totalSize:Qde(ue,X)});if(oe){var re,me,Ne=xt(W)?K:W,tt=(re=(me=Fh(ie,ve,!0))!==null&&me!==void 0?me:Ne)!==null&&re!==void 0?re:0;xe=Pre({barGap:B,barCategoryGap:L,bandSize:tt!==he?tt:he,sizeList:Ie[ye],maxBarSize:Ne}),tt!==he&&(xe=xe.map(function(et){return we(we({},et),{},{position:we(we({},et.position),{},{offset:et.position.offset-tt/2})})}))}var je=D&&D.type&&D.type.getComposedData;je&&T.push({props:we(we({},je(we(we({},ue),{},{displayedData:F,props:j,dataKey:ee,item:D,bandSize:he,barPosition:xe,offset:A,stackedData:Oe,layout:z,dataStartIndex:k,dataEndIndex:R}))),{},pt(pt(pt({key:D.key||"item-".concat(Q)},V,ue[V]),X,ue[X]),"animationId",O)),childIndex:TY(D,j.children),item:D})}),T},g=function(j,N){var _=j.props,P=j.dataStartIndex,A=j.dataEndIndex,O=j.updateId;if(!cO({props:_}))return null;var k=_.children,R=_.layout,$=_.stackOffset,z=_.data,B=_.reverseStackOrder,L=KI(R),K=L.numericAxisName,U=L.cateAxisName,V=ta(k,r),X=Fre(z,V,"".concat(K,"Id"),"".concat(U,"Id"),$,B),J=d.reduce(function(M,ee){var W="".concat(ee.axisType,"Map");return we(we({},M),{},pt({},W,Kde(_,we(we({},ee),{},{graphicalItems:V,stackGroups:ee.axisType===K&&X,dataStartIndex:P,dataEndIndex:A}))))},{}),T=Xde(we(we({},J),{},{props:_,graphicalItems:V}),N?.legendBBox);Object.keys(J).forEach(function(M){J[M]=h(_,J[M],T,M.replace("Map",""),n)});var D=J["".concat(U,"Map")],Q=Gde(D),F=y(_,we(we({},J),{},{dataStartIndex:P,dataEndIndex:A,updateId:O,graphicalItems:V,stackGroups:X,offset:T}));return we(we({formattedGraphicalItems:F,graphicalItems:V,offset:T,stackGroups:X},Q),J)},S=(function(x){function j(N){var _,P,A;return Ode(this,j),A=Tde(this,j,[N]),pt(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),pt(A,"accessibilityManager",new vde),pt(A,"handleLegendBBoxUpdate",function(O){if(O){var k=A.state,R=k.dataStartIndex,$=k.dataEndIndex,z=k.updateId;A.setState(we({legendBBox:O},g({props:A.props,dataStartIndex:R,dataEndIndex:$,updateId:z},we(we({},A.state),{},{legendBBox:O}))))}}),pt(A,"handleReceiveSyncEvent",function(O,k,R){if(A.props.syncId===O){if(R===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(k)}}),pt(A,"handleBrushChange",function(O){var k=O.startIndex,R=O.endIndex;if(k!==A.state.dataStartIndex||R!==A.state.dataEndIndex){var $=A.state.updateId;A.setState(function(){return we({dataStartIndex:k,dataEndIndex:R},g({props:A.props,dataStartIndex:k,dataEndIndex:R,updateId:$},A.state))}),A.triggerSyncEvent({dataStartIndex:k,dataEndIndex:R})}}),pt(A,"handleMouseEnter",function(O){var k=A.getMouseInfo(O);if(k){var R=we(we({},k),{},{isTooltipActive:!0});A.setState(R),A.triggerSyncEvent(R);var $=A.props.onMouseEnter;gt($)&&$(R,O)}}),pt(A,"triggeredAfterMouseMove",function(O){var k=A.getMouseInfo(O),R=k?we(we({},k),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState(R),A.triggerSyncEvent(R);var $=A.props.onMouseMove;gt($)&&$(R,O)}),pt(A,"handleItemMouseEnter",function(O){A.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),pt(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),pt(A,"handleMouseMove",function(O){O.persist(),A.throttleTriggeredAfterMouseMove(O)}),pt(A,"handleMouseLeave",function(O){A.throttleTriggeredAfterMouseMove.cancel();var k={isTooltipActive:!1};A.setState(k),A.triggerSyncEvent(k);var R=A.props.onMouseLeave;gt(R)&&R(k,O)}),pt(A,"handleOuterEvent",function(O){var k=RY(O),R=ea(A.props,"".concat(k));if(k&&gt(R)){var $,z;/.*touch.*/i.test(k)?z=A.getMouseInfo(O.changedTouches[0]):z=A.getMouseInfo(O),R(($=z)!==null&&$!==void 0?$:{},O)}}),pt(A,"handleClick",function(O){var k=A.getMouseInfo(O);if(k){var R=we(we({},k),{},{isTooltipActive:!0});A.setState(R),A.triggerSyncEvent(R);var $=A.props.onClick;gt($)&&$(R,O)}}),pt(A,"handleMouseDown",function(O){var k=A.props.onMouseDown;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"handleMouseUp",function(O){var k=A.props.onMouseUp;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),pt(A,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&A.handleMouseDown(O.changedTouches[0])}),pt(A,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&A.handleMouseUp(O.changedTouches[0])}),pt(A,"handleDoubleClick",function(O){var k=A.props.onDoubleClick;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"handleContextMenu",function(O){var k=A.props.onContextMenu;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"triggerSyncEvent",function(O){A.props.syncId!==void 0&&Zw.emit(e1,A.props.syncId,O,A.eventEmitterSymbol)}),pt(A,"applySyncEvent",function(O){var k=A.props,R=k.layout,$=k.syncMethod,z=A.state.updateId,B=O.dataStartIndex,L=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)A.setState(we({dataStartIndex:B,dataEndIndex:L},g({props:A.props,dataStartIndex:B,dataEndIndex:L,updateId:z},A.state)));else if(O.activeTooltipIndex!==void 0){var K=O.chartX,U=O.chartY,V=O.activeTooltipIndex,X=A.state,J=X.offset,T=X.tooltipTicks;if(!J)return;if(typeof $=="function")V=$(T,O);else if($==="value"){V=-1;for(var D=0;D<T.length;D++)if(T[D].value===O.activeLabel){V=D;break}}var Q=we(we({},J),{},{x:J.left,y:J.top}),F=Math.min(K,Q.x+Q.width),M=Math.min(U,Q.y+Q.height),ee=T[V]&&T[V].value,W=ZS(A.state,A.props.data,V),Z=T[V]?{x:R==="horizontal"?T[V].coordinate:F,y:R==="horizontal"?M:T[V].coordinate}:M4;A.setState(we(we({},O),{},{activeLabel:ee,activeCoordinate:Z,activePayload:W,activeTooltipIndex:V}))}else A.setState(O)}),pt(A,"renderCursor",function(O){var k,R=A.state,$=R.isTooltipActive,z=R.activeCoordinate,B=R.activePayload,L=R.offset,K=R.activeTooltipIndex,U=R.tooltipAxisBandSize,V=A.getTooltipEventType(),X=(k=O.props.active)!==null&&k!==void 0?k:$,J=A.props.layout,T=O.key||"_recharts-cursor";return q.createElement(jde,{key:T,activeCoordinate:z,activePayload:B,activeTooltipIndex:K,chartName:n,element:O,isActive:X,layout:J,offset:L,tooltipAxisBandSize:U,tooltipEventType:V})}),pt(A,"renderPolarAxis",function(O,k,R){var $=ea(O,"type.axisType"),z=ea(A.state,"".concat($,"Map")),B=O.type.defaultProps,L=B!==void 0?we(we({},B),O.props):O.props,K=z&&z[L["".concat($,"Id")]];return v.cloneElement(O,we(we({},K),{},{className:bt($,K.className),key:O.key||"".concat(k,"-").concat(R),ticks:mo(K,!0)}))}),pt(A,"renderPolarGrid",function(O){var k=O.props,R=k.radialLines,$=k.polarAngles,z=k.polarRadius,B=A.state,L=B.radiusAxisMap,K=B.angleAxisMap,U=wl(L),V=wl(K),X=V.cx,J=V.cy,T=V.innerRadius,D=V.outerRadius;return v.cloneElement(O,{polarAngles:Array.isArray($)?$:mo(V,!0).map(function(Q){return Q.coordinate}),polarRadius:Array.isArray(z)?z:mo(U,!0).map(function(Q){return Q.coordinate}),cx:X,cy:J,innerRadius:T,outerRadius:D,key:O.key||"polar-grid",radialLines:R})}),pt(A,"renderLegend",function(){var O=A.state.formattedGraphicalItems,k=A.props,R=k.children,$=k.width,z=k.height,B=A.props.margin||{},L=$-(B.left||0)-(B.right||0),K=gL({children:R,formattedGraphicalItems:O,legendWidth:L,legendContent:f});if(!K)return null;var U=K.item,V=qI(K,Nde);return v.cloneElement(U,we(we({},V),{},{chartWidth:$,chartHeight:z,margin:B,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),pt(A,"renderTooltip",function(){var O,k=A.props,R=k.children,$=k.accessibilityLayer,z=Vr(R,Hr);if(!z)return null;var B=A.state,L=B.isTooltipActive,K=B.activeCoordinate,U=B.activePayload,V=B.activeLabel,X=B.offset,J=(O=z.props.active)!==null&&O!==void 0?O:L;return v.cloneElement(z,{viewBox:we(we({},X),{},{x:X.left,y:X.top}),active:J,label:V,payload:J?U:[],coordinate:K,accessibilityLayer:$})}),pt(A,"renderBrush",function(O){var k=A.props,R=k.margin,$=k.data,z=A.state,B=z.offset,L=z.dataStartIndex,K=z.dataEndIndex,U=z.updateId;return v.cloneElement(O,{key:O.key||"_recharts-brush",onChange:zp(A.handleBrushChange,O.props.onChange),data:$,x:$e(O.props.x)?O.props.x:B.left,y:$e(O.props.y)?O.props.y:B.top+B.height+B.brushBottom-(R.bottom||0),width:$e(O.props.width)?O.props.width:B.width,startIndex:L,endIndex:K,updateId:"brush-".concat(U)})}),pt(A,"renderReferenceElement",function(O,k,R){if(!O)return null;var $=A,z=$.clipPathId,B=A.state,L=B.xAxisMap,K=B.yAxisMap,U=B.offset,V=O.type.defaultProps||{},X=O.props,J=X.xAxisId,T=J===void 0?V.xAxisId:J,D=X.yAxisId,Q=D===void 0?V.yAxisId:D;return v.cloneElement(O,{key:O.key||"".concat(k,"-").concat(R),xAxis:L[T],yAxis:K[Q],viewBox:{x:U.left,y:U.top,width:U.width,height:U.height},clipPathId:z})}),pt(A,"renderActivePoints",function(O){var k=O.item,R=O.activePoint,$=O.basePoint,z=O.childIndex,B=O.isRange,L=[],K=k.props.key,U=k.item.type.defaultProps!==void 0?we(we({},k.item.type.defaultProps),k.item.props):k.item.props,V=U.activeDot,X=U.dataKey,J=we(we({index:z,dataKey:X,cx:R.x,cy:R.y,r:4,fill:LN(k.item),strokeWidth:2,stroke:"#fff",payload:R.payload,value:R.value},ft(V,!1)),hh(V));return L.push(j.renderActiveDot(V,J,"".concat(K,"-activePoint-").concat(z))),$?L.push(j.renderActiveDot(V,we(we({},J),{},{cx:$.x,cy:$.y}),"".concat(K,"-basePoint-").concat(z))):B&&L.push(null),L}),pt(A,"renderGraphicChild",function(O,k,R){var $=A.filterFormatItem(O,k,R);if(!$)return null;var z=A.getTooltipEventType(),B=A.state,L=B.isTooltipActive,K=B.tooltipAxis,U=B.activeTooltipIndex,V=B.activeLabel,X=A.props.children,J=Vr(X,Hr),T=$.props,D=T.points,Q=T.isRange,F=T.baseLine,M=$.item.type.defaultProps!==void 0?we(we({},$.item.type.defaultProps),$.item.props):$.item.props,ee=M.activeDot,W=M.hide,Z=M.activeBar,ye=M.activeShape,ae=!!(!W&&L&&J&&(ee||Z||ye)),ue={};z!=="axis"&&J&&J.props.trigger==="click"?ue={onClick:zp(A.handleItemMouseEnter,O.props.onClick)}:z!=="axis"&&(ue={onMouseLeave:zp(A.handleItemMouseLeave,O.props.onMouseLeave),onMouseEnter:zp(A.handleItemMouseEnter,O.props.onMouseEnter)});var ie=v.cloneElement(O,we(we({},$.props),ue));function ve(dt){return typeof K.dataKey=="function"?K.dataKey(dt.payload):null}if(ae)if(U>=0){var Oe,oe;if(K.dataKey&&!K.allowDuplicatedCategory){var he=typeof K.dataKey=="function"?ve:"payload.".concat(K.dataKey.toString());Oe=ph(D,he,V),oe=Q&&F&&ph(F,he,V)}else Oe=D?.[U],oe=Q&&F&&F[U];if(ye||Z){var xe=O.props.activeIndex!==void 0?O.props.activeIndex:U;return[v.cloneElement(O,we(we(we({},$.props),ue),{},{activeIndex:xe})),null,null]}if(!xt(Oe))return[ie].concat(yc(A.renderActivePoints({item:$,activePoint:Oe,basePoint:oe,childIndex:U,isRange:Q})))}else{var Ie,re=(Ie=A.getItemByXY(A.state.activeCoordinate))!==null&&Ie!==void 0?Ie:{graphicalItem:ie},me=re.graphicalItem,Ne=me.item,tt=Ne===void 0?O:Ne,je=me.childIndex,et=we(we(we({},$.props),ue),{},{activeIndex:je});return[v.cloneElement(tt,et),null,null]}return Q?[ie,null,null]:[ie,null]}),pt(A,"renderCustomized",function(O,k,R){return v.cloneElement(O,we(we({key:"recharts-customized-".concat(R)},A.props),A.state))}),pt(A,"renderMap",{CartesianGrid:{handler:Hp,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:Hp},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:Hp},YAxis:{handler:Hp},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((_=N.id)!==null&&_!==void 0?_:Tc("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=g5(A.triggeredAfterMouseMove,(P=N.throttleDelay)!==null&&P!==void 0?P:1e3/60),A.state={},A}return $de(j,x),Rde(j,[{key:"componentDidMount",value:function(){var _,P;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(_=this.props.margin.left)!==null&&_!==void 0?_:0,top:(P=this.props.margin.top)!==null&&P!==void 0?P:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var _=this.props,P=_.children,A=_.data,O=_.height,k=_.layout,R=Vr(P,Hr);if(R){var $=R.props.defaultIndex;if(!(typeof $!="number"||$<0||$>this.state.tooltipTicks.length-1)){var z=this.state.tooltipTicks[$]&&this.state.tooltipTicks[$].value,B=ZS(this.state,A,$,z),L=this.state.tooltipTicks[$].coordinate,K=(this.state.offset.top+O)/2,U=k==="horizontal",V=U?{x:L,y:K}:{y:L,x:K},X=this.state.formattedGraphicalItems.find(function(T){var D=T.item;return D.type.name==="Scatter"});X&&(V=we(we({},V),X.props.points[$].tooltipPosition),B=X.props.points[$].tooltipPayload);var J={activeTooltipIndex:$,isTooltipActive:!0,activeLabel:z,activePayload:B,activeCoordinate:V};this.setState(J),this.renderCursor(R),this.accessibilityManager.setIndex($)}}}},{key:"getSnapshotBeforeUpdate",value:function(_,P){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==P.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==_.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==_.margin){var A,O;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(_){I1([Vr(_.children,Hr)],[Vr(this.props.children,Hr)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var _=Vr(this.props.children,Hr);if(_&&typeof _.props.shared=="boolean"){var P=_.props.shared?"axis":"item";return c.indexOf(P)>=0?P:i}return i}},{key:"getMouseInfo",value:function(_){if(!this.container)return null;var P=this.container,A=P.getBoundingClientRect(),O=xZ(A),k={chartX:Math.round(_.pageX-O.left),chartY:Math.round(_.pageY-O.top)},R=A.width/P.offsetWidth||1,$=this.inRange(k.chartX,k.chartY,R);if(!$)return null;var z=this.state,B=z.xAxisMap,L=z.yAxisMap,K=this.getTooltipEventType(),U=VI(this.state,this.props.data,this.props.layout,$);if(K!=="axis"&&B&&L){var V=wl(B).scale,X=wl(L).scale,J=V&&V.invert?V.invert(k.chartX):null,T=X&&X.invert?X.invert(k.chartY):null;return we(we({},k),{},{xValue:J,yValue:T},U)}return U?we(we({},k),U):null}},{key:"inRange",value:function(_,P){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,k=_/A,R=P/A;if(O==="horizontal"||O==="vertical"){var $=this.state.offset,z=k>=$.left&&k<=$.left+$.width&&R>=$.top&&R<=$.top+$.height;return z?{x:k,y:R}:null}var B=this.state,L=B.angleAxisMap,K=B.radiusAxisMap;if(L&&K){var U=wl(L);return J2({x:k,y:R},U)}return null}},{key:"parseEventsOfWrapper",value:function(){var _=this.props.children,P=this.getTooltipEventType(),A=Vr(_,Hr),O={};A&&P==="axis"&&(A.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var k=hh(this.props,this.handleOuterEvent);return we(we({},k),O)}},{key:"addListener",value:function(){Zw.on(e1,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Zw.removeListener(e1,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(_,P,A){for(var O=this.state.formattedGraphicalItems,k=0,R=O.length;k<R;k++){var $=O[k];if($.item===_||$.props.key===_.key||P===Ls($.item.type)&&A===$.childIndex)return $}return null}},{key:"renderClipPath",value:function(){var _=this.clipPathId,P=this.state.offset,A=P.left,O=P.top,k=P.height,R=P.width;return q.createElement("defs",null,q.createElement("clipPath",{id:_},q.createElement("rect",{x:A,y:O,height:k,width:R})))}},{key:"getXScales",value:function(){var _=this.state.xAxisMap;return _?Object.entries(_).reduce(function(P,A){var O=UI(A,2),k=O[0],R=O[1];return we(we({},P),{},pt({},k,R.scale))},{}):null}},{key:"getYScales",value:function(){var _=this.state.yAxisMap;return _?Object.entries(_).reduce(function(P,A){var O=UI(A,2),k=O[0],R=O[1];return we(we({},P),{},pt({},k,R.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(_){var P;return(P=this.state.xAxisMap)===null||P===void 0||(P=P[_])===null||P===void 0?void 0:P.scale}},{key:"getYScaleByAxisId",value:function(_){var P;return(P=this.state.yAxisMap)===null||P===void 0||(P=P[_])===null||P===void 0?void 0:P.scale}},{key:"getItemByXY",value:function(_){var P=this.state,A=P.formattedGraphicalItems,O=P.activeItem;if(A&&A.length)for(var k=0,R=A.length;k<R;k++){var $=A[k],z=$.props,B=$.item,L=B.type.defaultProps!==void 0?we(we({},B.type.defaultProps),B.props):B.props,K=Ls(B.type);if(K==="Bar"){var U=(z.data||[]).find(function(T){return Bie(_,T)});if(U)return{graphicalItem:$,payload:U}}else if(K==="RadialBar"){var V=(z.data||[]).find(function(T){return J2(_,T)});if(V)return{graphicalItem:$,payload:V}}else if(_v($,O)||Av($,O)||Md($,O)){var X=cle({graphicalItem:$,activeTooltipItem:O,itemData:L.data}),J=L.activeIndex===void 0?X:L.activeIndex;return{graphicalItem:we(we({},$),{},{childIndex:J}),payload:Md($,O)?L.data[X]:$.props.data[X]}}}return null}},{key:"render",value:function(){var _=this;if(!cO(this))return null;var P=this.props,A=P.children,O=P.className,k=P.width,R=P.height,$=P.style,z=P.compact,B=P.title,L=P.desc,K=qI(P,Cde),U=ft(K,!1);if(z)return q.createElement(CI,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},q.createElement($1,El({},U,{width:k,height:R,title:B,desc:L}),this.renderClipPath(),dO(A,this.renderMap)));if(this.props.accessibilityLayer){var V,X;U.tabIndex=(V=this.props.tabIndex)!==null&&V!==void 0?V:0,U.role=(X=this.props.role)!==null&&X!==void 0?X:"application",U.onKeyDown=function(T){_.accessibilityManager.keyboardEvent(T)},U.onFocus=function(){_.accessibilityManager.focus()}}var J=this.parseEventsOfWrapper();return q.createElement(CI,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},q.createElement("div",El({className:bt("recharts-wrapper",O),style:we({position:"relative",cursor:"default",width:k,height:R},$)},J,{ref:function(D){_.container=D}}),q.createElement($1,El({},U,{width:k,height:R,title:B,desc:L,style:Ude}),this.renderClipPath(),dO(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(v.Component);pt(S,"displayName",n),pt(S,"defaultProps",we({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},p)),pt(S,"getDerivedStateFromProps",function(x,j){var N=x.dataKey,_=x.data,P=x.children,A=x.width,O=x.height,k=x.layout,R=x.stackOffset,$=x.margin,z=j.dataStartIndex,B=j.dataEndIndex;if(j.updateId===void 0){var L=HI(x);return we(we(we({},L),{},{updateId:0},g(we(we({props:x},L),{},{updateId:0}),j)),{},{prevDataKey:N,prevData:_,prevWidth:A,prevHeight:O,prevLayout:k,prevStackOffset:R,prevMargin:$,prevChildren:P})}if(N!==j.prevDataKey||_!==j.prevData||A!==j.prevWidth||O!==j.prevHeight||k!==j.prevLayout||R!==j.prevStackOffset||!Ml($,j.prevMargin)){var K=HI(x),U={chartX:j.chartX,chartY:j.chartY,isTooltipActive:j.isTooltipActive},V=we(we({},VI(j,_,k)),{},{updateId:j.updateId+1}),X=we(we(we({},K),U),V);return we(we(we({},X),g(we({props:x},X),j)),{},{prevDataKey:N,prevData:_,prevWidth:A,prevHeight:O,prevLayout:k,prevStackOffset:R,prevMargin:$,prevChildren:P})}if(!I1(P,j.prevChildren)){var J,T,D,Q,F=Vr(P,oc),M=F&&(J=(T=F.props)===null||T===void 0?void 0:T.startIndex)!==null&&J!==void 0?J:z,ee=F&&(D=(Q=F.props)===null||Q===void 0?void 0:Q.endIndex)!==null&&D!==void 0?D:B,W=M!==z||ee!==B,Z=!xt(_),ye=Z&&!W?j.updateId:j.updateId+1;return we(we({updateId:ye},g(we(we({props:x},j),{},{updateId:ye,dataStartIndex:M,dataEndIndex:ee}),j)),{},{prevChildren:P,dataStartIndex:M,dataEndIndex:ee})}return null}),pt(S,"renderActiveDot",function(x,j,N){var _;return v.isValidElement(x)?_=v.cloneElement(x,j):gt(x)?_=x(j):_=q.createElement(wv,j),q.createElement(Tt,{className:"recharts-active-dot",key:N},_)});var b=v.forwardRef(function(j,N){return q.createElement(S,El({},j,{ref:N}))});return b.displayName=S.displayName,b},GI=WN({chartName:"LineChart",GraphicalChild:hc,axisComponents:[{axisType:"xAxis",AxisComp:Ao},{axisType:"yAxis",AxisComp:Eo}],formatAxisMap:e4}),Jde=WN({chartName:"BarChart",GraphicalChild:zo,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Ao},{axisType:"yAxis",AxisComp:Eo}],formatAxisMap:e4}),Zde=WN({chartName:"PieChart",GraphicalChild:Js,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Cv},{axisType:"radiusAxis",AxisComp:jv}],formatAxisMap:Qre,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const efe=()=>{const{configs:e}=tf(),{source:t}=On(),[n,r]=v.useState([]),[a,i]=v.useState("timestamp"),[o,c]=v.useState("desc"),d=x=>{if(a===x){c(j=>j==="asc"?"desc":"asc");return}i(x),c("desc")};v.useEffect(()=>{let x=!0;return t.listResults().then(j=>{x&&r(j)}),()=>{x=!1}},[t]);const f=e.length,h=n.length,p=h===0?0:n.reduce((x,j)=>x+j.overallPassRate,0)/h,y=h===0?0:Math.round(n.reduce((x,j)=>x+j.avgLatency,0)/h),g=v.useMemo(()=>[...n].sort((j,N)=>{let _=0;return a==="timestamp"&&(_=new Date(j.timestamp).getTime()-new Date(N.timestamp).getTime()),a==="passRate"&&(_=j.overallPassRate-N.overallPassRate),a==="latency"&&(_=j.avgLatency-N.avgLatency),a==="scenarios"&&(_=j.totalScenarios-N.totalScenarios),o==="asc"?_:-_}),[n,a,o]),S=[...g].reverse().map(x=>({date:new Date(x.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric"}),passRate:Math.round(x.overallPassRate*100),latency:x.avgLatency})),b=x=>{const j=Array.from(new Set(x.scenarios.map(A=>A.scenarioId).filter(Boolean))),N=Array.from(new Set(x.scenarios.map(A=>A.agentName).filter(Boolean))),_=j.slice(0,2).join(", "),P=j.length>2?` +${j.length-2}`:"";return{scenarioCount:j.length,agentCount:N.length,scenarioPreview:_?`${_}${P}`:"n/a"}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(r$,{className:"h-6 w-6"}),"Dashboard"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Overview of your MCP evaluation runs"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(se,{asChild:!0,children:s.jsxs(yt,{to:"/mcp-evaluations/new",children:[s.jsx(jj,{className:"mr-2 h-4 w-4"}),"New MCP Evaluation"]})}),s.jsx(se,{variant:"outline",asChild:!0,children:s.jsxs(yt,{to:"/run",children:[s.jsx(kl,{className:"mr-2 h-4 w-4"}),"Run Evaluation"]})}),s.jsx(se,{variant:"outline",asChild:!0,children:s.jsxs(yt,{to:"/results",children:[s.jsx(ed,{className:"mr-2 h-4 w-4"}),"Browse Results"]})})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Ts,{title:"MCP Evaluations",value:f,icon:p1,subtitle:`${f} active`}),s.jsx(Ts,{title:"Total Runs",value:h,icon:JM,subtitle:"Last 30 days"}),s.jsx(Ts,{title:"Pass Rate",value:`${Math.round(p*100)}%`,icon:ed,subtitle:"+5% from last week",trend:"up"}),s.jsx(Ts,{title:"Avg Latency",value:`${y}ms`,icon:l$,subtitle:"-120ms from last week",trend:"up"})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Pass Rate Trend"})}),s.jsx(ze,{children:s.jsx(X1,{width:"100%",height:200,children:s.jsxs(GI,{data:S,children:[s.jsx(Ao,{dataKey:"date",tick:{fontSize:11},tickLine:!1,axisLine:!1}),s.jsx(Eo,{domain:[0,100],tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:x=>`${x}%`}),s.jsx(Hr,{formatter:x=>[`${x}%`,"Pass Rate"]}),s.jsx(hc,{type:"monotone",dataKey:"passRate",stroke:"hsl(38, 92%, 50%)",strokeWidth:2,dot:{r:3,fill:"hsl(38, 92%, 50%)"}})]})})})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Recent Tool Latency (ms)"})}),s.jsx(ze,{children:s.jsx(X1,{width:"100%",height:200,children:s.jsxs(GI,{data:S,children:[s.jsx(Ao,{dataKey:"date",tick:{fontSize:11},tickLine:!1,axisLine:!1}),s.jsx(Eo,{tick:{fontSize:11},tickLine:!1,axisLine:!1}),s.jsx(Hr,{formatter:x=>[`${x}ms`,"Latency"]}),s.jsx(hc,{type:"monotone",dataKey:"latency",stroke:"hsl(200, 80%, 50%)",strokeWidth:2,dot:{r:3,fill:"hsl(200, 80%, 50%)"}})]})})})]})]}),s.jsx("div",{className:"grid gap-6",children:s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Recent Runs"})}),s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Run ID"}),s.jsx(Qe,{children:"Evaluated"}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>d("timestamp"),children:["Timestamp",a==="timestamp"?o==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}):s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>d("passRate"),children:["Pass Rate",a==="passRate"?o==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}):s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>d("scenarios"),children:["Scenarios",a==="scenarios"?o==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}):s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"})]})})]})}),s.jsx(Jr,{children:g.map(x=>s.jsxs(Bt,{className:"cursor-pointer",children:[s.jsx(Fe,{children:s.jsx(yt,{to:`/results/${x.id}`,className:"font-mono text-xs text-primary hover:underline",children:x.id})}),s.jsx(Fe,{className:"text-[11px] text-muted-foreground",children:(()=>{const j=b(x);return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{children:["Evaluated: ",j.scenarioCount," scenario",j.scenarioCount===1?"":"s"," · ",j.agentCount," agent",j.agentCount===1?"":"s"]}),s.jsx("div",{className:"font-mono text-xs text-foreground/80",children:j.scenarioPreview})]})})()}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Nm,{className:"h-3 w-3"}),new Date(x.timestamp).toLocaleString()]})}),s.jsx(Fe,{children:s.jsx(vo,{rate:x.overallPassRate})}),s.jsx(Fe,{className:"text-right font-mono text-sm",children:x.totalScenarios})]},x.id))})]})})]})})]})};var tfe=v.createContext(void 0);function Lc(e){const t=v.useContext(tfe);return e||t||"ltr"}var n1="rovingFocusGroup.onEntryFocus",nfe={bubbles:!1,cancelable:!0},ff="RovingFocusGroup",[ej,D4,rfe]=Hd(ff),[afe,Mv]=ir(ff,[rfe]),[sfe,ife]=afe(ff),L4=v.forwardRef((e,t)=>s.jsx(ej.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ej.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ofe,{...e,ref:t})})}));L4.displayName=ff;var ofe=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:h=!1,...p}=e,y=v.useRef(null),g=ut(t,y),S=Lc(i),[b,x]=na({prop:o,defaultProp:c??null,onChange:d,caller:ff}),[j,N]=v.useState(!1),_=Pn(f),P=D4(n),A=v.useRef(!1),[O,k]=v.useState(0);return v.useEffect(()=>{const R=y.current;if(R)return R.addEventListener(n1,_),()=>R.removeEventListener(n1,_)},[_]),s.jsx(sfe,{scope:n,orientation:r,dir:S,loop:a,currentTabStopId:b,onItemFocus:v.useCallback(R=>x(R),[x]),onItemShiftTab:v.useCallback(()=>N(!0),[]),onFocusableItemAdd:v.useCallback(()=>k(R=>R+1),[]),onFocusableItemRemove:v.useCallback(()=>k(R=>R-1),[]),children:s.jsx(De.div,{tabIndex:j||O===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Ae(e.onMouseDown,()=>{A.current=!0}),onFocus:Ae(e.onFocus,R=>{const $=!A.current;if(R.target===R.currentTarget&&$&&!j){const z=new CustomEvent(n1,nfe);if(R.currentTarget.dispatchEvent(z),!z.defaultPrevented){const B=P().filter(X=>X.focusable),L=B.find(X=>X.active),K=B.find(X=>X.id===b),V=[L,K,...B].filter(Boolean).map(X=>X.ref.current);z4(V,h)}}A.current=!1}),onBlur:Ae(e.onBlur,()=>N(!1))})})}),F4="RovingFocusGroupItem",B4=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=e,d=Hn(),f=i||d,h=ife(F4,n),p=h.currentTabStopId===f,y=D4(n),{onFocusableItemAdd:g,onFocusableItemRemove:S,currentTabStopId:b}=h;return v.useEffect(()=>{if(r)return g(),()=>S()},[r,g,S]),s.jsx(ej.ItemSlot,{scope:n,id:f,focusable:r,active:a,children:s.jsx(De.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...c,ref:t,onMouseDown:Ae(e.onMouseDown,x=>{r?h.onItemFocus(f):x.preventDefault()}),onFocus:Ae(e.onFocus,()=>h.onItemFocus(f)),onKeyDown:Ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const j=ufe(x,h.orientation,h.dir);if(j!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let _=y().filter(P=>P.focusable).map(P=>P.ref.current);if(j==="last")_.reverse();else if(j==="prev"||j==="next"){j==="prev"&&_.reverse();const P=_.indexOf(x.currentTarget);_=h.loop?dfe(_,P+1):_.slice(P+1)}setTimeout(()=>z4(_))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:b!=null}):o})})});B4.displayName=F4;var lfe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cfe(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ufe(e,t,n){const r=cfe(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return lfe[r]}function z4(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dfe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var U4=L4,q4=B4;function ffe(e){const t=pfe(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(mfe);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function pfe(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=gfe(a),c=vfe(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var hfe=Symbol("radix.slottable");function mfe(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hfe}function vfe(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function gfe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var tj=["Enter"," "],yfe=["ArrowDown","PageUp","Home"],W4=["ArrowUp","PageDown","End"],xfe=[...yfe,...W4],bfe={ltr:[...tj,"ArrowRight"],rtl:[...tj,"ArrowLeft"]},wfe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pf="Menu",[Ud,Sfe,jfe]=Hd(pf),[Uo,V4]=ir(pf,[jfe,Di,Mv]),$v=Di(),H4=Mv(),[Nfe,qo]=Uo(pf),[Cfe,hf]=Uo(pf),K4=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=e,c=$v(t),[d,f]=v.useState(null),h=v.useRef(!1),p=Pn(i),y=Lc(a);return v.useEffect(()=>{const g=()=>{h.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>h.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),s.jsx(Rm,{...c,children:s.jsx(Nfe,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:s.jsx(Cfe,{scope:t,onClose:v.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:y,modal:o,children:r})})})};K4.displayName=pf;var _fe="MenuAnchor",VN=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=$v(n);return s.jsx(Yd,{...a,...r,ref:t})});VN.displayName=_fe;var HN="MenuPortal",[Afe,G4]=Uo(HN,{forceMount:void 0}),Y4=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,i=qo(HN,t);return s.jsx(Afe,{scope:t,forceMount:n,children:s.jsx(Gn,{present:n||i.open,children:s.jsx(Sc,{asChild:!0,container:a,children:r})})})};Y4.displayName=HN;var ya="MenuContent",[Efe,KN]=Uo(ya),X4=v.forwardRef((e,t)=>{const n=G4(ya,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=qo(ya,e.__scopeMenu),o=hf(ya,e.__scopeMenu);return s.jsx(Ud.Provider,{scope:e.__scopeMenu,children:s.jsx(Gn,{present:r||i.open,children:s.jsx(Ud.Slot,{scope:e.__scopeMenu,children:o.modal?s.jsx(Pfe,{...a,ref:t}):s.jsx(Ofe,{...a,ref:t})})})})}),Pfe=v.forwardRef((e,t)=>{const n=qo(ya,e.__scopeMenu),r=v.useRef(null),a=ut(t,r);return v.useEffect(()=>{const i=r.current;if(i)return Hm(i)},[]),s.jsx(GN,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ae(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ofe=v.forwardRef((e,t)=>{const n=qo(ya,e.__scopeMenu);return s.jsx(GN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),kfe=ffe("MenuContent.ScrollLock"),GN=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:g,disableOutsideScroll:S,...b}=e,x=qo(ya,n),j=hf(ya,n),N=$v(n),_=H4(n),P=Sfe(n),[A,O]=v.useState(null),k=v.useRef(null),R=ut(t,k,x.onContentChange),$=v.useRef(0),z=v.useRef(""),B=v.useRef(0),L=v.useRef(null),K=v.useRef("right"),U=v.useRef(0),V=S?Qd:v.Fragment,X=S?{as:kfe,allowPinchZoom:!0}:void 0,J=D=>{const Q=z.current+D,F=P().filter(ae=>!ae.disabled),M=document.activeElement,ee=F.find(ae=>ae.ref.current===M)?.textValue,W=F.map(ae=>ae.textValue),Z=qfe(W,Q,ee),ye=F.find(ae=>ae.textValue===Z)?.ref.current;(function ae(ue){z.current=ue,window.clearTimeout($.current),ue!==""&&($.current=window.setTimeout(()=>ae(""),1e3))})(Q),ye&&setTimeout(()=>ye.focus())};v.useEffect(()=>()=>window.clearTimeout($.current),[]),Wm();const T=v.useCallback(D=>K.current===L.current?.side&&Vfe(D,L.current?.area),[]);return s.jsx(Efe,{scope:n,searchRef:z,onItemEnter:v.useCallback(D=>{T(D)&&D.preventDefault()},[T]),onItemLeave:v.useCallback(D=>{T(D)||(k.current?.focus(),O(null))},[T]),onTriggerLeave:v.useCallback(D=>{T(D)&&D.preventDefault()},[T]),pointerGraceTimerRef:B,onPointerGraceIntentChange:v.useCallback(D=>{L.current=D},[]),children:s.jsx(V,{...X,children:s.jsx(Xd,{asChild:!0,trapped:a,onMountAutoFocus:Ae(i,D=>{D.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:g,children:s.jsx(U4,{asChild:!0,..._,dir:j.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:O,onEntryFocus:Ae(d,D=>{j.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Tm,{role:"menu","aria-orientation":"vertical","data-state":fF(x.open),"data-radix-menu-content":"",dir:j.dir,...N,...b,ref:R,style:{outline:"none",...b.style},onKeyDown:Ae(b.onKeyDown,D=>{const F=D.target.closest("[data-radix-menu-content]")===D.currentTarget,M=D.ctrlKey||D.altKey||D.metaKey,ee=D.key.length===1;F&&(D.key==="Tab"&&D.preventDefault(),!M&&ee&&J(D.key));const W=k.current;if(D.target!==W||!xfe.includes(D.key))return;D.preventDefault();const ye=P().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);W4.includes(D.key)&&ye.reverse(),zfe(ye)}),onBlur:Ae(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout($.current),z.current="")}),onPointerMove:Ae(e.onPointerMove,qd(D=>{const Q=D.target,F=U.current!==D.clientX;if(D.currentTarget.contains(Q)&&F){const M=D.clientX>U.current?"right":"left";K.current=M,U.current=D.clientX}}))})})})})})})});X4.displayName=ya;var Rfe="MenuGroup",YN=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(De.div,{role:"group",...r,ref:t})});YN.displayName=Rfe;var Tfe="MenuLabel",Q4=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(De.div,{...r,ref:t})});Q4.displayName=Tfe;var pm="MenuItem",YI="menu.itemSelect",Dv=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,i=v.useRef(null),o=hf(pm,e.__scopeMenu),c=KN(pm,e.__scopeMenu),d=ut(t,i),f=v.useRef(!1),h=()=>{const p=i.current;if(!n&&p){const y=new CustomEvent(YI,{bubbles:!0,cancelable:!0});p.addEventListener(YI,g=>r?.(g),{once:!0}),gj(p,y),y.defaultPrevented?f.current=!1:o.onClose()}};return s.jsx(J4,{...a,ref:d,disabled:n,onClick:Ae(e.onClick,h),onPointerDown:p=>{e.onPointerDown?.(p),f.current=!0},onPointerUp:Ae(e.onPointerUp,p=>{f.current||p.currentTarget?.click()}),onKeyDown:Ae(e.onKeyDown,p=>{const y=c.searchRef.current!=="";n||y&&p.key===" "||tj.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Dv.displayName=pm;var J4=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=e,o=KN(pm,n),c=H4(n),d=v.useRef(null),f=ut(t,d),[h,p]=v.useState(!1),[y,g]=v.useState("");return v.useEffect(()=>{const S=d.current;S&&g((S.textContent??"").trim())},[i.children]),s.jsx(Ud.ItemSlot,{scope:n,disabled:r,textValue:a??y,children:s.jsx(q4,{asChild:!0,...c,focusable:!r,children:s.jsx(De.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:f,onPointerMove:Ae(e.onPointerMove,qd(S=>{r?o.onItemLeave(S):(o.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ae(e.onPointerLeave,qd(S=>o.onItemLeave(S))),onFocus:Ae(e.onFocus,()=>p(!0)),onBlur:Ae(e.onBlur,()=>p(!1))})})})}),Ife="MenuCheckboxItem",Z4=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return s.jsx(aF,{scope:e.__scopeMenu,checked:n,children:s.jsx(Dv,{role:"menuitemcheckbox","aria-checked":hm(n)?"mixed":n,...a,ref:t,"data-state":QN(n),onSelect:Ae(a.onSelect,()=>r?.(hm(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Z4.displayName=Ife;var eF="MenuRadioGroup",[Mfe,$fe]=Uo(eF,{value:void 0,onValueChange:()=>{}}),tF=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,i=Pn(r);return s.jsx(Mfe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:s.jsx(YN,{...a,ref:t})})});tF.displayName=eF;var nF="MenuRadioItem",rF=v.forwardRef((e,t)=>{const{value:n,...r}=e,a=$fe(nF,e.__scopeMenu),i=n===a.value;return s.jsx(aF,{scope:e.__scopeMenu,checked:i,children:s.jsx(Dv,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":QN(i),onSelect:Ae(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});rF.displayName=nF;var XN="MenuItemIndicator",[aF,Dfe]=Uo(XN,{checked:!1}),sF=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,i=Dfe(XN,n);return s.jsx(Gn,{present:r||hm(i.checked)||i.checked===!0,children:s.jsx(De.span,{...a,ref:t,"data-state":QN(i.checked)})})});sF.displayName=XN;var Lfe="MenuSeparator",iF=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(De.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});iF.displayName=Lfe;var Ffe="MenuArrow",oF=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=$v(n);return s.jsx(Im,{...a,...r,ref:t})});oF.displayName=Ffe;var Bfe="MenuSub",[Ege,lF]=Uo(Bfe),Uu="MenuSubTrigger",cF=v.forwardRef((e,t)=>{const n=qo(Uu,e.__scopeMenu),r=hf(Uu,e.__scopeMenu),a=lF(Uu,e.__scopeMenu),i=KN(Uu,e.__scopeMenu),o=v.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=i,f={__scopeMenu:e.__scopeMenu},h=v.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return v.useEffect(()=>h,[h]),v.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),s.jsx(VN,{asChild:!0,...f,children:s.jsx(J4,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":fF(n.open),...e,ref:jr(t,a.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ae(e.onPointerMove,qd(p=>{i.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Ae(e.onPointerLeave,qd(p=>{h();const y=n.content?.getBoundingClientRect();if(y){const g=n.content?.dataset.side,S=g==="right",b=S?-5:5,x=y[S?"left":"right"],j=y[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x,y:y.top},{x:j,y:y.top},{x:j,y:y.bottom},{x,y:y.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(p),p.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ae(e.onKeyDown,p=>{const y=i.searchRef.current!=="";e.disabled||y&&p.key===" "||bfe[r.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});cF.displayName=Uu;var uF="MenuSubContent",dF=v.forwardRef((e,t)=>{const n=G4(ya,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=qo(ya,e.__scopeMenu),o=hf(ya,e.__scopeMenu),c=lF(uF,e.__scopeMenu),d=v.useRef(null),f=ut(t,d);return s.jsx(Ud.Provider,{scope:e.__scopeMenu,children:s.jsx(Gn,{present:r||i.open,children:s.jsx(Ud.Slot,{scope:e.__scopeMenu,children:s.jsx(GN,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:f,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{o.isUsingKeyboardRef.current&&d.current?.focus(),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Ae(e.onFocusOutside,h=>{h.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ae(e.onEscapeKeyDown,h=>{o.onClose(),h.preventDefault()}),onKeyDown:Ae(e.onKeyDown,h=>{const p=h.currentTarget.contains(h.target),y=wfe[o.dir].includes(h.key);p&&y&&(i.onOpenChange(!1),c.trigger?.focus(),h.preventDefault())})})})})})});dF.displayName=uF;function fF(e){return e?"open":"closed"}function hm(e){return e==="indeterminate"}function QN(e){return hm(e)?"indeterminate":e?"checked":"unchecked"}function zfe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ufe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function qfe(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=Ufe(e,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const d=o.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function Wfe(e,t){const{x:n,y:r}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const c=t[i],d=t[o],f=c.x,h=c.y,p=d.x,y=d.y;h>r!=y>r&&n<(p-f)*(r-h)/(y-h)+f&&(a=!a)}return a}function Vfe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Wfe(n,t)}function qd(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Hfe=K4,Kfe=VN,Gfe=Y4,Yfe=X4,Xfe=YN,Qfe=Q4,Jfe=Dv,Zfe=Z4,epe=tF,tpe=rF,npe=sF,rpe=iF,ape=oF,spe=cF,ipe=dF,Lv="DropdownMenu",[ope]=ir(Lv,[V4]),Nr=V4(),[lpe,pF]=ope(Lv),hF=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:c=!0}=e,d=Nr(t),f=v.useRef(null),[h,p]=na({prop:a,defaultProp:i??!1,onChange:o,caller:Lv});return s.jsx(lpe,{scope:t,triggerId:Hn(),triggerRef:f,contentId:Hn(),open:h,onOpenChange:p,onOpenToggle:v.useCallback(()=>p(y=>!y),[p]),modal:c,children:s.jsx(Hfe,{...d,open:h,onOpenChange:p,dir:r,modal:c,children:n})})};hF.displayName=Lv;var mF="DropdownMenuTrigger",vF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,i=pF(mF,n),o=Nr(n);return s.jsx(Kfe,{asChild:!0,...o,children:s.jsx(De.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:jr(t,i.triggerRef),onPointerDown:Ae(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ae(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});vF.displayName=mF;var cpe="DropdownMenuPortal",gF=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nr(t);return s.jsx(Gfe,{...r,...n})};gF.displayName=cpe;var yF="DropdownMenuContent",xF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=pF(yF,n),i=Nr(n),o=v.useRef(!1);return s.jsx(Yfe,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:t,onCloseAutoFocus:Ae(e.onCloseAutoFocus,c=>{o.current||a.triggerRef.current?.focus(),o.current=!1,c.preventDefault()}),onInteractOutside:Ae(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,h=d.button===2||f;(!a.modal||h)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xF.displayName=yF;var upe="DropdownMenuGroup",dpe=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Xfe,{...a,...r,ref:t})});dpe.displayName=upe;var fpe="DropdownMenuLabel",bF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Qfe,{...a,...r,ref:t})});bF.displayName=fpe;var ppe="DropdownMenuItem",wF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Jfe,{...a,...r,ref:t})});wF.displayName=ppe;var hpe="DropdownMenuCheckboxItem",SF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Zfe,{...a,...r,ref:t})});SF.displayName=hpe;var mpe="DropdownMenuRadioGroup",vpe=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(epe,{...a,...r,ref:t})});vpe.displayName=mpe;var gpe="DropdownMenuRadioItem",jF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(tpe,{...a,...r,ref:t})});jF.displayName=gpe;var ype="DropdownMenuItemIndicator",NF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(npe,{...a,...r,ref:t})});NF.displayName=ype;var xpe="DropdownMenuSeparator",CF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(rpe,{...a,...r,ref:t})});CF.displayName=xpe;var bpe="DropdownMenuArrow",wpe=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(ape,{...a,...r,ref:t})});wpe.displayName=bpe;var Spe="DropdownMenuSubTrigger",_F=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(spe,{...a,...r,ref:t})});_F.displayName=Spe;var jpe="DropdownMenuSubContent",AF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(ipe,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});AF.displayName=jpe;var Npe=hF,Cpe=vF,_pe=gF,EF=xF,PF=bF,OF=wF,kF=SF,RF=jF,TF=NF,IF=CF,MF=_F,$F=AF;const Fc=Npe,Bc=Cpe,Ape=v.forwardRef(({className:e,inset:t,children:n,...r},a)=>s.jsxs(MF,{ref:a,className:Se("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,s.jsx(ZM,{className:"ml-auto h-4 w-4"})]}));Ape.displayName=MF.displayName;const Epe=v.forwardRef(({className:e,...t},n)=>s.jsx($F,{ref:n,className:Se("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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 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",e),...t}));Epe.displayName=$F.displayName;const Wo=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(_pe,{children:s.jsx(EF,{ref:r,sideOffset:t,className:Se("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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 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",e),...n})}));Wo.displayName=EF.displayName;const hr=v.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(OF,{ref:r,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));hr.displayName=OF.displayName;const Ppe=v.forwardRef(({className:e,children:t,checked:n,...r},a)=>s.jsxs(kF,{ref:a,className:Se("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(TF,{children:s.jsx(ql,{className:"h-4 w-4"})})}),t]}));Ppe.displayName=kF.displayName;const Ope=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(RF,{ref:r,className:Se("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(TF,{children:s.jsx(P7,{className:"h-2 w-2 fill-current"})})}),t]}));Ope.displayName=RF.displayName;const JN=v.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(PF,{ref:r,className:Se("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));JN.displayName=PF.displayName;const ZN=v.forwardRef(({className:e,...t},n)=>s.jsx(IF,{ref:n,className:Se("-mx-1 my-1 h-px bg-muted",e),...t}));ZN.displayName=IF.displayName;const Mu=e=>e.configName?.trim()||e.name,kpe=()=>{const{configs:e,deleteConfig:t,cloneConfig:n,loading:r,reload:a}=tf(),i=wa(),[o,c]=v.useState("name"),[d,f]=v.useState("asc"),h=j=>{if(o===j){f(N=>N==="asc"?"desc":"asc");return}c(j),f(j==="updatedAt"?"desc":"asc")};v.useEffect(()=>{a();const j=()=>{a()};return window.addEventListener("focus",j),()=>{window.removeEventListener("focus",j)}},[a]);const p=async(j,N)=>{await t(j),Pe({title:"Deleted",description:`"${N}" has been removed.`})},y=async j=>{const N=await n(j);Pe({title:"Cloned",description:`Created "${Mu(N)}".`}),i(`/mcp-evaluations/${N.id}`)},g=j=>j.agentEntries?.length??j.agents?.length??0,S=j=>j.scenarioEntries?.length??j.scenarios?.length??0,b=v.useMemo(()=>[...e].sort((N,_)=>{let P=0;return o==="name"&&(P=Mu(N).localeCompare(Mu(_))),o==="scenarios"&&(P=S(N)-S(_)),o==="agents"&&(P=g(N)-g(_)),o==="updatedAt"&&(P=new Date(N.updatedAt).getTime()-new Date(_.updatedAt).getTime()),d==="asc"?P:-P}),[e,o,d]),x=j=>o!==j?s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"}):d==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"});return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(n$,{className:"h-6 w-6"}),"MCP Evaluations"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage your MCP evaluation suites"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(se,{variant:"outline",size:"sm",onClick:()=>{a()},children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{variant:"outline",size:"sm",children:[s.jsx($7,{className:"mr-2 h-4 w-4"}),"Import YAML"]}),s.jsx(se,{size:"sm",asChild:!0,children:s.jsxs(yt,{to:"/mcp-evaluations/new",children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Create New"]})})]})]}),s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("name"),children:["Name",x("name")]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("scenarios"),children:["Scenarios",x("scenarios")]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("agents"),children:["Agents",x("agents")]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("updatedAt"),children:["Last Updated",x("updatedAt")]})}),s.jsx(Qe,{className:"w-10"})]})}),s.jsxs(Jr,{children:[b.map(j=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:s.jsxs("div",{children:[s.jsx(yt,{to:`/mcp-evaluations/${j.id}`,className:"font-medium text-sm hover:text-primary",children:Mu(j)}),j.loadError&&s.jsxs(Ke,{variant:"destructive",className:"ml-2 align-middle text-[10px]",children:[s.jsx(Qp,{className:"mr-1 h-3 w-3"}),"Broken"]}),j.description&&s.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:j.description}),j.loadError&&s.jsx("p",{className:"text-xs text-destructive mt-0.5 break-all",children:j.loadError})]})}),s.jsx(Fe,{className:"text-right font-mono text-sm",children:S(j)}),s.jsx(Fe,{className:"text-right font-mono text-sm",children:g(j)}),s.jsx(Fe,{className:"text-right text-xs text-muted-foreground",children:new Date(j.updatedAt).toLocaleDateString()}),s.jsx(Fe,{children:s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8",children:s.jsx(Cm,{className:"h-4 w-4"})})}),s.jsxs(Wo,{align:"end",children:[s.jsxs(hr,{onClick:()=>i(`/mcp-evaluations/${j.id}`),children:[s.jsx(_m,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}),s.jsxs(hr,{onClick:()=>{y(j.id)},children:[s.jsx(Ri,{className:"mr-2 h-3.5 w-3.5"}),"Clone"]}),s.jsxs(hr,{children:[s.jsx(ga,{className:"mr-2 h-3.5 w-3.5"}),"Download YAML"]}),s.jsxs(hr,{className:"text-destructive",onClick:()=>{p(j.id,Mu(j))},children:[s.jsx(xa,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]},j.id)),!r&&e.length===0&&s.jsx(Bt,{children:s.jsx(Fe,{colSpan:5,className:"text-center py-12 text-muted-foreground",children:"No MCP evaluations yet. Create your first one to get started."})}),r&&s.jsx(Bt,{children:s.jsx(Fe,{colSpan:5,className:"text-center py-12 text-muted-foreground",children:"Loading MCP evaluations..."})})]})]})})})]})};var Rpe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tpe=Rpe.reduce((e,t)=>{const n=qm(`Primitive.${t}`),r=v.forwardRef((a,i)=>{const{asChild:o,...c}=a,d=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Ipe="Label",DF=v.forwardRef((e,t)=>s.jsx(Tpe.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));DF.displayName=Ipe;var LF=DF;const Mpe=Io("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Me=v.forwardRef(({className:e,...t},n)=>s.jsx(LF,{ref:n,className:Se(Mpe(),e),...t}));Me.displayName=LF.displayName;const Ks=v.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:Se("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ks.displayName="Textarea";function Fv(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Bv="Switch",[$pe]=ir(Bv),[Dpe,Lpe]=$pe(Bv),FF=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:d="on",onCheckedChange:f,form:h,...p}=e,[y,g]=v.useState(null),S=ut(t,_=>g(_)),b=v.useRef(!1),x=y?h||!!y.closest("form"):!0,[j,N]=na({prop:a,defaultProp:i??!1,onChange:f,caller:Bv});return s.jsxs(Dpe,{scope:n,checked:j,disabled:c,children:[s.jsx(De.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":qF(j),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:S,onClick:Ae(e.onClick,_=>{N(P=>!P),x&&(b.current=_.isPropagationStopped(),b.current||_.stopPropagation())})}),x&&s.jsx(UF,{control:y,bubbles:!b.current,name:r,value:d,checked:j,required:o,disabled:c,form:h,style:{transform:"translateX(-100%)"}})]})});FF.displayName=Bv;var BF="SwitchThumb",zF=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Lpe(BF,n);return s.jsx(De.span,{"data-state":qF(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});zF.displayName=BF;var Fpe="SwitchBubbleInput",UF=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},i)=>{const o=v.useRef(null),c=ut(o,i),d=Fv(n),f=km(t);return v.useEffect(()=>{const h=o.current;if(!h)return;const p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&g){const S=new Event("click",{bubbles:r});g.call(h,n),h.dispatchEvent(S)}},[d,n,r]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});UF.displayName=Fpe;function qF(e){return e?"checked":"unchecked"}var WF=FF,Bpe=zF;const mm=v.forwardRef(({className:e,...t},n)=>s.jsx(WF,{className:Se("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...t,ref:n,children:s.jsx(Bpe,{className:Se("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));mm.displayName=WF.displayName;var zv="Tabs",[zpe]=ir(zv,[Mv]),VF=Mv(),[Upe,eC]=zpe(zv),HF=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:d="automatic",...f}=e,h=Lc(c),[p,y]=na({prop:r,onChange:a,defaultProp:i??"",caller:zv});return s.jsx(Upe,{scope:n,baseId:Hn(),value:p,onValueChange:y,orientation:o,dir:h,activationMode:d,children:s.jsx(De.div,{dir:h,"data-orientation":o,...f,ref:t})})});HF.displayName=zv;var KF="TabsList",GF=v.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,i=eC(KF,n),o=VF(n);return s.jsx(U4,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(De.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:t})})});GF.displayName=KF;var YF="TabsTrigger",XF=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=e,o=eC(YF,n),c=VF(n),d=ZF(o.baseId,r),f=eB(o.baseId,r),h=r===o.value;return s.jsx(q4,{asChild:!0,...c,focusable:!a,active:h,children:s.jsx(De.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":f,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...i,ref:t,onMouseDown:Ae(e.onMouseDown,p=>{!a&&p.button===0&&p.ctrlKey===!1?o.onValueChange(r):p.preventDefault()}),onKeyDown:Ae(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&o.onValueChange(r)}),onFocus:Ae(e.onFocus,()=>{const p=o.activationMode!=="manual";!h&&!a&&p&&o.onValueChange(r)})})})});XF.displayName=YF;var QF="TabsContent",JF=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=e,c=eC(QF,n),d=ZF(c.baseId,r),f=eB(c.baseId,r),h=r===c.value,p=v.useRef(h);return v.useEffect(()=>{const y=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(y)},[]),s.jsx(Gn,{present:a||h,children:({present:y})=>s.jsx(De.div,{"data-state":h?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:f,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:y&&i})})});JF.displayName=QF;function ZF(e,t){return`${e}-trigger-${t}`}function eB(e,t){return`${e}-content-${t}`}var qpe=HF,tB=GF,nB=XF,rB=JF;const tC=qpe,Uv=v.forwardRef(({className:e,...t},n)=>s.jsx(tB,{ref:n,className:Se("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Uv.displayName=tB.displayName;const Po=v.forwardRef(({className:e,...t},n)=>s.jsx(nB,{ref:n,className:Se("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));Po.displayName=nB.displayName;const Wd=v.forwardRef(({className:e,...t},n)=>s.jsx(rB,{ref:n,className:Se("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Wd.displayName=rB.displayName;const XI={openai:"bg-emerald-100 text-emerald-800",anthropic:"bg-orange-100 text-orange-800",azure:"bg-blue-100 text-blue-800",google:"bg-yellow-100 text-yellow-800",custom:"bg-gray-100 text-gray-800"};function aB({provider:e}){return s.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${XI[e]??XI.custom}`,children:e})}function Vd(e,[t,n]){return Math.min(n,Math.max(t,e))}function Wpe(e){const t=Vpe(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(Kpe);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function Vpe(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=Ype(a),c=Gpe(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hpe=Symbol("radix.slottable");function Kpe(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hpe}function Gpe(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function Ype(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xpe=[" ","Enter","ArrowUp","ArrowDown"],Qpe=[" ","Enter"],Oo="Select",[qv,Wv,Jpe]=Hd(Oo),[zc]=ir(Oo,[Jpe,Di]),Vv=Di(),[Zpe,qi]=zc(Oo),[ehe,the]=zc(Oo),sB=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:d,dir:f,name:h,autoComplete:p,disabled:y,required:g,form:S}=e,b=Vv(t),[x,j]=v.useState(null),[N,_]=v.useState(null),[P,A]=v.useState(!1),O=Lc(f),[k,R]=na({prop:r,defaultProp:a??!1,onChange:i,caller:Oo}),[$,z]=na({prop:o,defaultProp:c,onChange:d,caller:Oo}),B=v.useRef(null),L=x?S||!!x.closest("form"):!0,[K,U]=v.useState(new Set),V=Array.from(K).map(X=>X.props.value).join(";");return s.jsx(Rm,{...b,children:s.jsxs(Zpe,{required:g,scope:t,trigger:x,onTriggerChange:j,valueNode:N,onValueNodeChange:_,valueNodeHasChildren:P,onValueNodeHasChildrenChange:A,contentId:Hn(),value:$,onValueChange:z,open:k,onOpenChange:R,dir:O,triggerPointerDownPosRef:B,disabled:y,children:[s.jsx(qv.Provider,{scope:t,children:s.jsx(ehe,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(X=>{U(J=>new Set(J).add(X))},[]),onNativeOptionRemove:v.useCallback(X=>{U(J=>{const T=new Set(J);return T.delete(X),T})},[]),children:n})}),L?s.jsxs(PB,{"aria-hidden":!0,required:g,tabIndex:-1,name:h,autoComplete:p,value:$,onChange:X=>z(X.target.value),disabled:y,form:S,children:[$===void 0?s.jsx("option",{value:""}):null,Array.from(K)]},V):null]})})};sB.displayName=Oo;var iB="SelectTrigger",oB=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...a}=e,i=Vv(n),o=qi(iB,n),c=o.disabled||r,d=ut(t,o.onTriggerChange),f=Wv(n),h=v.useRef("touch"),[p,y,g]=kB(b=>{const x=f().filter(_=>!_.disabled),j=x.find(_=>_.value===o.value),N=RB(x,b,j);N!==void 0&&o.onValueChange(N.value)}),S=b=>{c||(o.onOpenChange(!0),g()),b&&(o.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return s.jsx(Yd,{asChild:!0,...i,children:s.jsx(De.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":OB(o.value)?"":void 0,...a,ref:d,onClick:Ae(a.onClick,b=>{b.currentTarget.focus(),h.current!=="mouse"&&S(b)}),onPointerDown:Ae(a.onPointerDown,b=>{h.current=b.pointerType;const x=b.target;x.hasPointerCapture(b.pointerId)&&x.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(S(b),b.preventDefault())}),onKeyDown:Ae(a.onKeyDown,b=>{const x=p.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&y(b.key),!(x&&b.key===" ")&&Xpe.includes(b.key)&&(S(),b.preventDefault())})})})});oB.displayName=iB;var lB="SelectValue",cB=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=e,d=qi(lB,n),{onValueNodeHasChildrenChange:f}=d,h=i!==void 0,p=ut(t,d.onValueNodeChange);return Kn(()=>{f(h)},[f,h]),s.jsx(De.span,{...c,ref:p,style:{pointerEvents:"none"},children:OB(d.value)?s.jsx(s.Fragment,{children:o}):i})});cB.displayName=lB;var nhe="SelectIcon",uB=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...a}=e;return s.jsx(De.span,{"aria-hidden":!0,...a,ref:t,children:r||"▼"})});uB.displayName=nhe;var rhe="SelectPortal",dB=e=>s.jsx(Sc,{asChild:!0,...e});dB.displayName=rhe;var ko="SelectContent",fB=v.forwardRef((e,t)=>{const n=qi(ko,e.__scopeSelect),[r,a]=v.useState();if(Kn(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?wc.createPortal(s.jsx(pB,{scope:e.__scopeSelect,children:s.jsx(qv.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),i):null}return s.jsx(hB,{...e,ref:t})});fB.displayName=ko;var Ia=10,[pB,Wi]=zc(ko),ahe="SelectContentImpl",she=Wpe("SelectContent.RemoveScroll"),hB=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:d,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:g,sticky:S,hideWhenDetached:b,avoidCollisions:x,...j}=e,N=qi(ko,n),[_,P]=v.useState(null),[A,O]=v.useState(null),k=ut(t,ae=>P(ae)),[R,$]=v.useState(null),[z,B]=v.useState(null),L=Wv(n),[K,U]=v.useState(!1),V=v.useRef(!1);v.useEffect(()=>{if(_)return Hm(_)},[_]),Wm();const X=v.useCallback(ae=>{const[ue,...ie]=L().map(oe=>oe.ref.current),[ve]=ie.slice(-1),Oe=document.activeElement;for(const oe of ae)if(oe===Oe||(oe?.scrollIntoView({block:"nearest"}),oe===ue&&A&&(A.scrollTop=0),oe===ve&&A&&(A.scrollTop=A.scrollHeight),oe?.focus(),document.activeElement!==Oe))return},[L,A]),J=v.useCallback(()=>X([R,_]),[X,R,_]);v.useEffect(()=>{K&&J()},[K,J]);const{onOpenChange:T,triggerPointerDownPosRef:D}=N;v.useEffect(()=>{if(_){let ae={x:0,y:0};const ue=ve=>{ae={x:Math.abs(Math.round(ve.pageX)-(D.current?.x??0)),y:Math.abs(Math.round(ve.pageY)-(D.current?.y??0))}},ie=ve=>{ae.x<=10&&ae.y<=10?ve.preventDefault():_.contains(ve.target)||T(!1),document.removeEventListener("pointermove",ue),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",ie,{capture:!0})}}},[_,T,D]),v.useEffect(()=>{const ae=()=>T(!1);return window.addEventListener("blur",ae),window.addEventListener("resize",ae),()=>{window.removeEventListener("blur",ae),window.removeEventListener("resize",ae)}},[T]);const[Q,F]=kB(ae=>{const ue=L().filter(Oe=>!Oe.disabled),ie=ue.find(Oe=>Oe.ref.current===document.activeElement),ve=RB(ue,ae,ie);ve&&setTimeout(()=>ve.ref.current.focus())}),M=v.useCallback((ae,ue,ie)=>{const ve=!V.current&&!ie;(N.value!==void 0&&N.value===ue||ve)&&($(ae),ve&&(V.current=!0))},[N.value]),ee=v.useCallback(()=>_?.focus(),[_]),W=v.useCallback((ae,ue,ie)=>{const ve=!V.current&&!ie;(N.value!==void 0&&N.value===ue||ve)&&B(ae)},[N.value]),Z=r==="popper"?nj:mB,ye=Z===nj?{side:c,sideOffset:d,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:g,sticky:S,hideWhenDetached:b,avoidCollisions:x}:{};return s.jsx(pB,{scope:n,content:_,viewport:A,onViewportChange:O,itemRefCallback:M,selectedItem:R,onItemLeave:ee,itemTextRefCallback:W,focusSelectedItem:J,selectedItemText:z,position:r,isPositioned:K,searchRef:Q,children:s.jsx(Qd,{as:she,allowPinchZoom:!0,children:s.jsx(Xd,{asChild:!0,trapped:N.open,onMountAutoFocus:ae=>{ae.preventDefault()},onUnmountAutoFocus:Ae(a,ae=>{N.trigger?.focus({preventScroll:!0}),ae.preventDefault()}),children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:ae=>ae.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:s.jsx(Z,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:ae=>ae.preventDefault(),...j,...ye,onPlaced:()=>U(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Ae(j.onKeyDown,ae=>{const ue=ae.ctrlKey||ae.altKey||ae.metaKey;if(ae.key==="Tab"&&ae.preventDefault(),!ue&&ae.key.length===1&&F(ae.key),["ArrowUp","ArrowDown","Home","End"].includes(ae.key)){let ve=L().filter(Oe=>!Oe.disabled).map(Oe=>Oe.ref.current);if(["ArrowUp","End"].includes(ae.key)&&(ve=ve.slice().reverse()),["ArrowUp","ArrowDown"].includes(ae.key)){const Oe=ae.target,oe=ve.indexOf(Oe);ve=ve.slice(oe+1)}setTimeout(()=>X(ve)),ae.preventDefault()}})})})})})})});hB.displayName=ahe;var ihe="SelectItemAlignedPosition",mB=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...a}=e,i=qi(ko,n),o=Wi(ko,n),[c,d]=v.useState(null),[f,h]=v.useState(null),p=ut(t,k=>h(k)),y=Wv(n),g=v.useRef(!1),S=v.useRef(!0),{viewport:b,selectedItem:x,selectedItemText:j,focusSelectedItem:N}=o,_=v.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&f&&b&&x&&j){const k=i.trigger.getBoundingClientRect(),R=f.getBoundingClientRect(),$=i.valueNode.getBoundingClientRect(),z=j.getBoundingClientRect();if(i.dir!=="rtl"){const Oe=z.left-R.left,oe=$.left-Oe,he=k.left-oe,xe=k.width+he,Ie=Math.max(xe,R.width),re=window.innerWidth-Ia,me=Vd(oe,[Ia,Math.max(Ia,re-Ie)]);c.style.minWidth=xe+"px",c.style.left=me+"px"}else{const Oe=R.right-z.right,oe=window.innerWidth-$.right-Oe,he=window.innerWidth-k.right-oe,xe=k.width+he,Ie=Math.max(xe,R.width),re=window.innerWidth-Ia,me=Vd(oe,[Ia,Math.max(Ia,re-Ie)]);c.style.minWidth=xe+"px",c.style.right=me+"px"}const B=y(),L=window.innerHeight-Ia*2,K=b.scrollHeight,U=window.getComputedStyle(f),V=parseInt(U.borderTopWidth,10),X=parseInt(U.paddingTop,10),J=parseInt(U.borderBottomWidth,10),T=parseInt(U.paddingBottom,10),D=V+X+K+T+J,Q=Math.min(x.offsetHeight*5,D),F=window.getComputedStyle(b),M=parseInt(F.paddingTop,10),ee=parseInt(F.paddingBottom,10),W=k.top+k.height/2-Ia,Z=L-W,ye=x.offsetHeight/2,ae=x.offsetTop+ye,ue=V+X+ae,ie=D-ue;if(ue<=W){const Oe=B.length>0&&x===B[B.length-1].ref.current;c.style.bottom="0px";const oe=f.clientHeight-b.offsetTop-b.offsetHeight,he=Math.max(Z,ye+(Oe?ee:0)+oe+J),xe=ue+he;c.style.height=xe+"px"}else{const Oe=B.length>0&&x===B[0].ref.current;c.style.top="0px";const he=Math.max(W,V+b.offsetTop+(Oe?M:0)+ye)+ie;c.style.height=he+"px",b.scrollTop=ue-W+b.offsetTop}c.style.margin=`${Ia}px 0`,c.style.minHeight=Q+"px",c.style.maxHeight=L+"px",r?.(),requestAnimationFrame(()=>g.current=!0)}},[y,i.trigger,i.valueNode,c,f,b,x,j,i.dir,r]);Kn(()=>_(),[_]);const[P,A]=v.useState();Kn(()=>{f&&A(window.getComputedStyle(f).zIndex)},[f]);const O=v.useCallback(k=>{k&&S.current===!0&&(_(),N?.(),S.current=!1)},[_,N]);return s.jsx(lhe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:O,children:s.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:s.jsx(De.div,{...a,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});mB.displayName=ihe;var ohe="SelectPopperPosition",nj=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Ia,...i}=e,o=Vv(n);return s.jsx(Tm,{...o,...i,ref:t,align:r,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});nj.displayName=ohe;var[lhe,nC]=zc(ko,{}),rj="SelectViewport",vB=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...a}=e,i=Wi(rj,n),o=nC(rj,n),c=ut(t,i.onViewportChange),d=v.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(qv.Slot,{scope:n,children:s.jsx(De.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ae(a.onScroll,f=>{const h=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:y}=o;if(y?.current&&p){const g=Math.abs(d.current-h.scrollTop);if(g>0){const S=window.innerHeight-Ia*2,b=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),j=Math.max(b,x);if(j<S){const N=j+g,_=Math.min(S,N),P=N-_;p.style.height=_+"px",p.style.bottom==="0px"&&(h.scrollTop=P>0?P:0,p.style.justifyContent="flex-end")}}}d.current=h.scrollTop})})})]})});vB.displayName=rj;var gB="SelectGroup",[che,uhe]=zc(gB),dhe=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=Hn();return s.jsx(che,{scope:n,id:a,children:s.jsx(De.div,{role:"group","aria-labelledby":a,...r,ref:t})})});dhe.displayName=gB;var yB="SelectLabel",xB=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=uhe(yB,n);return s.jsx(De.div,{id:a.id,...r,ref:t})});xB.displayName=yB;var vm="SelectItem",[fhe,bB]=zc(vm),wB=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=e,c=qi(vm,n),d=Wi(vm,n),f=c.value===r,[h,p]=v.useState(i??""),[y,g]=v.useState(!1),S=ut(t,N=>d.itemRefCallback?.(N,r,a)),b=Hn(),x=v.useRef("touch"),j=()=>{a||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(fhe,{scope:n,value:r,disabled:a,textId:b,isSelected:f,onItemTextChange:v.useCallback(N=>{p(_=>_||(N?.textContent??"").trim())},[]),children:s.jsx(qv.ItemSlot,{scope:n,value:r,disabled:a,textValue:h,children:s.jsx(De.div,{role:"option","aria-labelledby":b,"data-highlighted":y?"":void 0,"aria-selected":f&&y,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:S,onFocus:Ae(o.onFocus,()=>g(!0)),onBlur:Ae(o.onBlur,()=>g(!1)),onClick:Ae(o.onClick,()=>{x.current!=="mouse"&&j()}),onPointerUp:Ae(o.onPointerUp,()=>{x.current==="mouse"&&j()}),onPointerDown:Ae(o.onPointerDown,N=>{x.current=N.pointerType}),onPointerMove:Ae(o.onPointerMove,N=>{x.current=N.pointerType,a?d.onItemLeave?.():x.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ae(o.onPointerLeave,N=>{N.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Ae(o.onKeyDown,N=>{d.searchRef?.current!==""&&N.key===" "||(Qpe.includes(N.key)&&j(),N.key===" "&&N.preventDefault())})})})})});wB.displayName=vm;var qu="SelectItemText",SB=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,...i}=e,o=qi(qu,n),c=Wi(qu,n),d=bB(qu,n),f=the(qu,n),[h,p]=v.useState(null),y=ut(t,j=>p(j),d.onItemTextChange,j=>c.itemTextRefCallback?.(j,d.value,d.disabled)),g=h?.textContent,S=v.useMemo(()=>s.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=f;return Kn(()=>(b(S),()=>x(S)),[b,x,S]),s.jsxs(s.Fragment,{children:[s.jsx(De.span,{id:d.textId,...i,ref:y}),d.isSelected&&o.valueNode&&!o.valueNodeHasChildren?wc.createPortal(i.children,o.valueNode):null]})});SB.displayName=qu;var jB="SelectItemIndicator",NB=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return bB(jB,n).isSelected?s.jsx(De.span,{"aria-hidden":!0,...r,ref:t}):null});NB.displayName=jB;var aj="SelectScrollUpButton",CB=v.forwardRef((e,t)=>{const n=Wi(aj,e.__scopeSelect),r=nC(aj,e.__scopeSelect),[a,i]=v.useState(!1),o=ut(t,r.onScrollButtonChange);return Kn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;i(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?s.jsx(AB,{...e,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});CB.displayName=aj;var sj="SelectScrollDownButton",_B=v.forwardRef((e,t)=>{const n=Wi(sj,e.__scopeSelect),r=nC(sj,e.__scopeSelect),[a,i]=v.useState(!1),o=ut(t,r.onScrollButtonChange);return Kn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,h=Math.ceil(d.scrollTop)<f;i(h)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?s.jsx(AB,{...e,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});_B.displayName=sj;var AB=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=e,i=Wi("SelectScrollButton",n),o=v.useRef(null),c=Wv(n),d=v.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return v.useEffect(()=>()=>d(),[d]),Kn(()=>{c().find(h=>h.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),s.jsx(De.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:Ae(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Ae(a.onPointerMove,()=>{i.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Ae(a.onPointerLeave,()=>{d()})})}),phe="SelectSeparator",EB=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(De.div,{"aria-hidden":!0,...r,ref:t})});EB.displayName=phe;var ij="SelectArrow",hhe=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=Vv(n),i=qi(ij,n),o=Wi(ij,n);return i.open&&o.position==="popper"?s.jsx(Im,{...a,...r,ref:t}):null});hhe.displayName=ij;var mhe="SelectBubbleInput",PB=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const a=v.useRef(null),i=ut(r,a),o=Fv(t);return v.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(o!==t&&h){const p=new Event("change",{bubbles:!0});h.call(c,t),c.dispatchEvent(p)}},[o,t]),s.jsx(De.select,{...n,style:{...OM,...n.style},ref:i,defaultValue:t})});PB.displayName=mhe;function OB(e){return e===""||e===void 0}function kB(e){const t=Pn(e),n=v.useRef(""),r=v.useRef(0),a=v.useCallback(o=>{const c=n.current+o;t(c),(function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),i=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function RB(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=vhe(e,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const d=o.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function vhe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ghe=sB,TB=oB,yhe=cB,xhe=uB,bhe=dB,IB=fB,whe=vB,MB=xB,$B=wB,She=SB,jhe=NB,DB=CB,LB=_B,FB=EB;const sn=ghe,on=yhe,Jt=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(TB,{ref:r,className:Se("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,s.jsx(xhe,{asChild:!0,children:s.jsx(qt,{className:"h-4 w-4 opacity-50"})})]}));Jt.displayName=TB.displayName;const BB=v.forwardRef(({className:e,...t},n)=>s.jsx(DB,{ref:n,className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(is,{className:"h-4 w-4"})}));BB.displayName=DB.displayName;const zB=v.forwardRef(({className:e,...t},n)=>s.jsx(LB,{ref:n,className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(qt,{className:"h-4 w-4"})}));zB.displayName=LB.displayName;const Zt=v.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>s.jsx(bhe,{children:s.jsxs(IB,{ref:a,className:Se("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md 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 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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[s.jsx(BB,{}),s.jsx(whe,{className:Se("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),s.jsx(zB,{})]})}));Zt.displayName=IB.displayName;const Nhe=v.forwardRef(({className:e,...t},n)=>s.jsx(MB,{ref:n,className:Se("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Nhe.displayName=MB.displayName;const at=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs($B,{ref:r,className:Se("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(jhe,{children:s.jsx(ql,{className:"h-4 w-4"})})}),s.jsx(She,{children:t})]}));at.displayName=$B.displayName;const Che=v.forwardRef(({className:e,...t},n)=>s.jsx(FB,{ref:n,className:Se("-mx-1 my-1 h-px bg-muted",e),...t}));Che.displayName=FB.displayName;var Hv="Collapsible",[_he]=ir(Hv),[Ahe,rC]=_he(Hv),UB=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...c}=e,[d,f]=na({prop:r,defaultProp:a??!1,onChange:o,caller:Hv});return s.jsx(Ahe,{scope:n,disabled:i,contentId:Hn(),open:d,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),children:s.jsx(De.div,{"data-state":sC(d),"data-disabled":i?"":void 0,...c,ref:t})})});UB.displayName=Hv;var qB="CollapsibleTrigger",WB=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,a=rC(qB,n);return s.jsx(De.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":sC(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:Ae(e.onClick,a.onOpenToggle)})});WB.displayName=qB;var aC="CollapsibleContent",VB=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=rC(aC,e.__scopeCollapsible);return s.jsx(Gn,{present:n||a.open,children:({present:i})=>s.jsx(Ehe,{...r,ref:t,present:i})})});VB.displayName=aC;var Ehe=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:a,...i}=e,o=rC(aC,n),[c,d]=v.useState(r),f=v.useRef(null),h=ut(t,f),p=v.useRef(0),y=p.current,g=v.useRef(0),S=g.current,b=o.open||c,x=v.useRef(b),j=v.useRef(void 0);return v.useEffect(()=>{const N=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(N)},[]),Kn(()=>{const N=f.current;if(N){j.current=j.current||{transitionDuration:N.style.transitionDuration,animationName:N.style.animationName},N.style.transitionDuration="0s",N.style.animationName="none";const _=N.getBoundingClientRect();p.current=_.height,g.current=_.width,x.current||(N.style.transitionDuration=j.current.transitionDuration,N.style.animationName=j.current.animationName),d(r)}},[o.open,r]),s.jsx(De.div,{"data-state":sC(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!b,...i,ref:h,style:{"--radix-collapsible-content-height":y?`${y}px`:void 0,"--radix-collapsible-content-width":S?`${S}px`:void 0,...e.style},children:b&&a})});function sC(e){return e?"open":"closed"}var Phe=UB;const Ci=Phe,Rs=WB,_i=VB,Ohe=Gm,khe=Ym,HB=v.forwardRef(({className:e,...t},n)=>s.jsx(Pc,{ref:n,className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));HB.displayName=Pc.displayName;const KB=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(khe,{children:[s.jsx(HB,{}),s.jsxs(Oc,{ref:r,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,s.jsxs(Xm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(Ti,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));KB.displayName=Oc.displayName;const GB=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});GB.displayName="DialogHeader";const YB=v.forwardRef(({className:e,...t},n)=>s.jsx(Jd,{ref:n,className:Se("text-lg font-semibold leading-none tracking-tight",e),...t}));YB.displayName=Jd.displayName;const XB=v.forwardRef(({className:e,...t},n)=>s.jsx(Zd,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));XB.displayName=Zd.displayName;function Rhe(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var iC="ScrollArea",[QB]=ir(iC),[The,ja]=QB(iC),JB=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:i=600,...o}=e,[c,d]=v.useState(null),[f,h]=v.useState(null),[p,y]=v.useState(null),[g,S]=v.useState(null),[b,x]=v.useState(null),[j,N]=v.useState(0),[_,P]=v.useState(0),[A,O]=v.useState(!1),[k,R]=v.useState(!1),$=ut(t,B=>d(B)),z=Lc(a);return s.jsx(The,{scope:n,type:r,dir:z,scrollHideDelay:i,scrollArea:c,viewport:f,onViewportChange:h,content:p,onContentChange:y,scrollbarX:g,onScrollbarXChange:S,scrollbarXEnabled:A,onScrollbarXEnabledChange:O,scrollbarY:b,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:R,onCornerWidthChange:N,onCornerHeightChange:P,children:s.jsx(De.div,{dir:z,...o,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})});JB.displayName=iC;var ZB="ScrollAreaViewport",e8=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:a,...i}=e,o=ja(ZB,n),c=v.useRef(null),d=ut(t,c,o.onViewportChange);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),s.jsx(De.div,{"data-radix-scroll-area-viewport":"",...i,ref:d,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});e8.displayName=ZB;var xs="ScrollAreaScrollbar",oC=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=ja(xs,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,c=e.orientation==="horizontal";return v.useEffect(()=>(c?i(!0):o(!0),()=>{c?i(!1):o(!1)}),[c,i,o]),a.type==="hover"?s.jsx(Ihe,{...r,ref:t,forceMount:n}):a.type==="scroll"?s.jsx(Mhe,{...r,ref:t,forceMount:n}):a.type==="auto"?s.jsx(t8,{...r,ref:t,forceMount:n}):a.type==="always"?s.jsx(lC,{...r,ref:t}):null});oC.displayName=xs;var Ihe=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=ja(xs,e.__scopeScrollArea),[i,o]=v.useState(!1);return v.useEffect(()=>{const c=a.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),o(!0)},h=()=>{d=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",h),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",h)}}},[a.scrollArea,a.scrollHideDelay]),s.jsx(Gn,{present:n||i,children:s.jsx(t8,{"data-state":i?"visible":"hidden",...r,ref:t})})}),Mhe=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=ja(xs,e.__scopeScrollArea),i=e.orientation==="horizontal",o=Gv(()=>d("SCROLL_END"),100),[c,d]=Rhe("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return v.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,a.scrollHideDelay,d]),v.useEffect(()=>{const f=a.viewport,h=i?"scrollLeft":"scrollTop";if(f){let p=f[h];const y=()=>{const g=f[h];p!==g&&(d("SCROLL"),o()),p=g};return f.addEventListener("scroll",y),()=>f.removeEventListener("scroll",y)}},[a.viewport,i,d,o]),s.jsx(Gn,{present:n||c!=="hidden",children:s.jsx(lC,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ae(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Ae(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),t8=v.forwardRef((e,t)=>{const n=ja(xs,e.__scopeScrollArea),{forceMount:r,...a}=e,[i,o]=v.useState(!1),c=e.orientation==="horizontal",d=Gv(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,h=n.viewport.offsetHeight<n.viewport.scrollHeight;o(c?f:h)}},10);return xc(n.viewport,d),xc(n.content,d),s.jsx(Gn,{present:r||i,children:s.jsx(lC,{"data-state":i?"visible":"hidden",...a,ref:t})})}),lC=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,a=ja(xs,e.__scopeScrollArea),i=v.useRef(null),o=v.useRef(0),[c,d]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=i8(c.viewport,c.content),h={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:y=>i.current=y,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:y=>o.current=y};function p(y,g){return zhe(y,o.current,c,g)}return n==="horizontal"?s.jsx($he,{...h,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const y=a.viewport.scrollLeft,g=QI(y,c,a.dir);i.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollLeft=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollLeft=p(y,a.dir))}}):n==="vertical"?s.jsx(Dhe,{...h,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const y=a.viewport.scrollTop,g=QI(y,c);i.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollTop=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollTop=p(y))}}):null}),$he=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,i=ja(xs,e.__scopeScrollArea),[o,c]=v.useState(),d=v.useRef(null),f=ut(t,d,i.onScrollbarXChange);return v.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(r8,{"data-orientation":"horizontal",...a,ref:f,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Kv(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.x),onDragScroll:h=>e.onDragScroll(h.x),onWheelScroll:(h,p)=>{if(i.viewport){const y=i.viewport.scrollLeft+h.deltaX;e.onWheelScroll(y),l8(y,p)&&h.preventDefault()}},onResize:()=>{d.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:ym(o.paddingLeft),paddingEnd:ym(o.paddingRight)}})}})}),Dhe=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,i=ja(xs,e.__scopeScrollArea),[o,c]=v.useState(),d=v.useRef(null),f=ut(t,d,i.onScrollbarYChange);return v.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(r8,{"data-orientation":"vertical",...a,ref:f,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Kv(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.y),onDragScroll:h=>e.onDragScroll(h.y),onWheelScroll:(h,p)=>{if(i.viewport){const y=i.viewport.scrollTop+h.deltaY;e.onWheelScroll(y),l8(y,p)&&h.preventDefault()}},onResize:()=>{d.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:ym(o.paddingTop),paddingEnd:ym(o.paddingBottom)}})}})}),[Lhe,n8]=QB(xs),r8=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:h,onResize:p,...y}=e,g=ja(xs,n),[S,b]=v.useState(null),x=ut(t,$=>b($)),j=v.useRef(null),N=v.useRef(""),_=g.viewport,P=r.content-r.viewport,A=Pn(h),O=Pn(d),k=Gv(p,10);function R($){if(j.current){const z=$.clientX-j.current.left,B=$.clientY-j.current.top;f({x:z,y:B})}}return v.useEffect(()=>{const $=z=>{const B=z.target;S?.contains(B)&&A(z,P)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[_,S,P,A]),v.useEffect(O,[r,O]),xc(S,k),xc(g.content,k),s.jsx(Lhe,{scope:n,scrollbar:S,hasThumb:a,onThumbChange:Pn(i),onThumbPointerUp:Pn(o),onThumbPositionChange:O,onThumbPointerDown:Pn(c),children:s.jsx(De.div,{...y,ref:x,style:{position:"absolute",...y.style},onPointerDown:Ae(e.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),j.current=S.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),R($))}),onPointerMove:Ae(e.onPointerMove,R),onPointerUp:Ae(e.onPointerUp,$=>{const z=$.target;z.hasPointerCapture($.pointerId)&&z.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=N.current,g.viewport&&(g.viewport.style.scrollBehavior=""),j.current=null})})})}),gm="ScrollAreaThumb",a8=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=n8(gm,e.__scopeScrollArea);return s.jsx(Gn,{present:n||a.hasThumb,children:s.jsx(Fhe,{ref:t,...r})})}),Fhe=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...a}=e,i=ja(gm,n),o=n8(gm,n),{onThumbPositionChange:c}=o,d=ut(t,p=>o.onThumbChange(p)),f=v.useRef(void 0),h=Gv(()=>{f.current&&(f.current(),f.current=void 0)},100);return v.useEffect(()=>{const p=i.viewport;if(p){const y=()=>{if(h(),!f.current){const g=Uhe(p,c);f.current=g,c()}};return c(),p.addEventListener("scroll",y),()=>p.removeEventListener("scroll",y)}},[i.viewport,h,c]),s.jsx(De.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Ae(e.onPointerDownCapture,p=>{const g=p.target.getBoundingClientRect(),S=p.clientX-g.left,b=p.clientY-g.top;o.onThumbPointerDown({x:S,y:b})}),onPointerUp:Ae(e.onPointerUp,o.onThumbPointerUp)})});a8.displayName=gm;var cC="ScrollAreaCorner",s8=v.forwardRef((e,t)=>{const n=ja(cC,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(Bhe,{...e,ref:t}):null});s8.displayName=cC;var Bhe=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,a=ja(cC,n),[i,o]=v.useState(0),[c,d]=v.useState(0),f=!!(i&&c);return xc(a.scrollbarX,()=>{const h=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(h),d(h)}),xc(a.scrollbarY,()=>{const h=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(h),o(h)}),f?s.jsx(De.div,{...r,ref:t,style:{width:i,height:c,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ym(e){return e?parseInt(e,10):0}function i8(e,t){const n=e/t;return isNaN(n)?0:n}function Kv(e){const t=i8(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zhe(e,t,n,r="ltr"){const a=Kv(n),i=a/2,o=t||i,c=a-o,d=n.scrollbar.paddingStart+o,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,h=n.content-n.viewport,p=r==="ltr"?[0,h]:[h*-1,0];return o8([d,f],p)(e)}function QI(e,t,n="ltr"){const r=Kv(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-a,o=t.content-t.viewport,c=i-r,d=n==="ltr"?[0,o]:[o*-1,0],f=Vd(e,d);return o8([0,o],[0,c])(f)}function o8(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function l8(e,t){return e>0&&e<t}var Uhe=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function a(){const i={left:e.scrollLeft,top:e.scrollTop},o=n.left!==i.left,c=n.top!==i.top;(o||c)&&t(),n=i,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function Gv(e,t){const n=Pn(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function xc(e,t){const n=Pn(t);Kn(()=>{let r=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return a.observe(e),()=>{window.cancelAnimationFrame(r),a.unobserve(e)}}},[e,n])}var c8=JB,qhe=e8,Whe=s8;const xm=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(c8,{ref:r,className:Se("relative overflow-hidden",e),...n,children:[s.jsx(qhe,{className:"h-full w-full rounded-[inherit]",children:t}),s.jsx(u8,{}),s.jsx(Whe,{})]}));xm.displayName=c8.displayName;const u8=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>s.jsx(oC,{ref:r,orientation:t,className:Se("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:s.jsx(a8,{className:"relative flex-1 rounded-full bg-border"})}));u8.displayName=oC.displayName;const Vhe=[{label:"Suggest Checks",description:"Propose stronger evaluation checks for this scenario.",prompt:"Suggest checks"},{label:"Suggest Value Capture Rules",description:"Recommend extract/value capture rules for key outputs.",prompt:"Suggest value capture rules"},{label:"Improve Prompt Determinism",description:"Reduce ambiguity and improve reproducibility.",prompt:"Improve prompt determinism"},{label:"Explain Snapshot Drift Risk",description:"Assess likely causes of drift and stabilization options.",prompt:"Explain snapshot drift risk"},{label:"Generate Scenario Draft",description:"Create a draft scenario from the current context.",prompt:"Generate scenario draft"}];function Hhe({open:e,onOpenChange:t,configId:n,configPath:r,scenario:a,agents:i,servers:o,snapshotEval:c,defaultAssistantAgentName:d,initialUserMessage:f,onApplyPatch:h}){const{source:p}=On(),[y,g]=v.useState(null),[S,b]=v.useState(null),[x,j]=v.useState(""),[N,_]=v.useState(!1),[P,A]=v.useState(new Set),O=v.useRef(null),k=v.useRef(null),R=v.useRef(null),[$,z]=v.useState(!1),B=v.useRef(!1),L=d||i[0]?.id||"";v.useEffect(()=>{if(!e||!L||y)return;let W=!1;return _(!0),p.createScenarioAssistantSession({configId:n,configPath:r,scenarioId:a.id,selectedAssistantAgentName:L,context:{configSnapshotPolicy:c?{enabled:c.enabled,mode:c.mode,baselineSnapshotId:c.baselineSnapshotId}:void 0,scenario:{id:a.id,name:a.name,prompt:a.prompt,serverNames:a.serverIds,evalRules:a.evalRules,extractRules:a.extractRules,snapshotEval:a.snapshotEval?{enabled:a.snapshotEval.enabled,baselineSnapshotId:a.snapshotEval.baselineSnapshotId}:void 0},availableServers:o.map(Z=>({name:Z.name||Z.id,url:Z.url})),availableAgents:i.map(Z=>({name:Z.name||Z.id,provider:Z.provider,model:Z.model}))}}).then(Z=>{W||(g(Z.sessionId),b(Z.session))}).catch(Z=>{W||Pe({title:"Could not start Scenario Assistant",description:Z instanceof Error?Z.message:String(Z),variant:"destructive"})}).finally(()=>{W||_(!1)}),()=>{W=!0}},[e,p,y,n,r,a,c,i,o,L]);const K=()=>{g(null),b(null),j(""),A(new Set),R.current=null},U=W=>{K(),p.closeScenarioAssistantSession(W).catch(()=>{})};v.useEffect(()=>{e||y&&(B.current||$||U(y))},[e,y,p,$]),v.useEffect(()=>()=>{y&&p.closeScenarioAssistantSession(y).catch(()=>{})},[y,p]),v.useEffect(()=>{if(!e)return;$&&z(!1),B.current&&(B.current=!1);const W=window.setTimeout(()=>{O.current?.scrollIntoView({behavior:"smooth",block:"end"})},0);return()=>window.clearTimeout(W)},[e,N,S?.messages.length,S?.pendingToolCalls.length,S?.warnings.length]),v.useEffect(()=>{const W=k.current;if(!W)return;W.style.height="0px";const Z=Math.min(W.scrollHeight,160);W.style.height=`${Math.max(40,Z)}px`},[x,e]);const V=i.length>0&&a.serverIds.length>0&&!!L,X=async W=>{if(!y)return;const Z=W.trim();if(!Z)return;const ye=`msg-local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ae={id:ye,role:"user",text:Z,createdAt:new Date().toISOString()};b(ue=>ue&&{...ue,messages:[...ue.messages,ae]}),j(""),_(!0);try{const ue=await p.sendScenarioAssistantMessage(y,Z);b(ue.session)}catch(ue){b(ie=>ie&&{...ie,messages:ie.messages.filter(ve=>ve.id!==ye)}),j(ie=>ie.trim()?ie:Z),Pe({title:"Scenario Assistant error",description:ue instanceof Error?ue.message:String(ue),variant:"destructive"})}finally{_(!1)}},J=W=>{j(W),requestAnimationFrame(()=>k.current?.focus())};v.useEffect(()=>{if(!e||!y||!S||!V||N)return;const W=String(f??"").trim();W&&R.current!==W&&(R.current=W,X(W))},[e,y,S,V,N,f]);const T=async W=>{if(y){_(!0);try{const Z=await p.approveScenarioAssistantToolCall(y,W);b(Z.session)}catch(Z){Pe({title:"Tool call failed",description:Z instanceof Error?Z.message:String(Z),variant:"destructive"})}finally{_(!1)}}},D=async W=>{if(y){_(!0);try{const Z=await p.denyScenarioAssistantToolCall(y,W);b(Z.session)}catch(Z){Pe({title:"Could not deny tool call",description:Z instanceof Error?Z.message:String(Z),variant:"destructive"})}finally{_(!1)}}},Q=(W,Z,ye)=>{if(!Z)return;if(ye==="prompt"&&Z.prompt&&h({prompt:Z.prompt.replacement}),ye==="evalRules"&&Z.evalRules&&h({evalRules:Z.evalRules.replacement}),ye==="extractRules"&&Z.extractRules&&h({extractRules:Z.extractRules.replacement}),ye==="snapshotEval"&&Z.snapshotEval&&h({snapshotEval:{enabled:Z.snapshotEval.patch.enabled,baselineSnapshotId:Z.snapshotEval.patch.baselineSnapshotId}}),W){const ue=`${W}:${ye}`;A(ie=>new Set([...ie,ue]))}Pe({title:"Applied suggestion",description:`Updated ${{prompt:"Prompt",evalRules:"Checks",extractRules:"Value Capture Rules",snapshotEval:"Snapshot Settings"}[ye]}`})},F=W=>{W||(z(!1),B.current=!1),t(W)},M=()=>{B.current=!0,z(!0),t(!1)},ee=()=>{B.current=!1,z(!1),y&&U(y)};return s.jsxs(s.Fragment,{children:[!e&&y&&s.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 rounded-md border bg-background px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-medium",children:"Scenario Assistant (session active)"}),s.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:["Resume conversation for ",s.jsx("span",{className:"font-mono",children:a.id}),S?` · ${S.messages.length} messages`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>t(!0),children:[s.jsx(fa,{className:"mr-1.5 h-3.5 w-3.5"}),"Resume"]}),s.jsx(se,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2 text-muted-foreground",onClick:ee,"aria-label":"Discard assistant session",title:"Discard assistant session",children:s.jsx(Ti,{className:"h-4 w-4"})})]})]}),s.jsx(Ohe,{open:e,onOpenChange:F,children:s.jsxs(KB,{className:"max-w-6xl h-[85vh] flex flex-col",children:[y&&s.jsxs("button",{type:"button",className:"absolute right-12 top-4 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:M,"aria-label":"Minimize assistant",title:"Minimize assistant",children:[s.jsx(T7,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Minimize"})]}),s.jsx(GB,{className:"pr-20",children:s.jsx("div",{className:"flex items-start justify-between gap-3",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs(YB,{className:"flex items-center gap-2",children:[s.jsx(fa,{className:"h-4 w-4"}),"Scenario Assistant"]}),s.jsx(XB,{children:"LLM-guided scenario authoring with MCP tool introspection and per-tool-call approval."})]})})}),V?s.jsxs("div",{className:"min-h-0 flex flex-1 flex-col gap-3",children:[s.jsx("div",{className:"grid gap-3 sm:grid-cols-1",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"MCP Context"}),s.jsxs("div",{className:"h-8 rounded-md border px-2 text-xs flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),S?`Loaded ${S.toolsLoaded} tools`:"Preparing..."]})]})}),s.jsx(xm,{className:"min-h-0 flex-1 rounded-md border p-3",children:s.jsxs("div",{className:"space-y-3",children:[S?.warnings?.map((W,Z)=>s.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:W},`${W}-${Z}`)),S?.messages.map(W=>s.jsxs(v.Fragment,{children:[(()=>{const Z=W.pendingToolCallId?(S?.pendingToolCalls??[]).find(Oe=>Oe.id===W.pendingToolCallId):void 0;if(!(W.role==="assistant"&&!!W.pendingToolCallId))return s.jsx("div",{className:"space-y-2",children:s.jsx(Khe,{message:W})});const ae=W.text.match(/I need to call ['"]([^'"]+)['"]/i)?.[1]?.replace(/^.*__/,"")??void 0,ue=Z?.tool??W.toolRequestName??ae,ie=Z?.publicToolName??W.toolRequestPublicName,ve=ue??ie??"unknown_tool";return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("details",{open:!!Z,className:"group w-full max-w-[92%] rounded-md border border-border/60 bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2",children:[s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"truncate text-sm font-medium",children:`Tool call ${ve}`}),s.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${Z?"bg-amber-100 text-amber-900":"bg-muted text-muted-foreground"}`,children:Z?"Needs approval":"Completed"})]})}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"space-y-2 border-t border-border/50 px-3 py-2",children:[s.jsx(oj,{text:W.text,variant:"assistant"}),Z&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"max-h-40 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{children:JSON.stringify(Z.arguments??{},null,2)})}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{D(Z.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{T(Z.id)},children:"Approve"})]})]})]})]})]})})(),W.suggestions&&s.jsxs("div",{className:"ml-0 space-y-3 rounded-md border border-dashed bg-muted/10 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Structured Suggestions"]}),W.suggestions.prompt&&s.jsx(Kp,{title:"Prompt",rationale:W.suggestions.prompt.rationale,preview:W.suggestions.prompt.replacement,applied:P.has(`${W.id}:prompt`),onApply:()=>Q(W.id,W.suggestions,"prompt")}),W.suggestions.evalRules&&s.jsx(Kp,{title:"Checks",rationale:W.suggestions.evalRules.rationale,preview:JSON.stringify(W.suggestions.evalRules.replacement,null,2),applied:P.has(`${W.id}:evalRules`),onApply:()=>Q(W.id,W.suggestions,"evalRules")}),W.suggestions.extractRules&&s.jsx(Kp,{title:"Value Capture Rules",rationale:W.suggestions.extractRules.rationale,preview:JSON.stringify(W.suggestions.extractRules.replacement,null,2),applied:P.has(`${W.id}:extractRules`),onApply:()=>Q(W.id,W.suggestions,"extractRules")}),W.suggestions.snapshotEval&&s.jsx(Kp,{title:"Snapshot Settings",rationale:W.suggestions.snapshotEval.rationale,preview:JSON.stringify(W.suggestions.snapshotEval.patch,null,2),applied:P.has(`${W.id}:snapshotEval`),onApply:()=>Q(W.id,W.suggestions,"snapshotEval")}),(()=>{const Z=W.suggestions?.notes,ye=Array.isArray(Z)?Z:typeof Z=="string"?[Z]:[];return ye.length===0?null:s.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[s.jsx("h5",{className:"text-sm font-medium",children:"Notes"}),s.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground list-disc pl-4",children:ye.map((ae,ue)=>s.jsx("li",{children:ae},`${W.id}-note-${ue}`))})]})})()]})]},W.id)),(S?.pendingToolCalls??[]).filter(W=>!(S?.messages??[]).some(Z=>Z.pendingToolCallId===W.id)).map(W=>s.jsxs("details",{open:!0,className:"group min-w-0 rounded-md border bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-2 p-3",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("p",{className:"min-w-0 truncate font-mono text-xs font-semibold",children:W.publicToolName||W.tool}),s.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-900",children:"Needs approval"})]})}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"border-t px-3 pb-3 pt-2",children:[s.jsx("pre",{className:"max-h-40 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{children:JSON.stringify(W.arguments??{},null,2)})}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{D(W.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{T(W.id)},children:"Approve"})]})]})]},W.id)),!S&&N&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Starting assistant session..."]}),S&&N&&s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Thinking..."]})]}),s.jsx("div",{ref:O})]})}),s.jsxs("div",{className:"rounded-xl border bg-background p-2 shadow-sm",children:[s.jsx(Ks,{ref:k,value:x,onChange:W=>j(W.target.value),placeholder:"Get assistance with creating or refining this scenario ...",disabled:!y||N,rows:1,className:"min-h-10 max-h-40 resize-none border-0 bg-transparent px-2 py-1 text-sm shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",onKeyDown:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),X(x))}}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 px-1 pt-1",children:[s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 px-1.5 text-[11px] font-normal text-muted-foreground/80 hover:text-muted-foreground",disabled:!y||N,children:[s.jsx(us,{className:"h-3 w-3"}),"Snippets",s.jsx(qt,{className:"h-3 w-3"})]})}),s.jsxs(Wo,{align:"start",className:"w-[320px]",children:[s.jsx(JN,{children:"Scenario Assistant Snippets"}),s.jsx(ZN,{}),Vhe.map(W=>s.jsx(hr,{className:"items-start whitespace-normal px-2 py-2",onSelect:()=>J(W.prompt),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"text-xs font-medium leading-tight",children:W.label}),s.jsx("div",{className:"text-[11px] leading-snug text-muted-foreground",children:W.description})]})},W.label))]})]}),s.jsx(se,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>{X(x)},disabled:!y||N||!x.trim(),"aria-label":"Send message",title:"Send message",children:N?s.jsx(sr,{className:"h-4 w-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(o$,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send"})]})})]})]})]}):s.jsx("div",{className:"rounded-md border p-3 text-sm text-muted-foreground",children:"Scenario Assistant requires a configured assistant agent and at least one selected server on the scenario."})]})})]})}function Kp({title:e,rationale:t,preview:n,applied:r=!1,onApply:a}){return s.jsxs("div",{className:`space-y-2 rounded-md border p-3 ${r?"border-emerald-300 bg-emerald-50/40":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h5",{className:"text-sm font-medium",children:e}),s.jsx(se,{type:"button",size:"sm",variant:r?"secondary":"outline",onClick:a,disabled:r,children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ol,{className:"mr-1.5 h-3.5 w-3.5"}),"Applied"]}):"Apply"})]}),t&&s.jsx("p",{className:"text-xs text-muted-foreground",children:t}),s.jsx("pre",{className:"max-h-56 overflow-auto rounded bg-muted p-2 text-xs whitespace-pre-wrap",children:n})]})}function Khe({message:e}){const t=async o=>{try{await navigator.clipboard.writeText(o),Pe({title:"Copied"})}catch(c){Pe({title:"Could not copy",description:c instanceof Error?c.message:String(c),variant:"destructive"})}},n=e.role;if(n==="tool"){const o=String(e.text??"").trim();return/^(Approved|Denied) tool call\b/i.test(o)?null:s.jsxs("div",{className:"rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-2 text-sm",children:[s.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wide text-sky-700",children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),"Tool",s.jsx("span",{className:"font-normal normal-case text-sky-700/80",children:new Date(e.createdAt).toLocaleTimeString()})]}),s.jsx("p",{className:"whitespace-pre-wrap text-sky-900",children:e.text})]})}if(n==="system")return s.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(i$,{className:"h-3 w-3"})}),s.jsx("div",{className:"max-w-[92%] rounded-md border border-amber-400/30 bg-amber-50/70 p-3 text-sm",children:s.jsx(oj,{text:e.text,variant:"assistant"})})]});const r=n==="user",a=r?Nj:ha,i=n==="user"||n==="assistant";return s.jsxs("div",{className:`flex items-start gap-2 text-xs ${r?"justify-end":"justify-start"}`,children:[!r&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(a,{className:"h-3 w-3"})}),s.jsxs("div",{className:"relative max-w-[92%]",children:[s.jsxs("div",{className:`max-w-full rounded-md border px-3 py-2 text-sm ${r?"border-primary/20 bg-primary/10":"border-border/80 bg-background shadow-sm"}`,children:[!r&&s.jsx("p",{className:"mb-2 text-[11px] font-semibold text-muted-foreground",children:"Assistant"}),r?s.jsx("p",{className:"whitespace-pre-wrap",children:e.text}):s.jsx(oj,{text:e.text,variant:"assistant"})]}),i&&s.jsx(se,{type:"button",variant:"ghost",size:"icon",className:`absolute bottom-1 h-6 w-6 text-muted-foreground ${r?"-left-8":"-right-8"}`,onClick:()=>{t(e.text)},"aria-label":"Copy message",title:"Copy message",children:s.jsx(Ri,{className:"h-3.5 w-3.5"})})]}),r&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-primary/30 bg-primary/15 text-primary",children:s.jsx(a,{className:"h-3 w-3"})})]})}function oj({text:e,variant:t="assistant"}){const n=Ghe(e);return s.jsx("div",{className:Se("space-y-2",t==="system"&&"text-xs"),children:n.map((r,a)=>s.jsx(v.Fragment,{children:Yhe(r,a,t)},`md-${a}`))})}function Ghe(e){const t=e.replace(/\r\n/g,`
120
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function T4(e,t){if(e){if(typeof e=="string")return JS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return JS(e,t)}}function Lde(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Fde(e){if(Array.isArray(e))return JS(e)}function JS(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function WI(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function we(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?WI(Object(n),!0).forEach(function(r){pt(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):WI(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function pt(e,t,n){return t=I4(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function I4(e){var t=Bde(e,"string");return gc(t)=="symbol"?t:t+""}function Bde(e,t){if(gc(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(gc(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var zde={xAxis:["bottom","top"],yAxis:["left","right"]},Ude={width:"100%",height:"100%"},M4={x:0,y:0};function Hp(e){return e}var qde=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},Wde=function(t,n,r,a){var i=n.find(function(h){return h&&h.index===r});if(i){if(t==="horizontal")return{x:i.coordinate,y:a.y};if(t==="vertical")return{x:a.x,y:i.coordinate};if(t==="centric"){var o=i.coordinate,c=a.radius;return we(we(we({},a),ln(a.cx,a.cy,c,o)),{},{angle:o,radius:c})}var d=i.coordinate,f=a.angle;return we(we(we({},a),ln(a.cx,a.cy,d,f)),{},{angle:f,radius:d})}return M4},Iv=function(t,n){var r=n.graphicalItems,a=n.dataStartIndex,i=n.dataEndIndex,o=(r??[]).reduce(function(c,d){var f=d.props.data;return f&&f.length?[].concat(yc(c),yc(f)):c},[]);return o.length>0?o:t&&t.length&&$e(a)&&$e(i)?t.slice(a,i+1):[]};function $4(e){return e==="number"?[0,"auto"]:void 0}var ZS=function(t,n,r,a){var i=t.graphicalItems,o=t.tooltipAxis,c=Iv(n,t);return r<0||!i||!i.length||r>=c.length?null:i.reduce(function(d,f){var h,p=(h=f.props.data)!==null&&h!==void 0?h:n;p&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(p=p.slice(t.dataStartIndex,t.dataEndIndex+1));var y;if(o.dataKey&&!o.allowDuplicatedCategory){var g=p===void 0?c:p;y=ph(g,o.dataKey,a)}else y=p&&p[r]||c[r];return y?[].concat(yc(d),[CL(f,y)]):d},[])},VI=function(t,n,r,a){var i=a||{x:t.chartX,y:t.chartY},o=qde(i,r),c=t.orderedTooltipTicks,d=t.tooltipAxis,f=t.tooltipTicks,h=Are(o,c,f,d);if(h>=0&&f){var p=f[h]&&f[h].value,y=ZS(t,n,h,p),g=Wde(r,c,h,i);return{activeTooltipIndex:h,activeLabel:p,activePayload:y,activeCoordinate:g}}return null},Vde=function(t,n){var r=n.axes,a=n.graphicalItems,i=n.axisType,o=n.axisIdKey,c=n.stackGroups,d=n.dataStartIndex,f=n.dataEndIndex,h=t.layout,p=t.children,y=t.stackOffset,g=bL(h,i);return r.reduce(function(S,b){var x,j=b.type.defaultProps!==void 0?we(we({},b.type.defaultProps),b.props):b.props,N=j.type,_=j.dataKey,P=j.allowDataOverflow,A=j.allowDuplicatedCategory,O=j.scale,k=j.ticks,R=j.includeHidden,$=j[o];if(S[$])return S;var z=Iv(t.data,{graphicalItems:a.filter(function(M){var ee,W=o in M.props?M.props[o]:(ee=M.type.defaultProps)===null||ee===void 0?void 0:ee[o];return W===$}),dataStartIndex:d,dataEndIndex:f}),B=z.length,L,K,U;gde(j.domain,P,N)&&(L=pS(j.domain,null,P),g&&(N==="number"||O!=="auto")&&(U=Gu(z,_,"category")));var V=$4(N);if(!L||L.length===0){var X,J=(X=j.domain)!==null&&X!==void 0?X:V;if(_){if(L=Gu(z,_,N),N==="category"&&g){var T=bY(L);A&&T?(K=L,L=Zh(0,B)):A||(L=Y2(J,L,b).reduce(function(M,ee){return M.indexOf(ee)>=0?M:[].concat(yc(M),[ee])},[]))}else if(N==="category")A?L=L.filter(function(M){return M!==""&&!xt(M)}):L=Y2(J,L,b).reduce(function(M,ee){return M.indexOf(ee)>=0||ee===""||xt(ee)?M:[].concat(yc(M),[ee])},[]);else if(N==="number"){var D=Rre(z,a.filter(function(M){var ee,W,Z=o in M.props?M.props[o]:(ee=M.type.defaultProps)===null||ee===void 0?void 0:ee[o],ye="hide"in M.props?M.props.hide:(W=M.type.defaultProps)===null||W===void 0?void 0:W.hide;return Z===$&&(R||!ye)}),_,i,h);D&&(L=D)}g&&(N==="number"||O!=="auto")&&(U=Gu(z,_,"category"))}else g?L=Zh(0,B):c&&c[$]&&c[$].hasStack&&N==="number"?L=y==="expand"?[0,1]:NL(c[$].stackGroups,d,f):L=xL(z,a.filter(function(M){var ee=o in M.props?M.props[o]:M.type.defaultProps[o],W="hide"in M.props?M.props.hide:M.type.defaultProps.hide;return ee===$&&(R||!W)}),N,h,!0);if(N==="number")L=XS(p,L,$,i,k),J&&(L=pS(J,L,P));else if(N==="category"&&J){var Q=J,F=L.every(function(M){return Q.indexOf(M)>=0});F&&(L=Q)}}return we(we({},S),{},pt({},$,we(we({},j),{},{axisType:i,domain:L,categoricalDomain:U,duplicateDomain:K,originalDomain:(x=j.domain)!==null&&x!==void 0?x:V,isCategorical:g,layout:h})))},{})},Hde=function(t,n){var r=n.graphicalItems,a=n.Axis,i=n.axisType,o=n.axisIdKey,c=n.stackGroups,d=n.dataStartIndex,f=n.dataEndIndex,h=t.layout,p=t.children,y=Iv(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:f}),g=y.length,S=bL(h,i),b=-1;return r.reduce(function(x,j){var N=j.type.defaultProps!==void 0?we(we({},j.type.defaultProps),j.props):j.props,_=N[o],P=$4("number");if(!x[_]){b++;var A;return S?A=Zh(0,g):c&&c[_]&&c[_].hasStack?(A=NL(c[_].stackGroups,d,f),A=XS(p,A,_,i)):(A=pS(P,xL(y,r.filter(function(O){var k,R,$=o in O.props?O.props[o]:(k=O.type.defaultProps)===null||k===void 0?void 0:k[o],z="hide"in O.props?O.props.hide:(R=O.type.defaultProps)===null||R===void 0?void 0:R.hide;return $===_&&!z}),"number",h),a.defaultProps.allowDataOverflow),A=XS(p,A,_,i)),we(we({},x),{},pt({},_,we(we({axisType:i},a.defaultProps),{},{hide:!0,orientation:ea(zde,"".concat(i,".").concat(b%2),null),domain:A,originalDomain:P,isCategorical:S,layout:h})))}return x},{})},Kde=function(t,n){var r=n.axisType,a=r===void 0?"xAxis":r,i=n.AxisComp,o=n.graphicalItems,c=n.stackGroups,d=n.dataStartIndex,f=n.dataEndIndex,h=t.children,p="".concat(a,"Id"),y=ta(h,i),g={};return y&&y.length?g=Vde(t,{axes:y,graphicalItems:o,axisType:a,axisIdKey:p,stackGroups:c,dataStartIndex:d,dataEndIndex:f}):o&&o.length&&(g=Hde(t,{Axis:i,graphicalItems:o,axisType:a,axisIdKey:p,stackGroups:c,dataStartIndex:d,dataEndIndex:f})),g},Gde=function(t){var n=wl(t),r=mo(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:fN(r,function(a){return a.coordinate}),tooltipAxis:n,tooltipAxisBandSize:Fh(n,r)}},HI=function(t){var n=t.children,r=t.defaultShowTooltip,a=Vr(n,oc),i=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),a&&a.props&&(a.props.startIndex>=0&&(i=a.props.startIndex),a.props.endIndex>=0&&(o=a.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:i,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},Yde=function(t){return!t||!t.length?!1:t.some(function(n){var r=Ls(n&&n.type);return r&&r.indexOf("Bar")>=0})},KI=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Xde=function(t,n){var r=t.props,a=t.graphicalItems,i=t.xAxisMap,o=i===void 0?{}:i,c=t.yAxisMap,d=c===void 0?{}:c,f=r.width,h=r.height,p=r.children,y=r.margin||{},g=Vr(p,oc),S=Vr(p,$l),b=Object.keys(d).reduce(function(A,O){var k=d[O],R=k.orientation;return!k.mirror&&!k.hide?we(we({},A),{},pt({},R,A[R]+k.width)):A},{left:y.left||0,right:y.right||0}),x=Object.keys(o).reduce(function(A,O){var k=o[O],R=k.orientation;return!k.mirror&&!k.hide?we(we({},A),{},pt({},R,ea(A,"".concat(R))+k.height)):A},{top:y.top||0,bottom:y.bottom||0}),j=we(we({},x),b),N=j.bottom;g&&(j.bottom+=g.props.height||oc.defaultProps.height),S&&n&&(j=Ore(j,a,r,n));var _=f-j.left-j.right,P=h-j.top-j.bottom;return we(we({brushBottom:N},j),{},{width:Math.max(_,0),height:Math.max(P,0)})},Qde=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},WN=function(t){var n=t.chartName,r=t.GraphicalChild,a=t.defaultTooltipEventType,i=a===void 0?"axis":a,o=t.validateTooltipEventTypes,c=o===void 0?["axis"]:o,d=t.axisComponents,f=t.legendContent,h=t.formatAxisMap,p=t.defaultProps,y=function(j,N){var _=N.graphicalItems,P=N.stackGroups,A=N.offset,O=N.updateId,k=N.dataStartIndex,R=N.dataEndIndex,$=j.barSize,z=j.layout,B=j.barGap,L=j.barCategoryGap,K=j.maxBarSize,U=KI(z),V=U.numericAxisName,X=U.cateAxisName,J=Yde(_),T=[];return _.forEach(function(D,Q){var F=Iv(j.data,{graphicalItems:[D],dataStartIndex:k,dataEndIndex:R}),M=D.type.defaultProps!==void 0?we(we({},D.type.defaultProps),D.props):D.props,ee=M.dataKey,W=M.maxBarSize,Z=M["".concat(V,"Id")],ye=M["".concat(X,"Id")],ae={},ue=d.reduce(function(et,dt){var Pt=N["".concat(dt.axisType,"Map")],hn=M["".concat(dt.axisType,"Id")];Pt&&Pt[hn]||dt.axisType==="zAxis"||_o();var be=Pt[hn];return we(we({},et),{},pt(pt({},dt.axisType,be),"".concat(dt.axisType,"Ticks"),mo(be)))},ae),ie=ue[X],ve=ue["".concat(X,"Ticks")],Oe=P&&P[Z]&&P[Z].hasStack&&zre(D,P[Z].stackGroups),oe=Ls(D.type).indexOf("Bar")>=0,he=Fh(ie,ve),xe=[],Ie=J&&Ere({barSize:$,stackGroups:P,totalSize:Qde(ue,X)});if(oe){var re,me,Ne=xt(W)?K:W,tt=(re=(me=Fh(ie,ve,!0))!==null&&me!==void 0?me:Ne)!==null&&re!==void 0?re:0;xe=Pre({barGap:B,barCategoryGap:L,bandSize:tt!==he?tt:he,sizeList:Ie[ye],maxBarSize:Ne}),tt!==he&&(xe=xe.map(function(et){return we(we({},et),{},{position:we(we({},et.position),{},{offset:et.position.offset-tt/2})})}))}var je=D&&D.type&&D.type.getComposedData;je&&T.push({props:we(we({},je(we(we({},ue),{},{displayedData:F,props:j,dataKey:ee,item:D,bandSize:he,barPosition:xe,offset:A,stackedData:Oe,layout:z,dataStartIndex:k,dataEndIndex:R}))),{},pt(pt(pt({key:D.key||"item-".concat(Q)},V,ue[V]),X,ue[X]),"animationId",O)),childIndex:TY(D,j.children),item:D})}),T},g=function(j,N){var _=j.props,P=j.dataStartIndex,A=j.dataEndIndex,O=j.updateId;if(!cO({props:_}))return null;var k=_.children,R=_.layout,$=_.stackOffset,z=_.data,B=_.reverseStackOrder,L=KI(R),K=L.numericAxisName,U=L.cateAxisName,V=ta(k,r),X=Fre(z,V,"".concat(K,"Id"),"".concat(U,"Id"),$,B),J=d.reduce(function(M,ee){var W="".concat(ee.axisType,"Map");return we(we({},M),{},pt({},W,Kde(_,we(we({},ee),{},{graphicalItems:V,stackGroups:ee.axisType===K&&X,dataStartIndex:P,dataEndIndex:A}))))},{}),T=Xde(we(we({},J),{},{props:_,graphicalItems:V}),N?.legendBBox);Object.keys(J).forEach(function(M){J[M]=h(_,J[M],T,M.replace("Map",""),n)});var D=J["".concat(U,"Map")],Q=Gde(D),F=y(_,we(we({},J),{},{dataStartIndex:P,dataEndIndex:A,updateId:O,graphicalItems:V,stackGroups:X,offset:T}));return we(we({formattedGraphicalItems:F,graphicalItems:V,offset:T,stackGroups:X},Q),J)},S=(function(x){function j(N){var _,P,A;return Ode(this,j),A=Tde(this,j,[N]),pt(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),pt(A,"accessibilityManager",new vde),pt(A,"handleLegendBBoxUpdate",function(O){if(O){var k=A.state,R=k.dataStartIndex,$=k.dataEndIndex,z=k.updateId;A.setState(we({legendBBox:O},g({props:A.props,dataStartIndex:R,dataEndIndex:$,updateId:z},we(we({},A.state),{},{legendBBox:O}))))}}),pt(A,"handleReceiveSyncEvent",function(O,k,R){if(A.props.syncId===O){if(R===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(k)}}),pt(A,"handleBrushChange",function(O){var k=O.startIndex,R=O.endIndex;if(k!==A.state.dataStartIndex||R!==A.state.dataEndIndex){var $=A.state.updateId;A.setState(function(){return we({dataStartIndex:k,dataEndIndex:R},g({props:A.props,dataStartIndex:k,dataEndIndex:R,updateId:$},A.state))}),A.triggerSyncEvent({dataStartIndex:k,dataEndIndex:R})}}),pt(A,"handleMouseEnter",function(O){var k=A.getMouseInfo(O);if(k){var R=we(we({},k),{},{isTooltipActive:!0});A.setState(R),A.triggerSyncEvent(R);var $=A.props.onMouseEnter;gt($)&&$(R,O)}}),pt(A,"triggeredAfterMouseMove",function(O){var k=A.getMouseInfo(O),R=k?we(we({},k),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState(R),A.triggerSyncEvent(R);var $=A.props.onMouseMove;gt($)&&$(R,O)}),pt(A,"handleItemMouseEnter",function(O){A.setState(function(){return{isTooltipActive:!0,activeItem:O,activePayload:O.tooltipPayload,activeCoordinate:O.tooltipPosition||{x:O.cx,y:O.cy}}})}),pt(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),pt(A,"handleMouseMove",function(O){O.persist(),A.throttleTriggeredAfterMouseMove(O)}),pt(A,"handleMouseLeave",function(O){A.throttleTriggeredAfterMouseMove.cancel();var k={isTooltipActive:!1};A.setState(k),A.triggerSyncEvent(k);var R=A.props.onMouseLeave;gt(R)&&R(k,O)}),pt(A,"handleOuterEvent",function(O){var k=RY(O),R=ea(A.props,"".concat(k));if(k&&gt(R)){var $,z;/.*touch.*/i.test(k)?z=A.getMouseInfo(O.changedTouches[0]):z=A.getMouseInfo(O),R(($=z)!==null&&$!==void 0?$:{},O)}}),pt(A,"handleClick",function(O){var k=A.getMouseInfo(O);if(k){var R=we(we({},k),{},{isTooltipActive:!0});A.setState(R),A.triggerSyncEvent(R);var $=A.props.onClick;gt($)&&$(R,O)}}),pt(A,"handleMouseDown",function(O){var k=A.props.onMouseDown;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"handleMouseUp",function(O){var k=A.props.onMouseUp;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"handleTouchMove",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(O.changedTouches[0])}),pt(A,"handleTouchStart",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&A.handleMouseDown(O.changedTouches[0])}),pt(A,"handleTouchEnd",function(O){O.changedTouches!=null&&O.changedTouches.length>0&&A.handleMouseUp(O.changedTouches[0])}),pt(A,"handleDoubleClick",function(O){var k=A.props.onDoubleClick;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"handleContextMenu",function(O){var k=A.props.onContextMenu;if(gt(k)){var R=A.getMouseInfo(O);k(R,O)}}),pt(A,"triggerSyncEvent",function(O){A.props.syncId!==void 0&&Zw.emit(e1,A.props.syncId,O,A.eventEmitterSymbol)}),pt(A,"applySyncEvent",function(O){var k=A.props,R=k.layout,$=k.syncMethod,z=A.state.updateId,B=O.dataStartIndex,L=O.dataEndIndex;if(O.dataStartIndex!==void 0||O.dataEndIndex!==void 0)A.setState(we({dataStartIndex:B,dataEndIndex:L},g({props:A.props,dataStartIndex:B,dataEndIndex:L,updateId:z},A.state)));else if(O.activeTooltipIndex!==void 0){var K=O.chartX,U=O.chartY,V=O.activeTooltipIndex,X=A.state,J=X.offset,T=X.tooltipTicks;if(!J)return;if(typeof $=="function")V=$(T,O);else if($==="value"){V=-1;for(var D=0;D<T.length;D++)if(T[D].value===O.activeLabel){V=D;break}}var Q=we(we({},J),{},{x:J.left,y:J.top}),F=Math.min(K,Q.x+Q.width),M=Math.min(U,Q.y+Q.height),ee=T[V]&&T[V].value,W=ZS(A.state,A.props.data,V),Z=T[V]?{x:R==="horizontal"?T[V].coordinate:F,y:R==="horizontal"?M:T[V].coordinate}:M4;A.setState(we(we({},O),{},{activeLabel:ee,activeCoordinate:Z,activePayload:W,activeTooltipIndex:V}))}else A.setState(O)}),pt(A,"renderCursor",function(O){var k,R=A.state,$=R.isTooltipActive,z=R.activeCoordinate,B=R.activePayload,L=R.offset,K=R.activeTooltipIndex,U=R.tooltipAxisBandSize,V=A.getTooltipEventType(),X=(k=O.props.active)!==null&&k!==void 0?k:$,J=A.props.layout,T=O.key||"_recharts-cursor";return q.createElement(jde,{key:T,activeCoordinate:z,activePayload:B,activeTooltipIndex:K,chartName:n,element:O,isActive:X,layout:J,offset:L,tooltipAxisBandSize:U,tooltipEventType:V})}),pt(A,"renderPolarAxis",function(O,k,R){var $=ea(O,"type.axisType"),z=ea(A.state,"".concat($,"Map")),B=O.type.defaultProps,L=B!==void 0?we(we({},B),O.props):O.props,K=z&&z[L["".concat($,"Id")]];return v.cloneElement(O,we(we({},K),{},{className:bt($,K.className),key:O.key||"".concat(k,"-").concat(R),ticks:mo(K,!0)}))}),pt(A,"renderPolarGrid",function(O){var k=O.props,R=k.radialLines,$=k.polarAngles,z=k.polarRadius,B=A.state,L=B.radiusAxisMap,K=B.angleAxisMap,U=wl(L),V=wl(K),X=V.cx,J=V.cy,T=V.innerRadius,D=V.outerRadius;return v.cloneElement(O,{polarAngles:Array.isArray($)?$:mo(V,!0).map(function(Q){return Q.coordinate}),polarRadius:Array.isArray(z)?z:mo(U,!0).map(function(Q){return Q.coordinate}),cx:X,cy:J,innerRadius:T,outerRadius:D,key:O.key||"polar-grid",radialLines:R})}),pt(A,"renderLegend",function(){var O=A.state.formattedGraphicalItems,k=A.props,R=k.children,$=k.width,z=k.height,B=A.props.margin||{},L=$-(B.left||0)-(B.right||0),K=gL({children:R,formattedGraphicalItems:O,legendWidth:L,legendContent:f});if(!K)return null;var U=K.item,V=qI(K,Nde);return v.cloneElement(U,we(we({},V),{},{chartWidth:$,chartHeight:z,margin:B,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),pt(A,"renderTooltip",function(){var O,k=A.props,R=k.children,$=k.accessibilityLayer,z=Vr(R,Hr);if(!z)return null;var B=A.state,L=B.isTooltipActive,K=B.activeCoordinate,U=B.activePayload,V=B.activeLabel,X=B.offset,J=(O=z.props.active)!==null&&O!==void 0?O:L;return v.cloneElement(z,{viewBox:we(we({},X),{},{x:X.left,y:X.top}),active:J,label:V,payload:J?U:[],coordinate:K,accessibilityLayer:$})}),pt(A,"renderBrush",function(O){var k=A.props,R=k.margin,$=k.data,z=A.state,B=z.offset,L=z.dataStartIndex,K=z.dataEndIndex,U=z.updateId;return v.cloneElement(O,{key:O.key||"_recharts-brush",onChange:zp(A.handleBrushChange,O.props.onChange),data:$,x:$e(O.props.x)?O.props.x:B.left,y:$e(O.props.y)?O.props.y:B.top+B.height+B.brushBottom-(R.bottom||0),width:$e(O.props.width)?O.props.width:B.width,startIndex:L,endIndex:K,updateId:"brush-".concat(U)})}),pt(A,"renderReferenceElement",function(O,k,R){if(!O)return null;var $=A,z=$.clipPathId,B=A.state,L=B.xAxisMap,K=B.yAxisMap,U=B.offset,V=O.type.defaultProps||{},X=O.props,J=X.xAxisId,T=J===void 0?V.xAxisId:J,D=X.yAxisId,Q=D===void 0?V.yAxisId:D;return v.cloneElement(O,{key:O.key||"".concat(k,"-").concat(R),xAxis:L[T],yAxis:K[Q],viewBox:{x:U.left,y:U.top,width:U.width,height:U.height},clipPathId:z})}),pt(A,"renderActivePoints",function(O){var k=O.item,R=O.activePoint,$=O.basePoint,z=O.childIndex,B=O.isRange,L=[],K=k.props.key,U=k.item.type.defaultProps!==void 0?we(we({},k.item.type.defaultProps),k.item.props):k.item.props,V=U.activeDot,X=U.dataKey,J=we(we({index:z,dataKey:X,cx:R.x,cy:R.y,r:4,fill:LN(k.item),strokeWidth:2,stroke:"#fff",payload:R.payload,value:R.value},ft(V,!1)),hh(V));return L.push(j.renderActiveDot(V,J,"".concat(K,"-activePoint-").concat(z))),$?L.push(j.renderActiveDot(V,we(we({},J),{},{cx:$.x,cy:$.y}),"".concat(K,"-basePoint-").concat(z))):B&&L.push(null),L}),pt(A,"renderGraphicChild",function(O,k,R){var $=A.filterFormatItem(O,k,R);if(!$)return null;var z=A.getTooltipEventType(),B=A.state,L=B.isTooltipActive,K=B.tooltipAxis,U=B.activeTooltipIndex,V=B.activeLabel,X=A.props.children,J=Vr(X,Hr),T=$.props,D=T.points,Q=T.isRange,F=T.baseLine,M=$.item.type.defaultProps!==void 0?we(we({},$.item.type.defaultProps),$.item.props):$.item.props,ee=M.activeDot,W=M.hide,Z=M.activeBar,ye=M.activeShape,ae=!!(!W&&L&&J&&(ee||Z||ye)),ue={};z!=="axis"&&J&&J.props.trigger==="click"?ue={onClick:zp(A.handleItemMouseEnter,O.props.onClick)}:z!=="axis"&&(ue={onMouseLeave:zp(A.handleItemMouseLeave,O.props.onMouseLeave),onMouseEnter:zp(A.handleItemMouseEnter,O.props.onMouseEnter)});var ie=v.cloneElement(O,we(we({},$.props),ue));function ve(dt){return typeof K.dataKey=="function"?K.dataKey(dt.payload):null}if(ae)if(U>=0){var Oe,oe;if(K.dataKey&&!K.allowDuplicatedCategory){var he=typeof K.dataKey=="function"?ve:"payload.".concat(K.dataKey.toString());Oe=ph(D,he,V),oe=Q&&F&&ph(F,he,V)}else Oe=D?.[U],oe=Q&&F&&F[U];if(ye||Z){var xe=O.props.activeIndex!==void 0?O.props.activeIndex:U;return[v.cloneElement(O,we(we(we({},$.props),ue),{},{activeIndex:xe})),null,null]}if(!xt(Oe))return[ie].concat(yc(A.renderActivePoints({item:$,activePoint:Oe,basePoint:oe,childIndex:U,isRange:Q})))}else{var Ie,re=(Ie=A.getItemByXY(A.state.activeCoordinate))!==null&&Ie!==void 0?Ie:{graphicalItem:ie},me=re.graphicalItem,Ne=me.item,tt=Ne===void 0?O:Ne,je=me.childIndex,et=we(we(we({},$.props),ue),{},{activeIndex:je});return[v.cloneElement(tt,et),null,null]}return Q?[ie,null,null]:[ie,null]}),pt(A,"renderCustomized",function(O,k,R){return v.cloneElement(O,we(we({key:"recharts-customized-".concat(R)},A.props),A.state))}),pt(A,"renderMap",{CartesianGrid:{handler:Hp,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:Hp},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:Hp},YAxis:{handler:Hp},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((_=N.id)!==null&&_!==void 0?_:Tc("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=g5(A.triggeredAfterMouseMove,(P=N.throttleDelay)!==null&&P!==void 0?P:1e3/60),A.state={},A}return $de(j,x),Rde(j,[{key:"componentDidMount",value:function(){var _,P;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(_=this.props.margin.left)!==null&&_!==void 0?_:0,top:(P=this.props.margin.top)!==null&&P!==void 0?P:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var _=this.props,P=_.children,A=_.data,O=_.height,k=_.layout,R=Vr(P,Hr);if(R){var $=R.props.defaultIndex;if(!(typeof $!="number"||$<0||$>this.state.tooltipTicks.length-1)){var z=this.state.tooltipTicks[$]&&this.state.tooltipTicks[$].value,B=ZS(this.state,A,$,z),L=this.state.tooltipTicks[$].coordinate,K=(this.state.offset.top+O)/2,U=k==="horizontal",V=U?{x:L,y:K}:{y:L,x:K},X=this.state.formattedGraphicalItems.find(function(T){var D=T.item;return D.type.name==="Scatter"});X&&(V=we(we({},V),X.props.points[$].tooltipPosition),B=X.props.points[$].tooltipPayload);var J={activeTooltipIndex:$,isTooltipActive:!0,activeLabel:z,activePayload:B,activeCoordinate:V};this.setState(J),this.renderCursor(R),this.accessibilityManager.setIndex($)}}}},{key:"getSnapshotBeforeUpdate",value:function(_,P){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==P.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==_.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==_.margin){var A,O;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(O=this.props.margin.top)!==null&&O!==void 0?O:0}})}return null}},{key:"componentDidUpdate",value:function(_){I1([Vr(_.children,Hr)],[Vr(this.props.children,Hr)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var _=Vr(this.props.children,Hr);if(_&&typeof _.props.shared=="boolean"){var P=_.props.shared?"axis":"item";return c.indexOf(P)>=0?P:i}return i}},{key:"getMouseInfo",value:function(_){if(!this.container)return null;var P=this.container,A=P.getBoundingClientRect(),O=xZ(A),k={chartX:Math.round(_.pageX-O.left),chartY:Math.round(_.pageY-O.top)},R=A.width/P.offsetWidth||1,$=this.inRange(k.chartX,k.chartY,R);if(!$)return null;var z=this.state,B=z.xAxisMap,L=z.yAxisMap,K=this.getTooltipEventType(),U=VI(this.state,this.props.data,this.props.layout,$);if(K!=="axis"&&B&&L){var V=wl(B).scale,X=wl(L).scale,J=V&&V.invert?V.invert(k.chartX):null,T=X&&X.invert?X.invert(k.chartY):null;return we(we({},k),{},{xValue:J,yValue:T},U)}return U?we(we({},k),U):null}},{key:"inRange",value:function(_,P){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,O=this.props.layout,k=_/A,R=P/A;if(O==="horizontal"||O==="vertical"){var $=this.state.offset,z=k>=$.left&&k<=$.left+$.width&&R>=$.top&&R<=$.top+$.height;return z?{x:k,y:R}:null}var B=this.state,L=B.angleAxisMap,K=B.radiusAxisMap;if(L&&K){var U=wl(L);return J2({x:k,y:R},U)}return null}},{key:"parseEventsOfWrapper",value:function(){var _=this.props.children,P=this.getTooltipEventType(),A=Vr(_,Hr),O={};A&&P==="axis"&&(A.props.trigger==="click"?O={onClick:this.handleClick}:O={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var k=hh(this.props,this.handleOuterEvent);return we(we({},k),O)}},{key:"addListener",value:function(){Zw.on(e1,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){Zw.removeListener(e1,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(_,P,A){for(var O=this.state.formattedGraphicalItems,k=0,R=O.length;k<R;k++){var $=O[k];if($.item===_||$.props.key===_.key||P===Ls($.item.type)&&A===$.childIndex)return $}return null}},{key:"renderClipPath",value:function(){var _=this.clipPathId,P=this.state.offset,A=P.left,O=P.top,k=P.height,R=P.width;return q.createElement("defs",null,q.createElement("clipPath",{id:_},q.createElement("rect",{x:A,y:O,height:k,width:R})))}},{key:"getXScales",value:function(){var _=this.state.xAxisMap;return _?Object.entries(_).reduce(function(P,A){var O=UI(A,2),k=O[0],R=O[1];return we(we({},P),{},pt({},k,R.scale))},{}):null}},{key:"getYScales",value:function(){var _=this.state.yAxisMap;return _?Object.entries(_).reduce(function(P,A){var O=UI(A,2),k=O[0],R=O[1];return we(we({},P),{},pt({},k,R.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(_){var P;return(P=this.state.xAxisMap)===null||P===void 0||(P=P[_])===null||P===void 0?void 0:P.scale}},{key:"getYScaleByAxisId",value:function(_){var P;return(P=this.state.yAxisMap)===null||P===void 0||(P=P[_])===null||P===void 0?void 0:P.scale}},{key:"getItemByXY",value:function(_){var P=this.state,A=P.formattedGraphicalItems,O=P.activeItem;if(A&&A.length)for(var k=0,R=A.length;k<R;k++){var $=A[k],z=$.props,B=$.item,L=B.type.defaultProps!==void 0?we(we({},B.type.defaultProps),B.props):B.props,K=Ls(B.type);if(K==="Bar"){var U=(z.data||[]).find(function(T){return Bie(_,T)});if(U)return{graphicalItem:$,payload:U}}else if(K==="RadialBar"){var V=(z.data||[]).find(function(T){return J2(_,T)});if(V)return{graphicalItem:$,payload:V}}else if(_v($,O)||Av($,O)||Md($,O)){var X=cle({graphicalItem:$,activeTooltipItem:O,itemData:L.data}),J=L.activeIndex===void 0?X:L.activeIndex;return{graphicalItem:we(we({},$),{},{childIndex:J}),payload:Md($,O)?L.data[X]:$.props.data[X]}}}return null}},{key:"render",value:function(){var _=this;if(!cO(this))return null;var P=this.props,A=P.children,O=P.className,k=P.width,R=P.height,$=P.style,z=P.compact,B=P.title,L=P.desc,K=qI(P,Cde),U=ft(K,!1);if(z)return q.createElement(CI,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},q.createElement($1,El({},U,{width:k,height:R,title:B,desc:L}),this.renderClipPath(),dO(A,this.renderMap)));if(this.props.accessibilityLayer){var V,X;U.tabIndex=(V=this.props.tabIndex)!==null&&V!==void 0?V:0,U.role=(X=this.props.role)!==null&&X!==void 0?X:"application",U.onKeyDown=function(T){_.accessibilityManager.keyboardEvent(T)},U.onFocus=function(){_.accessibilityManager.focus()}}var J=this.parseEventsOfWrapper();return q.createElement(CI,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},q.createElement("div",El({className:bt("recharts-wrapper",O),style:we({position:"relative",cursor:"default",width:k,height:R},$)},J,{ref:function(D){_.container=D}}),q.createElement($1,El({},U,{width:k,height:R,title:B,desc:L,style:Ude}),this.renderClipPath(),dO(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(v.Component);pt(S,"displayName",n),pt(S,"defaultProps",we({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},p)),pt(S,"getDerivedStateFromProps",function(x,j){var N=x.dataKey,_=x.data,P=x.children,A=x.width,O=x.height,k=x.layout,R=x.stackOffset,$=x.margin,z=j.dataStartIndex,B=j.dataEndIndex;if(j.updateId===void 0){var L=HI(x);return we(we(we({},L),{},{updateId:0},g(we(we({props:x},L),{},{updateId:0}),j)),{},{prevDataKey:N,prevData:_,prevWidth:A,prevHeight:O,prevLayout:k,prevStackOffset:R,prevMargin:$,prevChildren:P})}if(N!==j.prevDataKey||_!==j.prevData||A!==j.prevWidth||O!==j.prevHeight||k!==j.prevLayout||R!==j.prevStackOffset||!Ml($,j.prevMargin)){var K=HI(x),U={chartX:j.chartX,chartY:j.chartY,isTooltipActive:j.isTooltipActive},V=we(we({},VI(j,_,k)),{},{updateId:j.updateId+1}),X=we(we(we({},K),U),V);return we(we(we({},X),g(we({props:x},X),j)),{},{prevDataKey:N,prevData:_,prevWidth:A,prevHeight:O,prevLayout:k,prevStackOffset:R,prevMargin:$,prevChildren:P})}if(!I1(P,j.prevChildren)){var J,T,D,Q,F=Vr(P,oc),M=F&&(J=(T=F.props)===null||T===void 0?void 0:T.startIndex)!==null&&J!==void 0?J:z,ee=F&&(D=(Q=F.props)===null||Q===void 0?void 0:Q.endIndex)!==null&&D!==void 0?D:B,W=M!==z||ee!==B,Z=!xt(_),ye=Z&&!W?j.updateId:j.updateId+1;return we(we({updateId:ye},g(we(we({props:x},j),{},{updateId:ye,dataStartIndex:M,dataEndIndex:ee}),j)),{},{prevChildren:P,dataStartIndex:M,dataEndIndex:ee})}return null}),pt(S,"renderActiveDot",function(x,j,N){var _;return v.isValidElement(x)?_=v.cloneElement(x,j):gt(x)?_=x(j):_=q.createElement(wv,j),q.createElement(Tt,{className:"recharts-active-dot",key:N},_)});var b=v.forwardRef(function(j,N){return q.createElement(S,El({},j,{ref:N}))});return b.displayName=S.displayName,b},GI=WN({chartName:"LineChart",GraphicalChild:hc,axisComponents:[{axisType:"xAxis",AxisComp:Ao},{axisType:"yAxis",AxisComp:Eo}],formatAxisMap:e4}),Jde=WN({chartName:"BarChart",GraphicalChild:zo,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Ao},{axisType:"yAxis",AxisComp:Eo}],formatAxisMap:e4}),Zde=WN({chartName:"PieChart",GraphicalChild:Js,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Cv},{axisType:"radiusAxis",AxisComp:jv}],formatAxisMap:Qre,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});const efe=()=>{const{configs:e}=tf(),{source:t}=On(),[n,r]=v.useState([]),[a,i]=v.useState("timestamp"),[o,c]=v.useState("desc"),d=x=>{if(a===x){c(j=>j==="asc"?"desc":"asc");return}i(x),c("desc")};v.useEffect(()=>{let x=!0;return t.listResults().then(j=>{x&&r(j)}),()=>{x=!1}},[t]);const f=e.length,h=n.length,p=h===0?0:n.reduce((x,j)=>x+j.overallPassRate,0)/h,y=h===0?0:Math.round(n.reduce((x,j)=>x+j.avgLatency,0)/h),g=v.useMemo(()=>[...n].sort((j,N)=>{let _=0;return a==="timestamp"&&(_=new Date(j.timestamp).getTime()-new Date(N.timestamp).getTime()),a==="passRate"&&(_=j.overallPassRate-N.overallPassRate),a==="latency"&&(_=j.avgLatency-N.avgLatency),a==="scenarios"&&(_=j.totalScenarios-N.totalScenarios),o==="asc"?_:-_}),[n,a,o]),S=[...g].reverse().map(x=>({date:new Date(x.timestamp).toLocaleDateString("en-US",{month:"short",day:"numeric"}),passRate:Math.round(x.overallPassRate*100),latency:x.avgLatency})),b=x=>{const j=Array.from(new Set(x.scenarios.map(A=>A.scenarioId).filter(Boolean))),N=Array.from(new Set(x.scenarios.map(A=>A.agentName).filter(Boolean))),_=j.slice(0,2).join(", "),P=j.length>2?` +${j.length-2}`:"";return{scenarioCount:j.length,agentCount:N.length,scenarioPreview:_?`${_}${P}`:"n/a"}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(r$,{className:"h-6 w-6"}),"Dashboard"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Overview of your MCP evaluation runs"})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsx(se,{asChild:!0,children:s.jsxs(yt,{to:"/mcp-evaluations/new",children:[s.jsx(jj,{className:"mr-2 h-4 w-4"}),"New MCP Evaluation"]})}),s.jsx(se,{variant:"outline",asChild:!0,children:s.jsxs(yt,{to:"/run",children:[s.jsx(kl,{className:"mr-2 h-4 w-4"}),"Run Evaluation"]})}),s.jsx(se,{variant:"outline",asChild:!0,children:s.jsxs(yt,{to:"/results",children:[s.jsx(ed,{className:"mr-2 h-4 w-4"}),"Browse Results"]})})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[s.jsx(Ts,{title:"MCP Evaluations",value:f,icon:p1,subtitle:`${f} active`}),s.jsx(Ts,{title:"Total Runs",value:h,icon:JM,subtitle:"Last 30 days"}),s.jsx(Ts,{title:"Pass Rate",value:`${Math.round(p*100)}%`,icon:ed,subtitle:"+5% from last week",trend:"up"}),s.jsx(Ts,{title:"Avg Latency",value:`${y}ms`,icon:l$,subtitle:"-120ms from last week",trend:"up"})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Pass Rate Trend"})}),s.jsx(ze,{children:s.jsx(X1,{width:"100%",height:200,children:s.jsxs(GI,{data:S,children:[s.jsx(Ao,{dataKey:"date",tick:{fontSize:11},tickLine:!1,axisLine:!1}),s.jsx(Eo,{domain:[0,100],tick:{fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:x=>`${x}%`}),s.jsx(Hr,{formatter:x=>[`${x}%`,"Pass Rate"]}),s.jsx(hc,{type:"monotone",dataKey:"passRate",stroke:"hsl(38, 92%, 50%)",strokeWidth:2,dot:{r:3,fill:"hsl(38, 92%, 50%)"}})]})})})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Recent Tool Latency (ms)"})}),s.jsx(ze,{children:s.jsx(X1,{width:"100%",height:200,children:s.jsxs(GI,{data:S,children:[s.jsx(Ao,{dataKey:"date",tick:{fontSize:11},tickLine:!1,axisLine:!1}),s.jsx(Eo,{tick:{fontSize:11},tickLine:!1,axisLine:!1}),s.jsx(Hr,{formatter:x=>[`${x}ms`,"Latency"]}),s.jsx(hc,{type:"monotone",dataKey:"latency",stroke:"hsl(200, 80%, 50%)",strokeWidth:2,dot:{r:3,fill:"hsl(200, 80%, 50%)"}})]})})})]})]}),s.jsx("div",{className:"grid gap-6",children:s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Recent Runs"})}),s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Run ID"}),s.jsx(Qe,{children:"Evaluated"}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>d("timestamp"),children:["Timestamp",a==="timestamp"?o==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}):s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>d("passRate"),children:["Pass Rate",a==="passRate"?o==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}):s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"})]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>d("scenarios"),children:["Scenarios",a==="scenarios"?o==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}):s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"})]})})]})}),s.jsx(Jr,{children:g.map(x=>s.jsxs(Bt,{className:"cursor-pointer",children:[s.jsx(Fe,{children:s.jsx(yt,{to:`/results/${x.id}`,className:"font-mono text-xs text-primary hover:underline",children:x.id})}),s.jsx(Fe,{className:"text-[11px] text-muted-foreground",children:(()=>{const j=b(x);return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{children:["Evaluated: ",j.scenarioCount," scenario",j.scenarioCount===1?"":"s"," · ",j.agentCount," agent",j.agentCount===1?"":"s"]}),s.jsx("div",{className:"font-mono text-xs text-foreground/80",children:j.scenarioPreview})]})})()}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Nm,{className:"h-3 w-3"}),new Date(x.timestamp).toLocaleString()]})}),s.jsx(Fe,{children:s.jsx(vo,{rate:x.overallPassRate})}),s.jsx(Fe,{className:"text-right font-mono text-sm",children:x.totalScenarios})]},x.id))})]})})]})})]})};var tfe=v.createContext(void 0);function Lc(e){const t=v.useContext(tfe);return e||t||"ltr"}var n1="rovingFocusGroup.onEntryFocus",nfe={bubbles:!1,cancelable:!0},ff="RovingFocusGroup",[ej,D4,rfe]=Hd(ff),[afe,Mv]=ir(ff,[rfe]),[sfe,ife]=afe(ff),L4=v.forwardRef((e,t)=>s.jsx(ej.Provider,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ej.Slot,{scope:e.__scopeRovingFocusGroup,children:s.jsx(ofe,{...e,ref:t})})}));L4.displayName=ff;var ofe=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:a=!1,dir:i,currentTabStopId:o,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:d,onEntryFocus:f,preventScrollOnEntryFocus:h=!1,...p}=e,y=v.useRef(null),g=ut(t,y),S=Lc(i),[b,x]=na({prop:o,defaultProp:c??null,onChange:d,caller:ff}),[j,N]=v.useState(!1),_=Pn(f),P=D4(n),A=v.useRef(!1),[O,k]=v.useState(0);return v.useEffect(()=>{const R=y.current;if(R)return R.addEventListener(n1,_),()=>R.removeEventListener(n1,_)},[_]),s.jsx(sfe,{scope:n,orientation:r,dir:S,loop:a,currentTabStopId:b,onItemFocus:v.useCallback(R=>x(R),[x]),onItemShiftTab:v.useCallback(()=>N(!0),[]),onFocusableItemAdd:v.useCallback(()=>k(R=>R+1),[]),onFocusableItemRemove:v.useCallback(()=>k(R=>R-1),[]),children:s.jsx(De.div,{tabIndex:j||O===0?-1:0,"data-orientation":r,...p,ref:g,style:{outline:"none",...e.style},onMouseDown:Ae(e.onMouseDown,()=>{A.current=!0}),onFocus:Ae(e.onFocus,R=>{const $=!A.current;if(R.target===R.currentTarget&&$&&!j){const z=new CustomEvent(n1,nfe);if(R.currentTarget.dispatchEvent(z),!z.defaultPrevented){const B=P().filter(X=>X.focusable),L=B.find(X=>X.active),K=B.find(X=>X.id===b),V=[L,K,...B].filter(Boolean).map(X=>X.ref.current);z4(V,h)}}A.current=!1}),onBlur:Ae(e.onBlur,()=>N(!1))})})}),F4="RovingFocusGroupItem",B4=v.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:a=!1,tabStopId:i,children:o,...c}=e,d=Hn(),f=i||d,h=ife(F4,n),p=h.currentTabStopId===f,y=D4(n),{onFocusableItemAdd:g,onFocusableItemRemove:S,currentTabStopId:b}=h;return v.useEffect(()=>{if(r)return g(),()=>S()},[r,g,S]),s.jsx(ej.ItemSlot,{scope:n,id:f,focusable:r,active:a,children:s.jsx(De.span,{tabIndex:p?0:-1,"data-orientation":h.orientation,...c,ref:t,onMouseDown:Ae(e.onMouseDown,x=>{r?h.onItemFocus(f):x.preventDefault()}),onFocus:Ae(e.onFocus,()=>h.onItemFocus(f)),onKeyDown:Ae(e.onKeyDown,x=>{if(x.key==="Tab"&&x.shiftKey){h.onItemShiftTab();return}if(x.target!==x.currentTarget)return;const j=ufe(x,h.orientation,h.dir);if(j!==void 0){if(x.metaKey||x.ctrlKey||x.altKey||x.shiftKey)return;x.preventDefault();let _=y().filter(P=>P.focusable).map(P=>P.ref.current);if(j==="last")_.reverse();else if(j==="prev"||j==="next"){j==="prev"&&_.reverse();const P=_.indexOf(x.currentTarget);_=h.loop?dfe(_,P+1):_.slice(P+1)}setTimeout(()=>z4(_))}}),children:typeof o=="function"?o({isCurrentTabStop:p,hasTabStop:b!=null}):o})})});B4.displayName=F4;var lfe={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function cfe(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function ufe(e,t,n){const r=cfe(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return lfe[r]}function z4(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function dfe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var U4=L4,q4=B4;function ffe(e){const t=pfe(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(mfe);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function pfe(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=gfe(a),c=vfe(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var hfe=Symbol("radix.slottable");function mfe(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hfe}function vfe(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function gfe(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var tj=["Enter"," "],yfe=["ArrowDown","PageUp","Home"],W4=["ArrowUp","PageDown","End"],xfe=[...yfe,...W4],bfe={ltr:[...tj,"ArrowRight"],rtl:[...tj,"ArrowLeft"]},wfe={ltr:["ArrowLeft"],rtl:["ArrowRight"]},pf="Menu",[Ud,Sfe,jfe]=Hd(pf),[Uo,V4]=ir(pf,[jfe,Di,Mv]),$v=Di(),H4=Mv(),[Nfe,qo]=Uo(pf),[Cfe,hf]=Uo(pf),K4=e=>{const{__scopeMenu:t,open:n=!1,children:r,dir:a,onOpenChange:i,modal:o=!0}=e,c=$v(t),[d,f]=v.useState(null),h=v.useRef(!1),p=Pn(i),y=Lc(a);return v.useEffect(()=>{const g=()=>{h.current=!0,document.addEventListener("pointerdown",S,{capture:!0,once:!0}),document.addEventListener("pointermove",S,{capture:!0,once:!0})},S=()=>h.current=!1;return document.addEventListener("keydown",g,{capture:!0}),()=>{document.removeEventListener("keydown",g,{capture:!0}),document.removeEventListener("pointerdown",S,{capture:!0}),document.removeEventListener("pointermove",S,{capture:!0})}},[]),s.jsx(Rm,{...c,children:s.jsx(Nfe,{scope:t,open:n,onOpenChange:p,content:d,onContentChange:f,children:s.jsx(Cfe,{scope:t,onClose:v.useCallback(()=>p(!1),[p]),isUsingKeyboardRef:h,dir:y,modal:o,children:r})})})};K4.displayName=pf;var _fe="MenuAnchor",VN=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=$v(n);return s.jsx(Yd,{...a,...r,ref:t})});VN.displayName=_fe;var HN="MenuPortal",[Afe,G4]=Uo(HN,{forceMount:void 0}),Y4=e=>{const{__scopeMenu:t,forceMount:n,children:r,container:a}=e,i=qo(HN,t);return s.jsx(Afe,{scope:t,forceMount:n,children:s.jsx(Gn,{present:n||i.open,children:s.jsx(Sc,{asChild:!0,container:a,children:r})})})};Y4.displayName=HN;var ya="MenuContent",[Efe,KN]=Uo(ya),X4=v.forwardRef((e,t)=>{const n=G4(ya,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=qo(ya,e.__scopeMenu),o=hf(ya,e.__scopeMenu);return s.jsx(Ud.Provider,{scope:e.__scopeMenu,children:s.jsx(Gn,{present:r||i.open,children:s.jsx(Ud.Slot,{scope:e.__scopeMenu,children:o.modal?s.jsx(Pfe,{...a,ref:t}):s.jsx(Ofe,{...a,ref:t})})})})}),Pfe=v.forwardRef((e,t)=>{const n=qo(ya,e.__scopeMenu),r=v.useRef(null),a=ut(t,r);return v.useEffect(()=>{const i=r.current;if(i)return Hm(i)},[]),s.jsx(GN,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ae(e.onFocusOutside,i=>i.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ofe=v.forwardRef((e,t)=>{const n=qo(ya,e.__scopeMenu);return s.jsx(GN,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),kfe=ffe("MenuContent.ScrollLock"),GN=v.forwardRef((e,t)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:a,onOpenAutoFocus:i,onCloseAutoFocus:o,disableOutsidePointerEvents:c,onEntryFocus:d,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:g,disableOutsideScroll:S,...b}=e,x=qo(ya,n),j=hf(ya,n),N=$v(n),_=H4(n),P=Sfe(n),[A,O]=v.useState(null),k=v.useRef(null),R=ut(t,k,x.onContentChange),$=v.useRef(0),z=v.useRef(""),B=v.useRef(0),L=v.useRef(null),K=v.useRef("right"),U=v.useRef(0),V=S?Qd:v.Fragment,X=S?{as:kfe,allowPinchZoom:!0}:void 0,J=D=>{const Q=z.current+D,F=P().filter(ae=>!ae.disabled),M=document.activeElement,ee=F.find(ae=>ae.ref.current===M)?.textValue,W=F.map(ae=>ae.textValue),Z=qfe(W,Q,ee),ye=F.find(ae=>ae.textValue===Z)?.ref.current;(function ae(ue){z.current=ue,window.clearTimeout($.current),ue!==""&&($.current=window.setTimeout(()=>ae(""),1e3))})(Q),ye&&setTimeout(()=>ye.focus())};v.useEffect(()=>()=>window.clearTimeout($.current),[]),Wm();const T=v.useCallback(D=>K.current===L.current?.side&&Vfe(D,L.current?.area),[]);return s.jsx(Efe,{scope:n,searchRef:z,onItemEnter:v.useCallback(D=>{T(D)&&D.preventDefault()},[T]),onItemLeave:v.useCallback(D=>{T(D)||(k.current?.focus(),O(null))},[T]),onTriggerLeave:v.useCallback(D=>{T(D)&&D.preventDefault()},[T]),pointerGraceTimerRef:B,onPointerGraceIntentChange:v.useCallback(D=>{L.current=D},[]),children:s.jsx(V,{...X,children:s.jsx(Xd,{asChild:!0,trapped:a,onMountAutoFocus:Ae(i,D=>{D.preventDefault(),k.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:c,onEscapeKeyDown:f,onPointerDownOutside:h,onFocusOutside:p,onInteractOutside:y,onDismiss:g,children:s.jsx(U4,{asChild:!0,..._,dir:j.dir,orientation:"vertical",loop:r,currentTabStopId:A,onCurrentTabStopIdChange:O,onEntryFocus:Ae(d,D=>{j.isUsingKeyboardRef.current||D.preventDefault()}),preventScrollOnEntryFocus:!0,children:s.jsx(Tm,{role:"menu","aria-orientation":"vertical","data-state":fF(x.open),"data-radix-menu-content":"",dir:j.dir,...N,...b,ref:R,style:{outline:"none",...b.style},onKeyDown:Ae(b.onKeyDown,D=>{const F=D.target.closest("[data-radix-menu-content]")===D.currentTarget,M=D.ctrlKey||D.altKey||D.metaKey,ee=D.key.length===1;F&&(D.key==="Tab"&&D.preventDefault(),!M&&ee&&J(D.key));const W=k.current;if(D.target!==W||!xfe.includes(D.key))return;D.preventDefault();const ye=P().filter(ae=>!ae.disabled).map(ae=>ae.ref.current);W4.includes(D.key)&&ye.reverse(),zfe(ye)}),onBlur:Ae(e.onBlur,D=>{D.currentTarget.contains(D.target)||(window.clearTimeout($.current),z.current="")}),onPointerMove:Ae(e.onPointerMove,qd(D=>{const Q=D.target,F=U.current!==D.clientX;if(D.currentTarget.contains(Q)&&F){const M=D.clientX>U.current?"right":"left";K.current=M,U.current=D.clientX}}))})})})})})})});X4.displayName=ya;var Rfe="MenuGroup",YN=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(De.div,{role:"group",...r,ref:t})});YN.displayName=Rfe;var Tfe="MenuLabel",Q4=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(De.div,{...r,ref:t})});Q4.displayName=Tfe;var pm="MenuItem",YI="menu.itemSelect",Dv=v.forwardRef((e,t)=>{const{disabled:n=!1,onSelect:r,...a}=e,i=v.useRef(null),o=hf(pm,e.__scopeMenu),c=KN(pm,e.__scopeMenu),d=ut(t,i),f=v.useRef(!1),h=()=>{const p=i.current;if(!n&&p){const y=new CustomEvent(YI,{bubbles:!0,cancelable:!0});p.addEventListener(YI,g=>r?.(g),{once:!0}),gj(p,y),y.defaultPrevented?f.current=!1:o.onClose()}};return s.jsx(J4,{...a,ref:d,disabled:n,onClick:Ae(e.onClick,h),onPointerDown:p=>{e.onPointerDown?.(p),f.current=!0},onPointerUp:Ae(e.onPointerUp,p=>{f.current||p.currentTarget?.click()}),onKeyDown:Ae(e.onKeyDown,p=>{const y=c.searchRef.current!=="";n||y&&p.key===" "||tj.includes(p.key)&&(p.currentTarget.click(),p.preventDefault())})})});Dv.displayName=pm;var J4=v.forwardRef((e,t)=>{const{__scopeMenu:n,disabled:r=!1,textValue:a,...i}=e,o=KN(pm,n),c=H4(n),d=v.useRef(null),f=ut(t,d),[h,p]=v.useState(!1),[y,g]=v.useState("");return v.useEffect(()=>{const S=d.current;S&&g((S.textContent??"").trim())},[i.children]),s.jsx(Ud.ItemSlot,{scope:n,disabled:r,textValue:a??y,children:s.jsx(q4,{asChild:!0,...c,focusable:!r,children:s.jsx(De.div,{role:"menuitem","data-highlighted":h?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...i,ref:f,onPointerMove:Ae(e.onPointerMove,qd(S=>{r?o.onItemLeave(S):(o.onItemEnter(S),S.defaultPrevented||S.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ae(e.onPointerLeave,qd(S=>o.onItemLeave(S))),onFocus:Ae(e.onFocus,()=>p(!0)),onBlur:Ae(e.onBlur,()=>p(!1))})})})}),Ife="MenuCheckboxItem",Z4=v.forwardRef((e,t)=>{const{checked:n=!1,onCheckedChange:r,...a}=e;return s.jsx(aF,{scope:e.__scopeMenu,checked:n,children:s.jsx(Dv,{role:"menuitemcheckbox","aria-checked":hm(n)?"mixed":n,...a,ref:t,"data-state":QN(n),onSelect:Ae(a.onSelect,()=>r?.(hm(n)?!0:!n),{checkForDefaultPrevented:!1})})})});Z4.displayName=Ife;var eF="MenuRadioGroup",[Mfe,$fe]=Uo(eF,{value:void 0,onValueChange:()=>{}}),tF=v.forwardRef((e,t)=>{const{value:n,onValueChange:r,...a}=e,i=Pn(r);return s.jsx(Mfe,{scope:e.__scopeMenu,value:n,onValueChange:i,children:s.jsx(YN,{...a,ref:t})})});tF.displayName=eF;var nF="MenuRadioItem",rF=v.forwardRef((e,t)=>{const{value:n,...r}=e,a=$fe(nF,e.__scopeMenu),i=n===a.value;return s.jsx(aF,{scope:e.__scopeMenu,checked:i,children:s.jsx(Dv,{role:"menuitemradio","aria-checked":i,...r,ref:t,"data-state":QN(i),onSelect:Ae(r.onSelect,()=>a.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});rF.displayName=nF;var XN="MenuItemIndicator",[aF,Dfe]=Uo(XN,{checked:!1}),sF=v.forwardRef((e,t)=>{const{__scopeMenu:n,forceMount:r,...a}=e,i=Dfe(XN,n);return s.jsx(Gn,{present:r||hm(i.checked)||i.checked===!0,children:s.jsx(De.span,{...a,ref:t,"data-state":QN(i.checked)})})});sF.displayName=XN;var Lfe="MenuSeparator",iF=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e;return s.jsx(De.div,{role:"separator","aria-orientation":"horizontal",...r,ref:t})});iF.displayName=Lfe;var Ffe="MenuArrow",oF=v.forwardRef((e,t)=>{const{__scopeMenu:n,...r}=e,a=$v(n);return s.jsx(Im,{...a,...r,ref:t})});oF.displayName=Ffe;var Bfe="MenuSub",[Ege,lF]=Uo(Bfe),Uu="MenuSubTrigger",cF=v.forwardRef((e,t)=>{const n=qo(Uu,e.__scopeMenu),r=hf(Uu,e.__scopeMenu),a=lF(Uu,e.__scopeMenu),i=KN(Uu,e.__scopeMenu),o=v.useRef(null),{pointerGraceTimerRef:c,onPointerGraceIntentChange:d}=i,f={__scopeMenu:e.__scopeMenu},h=v.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return v.useEffect(()=>h,[h]),v.useEffect(()=>{const p=c.current;return()=>{window.clearTimeout(p),d(null)}},[c,d]),s.jsx(VN,{asChild:!0,...f,children:s.jsx(J4,{id:a.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":a.contentId,"data-state":fF(n.open),...e,ref:jr(t,a.onTriggerChange),onClick:p=>{e.onClick?.(p),!(e.disabled||p.defaultPrevented)&&(p.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Ae(e.onPointerMove,qd(p=>{i.onItemEnter(p),!p.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(i.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),h()},100))})),onPointerLeave:Ae(e.onPointerLeave,qd(p=>{h();const y=n.content?.getBoundingClientRect();if(y){const g=n.content?.dataset.side,S=g==="right",b=S?-5:5,x=y[S?"left":"right"],j=y[S?"right":"left"];i.onPointerGraceIntentChange({area:[{x:p.clientX+b,y:p.clientY},{x,y:y.top},{x:j,y:y.top},{x:j,y:y.bottom},{x,y:y.bottom}],side:g}),window.clearTimeout(c.current),c.current=window.setTimeout(()=>i.onPointerGraceIntentChange(null),300)}else{if(i.onTriggerLeave(p),p.defaultPrevented)return;i.onPointerGraceIntentChange(null)}})),onKeyDown:Ae(e.onKeyDown,p=>{const y=i.searchRef.current!=="";e.disabled||y&&p.key===" "||bfe[r.dir].includes(p.key)&&(n.onOpenChange(!0),n.content?.focus(),p.preventDefault())})})})});cF.displayName=Uu;var uF="MenuSubContent",dF=v.forwardRef((e,t)=>{const n=G4(ya,e.__scopeMenu),{forceMount:r=n.forceMount,...a}=e,i=qo(ya,e.__scopeMenu),o=hf(ya,e.__scopeMenu),c=lF(uF,e.__scopeMenu),d=v.useRef(null),f=ut(t,d);return s.jsx(Ud.Provider,{scope:e.__scopeMenu,children:s.jsx(Gn,{present:r||i.open,children:s.jsx(Ud.Slot,{scope:e.__scopeMenu,children:s.jsx(GN,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:f,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:h=>{o.isUsingKeyboardRef.current&&d.current?.focus(),h.preventDefault()},onCloseAutoFocus:h=>h.preventDefault(),onFocusOutside:Ae(e.onFocusOutside,h=>{h.target!==c.trigger&&i.onOpenChange(!1)}),onEscapeKeyDown:Ae(e.onEscapeKeyDown,h=>{o.onClose(),h.preventDefault()}),onKeyDown:Ae(e.onKeyDown,h=>{const p=h.currentTarget.contains(h.target),y=wfe[o.dir].includes(h.key);p&&y&&(i.onOpenChange(!1),c.trigger?.focus(),h.preventDefault())})})})})})});dF.displayName=uF;function fF(e){return e?"open":"closed"}function hm(e){return e==="indeterminate"}function QN(e){return hm(e)?"indeterminate":e?"checked":"unchecked"}function zfe(e){const t=document.activeElement;for(const n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Ufe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function qfe(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=Ufe(e,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const d=o.find(f=>f.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function Wfe(e,t){const{x:n,y:r}=e;let a=!1;for(let i=0,o=t.length-1;i<t.length;o=i++){const c=t[i],d=t[o],f=c.x,h=c.y,p=d.x,y=d.y;h>r!=y>r&&n<(p-f)*(r-h)/(y-h)+f&&(a=!a)}return a}function Vfe(e,t){if(!t)return!1;const n={x:e.clientX,y:e.clientY};return Wfe(n,t)}function qd(e){return t=>t.pointerType==="mouse"?e(t):void 0}var Hfe=K4,Kfe=VN,Gfe=Y4,Yfe=X4,Xfe=YN,Qfe=Q4,Jfe=Dv,Zfe=Z4,epe=tF,tpe=rF,npe=sF,rpe=iF,ape=oF,spe=cF,ipe=dF,Lv="DropdownMenu",[ope]=ir(Lv,[V4]),Nr=V4(),[lpe,pF]=ope(Lv),hF=e=>{const{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:i,onOpenChange:o,modal:c=!0}=e,d=Nr(t),f=v.useRef(null),[h,p]=na({prop:a,defaultProp:i??!1,onChange:o,caller:Lv});return s.jsx(lpe,{scope:t,triggerId:Hn(),triggerRef:f,contentId:Hn(),open:h,onOpenChange:p,onOpenToggle:v.useCallback(()=>p(y=>!y),[p]),modal:c,children:s.jsx(Hfe,{...d,open:h,onOpenChange:p,dir:r,modal:c,children:n})})};hF.displayName=Lv;var mF="DropdownMenuTrigger",vF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...a}=e,i=pF(mF,n),o=Nr(n);return s.jsx(Kfe,{asChild:!0,...o,children:s.jsx(De.button,{type:"button",id:i.triggerId,"aria-haspopup":"menu","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":i.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...a,ref:jr(t,i.triggerRef),onPointerDown:Ae(e.onPointerDown,c=>{!r&&c.button===0&&c.ctrlKey===!1&&(i.onOpenToggle(),i.open||c.preventDefault())}),onKeyDown:Ae(e.onKeyDown,c=>{r||(["Enter"," "].includes(c.key)&&i.onOpenToggle(),c.key==="ArrowDown"&&i.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(c.key)&&c.preventDefault())})})})});vF.displayName=mF;var cpe="DropdownMenuPortal",gF=e=>{const{__scopeDropdownMenu:t,...n}=e,r=Nr(t);return s.jsx(Gfe,{...r,...n})};gF.displayName=cpe;var yF="DropdownMenuContent",xF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=pF(yF,n),i=Nr(n),o=v.useRef(!1);return s.jsx(Yfe,{id:a.contentId,"aria-labelledby":a.triggerId,...i,...r,ref:t,onCloseAutoFocus:Ae(e.onCloseAutoFocus,c=>{o.current||a.triggerRef.current?.focus(),o.current=!1,c.preventDefault()}),onInteractOutside:Ae(e.onInteractOutside,c=>{const d=c.detail.originalEvent,f=d.button===0&&d.ctrlKey===!0,h=d.button===2||f;(!a.modal||h)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});xF.displayName=yF;var upe="DropdownMenuGroup",dpe=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Xfe,{...a,...r,ref:t})});dpe.displayName=upe;var fpe="DropdownMenuLabel",bF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Qfe,{...a,...r,ref:t})});bF.displayName=fpe;var ppe="DropdownMenuItem",wF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Jfe,{...a,...r,ref:t})});wF.displayName=ppe;var hpe="DropdownMenuCheckboxItem",SF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(Zfe,{...a,...r,ref:t})});SF.displayName=hpe;var mpe="DropdownMenuRadioGroup",vpe=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(epe,{...a,...r,ref:t})});vpe.displayName=mpe;var gpe="DropdownMenuRadioItem",jF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(tpe,{...a,...r,ref:t})});jF.displayName=gpe;var ype="DropdownMenuItemIndicator",NF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(npe,{...a,...r,ref:t})});NF.displayName=ype;var xpe="DropdownMenuSeparator",CF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(rpe,{...a,...r,ref:t})});CF.displayName=xpe;var bpe="DropdownMenuArrow",wpe=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(ape,{...a,...r,ref:t})});wpe.displayName=bpe;var Spe="DropdownMenuSubTrigger",_F=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(spe,{...a,...r,ref:t})});_F.displayName=Spe;var jpe="DropdownMenuSubContent",AF=v.forwardRef((e,t)=>{const{__scopeDropdownMenu:n,...r}=e,a=Nr(n);return s.jsx(ipe,{...a,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});AF.displayName=jpe;var Npe=hF,Cpe=vF,_pe=gF,EF=xF,PF=bF,OF=wF,kF=SF,RF=jF,TF=NF,IF=CF,MF=_F,$F=AF;const Fc=Npe,Bc=Cpe,Ape=v.forwardRef(({className:e,inset:t,children:n,...r},a)=>s.jsxs(MF,{ref:a,className:Se("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent",t&&"pl-8",e),...r,children:[n,s.jsx(ZM,{className:"ml-auto h-4 w-4"})]}));Ape.displayName=MF.displayName;const Epe=v.forwardRef(({className:e,...t},n)=>s.jsx($F,{ref:n,className:Se("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg 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 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",e),...t}));Epe.displayName=$F.displayName;const Wo=v.forwardRef(({className:e,sideOffset:t=4,...n},r)=>s.jsx(_pe,{children:s.jsx(EF,{ref:r,sideOffset:t,className:Se("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 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 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",e),...n})}));Wo.displayName=EF.displayName;const hr=v.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(OF,{ref:r,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",t&&"pl-8",e),...n}));hr.displayName=OF.displayName;const Ppe=v.forwardRef(({className:e,children:t,checked:n,...r},a)=>s.jsxs(kF,{ref:a,className:Se("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),checked:n,...r,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(TF,{children:s.jsx(ql,{className:"h-4 w-4"})})}),t]}));Ppe.displayName=kF.displayName;const Ope=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(RF,{ref:r,className:Se("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(TF,{children:s.jsx(P7,{className:"h-2 w-2 fill-current"})})}),t]}));Ope.displayName=RF.displayName;const JN=v.forwardRef(({className:e,inset:t,...n},r)=>s.jsx(PF,{ref:r,className:Se("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...n}));JN.displayName=PF.displayName;const ZN=v.forwardRef(({className:e,...t},n)=>s.jsx(IF,{ref:n,className:Se("-mx-1 my-1 h-px bg-muted",e),...t}));ZN.displayName=IF.displayName;const Mu=e=>e.configName?.trim()||e.name,kpe=()=>{const{configs:e,deleteConfig:t,cloneConfig:n,loading:r,reload:a}=tf(),i=wa(),[o,c]=v.useState("name"),[d,f]=v.useState("asc"),h=j=>{if(o===j){f(N=>N==="asc"?"desc":"asc");return}c(j),f(j==="updatedAt"?"desc":"asc")};v.useEffect(()=>{a();const j=()=>{a()};return window.addEventListener("focus",j),()=>{window.removeEventListener("focus",j)}},[a]);const p=async(j,N)=>{await t(j),Pe({title:"Deleted",description:`"${N}" has been removed.`})},y=async j=>{const N=await n(j);Pe({title:"Cloned",description:`Created "${Mu(N)}".`}),i(`/mcp-evaluations/${N.id}`)},g=j=>j.agentEntries?.length??j.agents?.length??0,S=j=>j.scenarioEntries?.length??j.scenarios?.length??0,b=v.useMemo(()=>[...e].sort((N,_)=>{let P=0;return o==="name"&&(P=Mu(N).localeCompare(Mu(_))),o==="scenarios"&&(P=S(N)-S(_)),o==="agents"&&(P=g(N)-g(_)),o==="updatedAt"&&(P=new Date(N.updatedAt).getTime()-new Date(_.updatedAt).getTime()),d==="asc"?P:-P}),[e,o,d]),x=j=>o!==j?s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"}):d==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"});return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(n$,{className:"h-6 w-6"}),"MCP Evaluations"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage your MCP evaluation suites"})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(se,{variant:"outline",size:"sm",onClick:()=>{a()},children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{variant:"outline",size:"sm",children:[s.jsx($7,{className:"mr-2 h-4 w-4"}),"Import YAML"]}),s.jsx(se,{size:"sm",asChild:!0,children:s.jsxs(yt,{to:"/mcp-evaluations/new",children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Create New"]})})]})]}),s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("name"),children:["Name",x("name")]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("scenarios"),children:["Scenarios",x("scenarios")]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("agents"),children:["Agents",x("agents")]})}),s.jsx(Qe,{className:"text-right",children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>h("updatedAt"),children:["Last Updated",x("updatedAt")]})}),s.jsx(Qe,{className:"w-10"})]})}),s.jsxs(Jr,{children:[b.map(j=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:s.jsxs("div",{children:[s.jsx(yt,{to:`/mcp-evaluations/${j.id}`,className:"font-medium text-sm hover:text-primary",children:Mu(j)}),j.loadError&&s.jsxs(Ke,{variant:"destructive",className:"ml-2 align-middle text-[10px]",children:[s.jsx(Qp,{className:"mr-1 h-3 w-3"}),"Broken"]}),j.description&&s.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:j.description}),j.loadError&&s.jsx("p",{className:"text-xs text-destructive mt-0.5 break-all",children:j.loadError})]})}),s.jsx(Fe,{className:"text-right font-mono text-sm",children:S(j)}),s.jsx(Fe,{className:"text-right font-mono text-sm",children:g(j)}),s.jsx(Fe,{className:"text-right text-xs text-muted-foreground",children:new Date(j.updatedAt).toLocaleDateString()}),s.jsx(Fe,{children:s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8",children:s.jsx(Cm,{className:"h-4 w-4"})})}),s.jsxs(Wo,{align:"end",children:[s.jsxs(hr,{onClick:()=>i(`/mcp-evaluations/${j.id}`),children:[s.jsx(_m,{className:"mr-2 h-3.5 w-3.5"}),"Edit"]}),s.jsxs(hr,{onClick:()=>{y(j.id)},children:[s.jsx(Ri,{className:"mr-2 h-3.5 w-3.5"}),"Clone"]}),s.jsxs(hr,{children:[s.jsx(ga,{className:"mr-2 h-3.5 w-3.5"}),"Download YAML"]}),s.jsxs(hr,{className:"text-destructive",onClick:()=>{p(j.id,Mu(j))},children:[s.jsx(xa,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]},j.id)),!r&&e.length===0&&s.jsx(Bt,{children:s.jsx(Fe,{colSpan:5,className:"text-center py-12 text-muted-foreground",children:"No MCP evaluations yet. Create your first one to get started."})}),r&&s.jsx(Bt,{children:s.jsx(Fe,{colSpan:5,className:"text-center py-12 text-muted-foreground",children:"Loading MCP evaluations..."})})]})]})})})]})};var Rpe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Tpe=Rpe.reduce((e,t)=>{const n=qm(`Primitive.${t}`),r=v.forwardRef((a,i)=>{const{asChild:o,...c}=a,d=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Ipe="Label",DF=v.forwardRef((e,t)=>s.jsx(Tpe.label,{...e,ref:t,onMouseDown:n=>{n.target.closest("button, input, select, textarea")||(e.onMouseDown?.(n),!n.defaultPrevented&&n.detail>1&&n.preventDefault())}}));DF.displayName=Ipe;var LF=DF;const Mpe=Io("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Me=v.forwardRef(({className:e,...t},n)=>s.jsx(LF,{ref:n,className:Se(Mpe(),e),...t}));Me.displayName=LF.displayName;const Ks=v.forwardRef(({className:e,...t},n)=>s.jsx("textarea",{className:Se("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:n,...t}));Ks.displayName="Textarea";function Fv(e){const t=v.useRef({value:e,previous:e});return v.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Bv="Switch",[$pe]=ir(Bv),[Dpe,Lpe]=$pe(Bv),FF=v.forwardRef((e,t)=>{const{__scopeSwitch:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:d="on",onCheckedChange:f,form:h,...p}=e,[y,g]=v.useState(null),S=ut(t,_=>g(_)),b=v.useRef(!1),x=y?h||!!y.closest("form"):!0,[j,N]=na({prop:a,defaultProp:i??!1,onChange:f,caller:Bv});return s.jsxs(Dpe,{scope:n,checked:j,disabled:c,children:[s.jsx(De.button,{type:"button",role:"switch","aria-checked":j,"aria-required":o,"data-state":qF(j),"data-disabled":c?"":void 0,disabled:c,value:d,...p,ref:S,onClick:Ae(e.onClick,_=>{N(P=>!P),x&&(b.current=_.isPropagationStopped(),b.current||_.stopPropagation())})}),x&&s.jsx(UF,{control:y,bubbles:!b.current,name:r,value:d,checked:j,required:o,disabled:c,form:h,style:{transform:"translateX(-100%)"}})]})});FF.displayName=Bv;var BF="SwitchThumb",zF=v.forwardRef((e,t)=>{const{__scopeSwitch:n,...r}=e,a=Lpe(BF,n);return s.jsx(De.span,{"data-state":qF(a.checked),"data-disabled":a.disabled?"":void 0,...r,ref:t})});zF.displayName=BF;var Fpe="SwitchBubbleInput",UF=v.forwardRef(({__scopeSwitch:e,control:t,checked:n,bubbles:r=!0,...a},i)=>{const o=v.useRef(null),c=ut(o,i),d=Fv(n),f=km(t);return v.useEffect(()=>{const h=o.current;if(!h)return;const p=window.HTMLInputElement.prototype,g=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&g){const S=new Event("click",{bubbles:r});g.call(h,n),h.dispatchEvent(S)}},[d,n,r]),s.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...a,tabIndex:-1,ref:c,style:{...a.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});UF.displayName=Fpe;function qF(e){return e?"checked":"unchecked"}var WF=FF,Bpe=zF;const mm=v.forwardRef(({className:e,...t},n)=>s.jsx(WF,{className:Se("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",e),...t,ref:n,children:s.jsx(Bpe,{className:Se("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));mm.displayName=WF.displayName;var zv="Tabs",[zpe]=ir(zv,[Mv]),VF=Mv(),[Upe,eC]=zpe(zv),HF=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:a,defaultValue:i,orientation:o="horizontal",dir:c,activationMode:d="automatic",...f}=e,h=Lc(c),[p,y]=na({prop:r,onChange:a,defaultProp:i??"",caller:zv});return s.jsx(Upe,{scope:n,baseId:Hn(),value:p,onValueChange:y,orientation:o,dir:h,activationMode:d,children:s.jsx(De.div,{dir:h,"data-orientation":o,...f,ref:t})})});HF.displayName=zv;var KF="TabsList",GF=v.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...a}=e,i=eC(KF,n),o=VF(n);return s.jsx(U4,{asChild:!0,...o,orientation:i.orientation,dir:i.dir,loop:r,children:s.jsx(De.div,{role:"tablist","aria-orientation":i.orientation,...a,ref:t})})});GF.displayName=KF;var YF="TabsTrigger",XF=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:a=!1,...i}=e,o=eC(YF,n),c=VF(n),d=ZF(o.baseId,r),f=eB(o.baseId,r),h=r===o.value;return s.jsx(q4,{asChild:!0,...c,focusable:!a,active:h,children:s.jsx(De.button,{type:"button",role:"tab","aria-selected":h,"aria-controls":f,"data-state":h?"active":"inactive","data-disabled":a?"":void 0,disabled:a,id:d,...i,ref:t,onMouseDown:Ae(e.onMouseDown,p=>{!a&&p.button===0&&p.ctrlKey===!1?o.onValueChange(r):p.preventDefault()}),onKeyDown:Ae(e.onKeyDown,p=>{[" ","Enter"].includes(p.key)&&o.onValueChange(r)}),onFocus:Ae(e.onFocus,()=>{const p=o.activationMode!=="manual";!h&&!a&&p&&o.onValueChange(r)})})})});XF.displayName=YF;var QF="TabsContent",JF=v.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:a,children:i,...o}=e,c=eC(QF,n),d=ZF(c.baseId,r),f=eB(c.baseId,r),h=r===c.value,p=v.useRef(h);return v.useEffect(()=>{const y=requestAnimationFrame(()=>p.current=!1);return()=>cancelAnimationFrame(y)},[]),s.jsx(Gn,{present:a||h,children:({present:y})=>s.jsx(De.div,{"data-state":h?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":d,hidden:!y,id:f,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:p.current?"0s":void 0},children:y&&i})})});JF.displayName=QF;function ZF(e,t){return`${e}-trigger-${t}`}function eB(e,t){return`${e}-content-${t}`}var qpe=HF,tB=GF,nB=XF,rB=JF;const tC=qpe,Uv=v.forwardRef(({className:e,...t},n)=>s.jsx(tB,{ref:n,className:Se("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));Uv.displayName=tB.displayName;const Po=v.forwardRef(({className:e,...t},n)=>s.jsx(nB,{ref:n,className:Se("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",e),...t}));Po.displayName=nB.displayName;const Wd=v.forwardRef(({className:e,...t},n)=>s.jsx(rB,{ref:n,className:Se("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Wd.displayName=rB.displayName;const XI={openai:"bg-emerald-100 text-emerald-800",anthropic:"bg-orange-100 text-orange-800",azure:"bg-blue-100 text-blue-800",google:"bg-yellow-100 text-yellow-800",custom:"bg-gray-100 text-gray-800"};function aB({provider:e}){return s.jsx("span",{className:`inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${XI[e]??XI.custom}`,children:e})}function Vd(e,[t,n]){return Math.min(n,Math.max(t,e))}function Wpe(e){const t=Vpe(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(Kpe);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function Vpe(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=Ype(a),c=Gpe(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Hpe=Symbol("radix.slottable");function Kpe(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Hpe}function Gpe(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function Ype(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xpe=[" ","Enter","ArrowUp","ArrowDown"],Qpe=[" ","Enter"],Oo="Select",[qv,Wv,Jpe]=Hd(Oo),[zc]=ir(Oo,[Jpe,Di]),Vv=Di(),[Zpe,qi]=zc(Oo),[ehe,the]=zc(Oo),sB=e=>{const{__scopeSelect:t,children:n,open:r,defaultOpen:a,onOpenChange:i,value:o,defaultValue:c,onValueChange:d,dir:f,name:h,autoComplete:p,disabled:y,required:g,form:S}=e,b=Vv(t),[x,j]=v.useState(null),[N,_]=v.useState(null),[P,A]=v.useState(!1),O=Lc(f),[k,R]=na({prop:r,defaultProp:a??!1,onChange:i,caller:Oo}),[$,z]=na({prop:o,defaultProp:c,onChange:d,caller:Oo}),B=v.useRef(null),L=x?S||!!x.closest("form"):!0,[K,U]=v.useState(new Set),V=Array.from(K).map(X=>X.props.value).join(";");return s.jsx(Rm,{...b,children:s.jsxs(Zpe,{required:g,scope:t,trigger:x,onTriggerChange:j,valueNode:N,onValueNodeChange:_,valueNodeHasChildren:P,onValueNodeHasChildrenChange:A,contentId:Hn(),value:$,onValueChange:z,open:k,onOpenChange:R,dir:O,triggerPointerDownPosRef:B,disabled:y,children:[s.jsx(qv.Provider,{scope:t,children:s.jsx(ehe,{scope:e.__scopeSelect,onNativeOptionAdd:v.useCallback(X=>{U(J=>new Set(J).add(X))},[]),onNativeOptionRemove:v.useCallback(X=>{U(J=>{const T=new Set(J);return T.delete(X),T})},[]),children:n})}),L?s.jsxs(PB,{"aria-hidden":!0,required:g,tabIndex:-1,name:h,autoComplete:p,value:$,onChange:X=>z(X.target.value),disabled:y,form:S,children:[$===void 0?s.jsx("option",{value:""}):null,Array.from(K)]},V):null]})})};sB.displayName=Oo;var iB="SelectTrigger",oB=v.forwardRef((e,t)=>{const{__scopeSelect:n,disabled:r=!1,...a}=e,i=Vv(n),o=qi(iB,n),c=o.disabled||r,d=ut(t,o.onTriggerChange),f=Wv(n),h=v.useRef("touch"),[p,y,g]=kB(b=>{const x=f().filter(_=>!_.disabled),j=x.find(_=>_.value===o.value),N=RB(x,b,j);N!==void 0&&o.onValueChange(N.value)}),S=b=>{c||(o.onOpenChange(!0),g()),b&&(o.triggerPointerDownPosRef.current={x:Math.round(b.pageX),y:Math.round(b.pageY)})};return s.jsx(Yd,{asChild:!0,...i,children:s.jsx(De.button,{type:"button",role:"combobox","aria-controls":o.contentId,"aria-expanded":o.open,"aria-required":o.required,"aria-autocomplete":"none",dir:o.dir,"data-state":o.open?"open":"closed",disabled:c,"data-disabled":c?"":void 0,"data-placeholder":OB(o.value)?"":void 0,...a,ref:d,onClick:Ae(a.onClick,b=>{b.currentTarget.focus(),h.current!=="mouse"&&S(b)}),onPointerDown:Ae(a.onPointerDown,b=>{h.current=b.pointerType;const x=b.target;x.hasPointerCapture(b.pointerId)&&x.releasePointerCapture(b.pointerId),b.button===0&&b.ctrlKey===!1&&b.pointerType==="mouse"&&(S(b),b.preventDefault())}),onKeyDown:Ae(a.onKeyDown,b=>{const x=p.current!=="";!(b.ctrlKey||b.altKey||b.metaKey)&&b.key.length===1&&y(b.key),!(x&&b.key===" ")&&Xpe.includes(b.key)&&(S(),b.preventDefault())})})})});oB.displayName=iB;var lB="SelectValue",cB=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,children:i,placeholder:o="",...c}=e,d=qi(lB,n),{onValueNodeHasChildrenChange:f}=d,h=i!==void 0,p=ut(t,d.onValueNodeChange);return Kn(()=>{f(h)},[f,h]),s.jsx(De.span,{...c,ref:p,style:{pointerEvents:"none"},children:OB(d.value)?s.jsx(s.Fragment,{children:o}):i})});cB.displayName=lB;var nhe="SelectIcon",uB=v.forwardRef((e,t)=>{const{__scopeSelect:n,children:r,...a}=e;return s.jsx(De.span,{"aria-hidden":!0,...a,ref:t,children:r||"▼"})});uB.displayName=nhe;var rhe="SelectPortal",dB=e=>s.jsx(Sc,{asChild:!0,...e});dB.displayName=rhe;var ko="SelectContent",fB=v.forwardRef((e,t)=>{const n=qi(ko,e.__scopeSelect),[r,a]=v.useState();if(Kn(()=>{a(new DocumentFragment)},[]),!n.open){const i=r;return i?wc.createPortal(s.jsx(pB,{scope:e.__scopeSelect,children:s.jsx(qv.Slot,{scope:e.__scopeSelect,children:s.jsx("div",{children:e.children})})}),i):null}return s.jsx(hB,{...e,ref:t})});fB.displayName=ko;var Ia=10,[pB,Wi]=zc(ko),ahe="SelectContentImpl",she=Wpe("SelectContent.RemoveScroll"),hB=v.forwardRef((e,t)=>{const{__scopeSelect:n,position:r="item-aligned",onCloseAutoFocus:a,onEscapeKeyDown:i,onPointerDownOutside:o,side:c,sideOffset:d,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:g,sticky:S,hideWhenDetached:b,avoidCollisions:x,...j}=e,N=qi(ko,n),[_,P]=v.useState(null),[A,O]=v.useState(null),k=ut(t,ae=>P(ae)),[R,$]=v.useState(null),[z,B]=v.useState(null),L=Wv(n),[K,U]=v.useState(!1),V=v.useRef(!1);v.useEffect(()=>{if(_)return Hm(_)},[_]),Wm();const X=v.useCallback(ae=>{const[ue,...ie]=L().map(oe=>oe.ref.current),[ve]=ie.slice(-1),Oe=document.activeElement;for(const oe of ae)if(oe===Oe||(oe?.scrollIntoView({block:"nearest"}),oe===ue&&A&&(A.scrollTop=0),oe===ve&&A&&(A.scrollTop=A.scrollHeight),oe?.focus(),document.activeElement!==Oe))return},[L,A]),J=v.useCallback(()=>X([R,_]),[X,R,_]);v.useEffect(()=>{K&&J()},[K,J]);const{onOpenChange:T,triggerPointerDownPosRef:D}=N;v.useEffect(()=>{if(_){let ae={x:0,y:0};const ue=ve=>{ae={x:Math.abs(Math.round(ve.pageX)-(D.current?.x??0)),y:Math.abs(Math.round(ve.pageY)-(D.current?.y??0))}},ie=ve=>{ae.x<=10&&ae.y<=10?ve.preventDefault():_.contains(ve.target)||T(!1),document.removeEventListener("pointermove",ue),D.current=null};return D.current!==null&&(document.addEventListener("pointermove",ue),document.addEventListener("pointerup",ie,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ue),document.removeEventListener("pointerup",ie,{capture:!0})}}},[_,T,D]),v.useEffect(()=>{const ae=()=>T(!1);return window.addEventListener("blur",ae),window.addEventListener("resize",ae),()=>{window.removeEventListener("blur",ae),window.removeEventListener("resize",ae)}},[T]);const[Q,F]=kB(ae=>{const ue=L().filter(Oe=>!Oe.disabled),ie=ue.find(Oe=>Oe.ref.current===document.activeElement),ve=RB(ue,ae,ie);ve&&setTimeout(()=>ve.ref.current.focus())}),M=v.useCallback((ae,ue,ie)=>{const ve=!V.current&&!ie;(N.value!==void 0&&N.value===ue||ve)&&($(ae),ve&&(V.current=!0))},[N.value]),ee=v.useCallback(()=>_?.focus(),[_]),W=v.useCallback((ae,ue,ie)=>{const ve=!V.current&&!ie;(N.value!==void 0&&N.value===ue||ve)&&B(ae)},[N.value]),Z=r==="popper"?nj:mB,ye=Z===nj?{side:c,sideOffset:d,align:f,alignOffset:h,arrowPadding:p,collisionBoundary:y,collisionPadding:g,sticky:S,hideWhenDetached:b,avoidCollisions:x}:{};return s.jsx(pB,{scope:n,content:_,viewport:A,onViewportChange:O,itemRefCallback:M,selectedItem:R,onItemLeave:ee,itemTextRefCallback:W,focusSelectedItem:J,selectedItemText:z,position:r,isPositioned:K,searchRef:Q,children:s.jsx(Qd,{as:she,allowPinchZoom:!0,children:s.jsx(Xd,{asChild:!0,trapped:N.open,onMountAutoFocus:ae=>{ae.preventDefault()},onUnmountAutoFocus:Ae(a,ae=>{N.trigger?.focus({preventScroll:!0}),ae.preventDefault()}),children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:i,onPointerDownOutside:o,onFocusOutside:ae=>ae.preventDefault(),onDismiss:()=>N.onOpenChange(!1),children:s.jsx(Z,{role:"listbox",id:N.contentId,"data-state":N.open?"open":"closed",dir:N.dir,onContextMenu:ae=>ae.preventDefault(),...j,...ye,onPlaced:()=>U(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...j.style},onKeyDown:Ae(j.onKeyDown,ae=>{const ue=ae.ctrlKey||ae.altKey||ae.metaKey;if(ae.key==="Tab"&&ae.preventDefault(),!ue&&ae.key.length===1&&F(ae.key),["ArrowUp","ArrowDown","Home","End"].includes(ae.key)){let ve=L().filter(Oe=>!Oe.disabled).map(Oe=>Oe.ref.current);if(["ArrowUp","End"].includes(ae.key)&&(ve=ve.slice().reverse()),["ArrowUp","ArrowDown"].includes(ae.key)){const Oe=ae.target,oe=ve.indexOf(Oe);ve=ve.slice(oe+1)}setTimeout(()=>X(ve)),ae.preventDefault()}})})})})})})});hB.displayName=ahe;var ihe="SelectItemAlignedPosition",mB=v.forwardRef((e,t)=>{const{__scopeSelect:n,onPlaced:r,...a}=e,i=qi(ko,n),o=Wi(ko,n),[c,d]=v.useState(null),[f,h]=v.useState(null),p=ut(t,k=>h(k)),y=Wv(n),g=v.useRef(!1),S=v.useRef(!0),{viewport:b,selectedItem:x,selectedItemText:j,focusSelectedItem:N}=o,_=v.useCallback(()=>{if(i.trigger&&i.valueNode&&c&&f&&b&&x&&j){const k=i.trigger.getBoundingClientRect(),R=f.getBoundingClientRect(),$=i.valueNode.getBoundingClientRect(),z=j.getBoundingClientRect();if(i.dir!=="rtl"){const Oe=z.left-R.left,oe=$.left-Oe,he=k.left-oe,xe=k.width+he,Ie=Math.max(xe,R.width),re=window.innerWidth-Ia,me=Vd(oe,[Ia,Math.max(Ia,re-Ie)]);c.style.minWidth=xe+"px",c.style.left=me+"px"}else{const Oe=R.right-z.right,oe=window.innerWidth-$.right-Oe,he=window.innerWidth-k.right-oe,xe=k.width+he,Ie=Math.max(xe,R.width),re=window.innerWidth-Ia,me=Vd(oe,[Ia,Math.max(Ia,re-Ie)]);c.style.minWidth=xe+"px",c.style.right=me+"px"}const B=y(),L=window.innerHeight-Ia*2,K=b.scrollHeight,U=window.getComputedStyle(f),V=parseInt(U.borderTopWidth,10),X=parseInt(U.paddingTop,10),J=parseInt(U.borderBottomWidth,10),T=parseInt(U.paddingBottom,10),D=V+X+K+T+J,Q=Math.min(x.offsetHeight*5,D),F=window.getComputedStyle(b),M=parseInt(F.paddingTop,10),ee=parseInt(F.paddingBottom,10),W=k.top+k.height/2-Ia,Z=L-W,ye=x.offsetHeight/2,ae=x.offsetTop+ye,ue=V+X+ae,ie=D-ue;if(ue<=W){const Oe=B.length>0&&x===B[B.length-1].ref.current;c.style.bottom="0px";const oe=f.clientHeight-b.offsetTop-b.offsetHeight,he=Math.max(Z,ye+(Oe?ee:0)+oe+J),xe=ue+he;c.style.height=xe+"px"}else{const Oe=B.length>0&&x===B[0].ref.current;c.style.top="0px";const he=Math.max(W,V+b.offsetTop+(Oe?M:0)+ye)+ie;c.style.height=he+"px",b.scrollTop=ue-W+b.offsetTop}c.style.margin=`${Ia}px 0`,c.style.minHeight=Q+"px",c.style.maxHeight=L+"px",r?.(),requestAnimationFrame(()=>g.current=!0)}},[y,i.trigger,i.valueNode,c,f,b,x,j,i.dir,r]);Kn(()=>_(),[_]);const[P,A]=v.useState();Kn(()=>{f&&A(window.getComputedStyle(f).zIndex)},[f]);const O=v.useCallback(k=>{k&&S.current===!0&&(_(),N?.(),S.current=!1)},[_,N]);return s.jsx(lhe,{scope:n,contentWrapper:c,shouldExpandOnScrollRef:g,onScrollButtonChange:O,children:s.jsx("div",{ref:d,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:P},children:s.jsx(De.div,{...a,ref:p,style:{boxSizing:"border-box",maxHeight:"100%",...a.style}})})})});mB.displayName=ihe;var ohe="SelectPopperPosition",nj=v.forwardRef((e,t)=>{const{__scopeSelect:n,align:r="start",collisionPadding:a=Ia,...i}=e,o=Vv(n);return s.jsx(Tm,{...o,...i,ref:t,align:r,collisionPadding:a,style:{boxSizing:"border-box",...i.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});nj.displayName=ohe;var[lhe,nC]=zc(ko,{}),rj="SelectViewport",vB=v.forwardRef((e,t)=>{const{__scopeSelect:n,nonce:r,...a}=e,i=Wi(rj,n),o=nC(rj,n),c=ut(t,i.onViewportChange),d=v.useRef(0);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:r}),s.jsx(qv.Slot,{scope:n,children:s.jsx(De.div,{"data-radix-select-viewport":"",role:"presentation",...a,ref:c,style:{position:"relative",flex:1,overflow:"hidden auto",...a.style},onScroll:Ae(a.onScroll,f=>{const h=f.currentTarget,{contentWrapper:p,shouldExpandOnScrollRef:y}=o;if(y?.current&&p){const g=Math.abs(d.current-h.scrollTop);if(g>0){const S=window.innerHeight-Ia*2,b=parseFloat(p.style.minHeight),x=parseFloat(p.style.height),j=Math.max(b,x);if(j<S){const N=j+g,_=Math.min(S,N),P=N-_;p.style.height=_+"px",p.style.bottom==="0px"&&(h.scrollTop=P>0?P:0,p.style.justifyContent="flex-end")}}}d.current=h.scrollTop})})})]})});vB.displayName=rj;var gB="SelectGroup",[che,uhe]=zc(gB),dhe=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=Hn();return s.jsx(che,{scope:n,id:a,children:s.jsx(De.div,{role:"group","aria-labelledby":a,...r,ref:t})})});dhe.displayName=gB;var yB="SelectLabel",xB=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=uhe(yB,n);return s.jsx(De.div,{id:a.id,...r,ref:t})});xB.displayName=yB;var vm="SelectItem",[fhe,bB]=zc(vm),wB=v.forwardRef((e,t)=>{const{__scopeSelect:n,value:r,disabled:a=!1,textValue:i,...o}=e,c=qi(vm,n),d=Wi(vm,n),f=c.value===r,[h,p]=v.useState(i??""),[y,g]=v.useState(!1),S=ut(t,N=>d.itemRefCallback?.(N,r,a)),b=Hn(),x=v.useRef("touch"),j=()=>{a||(c.onValueChange(r),c.onOpenChange(!1))};if(r==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return s.jsx(fhe,{scope:n,value:r,disabled:a,textId:b,isSelected:f,onItemTextChange:v.useCallback(N=>{p(_=>_||(N?.textContent??"").trim())},[]),children:s.jsx(qv.ItemSlot,{scope:n,value:r,disabled:a,textValue:h,children:s.jsx(De.div,{role:"option","aria-labelledby":b,"data-highlighted":y?"":void 0,"aria-selected":f&&y,"data-state":f?"checked":"unchecked","aria-disabled":a||void 0,"data-disabled":a?"":void 0,tabIndex:a?void 0:-1,...o,ref:S,onFocus:Ae(o.onFocus,()=>g(!0)),onBlur:Ae(o.onBlur,()=>g(!1)),onClick:Ae(o.onClick,()=>{x.current!=="mouse"&&j()}),onPointerUp:Ae(o.onPointerUp,()=>{x.current==="mouse"&&j()}),onPointerDown:Ae(o.onPointerDown,N=>{x.current=N.pointerType}),onPointerMove:Ae(o.onPointerMove,N=>{x.current=N.pointerType,a?d.onItemLeave?.():x.current==="mouse"&&N.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Ae(o.onPointerLeave,N=>{N.currentTarget===document.activeElement&&d.onItemLeave?.()}),onKeyDown:Ae(o.onKeyDown,N=>{d.searchRef?.current!==""&&N.key===" "||(Qpe.includes(N.key)&&j(),N.key===" "&&N.preventDefault())})})})})});wB.displayName=vm;var qu="SelectItemText",SB=v.forwardRef((e,t)=>{const{__scopeSelect:n,className:r,style:a,...i}=e,o=qi(qu,n),c=Wi(qu,n),d=bB(qu,n),f=the(qu,n),[h,p]=v.useState(null),y=ut(t,j=>p(j),d.onItemTextChange,j=>c.itemTextRefCallback?.(j,d.value,d.disabled)),g=h?.textContent,S=v.useMemo(()=>s.jsx("option",{value:d.value,disabled:d.disabled,children:g},d.value),[d.disabled,d.value,g]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=f;return Kn(()=>(b(S),()=>x(S)),[b,x,S]),s.jsxs(s.Fragment,{children:[s.jsx(De.span,{id:d.textId,...i,ref:y}),d.isSelected&&o.valueNode&&!o.valueNodeHasChildren?wc.createPortal(i.children,o.valueNode):null]})});SB.displayName=qu;var jB="SelectItemIndicator",NB=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return bB(jB,n).isSelected?s.jsx(De.span,{"aria-hidden":!0,...r,ref:t}):null});NB.displayName=jB;var aj="SelectScrollUpButton",CB=v.forwardRef((e,t)=>{const n=Wi(aj,e.__scopeSelect),r=nC(aj,e.__scopeSelect),[a,i]=v.useState(!1),o=ut(t,r.onScrollButtonChange);return Kn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollTop>0;i(f)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?s.jsx(AB,{...e,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop-d.offsetHeight)}}):null});CB.displayName=aj;var sj="SelectScrollDownButton",_B=v.forwardRef((e,t)=>{const n=Wi(sj,e.__scopeSelect),r=nC(sj,e.__scopeSelect),[a,i]=v.useState(!1),o=ut(t,r.onScrollButtonChange);return Kn(()=>{if(n.viewport&&n.isPositioned){let c=function(){const f=d.scrollHeight-d.clientHeight,h=Math.ceil(d.scrollTop)<f;i(h)};const d=n.viewport;return c(),d.addEventListener("scroll",c),()=>d.removeEventListener("scroll",c)}},[n.viewport,n.isPositioned]),a?s.jsx(AB,{...e,ref:o,onAutoScroll:()=>{const{viewport:c,selectedItem:d}=n;c&&d&&(c.scrollTop=c.scrollTop+d.offsetHeight)}}):null});_B.displayName=sj;var AB=v.forwardRef((e,t)=>{const{__scopeSelect:n,onAutoScroll:r,...a}=e,i=Wi("SelectScrollButton",n),o=v.useRef(null),c=Wv(n),d=v.useCallback(()=>{o.current!==null&&(window.clearInterval(o.current),o.current=null)},[]);return v.useEffect(()=>()=>d(),[d]),Kn(()=>{c().find(h=>h.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:"nearest"})},[c]),s.jsx(De.div,{"aria-hidden":!0,...a,ref:t,style:{flexShrink:0,...a.style},onPointerDown:Ae(a.onPointerDown,()=>{o.current===null&&(o.current=window.setInterval(r,50))}),onPointerMove:Ae(a.onPointerMove,()=>{i.onItemLeave?.(),o.current===null&&(o.current=window.setInterval(r,50))}),onPointerLeave:Ae(a.onPointerLeave,()=>{d()})})}),phe="SelectSeparator",EB=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e;return s.jsx(De.div,{"aria-hidden":!0,...r,ref:t})});EB.displayName=phe;var ij="SelectArrow",hhe=v.forwardRef((e,t)=>{const{__scopeSelect:n,...r}=e,a=Vv(n),i=qi(ij,n),o=Wi(ij,n);return i.open&&o.position==="popper"?s.jsx(Im,{...a,...r,ref:t}):null});hhe.displayName=ij;var mhe="SelectBubbleInput",PB=v.forwardRef(({__scopeSelect:e,value:t,...n},r)=>{const a=v.useRef(null),i=ut(r,a),o=Fv(t);return v.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLSelectElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(o!==t&&h){const p=new Event("change",{bubbles:!0});h.call(c,t),c.dispatchEvent(p)}},[o,t]),s.jsx(De.select,{...n,style:{...OM,...n.style},ref:i,defaultValue:t})});PB.displayName=mhe;function OB(e){return e===""||e===void 0}function kB(e){const t=Pn(e),n=v.useRef(""),r=v.useRef(0),a=v.useCallback(o=>{const c=n.current+o;t(c),(function d(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>d(""),1e3))})(c)},[t]),i=v.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,a,i]}function RB(e,t,n){const a=t.length>1&&Array.from(t).every(f=>f===t[0])?t[0]:t,i=n?e.indexOf(n):-1;let o=vhe(e,Math.max(i,0));a.length===1&&(o=o.filter(f=>f!==n));const d=o.find(f=>f.textValue.toLowerCase().startsWith(a.toLowerCase()));return d!==n?d:void 0}function vhe(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var ghe=sB,TB=oB,yhe=cB,xhe=uB,bhe=dB,IB=fB,whe=vB,MB=xB,$B=wB,She=SB,jhe=NB,DB=CB,LB=_B,FB=EB;const sn=ghe,on=yhe,Jt=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(TB,{ref:r,className:Se("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...n,children:[t,s.jsx(xhe,{asChild:!0,children:s.jsx(qt,{className:"h-4 w-4 opacity-50"})})]}));Jt.displayName=TB.displayName;const BB=v.forwardRef(({className:e,...t},n)=>s.jsx(DB,{ref:n,className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(is,{className:"h-4 w-4"})}));BB.displayName=DB.displayName;const zB=v.forwardRef(({className:e,...t},n)=>s.jsx(LB,{ref:n,className:Se("flex cursor-default items-center justify-center py-1",e),...t,children:s.jsx(qt,{className:"h-4 w-4"})}));zB.displayName=LB.displayName;const Zt=v.forwardRef(({className:e,children:t,position:n="popper",...r},a)=>s.jsx(bhe,{children:s.jsxs(IB,{ref:a,className:Se("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md 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 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",n==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:n,...r,children:[s.jsx(BB,{}),s.jsx(whe,{className:Se("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:t}),s.jsx(zB,{})]})}));Zt.displayName=IB.displayName;const Nhe=v.forwardRef(({className:e,...t},n)=>s.jsx(MB,{ref:n,className:Se("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...t}));Nhe.displayName=MB.displayName;const at=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs($B,{ref:r,className:Se("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground",e),...n,children:[s.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:s.jsx(jhe,{children:s.jsx(ql,{className:"h-4 w-4"})})}),s.jsx(She,{children:t})]}));at.displayName=$B.displayName;const Che=v.forwardRef(({className:e,...t},n)=>s.jsx(FB,{ref:n,className:Se("-mx-1 my-1 h-px bg-muted",e),...t}));Che.displayName=FB.displayName;var Hv="Collapsible",[_he]=ir(Hv),[Ahe,rC]=_he(Hv),UB=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:a,disabled:i,onOpenChange:o,...c}=e,[d,f]=na({prop:r,defaultProp:a??!1,onChange:o,caller:Hv});return s.jsx(Ahe,{scope:n,disabled:i,contentId:Hn(),open:d,onOpenToggle:v.useCallback(()=>f(h=>!h),[f]),children:s.jsx(De.div,{"data-state":sC(d),"data-disabled":i?"":void 0,...c,ref:t})})});UB.displayName=Hv;var qB="CollapsibleTrigger",WB=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,a=rC(qB,n);return s.jsx(De.button,{type:"button","aria-controls":a.contentId,"aria-expanded":a.open||!1,"data-state":sC(a.open),"data-disabled":a.disabled?"":void 0,disabled:a.disabled,...r,ref:t,onClick:Ae(e.onClick,a.onOpenToggle)})});WB.displayName=qB;var aC="CollapsibleContent",VB=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=rC(aC,e.__scopeCollapsible);return s.jsx(Gn,{present:n||a.open,children:({present:i})=>s.jsx(Ehe,{...r,ref:t,present:i})})});VB.displayName=aC;var Ehe=v.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:a,...i}=e,o=rC(aC,n),[c,d]=v.useState(r),f=v.useRef(null),h=ut(t,f),p=v.useRef(0),y=p.current,g=v.useRef(0),S=g.current,b=o.open||c,x=v.useRef(b),j=v.useRef(void 0);return v.useEffect(()=>{const N=requestAnimationFrame(()=>x.current=!1);return()=>cancelAnimationFrame(N)},[]),Kn(()=>{const N=f.current;if(N){j.current=j.current||{transitionDuration:N.style.transitionDuration,animationName:N.style.animationName},N.style.transitionDuration="0s",N.style.animationName="none";const _=N.getBoundingClientRect();p.current=_.height,g.current=_.width,x.current||(N.style.transitionDuration=j.current.transitionDuration,N.style.animationName=j.current.animationName),d(r)}},[o.open,r]),s.jsx(De.div,{"data-state":sC(o.open),"data-disabled":o.disabled?"":void 0,id:o.contentId,hidden:!b,...i,ref:h,style:{"--radix-collapsible-content-height":y?`${y}px`:void 0,"--radix-collapsible-content-width":S?`${S}px`:void 0,...e.style},children:b&&a})});function sC(e){return e?"open":"closed"}var Phe=UB;const Ci=Phe,Rs=WB,_i=VB,Ohe=Gm,khe=Ym,HB=v.forwardRef(({className:e,...t},n)=>s.jsx(Pc,{ref:n,className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));HB.displayName=Pc.displayName;const KB=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(khe,{children:[s.jsx(HB,{}),s.jsxs(Oc,{ref:r,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...n,children:[t,s.jsxs(Xm,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity data-[state=open]:bg-accent data-[state=open]:text-muted-foreground hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none",children:[s.jsx(Ti,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));KB.displayName=Oc.displayName;const GB=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col space-y-1.5 text-center sm:text-left",e),...t});GB.displayName="DialogHeader";const YB=v.forwardRef(({className:e,...t},n)=>s.jsx(Jd,{ref:n,className:Se("text-lg font-semibold leading-none tracking-tight",e),...t}));YB.displayName=Jd.displayName;const XB=v.forwardRef(({className:e,...t},n)=>s.jsx(Zd,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));XB.displayName=Zd.displayName;function Rhe(e,t){return v.useReducer((n,r)=>t[n][r]??n,e)}var iC="ScrollArea",[QB]=ir(iC),[The,ja]=QB(iC),JB=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:a,scrollHideDelay:i=600,...o}=e,[c,d]=v.useState(null),[f,h]=v.useState(null),[p,y]=v.useState(null),[g,S]=v.useState(null),[b,x]=v.useState(null),[j,N]=v.useState(0),[_,P]=v.useState(0),[A,O]=v.useState(!1),[k,R]=v.useState(!1),$=ut(t,B=>d(B)),z=Lc(a);return s.jsx(The,{scope:n,type:r,dir:z,scrollHideDelay:i,scrollArea:c,viewport:f,onViewportChange:h,content:p,onContentChange:y,scrollbarX:g,onScrollbarXChange:S,scrollbarXEnabled:A,onScrollbarXEnabledChange:O,scrollbarY:b,onScrollbarYChange:x,scrollbarYEnabled:k,onScrollbarYEnabledChange:R,onCornerWidthChange:N,onCornerHeightChange:P,children:s.jsx(De.div,{dir:z,...o,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})});JB.displayName=iC;var ZB="ScrollAreaViewport",e8=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:a,...i}=e,o=ja(ZB,n),c=v.useRef(null),d=ut(t,c,o.onViewportChange);return s.jsxs(s.Fragment,{children:[s.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),s.jsx(De.div,{"data-radix-scroll-area-viewport":"",...i,ref:d,style:{overflowX:o.scrollbarXEnabled?"scroll":"hidden",overflowY:o.scrollbarYEnabled?"scroll":"hidden",...e.style},children:s.jsx("div",{ref:o.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})});e8.displayName=ZB;var xs="ScrollAreaScrollbar",oC=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=ja(xs,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:o}=a,c=e.orientation==="horizontal";return v.useEffect(()=>(c?i(!0):o(!0),()=>{c?i(!1):o(!1)}),[c,i,o]),a.type==="hover"?s.jsx(Ihe,{...r,ref:t,forceMount:n}):a.type==="scroll"?s.jsx(Mhe,{...r,ref:t,forceMount:n}):a.type==="auto"?s.jsx(t8,{...r,ref:t,forceMount:n}):a.type==="always"?s.jsx(lC,{...r,ref:t}):null});oC.displayName=xs;var Ihe=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=ja(xs,e.__scopeScrollArea),[i,o]=v.useState(!1);return v.useEffect(()=>{const c=a.scrollArea;let d=0;if(c){const f=()=>{window.clearTimeout(d),o(!0)},h=()=>{d=window.setTimeout(()=>o(!1),a.scrollHideDelay)};return c.addEventListener("pointerenter",f),c.addEventListener("pointerleave",h),()=>{window.clearTimeout(d),c.removeEventListener("pointerenter",f),c.removeEventListener("pointerleave",h)}}},[a.scrollArea,a.scrollHideDelay]),s.jsx(Gn,{present:n||i,children:s.jsx(t8,{"data-state":i?"visible":"hidden",...r,ref:t})})}),Mhe=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=ja(xs,e.__scopeScrollArea),i=e.orientation==="horizontal",o=Gv(()=>d("SCROLL_END"),100),[c,d]=Rhe("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return v.useEffect(()=>{if(c==="idle"){const f=window.setTimeout(()=>d("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(f)}},[c,a.scrollHideDelay,d]),v.useEffect(()=>{const f=a.viewport,h=i?"scrollLeft":"scrollTop";if(f){let p=f[h];const y=()=>{const g=f[h];p!==g&&(d("SCROLL"),o()),p=g};return f.addEventListener("scroll",y),()=>f.removeEventListener("scroll",y)}},[a.viewport,i,d,o]),s.jsx(Gn,{present:n||c!=="hidden",children:s.jsx(lC,{"data-state":c==="hidden"?"hidden":"visible",...r,ref:t,onPointerEnter:Ae(e.onPointerEnter,()=>d("POINTER_ENTER")),onPointerLeave:Ae(e.onPointerLeave,()=>d("POINTER_LEAVE"))})})}),t8=v.forwardRef((e,t)=>{const n=ja(xs,e.__scopeScrollArea),{forceMount:r,...a}=e,[i,o]=v.useState(!1),c=e.orientation==="horizontal",d=Gv(()=>{if(n.viewport){const f=n.viewport.offsetWidth<n.viewport.scrollWidth,h=n.viewport.offsetHeight<n.viewport.scrollHeight;o(c?f:h)}},10);return xc(n.viewport,d),xc(n.content,d),s.jsx(Gn,{present:r||i,children:s.jsx(lC,{"data-state":i?"visible":"hidden",...a,ref:t})})}),lC=v.forwardRef((e,t)=>{const{orientation:n="vertical",...r}=e,a=ja(xs,e.__scopeScrollArea),i=v.useRef(null),o=v.useRef(0),[c,d]=v.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),f=i8(c.viewport,c.content),h={...r,sizes:c,onSizesChange:d,hasThumb:f>0&&f<1,onThumbChange:y=>i.current=y,onThumbPointerUp:()=>o.current=0,onThumbPointerDown:y=>o.current=y};function p(y,g){return zhe(y,o.current,c,g)}return n==="horizontal"?s.jsx($he,{...h,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const y=a.viewport.scrollLeft,g=QI(y,c,a.dir);i.current.style.transform=`translate3d(${g}px, 0, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollLeft=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollLeft=p(y,a.dir))}}):n==="vertical"?s.jsx(Dhe,{...h,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const y=a.viewport.scrollTop,g=QI(y,c);i.current.style.transform=`translate3d(0, ${g}px, 0)`}},onWheelScroll:y=>{a.viewport&&(a.viewport.scrollTop=y)},onDragScroll:y=>{a.viewport&&(a.viewport.scrollTop=p(y))}}):null}),$he=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,i=ja(xs,e.__scopeScrollArea),[o,c]=v.useState(),d=v.useRef(null),f=ut(t,d,i.onScrollbarXChange);return v.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(r8,{"data-orientation":"horizontal",...a,ref:f,sizes:n,style:{bottom:0,left:i.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:i.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":Kv(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.x),onDragScroll:h=>e.onDragScroll(h.x),onWheelScroll:(h,p)=>{if(i.viewport){const y=i.viewport.scrollLeft+h.deltaX;e.onWheelScroll(y),l8(y,p)&&h.preventDefault()}},onResize:()=>{d.current&&i.viewport&&o&&r({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:d.current.clientWidth,paddingStart:ym(o.paddingLeft),paddingEnd:ym(o.paddingRight)}})}})}),Dhe=v.forwardRef((e,t)=>{const{sizes:n,onSizesChange:r,...a}=e,i=ja(xs,e.__scopeScrollArea),[o,c]=v.useState(),d=v.useRef(null),f=ut(t,d,i.onScrollbarYChange);return v.useEffect(()=>{d.current&&c(getComputedStyle(d.current))},[d]),s.jsx(r8,{"data-orientation":"vertical",...a,ref:f,sizes:n,style:{top:0,right:i.dir==="ltr"?0:void 0,left:i.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":Kv(n)+"px",...e.style},onThumbPointerDown:h=>e.onThumbPointerDown(h.y),onDragScroll:h=>e.onDragScroll(h.y),onWheelScroll:(h,p)=>{if(i.viewport){const y=i.viewport.scrollTop+h.deltaY;e.onWheelScroll(y),l8(y,p)&&h.preventDefault()}},onResize:()=>{d.current&&i.viewport&&o&&r({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:d.current.clientHeight,paddingStart:ym(o.paddingTop),paddingEnd:ym(o.paddingBottom)}})}})}),[Lhe,n8]=QB(xs),r8=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:a,onThumbChange:i,onThumbPointerUp:o,onThumbPointerDown:c,onThumbPositionChange:d,onDragScroll:f,onWheelScroll:h,onResize:p,...y}=e,g=ja(xs,n),[S,b]=v.useState(null),x=ut(t,$=>b($)),j=v.useRef(null),N=v.useRef(""),_=g.viewport,P=r.content-r.viewport,A=Pn(h),O=Pn(d),k=Gv(p,10);function R($){if(j.current){const z=$.clientX-j.current.left,B=$.clientY-j.current.top;f({x:z,y:B})}}return v.useEffect(()=>{const $=z=>{const B=z.target;S?.contains(B)&&A(z,P)};return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[_,S,P,A]),v.useEffect(O,[r,O]),xc(S,k),xc(g.content,k),s.jsx(Lhe,{scope:n,scrollbar:S,hasThumb:a,onThumbChange:Pn(i),onThumbPointerUp:Pn(o),onThumbPositionChange:O,onThumbPointerDown:Pn(c),children:s.jsx(De.div,{...y,ref:x,style:{position:"absolute",...y.style},onPointerDown:Ae(e.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),j.current=S.getBoundingClientRect(),N.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",g.viewport&&(g.viewport.style.scrollBehavior="auto"),R($))}),onPointerMove:Ae(e.onPointerMove,R),onPointerUp:Ae(e.onPointerUp,$=>{const z=$.target;z.hasPointerCapture($.pointerId)&&z.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=N.current,g.viewport&&(g.viewport.style.scrollBehavior=""),j.current=null})})})}),gm="ScrollAreaThumb",a8=v.forwardRef((e,t)=>{const{forceMount:n,...r}=e,a=n8(gm,e.__scopeScrollArea);return s.jsx(Gn,{present:n||a.hasThumb,children:s.jsx(Fhe,{ref:t,...r})})}),Fhe=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,style:r,...a}=e,i=ja(gm,n),o=n8(gm,n),{onThumbPositionChange:c}=o,d=ut(t,p=>o.onThumbChange(p)),f=v.useRef(void 0),h=Gv(()=>{f.current&&(f.current(),f.current=void 0)},100);return v.useEffect(()=>{const p=i.viewport;if(p){const y=()=>{if(h(),!f.current){const g=Uhe(p,c);f.current=g,c()}};return c(),p.addEventListener("scroll",y),()=>p.removeEventListener("scroll",y)}},[i.viewport,h,c]),s.jsx(De.div,{"data-state":o.hasThumb?"visible":"hidden",...a,ref:d,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Ae(e.onPointerDownCapture,p=>{const g=p.target.getBoundingClientRect(),S=p.clientX-g.left,b=p.clientY-g.top;o.onThumbPointerDown({x:S,y:b})}),onPointerUp:Ae(e.onPointerUp,o.onThumbPointerUp)})});a8.displayName=gm;var cC="ScrollAreaCorner",s8=v.forwardRef((e,t)=>{const n=ja(cC,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&r?s.jsx(Bhe,{...e,ref:t}):null});s8.displayName=cC;var Bhe=v.forwardRef((e,t)=>{const{__scopeScrollArea:n,...r}=e,a=ja(cC,n),[i,o]=v.useState(0),[c,d]=v.useState(0),f=!!(i&&c);return xc(a.scrollbarX,()=>{const h=a.scrollbarX?.offsetHeight||0;a.onCornerHeightChange(h),d(h)}),xc(a.scrollbarY,()=>{const h=a.scrollbarY?.offsetWidth||0;a.onCornerWidthChange(h),o(h)}),f?s.jsx(De.div,{...r,ref:t,style:{width:i,height:c,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null});function ym(e){return e?parseInt(e,10):0}function i8(e,t){const n=e/t;return isNaN(n)?0:n}function Kv(e){const t=i8(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function zhe(e,t,n,r="ltr"){const a=Kv(n),i=a/2,o=t||i,c=a-o,d=n.scrollbar.paddingStart+o,f=n.scrollbar.size-n.scrollbar.paddingEnd-c,h=n.content-n.viewport,p=r==="ltr"?[0,h]:[h*-1,0];return o8([d,f],p)(e)}function QI(e,t,n="ltr"){const r=Kv(t),a=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,i=t.scrollbar.size-a,o=t.content-t.viewport,c=i-r,d=n==="ltr"?[0,o]:[o*-1,0],f=Vd(e,d);return o8([0,o],[0,c])(f)}function o8(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function l8(e,t){return e>0&&e<t}var Uhe=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return(function a(){const i={left:e.scrollLeft,top:e.scrollTop},o=n.left!==i.left,c=n.top!==i.top;(o||c)&&t(),n=i,r=window.requestAnimationFrame(a)})(),()=>window.cancelAnimationFrame(r)};function Gv(e,t){const n=Pn(e),r=v.useRef(0);return v.useEffect(()=>()=>window.clearTimeout(r.current),[]),v.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}function xc(e,t){const n=Pn(t);Kn(()=>{let r=0;if(e){const a=new ResizeObserver(()=>{cancelAnimationFrame(r),r=window.requestAnimationFrame(n)});return a.observe(e),()=>{window.cancelAnimationFrame(r),a.unobserve(e)}}},[e,n])}var c8=JB,qhe=e8,Whe=s8;const xm=v.forwardRef(({className:e,children:t,...n},r)=>s.jsxs(c8,{ref:r,className:Se("relative overflow-hidden",e),...n,children:[s.jsx(qhe,{className:"h-full w-full rounded-[inherit]",children:t}),s.jsx(u8,{}),s.jsx(Whe,{})]}));xm.displayName=c8.displayName;const u8=v.forwardRef(({className:e,orientation:t="vertical",...n},r)=>s.jsx(oC,{ref:r,orientation:t,className:Se("flex touch-none select-none transition-colors",t==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",t==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",e),...n,children:s.jsx(a8,{className:"relative flex-1 rounded-full bg-border"})}));u8.displayName=oC.displayName;const Vhe=[{label:"Suggest Checks",description:"Propose stronger evaluation checks for this scenario.",prompt:"Suggest checks"},{label:"Suggest Value Capture Rules",description:"Recommend extract/value capture rules for key outputs.",prompt:"Suggest value capture rules"},{label:"Improve Prompt Determinism",description:"Reduce ambiguity and improve reproducibility.",prompt:"Improve prompt determinism"},{label:"Explain Snapshot Drift Risk",description:"Assess likely causes of drift and stabilization options.",prompt:"Explain snapshot drift risk"},{label:"Generate Scenario Draft",description:"Create a draft scenario from the current context.",prompt:"Generate scenario draft"}];function Hhe({open:e,onOpenChange:t,configId:n,configPath:r,scenario:a,agents:i,servers:o,snapshotEval:c,defaultAssistantAgentName:d,initialUserMessage:f,onApplyPatch:h}){const{source:p}=On(),[y,g]=v.useState(null),[S,b]=v.useState(null),[x,j]=v.useState(""),[N,_]=v.useState(!1),[P,A]=v.useState(new Set),O=v.useRef(null),k=v.useRef(null),R=v.useRef(null),[$,z]=v.useState(!1),B=v.useRef(!1),L=d||i[0]?.id||"";v.useEffect(()=>{if(!e||!L||y)return;let W=!1;return _(!0),p.createScenarioAssistantSession({configId:n,configPath:r,scenarioId:a.id,selectedAssistantAgentName:L,context:{configSnapshotPolicy:c?{enabled:c.enabled,mode:c.mode,baselineSnapshotId:c.baselineSnapshotId}:void 0,scenario:{id:a.id,name:a.name,prompt:a.prompt,serverNames:a.serverIds,evalRules:a.evalRules,extractRules:a.extractRules,snapshotEval:a.snapshotEval?{enabled:a.snapshotEval.enabled,baselineSnapshotId:a.snapshotEval.baselineSnapshotId}:void 0},availableServers:o.map(Z=>({name:Z.name||Z.id,url:Z.url})),availableAgents:i.map(Z=>({name:Z.name||Z.id,provider:Z.provider,model:Z.model}))}}).then(Z=>{W||(g(Z.sessionId),b(Z.session))}).catch(Z=>{W||Pe({title:"Could not start Scenario Assistant",description:Z instanceof Error?Z.message:String(Z),variant:"destructive"})}).finally(()=>{W||_(!1)}),()=>{W=!0}},[e,p,y,n,r,a,c,i,o,L]);const K=()=>{g(null),b(null),j(""),A(new Set),R.current=null},U=W=>{K(),p.closeScenarioAssistantSession(W).catch(()=>{})};v.useEffect(()=>{e||y&&(B.current||$||U(y))},[e,y,p,$]),v.useEffect(()=>()=>{y&&p.closeScenarioAssistantSession(y).catch(()=>{})},[y,p]),v.useEffect(()=>{if(!e)return;$&&z(!1),B.current&&(B.current=!1);const W=window.setTimeout(()=>{O.current?.scrollIntoView({behavior:"smooth",block:"end"})},0);return()=>window.clearTimeout(W)},[e,N,S?.messages.length,S?.pendingToolCalls.length,S?.warnings.length]),v.useEffect(()=>{const W=k.current;if(!W)return;W.style.height="0px";const Z=Math.min(W.scrollHeight,160);W.style.height=`${Math.max(40,Z)}px`},[x,e]);const V=i.length>0&&a.serverIds.length>0&&!!L,X=async W=>{if(!y)return;const Z=W.trim();if(!Z)return;const ye=`msg-local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,ae={id:ye,role:"user",text:Z,createdAt:new Date().toISOString()};b(ue=>ue&&{...ue,messages:[...ue.messages,ae]}),j(""),_(!0);try{const ue=await p.sendScenarioAssistantMessage(y,Z);b(ue.session)}catch(ue){b(ie=>ie&&{...ie,messages:ie.messages.filter(ve=>ve.id!==ye)}),j(ie=>ie.trim()?ie:Z),Pe({title:"Scenario Assistant error",description:ue instanceof Error?ue.message:String(ue),variant:"destructive"})}finally{_(!1)}},J=W=>{j(W),requestAnimationFrame(()=>k.current?.focus())};v.useEffect(()=>{if(!e||!y||!S||!V||N)return;const W=String(f??"").trim();W&&R.current!==W&&(R.current=W,X(W))},[e,y,S,V,N,f]);const T=async W=>{if(y){_(!0);try{const Z=await p.approveScenarioAssistantToolCall(y,W);b(Z.session)}catch(Z){Pe({title:"Tool call failed",description:Z instanceof Error?Z.message:String(Z),variant:"destructive"})}finally{_(!1)}}},D=async W=>{if(y){_(!0);try{const Z=await p.denyScenarioAssistantToolCall(y,W);b(Z.session)}catch(Z){Pe({title:"Could not deny tool call",description:Z instanceof Error?Z.message:String(Z),variant:"destructive"})}finally{_(!1)}}},Q=(W,Z,ye)=>{if(!Z)return;if(ye==="prompt"&&Z.prompt&&h({prompt:Z.prompt.replacement}),ye==="evalRules"&&Z.evalRules&&h({evalRules:Z.evalRules.replacement}),ye==="extractRules"&&Z.extractRules&&h({extractRules:Z.extractRules.replacement}),ye==="snapshotEval"&&Z.snapshotEval&&h({snapshotEval:{enabled:Z.snapshotEval.patch.enabled,baselineSnapshotId:Z.snapshotEval.patch.baselineSnapshotId}}),W){const ue=`${W}:${ye}`;A(ie=>new Set([...ie,ue]))}Pe({title:"Applied suggestion",description:`Updated ${{prompt:"Prompt",evalRules:"Checks",extractRules:"Value Capture Rules",snapshotEval:"Snapshot Settings"}[ye]}`})},F=W=>{W||(z(!1),B.current=!1),t(W)},M=()=>{B.current=!0,z(!0),t(!1)},ee=()=>{B.current=!1,z(!1),y&&U(y)};return s.jsxs(s.Fragment,{children:[!e&&y&&s.jsxs("div",{className:"mt-3 flex items-center justify-between gap-2 rounded-md border bg-background px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-sm font-medium",children:"Scenario Assistant (session active)"}),s.jsxs("p",{className:"truncate text-xs text-muted-foreground",children:["Resume conversation for ",s.jsx("span",{className:"font-mono",children:a.id}),S?` · ${S.messages.length} messages`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>t(!0),children:[s.jsx(fa,{className:"mr-1.5 h-3.5 w-3.5"}),"Resume"]}),s.jsx(se,{type:"button",size:"sm",variant:"ghost",className:"h-8 px-2 text-muted-foreground",onClick:ee,"aria-label":"Discard assistant session",title:"Discard assistant session",children:s.jsx(Ti,{className:"h-4 w-4"})})]})]}),s.jsx(Ohe,{open:e,onOpenChange:F,children:s.jsxs(KB,{className:"max-w-6xl h-[85vh] flex flex-col",children:[y&&s.jsxs("button",{type:"button",className:"absolute right-12 top-4 z-10 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",onClick:M,"aria-label":"Minimize assistant",title:"Minimize assistant",children:[s.jsx(T7,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Minimize"})]}),s.jsx(GB,{className:"pr-20",children:s.jsx("div",{className:"flex items-start justify-between gap-3",children:s.jsxs("div",{className:"min-w-0",children:[s.jsxs(YB,{className:"flex items-center gap-2",children:[s.jsx(fa,{className:"h-4 w-4"}),"Scenario Assistant"]}),s.jsx(XB,{children:"LLM-guided scenario authoring with MCP tool introspection and per-tool-call approval."})]})})}),V?s.jsxs("div",{className:"min-h-0 flex flex-1 flex-col gap-3",children:[s.jsx("div",{className:"grid gap-3 sm:grid-cols-1",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"MCP Context"}),s.jsxs("div",{className:"h-8 rounded-md border px-2 text-xs flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),S?`Loaded ${S.toolsLoaded} tools`:"Preparing..."]})]})}),s.jsx(xm,{className:"min-h-0 flex-1 rounded-md border p-3",children:s.jsxs("div",{className:"space-y-3",children:[S?.warnings?.map((W,Z)=>s.jsx("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-xs text-amber-900",children:W},`${W}-${Z}`)),S?.messages.map(W=>s.jsxs(v.Fragment,{children:[(()=>{const Z=W.pendingToolCallId?(S?.pendingToolCalls??[]).find(Oe=>Oe.id===W.pendingToolCallId):void 0;if(!(W.role==="assistant"&&!!W.pendingToolCallId))return s.jsx("div",{className:"space-y-2",children:s.jsx(Khe,{message:W})});const ae=W.text.match(/I need to call ['"]([^'"]+)['"]/i)?.[1]?.replace(/^.*__/,"")??void 0,ue=Z?.tool??W.toolRequestName??ae,ie=Z?.publicToolName??W.toolRequestPublicName,ve=ue??ie??"unknown_tool";return s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("details",{open:!!Z,className:"group w-full max-w-[92%] overflow-hidden rounded-md border border-border/60 bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:`Tool call ${ve}`}),s.jsx("span",{className:`shrink-0 whitespace-nowrap rounded px-1.5 py-0.5 text-[10px] font-semibold ${Z?"bg-amber-100 text-amber-900":"bg-muted text-muted-foreground"}`,children:Z?"Needs approval":"Completed"})]})}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"space-y-2 border-t border-border/50 px-3 py-2",children:[s.jsx(oj,{text:W.text,variant:"assistant"}),Z&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"max-h-40 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{children:JSON.stringify(Z.arguments??{},null,2)})}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{D(Z.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{T(Z.id)},children:"Approve"})]})]})]})]})]})})(),W.suggestions&&s.jsxs("div",{className:"ml-0 space-y-3 rounded-md border border-dashed bg-muted/10 p-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs font-medium text-muted-foreground",children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Structured Suggestions"]}),W.suggestions.prompt&&s.jsx(Kp,{title:"Prompt",rationale:W.suggestions.prompt.rationale,preview:W.suggestions.prompt.replacement,applied:P.has(`${W.id}:prompt`),onApply:()=>Q(W.id,W.suggestions,"prompt")}),W.suggestions.evalRules&&s.jsx(Kp,{title:"Checks",rationale:W.suggestions.evalRules.rationale,preview:JSON.stringify(W.suggestions.evalRules.replacement,null,2),applied:P.has(`${W.id}:evalRules`),onApply:()=>Q(W.id,W.suggestions,"evalRules")}),W.suggestions.extractRules&&s.jsx(Kp,{title:"Value Capture Rules",rationale:W.suggestions.extractRules.rationale,preview:JSON.stringify(W.suggestions.extractRules.replacement,null,2),applied:P.has(`${W.id}:extractRules`),onApply:()=>Q(W.id,W.suggestions,"extractRules")}),W.suggestions.snapshotEval&&s.jsx(Kp,{title:"Snapshot Settings",rationale:W.suggestions.snapshotEval.rationale,preview:JSON.stringify(W.suggestions.snapshotEval.patch,null,2),applied:P.has(`${W.id}:snapshotEval`),onApply:()=>Q(W.id,W.suggestions,"snapshotEval")}),(()=>{const Z=W.suggestions?.notes,ye=Array.isArray(Z)?Z:typeof Z=="string"?[Z]:[];return ye.length===0?null:s.jsxs("div",{className:"space-y-2 rounded-md border p-3",children:[s.jsx("h5",{className:"text-sm font-medium",children:"Notes"}),s.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground list-disc pl-4",children:ye.map((ae,ue)=>s.jsx("li",{children:ae},`${W.id}-note-${ue}`))})]})})()]})]},W.id)),(S?.pendingToolCalls??[]).filter(W=>!(S?.messages??[]).some(Z=>Z.pendingToolCallId===W.id)).map(W=>s.jsxs("details",{open:!0,className:"group min-w-0 rounded-md border bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-2 p-3",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("p",{className:"min-w-0 truncate font-mono text-xs font-semibold",children:W.publicToolName||W.tool}),s.jsx("span",{className:"shrink-0 rounded bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-900",children:"Needs approval"})]})}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"border-t px-3 pb-3 pt-2",children:[s.jsx("pre",{className:"max-h-40 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{children:JSON.stringify(W.arguments??{},null,2)})}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{D(W.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:N,onClick:()=>{T(W.id)},children:"Approve"})]})]})]},W.id)),!S&&N&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Starting assistant session..."]}),S&&N&&s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Thinking..."]})]}),s.jsx("div",{ref:O})]})}),s.jsxs("div",{className:"rounded-xl border bg-background p-2 shadow-sm",children:[s.jsx(Ks,{ref:k,value:x,onChange:W=>j(W.target.value),placeholder:"Get assistance with creating or refining this scenario ...",disabled:!y||N,rows:1,className:"min-h-10 max-h-40 resize-none border-0 bg-transparent px-2 py-1 text-sm shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",onKeyDown:W=>{W.key==="Enter"&&!W.shiftKey&&(W.preventDefault(),X(x))}}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 px-1 pt-1",children:[s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 px-1.5 text-[11px] font-normal text-muted-foreground/80 hover:text-muted-foreground",disabled:!y||N,children:[s.jsx(us,{className:"h-3 w-3"}),"Snippets",s.jsx(qt,{className:"h-3 w-3"})]})}),s.jsxs(Wo,{align:"start",className:"w-[320px]",children:[s.jsx(JN,{children:"Scenario Assistant Snippets"}),s.jsx(ZN,{}),Vhe.map(W=>s.jsx(hr,{className:"items-start whitespace-normal px-2 py-2",onSelect:()=>J(W.prompt),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"text-xs font-medium leading-tight",children:W.label}),s.jsx("div",{className:"text-[11px] leading-snug text-muted-foreground",children:W.description})]})},W.label))]})]}),s.jsx(se,{type:"button",size:"icon",className:"h-8 w-8 rounded-full",onClick:()=>{X(x)},disabled:!y||N||!x.trim(),"aria-label":"Send message",title:"Send message",children:N?s.jsx(sr,{className:"h-4 w-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(o$,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Send"})]})})]})]})]}):s.jsx("div",{className:"rounded-md border p-3 text-sm text-muted-foreground",children:"Scenario Assistant requires a configured assistant agent and at least one selected server on the scenario."})]})})]})}function Kp({title:e,rationale:t,preview:n,applied:r=!1,onApply:a}){return s.jsxs("div",{className:`space-y-2 rounded-md border p-3 ${r?"border-emerald-300 bg-emerald-50/40":""}`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("h5",{className:"text-sm font-medium",children:e}),s.jsx(se,{type:"button",size:"sm",variant:r?"secondary":"outline",onClick:a,disabled:r,children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ol,{className:"mr-1.5 h-3.5 w-3.5"}),"Applied"]}):"Apply"})]}),t&&s.jsx("p",{className:"text-xs text-muted-foreground",children:t}),s.jsx("pre",{className:"max-h-56 overflow-auto rounded bg-muted p-2 text-xs whitespace-pre-wrap",children:n})]})}function Khe({message:e}){const t=async o=>{try{await navigator.clipboard.writeText(o),Pe({title:"Copied"})}catch(c){Pe({title:"Could not copy",description:c instanceof Error?c.message:String(c),variant:"destructive"})}},n=e.role;if(n==="tool"){const o=String(e.text??"").trim();return/^(Approved|Denied) tool call\b/i.test(o)?null:s.jsxs("div",{className:"rounded-md border border-sky-500/30 bg-sky-500/10 px-3 py-2 text-sm",children:[s.jsxs("div",{className:"mb-1 flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wide text-sky-700",children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),"Tool",s.jsx("span",{className:"font-normal normal-case text-sky-700/80",children:new Date(e.createdAt).toLocaleTimeString()})]}),s.jsx("p",{className:"whitespace-pre-wrap text-sky-900",children:e.text})]})}if(n==="system")return s.jsxs("div",{className:"flex items-start gap-2 text-xs",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(i$,{className:"h-3 w-3"})}),s.jsx("div",{className:"max-w-[92%] rounded-md border border-amber-400/30 bg-amber-50/70 p-3 text-sm",children:s.jsx(oj,{text:e.text,variant:"assistant"})})]});const r=n==="user",a=r?Nj:ha,i=n==="user"||n==="assistant";return s.jsxs("div",{className:`flex items-start gap-2 text-xs ${r?"justify-end":"justify-start"}`,children:[!r&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(a,{className:"h-3 w-3"})}),s.jsxs("div",{className:"relative max-w-[92%]",children:[s.jsxs("div",{className:`max-w-full rounded-md border px-3 py-2 text-sm ${r?"border-primary/20 bg-primary/10":"border-border/80 bg-background shadow-sm"}`,children:[!r&&s.jsx("p",{className:"mb-2 text-[11px] font-semibold text-muted-foreground",children:"Assistant"}),r?s.jsx("p",{className:"whitespace-pre-wrap",children:e.text}):s.jsx(oj,{text:e.text,variant:"assistant"})]}),i&&s.jsx(se,{type:"button",variant:"ghost",size:"icon",className:`absolute bottom-1 h-6 w-6 text-muted-foreground ${r?"-left-8":"-right-8"}`,onClick:()=>{t(e.text)},"aria-label":"Copy message",title:"Copy message",children:s.jsx(Ri,{className:"h-3.5 w-3.5"})})]}),r&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-primary/30 bg-primary/15 text-primary",children:s.jsx(a,{className:"h-3 w-3"})})]})}function oj({text:e,variant:t="assistant"}){const n=Ghe(e);return s.jsx("div",{className:Se("space-y-2",t==="system"&&"text-xs"),children:n.map((r,a)=>s.jsx(v.Fragment,{children:Yhe(r,a,t)},`md-${a}`))})}function Ghe(e){const t=e.replace(/\r\n/g,`
121
121
  `).split(`
122
122
  `),n=[];let r=0;const a=o=>o.trim()==="",i=o=>o.trimStart().startsWith("```");for(;r<t.length;){const o=t[r],c=o.trim();if(a(o)){r+=1;continue}if(i(o)){const y=c.replace(/^```/,"").trim()||void 0;r+=1;const g=[];for(;r<t.length&&!i(t[r]);)g.push(t[r]),r+=1;r<t.length&&i(t[r])&&(r+=1),n.push({type:"code",lang:y,code:g.join(`
123
123
  `)});continue}if(/^---+$/.test(c)||/^\*\*\*+$/.test(c)){n.push({type:"hr"}),r+=1;continue}const d=c.match(/^(#{1,4})\s+(.+)$/);if(d){n.push({type:"heading",level:d[1].length,text:d[2].trim()}),r+=1;continue}if(JI(t,r)){const y=ZI(t[r]);r+=2;const g=[];for(;r<t.length&&t[r].includes("|")&&!a(t[r]);)g.push(ZI(t[r])),r+=1;n.push({type:"table",headers:y,rows:g});continue}const f=c.match(/^\d+\.\s+/),h=c.match(/^[-*+]\s+/);if(f||h){const y=!!f,g=[];for(;r<t.length;){const S=t[r].trim();if(y?/^\d+\.\s+/.test(S):/^[-*+]\s+/.test(S)){g.push(S.replace(y?/^\d+\.\s+/:/^[-*+]\s+/,"")),r+=1;continue}a(t[r])&&(r+=1);break}n.push({type:"list",ordered:y,items:g});continue}const p=[o];for(r+=1;r<t.length;){const y=t[r],g=y.trim();if(a(y)||i(y)||/^---+$/.test(g)||/^#{1,4}\s+/.test(g)||JI(t,r)||/^\d+\.\s+/.test(g)||/^[-*+]\s+/.test(g))break;p.push(y),r+=1}n.push({type:"paragraph",text:p.join(`
@@ -127,7 +127,7 @@ You can add a description to the \`${Fl}\` by passing a \`${y8}\` component as a
127
127
 
128
128
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Fl}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
129
129
 
130
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},fme=f8,pme=p8,j8=h8,N8=m8,C8=b8,_8=S8,A8=g8,E8=x8;const bs=fme,hme=pme,P8=v.forwardRef(({className:e,...t},n)=>s.jsx(j8,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));P8.displayName=j8.displayName;const Va=v.forwardRef(({className:e,...t},n)=>s.jsxs(hme,{children:[s.jsx(P8,{}),s.jsx(N8,{ref:n,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Va.displayName=N8.displayName;const Ha=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ha.displayName="AlertDialogHeader";const Ka=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ka.displayName="AlertDialogFooter";const Ga=v.forwardRef(({className:e,...t},n)=>s.jsx(A8,{ref:n,className:Se("text-lg font-semibold",e),...t}));Ga.displayName=A8.displayName;const Ya=v.forwardRef(({className:e,...t},n)=>s.jsx(E8,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));Ya.displayName=E8.displayName;const Xa=v.forwardRef(({className:e,...t},n)=>s.jsx(C8,{ref:n,className:Se(zj(),e),...t}));Xa.displayName=C8.displayName;const Qa=v.forwardRef(({className:e,...t},n)=>s.jsx(_8,{ref:n,className:Se(zj({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Qa.displayName=_8.displayName;const mme=()=>{const{servers:e,setServers:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=p=>p.name?.trim()||p.id,d=async p=>{const y=`${c(p)}-copy`;let g=y,S=1;for(;e.some(x=>(x.name?.trim()||x.id)===g);)g=`${y}-${S}`,S+=1;const b={...structuredClone(p),id:`srv-${Date.now()}`,name:g};await t([...e,b]),Pe({title:"Server duplicated",description:`Created ${g}.`})},f=async p=>{await t(e.filter(y=>y.id!==p.id)),Pe({title:"Server deleted",description:`${c(p)} was removed.`}),o(null)},h=p=>p.transport==="stdio"?[p.command,...p.args||[]].filter(Boolean).join(" "):p.url||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(e$,{className:"h-6 w-6"}),"Servers"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable MCP server definitions shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No servers configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]}):s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Transport"}),s.jsx(Qe,{children:"Endpoint"}),s.jsx(Qe,{children:"Auth"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(p=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(Fe,{className:"font-medium",children:c(p)}),s.jsx(Fe,{children:s.jsx(Ke,{variant:"secondary",className:"font-mono text-xs",children:p.transport})}),s.jsx(Fe,{children:s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h(p)})}),s.jsx(Fe,{children:!p.authType||p.authType==="none"?s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):s.jsx(Ke,{variant:"outline",className:"text-xs",children:p.authType})}),s.jsx(Fe,{className:"text-right",onClick:y=>y.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(p),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{d(p)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},p.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:p=>!p&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?c(i):""})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&f(i)},children:"Delete Server"})]})]})})]})},tM={stdio:"Check that the command is installed and the args are correct",sse:"Check that the server is running and the URL is reachable","streamable-http":"Check that the server is running and the URL is reachable"},vme=()=>({id:`srv-${Date.now()}`,name:"",transport:"stdio",authType:"none",oauthRedirectUrl:"http://localhost:6274/oauth/"}),gme=()=>{const{serverId:e}=Mo(),t=wa(),{servers:n,setServers:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(R=>R.id===o||R.name===o),d=R=>R.name?.trim()||R.id,[f,h]=v.useState(()=>c??vme()),[p,y]=v.useState(!1),[g,S]=v.useState(!1),[b,x]=v.useState({status:"idle"}),[j,N]=v.useState(!1);v.useEffect(()=>{c&&h(c)},[c]);const _=R=>{h($=>({...$,authType:R,...R!=="oauth2"?{oauthClientId:void 0,oauthClientSecret:void 0,oauthRedirectUrl:void 0,oauthScope:void 0}:{oauthRedirectUrl:$.oauthRedirectUrl||"http://localhost:6274/oauth/"}}))},P=async()=>{N(!0),x({status:"loading"});try{const $=(await a.discoverToolsForAnalysis({serverNames:[f.id]})).servers[0];$&&$.warnings.length===0?x({status:"success",toolNames:$.tools.map(z=>z.name),toolCount:$.tools.length,testedAt:new Date().toISOString()}):x({status:"error",message:$?.warnings[0]??"Connection failed",testedAt:new Date().toISOString()})}catch(R){x({status:"error",message:R instanceof Error?R.message:String(R),testedAt:new Date().toISOString()})}},A=async()=>{if(!f.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}S(!0);try{if(i)await r([...n,f]),Pe({title:"Server created"}),t(`/libraries/servers/${encodeURIComponent(f.id)}`);else{const R=n.map($=>$.id===c?.id?f:$);await r(R),Pe({title:"Server saved"}),f.id!==o&&t(`/libraries/servers/${encodeURIComponent(f.id)}`,{replace:!0})}}finally{S(!1)}},O=async()=>{const R=n.filter($=>$.id!==c?.id);await r(R),Pe({title:"Server deleted"}),t("/libraries/servers")},k=()=>f.transport==="stdio"?[f.command,...f.args||[]].filter(Boolean).join(" "):f.url||"";return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Server "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Server":d(f)})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{P()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),j&&s.jsxs(Be,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>N(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Server:"}),s.jsx("span",{className:"font-medium text-foreground",children:d(f)}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Transport:"}),s.jsx("span",{className:"font-medium text-foreground",children:f.transport}),k()&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsx("code",{className:"font-mono text-xs",children:k()})]})]}),b.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Connecting to MCP server…"]}),b.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",b.toolCount," tool",b.toolCount!==1?"s":""]}),b.toolNames.length>0&&s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"First 5 tools:"}),s.jsx("ul",{className:"space-y-0.5",children:b.toolNames.slice(0,5).map(R=>s.jsx("li",{className:"font-mono text-xs",children:R},R))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]}),b.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," — ",b.message]}),tM[f.transport]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",tM[f.transport]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:f.name,onChange:R=>h($=>({...$,name:R.target.value})),placeholder:"e.g. Filesystem MCP"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Transport"}),s.jsxs(sn,{value:f.transport,onValueChange:R=>h($=>({...$,transport:R})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"stdio",children:"stdio"}),s.jsx(at,{value:"sse",children:"SSE"}),s.jsx(at,{value:"streamable-http",children:"Streamable HTTP"})]})]})]})]}),f.transport==="stdio"?s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Command"}),s.jsx(ht,{value:f.command||"",onChange:R=>h($=>({...$,command:R.target.value})),placeholder:"npx",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Args (comma-separated)"}),s.jsx(ht,{value:(f.args||[]).join(", "),onChange:R=>h($=>({...$,args:R.target.value.split(",").map(z=>z.trim()).filter(Boolean)})),placeholder:"-y, @mcp/server",className:"font-mono text-xs"})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"URL"}),s.jsx(ht,{value:f.url||"",onChange:R=>h($=>({...$,url:R.target.value})),placeholder:"http://localhost:3001/sse",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Auth Type"}),s.jsxs(sn,{value:f.authType||"none",onValueChange:R=>_(R),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"none",children:"None"}),s.jsx(at,{value:"bearer",children:"Bearer Token"}),s.jsx(at,{value:"api-key",children:"API Key"}),s.jsx(at,{value:"oauth2",children:"OAuth 2.0"})]})]})]}),f.authType&&f.authType!=="none"&&f.authType!=="oauth2"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:f.authType==="bearer"?"Token":"API Key"}),s.jsx(ht,{type:"password",value:f.authValue||"",onChange:R=>h($=>({...$,authValue:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),f.authType==="oauth2"&&s.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[s.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"OAuth 2.0 Flow"}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client ID"}),s.jsx(ht,{value:f.oauthClientId||"",onChange:R=>h($=>({...$,oauthClientId:R.target.value})),placeholder:"your-client-id",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client Secret (optional)"}),s.jsx(ht,{type:"password",value:f.oauthClientSecret||"",onChange:R=>h($=>({...$,oauthClientSecret:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Redirect URL"}),s.jsx(ht,{value:f.oauthRedirectUrl||"http://localhost:6274/oauth/",onChange:R=>h($=>({...$,oauthRedirectUrl:R.target.value})),placeholder:"http://localhost:6274/oauth/",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Scope (space-separated)"}),s.jsx(ht,{value:f.oauthScope||"",onChange:R=>h($=>({...$,oauthScope:R.target.value})),placeholder:"openid profile mcp",className:"font-mono text-xs"})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>y(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/servers"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{A()},disabled:g,children:[g&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Server":"Save"]})]})]})]})]}),s.jsx(bs,{open:p,onOpenChange:y,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove the server"," ",s.jsx("span",{className:"font-mono",children:f.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{O()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},yme=()=>{const{agents:e,setAgents:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=async f=>{const h=`${f.name}-copy`;let p=h,y=1;for(;e.some(S=>S.name===p);)p=`${h}-${y}`,y+=1;const g={...structuredClone(f),id:`agt-${Date.now()}`,name:p};await t([...e,g]),Pe({title:"Agent duplicated",description:`Created ${p}.`})},d=async f=>{await t(e.filter(h=>h.id!==f.id)),Pe({title:"Agent deleted",description:`${f.name} was removed.`}),o(null)};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(ha,{className:"h-6 w-6"}),"Agents"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable agent profiles shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]}):s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Provider"}),s.jsx(Qe,{children:"Model"}),s.jsx(Qe,{children:"Max Tokens"}),s.jsx(Qe,{children:"Temperature"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(f=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(Fe,{className:"font-medium",children:f.name}),s.jsx(Fe,{children:s.jsx(aB,{provider:f.provider})}),s.jsx(Fe,{children:s.jsx("span",{className:"font-mono text-xs",children:f.model})}),s.jsx(Fe,{className:"font-mono text-xs",children:f.maxTokens}),s.jsx(Fe,{className:"font-mono text-xs",children:f.temperature.toFixed(2)}),s.jsx(Fe,{className:"text-right",onClick:h=>h.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(f),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{c(f)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},f.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:f=>!f&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?.name})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&d(i)},children:"Delete Agent"})]})]})})]})};var O8=["PageUp","PageDown"],k8=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R8={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Uc="Slider",[cj,xme,bme]=Hd(Uc),[T8]=ir(Uc,[bme]),[wme,Yv]=T8(Uc),I8=v.forwardRef((e,t)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:d=0,defaultValue:f=[r],value:h,onValueChange:p=()=>{},onValueCommit:y=()=>{},inverted:g=!1,form:S,...b}=e,x=v.useRef(new Set),j=v.useRef(0),_=o==="horizontal"?Sme:jme,[P=[],A]=na({prop:h,defaultProp:f,onChange:B=>{[...x.current][j.current]?.focus(),p(B)}}),O=v.useRef(P);function k(B){const L=Eme(P,B);z(B,L)}function R(B){z(B,j.current)}function $(){const B=O.current[j.current];P[j.current]!==B&&y(P)}function z(B,L,{commit:K}={commit:!1}){const U=Rme(i),V=Tme(Math.round((B-r)/i)*i+r,U),X=Vd(V,[r,a]);A((J=[])=>{const T=_me(J,X,L);if(kme(T,d*i)){j.current=T.indexOf(X);const D=String(T)!==String(J);return D&&K&&y(T),D?T:J}else return J})}return s.jsx(wme,{scope:e.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:j,thumbs:x.current,values:P,orientation:o,form:S,children:s.jsx(cj.Provider,{scope:e.__scopeSlider,children:s.jsx(cj.Slot,{scope:e.__scopeSlider,children:s.jsx(_,{"aria-disabled":c,"data-disabled":c?"":void 0,...b,ref:t,onPointerDown:Ae(b.onPointerDown,()=>{c||(O.current=P)}),min:r,max:a,inverted:g,onSlideStart:c?void 0:k,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:$,onHomeKeyDown:()=>!c&&z(r,0,{commit:!0}),onEndKeyDown:()=>!c&&z(a,P.length-1,{commit:!0}),onStepKeyDown:({event:B,direction:L})=>{if(!c){const V=O8.includes(B.key)||B.shiftKey&&k8.includes(B.key)?10:1,X=j.current,J=P[X],T=i*V*L;z(J+T,X,{commit:!0})}}})})})})});I8.displayName=Uc;var[M8,$8]=T8(Uc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Sme=v.forwardRef((e,t)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:d,onStepKeyDown:f,...h}=e,[p,y]=v.useState(null),g=ut(t,_=>y(_)),S=v.useRef(void 0),b=Lc(a),x=b==="ltr",j=x&&!i||!x&&i;function N(_){const P=S.current||p.getBoundingClientRect(),A=[0,P.width],k=uC(A,j?[n,r]:[r,n]);return S.current=P,k(_-P.left)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:j?"left":"right",endEdge:j?"right":"left",direction:j?1:-1,size:"width",children:s.jsx(D8,{dir:b,"data-orientation":"horizontal",...h,ref:g,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const P=N(_.clientX);o?.(P)},onSlideMove:_=>{const P=N(_.clientX);c?.(P)},onSlideEnd:()=>{S.current=void 0,d?.()},onStepKeyDown:_=>{const A=R8[j?"from-left":"from-right"].includes(_.key);f?.({event:_,direction:A?-1:1})}})})}),jme=v.forwardRef((e,t)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:d,...f}=e,h=v.useRef(null),p=ut(t,h),y=v.useRef(void 0),g=!a;function S(b){const x=y.current||h.current.getBoundingClientRect(),j=[0,x.height],_=uC(j,g?[r,n]:[n,r]);return y.current=x,_(b-x.top)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:s.jsx(D8,{"data-orientation":"vertical",...f,ref:p,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=S(b.clientY);i?.(x)},onSlideMove:b=>{const x=S(b.clientY);o?.(x)},onSlideEnd:()=>{y.current=void 0,c?.()},onStepKeyDown:b=>{const j=R8[g?"from-bottom":"from-top"].includes(b.key);d?.({event:b,direction:j?-1:1})}})})}),D8=v.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:d,...f}=e,h=Yv(Uc,n);return s.jsx(De.span,{...f,ref:t,onKeyDown:Ae(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(c(p),p.preventDefault()):O8.concat(k8).includes(p.key)&&(d(p),p.preventDefault())}),onPointerDown:Ae(e.onPointerDown,p=>{const y=p.target;y.setPointerCapture(p.pointerId),p.preventDefault(),h.thumbs.has(y)?y.focus():r(p)}),onPointerMove:Ae(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&a(p)}),onPointerUp:Ae(e.onPointerUp,p=>{const y=p.target;y.hasPointerCapture(p.pointerId)&&(y.releasePointerCapture(p.pointerId),i(p))})})}),L8="SliderTrack",F8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(L8,n);return s.jsx(De.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});F8.displayName=L8;var uj="SliderRange",B8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(uj,n),i=$8(uj,n),o=v.useRef(null),c=ut(t,o),d=a.values.length,f=a.values.map(y=>q8(y,a.min,a.max)),h=d>1?Math.min(...f):0,p=100-Math.max(...f);return s.jsx(De.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:p+"%"}})});B8.displayName=uj;var dj="SliderThumb",z8=v.forwardRef((e,t)=>{const n=xme(e.__scopeSlider),[r,a]=v.useState(null),i=ut(t,c=>a(c)),o=v.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(Nme,{...e,ref:i,index:o})}),Nme=v.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:a,...i}=e,o=Yv(dj,n),c=$8(dj,n),[d,f]=v.useState(null),h=ut(t,N=>f(N)),p=d?o.form||!!d.closest("form"):!0,y=km(d),g=o.values[r],S=g===void 0?0:q8(g,o.min,o.max),b=Ame(r,o.values.length),x=y?.[c.size],j=x?Pme(x,S,c.direction):0;return v.useEffect(()=>{if(d)return o.thumbs.add(d),()=>{o.thumbs.delete(d)}},[d,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${S}% + ${j}px)`},children:[s.jsx(cj.ItemSlot,{scope:e.__scopeSlider,children:s.jsx(De.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":o.min,"aria-valuenow":g,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:h,style:g===void 0?{display:"none"}:e.style,onFocus:Ae(e.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),p&&s.jsx(U8,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:g},r)]})});z8.displayName=dj;var Cme="RadioBubbleInput",U8=v.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const a=v.useRef(null),i=ut(a,r),o=Fv(t);return v.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(o!==t&&h){const p=new Event("input",{bubbles:!0});h.call(c,t),c.dispatchEvent(p)}},[o,t]),s.jsx(De.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});U8.displayName=Cme;function _me(e=[],t,n){const r=[...e];return r[n]=t,r.sort((a,i)=>a-i)}function q8(e,t,n){const i=100/(n-t)*(e-t);return Vd(i,[0,100])}function Ame(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Eme(e,t){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-t)),r=Math.min(...n);return n.indexOf(r)}function Pme(e,t,n){const r=e/2,i=uC([0,50],[0,r]);return(r-i(t)*n)*n}function Ome(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function kme(e,t){if(t>0){const n=Ome(e);return Math.min(...n)>=t}return!0}function uC(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Rme(e){return(String(e).split(".")[1]||"").length}function Tme(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var W8=I8,Ime=F8,Mme=B8,$me=z8;const V8=v.forwardRef(({className:e,...t},n)=>s.jsxs(W8,{ref:n,className:Se("relative flex w-full touch-none select-none items-center",e),...t,children:[s.jsx(Ime,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:s.jsx(Mme,{className:"absolute h-full bg-primary"})}),s.jsx($me,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));V8.displayName=W8.displayName;function Dme(e){const t=Lme(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(Bme);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function Lme(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=Ume(a),c=zme(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Fme=Symbol("radix.slottable");function Bme(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Fme}function zme(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function Ume(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xv="Popover",[H8]=ir(Xv,[Di]),vf=Di(),[qme,Vi]=H8(Xv),K8=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,c=vf(t),d=v.useRef(null),[f,h]=v.useState(!1),[p,y]=na({prop:r,defaultProp:a??!1,onChange:i,caller:Xv});return s.jsx(Rm,{...c,children:s.jsx(qme,{scope:t,contentId:Hn(),triggerRef:d,open:p,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(g=>!g),[y]),hasCustomAnchor:f,onCustomAnchorAdd:v.useCallback(()=>h(!0),[]),onCustomAnchorRemove:v.useCallback(()=>h(!1),[]),modal:o,children:n})})};K8.displayName=Xv;var G8="PopoverAnchor",Wme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(G8,n),i=vf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:c}=a;return v.useEffect(()=>(o(),()=>c()),[o,c]),s.jsx(Yd,{...i,...r,ref:t})});Wme.displayName=G8;var Y8="PopoverTrigger",X8=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(Y8,n),i=vf(n),o=ut(t,a.triggerRef),c=s.jsx(De.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":tz(a.open),...r,ref:o,onClick:Ae(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:s.jsx(Yd,{asChild:!0,...i,children:c})});X8.displayName=Y8;var dC="PopoverPortal",[Vme,Hme]=H8(dC,{forceMount:void 0}),Q8=e=>{const{__scopePopover:t,forceMount:n,children:r,container:a}=e,i=Vi(dC,t);return s.jsx(Vme,{scope:t,forceMount:n,children:s.jsx(Gn,{present:n||i.open,children:s.jsx(Sc,{asChild:!0,container:a,children:r})})})};Q8.displayName=dC;var bc="PopoverContent",J8=v.forwardRef((e,t)=>{const n=Hme(bc,e.__scopePopover),{forceMount:r=n.forceMount,...a}=e,i=Vi(bc,e.__scopePopover);return s.jsx(Gn,{present:r||i.open,children:i.modal?s.jsx(Gme,{...a,ref:t}):s.jsx(Yme,{...a,ref:t})})});J8.displayName=bc;var Kme=Dme("PopoverContent.RemoveScroll"),Gme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(null),a=ut(t,r),i=v.useRef(!1);return v.useEffect(()=>{const o=r.current;if(o)return Hm(o)},[]),s.jsx(Qd,{as:Kme,allowPinchZoom:!0,children:s.jsx(Z8,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(e.onCloseAutoFocus,o=>{o.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Ae(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Ae(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Yme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(!1),a=v.useRef(!1);return s.jsx(Z8,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;n.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Z8=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,...p}=e,y=Vi(bc,n),g=vf(n);return Wm(),s.jsx(Xd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>y.onOpenChange(!1),children:s.jsx(Tm,{"data-state":tz(y.open),role:"dialog",id:y.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ez="PopoverClose",Xme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(ez,n);return s.jsx(De.button,{type:"button",...r,ref:t,onClick:Ae(e.onClick,()=>a.onOpenChange(!1))})});Xme.displayName=ez;var Qme="PopoverArrow",Jme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=vf(n);return s.jsx(Im,{...a,...r,ref:t})});Jme.displayName=Qme;function tz(e){return e?"open":"closed"}var Zme=K8,eve=X8,tve=Q8,nz=J8;const nve=Zme,rve=eve,rz=v.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>s.jsx(tve,{children:s.jsx(nz,{ref:a,align:t,sideOffset:n,className:Se("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 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",e),...r})}));rz.displayName=nz.displayName;var nM=1,ave=.9,sve=.8,ive=.17,r1=.1,a1=.999,ove=.9999,lve=.99,cve=/[\\\/_+.#"@\[\(\{&]/,uve=/[\\\/_+.#"@\[\(\{&]/g,dve=/[\s-]/,az=/[\s-]/g;function fj(e,t,n,r,a,i,o){if(i===t.length)return a===e.length?nM:lve;var c=`${a},${i}`;if(o[c]!==void 0)return o[c];for(var d=r.charAt(i),f=n.indexOf(d,a),h=0,p,y,g,S;f>=0;)p=fj(e,t,n,r,f+1,i+1,o),p>h&&(f===a?p*=nM:cve.test(e.charAt(f-1))?(p*=sve,g=e.slice(a,f-1).match(uve),g&&a>0&&(p*=Math.pow(a1,g.length))):dve.test(e.charAt(f-1))?(p*=ave,S=e.slice(a,f-1).match(az),S&&a>0&&(p*=Math.pow(a1,S.length))):(p*=ive,a>0&&(p*=Math.pow(a1,f-a))),e.charAt(f)!==t.charAt(i)&&(p*=ove)),(p<r1&&n.charAt(f-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(f-1)!==r.charAt(i))&&(y=fj(e,t,n,r,f+1,i+2,o),y*r1>p&&(p=y*r1)),p>h&&(h=p),f=n.indexOf(d,f+1);return o[c]=h,h}function rM(e){return e.toLowerCase().replace(az," ")}function fve(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fj(e,t,rM(e),rM(t),0,0,{})}var Du='[cmdk-group=""]',s1='[cmdk-group-items=""]',pve='[cmdk-group-heading=""]',sz='[cmdk-item=""]',aM=`${sz}:not([aria-disabled="true"])`,pj="cmdk-item-select",Sl="data-value",hve=(e,t,n)=>fve(e,t,n),iz=v.createContext(void 0),gf=()=>v.useContext(iz),oz=v.createContext(void 0),fC=()=>v.useContext(oz),lz=v.createContext(void 0),cz=v.forwardRef((e,t)=>{let n=jl(()=>{var M,ee;return{search:"",value:(ee=(M=e.value)!=null?M:e.defaultValue)!=null?ee:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=jl(()=>new Set),a=jl(()=>new Map),i=jl(()=>new Map),o=jl(()=>new Set),c=uz(e),{label:d,children:f,value:h,onValueChange:p,filter:y,shouldFilter:g,loop:S,disablePointerSelection:b=!1,vimBindings:x=!0,...j}=e,N=Hn(),_=Hn(),P=Hn(),A=v.useRef(null),O=Cve();Ro(()=>{if(h!==void 0){let M=h.trim();n.current.value=M,k.emit()}},[h]),Ro(()=>{O(6,K)},[]);let k=v.useMemo(()=>({subscribe:M=>(o.current.add(M),()=>o.current.delete(M)),snapshot:()=>n.current,setState:(M,ee,W)=>{var Z,ye,ae,ue;if(!Object.is(n.current[M],ee)){if(n.current[M]=ee,M==="search")L(),z(),O(1,B);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ie=document.getElementById(P);ie?ie.focus():(Z=document.getElementById(N))==null||Z.focus()}if(O(7,()=>{var ie;n.current.selectedItemId=(ie=U())==null?void 0:ie.id,k.emit()}),W||O(5,K),((ye=c.current)==null?void 0:ye.value)!==void 0){let ie=ee??"";(ue=(ae=c.current).onValueChange)==null||ue.call(ae,ie);return}}k.emit()}},emit:()=>{o.current.forEach(M=>M())}}),[]),R=v.useMemo(()=>({value:(M,ee,W)=>{var Z;ee!==((Z=i.current.get(M))==null?void 0:Z.value)&&(i.current.set(M,{value:ee,keywords:W}),n.current.filtered.items.set(M,$(ee,W)),O(2,()=>{z(),k.emit()}))},item:(M,ee)=>(r.current.add(M),ee&&(a.current.has(ee)?a.current.get(ee).add(M):a.current.set(ee,new Set([M]))),O(3,()=>{L(),z(),n.current.value||B(),k.emit()}),()=>{i.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let W=U();O(4,()=>{L(),W?.getAttribute("id")===M&&B(),k.emit()})}),group:M=>(a.current.has(M)||a.current.set(M,new Set),()=>{i.current.delete(M),a.current.delete(M)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:N,inputId:P,labelId:_,listInnerRef:A}),[]);function $(M,ee){var W,Z;let ye=(Z=(W=c.current)==null?void 0:W.filter)!=null?Z:hve;return M?ye(M,n.current.search,ee):0}function z(){if(!n.current.search||c.current.shouldFilter===!1)return;let M=n.current.filtered.items,ee=[];n.current.filtered.groups.forEach(Z=>{let ye=a.current.get(Z),ae=0;ye.forEach(ue=>{let ie=M.get(ue);ae=Math.max(ie,ae)}),ee.push([Z,ae])});let W=A.current;V().sort((Z,ye)=>{var ae,ue;let ie=Z.getAttribute("id"),ve=ye.getAttribute("id");return((ae=M.get(ve))!=null?ae:0)-((ue=M.get(ie))!=null?ue:0)}).forEach(Z=>{let ye=Z.closest(s1);ye?ye.appendChild(Z.parentElement===ye?Z:Z.closest(`${s1} > *`)):W.appendChild(Z.parentElement===W?Z:Z.closest(`${s1} > *`))}),ee.sort((Z,ye)=>ye[1]-Z[1]).forEach(Z=>{var ye;let ae=(ye=A.current)==null?void 0:ye.querySelector(`${Du}[${Sl}="${encodeURIComponent(Z[0])}"]`);ae?.parentElement.appendChild(ae)})}function B(){let M=V().find(W=>W.getAttribute("aria-disabled")!=="true"),ee=M?.getAttribute(Sl);k.setState("value",ee||void 0)}function L(){var M,ee,W,Z;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ye=0;for(let ae of r.current){let ue=(ee=(M=i.current.get(ae))==null?void 0:M.value)!=null?ee:"",ie=(Z=(W=i.current.get(ae))==null?void 0:W.keywords)!=null?Z:[],ve=$(ue,ie);n.current.filtered.items.set(ae,ve),ve>0&&ye++}for(let[ae,ue]of a.current)for(let ie of ue)if(n.current.filtered.items.get(ie)>0){n.current.filtered.groups.add(ae);break}n.current.filtered.count=ye}function K(){var M,ee,W;let Z=U();Z&&(((M=Z.parentElement)==null?void 0:M.firstChild)===Z&&((W=(ee=Z.closest(Du))==null?void 0:ee.querySelector(pve))==null||W.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function U(){var M;return(M=A.current)==null?void 0:M.querySelector(`${sz}[aria-selected="true"]`)}function V(){var M;return Array.from(((M=A.current)==null?void 0:M.querySelectorAll(aM))||[])}function X(M){let ee=V()[M];ee&&k.setState("value",ee.getAttribute(Sl))}function J(M){var ee;let W=U(),Z=V(),ye=Z.findIndex(ue=>ue===W),ae=Z[ye+M];(ee=c.current)!=null&&ee.loop&&(ae=ye+M<0?Z[Z.length-1]:ye+M===Z.length?Z[0]:Z[ye+M]),ae&&k.setState("value",ae.getAttribute(Sl))}function T(M){let ee=U(),W=ee?.closest(Du),Z;for(;W&&!Z;)W=M>0?jve(W,Du):Nve(W,Du),Z=W?.querySelector(aM);Z?k.setState("value",Z.getAttribute(Sl)):J(M)}let D=()=>X(V().length-1),Q=M=>{M.preventDefault(),M.metaKey?D():M.altKey?T(1):J(1)},F=M=>{M.preventDefault(),M.metaKey?X(0):M.altKey?T(-1):J(-1)};return v.createElement(De.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:M=>{var ee;(ee=j.onKeyDown)==null||ee.call(j,M);let W=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||W))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&Q(M);break}case"ArrowDown":{Q(M);break}case"p":case"k":{x&&M.ctrlKey&&F(M);break}case"ArrowUp":{F(M);break}case"Home":{M.preventDefault(),X(0);break}case"End":{M.preventDefault(),D();break}case"Enter":{M.preventDefault();let Z=U();if(Z){let ye=new Event(pj);Z.dispatchEvent(ye)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:Ave},d),Qv(e,M=>v.createElement(oz.Provider,{value:k},v.createElement(iz.Provider,{value:R},M))))}),mve=v.forwardRef((e,t)=>{var n,r;let a=Hn(),i=v.useRef(null),o=v.useContext(lz),c=gf(),d=uz(e),f=(r=(n=d.current)==null?void 0:n.forceMount)!=null?r:o?.forceMount;Ro(()=>{if(!f)return c.item(a,o?.id)},[f]);let h=dz(a,i,[e.value,e.children,i],e.keywords),p=fC(),y=$i(O=>O.value&&O.value===h.current),g=$i(O=>f||c.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);v.useEffect(()=>{let O=i.current;if(!(!O||e.disabled))return O.addEventListener(pj,S),()=>O.removeEventListener(pj,S)},[g,e.onSelect,e.disabled]);function S(){var O,k;b(),(k=(O=d.current).onSelect)==null||k.call(O,h.current)}function b(){p.setState("value",h.current,!0)}if(!g)return null;let{disabled:x,value:j,onSelect:N,forceMount:_,keywords:P,...A}=e;return v.createElement(De.div,{ref:jr(i,t),...A,id:a,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!y,"data-disabled":!!x,"data-selected":!!y,onPointerMove:x||c.getDisablePointerSelection()?void 0:b,onClick:x?void 0:S},e.children)}),vve=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...i}=e,o=Hn(),c=v.useRef(null),d=v.useRef(null),f=Hn(),h=gf(),p=$i(g=>a||h.filter()===!1?!0:g.search?g.filtered.groups.has(o):!0);Ro(()=>h.group(o),[]),dz(o,c,[e.value,e.heading,d]);let y=v.useMemo(()=>({id:o,forceMount:a}),[a]);return v.createElement(De.div,{ref:jr(c,t),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&v.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),Qv(e,g=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},v.createElement(lz.Provider,{value:y},g))))}),gve=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=v.useRef(null),i=$i(o=>!o.search);return!n&&!i?null:v.createElement(De.div,{ref:jr(a,t),...r,"cmdk-separator":"",role:"separator"})}),yve=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,a=e.value!=null,i=fC(),o=$i(f=>f.search),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),v.createElement(De.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:o,onChange:f=>{a||i.setState("search",f.target.value),n?.(f.target.value)}})}),xve=v.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...a}=e,i=v.useRef(null),o=v.useRef(null),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{if(o.current&&i.current){let f=o.current,h=i.current,p,y=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let g=f.offsetHeight;h.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return y.observe(f),()=>{cancelAnimationFrame(p),y.unobserve(f)}}},[]),v.createElement(De.div,{ref:jr(i,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:d.listId},Qv(e,f=>v.createElement("div",{ref:jr(o,d.listInnerRef),"cmdk-list-sizer":""},f)))}),bve=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...c}=e;return v.createElement(Gm,{open:n,onOpenChange:r},v.createElement(Ym,{container:o},v.createElement(Pc,{"cmdk-overlay":"",className:a}),v.createElement(Oc,{"aria-label":e.label,"cmdk-dialog":"",className:i},v.createElement(cz,{ref:t,...c}))))}),wve=v.forwardRef((e,t)=>$i(n=>n.filtered.count===0)?v.createElement(De.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Sve=v.forwardRef((e,t)=>{let{progress:n,children:r,label:a="Loading...",...i}=e;return v.createElement(De.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Qv(e,o=>v.createElement("div",{"aria-hidden":!0},o)))}),$r=Object.assign(cz,{List:xve,Item:mve,Input:yve,Group:vve,Separator:gve,Dialog:bve,Empty:wve,Loading:Sve});function jve(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Nve(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function uz(e){let t=v.useRef(e);return Ro(()=>{t.current=e}),t}var Ro=typeof window>"u"?v.useEffect:v.useLayoutEffect;function jl(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function $i(e){let t=fC(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function dz(e,t,n,r=[]){let a=v.useRef(),i=gf();return Ro(()=>{var o;let c=(()=>{var f;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(f=h.current.textContent)==null?void 0:f.trim():a.current}})(),d=r.map(f=>f.trim());i.value(e,c,d),(o=t.current)==null||o.setAttribute(Sl,c),a.current=c}),a}var Cve=()=>{let[e,t]=v.useState(),n=jl(()=>new Map);return Ro(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,a)=>{n.current.set(r,a),t({})}};function _ve(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qv({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(_ve(t),{ref:t.ref},n(t.props.children)):n(t)}var Ave={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const fz=v.forwardRef(({className:e,...t},n)=>s.jsx($r,{ref:n,className:Se("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));fz.displayName=$r.displayName;const pz=v.forwardRef(({className:e,...t},n)=>s.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[s.jsx(Sj,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),s.jsx($r.Input,{ref:n,className:Se("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));pz.displayName=$r.Input.displayName;const hz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.List,{ref:n,className:Se("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));hz.displayName=$r.List.displayName;const mz=v.forwardRef((e,t)=>s.jsx($r.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));mz.displayName=$r.Empty.displayName;const vz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Group,{ref:n,className:Se("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));vz.displayName=$r.Group.displayName;const Eve=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Separator,{ref:n,className:Se("-mx-1 h-px bg-border",e),...t}));Eve.displayName=$r.Separator.displayName;const hj=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Item,{ref:n,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));hj.displayName=$r.Item.displayName;const sM={openai:["gpt-4o","gpt-4o-mini","gpt-4-turbo","o1","o1-mini"],anthropic:["claude-3-5-sonnet-latest","claude-3-5-haiku-latest","claude-3-opus-latest"],azure:["gpt-4o","gpt-4-turbo"],google:["gemini-2.0-flash","gemini-1.5-pro"],custom:[]},iM={anthropic:"Check that `ANTHROPIC_API_KEY` is set in your environment",openai:"Check that `OPENAI_API_KEY` is set in your environment",azure:"Check that Azure OpenAI env vars are configured in your environment"},Pve=()=>({id:`agt-${Date.now()}`,name:"",provider:"openai",model:"gpt-4o",temperature:0,maxTokens:4096}),Ove=()=>{const{agentName:e}=Mo(),t=wa(),{agents:n,setAgents:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(T=>T.id===o)??n.find(T=>T.name===o),[d,f]=v.useState(()=>c??Pve()),[h,p]=v.useState(!1),[y,g]=v.useState(!1),[S,b]=v.useState({status:"idle"}),[x,j]=v.useState(!1),[N,_]=v.useState([]),[P,A]=v.useState(!1),[O,k]=v.useState(!1),[R,$]=v.useState(!1);v.useEffect(()=>{c&&f(c)},[c]);const z=d.provider==="anthropic"||d.provider==="openai"||d.provider==="azure",B=Array.from(new Set([...sM[d.provider]||[],...N])),L=B.includes(d.model),K=R||!!d.model&&!L,U=async()=>{if(j(!0),d.provider==="google"||d.provider==="custom"){b({status:"unsupported"});return}b({status:"loading"});try{const T=await a.listProviderModels(d.provider);b({status:"success",items:T.items,source:T.source,kind:T.kind,testedAt:new Date().toISOString()})}catch(T){b({status:"error",message:T instanceof Error?T.message:String(T),testedAt:new Date().toISOString()})}},V=async()=>{if(!z){Pe({title:"Provider discovery not supported",description:"Model discovery is available for Anthropic, OpenAI, and Azure OpenAI."});return}A(!0);try{const T=await a.listProviderModels(d.provider);_(T.items),Pe({title:T.kind==="deployments"?"Deployments loaded":"Models loaded",description:`${T.items.length} ${T.kind} from ${T.source}`})}catch(T){Pe({title:"Could not load provider models",description:String(T instanceof Error?T.message:T),variant:"destructive"})}finally{A(!1)}},X=async()=>{if(!d.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}g(!0);try{if(i)await r([...n,d]),Pe({title:"Agent created"}),t(`/libraries/agents/${encodeURIComponent(d.id)}`);else{const T=n.map(D=>D.id===c?.id?d:D);await r(T),Pe({title:"Agent saved"}),d.id!==o&&t(`/libraries/agents/${encodeURIComponent(d.id)}`,{replace:!0})}}finally{g(!1)}},J=async()=>{const T=n.filter(D=>D.id!==c?.id);await r(T),Pe({title:"Agent deleted"}),t("/libraries/agents")};return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Agent "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Agent":d.name})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{U()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),x&&s.jsxs(Be,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>j(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Provider:"}),s.jsx("span",{className:"font-medium text-foreground",children:d.provider}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsxs("code",{className:"font-mono text-xs",children:["/api/providers/models?provider=",d.provider]})]}),S.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Testing connection..."]}),S.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",S.items.length," ",S.kind," from"," ",S.source]}),s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsxs("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:["First 5 ",S.kind,":"]}),s.jsx("ul",{className:"space-y-0.5",children:S.items.slice(0,5).map(T=>s.jsx("li",{className:"font-mono text-xs",children:T},T))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," —"," ",S.message]}),iM[d.provider]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",iM[d.provider]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="unsupported"&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground",children:["Connection testing is not supported for the"," ",s.jsx("span",{className:"font-medium",children:d.provider})," provider. Supported providers: Anthropic, OpenAI, Azure OpenAI."]})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:d.name,onChange:T=>f(D=>({...D,name:T.target.value})),placeholder:"e.g. GPT-4o"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Provider"}),s.jsxs(sn,{value:d.provider,onValueChange:T=>f(D=>({...D,provider:T,model:sM[T]?.[0]||""})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"openai",children:"OpenAI"}),s.jsx(at,{value:"anthropic",children:"Anthropic"}),s.jsx(at,{value:"azure",children:"Azure OpenAI"}),s.jsx(at,{value:"google",children:"Google"}),s.jsx(at,{value:"custom",children:"Custom"})]})]})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:d.provider==="azure"?"Deployment":"Model"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(nve,{open:O,onOpenChange:k,children:[s.jsx(rve,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"outline",role:"combobox","aria-expanded":O,className:"h-9 flex-1 justify-between font-mono text-xs",children:[s.jsx("span",{className:"truncate text-left",children:d.model||"Select model..."}),s.jsx(qt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(rz,{className:"w-[420px] p-0",align:"start",children:s.jsxs(fz,{children:[s.jsx(pz,{placeholder:`Search ${d.provider==="azure"?"deployments":"models"}...`}),s.jsxs(hz,{children:[s.jsxs(mz,{children:["No ",d.provider==="azure"?"deployments":"models"," found."]}),s.jsxs(vz,{heading:d.provider==="azure"?"Deployments":"Models",children:[B.map(T=>s.jsxs(hj,{value:T,onSelect:D=>{f(Q=>({...Q,model:D})),$(!1),k(!1)},children:[s.jsx(ql,{className:Se("mr-2 h-4 w-4",d.model===T?"opacity-100":"opacity-0")}),s.jsx("span",{className:"font-mono text-xs",children:T})]},T)),s.jsx(hj,{value:"__custom_model_id__",onSelect:()=>{$(!0),k(!1)},children:s.jsx("span",{className:"font-medium",children:d.provider==="azure"?"Custom deployment ID...":"Custom model ID..."})})]})]})]})})]}),z&&s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0 text-xs",onClick:()=>{V()},disabled:P,title:d.provider==="azure"?"Fetch Azure OpenAI deployments":`Fetch ${d.provider} models`,children:[P?s.jsx(sr,{className:"mr-1 h-3 w-3 animate-spin"}):s.jsx(Fa,{className:"mr-1 h-3 w-3"}),d.provider==="azure"?"Fetch Deployments":"Fetch Models"]})]}),K&&s.jsx(ht,{value:d.model,onChange:T=>f(D=>({...D,model:T.target.value})),placeholder:d.provider==="azure"?"Type deployment name manually":"Type model name manually",className:"font-mono text-xs"}),N.length>0&&s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Loaded ",N.length," ",d.provider==="azure"?"deployment names":"models"," from provider discovery."]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Max Tokens"}),s.jsx(ht,{type:"number",min:1,max:128e3,value:d.maxTokens,onChange:T=>f(D=>({...D,maxTokens:parseInt(T.target.value)||0})),className:"font-mono text-xs"})]})]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Max Turns"}),s.jsx(ht,{type:"number",min:1,max:50,value:d.maxTurns??"",onChange:T=>{const D=T.target.value.trim();f(Q=>({...Q,maxTurns:D&&parseInt(D)||void 0}))},placeholder:"15 (default)",className:"font-mono text-xs"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Maximum number of LLM round-trips (tool calls + final answer) per eval run."})]})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Me,{children:"Temperature"}),s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:d.temperature.toFixed(2)})]}),s.jsx(V8,{value:[d.temperature],onValueChange:([T])=>f(D=>({...D,temperature:T})),min:0,max:2,step:.01})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"System Prompt"}),s.jsx(Ks,{value:d.systemPrompt||"",onChange:T=>f(D=>({...D,systemPrompt:T.target.value})),placeholder:"Optional system prompt...",rows:3,className:"text-xs"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>p(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/agents"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{X()},disabled:y,children:[y&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Agent":"Save"]})]})]})]})]}),s.jsx(bs,{open:h,onOpenChange:p,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove the agent"," ",s.jsx("span",{className:"font-mono",children:d.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{J()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},oM="mcplab.resultAssistantScenarioHandoff",lM=()=>{const{testCaseId:e}=Mo(),[t,n]=Ec(),r=wa(),{source:a}=On(),{scenarios:i,setScenarios:o,agents:c,servers:d,reload:f,loading:h}=qa(),[p,y]=v.useState(""),[g,S]=v.useState("all"),[b,x]=v.useState("name"),[j,N]=v.useState("asc"),[_,P]=v.useState(""),[A,O]=v.useState(null),[k,R]=v.useState("idle"),[$,z]=v.useState(""),[B,L]=v.useState(""),[K,U]=v.useState(0),[V,X]=v.useState(null),J=v.useRef(null),T=v.useRef(!1),D=v.useRef(!1),Q=v.useRef(null),F=v.useRef(0),M=e?decodeURIComponent(e):void 0,ee=M?i.findIndex(re=>re.id===M):-1,W=ee>=0?i[ee]:void 0,Z=async re=>{if(!W||ee<0||!re)return;const me=[...i];me[ee]=re,await o(me)},ye=async()=>{const re=Q.current;if(!re||!W)return;if(T.current){D.current=!0;return}T.current=!0,D.current=!1;const me=++F.current;R("saving"),z("");try{await Z(re),me===F.current&&R("saved")}catch(Ne){const tt=Ne instanceof Error?Ne.message:String(Ne);me===F.current&&(R("error"),z(tt)),Pe({title:"Could not save scenario",description:tt,variant:"destructive"})}finally{T.current=!1,D.current&&(D.current=!1,ye())}},ae=re=>{Q.current=re,R("dirty"),z(""),J.current&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,ye()},700)},ue=async()=>{const re=`scn-${Date.now()}`;let me=re,Ne=1;for(;i.some(je=>je.id===me);)me=`${re}-${Ne}`,Ne+=1;const tt={id:me,name:"",serverIds:[],prompt:"",evalRules:[],extractRules:[]};await o([...i,tt]),r(`/libraries/test-cases/${encodeURIComponent(me)}`),Pe({title:"Test case created",description:`Opened ${me} for editing.`})},ie=re=>{const me=(re||`scn-${Date.now()}`).trim().replace(/\s+/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||`scn-${Date.now()}`;let Ne=me,tt=1;for(;i.some(je=>je.id===Ne);)Ne=`${me}-${tt}`,tt+=1;return Ne},ve=async(re,me=!1)=>{const Ne=ie(`${re.id}-copy`),tt={...structuredClone(re),id:Ne,name:re.name?`${re.name} (Copy)`:""};await o([...i,tt]),Pe({title:"Test case duplicated",description:`Created ${tt.id}.`}),me&&r(`/libraries/test-cases/${encodeURIComponent(tt.id)}`)},Oe=async re=>{J.current&&(window.clearTimeout(J.current),J.current=null);const me=i.filter(Ne=>Ne.id!==re.id);await o(me),Pe({title:"Test case deleted",description:`${re.id} was removed.`}),W?.id===re.id&&(O(null),Q.current=null,R("idle"),z(""),r("/libraries/test-cases"))},oe=re=>re.map(me=>d.find(Ne=>Ne.id===me)).filter(Boolean).map(me=>me?.name||me?.id).filter(Boolean),he=v.useMemo(()=>{const re=new Set;for(const me of i)for(const Ne of oe(me.serverIds))re.add(Ne);return Array.from(re).sort((me,Ne)=>me.localeCompare(Ne))},[i,d]),xe=v.useMemo(()=>{const re=p.trim().toLowerCase(),me=i.filter(Ne=>{const tt=(Ne.name||"").toLowerCase(),je=Ne.id.toLowerCase(),et=(Ne.prompt||"").toLowerCase(),dt=oe(Ne.serverIds);return g!=="all"&&!dt.includes(g)?!1:re?tt.includes(re)||je.includes(re)||et.includes(re)||dt.some(Pt=>Pt.toLowerCase().includes(re)):!0});return me.sort((Ne,tt)=>{const je=oe(Ne.serverIds),et=oe(tt.serverIds);let dt=0;switch(b){case"id":dt=Ne.id.localeCompare(tt.id);break;case"servers":dt=je.length-et.length;break;case"evalRules":dt=Ne.evalRules.length-tt.evalRules.length;break;case"extractRules":dt=Ne.extractRules.length-tt.extractRules.length;break;default:dt=(Ne.name||Ne.id).localeCompare(tt.name||tt.id);break}return dt===0&&(dt=Ne.id.localeCompare(tt.id)),j==="asc"?dt:-dt}),me},[i,p,g,b,j,d]);v.useEffect(()=>{let re=!0;return a.getWorkspaceSettings().then(me=>{!re||!me||P(me.scenarioAssistantAgentName??"")}).catch(()=>{re&&P("")}),()=>{re=!1}},[a]),v.useEffect(()=>{if(M&&t.get("assistantHandoff")==="1")try{const re=window.sessionStorage.getItem(oM);if(!re)return;const me=JSON.parse(re);if(!me||me.scenarioId!==M||!me.prompt)return;L(String(me.prompt)),U(Date.now()),window.sessionStorage.removeItem(oM);const Ne=new URLSearchParams(t);Ne.delete("assistantHandoff"),n(Ne,{replace:!0}),Pe({title:"Suggestion sent to Scenario Assistant",description:"Review the suggestion and apply changes in the scenario editor."})}catch{}},[M,t,n]),v.useEffect(()=>{W?(O(structuredClone(W)),Q.current=structuredClone(W),R("idle"),z("")):(O(null),Q.current=null,R("idle"),z("")),J.current&&(window.clearTimeout(J.current),J.current=null),T.current=!1,D.current=!1},[W]),v.useEffect(()=>()=>{J.current&&window.clearTimeout(J.current)},[]);const Ie=_||c[0]?.name||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(t$,{className:"h-6 w-6"}),"Manage Test Cases"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable test case templates shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[W&&s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>r("/libraries/test-cases"),children:[s.jsx(xo,{className:"mr-2 h-4 w-4"}),"Back to Overview"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{f()},disabled:h,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),!W&&s.jsxs(se,{type:"button",size:"sm",onClick:()=>{ue()},children:[s.jsx(us,{className:"mr-1.5 h-3.5 w-3.5"}),"Add Test Case"]})]})]}),!W&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 rounded-md border bg-muted/30 p-3 md:grid-cols-[1.6fr_1fr_1fr_auto]",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Search"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sj,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),s.jsx(ht,{value:p,onChange:re=>y(re.target.value),placeholder:"Search by name, id, prompt, server...",className:"h-8 pl-8 text-xs"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Server Filter"}),s.jsxs(sn,{value:g,onValueChange:S,children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"all",children:"All servers"}),he.map(re=>s.jsx(at,{value:re,children:re},re))]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Sort By"}),s.jsxs(sn,{value:b,onValueChange:re=>x(re),children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"name",children:"Name"}),s.jsx(at,{value:"id",children:"ID"}),s.jsx(at,{value:"servers",children:"# Servers"}),s.jsx(at,{value:"evalRules",children:"# Eval Rules"}),s.jsx(at,{value:"extractRules",children:"# Extract Rules"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Direction"}),s.jsxs(sn,{value:j,onValueChange:re=>N(re),children:[s.jsx(Jt,{className:"h-8 w-28 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"asc",children:"Ascending"}),s.jsx(at,{value:"desc",children:"Descending"})]})]})]})]}),s.jsx(Be,{children:s.jsxs(ze,{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Showing ",xe.length," of ",i.length," test case",i.length!==1?"s":"","."]}),M&&!W&&s.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Test case ",s.jsx("code",{className:"font-mono",children:M})," was not found."]}),i.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No library test cases yet."}):xe.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No test cases match the current filters."}):s.jsx("div",{className:"grid gap-3",children:xe.map(re=>{const me=M===re.id,Ne=`/libraries/test-cases/${encodeURIComponent(re.id)}`,tt=oe(re.serverIds);return s.jsx("div",{className:`rounded-lg border p-3 ${me?"border-primary bg-primary/5":""}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(yt,{to:Ne,className:"font-medium truncate hover:underline",children:re.name||re.id}),s.jsx(Ke,{variant:"outline",className:"font-mono text-[10px]",children:re.id}),me&&s.jsx(Ke,{children:"Selected"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground flex flex-wrap gap-x-3 gap-y-1",children:[s.jsxs("span",{children:[tt.length," server",tt.length!==1?"s":""]}),s.jsxs("span",{children:[re.evalRules.length," eval rule",re.evalRules.length!==1?"s":""]}),s.jsxs("span",{children:[re.extractRules.length," extract rule",re.extractRules.length!==1?"s":""]})]}),tt.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:tt.map(je=>s.jsx(Ke,{variant:"secondary",className:"text-[10px]",children:je},`${re.id}-${je}`))})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(re),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(re)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsx(se,{type:"button",size:"sm",variant:me?"default":"outline",asChild:!0,children:s.jsxs(yt,{to:Ne,children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})})]})]})},re.id)})})]})})]}),W&&A?s.jsxs(Be,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{children:s.jsx(_t,{className:"text-base",children:"Edit Test Case"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(A,!0)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(A),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]})]})]}),s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{children:["Focused editor for ",s.jsx("code",{className:"font-mono",children:W.id}),"."]}),s.jsx(Ke,{variant:"outline",className:`text-[10px] ${k==="saving"?"border-amber-300 text-amber-700":k==="saved"?"border-emerald-300 text-emerald-700":k==="error"?"border-destructive/40 text-destructive":k==="dirty"?"border-sky-300 text-sky-700":""}`,children:k==="saving"?"Saving...":k==="saved"?"Saved":k==="error"?"Save failed":k==="dirty"?"Unsaved changes":"Ready"}),k==="error"&&$&&s.jsx("span",{className:"text-[11px] text-destructive",children:$})]})})]}),s.jsx(ze,{className:"pt-3",children:s.jsx(lj,{scenarios:[A],agents:c,servers:d,defaultAssistantAgentName:Ie,assistantInitialPromptByScenarioId:B&&A?.id?{[A.id]:B}:void 0,assistantAutoOpenNonceByScenarioId:A?.id&&K?{[A.id]:K}:void 0,onChange:re=>{const me=re[0];me&&(O(me),ae(me))},allowAdd:!1})})]}):null,s.jsx(bs,{open:!!V,onOpenChange:re=>!re&&X(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete test case?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-medium",children:V?.name||V?.id})," ","from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{V&&(Oe(V),X(null))},children:"Delete Test Case"})]})]})})]})},kve=()=>{const{source:e}=On(),{agents:t,reload:n,loading:r}=qa(),[a,i]=v.useState(!1),[o,c]=v.useState(!1),[d,f]=v.useState(""),h=v.useMemo(()=>d||t[0]?.name||"",[d,t]),p=async()=>{i(!0);try{const S=await e.getWorkspaceSettings();f(S?.scenarioAssistantAgentName??"")}catch(S){f(""),Pe({title:"Could not load settings",description:S instanceof Error?S.message:String(S),variant:"destructive"})}finally{i(!1)}};v.useEffect(()=>{p()},[e]);const y=async S=>{f(S),c(!0);try{await e.updateWorkspaceSettings({scenarioAssistantAgentName:S||void 0}),Pe({title:"Settings updated",description:S?`Scenario Assistant Agent set to ${S}.`:"Scenario Assistant Agent cleared (will use first available agent by default)."})}catch(b){Pe({title:"Could not save settings",description:b instanceof Error?b.message:String(b),variant:"destructive"})}finally{c(!1)}},g=async()=>{await Promise.all([n(),p()])};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(jj,{className:"h-6 w-6"}),"Settings"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace-level MCP Lab settings and defaults."})]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{g()},disabled:r||a,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),s.jsxs(Be,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsx(_t,{className:"text-base",children:"Scenario Assistant"}),s.jsx(Ds,{children:"Default assistant model used on library test case pages. If unset, MCP Lab uses the first available agent automatically."})]}),s.jsxs(ze,{className:"grid gap-3 md:grid-cols-[1.3fr_auto] md:items-end",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Assistant Agent"}),s.jsxs(sn,{value:h||"__none__",onValueChange:S=>{y(S==="__none__"?"":S)},disabled:o,children:[s.jsx(Jt,{className:"h-9 text-sm",children:s.jsx(on,{placeholder:"Select assistant agent"})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"__none__",children:"None (use first agent)"}),t.map(S=>s.jsxs(at,{value:S.id,children:[S.name||S.id," · ",S.model]},S.id))]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Applies to `/libraries/test-cases/:testCaseId`. MCP Evaluation editors can still override the assistant agent from their evaluation context."})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:"Saved in workspace settings"})]})]})]})};var Jv="Checkbox",[Rve]=ir(Jv),[Tve,pC]=Rve(Jv);function Ive(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:c,onCheckedChange:d,required:f,value:h="on",internal_do_not_use_render:p}=e,[y,g]=na({prop:n,defaultProp:a??!1,onChange:d,caller:Jv}),[S,b]=v.useState(null),[x,j]=v.useState(null),N=v.useRef(!1),_=S?!!o||!!S.closest("form"):!0,P={checked:y,disabled:i,setChecked:g,control:S,setControl:b,name:c,form:o,value:h,hasConsumerStoppedPropagationRef:N,required:f,defaultChecked:ki(a)?!1:a,isFormControl:_,bubbleInput:x,setBubbleInput:j};return s.jsx(Tve,{scope:t,...P,children:Mve(p)?p(P):r})}var gz="CheckboxTrigger",yz=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{const{control:i,value:o,disabled:c,checked:d,required:f,setControl:h,setChecked:p,hasConsumerStoppedPropagationRef:y,isFormControl:g,bubbleInput:S}=pC(gz,e),b=ut(a,h),x=v.useRef(d);return v.useEffect(()=>{const j=i?.form;if(j){const N=()=>p(x.current);return j.addEventListener("reset",N),()=>j.removeEventListener("reset",N)}},[i,p]),s.jsx(De.button,{type:"button",role:"checkbox","aria-checked":ki(d)?"mixed":d,"aria-required":f,"data-state":jz(d),"data-disabled":c?"":void 0,disabled:c,value:o,...r,ref:b,onKeyDown:Ae(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Ae(n,j=>{p(N=>ki(N)?!0:!N),S&&g&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})})});yz.displayName=gz;var hC=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:d,onCheckedChange:f,form:h,...p}=e;return s.jsx(Ive,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:c,required:o,onCheckedChange:f,name:r,form:h,value:d,internal_do_not_use_render:({isFormControl:y})=>s.jsxs(s.Fragment,{children:[s.jsx(yz,{...p,ref:t,__scopeCheckbox:n}),y&&s.jsx(Sz,{__scopeCheckbox:n})]})})});hC.displayName=Jv;var xz="CheckboxIndicator",bz=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,i=pC(xz,n);return s.jsx(Gn,{present:r||ki(i.checked)||i.checked===!0,children:s.jsx(De.span,{"data-state":jz(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});bz.displayName=xz;var wz="CheckboxBubbleInput",Sz=v.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:c,disabled:d,name:f,value:h,form:p,bubbleInput:y,setBubbleInput:g}=pC(wz,e),S=ut(n,g),b=Fv(i),x=km(r);v.useEffect(()=>{const N=y;if(!N)return;const _=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(_,"checked").set,O=!a.current;if(b!==i&&A){const k=new Event("click",{bubbles:O});N.indeterminate=ki(i),A.call(N,ki(i)?!1:i),N.dispatchEvent(k)}},[y,b,i,a]);const j=v.useRef(ki(i)?!1:i);return s.jsx(De.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:c,disabled:d,name:f,value:h,form:p,...t,tabIndex:-1,ref:S,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sz.displayName=wz;function Mve(e){return typeof e=="function"}function ki(e){return e==="indeterminate"}function jz(e){return ki(e)?"indeterminate":e?"checked":"unchecked"}const va=v.forwardRef(({className:e,...t},n)=>s.jsx(hC,{ref:n,className:Se("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(bz,{className:Se("flex items-center justify-center text-current"),children:s.jsx(ql,{className:"h-4 w-4"})})}));va.displayName=hC.displayName;const $ve=Io("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Bl=v.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert",className:Se($ve({variant:t}),e),...n}));Bl.displayName="Alert";const zl=v.forwardRef(({className:e,...t},n)=>s.jsx("h5",{ref:n,className:Se("mb-1 font-medium leading-none tracking-tight",e),...t}));zl.displayName="AlertTitle";const Ul=v.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:Se("text-sm [&_p]:leading-relaxed",e),...t}));Ul.displayName="AlertDescription";function Dve(e,t=[]){let n=[];function r(i,o){const c=v.createContext(o);c.displayName=i+"Context";const d=n.length;n=[...n,o];const f=p=>{const{scope:y,children:g,...S}=p,b=y?.[e]?.[d]||c,x=v.useMemo(()=>S,Object.values(S));return s.jsx(b.Provider,{value:x,children:g})};f.displayName=i+"Provider";function h(p,y){const g=y?.[e]?.[d]||c,S=v.useContext(g);if(S)return S;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[f,h]}const a=()=>{const i=n.map(o=>v.createContext(o));return function(c){const d=c?.[e]||i;return v.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return a.scopeName=e,[r,Lve(a,...t)]}function Lve(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(i)[`__scope${f}`];return{...c,...p}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Fve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nz=Fve.reduce((e,t)=>{const n=qm(`Primitive.${t}`),r=v.forwardRef((a,i)=>{const{asChild:o,...c}=a,d=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),mC="Progress",vC=100,[Bve]=Dve(mC),[zve,Uve]=Bve(mC),Cz=v.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=qve,...o}=e;(a||a===0)&&!cM(a)&&console.error(Wve(`${a}`,"Progress"));const c=cM(a)?a:vC;r!==null&&!uM(r,c)&&console.error(Vve(`${r}`,"Progress"));const d=uM(r,c)?r:null,f=bm(d)?i(d,c):void 0;return s.jsx(zve,{scope:n,value:d,max:c,children:s.jsx(Nz.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":bm(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":Ez(d,c),"data-value":d??void 0,"data-max":c,...o,ref:t})})});Cz.displayName=mC;var _z="ProgressIndicator",Az=v.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,a=Uve(_z,n);return s.jsx(Nz.div,{"data-state":Ez(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:t})});Az.displayName=_z;function qve(e,t){return`${Math.round(e/t*100)}%`}function Ez(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function bm(e){return typeof e=="number"}function cM(e){return bm(e)&&!isNaN(e)&&e>0}function uM(e,t){return bm(e)&&!isNaN(e)&&e<=t&&e>=0}function Wve(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${vC}\`.`}function Vve(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
130
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return v.useEffect(()=>{document.getElementById(e.current?.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},fme=f8,pme=p8,j8=h8,N8=m8,C8=b8,_8=S8,A8=g8,E8=x8;const bs=fme,hme=pme,P8=v.forwardRef(({className:e,...t},n)=>s.jsx(j8,{className:Se("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));P8.displayName=j8.displayName;const Va=v.forwardRef(({className:e,...t},n)=>s.jsxs(hme,{children:[s.jsx(P8,{}),s.jsx(N8,{ref:n,className:Se("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 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 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]}));Va.displayName=N8.displayName;const Ha=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col space-y-2 text-center sm:text-left",e),...t});Ha.displayName="AlertDialogHeader";const Ka=({className:e,...t})=>s.jsx("div",{className:Se("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Ka.displayName="AlertDialogFooter";const Ga=v.forwardRef(({className:e,...t},n)=>s.jsx(A8,{ref:n,className:Se("text-lg font-semibold",e),...t}));Ga.displayName=A8.displayName;const Ya=v.forwardRef(({className:e,...t},n)=>s.jsx(E8,{ref:n,className:Se("text-sm text-muted-foreground",e),...t}));Ya.displayName=E8.displayName;const Xa=v.forwardRef(({className:e,...t},n)=>s.jsx(C8,{ref:n,className:Se(zj(),e),...t}));Xa.displayName=C8.displayName;const Qa=v.forwardRef(({className:e,...t},n)=>s.jsx(_8,{ref:n,className:Se(zj({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));Qa.displayName=_8.displayName;const mme=()=>{const{servers:e,setServers:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=p=>p.name?.trim()||p.id,d=async p=>{const y=`${c(p)}-copy`;let g=y,S=1;for(;e.some(x=>(x.name?.trim()||x.id)===g);)g=`${y}-${S}`,S+=1;const b={...structuredClone(p),id:`srv-${Date.now()}`,name:g};await t([...e,b]),Pe({title:"Server duplicated",description:`Created ${g}.`})},f=async p=>{await t(e.filter(y=>y.id!==p.id)),Pe({title:"Server deleted",description:`${c(p)} was removed.`}),o(null)},h=p=>p.transport==="stdio"?[p.command,...p.args||[]].filter(Boolean).join(" "):p.url||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(e$,{className:"h-6 w-6"}),"Servers"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable MCP server definitions shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No servers configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/servers/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Server"]})]}):s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Transport"}),s.jsx(Qe,{children:"Endpoint"}),s.jsx(Qe,{children:"Auth"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(p=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(Fe,{className:"font-medium",children:c(p)}),s.jsx(Fe,{children:s.jsx(Ke,{variant:"secondary",className:"font-mono text-xs",children:p.transport})}),s.jsx(Fe,{children:s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:h(p)})}),s.jsx(Fe,{children:!p.authType||p.authType==="none"?s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"}):s.jsx(Ke,{variant:"outline",className:"text-xs",children:p.authType})}),s.jsx(Fe,{className:"text-right",onClick:y=>y.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(p),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{d(p)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/servers/${encodeURIComponent(p.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},p.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:p=>!p&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?c(i):""})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&f(i)},children:"Delete Server"})]})]})})]})},tM={stdio:"Check that the command is installed and the args are correct",sse:"Check that the server is running and the URL is reachable","streamable-http":"Check that the server is running and the URL is reachable"},vme=()=>({id:`srv-${Date.now()}`,name:"",transport:"stdio",authType:"none",oauthRedirectUrl:"http://localhost:6274/oauth/"}),gme=()=>{const{serverId:e}=Mo(),t=wa(),{servers:n,setServers:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(R=>R.id===o||R.name===o),d=R=>R.name?.trim()||R.id,[f,h]=v.useState(()=>c??vme()),[p,y]=v.useState(!1),[g,S]=v.useState(!1),[b,x]=v.useState({status:"idle"}),[j,N]=v.useState(!1);v.useEffect(()=>{c&&h(c)},[c]);const _=R=>{h($=>({...$,authType:R,...R!=="oauth2"?{oauthClientId:void 0,oauthClientSecret:void 0,oauthRedirectUrl:void 0,oauthScope:void 0}:{oauthRedirectUrl:$.oauthRedirectUrl||"http://localhost:6274/oauth/"}}))},P=async()=>{N(!0),x({status:"loading"});try{const $=(await a.discoverToolsForAnalysis({serverNames:[f.id]})).servers[0];$&&$.warnings.length===0?x({status:"success",toolNames:$.tools.map(z=>z.name),toolCount:$.tools.length,testedAt:new Date().toISOString()}):x({status:"error",message:$?.warnings[0]??"Connection failed",testedAt:new Date().toISOString()})}catch(R){x({status:"error",message:R instanceof Error?R.message:String(R),testedAt:new Date().toISOString()})}},A=async()=>{if(!f.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}S(!0);try{if(i)await r([...n,f]),Pe({title:"Server created"}),t(`/libraries/servers/${encodeURIComponent(f.id)}`);else{const R=n.map($=>$.id===c?.id?f:$);await r(R),Pe({title:"Server saved"}),f.id!==o&&t(`/libraries/servers/${encodeURIComponent(f.id)}`,{replace:!0})}}finally{S(!1)}},O=async()=>{const R=n.filter($=>$.id!==c?.id);await r(R),Pe({title:"Server deleted"}),t("/libraries/servers")},k=()=>f.transport==="stdio"?[f.command,...f.args||[]].filter(Boolean).join(" "):f.url||"";return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Server "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/servers",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Servers"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Server":d(f)})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{P()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),j&&s.jsxs(Be,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>N(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Server:"}),s.jsx("span",{className:"font-medium text-foreground",children:d(f)}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Transport:"}),s.jsx("span",{className:"font-medium text-foreground",children:f.transport}),k()&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsx("code",{className:"font-mono text-xs",children:k()})]})]}),b.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Connecting to MCP server…"]}),b.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",b.toolCount," tool",b.toolCount!==1?"s":""]}),b.toolNames.length>0&&s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsx("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"First 5 tools:"}),s.jsx("ul",{className:"space-y-0.5",children:b.toolNames.slice(0,5).map(R=>s.jsx("li",{className:"font-mono text-xs",children:R},R))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]}),b.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," — ",b.message]}),tM[f.transport]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",tM[f.transport]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(b.testedAt).toLocaleString()]})]})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:f.name,onChange:R=>h($=>({...$,name:R.target.value})),placeholder:"e.g. Filesystem MCP"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Transport"}),s.jsxs(sn,{value:f.transport,onValueChange:R=>h($=>({...$,transport:R})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"stdio",children:"stdio"}),s.jsx(at,{value:"sse",children:"SSE"}),s.jsx(at,{value:"streamable-http",children:"Streamable HTTP"})]})]})]})]}),f.transport==="stdio"?s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Command"}),s.jsx(ht,{value:f.command||"",onChange:R=>h($=>({...$,command:R.target.value})),placeholder:"npx",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Args (comma-separated)"}),s.jsx(ht,{value:(f.args||[]).join(", "),onChange:R=>h($=>({...$,args:R.target.value.split(",").map(z=>z.trim()).filter(Boolean)})),placeholder:"-y, @mcp/server",className:"font-mono text-xs"})]})]}):s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"URL"}),s.jsx(ht,{value:f.url||"",onChange:R=>h($=>({...$,url:R.target.value})),placeholder:"http://localhost:3001/sse",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Auth Type"}),s.jsxs(sn,{value:f.authType||"none",onValueChange:R=>_(R),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"none",children:"None"}),s.jsx(at,{value:"bearer",children:"Bearer Token"}),s.jsx(at,{value:"api-key",children:"API Key"}),s.jsx(at,{value:"oauth2",children:"OAuth 2.0"})]})]})]}),f.authType&&f.authType!=="none"&&f.authType!=="oauth2"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:f.authType==="bearer"?"Token":"API Key"}),s.jsx(ht,{type:"password",value:f.authValue||"",onChange:R=>h($=>({...$,authValue:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),f.authType==="oauth2"&&s.jsxs("div",{className:"space-y-3 rounded-md border p-3",children:[s.jsx("div",{className:"text-xs font-medium text-muted-foreground",children:"OAuth 2.0 Flow"}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client ID"}),s.jsx(ht,{value:f.oauthClientId||"",onChange:R=>h($=>({...$,oauthClientId:R.target.value})),placeholder:"your-client-id",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Client Secret (optional)"}),s.jsx(ht,{type:"password",value:f.oauthClientSecret||"",onChange:R=>h($=>({...$,oauthClientSecret:R.target.value})),placeholder:"••••••••",className:"font-mono text-xs"})]})]}),s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Redirect URL"}),s.jsx(ht,{value:f.oauthRedirectUrl||"http://localhost:6274/oauth/",onChange:R=>h($=>({...$,oauthRedirectUrl:R.target.value})),placeholder:"http://localhost:6274/oauth/",className:"font-mono text-xs"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Scope (space-separated)"}),s.jsx(ht,{value:f.oauthScope||"",onChange:R=>h($=>({...$,oauthScope:R.target.value})),placeholder:"openid profile mcp",className:"font-mono text-xs"})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>y(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/servers"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{A()},disabled:g,children:[g&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Server":"Save"]})]})]})]})]}),s.jsx(bs,{open:p,onOpenChange:y,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete server?"}),s.jsxs(Ya,{children:["This will permanently remove the server"," ",s.jsx("span",{className:"font-mono",children:f.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{O()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},yme=()=>{const{agents:e,setAgents:t,reload:n,loading:r}=qa(),a=wa(),[i,o]=v.useState(null),c=async f=>{const h=`${f.name}-copy`;let p=h,y=1;for(;e.some(S=>S.name===p);)p=`${h}-${y}`,y+=1;const g={...structuredClone(f),id:`agt-${Date.now()}`,name:p};await t([...e,g]),Pe({title:"Agent duplicated",description:`Created ${p}.`})},d=async f=>{await t(e.filter(h=>h.id!==f.id)),Pe({title:"Agent deleted",description:`${f.name} was removed.`}),o(null)};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(ha,{className:"h-6 w-6"}),"Agents"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable agent profiles shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{n()},disabled:r,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]})]}),e.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center rounded-lg border border-dashed py-16 text-center",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No agents configured. Add one to get started."}),s.jsxs(se,{type:"button",size:"sm",className:"mt-4",onClick:()=>a("/libraries/agents/new"),children:[s.jsx(us,{className:"mr-2 h-4 w-4"}),"Add Agent"]})]}):s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Name"}),s.jsx(Qe,{children:"Provider"}),s.jsx(Qe,{children:"Model"}),s.jsx(Qe,{children:"Max Tokens"}),s.jsx(Qe,{children:"Temperature"}),s.jsx(Qe,{className:"text-right",children:"Actions"})]})}),s.jsx(Jr,{children:e.map(f=>s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(Fe,{className:"font-medium",children:f.name}),s.jsx(Fe,{children:s.jsx(aB,{provider:f.provider})}),s.jsx(Fe,{children:s.jsx("span",{className:"font-mono text-xs",children:f.model})}),s.jsx(Fe,{className:"font-mono text-xs",children:f.maxTokens}),s.jsx(Fe,{className:"font-mono text-xs",children:f.temperature.toFixed(2)}),s.jsx(Fe,{className:"text-right",onClick:h=>h.stopPropagation(),children:s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>o(f),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{c(f)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>a(`/libraries/agents/${encodeURIComponent(f.id)}`),children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})]})})]},f.id))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:f=>!f&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-mono",children:i?.name})," from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{i&&d(i)},children:"Delete Agent"})]})]})})]})};var O8=["PageUp","PageDown"],k8=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],R8={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Uc="Slider",[cj,xme,bme]=Hd(Uc),[T8]=ir(Uc,[bme]),[wme,Yv]=T8(Uc),I8=v.forwardRef((e,t)=>{const{name:n,min:r=0,max:a=100,step:i=1,orientation:o="horizontal",disabled:c=!1,minStepsBetweenThumbs:d=0,defaultValue:f=[r],value:h,onValueChange:p=()=>{},onValueCommit:y=()=>{},inverted:g=!1,form:S,...b}=e,x=v.useRef(new Set),j=v.useRef(0),_=o==="horizontal"?Sme:jme,[P=[],A]=na({prop:h,defaultProp:f,onChange:B=>{[...x.current][j.current]?.focus(),p(B)}}),O=v.useRef(P);function k(B){const L=Eme(P,B);z(B,L)}function R(B){z(B,j.current)}function $(){const B=O.current[j.current];P[j.current]!==B&&y(P)}function z(B,L,{commit:K}={commit:!1}){const U=Rme(i),V=Tme(Math.round((B-r)/i)*i+r,U),X=Vd(V,[r,a]);A((J=[])=>{const T=_me(J,X,L);if(kme(T,d*i)){j.current=T.indexOf(X);const D=String(T)!==String(J);return D&&K&&y(T),D?T:J}else return J})}return s.jsx(wme,{scope:e.__scopeSlider,name:n,disabled:c,min:r,max:a,valueIndexToChangeRef:j,thumbs:x.current,values:P,orientation:o,form:S,children:s.jsx(cj.Provider,{scope:e.__scopeSlider,children:s.jsx(cj.Slot,{scope:e.__scopeSlider,children:s.jsx(_,{"aria-disabled":c,"data-disabled":c?"":void 0,...b,ref:t,onPointerDown:Ae(b.onPointerDown,()=>{c||(O.current=P)}),min:r,max:a,inverted:g,onSlideStart:c?void 0:k,onSlideMove:c?void 0:R,onSlideEnd:c?void 0:$,onHomeKeyDown:()=>!c&&z(r,0,{commit:!0}),onEndKeyDown:()=>!c&&z(a,P.length-1,{commit:!0}),onStepKeyDown:({event:B,direction:L})=>{if(!c){const V=O8.includes(B.key)||B.shiftKey&&k8.includes(B.key)?10:1,X=j.current,J=P[X],T=i*V*L;z(J+T,X,{commit:!0})}}})})})})});I8.displayName=Uc;var[M8,$8]=T8(Uc,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Sme=v.forwardRef((e,t)=>{const{min:n,max:r,dir:a,inverted:i,onSlideStart:o,onSlideMove:c,onSlideEnd:d,onStepKeyDown:f,...h}=e,[p,y]=v.useState(null),g=ut(t,_=>y(_)),S=v.useRef(void 0),b=Lc(a),x=b==="ltr",j=x&&!i||!x&&i;function N(_){const P=S.current||p.getBoundingClientRect(),A=[0,P.width],k=uC(A,j?[n,r]:[r,n]);return S.current=P,k(_-P.left)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:j?"left":"right",endEdge:j?"right":"left",direction:j?1:-1,size:"width",children:s.jsx(D8,{dir:b,"data-orientation":"horizontal",...h,ref:g,style:{...h.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:_=>{const P=N(_.clientX);o?.(P)},onSlideMove:_=>{const P=N(_.clientX);c?.(P)},onSlideEnd:()=>{S.current=void 0,d?.()},onStepKeyDown:_=>{const A=R8[j?"from-left":"from-right"].includes(_.key);f?.({event:_,direction:A?-1:1})}})})}),jme=v.forwardRef((e,t)=>{const{min:n,max:r,inverted:a,onSlideStart:i,onSlideMove:o,onSlideEnd:c,onStepKeyDown:d,...f}=e,h=v.useRef(null),p=ut(t,h),y=v.useRef(void 0),g=!a;function S(b){const x=y.current||h.current.getBoundingClientRect(),j=[0,x.height],_=uC(j,g?[r,n]:[n,r]);return y.current=x,_(b-x.top)}return s.jsx(M8,{scope:e.__scopeSlider,startEdge:g?"bottom":"top",endEdge:g?"top":"bottom",size:"height",direction:g?1:-1,children:s.jsx(D8,{"data-orientation":"vertical",...f,ref:p,style:{...f.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:b=>{const x=S(b.clientY);i?.(x)},onSlideMove:b=>{const x=S(b.clientY);o?.(x)},onSlideEnd:()=>{y.current=void 0,c?.()},onStepKeyDown:b=>{const j=R8[g?"from-bottom":"from-top"].includes(b.key);d?.({event:b,direction:j?-1:1})}})})}),D8=v.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:a,onSlideEnd:i,onHomeKeyDown:o,onEndKeyDown:c,onStepKeyDown:d,...f}=e,h=Yv(Uc,n);return s.jsx(De.span,{...f,ref:t,onKeyDown:Ae(e.onKeyDown,p=>{p.key==="Home"?(o(p),p.preventDefault()):p.key==="End"?(c(p),p.preventDefault()):O8.concat(k8).includes(p.key)&&(d(p),p.preventDefault())}),onPointerDown:Ae(e.onPointerDown,p=>{const y=p.target;y.setPointerCapture(p.pointerId),p.preventDefault(),h.thumbs.has(y)?y.focus():r(p)}),onPointerMove:Ae(e.onPointerMove,p=>{p.target.hasPointerCapture(p.pointerId)&&a(p)}),onPointerUp:Ae(e.onPointerUp,p=>{const y=p.target;y.hasPointerCapture(p.pointerId)&&(y.releasePointerCapture(p.pointerId),i(p))})})}),L8="SliderTrack",F8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(L8,n);return s.jsx(De.span,{"data-disabled":a.disabled?"":void 0,"data-orientation":a.orientation,...r,ref:t})});F8.displayName=L8;var uj="SliderRange",B8=v.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,a=Yv(uj,n),i=$8(uj,n),o=v.useRef(null),c=ut(t,o),d=a.values.length,f=a.values.map(y=>q8(y,a.min,a.max)),h=d>1?Math.min(...f):0,p=100-Math.max(...f);return s.jsx(De.span,{"data-orientation":a.orientation,"data-disabled":a.disabled?"":void 0,...r,ref:c,style:{...e.style,[i.startEdge]:h+"%",[i.endEdge]:p+"%"}})});B8.displayName=uj;var dj="SliderThumb",z8=v.forwardRef((e,t)=>{const n=xme(e.__scopeSlider),[r,a]=v.useState(null),i=ut(t,c=>a(c)),o=v.useMemo(()=>r?n().findIndex(c=>c.ref.current===r):-1,[n,r]);return s.jsx(Nme,{...e,ref:i,index:o})}),Nme=v.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:a,...i}=e,o=Yv(dj,n),c=$8(dj,n),[d,f]=v.useState(null),h=ut(t,N=>f(N)),p=d?o.form||!!d.closest("form"):!0,y=km(d),g=o.values[r],S=g===void 0?0:q8(g,o.min,o.max),b=Ame(r,o.values.length),x=y?.[c.size],j=x?Pme(x,S,c.direction):0;return v.useEffect(()=>{if(d)return o.thumbs.add(d),()=>{o.thumbs.delete(d)}},[d,o.thumbs]),s.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[c.startEdge]:`calc(${S}% + ${j}px)`},children:[s.jsx(cj.ItemSlot,{scope:e.__scopeSlider,children:s.jsx(De.span,{role:"slider","aria-label":e["aria-label"]||b,"aria-valuemin":o.min,"aria-valuenow":g,"aria-valuemax":o.max,"aria-orientation":o.orientation,"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,tabIndex:o.disabled?void 0:0,...i,ref:h,style:g===void 0?{display:"none"}:e.style,onFocus:Ae(e.onFocus,()=>{o.valueIndexToChangeRef.current=r})})}),p&&s.jsx(U8,{name:a??(o.name?o.name+(o.values.length>1?"[]":""):void 0),form:o.form,value:g},r)]})});z8.displayName=dj;var Cme="RadioBubbleInput",U8=v.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const a=v.useRef(null),i=ut(a,r),o=Fv(t);return v.useEffect(()=>{const c=a.current;if(!c)return;const d=window.HTMLInputElement.prototype,h=Object.getOwnPropertyDescriptor(d,"value").set;if(o!==t&&h){const p=new Event("input",{bubbles:!0});h.call(c,t),c.dispatchEvent(p)}},[o,t]),s.jsx(De.input,{style:{display:"none"},...n,ref:i,defaultValue:t})});U8.displayName=Cme;function _me(e=[],t,n){const r=[...e];return r[n]=t,r.sort((a,i)=>a-i)}function q8(e,t,n){const i=100/(n-t)*(e-t);return Vd(i,[0,100])}function Ame(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function Eme(e,t){if(e.length===1)return 0;const n=e.map(a=>Math.abs(a-t)),r=Math.min(...n);return n.indexOf(r)}function Pme(e,t,n){const r=e/2,i=uC([0,50],[0,r]);return(r-i(t)*n)*n}function Ome(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function kme(e,t){if(t>0){const n=Ome(e);return Math.min(...n)>=t}return!0}function uC(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function Rme(e){return(String(e).split(".")[1]||"").length}function Tme(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var W8=I8,Ime=F8,Mme=B8,$me=z8;const V8=v.forwardRef(({className:e,...t},n)=>s.jsxs(W8,{ref:n,className:Se("relative flex w-full touch-none select-none items-center",e),...t,children:[s.jsx(Ime,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:s.jsx(Mme,{className:"absolute h-full bg-primary"})}),s.jsx($me,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));V8.displayName=W8.displayName;function Dme(e){const t=Lme(e),n=v.forwardRef((r,a)=>{const{children:i,...o}=r,c=v.Children.toArray(i),d=c.find(Bme);if(d){const f=d.props.children,h=c.map(p=>p===d?v.Children.count(f)>1?v.Children.only(null):v.isValidElement(f)?f.props.children:null:p);return s.jsx(t,{...o,ref:a,children:v.isValidElement(f)?v.cloneElement(f,void 0,h):null})}return s.jsx(t,{...o,ref:a,children:i})});return n.displayName=`${e}.Slot`,n}function Lme(e){const t=v.forwardRef((n,r)=>{const{children:a,...i}=n;if(v.isValidElement(a)){const o=Ume(a),c=zme(i,a.props);return a.type!==v.Fragment&&(c.ref=r?jr(r,o):o),v.cloneElement(a,c)}return v.Children.count(a)>1?v.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var Fme=Symbol("radix.slottable");function Bme(e){return v.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===Fme}function zme(e,t){const n={...t};for(const r in t){const a=e[r],i=t[r];/^on[A-Z]/.test(r)?a&&i?n[r]=(...c)=>{const d=i(...c);return a(...c),d}:a&&(n[r]=a):r==="style"?n[r]={...a,...i}:r==="className"&&(n[r]=[a,i].filter(Boolean).join(" "))}return{...e,...n}}function Ume(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Xv="Popover",[H8]=ir(Xv,[Di]),vf=Di(),[qme,Vi]=H8(Xv),K8=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:a,onOpenChange:i,modal:o=!1}=e,c=vf(t),d=v.useRef(null),[f,h]=v.useState(!1),[p,y]=na({prop:r,defaultProp:a??!1,onChange:i,caller:Xv});return s.jsx(Rm,{...c,children:s.jsx(qme,{scope:t,contentId:Hn(),triggerRef:d,open:p,onOpenChange:y,onOpenToggle:v.useCallback(()=>y(g=>!g),[y]),hasCustomAnchor:f,onCustomAnchorAdd:v.useCallback(()=>h(!0),[]),onCustomAnchorRemove:v.useCallback(()=>h(!1),[]),modal:o,children:n})})};K8.displayName=Xv;var G8="PopoverAnchor",Wme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(G8,n),i=vf(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:c}=a;return v.useEffect(()=>(o(),()=>c()),[o,c]),s.jsx(Yd,{...i,...r,ref:t})});Wme.displayName=G8;var Y8="PopoverTrigger",X8=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(Y8,n),i=vf(n),o=ut(t,a.triggerRef),c=s.jsx(De.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":tz(a.open),...r,ref:o,onClick:Ae(e.onClick,a.onOpenToggle)});return a.hasCustomAnchor?c:s.jsx(Yd,{asChild:!0,...i,children:c})});X8.displayName=Y8;var dC="PopoverPortal",[Vme,Hme]=H8(dC,{forceMount:void 0}),Q8=e=>{const{__scopePopover:t,forceMount:n,children:r,container:a}=e,i=Vi(dC,t);return s.jsx(Vme,{scope:t,forceMount:n,children:s.jsx(Gn,{present:n||i.open,children:s.jsx(Sc,{asChild:!0,container:a,children:r})})})};Q8.displayName=dC;var bc="PopoverContent",J8=v.forwardRef((e,t)=>{const n=Hme(bc,e.__scopePopover),{forceMount:r=n.forceMount,...a}=e,i=Vi(bc,e.__scopePopover);return s.jsx(Gn,{present:r||i.open,children:i.modal?s.jsx(Gme,{...a,ref:t}):s.jsx(Yme,{...a,ref:t})})});J8.displayName=bc;var Kme=Dme("PopoverContent.RemoveScroll"),Gme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(null),a=ut(t,r),i=v.useRef(!1);return v.useEffect(()=>{const o=r.current;if(o)return Hm(o)},[]),s.jsx(Qd,{as:Kme,allowPinchZoom:!0,children:s.jsx(Z8,{...e,ref:a,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ae(e.onCloseAutoFocus,o=>{o.preventDefault(),i.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Ae(e.onPointerDownOutside,o=>{const c=o.detail.originalEvent,d=c.button===0&&c.ctrlKey===!0,f=c.button===2||d;i.current=f},{checkForDefaultPrevented:!1}),onFocusOutside:Ae(e.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})})}),Yme=v.forwardRef((e,t)=>{const n=Vi(bc,e.__scopePopover),r=v.useRef(!1),a=v.useRef(!1);return s.jsx(Z8,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(r.current||n.triggerRef.current?.focus(),i.preventDefault()),r.current=!1,a.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(a.current=!0));const o=i.target;n.triggerRef.current?.contains(o)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),Z8=v.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:a,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:h,...p}=e,y=Vi(bc,n),g=vf(n);return Wm(),s.jsx(Xd,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:a,onUnmountAutoFocus:i,children:s.jsx(To,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:h,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:f,onDismiss:()=>y.onOpenChange(!1),children:s.jsx(Tm,{"data-state":tz(y.open),role:"dialog",id:y.contentId,...g,...p,ref:t,style:{...p.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),ez="PopoverClose",Xme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=Vi(ez,n);return s.jsx(De.button,{type:"button",...r,ref:t,onClick:Ae(e.onClick,()=>a.onOpenChange(!1))})});Xme.displayName=ez;var Qme="PopoverArrow",Jme=v.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,a=vf(n);return s.jsx(Im,{...a,...r,ref:t})});Jme.displayName=Qme;function tz(e){return e?"open":"closed"}var Zme=K8,eve=X8,tve=Q8,nz=J8;const nve=Zme,rve=eve,rz=v.forwardRef(({className:e,align:t="center",sideOffset:n=4,...r},a)=>s.jsx(tve,{children:s.jsx(nz,{ref:a,align:t,sideOffset:n,className:Se("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none 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 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",e),...r})}));rz.displayName=nz.displayName;var nM=1,ave=.9,sve=.8,ive=.17,r1=.1,a1=.999,ove=.9999,lve=.99,cve=/[\\\/_+.#"@\[\(\{&]/,uve=/[\\\/_+.#"@\[\(\{&]/g,dve=/[\s-]/,az=/[\s-]/g;function fj(e,t,n,r,a,i,o){if(i===t.length)return a===e.length?nM:lve;var c=`${a},${i}`;if(o[c]!==void 0)return o[c];for(var d=r.charAt(i),f=n.indexOf(d,a),h=0,p,y,g,S;f>=0;)p=fj(e,t,n,r,f+1,i+1,o),p>h&&(f===a?p*=nM:cve.test(e.charAt(f-1))?(p*=sve,g=e.slice(a,f-1).match(uve),g&&a>0&&(p*=Math.pow(a1,g.length))):dve.test(e.charAt(f-1))?(p*=ave,S=e.slice(a,f-1).match(az),S&&a>0&&(p*=Math.pow(a1,S.length))):(p*=ive,a>0&&(p*=Math.pow(a1,f-a))),e.charAt(f)!==t.charAt(i)&&(p*=ove)),(p<r1&&n.charAt(f-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(f-1)!==r.charAt(i))&&(y=fj(e,t,n,r,f+1,i+2,o),y*r1>p&&(p=y*r1)),p>h&&(h=p),f=n.indexOf(d,f+1);return o[c]=h,h}function rM(e){return e.toLowerCase().replace(az," ")}function fve(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,fj(e,t,rM(e),rM(t),0,0,{})}var Du='[cmdk-group=""]',s1='[cmdk-group-items=""]',pve='[cmdk-group-heading=""]',sz='[cmdk-item=""]',aM=`${sz}:not([aria-disabled="true"])`,pj="cmdk-item-select",Sl="data-value",hve=(e,t,n)=>fve(e,t,n),iz=v.createContext(void 0),gf=()=>v.useContext(iz),oz=v.createContext(void 0),fC=()=>v.useContext(oz),lz=v.createContext(void 0),cz=v.forwardRef((e,t)=>{let n=jl(()=>{var M,ee;return{search:"",value:(ee=(M=e.value)!=null?M:e.defaultValue)!=null?ee:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=jl(()=>new Set),a=jl(()=>new Map),i=jl(()=>new Map),o=jl(()=>new Set),c=uz(e),{label:d,children:f,value:h,onValueChange:p,filter:y,shouldFilter:g,loop:S,disablePointerSelection:b=!1,vimBindings:x=!0,...j}=e,N=Hn(),_=Hn(),P=Hn(),A=v.useRef(null),O=Cve();Ro(()=>{if(h!==void 0){let M=h.trim();n.current.value=M,k.emit()}},[h]),Ro(()=>{O(6,K)},[]);let k=v.useMemo(()=>({subscribe:M=>(o.current.add(M),()=>o.current.delete(M)),snapshot:()=>n.current,setState:(M,ee,W)=>{var Z,ye,ae,ue;if(!Object.is(n.current[M],ee)){if(n.current[M]=ee,M==="search")L(),z(),O(1,B);else if(M==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let ie=document.getElementById(P);ie?ie.focus():(Z=document.getElementById(N))==null||Z.focus()}if(O(7,()=>{var ie;n.current.selectedItemId=(ie=U())==null?void 0:ie.id,k.emit()}),W||O(5,K),((ye=c.current)==null?void 0:ye.value)!==void 0){let ie=ee??"";(ue=(ae=c.current).onValueChange)==null||ue.call(ae,ie);return}}k.emit()}},emit:()=>{o.current.forEach(M=>M())}}),[]),R=v.useMemo(()=>({value:(M,ee,W)=>{var Z;ee!==((Z=i.current.get(M))==null?void 0:Z.value)&&(i.current.set(M,{value:ee,keywords:W}),n.current.filtered.items.set(M,$(ee,W)),O(2,()=>{z(),k.emit()}))},item:(M,ee)=>(r.current.add(M),ee&&(a.current.has(ee)?a.current.get(ee).add(M):a.current.set(ee,new Set([M]))),O(3,()=>{L(),z(),n.current.value||B(),k.emit()}),()=>{i.current.delete(M),r.current.delete(M),n.current.filtered.items.delete(M);let W=U();O(4,()=>{L(),W?.getAttribute("id")===M&&B(),k.emit()})}),group:M=>(a.current.has(M)||a.current.set(M,new Set),()=>{i.current.delete(M),a.current.delete(M)}),filter:()=>c.current.shouldFilter,label:d||e["aria-label"],getDisablePointerSelection:()=>c.current.disablePointerSelection,listId:N,inputId:P,labelId:_,listInnerRef:A}),[]);function $(M,ee){var W,Z;let ye=(Z=(W=c.current)==null?void 0:W.filter)!=null?Z:hve;return M?ye(M,n.current.search,ee):0}function z(){if(!n.current.search||c.current.shouldFilter===!1)return;let M=n.current.filtered.items,ee=[];n.current.filtered.groups.forEach(Z=>{let ye=a.current.get(Z),ae=0;ye.forEach(ue=>{let ie=M.get(ue);ae=Math.max(ie,ae)}),ee.push([Z,ae])});let W=A.current;V().sort((Z,ye)=>{var ae,ue;let ie=Z.getAttribute("id"),ve=ye.getAttribute("id");return((ae=M.get(ve))!=null?ae:0)-((ue=M.get(ie))!=null?ue:0)}).forEach(Z=>{let ye=Z.closest(s1);ye?ye.appendChild(Z.parentElement===ye?Z:Z.closest(`${s1} > *`)):W.appendChild(Z.parentElement===W?Z:Z.closest(`${s1} > *`))}),ee.sort((Z,ye)=>ye[1]-Z[1]).forEach(Z=>{var ye;let ae=(ye=A.current)==null?void 0:ye.querySelector(`${Du}[${Sl}="${encodeURIComponent(Z[0])}"]`);ae?.parentElement.appendChild(ae)})}function B(){let M=V().find(W=>W.getAttribute("aria-disabled")!=="true"),ee=M?.getAttribute(Sl);k.setState("value",ee||void 0)}function L(){var M,ee,W,Z;if(!n.current.search||c.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ye=0;for(let ae of r.current){let ue=(ee=(M=i.current.get(ae))==null?void 0:M.value)!=null?ee:"",ie=(Z=(W=i.current.get(ae))==null?void 0:W.keywords)!=null?Z:[],ve=$(ue,ie);n.current.filtered.items.set(ae,ve),ve>0&&ye++}for(let[ae,ue]of a.current)for(let ie of ue)if(n.current.filtered.items.get(ie)>0){n.current.filtered.groups.add(ae);break}n.current.filtered.count=ye}function K(){var M,ee,W;let Z=U();Z&&(((M=Z.parentElement)==null?void 0:M.firstChild)===Z&&((W=(ee=Z.closest(Du))==null?void 0:ee.querySelector(pve))==null||W.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function U(){var M;return(M=A.current)==null?void 0:M.querySelector(`${sz}[aria-selected="true"]`)}function V(){var M;return Array.from(((M=A.current)==null?void 0:M.querySelectorAll(aM))||[])}function X(M){let ee=V()[M];ee&&k.setState("value",ee.getAttribute(Sl))}function J(M){var ee;let W=U(),Z=V(),ye=Z.findIndex(ue=>ue===W),ae=Z[ye+M];(ee=c.current)!=null&&ee.loop&&(ae=ye+M<0?Z[Z.length-1]:ye+M===Z.length?Z[0]:Z[ye+M]),ae&&k.setState("value",ae.getAttribute(Sl))}function T(M){let ee=U(),W=ee?.closest(Du),Z;for(;W&&!Z;)W=M>0?jve(W,Du):Nve(W,Du),Z=W?.querySelector(aM);Z?k.setState("value",Z.getAttribute(Sl)):J(M)}let D=()=>X(V().length-1),Q=M=>{M.preventDefault(),M.metaKey?D():M.altKey?T(1):J(1)},F=M=>{M.preventDefault(),M.metaKey?X(0):M.altKey?T(-1):J(-1)};return v.createElement(De.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:M=>{var ee;(ee=j.onKeyDown)==null||ee.call(j,M);let W=M.nativeEvent.isComposing||M.keyCode===229;if(!(M.defaultPrevented||W))switch(M.key){case"n":case"j":{x&&M.ctrlKey&&Q(M);break}case"ArrowDown":{Q(M);break}case"p":case"k":{x&&M.ctrlKey&&F(M);break}case"ArrowUp":{F(M);break}case"Home":{M.preventDefault(),X(0);break}case"End":{M.preventDefault(),D();break}case"Enter":{M.preventDefault();let Z=U();if(Z){let ye=new Event(pj);Z.dispatchEvent(ye)}}}}},v.createElement("label",{"cmdk-label":"",htmlFor:R.inputId,id:R.labelId,style:Ave},d),Qv(e,M=>v.createElement(oz.Provider,{value:k},v.createElement(iz.Provider,{value:R},M))))}),mve=v.forwardRef((e,t)=>{var n,r;let a=Hn(),i=v.useRef(null),o=v.useContext(lz),c=gf(),d=uz(e),f=(r=(n=d.current)==null?void 0:n.forceMount)!=null?r:o?.forceMount;Ro(()=>{if(!f)return c.item(a,o?.id)},[f]);let h=dz(a,i,[e.value,e.children,i],e.keywords),p=fC(),y=$i(O=>O.value&&O.value===h.current),g=$i(O=>f||c.filter()===!1?!0:O.search?O.filtered.items.get(a)>0:!0);v.useEffect(()=>{let O=i.current;if(!(!O||e.disabled))return O.addEventListener(pj,S),()=>O.removeEventListener(pj,S)},[g,e.onSelect,e.disabled]);function S(){var O,k;b(),(k=(O=d.current).onSelect)==null||k.call(O,h.current)}function b(){p.setState("value",h.current,!0)}if(!g)return null;let{disabled:x,value:j,onSelect:N,forceMount:_,keywords:P,...A}=e;return v.createElement(De.div,{ref:jr(i,t),...A,id:a,"cmdk-item":"",role:"option","aria-disabled":!!x,"aria-selected":!!y,"data-disabled":!!x,"data-selected":!!y,onPointerMove:x||c.getDisablePointerSelection()?void 0:b,onClick:x?void 0:S},e.children)}),vve=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...i}=e,o=Hn(),c=v.useRef(null),d=v.useRef(null),f=Hn(),h=gf(),p=$i(g=>a||h.filter()===!1?!0:g.search?g.filtered.groups.has(o):!0);Ro(()=>h.group(o),[]),dz(o,c,[e.value,e.heading,d]);let y=v.useMemo(()=>({id:o,forceMount:a}),[a]);return v.createElement(De.div,{ref:jr(c,t),...i,"cmdk-group":"",role:"presentation",hidden:p?void 0:!0},n&&v.createElement("div",{ref:d,"cmdk-group-heading":"","aria-hidden":!0,id:f},n),Qv(e,g=>v.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?f:void 0},v.createElement(lz.Provider,{value:y},g))))}),gve=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=v.useRef(null),i=$i(o=>!o.search);return!n&&!i?null:v.createElement(De.div,{ref:jr(a,t),...r,"cmdk-separator":"",role:"separator"})}),yve=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,a=e.value!=null,i=fC(),o=$i(f=>f.search),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{e.value!=null&&i.setState("search",e.value)},[e.value]),v.createElement(De.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":d.listId,"aria-labelledby":d.labelId,"aria-activedescendant":c,id:d.inputId,type:"text",value:a?e.value:o,onChange:f=>{a||i.setState("search",f.target.value),n?.(f.target.value)}})}),xve=v.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...a}=e,i=v.useRef(null),o=v.useRef(null),c=$i(f=>f.selectedItemId),d=gf();return v.useEffect(()=>{if(o.current&&i.current){let f=o.current,h=i.current,p,y=new ResizeObserver(()=>{p=requestAnimationFrame(()=>{let g=f.offsetHeight;h.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return y.observe(f),()=>{cancelAnimationFrame(p),y.unobserve(f)}}},[]),v.createElement(De.div,{ref:jr(i,t),...a,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":c,"aria-label":r,id:d.listId},Qv(e,f=>v.createElement("div",{ref:jr(o,d.listInnerRef),"cmdk-list-sizer":""},f)))}),bve=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:a,contentClassName:i,container:o,...c}=e;return v.createElement(Gm,{open:n,onOpenChange:r},v.createElement(Ym,{container:o},v.createElement(Pc,{"cmdk-overlay":"",className:a}),v.createElement(Oc,{"aria-label":e.label,"cmdk-dialog":"",className:i},v.createElement(cz,{ref:t,...c}))))}),wve=v.forwardRef((e,t)=>$i(n=>n.filtered.count===0)?v.createElement(De.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Sve=v.forwardRef((e,t)=>{let{progress:n,children:r,label:a="Loading...",...i}=e;return v.createElement(De.div,{ref:t,...i,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":a},Qv(e,o=>v.createElement("div",{"aria-hidden":!0},o)))}),$r=Object.assign(cz,{List:xve,Item:mve,Input:yve,Group:vve,Separator:gve,Dialog:bve,Empty:wve,Loading:Sve});function jve(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Nve(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function uz(e){let t=v.useRef(e);return Ro(()=>{t.current=e}),t}var Ro=typeof window>"u"?v.useEffect:v.useLayoutEffect;function jl(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function $i(e){let t=fC(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function dz(e,t,n,r=[]){let a=v.useRef(),i=gf();return Ro(()=>{var o;let c=(()=>{var f;for(let h of n){if(typeof h=="string")return h.trim();if(typeof h=="object"&&"current"in h)return h.current?(f=h.current.textContent)==null?void 0:f.trim():a.current}})(),d=r.map(f=>f.trim());i.value(e,c,d),(o=t.current)==null||o.setAttribute(Sl,c),a.current=c}),a}var Cve=()=>{let[e,t]=v.useState(),n=jl(()=>new Map);return Ro(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,a)=>{n.current.set(r,a),t({})}};function _ve(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function Qv({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(_ve(t),{ref:t.ref},n(t.props.children)):n(t)}var Ave={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const fz=v.forwardRef(({className:e,...t},n)=>s.jsx($r,{ref:n,className:Se("flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",e),...t}));fz.displayName=$r.displayName;const pz=v.forwardRef(({className:e,...t},n)=>s.jsxs("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[s.jsx(Sj,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),s.jsx($r.Input,{ref:n,className:Se("flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...t})]}));pz.displayName=$r.Input.displayName;const hz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.List,{ref:n,className:Se("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...t}));hz.displayName=$r.List.displayName;const mz=v.forwardRef((e,t)=>s.jsx($r.Empty,{ref:t,className:"py-6 text-center text-sm",...e}));mz.displayName=$r.Empty.displayName;const vz=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Group,{ref:n,className:Se("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",e),...t}));vz.displayName=$r.Group.displayName;const Eve=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Separator,{ref:n,className:Se("-mx-1 h-px bg-border",e),...t}));Eve.displayName=$r.Separator.displayName;const hj=v.forwardRef(({className:e,...t},n)=>s.jsx($r.Item,{ref:n,className:Se("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[disabled=true]:pointer-events-none data-[selected='true']:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:opacity-50",e),...t}));hj.displayName=$r.Item.displayName;const sM={openai:["gpt-4o","gpt-4o-mini","gpt-4-turbo","o1","o1-mini"],anthropic:["claude-3-5-sonnet-latest","claude-3-5-haiku-latest","claude-3-opus-latest"],azure:["gpt-4o","gpt-4-turbo"],google:["gemini-2.0-flash","gemini-1.5-pro"],custom:[]},iM={anthropic:"Check that `ANTHROPIC_API_KEY` is set in your environment",openai:"Check that `OPENAI_API_KEY` is set in your environment",azure:"Check that Azure OpenAI env vars are configured in your environment"},Pve=()=>({id:`agt-${Date.now()}`,name:"",provider:"openai",model:"gpt-4o",temperature:0,maxTokens:4096}),Ove=()=>{const{agentName:e}=Mo(),t=wa(),{agents:n,setAgents:r}=qa(),{source:a}=On(),i=e==="new",o=e?decodeURIComponent(e):"",c=i?null:n.find(T=>T.id===o)??n.find(T=>T.name===o),[d,f]=v.useState(()=>c??Pve()),[h,p]=v.useState(!1),[y,g]=v.useState(!1),[S,b]=v.useState({status:"idle"}),[x,j]=v.useState(!1),[N,_]=v.useState([]),[P,A]=v.useState(!1),[O,k]=v.useState(!1),[R,$]=v.useState(!1);v.useEffect(()=>{c&&f(c)},[c]);const z=d.provider==="anthropic"||d.provider==="openai"||d.provider==="azure",B=Array.from(new Set([...sM[d.provider]||[],...N])),L=B.includes(d.model),K=R||!!d.model&&!L,U=async()=>{if(j(!0),d.provider==="google"||d.provider==="custom"){b({status:"unsupported"});return}b({status:"loading"});try{const T=await a.listProviderModels(d.provider);b({status:"success",items:T.items,source:T.source,kind:T.kind,testedAt:new Date().toISOString()})}catch(T){b({status:"error",message:T instanceof Error?T.message:String(T),testedAt:new Date().toISOString()})}},V=async()=>{if(!z){Pe({title:"Provider discovery not supported",description:"Model discovery is available for Anthropic, OpenAI, and Azure OpenAI."});return}A(!0);try{const T=await a.listProviderModels(d.provider);_(T.items),Pe({title:T.kind==="deployments"?"Deployments loaded":"Models loaded",description:`${T.items.length} ${T.kind} from ${T.source}`})}catch(T){Pe({title:"Could not load provider models",description:String(T instanceof Error?T.message:T),variant:"destructive"})}finally{A(!1)}},X=async()=>{if(!d.name.trim()){Pe({title:"Name is required",variant:"destructive"});return}g(!0);try{if(i)await r([...n,d]),Pe({title:"Agent created"}),t(`/libraries/agents/${encodeURIComponent(d.id)}`);else{const T=n.map(D=>D.id===c?.id?d:D);await r(T),Pe({title:"Agent saved"}),d.id!==o&&t(`/libraries/agents/${encodeURIComponent(d.id)}`,{replace:!0})}}finally{g(!1)}},J=async()=>{const T=n.filter(D=>D.id!==c?.id);await r(T),Pe({title:"Agent deleted"}),t("/libraries/agents")};return!i&&!c?s.jsxs("div",{className:"space-y-4",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:['Agent "',o,'" not found.']})]}):s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsxs(yt,{to:"/libraries/agents",className:"inline-flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground",children:[s.jsx(xo,{className:"h-4 w-4"})," Agents"]}),s.jsx("h1",{className:"text-2xl font-bold",children:i?"New Agent":d.name})]}),!i&&s.jsxs(se,{type:"button",onClick:()=>{U()},children:[s.jsx(c$,{className:"mr-2 h-4 w-4"}),"Test Connection"]})]}),x&&s.jsxs(Be,{children:[s.jsxs(Ct,{className:"flex-row items-center justify-between space-y-0",children:[s.jsx(_t,{className:"text-base",children:"Connection Test"}),s.jsx("button",{type:"button",onClick:()=>j(!1),className:"rounded-sm opacity-70 hover:opacity-100",children:s.jsx(Ti,{className:"h-4 w-4"})})]}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted-foreground",children:[s.jsx("span",{children:"Provider:"}),s.jsx("span",{className:"font-medium text-foreground",children:d.provider}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:"Endpoint:"}),s.jsxs("code",{className:"font-mono text-xs",children:["/api/providers/models?provider=",d.provider]})]}),S.status==="loading"&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Testing connection..."]}),S.status==="success"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("p",{className:"flex items-center gap-2 text-sm text-emerald-700",children:[s.jsx(ql,{className:"h-4 w-4 shrink-0"}),"Connected — discovered ",S.items.length," ",S.kind," from"," ",S.source]}),s.jsxs("div",{className:"rounded-md bg-muted p-3",children:[s.jsxs("p",{className:"mb-1 text-xs font-medium text-muted-foreground",children:["First 5 ",S.kind,":"]}),s.jsx("ul",{className:"space-y-0.5",children:S.items.slice(0,5).map(T=>s.jsx("li",{className:"font-mono text-xs",children:T},T))})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="error"&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm text-destructive",children:[s.jsx("span",{className:"font-medium",children:"✗ Connection failed"})," —"," ",S.message]}),iM[d.provider]&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-xs text-muted-foreground",children:["Hint: ",iM[d.provider]]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Tested at ",new Date(S.testedAt).toLocaleString()]})]}),S.status==="unsupported"&&s.jsxs("p",{className:"rounded-md bg-muted px-3 py-2 text-sm text-muted-foreground",children:["Connection testing is not supported for the"," ",s.jsx("span",{className:"font-medium",children:d.provider})," provider. Supported providers: Anthropic, OpenAI, Azure OpenAI."]})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Configuration"})}),s.jsxs(ze,{className:"space-y-4",children:[s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Name"}),s.jsx(ht,{value:d.name,onChange:T=>f(D=>({...D,name:T.target.value})),placeholder:"e.g. GPT-4o"})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Provider"}),s.jsxs(sn,{value:d.provider,onValueChange:T=>f(D=>({...D,provider:T,model:sM[T]?.[0]||""})),children:[s.jsx(Jt,{children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"openai",children:"OpenAI"}),s.jsx(at,{value:"anthropic",children:"Anthropic"}),s.jsx(at,{value:"azure",children:"Azure OpenAI"}),s.jsx(at,{value:"google",children:"Google"}),s.jsx(at,{value:"custom",children:"Custom"})]})]})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:d.provider==="azure"?"Deployment":"Model"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(nve,{open:O,onOpenChange:k,children:[s.jsx(rve,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"outline",role:"combobox","aria-expanded":O,className:"h-9 flex-1 justify-between font-mono text-xs",children:[s.jsx("span",{className:"truncate text-left",children:d.model||"Select model..."}),s.jsx(qt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),s.jsx(rz,{className:"w-[420px] p-0",align:"start",children:s.jsxs(fz,{children:[s.jsx(pz,{placeholder:`Search ${d.provider==="azure"?"deployments":"models"}...`}),s.jsxs(hz,{children:[s.jsxs(mz,{children:["No ",d.provider==="azure"?"deployments":"models"," found."]}),s.jsxs(vz,{heading:d.provider==="azure"?"Deployments":"Models",children:[B.map(T=>s.jsxs(hj,{value:T,onSelect:D=>{f(Q=>({...Q,model:D})),$(!1),k(!1)},children:[s.jsx(ql,{className:Se("mr-2 h-4 w-4",d.model===T?"opacity-100":"opacity-0")}),s.jsx("span",{className:"font-mono text-xs",children:T})]},T)),s.jsx(hj,{value:"__custom_model_id__",onSelect:()=>{$(!0),k(!1)},children:s.jsx("span",{className:"font-medium",children:d.provider==="azure"?"Custom deployment ID...":"Custom model ID..."})})]})]})]})})]}),z&&s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-9 shrink-0 text-xs",onClick:()=>{V()},disabled:P,title:d.provider==="azure"?"Fetch Azure OpenAI deployments":`Fetch ${d.provider} models`,children:[P?s.jsx(sr,{className:"mr-1 h-3 w-3 animate-spin"}):s.jsx(Fa,{className:"mr-1 h-3 w-3"}),d.provider==="azure"?"Fetch Deployments":"Fetch Models"]})]}),K&&s.jsx(ht,{value:d.model,onChange:T=>f(D=>({...D,model:T.target.value})),placeholder:d.provider==="azure"?"Type deployment name manually":"Type model name manually",className:"font-mono text-xs"}),N.length>0&&s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Loaded ",N.length," ",d.provider==="azure"?"deployment names":"models"," from provider discovery."]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Max Tokens"}),s.jsx(ht,{type:"number",min:1,max:128e3,value:d.maxTokens,onChange:T=>f(D=>({...D,maxTokens:parseInt(T.target.value)||0})),className:"font-mono text-xs"})]})]}),s.jsx("div",{className:"grid gap-4 sm:grid-cols-2",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"Max Turns"}),s.jsx(ht,{type:"number",min:1,max:50,value:d.maxTurns??"",onChange:T=>{const D=T.target.value.trim();f(Q=>({...Q,maxTurns:D&&parseInt(D)||void 0}))},placeholder:"30 (default)",className:"font-mono text-xs"}),s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Maximum number of LLM round-trips (tool calls + final answer) per eval run."})]})}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(Me,{children:"Temperature"}),s.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:d.temperature.toFixed(2)})]}),s.jsx(V8,{value:[d.temperature],onValueChange:([T])=>f(D=>({...D,temperature:T})),min:0,max:2,step:.01})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{children:"System Prompt"}),s.jsx(Ks,{value:d.systemPrompt||"",onChange:T=>f(D=>({...D,systemPrompt:T.target.value})),placeholder:"Optional system prompt...",rows:3,className:"text-xs"})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("div",{children:!i&&s.jsx(se,{type:"button",variant:"destructive",size:"sm",onClick:()=>p(!0),children:"Delete"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{type:"button",variant:"outline",size:"sm",onClick:()=>t("/libraries/agents"),children:"Cancel"}),s.jsxs(se,{type:"button",size:"sm",onClick:()=>{X()},disabled:y,children:[y&&s.jsx(sr,{className:"mr-2 h-4 w-4 animate-spin"}),i?"Create Agent":"Save"]})]})]})]})]}),s.jsx(bs,{open:h,onOpenChange:p,children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete agent?"}),s.jsxs(Ya,{children:["This will permanently remove the agent"," ",s.jsx("span",{className:"font-mono",children:d.name}),". This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{onClick:()=>{J()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})})]})},oM="mcplab.resultAssistantScenarioHandoff",lM=()=>{const{testCaseId:e}=Mo(),[t,n]=Ec(),r=wa(),{source:a}=On(),{scenarios:i,setScenarios:o,agents:c,servers:d,reload:f,loading:h}=qa(),[p,y]=v.useState(""),[g,S]=v.useState("all"),[b,x]=v.useState("name"),[j,N]=v.useState("asc"),[_,P]=v.useState(""),[A,O]=v.useState(null),[k,R]=v.useState("idle"),[$,z]=v.useState(""),[B,L]=v.useState(""),[K,U]=v.useState(0),[V,X]=v.useState(null),J=v.useRef(null),T=v.useRef(!1),D=v.useRef(!1),Q=v.useRef(null),F=v.useRef(0),M=e?decodeURIComponent(e):void 0,ee=M?i.findIndex(re=>re.id===M):-1,W=ee>=0?i[ee]:void 0,Z=async re=>{if(!W||ee<0||!re)return;const me=[...i];me[ee]=re,await o(me)},ye=async()=>{const re=Q.current;if(!re||!W)return;if(T.current){D.current=!0;return}T.current=!0,D.current=!1;const me=++F.current;R("saving"),z("");try{await Z(re),me===F.current&&R("saved")}catch(Ne){const tt=Ne instanceof Error?Ne.message:String(Ne);me===F.current&&(R("error"),z(tt)),Pe({title:"Could not save scenario",description:tt,variant:"destructive"})}finally{T.current=!1,D.current&&(D.current=!1,ye())}},ae=re=>{Q.current=re,R("dirty"),z(""),J.current&&window.clearTimeout(J.current),J.current=window.setTimeout(()=>{J.current=null,ye()},700)},ue=async()=>{const re=`scn-${Date.now()}`;let me=re,Ne=1;for(;i.some(je=>je.id===me);)me=`${re}-${Ne}`,Ne+=1;const tt={id:me,name:"",serverIds:[],prompt:"",evalRules:[],extractRules:[]};await o([...i,tt]),r(`/libraries/test-cases/${encodeURIComponent(me)}`),Pe({title:"Test case created",description:`Opened ${me} for editing.`})},ie=re=>{const me=(re||`scn-${Date.now()}`).trim().replace(/\s+/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||`scn-${Date.now()}`;let Ne=me,tt=1;for(;i.some(je=>je.id===Ne);)Ne=`${me}-${tt}`,tt+=1;return Ne},ve=async(re,me=!1)=>{const Ne=ie(`${re.id}-copy`),tt={...structuredClone(re),id:Ne,name:re.name?`${re.name} (Copy)`:""};await o([...i,tt]),Pe({title:"Test case duplicated",description:`Created ${tt.id}.`}),me&&r(`/libraries/test-cases/${encodeURIComponent(tt.id)}`)},Oe=async re=>{J.current&&(window.clearTimeout(J.current),J.current=null);const me=i.filter(Ne=>Ne.id!==re.id);await o(me),Pe({title:"Test case deleted",description:`${re.id} was removed.`}),W?.id===re.id&&(O(null),Q.current=null,R("idle"),z(""),r("/libraries/test-cases"))},oe=re=>re.map(me=>d.find(Ne=>Ne.id===me)).filter(Boolean).map(me=>me?.name||me?.id).filter(Boolean),he=v.useMemo(()=>{const re=new Set;for(const me of i)for(const Ne of oe(me.serverIds))re.add(Ne);return Array.from(re).sort((me,Ne)=>me.localeCompare(Ne))},[i,d]),xe=v.useMemo(()=>{const re=p.trim().toLowerCase(),me=i.filter(Ne=>{const tt=(Ne.name||"").toLowerCase(),je=Ne.id.toLowerCase(),et=(Ne.prompt||"").toLowerCase(),dt=oe(Ne.serverIds);return g!=="all"&&!dt.includes(g)?!1:re?tt.includes(re)||je.includes(re)||et.includes(re)||dt.some(Pt=>Pt.toLowerCase().includes(re)):!0});return me.sort((Ne,tt)=>{const je=oe(Ne.serverIds),et=oe(tt.serverIds);let dt=0;switch(b){case"id":dt=Ne.id.localeCompare(tt.id);break;case"servers":dt=je.length-et.length;break;case"evalRules":dt=Ne.evalRules.length-tt.evalRules.length;break;case"extractRules":dt=Ne.extractRules.length-tt.extractRules.length;break;default:dt=(Ne.name||Ne.id).localeCompare(tt.name||tt.id);break}return dt===0&&(dt=Ne.id.localeCompare(tt.id)),j==="asc"?dt:-dt}),me},[i,p,g,b,j,d]);v.useEffect(()=>{let re=!0;return a.getWorkspaceSettings().then(me=>{!re||!me||P(me.scenarioAssistantAgentName??"")}).catch(()=>{re&&P("")}),()=>{re=!1}},[a]),v.useEffect(()=>{if(M&&t.get("assistantHandoff")==="1")try{const re=window.sessionStorage.getItem(oM);if(!re)return;const me=JSON.parse(re);if(!me||me.scenarioId!==M||!me.prompt)return;L(String(me.prompt)),U(Date.now()),window.sessionStorage.removeItem(oM);const Ne=new URLSearchParams(t);Ne.delete("assistantHandoff"),n(Ne,{replace:!0}),Pe({title:"Suggestion sent to Scenario Assistant",description:"Review the suggestion and apply changes in the scenario editor."})}catch{}},[M,t,n]),v.useEffect(()=>{W?(O(structuredClone(W)),Q.current=structuredClone(W),R("idle"),z("")):(O(null),Q.current=null,R("idle"),z("")),J.current&&(window.clearTimeout(J.current),J.current=null),T.current=!1,D.current=!1},[W]),v.useEffect(()=>()=>{J.current&&window.clearTimeout(J.current)},[]);const Ie=_||c[0]?.name||"";return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(t$,{className:"h-6 w-6"}),"Manage Test Cases"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Reusable test case templates shared across configurations."})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[W&&s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>r("/libraries/test-cases"),children:[s.jsx(xo,{className:"mr-2 h-4 w-4"}),"Back to Overview"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{f()},disabled:h,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]}),!W&&s.jsxs(se,{type:"button",size:"sm",onClick:()=>{ue()},children:[s.jsx(us,{className:"mr-1.5 h-3.5 w-3.5"}),"Add Test Case"]})]})]}),!W&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"grid gap-3 rounded-md border bg-muted/30 p-3 md:grid-cols-[1.6fr_1fr_1fr_auto]",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Search"}),s.jsxs("div",{className:"relative",children:[s.jsx(Sj,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),s.jsx(ht,{value:p,onChange:re=>y(re.target.value),placeholder:"Search by name, id, prompt, server...",className:"h-8 pl-8 text-xs"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Server Filter"}),s.jsxs(sn,{value:g,onValueChange:S,children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"all",children:"All servers"}),he.map(re=>s.jsx(at,{value:re,children:re},re))]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Sort By"}),s.jsxs(sn,{value:b,onValueChange:re=>x(re),children:[s.jsx(Jt,{className:"h-8 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"name",children:"Name"}),s.jsx(at,{value:"id",children:"ID"}),s.jsx(at,{value:"servers",children:"# Servers"}),s.jsx(at,{value:"evalRules",children:"# Eval Rules"}),s.jsx(at,{value:"extractRules",children:"# Extract Rules"})]})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Direction"}),s.jsxs(sn,{value:j,onValueChange:re=>N(re),children:[s.jsx(Jt,{className:"h-8 w-28 text-xs",children:s.jsx(on,{})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"asc",children:"Ascending"}),s.jsx(at,{value:"desc",children:"Descending"})]})]})]})]}),s.jsx(Be,{children:s.jsxs(ze,{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"text-xs text-muted-foreground",children:["Showing ",xe.length," of ",i.length," test case",i.length!==1?"s":"","."]}),M&&!W&&s.jsxs("div",{className:"rounded-md border border-amber-300 bg-amber-50 px-3 py-2 text-sm text-amber-900",children:["Test case ",s.jsx("code",{className:"font-mono",children:M})," was not found."]}),i.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No library test cases yet."}):xe.length===0?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No test cases match the current filters."}):s.jsx("div",{className:"grid gap-3",children:xe.map(re=>{const me=M===re.id,Ne=`/libraries/test-cases/${encodeURIComponent(re.id)}`,tt=oe(re.serverIds);return s.jsx("div",{className:`rounded-lg border p-3 ${me?"border-primary bg-primary/5":""}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"space-y-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx(yt,{to:Ne,className:"font-medium truncate hover:underline",children:re.name||re.id}),s.jsx(Ke,{variant:"outline",className:"font-mono text-[10px]",children:re.id}),me&&s.jsx(Ke,{children:"Selected"})]}),s.jsxs("div",{className:"text-xs text-muted-foreground flex flex-wrap gap-x-3 gap-y-1",children:[s.jsxs("span",{children:[tt.length," server",tt.length!==1?"s":""]}),s.jsxs("span",{children:[re.evalRules.length," eval rule",re.evalRules.length!==1?"s":""]}),s.jsxs("span",{children:[re.extractRules.length," extract rule",re.extractRules.length!==1?"s":""]})]}),tt.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:tt.map(je=>s.jsx(Ke,{variant:"secondary",className:"text-[10px]",children:je},`${re.id}-${je}`))})]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(re),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(re)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsx(se,{type:"button",size:"sm",variant:me?"default":"outline",asChild:!0,children:s.jsxs(yt,{to:Ne,children:[s.jsx(_m,{className:"mr-1.5 h-3.5 w-3.5"}),"Edit"]})})]})]})},re.id)})})]})})]}),W&&A?s.jsxs(Be,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsx("div",{children:s.jsx(_t,{className:"text-base",children:"Edit Test Case"})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{ve(A,!0)},children:[s.jsx(Ri,{className:"mr-1.5 h-3.5 w-3.5"}),"Duplicate"]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"text-destructive hover:text-destructive",onClick:()=>X(A),children:[s.jsx(xa,{className:"mr-1.5 h-3.5 w-3.5"}),"Delete"]})]})]}),s.jsx("div",{className:"text-sm text-muted-foreground",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs("span",{children:["Focused editor for ",s.jsx("code",{className:"font-mono",children:W.id}),"."]}),s.jsx(Ke,{variant:"outline",className:`text-[10px] ${k==="saving"?"border-amber-300 text-amber-700":k==="saved"?"border-emerald-300 text-emerald-700":k==="error"?"border-destructive/40 text-destructive":k==="dirty"?"border-sky-300 text-sky-700":""}`,children:k==="saving"?"Saving...":k==="saved"?"Saved":k==="error"?"Save failed":k==="dirty"?"Unsaved changes":"Ready"}),k==="error"&&$&&s.jsx("span",{className:"text-[11px] text-destructive",children:$})]})})]}),s.jsx(ze,{className:"pt-3",children:s.jsx(lj,{scenarios:[A],agents:c,servers:d,defaultAssistantAgentName:Ie,assistantInitialPromptByScenarioId:B&&A?.id?{[A.id]:B}:void 0,assistantAutoOpenNonceByScenarioId:A?.id&&K?{[A.id]:K}:void 0,onChange:re=>{const me=re[0];me&&(O(me),ae(me))},allowAdd:!1})})]}):null,s.jsx(bs,{open:!!V,onOpenChange:re=>!re&&X(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete test case?"}),s.jsxs(Ya,{children:["This will permanently remove"," ",s.jsx("span",{className:"font-medium",children:V?.name||V?.id})," ","from the library. This action cannot be undone."]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{children:"Cancel"}),s.jsx(Xa,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>{V&&(Oe(V),X(null))},children:"Delete Test Case"})]})]})})]})},kve=()=>{const{source:e}=On(),{agents:t,reload:n,loading:r}=qa(),[a,i]=v.useState(!1),[o,c]=v.useState(!1),[d,f]=v.useState(""),h=v.useMemo(()=>d||t[0]?.name||"",[d,t]),p=async()=>{i(!0);try{const S=await e.getWorkspaceSettings();f(S?.scenarioAssistantAgentName??"")}catch(S){f(""),Pe({title:"Could not load settings",description:S instanceof Error?S.message:String(S),variant:"destructive"})}finally{i(!1)}};v.useEffect(()=>{p()},[e]);const y=async S=>{f(S),c(!0);try{await e.updateWorkspaceSettings({scenarioAssistantAgentName:S||void 0}),Pe({title:"Settings updated",description:S?`Scenario Assistant Agent set to ${S}.`:"Scenario Assistant Agent cleared (will use first available agent by default)."})}catch(b){Pe({title:"Could not save settings",description:b instanceof Error?b.message:String(b),variant:"destructive"})}finally{c(!1)}},g=async()=>{await Promise.all([n(),p()])};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(jj,{className:"h-6 w-6"}),"Settings"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Workspace-level MCP Lab settings and defaults."})]}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",onClick:()=>{g()},disabled:r||a,children:[s.jsx(Fa,{className:"mr-2 h-4 w-4"}),"Refresh"]})]}),s.jsxs(Be,{children:[s.jsxs(Ct,{className:"pb-3",children:[s.jsx(_t,{className:"text-base",children:"Scenario Assistant"}),s.jsx(Ds,{children:"Default assistant model used on library test case pages. If unset, MCP Lab uses the first available agent automatically."})]}),s.jsxs(ze,{className:"grid gap-3 md:grid-cols-[1.3fr_auto] md:items-end",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx(Me,{className:"text-xs",children:"Assistant Agent"}),s.jsxs(sn,{value:h||"__none__",onValueChange:S=>{y(S==="__none__"?"":S)},disabled:o,children:[s.jsx(Jt,{className:"h-9 text-sm",children:s.jsx(on,{placeholder:"Select assistant agent"})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"__none__",children:"None (use first agent)"}),t.map(S=>s.jsxs(at,{value:S.id,children:[S.name||S.id," · ",S.model]},S.id))]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Applies to `/libraries/test-cases/:testCaseId`. MCP Evaluation editors can still override the assistant agent from their evaluation context."})]}),s.jsx("div",{className:"text-xs text-muted-foreground",children:"Saved in workspace settings"})]})]})]})};var Jv="Checkbox",[Rve]=ir(Jv),[Tve,pC]=Rve(Jv);function Ive(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:a,disabled:i,form:o,name:c,onCheckedChange:d,required:f,value:h="on",internal_do_not_use_render:p}=e,[y,g]=na({prop:n,defaultProp:a??!1,onChange:d,caller:Jv}),[S,b]=v.useState(null),[x,j]=v.useState(null),N=v.useRef(!1),_=S?!!o||!!S.closest("form"):!0,P={checked:y,disabled:i,setChecked:g,control:S,setControl:b,name:c,form:o,value:h,hasConsumerStoppedPropagationRef:N,required:f,defaultChecked:ki(a)?!1:a,isFormControl:_,bubbleInput:x,setBubbleInput:j};return s.jsx(Tve,{scope:t,...P,children:Mve(p)?p(P):r})}var gz="CheckboxTrigger",yz=v.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},a)=>{const{control:i,value:o,disabled:c,checked:d,required:f,setControl:h,setChecked:p,hasConsumerStoppedPropagationRef:y,isFormControl:g,bubbleInput:S}=pC(gz,e),b=ut(a,h),x=v.useRef(d);return v.useEffect(()=>{const j=i?.form;if(j){const N=()=>p(x.current);return j.addEventListener("reset",N),()=>j.removeEventListener("reset",N)}},[i,p]),s.jsx(De.button,{type:"button",role:"checkbox","aria-checked":ki(d)?"mixed":d,"aria-required":f,"data-state":jz(d),"data-disabled":c?"":void 0,disabled:c,value:o,...r,ref:b,onKeyDown:Ae(t,j=>{j.key==="Enter"&&j.preventDefault()}),onClick:Ae(n,j=>{p(N=>ki(N)?!0:!N),S&&g&&(y.current=j.isPropagationStopped(),y.current||j.stopPropagation())})})});yz.displayName=gz;var hC=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:a,defaultChecked:i,required:o,disabled:c,value:d,onCheckedChange:f,form:h,...p}=e;return s.jsx(Ive,{__scopeCheckbox:n,checked:a,defaultChecked:i,disabled:c,required:o,onCheckedChange:f,name:r,form:h,value:d,internal_do_not_use_render:({isFormControl:y})=>s.jsxs(s.Fragment,{children:[s.jsx(yz,{...p,ref:t,__scopeCheckbox:n}),y&&s.jsx(Sz,{__scopeCheckbox:n})]})})});hC.displayName=Jv;var xz="CheckboxIndicator",bz=v.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...a}=e,i=pC(xz,n);return s.jsx(Gn,{present:r||ki(i.checked)||i.checked===!0,children:s.jsx(De.span,{"data-state":jz(i.checked),"data-disabled":i.disabled?"":void 0,...a,ref:t,style:{pointerEvents:"none",...e.style}})})});bz.displayName=xz;var wz="CheckboxBubbleInput",Sz=v.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:a,checked:i,defaultChecked:o,required:c,disabled:d,name:f,value:h,form:p,bubbleInput:y,setBubbleInput:g}=pC(wz,e),S=ut(n,g),b=Fv(i),x=km(r);v.useEffect(()=>{const N=y;if(!N)return;const _=window.HTMLInputElement.prototype,A=Object.getOwnPropertyDescriptor(_,"checked").set,O=!a.current;if(b!==i&&A){const k=new Event("click",{bubbles:O});N.indeterminate=ki(i),A.call(N,ki(i)?!1:i),N.dispatchEvent(k)}},[y,b,i,a]);const j=v.useRef(ki(i)?!1:i);return s.jsx(De.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??j.current,required:c,disabled:d,name:f,value:h,form:p,...t,tabIndex:-1,ref:S,style:{...t.style,...x,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});Sz.displayName=wz;function Mve(e){return typeof e=="function"}function ki(e){return e==="indeterminate"}function jz(e){return ki(e)?"indeterminate":e?"checked":"unchecked"}const va=v.forwardRef(({className:e,...t},n)=>s.jsx(hC,{ref:n,className:Se("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),...t,children:s.jsx(bz,{className:Se("flex items-center justify-center text-current"),children:s.jsx(ql,{className:"h-4 w-4"})})}));va.displayName=hC.displayName;const $ve=Io("relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground",{variants:{variant:{default:"bg-background text-foreground",destructive:"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive"}},defaultVariants:{variant:"default"}}),Bl=v.forwardRef(({className:e,variant:t,...n},r)=>s.jsx("div",{ref:r,role:"alert",className:Se($ve({variant:t}),e),...n}));Bl.displayName="Alert";const zl=v.forwardRef(({className:e,...t},n)=>s.jsx("h5",{ref:n,className:Se("mb-1 font-medium leading-none tracking-tight",e),...t}));zl.displayName="AlertTitle";const Ul=v.forwardRef(({className:e,...t},n)=>s.jsx("div",{ref:n,className:Se("text-sm [&_p]:leading-relaxed",e),...t}));Ul.displayName="AlertDescription";function Dve(e,t=[]){let n=[];function r(i,o){const c=v.createContext(o);c.displayName=i+"Context";const d=n.length;n=[...n,o];const f=p=>{const{scope:y,children:g,...S}=p,b=y?.[e]?.[d]||c,x=v.useMemo(()=>S,Object.values(S));return s.jsx(b.Provider,{value:x,children:g})};f.displayName=i+"Provider";function h(p,y){const g=y?.[e]?.[d]||c,S=v.useContext(g);if(S)return S;if(o!==void 0)return o;throw new Error(`\`${p}\` must be used within \`${i}\``)}return[f,h]}const a=()=>{const i=n.map(o=>v.createContext(o));return function(c){const d=c?.[e]||i;return v.useMemo(()=>({[`__scope${e}`]:{...c,[e]:d}}),[c,d])}};return a.scopeName=e,[r,Lve(a,...t)]}function Lve(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(a=>({useScope:a(),scopeName:a.scopeName}));return function(i){const o=r.reduce((c,{useScope:d,scopeName:f})=>{const p=d(i)[`__scope${f}`];return{...c,...p}},{});return v.useMemo(()=>({[`__scope${t.scopeName}`]:o}),[o])}};return n.scopeName=t.scopeName,n}var Fve=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Nz=Fve.reduce((e,t)=>{const n=qm(`Primitive.${t}`),r=v.forwardRef((a,i)=>{const{asChild:o,...c}=a,d=o?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),s.jsx(d,{...c,ref:i})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),mC="Progress",vC=100,[Bve]=Dve(mC),[zve,Uve]=Bve(mC),Cz=v.forwardRef((e,t)=>{const{__scopeProgress:n,value:r=null,max:a,getValueLabel:i=qve,...o}=e;(a||a===0)&&!cM(a)&&console.error(Wve(`${a}`,"Progress"));const c=cM(a)?a:vC;r!==null&&!uM(r,c)&&console.error(Vve(`${r}`,"Progress"));const d=uM(r,c)?r:null,f=bm(d)?i(d,c):void 0;return s.jsx(zve,{scope:n,value:d,max:c,children:s.jsx(Nz.div,{"aria-valuemax":c,"aria-valuemin":0,"aria-valuenow":bm(d)?d:void 0,"aria-valuetext":f,role:"progressbar","data-state":Ez(d,c),"data-value":d??void 0,"data-max":c,...o,ref:t})})});Cz.displayName=mC;var _z="ProgressIndicator",Az=v.forwardRef((e,t)=>{const{__scopeProgress:n,...r}=e,a=Uve(_z,n);return s.jsx(Nz.div,{"data-state":Ez(a.value,a.max),"data-value":a.value??void 0,"data-max":a.max,...r,ref:t})});Az.displayName=_z;function qve(e,t){return`${Math.round(e/t*100)}%`}function Ez(e,t){return e==null?"indeterminate":e===t?"complete":"loading"}function bm(e){return typeof e=="number"}function cM(e){return bm(e)&&!isNaN(e)&&e>0}function uM(e,t){return bm(e)&&!isNaN(e)&&e<=t&&e>=0}function Wve(e,t){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${t}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${vC}\`.`}function Vve(e,t){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${t}\`. The \`value\` prop must be:
131
131
  - a positive number
132
132
  - less than the value passed to \`max\` (or ${vC} if no \`max\` prop is set)
133
133
  - \`null\` or \`undefined\` if the progress is indeterminate.
@@ -246,4 +246,4 @@ new Chart(document.getElementById('barChart'),{type:'bar',data:{labels:${JSON.st
246
246
  <\/script>
247
247
  </body>
248
248
  </html>`}function oo(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const lge="mcplab.resultAssistantScenarioHandoff",cge=[{label:"Summarize Run Results",description:"Highlight failures first, then notable tool usage and extracted values.",prompt:"Summarize the scenario results in this run. Highlight failed scenarios/checks first, then mention notable tool usage and extracted values."},{label:"Compare Agent Answer Quality",description:"Rank agents by completeness, depth, and recommendation quality.",prompt:"Compare the answer quality across all agents for this run. Rank them by completeness, analytical depth, and usefulness of recommendations. Highlight concrete differences in tool usage."},{label:"Explain Key Failures",description:"Use traces and tool outputs to identify likely root causes.",prompt:"Identify the most important failures in this run and explain likely root causes using the trace and tool outputs."},{label:"Compare With Previous Run",description:"Summarize changes in outcomes, tool usage, and extracted values.",prompt:"Compare this run with the previous run and summarize changes in outcomes, tool usage, and extracted values."}];function yM(e){const t=new Date().toISOString().replace(/[:]/g,"-").replace(/\..+/,"");return`mcplab/reports/result-assistant/${e}-${t}.md`}function xM(e){const t=e.toFixed(1);return t.endsWith(".0")?t.slice(0,-2):t}const uge=()=>{const{id:e}=Mo(),t=wa(),[n]=Ec(),{source:r}=On(),a=mf("snapshots",!1),{configs:i}=tf(),{scenarios:o}=qa(),[c,d]=v.useState(void 0),[f,h]=v.useState(!0),[p,y]=v.useState(new Set),[g,S]=v.useState(new Set),[b,x]=v.useState([]),[j,N]=v.useState(""),[_,P]=v.useState(null),[A,O]=v.useState(!1),[k,R]=v.useState(""),[$,z]=v.useState(""),[B,L]=v.useState(!1),[K,U]=v.useState(!1),[V,X]=v.useState(null),[J,T]=v.useState([]),[D,Q]=v.useState([]),[F,M]=v.useState(""),[ee,W]=v.useState(!1),[Z,ye]=v.useState(!1),[ae,ue]=v.useState("assistant"),[ie,ve]=v.useState(null),[Oe,oe]=v.useState(null),[he,xe]=v.useState(!1),[Ie,re]=v.useState(""),[me,Ne]=v.useState(""),[tt,je]=v.useState(!1),[et,dt]=v.useState(!1),[Pt,hn]=v.useState(!1),[be,Ue]=v.useState([]),[qe,$t]=v.useState(!1),[Dt,Mt]=v.useState(""),[mn,jn]=v.useState(null),[or,lr]=v.useState(!1),[Na,Dn]=v.useState(null),Dr=v.useRef(null),Cr=v.useRef(null),_r=v.useCallback(async(G,fe)=>{$t(!0);try{const Re=(await r.listMarkdownReports()).filter(Ot=>{const Nt=String(Ot.relativePath??""),Tn=String(Ot.name??"");return Nt.includes(G)||Tn.includes(G)});if(Ue(Re),fe&&Re.length>0){const Ot=Re.find(Nt=>Nt.relativePath===fe||Nt.path===fe||Nt.relativePath.endsWith(fe)||Nt.path.endsWith(fe));Ot&&Mt(Ot.relativePath)}return Re}catch{return Ue([]),[]}finally{$t(!1)}},[r]);v.useEffect(()=>{if(!e)return;let G=!0;const fe=V;return fe&&(r.closeResultAssistantSession(fe).catch(()=>{}),X(null),T([]),Q([]),oe(null)),h(!0),r.getResult(e).then(nt=>{G&&(d(nt),h(!1))}),()=>{G=!1}},[e,r]),v.useEffect(()=>{let G=!0;return r.listSnapshots().then(fe=>{G&&x(fe)}).catch(()=>{G&&x([])}),()=>{G=!1}},[r]),v.useEffect(()=>{if(!c?.id){Ue([]);return}let G=!0;return(async()=>{const fe=await _r(c.id)})(),()=>{G=!1}},[c?.id,_r]),v.useEffect(()=>{if(be.length===0){Mt(""),jn(null),Dn(null);return}(!Dt||!be.some(G=>G.relativePath===Dt))&&Mt(be[0].relativePath)},[be,Dt]),v.useEffect(()=>{if(!K||ae!=="reports")return;if(!Dt){jn(null),Dn(null);return}let G=!0;return lr(!0),Dn(null),r.getMarkdownReport(Dt).then(fe=>{G&&jn(fe)}).catch(fe=>{G&&(jn(null),Dn(fe instanceof Error?fe.message:String(fe)))}).finally(()=>{G&&lr(!1)}),()=>{G=!1}},[K,ae,Dt,r]);const kn=n.get("configId")??"",xn=v.useMemo(()=>{const G=kn?i.find(fe=>fe.id===kn):void 0;return G||(c?i.find(fe=>fe.id===c.configId):void 0)},[i,kn,c]),cn=v.useMemo(()=>{const G=new Map;if(xn){for(const fe of xn.scenarios)G.set(fe.id,fe),fe.name&&!G.has(fe.name)&&G.set(fe.name,fe);for(const fe of xn.scenarioEntries??[]){if(fe.kind!=="referenced")continue;const nt=o.find(Re=>Re.id===fe.ref);nt&&(G.set(nt.id,nt),nt.name&&G.set(nt.name,nt),G.has(fe.ref)||G.set(fe.ref,nt))}}for(const fe of o)G.has(fe.id)||G.set(fe.id,fe),fe.name&&!G.has(fe.name)&&G.set(fe.name,fe);return G},[xn,o]),Rn=v.useMemo(()=>{if(!c?.snapshotEval?.baselineSnapshotId)return"";const G=i.filter(fe=>fe.snapshotEval?.baselineSnapshotId===c.snapshotEval?.baselineSnapshotId);return G.length===1?G[0].id:""},[i,c?.snapshotEval?.baselineSnapshotId]);if(v.useEffect(()=>{c?.snapshotEval?.baselineSnapshotId&&N(G=>G||c.snapshotEval.baselineSnapshotId)},[c?.snapshotEval?.baselineSnapshotId]),v.useEffect(()=>{if(kn&&i.some(G=>G.id===kn)){R(kn);return}Rn&&R(G=>G||Rn)},[kn,i,Rn]),v.useEffect(()=>{if(!K)return;const G=window.setTimeout(()=>{Dr.current?.scrollIntoView({behavior:"smooth",block:"end"})},0);return()=>window.clearTimeout(G)},[K,J.length,ee]),v.useEffect(()=>()=>{V&&r.closeResultAssistantSession(V).catch(()=>{})},[V,r]),v.useEffect(()=>{const G=Cr.current;if(!G)return;G.style.height="0px";const fe=Math.min(G.scrollHeight,160);G.style.height=`${Math.max(40,fe)}px`},[F,K]),f)return s.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Loading result..."});if(!c)return s.jsx("div",{className:"p-8 text-center text-muted-foreground",children:"Result not found"});const le=c.scenarios.reduce((G,fe)=>G+fe.runs.filter(nt=>nt.passed).length,0),ke=c.totalRuns-le,it=[{name:"Pass",value:le,color:"hsl(152, 69%, 40%)"},{name:"Fail",value:ke,color:"hsl(0, 72%, 51%)"}],vt={};c.scenarios.forEach(G=>G.runs.forEach(fe=>fe.toolCalls.forEach(nt=>{vt[nt.name]=(vt[nt.name]||0)+1})));const zt=Object.entries(vt).map(([G,fe])=>({name:G,count:fe})).sort((G,fe)=>fe.count-G.count),tn=G=>{y(fe=>{const nt=new Set(fe);return nt.has(G)?nt.delete(G):nt.add(G),nt})},Et=(G,fe,nt,Re)=>`${G}:${fe}:${nt}:${Re}`,mr=(G,fe)=>`${G}::${fe}`,Vt=G=>{S(fe=>{const nt=new Set(fe);return nt.has(G)?nt.delete(G):nt.add(G),nt})},Ht=G=>{const fe=!G.endsWith(":conversation");return g.has(G)?!fe:fe},vr=new Map((_?.scenario_results??[]).map(G=>[G.scenario_id,G])),ei=async()=>{if(!(!c||!j)){O(!0);try{const G=await r.compareSnapshot(j,c.id);P(G)}finally{O(!1)}}},Ca=async G=>{const fe=G||c.snapshotEval?.baselineSnapshotId;if(fe){N(fe),O(!0);try{const nt=await r.compareSnapshot(fe,c.id);P(nt)}catch(nt){Pe({title:"Could not review drift",description:nt instanceof Error?nt.message:String(nt),variant:"destructive"})}finally{O(!1)}}},ti=async()=>{if(!k){Pe({title:"Select a configuration",description:"Choose which config should receive the new baseline.",variant:"destructive"});return}L(!0);try{const G=await r.generateSnapshotEvalBaseline(c.id,k,$.trim()||void 0);x(fe=>[G.snapshot,...fe.filter(nt=>nt.id!==G.snapshot.id)]),N(G.snapshot.id),Pe({title:"Baseline updated",description:`${G.snapshot.name} is now linked to the selected config.`}),$.trim()||z(G.snapshot.name),c.snapshotEval?.applied&&Ca(G.snapshot.id)}catch(G){Pe({title:"Could not accept new baseline",description:G instanceof Error?G.message:String(G),variant:"destructive"})}finally{L(!1)}},H=async()=>{const G=F.trim();if(!G||!c)return;const fe=`msg-local-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,nt={id:fe,role:"user",text:G,createdAt:new Date().toISOString()};M(""),T(Re=>[...Re,nt]),W(!0);try{let Re=V;if(!Re){const Nt=await r.createResultAssistantSession(c.id);Re=Nt.sessionId,X(Nt.session.id),Q(Nt.session.pendingToolCalls),oe({assistantAgentName:Nt.session.selectedAssistantAgentName,provider:Nt.session.provider,model:Nt.session.model}),T(Tn=>{const Ja=Tn.some(Fn=>Fn.id===fe),Yt=Nt.session.messages;return Ja?[...Yt,nt]:Yt})}const Ot=await r.sendResultAssistantMessage(Re,G);Ye(Ot.session)}catch(Re){T(Ot=>Ot.filter(Nt=>Nt.id!==fe)),Pe({title:"MCP Labs Assistant error",description:Re instanceof Error?Re.message:String(Re),variant:"destructive"})}finally{W(!1)}},ge=G=>{M(G),requestAnimationFrame(()=>Cr.current?.focus())},Ye=G=>{X(G.id),T(G.messages),Q(G.pendingToolCalls),oe({assistantAgentName:G.selectedAssistantAgentName,provider:G.provider,model:G.model})},Ze=async G=>{if(V){W(!0);try{const fe=await r.approveResultAssistantToolCall(V,G);Ye(fe.session)}catch(fe){Pe({title:"Could not approve assistant action",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{W(!1)}}},jt=async G=>{if(V){W(!0);try{const fe=await r.denyResultAssistantToolCall(V,G);Ye(fe.session)}catch(fe){Pe({title:"Could not deny assistant action",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{W(!1)}}},wt=(G,fe)=>{ue("assistant"),U(!0),ve(fe?.scenarioId??null),J.length===0&&T([{id:`msg-${Date.now()}`,role:"assistant",text:"Ask me to explain failures, tool usage, snapshot drift, or suggest what to inspect next in this result.",createdAt:new Date().toISOString()}]),G&&M(G)},Nn=G=>{ue("reports"),U(!0)},We=G=>{if(!c)return;if(!ie){Pe({title:"No scenario context",description:"Ask about a specific scenario or run first, then send the suggestion.",variant:"destructive"});return}const fe=o.find(Re=>Re.id===ie)??o.find(Re=>Re.name===ie);if(!fe){Pe({title:"Scenario not found in library",description:`Could not find library scenario '${ie}' to open in Scenario Assistant.`,variant:"destructive"});return}const nt=[`I am sending a suggestion from the Result Assistant for scenario '${ie}' based on run '${c.id}'.`,"Please review the suggestion, check it against the current scenario configuration, and propose concrete updates to the Checks and/or Value Capture Rules if appropriate.","","Result Assistant suggestion:",G].join(`
249
- `);try{window.sessionStorage.setItem(lge,JSON.stringify({type:"result-assistant-handoff-v1",runId:c.id,configId:kn||c.configId||"",scenarioId:fe.id,prompt:nt,sourceReply:G})),t(`/libraries/test-cases/${encodeURIComponent(fe.id)}?assistantHandoff=1`)}catch(Re){Pe({title:"Could not create handoff",description:Re instanceof Error?Re.message:String(Re),variant:"destructive"})}},vn=G=>{c&&(hn(!1),re(G),Ne(yM(c.id)),je(!1),xe(!0))},Ln=()=>{c&&(hn(!0),re(""),Ne(yM(c.id)),je(!1),xe(!0))},Gt=async()=>{if(!c)return;if(!Ie.trim()){Pe({title:"No markdown to write",description:"The selected assistant response is empty.",variant:"destructive"});return}dt(!0);try{const fe=await r.applyResultAssistantReport({runId:c.id,markdown:Ie,outputPath:me.trim()||void 0,overwrite:tt});Pe({title:"Markdown report written",description:typeof fe.path=="string"&&fe.path?fe.path:fe.outputPath}),await _r(c.id,typeof fe.path=="string"&&fe.path||fe.outputPath||void 0),K&&ue("reports"),xe(!1)}catch(fe){Pe({title:"Could not write markdown report",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{dt(!1)}},An=async G=>{try{await navigator.clipboard.writeText(G),Pe({title:"Copied"})}catch(fe){Pe({title:"Could not copy",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}};return s.jsxs("div",{className:`${K?"xl:flex xl:h-[calc(100vh-2rem-48px)] xl:min-h-0 xl:flex-col xl:overflow-hidden":""}`,children:[s.jsx("div",{className:`${K?"xl:shrink-0 xl:pb-6":"mb-6"}`,children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[s.jsx(se,{variant:"ghost",size:"icon",asChild:!0,children:s.jsx(yt,{to:"/results",children:s.jsx(xo,{className:"h-4 w-4"})})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h1",{className:"text-2xl font-bold font-mono",children:c.id}),s.jsx(vo,{rate:c.overallPassRate}),a&&c.snapshotEval?.applied&&s.jsxs(Ke,{variant:"outline",className:"text-xs",children:["Snapshot policy · ",c.snapshotEval.mode," · ",c.snapshotEval.status]})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[new Date(c.timestamp).toLocaleString()," · Config hash: ",s.jsx("span",{className:"font-mono",children:c.configHash})]}),a&&c.snapshotEval?.applied&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Baseline: ",s.jsx("span",{className:"font-mono",children:c.snapshotEval.baselineSnapshotId})," · score: ",c.snapshotEval.overallScore]})]})]}),s.jsxs("div",{className:"ml-auto flex shrink-0 flex-wrap items-center justify-end gap-2",children:[a&&c.snapshotEval?.applied&&s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>{Ca()},disabled:A,children:[s.jsx(wj,{className:"h-3.5 w-3.5"}),A?"Reviewing drift...":"Review Drift"]}),s.jsxs(se,{variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>{const G=oge(c),fe=new Blob([G],{type:"text/html"}),nt=URL.createObjectURL(fe),Re=document.createElement("a");Re.href=nt,Re.download=`mcplab-report-${c.id}.html`,Re.click(),URL.revokeObjectURL(nt)},children:[s.jsx(ga,{className:"h-3.5 w-3.5"}),"Download Report"]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>Nn(),disabled:qe,children:[s.jsx(rh,{className:"h-3.5 w-3.5"}),qe?"Reference Reports...":`Reference Reports${be.length?` (${be.length})`:""}`]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>wt(),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"MCP Labs Assistant"]})]})]})}),s.jsxs("div",{className:`grid gap-6 items-start ${K?Z?"xl:grid-cols-[minmax(0,1fr)_52rem] xl:flex-1 xl:min-h-0 xl:overflow-hidden":"xl:grid-cols-[minmax(0,1fr)_28rem] xl:flex-1 xl:min-h-0 xl:overflow-hidden":"grid-cols-1"}`,children:[s.jsxs("div",{className:`min-w-0 space-y-6 ${K?"xl:h-full xl:min-h-0 xl:overflow-y-auto xl:pr-2":""}`,children:[a&&c.snapshotEval?.applied&&s.jsxs(Be,{className:"border-amber-500/30",children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Snapshot Drift Review"})}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[s.jsxs(Ke,{variant:"outline",children:["Mode: ",c.snapshotEval.mode]}),s.jsxs(Ke,{variant:"outline",children:["Status: ",c.snapshotEval.status]}),s.jsxs(Ke,{variant:"outline",children:["Overall score: ",c.snapshotEval.overallScore]}),s.jsxs(Ke,{variant:"outline",className:"font-mono",children:["Baseline: ",c.snapshotEval.baselineSnapshotId]})]}),c.snapshotEval.impactedScenarios.length>0&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Impacted scenarios: ",c.snapshotEval.impactedScenarios.join(", ")]}),s.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.2fr_1fr_auto] items-end",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Target config for baseline update"}),s.jsxs(sn,{value:k,onValueChange:R,children:[s.jsx(Jt,{className:"h-8",children:s.jsx(on,{placeholder:"Select config to update"})}),s.jsx(Zt,{children:i.map(G=>s.jsx(at,{value:G.id,children:G.name},G.id))})]}),!k&&s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Tip: open results from the Run page to prefill the config automatically."})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"New snapshot name (optional)"}),s.jsx("div",{className:"relative",children:s.jsx("input",{value:$,onChange:G=>z(G.target.value),placeholder:`Snapshot ${c.id}`,className:"h-8 w-full rounded-md border bg-background px-2 text-xs"})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5",onClick:()=>{Ca()},disabled:A,children:[s.jsx(Fa,{className:`h-3.5 w-3.5 ${A?"animate-spin":""}`}),"Review Drift"]}),s.jsx(se,{type:"button",size:"sm",className:"h-8",onClick:()=>{ti()},disabled:B||c.overallPassRate!==1,children:B?"Accepting...":"Accept as New Baseline"})]})]}),c.overallPassRate!==1&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Baseline updates require a fully passing run (same rule as snapshot creation)."})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-5",children:[s.jsx(Ts,{title:"Scenarios",value:c.totalScenarios,icon:p1}),s.jsx(Ts,{title:"Total Runs",value:c.totalRuns,icon:JM}),s.jsx(Ts,{title:"Pass Rate",value:`${Math.round(c.overallPassRate*100)}%`,icon:ed}),s.jsx(Ts,{title:"Avg Tool Calls",value:xM(c.avgToolCalls),icon:Ol}),s.jsx(Ts,{title:"Avg Latency",value:`${c.avgLatency}ms`,icon:l$})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-2",children:s.jsx(_t,{className:"text-base",children:"Pass / Fail"})}),s.jsxs(ze,{className:"flex items-center justify-center",children:[s.jsxs(Zde,{width:180,height:180,children:[s.jsx(Js,{data:it,dataKey:"value",innerRadius:50,outerRadius:75,paddingAngle:3,children:it.map((G,fe)=>s.jsx(cv,{fill:G.color},fe))}),s.jsx(Hr,{})]}),s.jsxs("div",{className:"ml-4 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"h-3 w-3 rounded-full bg-success"}),le," passed"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"h-3 w-3 rounded-full bg-destructive"}),ke," failed"]})]})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-2",children:s.jsx(_t,{className:"text-base",children:"Tool Usage"})}),s.jsx(ze,{children:s.jsx(X1,{width:"100%",height:180,children:s.jsxs(Jde,{data:zt,layout:"vertical",children:[s.jsx(Ao,{type:"number",tick:{fontSize:11}}),s.jsx(Eo,{type:"category",dataKey:"name",tick:{fontSize:11},width:120}),s.jsx(Hr,{}),s.jsx(zo,{dataKey:"count",fill:"hsl(38, 92%, 50%)",radius:[0,4,4,0]})]})})})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx(_t,{className:"text-base",children:"Scenarios"}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 px-2 text-xs",onClick:()=>wt("Summarize the scenario results in this run. Highlight failed scenarios/checks first, then mention notable tool usage and extracted values."),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Ask Assistant"]})]})}),s.jsxs(ze,{className:"p-0",children:[a&&s.jsxs("div",{className:"flex flex-wrap items-end gap-2 border-b p-3",children:[s.jsxs("div",{className:"min-w-60 space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Snapshot"}),s.jsxs(sn,{value:j,onValueChange:N,children:[s.jsx(Jt,{className:"h-8",children:s.jsx(on,{placeholder:"Select snapshot"})}),s.jsx(Zt,{children:b.map(G=>s.jsx(at,{value:G.id,children:G.name},G.id))})]})]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",disabled:!j||A,onClick:()=>{ei()},children:A?"Comparing...":"Compare Snapshot"}),_&&s.jsxs(Ke,{variant:"outline",className:"h-8 px-2 py-0 text-xs",children:["Overall snapshot score: ",_.overall_score]})]}),s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{className:"w-8"}),s.jsx(Qe,{children:"Scenario"}),s.jsx(Qe,{children:"Agent"}),s.jsx(Qe,{children:"Runs"}),s.jsx(Qe,{children:"Pass Rate"}),s.jsx(Qe,{children:"Tool Calls"}),s.jsx(Qe,{children:"Snapshot"})]})}),s.jsx(Jr,{children:c.scenarios.map(G=>{const fe=mr(G.scenarioId,G.agentName),nt=G.scenarioName||G.scenarioId;return s.jsx(Ci,{open:p.has(fe),onOpenChange:()=>tn(fe),asChild:!0,children:s.jsxs(s.Fragment,{children:[s.jsx(Rs,{asChild:!0,children:s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",children:[s.jsx(Fe,{children:s.jsx(qt,{className:`h-4 w-4 transition-transform ${p.has(fe)?"rotate-180":""}`})}),s.jsx(Fe,{className:"font-medium text-sm",children:G.scenarioName}),s.jsx(Fe,{className:"text-sm",children:G.agentName}),s.jsx(Fe,{className:"font-mono text-sm",children:G.runs.length}),s.jsx(Fe,{children:s.jsx(vo,{rate:G.passRate})}),s.jsx(Fe,{className:"font-mono text-sm",children:xM(G.avgToolCalls)}),s.jsx(Fe,{children:(()=>{const Re=vr.get(G.scenarioId);if(!Re)return s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"});const Ot=Re.status==="Match"?"bg-success/15 text-success":Re.status==="Warn"?"bg-amber-500/15 text-amber-600":"bg-destructive/15 text-destructive";return s.jsxs(Ke,{variant:"outline",className:`text-xs ${Ot}`,children:[Re.status," · ",Re.score]})})()})]})}),s.jsx(_i,{asChild:!0,children:s.jsx("tr",{children:s.jsx("td",{colSpan:7,className:"p-0",children:s.jsxs("div",{className:"bg-muted/30 p-4 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border bg-card px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs font-semibold",children:"Scenario details"}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[nt," · ",G.agentName," · ",Math.round(G.passRate*100),"% pass rate"]})]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs shrink-0",onClick:()=>wt(`Explain why scenario '${nt}' failed (agent: ${G.agentName}). Summarize the likely cause from the result details and suggest what to inspect next.`,{scenarioId:G.scenarioId}),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Ask Assistant"]})]}),(()=>{const Re=vr.get(G.scenarioId);return!Re||Re.reasons.length===0?null:s.jsxs("div",{className:"rounded-md border bg-card p-2",children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-muted-foreground",children:"Snapshot reasons"}),s.jsxs("p",{className:"mb-1 text-[11px] text-muted-foreground",children:["Baseline agents: ",Re.baseline_agents.join(", ")||"—"," · observed agents: ",Re.observed_agents.join(", ")||"—"]}),s.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:Re.reasons.map((Ot,Nt)=>s.jsxs("li",{children:["• ",Ot]},Nt))})]})})(),G.runs.map(Re=>s.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-card p-3 text-sm",children:[s.jsx("div",{className:"mt-0.5",children:Re.passed?s.jsx(Ol,{className:"h-4 w-4 text-success"}):s.jsx(Xp,{className:"h-4 w-4 text-destructive"})}),s.jsxs("div",{className:"flex-1 space-y-1",children:[(()=>{const Ot=cn.get(G.scenarioId),Nt=Ot?pge(Ot.evalRules,Re.failureReasons):[],Tn=Nt.filter(Yt=>Yt.status==="failed"),Ja=Nt.filter(Yt=>Yt.status==="passed");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Run #",Re.runIndex+1]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[Re.duration,"ms"]}),!Re.passed&&s.jsx(Ke,{variant:"outline",className:"h-5 border-destructive/30 bg-destructive/10 text-destructive text-[10px]",children:"Failed"})]}),Re.failureReasons.length>0&&s.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2",children:[s.jsxs("p",{className:"mb-1 flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-destructive",children:[s.jsx(Xp,{className:"h-3.5 w-3.5"}),"Failure reasons"]}),s.jsx("ul",{className:"space-y-1 text-xs text-destructive",children:Re.failureReasons.map((Yt,Fn)=>s.jsxs("li",{children:["• ",SM(Yt)]},Fn))})]}),Nt.length>0&&s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"checks")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"checks")),children:s.jsxs("div",{className:"rounded-md border bg-muted/20 p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full flex-wrap items-center gap-2 text-left",children:[s.jsx(qt,{className:`h-3.5 w-3.5 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"checks"))?"rotate-180":""}`}),s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Checks"}),s.jsxs(Ke,{variant:"outline",className:"h-5 border-success/30 bg-success/10 text-success text-[10px]",children:[Ja.length," passed"]}),s.jsxs(Ke,{variant:"outline",className:`h-5 text-[10px] ${Tn.length>0?"border-destructive/30 bg-destructive/10 text-destructive":""}`,children:[Tn.length," failed"]})]})}),s.jsx(_i,{children:s.jsx("div",{className:"space-y-1",children:Nt.map((Yt,Fn)=>s.jsxs("div",{className:`flex items-start justify-between gap-2 rounded-md border px-2 py-1.5 text-xs ${Yt.status==="failed"?"border-destructive/20 bg-destructive/5":"border-success/20 bg-success/5"}`,children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Yt.status==="failed"?s.jsx(Xp,{className:"h-3.5 w-3.5 shrink-0 text-destructive"}):s.jsx(Ol,{className:"h-3.5 w-3.5 shrink-0 text-success"}),s.jsx("span",{className:"font-medium",children:mge(Yt.rule)})]}),Yt.failureReason&&s.jsx("p",{className:"mt-1 pl-5 text-[11px] text-destructive",children:SM(Yt.failureReason)})]}),s.jsx(Ke,{variant:"outline",className:`shrink-0 text-[10px] ${Yt.status==="failed"?"border-destructive/30 text-destructive":"border-success/30 text-success"}`,children:Yt.status})]},`${Yt.rule.type}-${Yt.rule.value}-${Fn}`))})})]})})]})})(),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"extracts")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"extracts")),children:s.jsxs("div",{className:"rounded-md border border-violet-500/20 bg-violet-500/5 p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full flex-wrap items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(qt,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"extracts"))?"rotate-180":""}`}),s.jsxs("p",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(p1,{className:"h-3.5 w-3.5 text-violet-600"}),"Extracted values"]})]}),s.jsxs(Ke,{variant:"outline",className:"h-5 text-[10px]",children:[Object.keys(Re.extractedValues??{}).length," total"]})]})}),s.jsx(_i,{children:Object.keys(Re.extractedValues??{}).length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No extracted values captured for this run."}):s.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:Object.entries(Re.extractedValues??{}).map(([Ot,Nt])=>s.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5 text-xs",children:[s.jsx("div",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:Ot}),s.jsx("div",{className:"font-mono break-all text-foreground",children:Nt===null?"null":String(Nt)})]},Ot))})})]})}),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"tools")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"tools")),children:s.jsxs("div",{className:"rounded-md border border-sky-500/20 bg-sky-500/5 p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full flex-wrap items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(qt,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"tools"))?"rotate-180":""}`}),s.jsxs("p",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(Is,{className:"h-3.5 w-3.5 text-sky-600"}),"Tool call sequence"]})]}),s.jsxs(Ke,{variant:"outline",className:"h-5 text-[10px]",children:[Re.toolCalls.length," total"]})]})}),s.jsx(_i,{children:Re.toolCalls.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No tool calls captured for this run."}):s.jsx("div",{className:"flex flex-wrap gap-1",children:Re.toolCalls.map((Ot,Nt)=>s.jsxs(Ke,{variant:"outline",className:"font-mono text-xs bg-background",children:[s.jsxs("span",{className:"mr-1 text-muted-foreground",children:["#",Nt+1]}),Ot.name,s.jsxs("span",{className:"ml-1 text-muted-foreground",children:[Ot.duration,"ms"]})]},Nt))})})]})}),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"final")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"final")),children:s.jsxs("div",{className:"rounded-md border border-muted-foreground/20 bg-card p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full items-center gap-2 text-left",children:[s.jsx(qt,{className:`h-3.5 w-3.5 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"final"))?"rotate-180":""}`}),s.jsxs("p",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(ha,{className:"h-3.5 w-3.5"}),"Final answer"]})]})}),s.jsx(_i,{children:s.jsx(mj,{text:Re.finalAnswer||"No final answer captured.",maxLength:1200,className:"text-xs text-foreground"})})]})}),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation")),children:s.jsxs("div",{className:"rounded-md border bg-muted/10 p-2",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",children:[s.jsx(qt,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation"))?"rotate-180":""}`}),s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Conversation trace"})]})}),s.jsx("div",{className:"flex flex-wrap gap-2",children:s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>wt(`Explain Run #${Re.runIndex+1} for scenario '${nt}'. It ${Re.passed?"passed":"failed"} in ${Re.duration}ms. Focus on the tool sequence and ${Re.passed?"why it passed":"what caused the failure"}.`,{scenarioId:G.scenarioId}),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Ask Assistant"]})})]}),s.jsx(_i,{children:s.jsx("div",{className:"space-y-2 rounded-md border bg-muted/20 p-2",children:Re.conversation.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No conversation trace captured."}):Re.conversation.map(Ot=>s.jsx(dge,{item:Ot,fallbackUserPrompt:cn.get(G.scenarioId)?.prompt},Ot.id))})}),!Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation"))&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Expand to inspect user/assistant/tool messages for this run."})]})})]})]},Re.runIndex))]})})})})]})},fe)})})]})]})]})]}),K&&s.jsxs("div",{className:"min-w-0 space-y-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col",children:[s.jsx(tC,{value:ae,onValueChange:G=>ue(G),className:"min-w-0 -mb-px px-3 pt-1",children:s.jsxs(Uv,{className:"h-auto w-full justify-start rounded-none border-b bg-transparent p-0",children:[s.jsx(Po,{value:"assistant",className:"-mb-px h-9 rounded-none rounded-t border border-border border-b-border bg-muted/20 px-3 text-xs text-muted-foreground data-[state=active]:z-10 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-border data-[state=active]:border-b-card data-[state=active]:shadow-none",children:"Assistant"}),s.jsx(Po,{value:"reports",className:"-mb-px h-9 rounded-none rounded-t border border-border border-b-border bg-muted/20 px-3 text-xs text-muted-foreground data-[state=active]:z-10 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-border data-[state=active]:border-b-card data-[state=active]:shadow-none",children:"Reports"})]})}),ae==="assistant"?s.jsxs(Be,{className:"min-w-0 overflow-hidden rounded-t-none xl:flex xl:h-full xl:min-h-0 xl:flex-col",children:[s.jsx(Ct,{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs(_t,{className:"flex items-center gap-2 text-base",children:[s.jsx(fa,{className:"h-4 w-4 text-amber-500"}),"MCP Labs Assistant"]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:()=>ye(G=>!G),children:[Z?s.jsx(sE,{className:"h-3.5 w-3.5"}):s.jsx(iE,{className:"h-3.5 w-3.5"}),Z?"Compact":"Expand"]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>U(!1),children:"Hide"})]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions about this run result, failures, tool usage, and snapshot drift."})]})}),s.jsxs(ze,{className:"flex h-[70vh] min-h-[520px] flex-col p-0 xl:h-auto xl:min-h-0 xl:flex-1",children:[s.jsx(xm,{className:"min-h-0 flex-1 bg-muted/15 px-4 py-4",children:s.jsxs("div",{className:"space-y-3 pr-2",children:[J.map((G,fe)=>{const nt=G.role==="user",Re=G.role==="assistant",Ot=G.role==="system",Nt=G.role==="tool",Tn=G.pendingToolCallId?D.find(qc=>qc.id===G.pendingToolCallId):void 0,Ja=Re&&!!G.pendingToolCallId;if(Nt&&/^(Approved|Denied) tool call\b/i.test(String(G.text??"").trim()))return null;Tn?.server??G.toolRequestServer;const Yt=Tn?.tool??G.toolRequestName,Fn=Tn?.publicToolName??G.toolRequestPublicName,yf=Re&&!Ja&&fge(G.text,!!ie);if(Ja){const qc=Yt??Fn??"unknown_tool";return Yt&&Yt.replace(/^mcplab_/,"").replace(/_/g," "),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("details",{open:!!Tn,className:"group min-w-0 w-full max-w-[92%] rounded-md border border-border/60 bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2",children:[s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5 text-muted-foreground"}),s.jsx("span",{className:"truncate text-sm font-medium",children:`Tool call ${qc}`}),s.jsx("span",{className:`rounded px-1.5 py-0.5 text-[10px] font-semibold ${Tn?"bg-amber-100 text-amber-900":"bg-muted text-muted-foreground"}`,children:Tn?"Needs approval":"Completed"})]})}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"min-w-0 space-y-2 border-t border-border/50 px-3 py-2",children:[s.jsx(Zu,{text:G.text,className:"text-sm"}),Tn&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"max-h-40 min-w-0 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre-wrap break-words rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{className:"break-words",children:JSON.stringify(Tn.arguments??{},null,2)})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{jt(Tn.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{Ze(Tn.id)},children:"Approve"})]})]})]})]})]},`${G.id??`${G.role}-${fe}`}:${Tn?"pending":"completed"}`)}const Lr=nt||Re&&!Nt&&!Ot;return s.jsxs("div",{className:`flex items-start gap-2 ${nt?"justify-end":"justify-start"}`,children:[!nt&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:Ot?s.jsx(i$,{className:"h-3 w-3"}):s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("div",{className:"relative max-w-[92%]",children:[s.jsxs("div",{className:`max-w-full rounded-md border p-3 text-sm ${nt?"border-primary/20 bg-primary/10":Ot?"border-amber-400/30 bg-amber-50/70":Nt?"border-blue-300/30 bg-blue-50/50":"border-border/80 bg-background shadow-sm"}`,children:[!(nt||Ot)&&s.jsx("p",{className:`mb-2 text-[11px] font-semibold text-muted-foreground ${nt?"text-right":""}`,children:Nt?"Tool":"Assistant"}),s.jsx(Zu,{text:G.text,className:"text-sm"}),yf&&s.jsxs("div",{className:"mt-3 flex max-w-full flex-wrap justify-end gap-2 overflow-x-auto pb-1",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>We(G.text),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Send to Scenario Assistant"]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>vn(G.text),children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),"Apply: Write Markdown Report"]})]}),!yf&&Re&&!Ja&&s.jsx("div",{className:"mt-3 flex max-w-full justify-end overflow-x-auto pb-1",children:s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>vn(G.text),children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),"Apply: Write Markdown Report"]})})]}),Lr&&s.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"absolute -right-8 bottom-1 h-6 w-6 text-muted-foreground",onClick:()=>{An(G.text)},"aria-label":"Copy message",title:"Copy message",children:s.jsx(Ri,{className:"h-3.5 w-3.5"})})]}),nt&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-primary/30 bg-primary/15 text-primary",children:s.jsx(Nj,{className:"h-3 w-3"})})]},G.id??`${G.role}-${fe}`)}),D.filter(G=>!J.some(fe=>fe.pendingToolCallId===G.id)).length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Pending actions (approve/deny)"}),D.filter(G=>!J.some(fe=>fe.pendingToolCallId===G.id)).map(G=>s.jsxs("details",{open:!0,className:"group min-w-0 rounded-md border bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-2 p-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-all font-mono text-xs font-semibold",children:G.publicToolName}),s.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[G.server,"::",G.tool]})]}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"border-t px-3 pb-3 pt-2",children:[s.jsx("pre",{className:"max-h-48 min-w-0 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre-wrap break-words rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{className:"break-words",children:JSON.stringify(G.arguments??{},null,2)})}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{jt(G.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{Ze(G.id)},children:"Approve"})]})]})]},G.id))]}),ee&&s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Thinking..."]})]}),s.jsx("div",{ref:Dr})]})}),s.jsx("div",{className:"border-t bg-background px-4 py-3",children:s.jsxs("div",{className:"rounded-xl border bg-background p-2 shadow-sm",children:[s.jsx(Ks,{ref:Cr,value:F,onChange:G=>M(G.target.value),placeholder:"Ask about this result...",rows:1,className:"min-h-10 max-h-40 resize-none border-0 bg-transparent px-2 py-1 text-sm shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",onKeyDown:G=>{G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),ee||H())}}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 px-1 pt-1",children:[s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 px-1.5 text-[11px] font-normal text-muted-foreground/80 hover:text-muted-foreground",disabled:ee,children:[s.jsx(us,{className:"h-3 w-3"}),"Snippets",s.jsx(qt,{className:"h-3 w-3"})]})}),s.jsxs(Wo,{align:"start",className:"w-[360px]",children:[s.jsx(JN,{children:"Result Assistant Snippets"}),s.jsx(ZN,{}),cge.map(G=>s.jsx(hr,{className:"items-start whitespace-normal px-2 py-2",onSelect:()=>ge(G.prompt),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"text-xs font-medium leading-tight",children:G.label}),s.jsx("div",{className:"text-[11px] leading-snug text-muted-foreground",children:G.description})]})},G.label))]})]}),s.jsx(se,{type:"button",size:"icon",className:"h-8 w-8 shrink-0 rounded-full",onClick:()=>{H()},disabled:ee||!F.trim(),"aria-label":"Send assistant message",title:"Send assistant message",children:ee?s.jsx(sr,{className:"h-4 w-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(o$,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Ask"})]})})]})]})})]})]}):s.jsxs(Be,{className:"min-w-0 overflow-hidden rounded-t-none xl:flex xl:h-full xl:min-h-0 xl:flex-col",children:[s.jsx(Ct,{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs(_t,{className:"flex items-center gap-2 text-base",children:[s.jsx(rh,{className:"h-4 w-4 text-muted-foreground"}),"Reference Reports"]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:()=>ye(G=>!G),children:[Z?s.jsx(sE,{className:"h-3.5 w-3.5"}):s.jsx(iE,{className:"h-3.5 w-3.5"}),Z?"Compact":"Expand"]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>U(!1),children:"Hide"})]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Review markdown reports for this run while keeping the result visible."})]})}),s.jsxs(ze,{className:"flex h-[70vh] min-h-[520px] flex-col p-0 xl:h-auto xl:min-h-0 xl:flex-1",children:[(qe||be.length===0||be.length>1)&&s.jsx("div",{className:"border-b px-4 py-3",children:qe?s.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading reference reports..."}):be.length===0?s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No reference reports for this run yet."}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"shrink-0 gap-1.5",onClick:()=>Ln(),children:[s.jsx(us,{className:"h-3.5 w-3.5"}),"New Report"]})]}):s.jsx("div",{className:"space-y-2",children:be.length>1?s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Selected report"}),s.jsxs(sn,{value:Dt,onValueChange:Mt,children:[s.jsx(Jt,{className:"h-8",children:s.jsx(on,{placeholder:"Select a report"})}),s.jsx(Zt,{children:be.map(G=>s.jsx(at,{value:G.relativePath,children:G.name},G.path))})]})]}):null})}),s.jsx(xm,{className:"min-h-0 flex-1 bg-muted/15 px-4 py-4",children:be.length===0?s.jsx("div",{className:"text-sm text-muted-foreground",children:"No report selected."}):or?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Loading report..."]}):Na?s.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",children:["Could not load report: ",Na]}):mn?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-md border bg-background p-3",children:[s.jsx("p",{className:"font-mono text-xs font-semibold",children:mn.name}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:mn.relativePath}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:new Date(mn.mtime).toLocaleString()})]}),s.jsx("div",{className:"rounded-md border bg-background p-3",children:s.jsx(Zu,{text:mn.content,className:"text-sm"})})]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Select a report to preview."})})]})]})]}),s.jsx(bs,{open:he,onOpenChange:G=>!et&&xe(G),children:s.jsxs(Va,{className:"max-w-2xl",children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:Pt?"Create markdown report":"Approve MCP action: write markdown report"}),s.jsx(Ya,{children:Pt?"Write a custom markdown report and save it to the workspace.":s.jsxs(s.Fragment,{children:["This will call ",s.jsx("code",{children:"mcplab_write_markdown_report"})," via the local MCPLab MCP server."]})})]}),s.jsxs("div",{className:"space-y-3",children:[!Pt&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Output path"}),s.jsx(ht,{value:me,onChange:G=>Ne(G.target.value),placeholder:"mcplab/reports/result-assistant/my-report.md",disabled:et})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx(va,{checked:tt,onCheckedChange:G=>je(G===!0),disabled:et}),s.jsx("span",{children:"Overwrite if file exists"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:Pt?"Markdown content":"Markdown preview (to be written)"}),s.jsx(Ks,{value:Ie,onChange:G=>re(G.target.value),rows:10,className:"font-mono text-xs",disabled:et})]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{disabled:et,children:"Cancel"}),s.jsx(Xa,{onClick:G=>{G.preventDefault(),Gt()},disabled:et,children:et?"Writing...":Pt?"Save Report":"Approve & Write"})]})]})})]})]})};function dge({item:e,fallbackUserPrompt:t}){if(e.kind==="tool_call")return s.jsx(wM,{variant:"call",title:`Tool call · ${e.toolName||"unknown"}`,text:e.text});if(e.kind==="tool_result"){const d=e.ok?s.jsx(Ol,{className:"h-3.5 w-3.5 text-emerald-700 dark:text-emerald-300"}):s.jsx(Xp,{className:"h-3.5 w-3.5 text-rose-700 dark:text-rose-300"});return s.jsx(wM,{variant:e.ok?"result_ok":"result_error",title:`Tool result · ${e.toolName||"unknown"} · ${e.ok?"ok":"error"}${typeof e.durationMs=="number"?` · ${e.durationMs}ms`:""}`,text:e.text,icon:d})}const n=e.kind==="user_prompt",r=bM(e.text,e.kind),a=t?bM(t,"user_prompt"):"",i=n&&a.length>r.length?a:r,o=n?"User prompt":e.kind==="assistant_final"?"Agent final":"Agent",c=n?Nj:ha;return s.jsxs("div",{className:`flex items-start gap-2 text-xs ${n?"justify-end":"justify-start"}`,children:[!n&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",children:s.jsx(c,{className:"h-3 w-3"})}),s.jsxs("div",{className:`max-w-[90%] rounded-md p-2 ${n?"bg-primary/10":"bg-muted/50"}`,children:[s.jsx("p",{className:`mb-1 text-[11px] font-semibold text-muted-foreground ${n?"text-right":""}`,children:o}),n?s.jsx(mj,{text:i,maxLength:280,className:"text-xs"}):s.jsx(mj,{text:i,maxLength:500,className:"text-xs"})]}),n&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-primary/30 bg-primary/15 text-primary",children:s.jsx(c,{className:"h-3 w-3"})})]})}function bM(e,t){const r=String(e??"").replace(/^\s+/,"");return t==="user_prompt"?r.replace(/^user:\s*/i,""):t==="assistant_final"||t==="assistant_thought"?r.replace(/^assistant:\s*/i,""):r}function fge(e,t){if(!t)return!1;const n=String(e??"").toLowerCase();if(!n.trim())return!1;const r=["check","checks","rule","rules","regex","pattern","value capture","extract rule","update","change","replace","modify","adjust","use ","set "],a=["change ","replace ","update ","use ","set the","suggested","you should","try ","text match failed","text must match pattern"];if(["i can only read","i don't have write access","i cannot directly edit","what happened","summary"].some(h=>n.includes(h))&&!a.some(h=>n.includes(h)))return!1;const o=r.some(h=>n.includes(h)),c=a.some(h=>n.includes(h)),d=/(^|\n)\s*[-*]\s+/.test(e)||/(^|\n)\s*\d+\.\s+/.test(e),f=/["'`][^"'`\n]{2,}["'`]/.test(e);return o&&(c||d||f)}function wM({variant:e,title:t,text:n,icon:r}){const[a,i]=v.useState(!1),o={call:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",result_ok:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",result_error:"border-rose-500/30 bg-rose-500/10 text-rose-700 dark:text-rose-300"};return s.jsx(Ci,{open:a,onOpenChange:i,children:s.jsxs("div",{className:`rounded-md border p-2 text-xs ${o[e]}`,children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-[11px]",children:[r??s.jsx(Is,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:t})]}),s.jsx("span",{className:"text-[11px] font-semibold",children:a?"Hide content":"Show content"})]})}),s.jsx(_i,{children:s.jsx("p",{className:"mt-2 font-mono whitespace-pre-wrap text-foreground",children:n})})]})})}function mj({text:e,maxLength:t,className:n}){const[r,a]=v.useState(!1),i=e.length>t,o=r||!i?e:`${e.slice(0,t)}...`;return s.jsxs("div",{children:[s.jsx(Zu,{text:o,className:n}),i&&s.jsx("button",{type:"button",className:"mt-1 text-[11px] font-medium text-primary hover:underline",onClick:()=>a(c=>!c),children:r?"Show less":"Show all"})]})}function pge(e,t){return e.map(n=>{const r=hge(n,t);return{rule:n,status:r?"failed":"passed",failureReason:r}})}function hge(e,t){const n=e.type==="required_tool"?`Required tool not used: ${e.value}`:e.type==="forbidden_tool"?`Forbidden tool used: ${e.value}`:`Regex assertion failed: ${e.value}`,r=t.find(a=>a===n);if(r)return r;if(e.type==="response_contains"||e.type==="response_not_contains")return t.find(a=>a.startsWith("Regex assertion failed:")&&a.includes(e.value))}function mge(e){return e.type==="required_tool"?`Required tool · ${e.value}`:e.type==="forbidden_tool"?`Forbidden tool · ${e.value}`:e.type==="response_contains"?`Text must match pattern · ${e.value}`:e.type==="response_not_contains"?`Text must not match pattern · ${e.value}`:`${e.type} · ${e.value}`}function SM(e){const t=String(e??"").trim(),n=t.match(/^Regex assertion failed:\s*(.+)$/i);return n?`Text match failed: ${n[1]}`:t}const jM=["hsl(38, 92%, 50%)","hsl(200, 80%, 50%)","hsl(152, 69%, 40%)","hsl(280, 60%, 50%)","hsl(0, 72%, 51%)"],vge=()=>{const{source:e}=On(),t=mf("snapshots",!1),[n,r]=v.useState([]),[a,i]=v.useState(!1),[o,c]=v.useState(new Set),[d,f]=v.useState("timestamp"),[h,p]=v.useState("desc"),[y,g]=v.useState("all"),[S,b]=v.useState("runs"),[x,j]=v.useState([]),[N,_]=v.useState(""),[P,A]=v.useState(""),[O,k]=v.useState(null),R=async()=>{i(!0);try{r(await e.listResults())}catch(T){Pe({title:"Could not load results",description:T instanceof Error?T.message:String(T),variant:"destructive"})}finally{i(!1)}};v.useEffect(()=>{let T=!0;return i(!0),e.listResults().then(D=>{T&&r(D)}).catch(D=>{T&&Pe({title:"Could not load results",description:D instanceof Error?D.message:String(D),variant:"destructive"})}).finally(()=>{T&&i(!1)}),()=>{T=!1}},[e]),v.useEffect(()=>{let T=!0;return e.listSnapshots().then(D=>{T&&j(D)}).catch(()=>{T&&j([])}),()=>{T=!1}},[e]);const $=T=>{if(d===T){p(D=>D==="asc"?"desc":"asc");return}f(T),p(T==="timestamp"?"desc":"asc")},z=T=>{c(D=>{const Q=new Set(D);return Q.has(T)?Q.delete(T):Q.add(T),Q})},B=v.useMemo(()=>{const T=new Set;return n.forEach(D=>{D.scenarios.forEach(Q=>{const F=String(Q.scenarioName??"").trim(),M=String(Q.scenarioId??"").trim(),ee=F||M;ee&&T.add(ee)})}),Array.from(T).sort((D,Q)=>D.localeCompare(Q))},[n]),L=v.useMemo(()=>y==="all"?n:n.filter(T=>T.scenarios.some(D=>{const Q=String(D.scenarioName??"").trim(),F=String(D.scenarioId??"").trim();return(Q||F)===y})),[n,y]),K=v.useMemo(()=>[...L].sort((D,Q)=>{let F=0;return d==="id"&&(F=D.id.localeCompare(Q.id)),d==="timestamp"&&(F=new Date(D.timestamp).getTime()-new Date(Q.timestamp).getTime()),d==="passRate"&&(F=D.overallPassRate-Q.overallPassRate),d==="scenarios"&&(F=D.totalScenarios-Q.totalScenarios),h==="asc"?F:-F}),[L,d,h]),U=K.filter(T=>o.has(T.id)),V=T=>d!==T?s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"}):h==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}),X=T=>{const D=Array.from(new Set(T.scenarios.map(ee=>ee.scenarioId).filter(Boolean))),Q=Array.from(new Set(T.scenarios.map(ee=>ee.agentName).filter(Boolean))),F=D.slice(0,2).join(", "),M=D.length>2?` +${D.length-2}`:"";return{scenarioCount:D.length,agentCount:Q.length,scenarioPreview:F?`${F}${M}`:"n/a"}},J=[...new Set(U.flatMap(T=>T.scenarios.map(D=>D.scenarioId)))];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(wj,{className:"h-6 w-6"}),"Compare Runs"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Select 2–5 runs to compare"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[S==="runs"&&s.jsxs(sn,{value:y,onValueChange:g,children:[s.jsx(Jt,{className:"w-[260px]",children:s.jsx(on,{placeholder:"Filter by scenario"})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"all",children:"All scenarios"}),B.map(T=>s.jsx(at,{value:T,children:T},T))]})]}),s.jsx(se,{variant:"outline",onClick:()=>{R()},disabled:a,children:a?"Refreshing...":"Refresh"})]})]}),S==="runs"&&s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{className:"w-10"}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("id"),children:["Run ID",V("id")]})}),s.jsx(Qe,{children:"Evaluated"}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("timestamp"),children:["Timestamp",V("timestamp")]})}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("passRate"),children:["Pass Rate",V("passRate")]})}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("scenarios"),children:["Scenarios",V("scenarios")]})})]})}),s.jsx(Jr,{children:K.map(T=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:s.jsx(va,{checked:o.has(T.id),onCheckedChange:()=>z(T.id),disabled:!o.has(T.id)&&o.size>=5})}),s.jsx(Fe,{className:"font-mono text-xs",children:T.id}),s.jsx(Fe,{className:"text-[11px] text-muted-foreground",children:(()=>{const D=X(T);return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{children:["Evaluated: ",D.scenarioCount," scenario",D.scenarioCount===1?"":"s"," · ",D.agentCount," agent",D.agentCount===1?"":"s"]}),s.jsx("div",{className:"font-mono text-xs text-foreground/80",children:D.scenarioPreview})]})})()}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:new Date(T.timestamp).toLocaleString()}),s.jsx(Fe,{children:s.jsx(vo,{rate:T.overallPassRate})}),s.jsx(Fe,{className:"font-mono text-sm",children:T.totalScenarios})]},T.id))})]})})}),S==="runs"&&U.length>=2&&s.jsxs(s.Fragment,{children:[U.length===2&&s.jsx(Be,{children:s.jsx(ze,{className:"pt-6",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Need a deeper comparison?"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Open the two selected runs in a dedicated side-by-side full result compare view."})]}),s.jsx(se,{asChild:!0,size:"sm",children:s.jsx(yt,{to:`/compare/results?left=${encodeURIComponent(U[0].id)}&right=${encodeURIComponent(U[1].id)}&leftConfig=${encodeURIComponent(U[0].configId)}&rightConfig=${encodeURIComponent(U[1].configId)}`,children:"Compare full results"})})]})})}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Summary Comparison"})}),s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Metric"}),U.map((T,D)=>s.jsx(Qe,{style:{color:jM[D]},className:"font-mono text-xs",children:T.id},T.id))]})}),s.jsxs(Jr,{children:[s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Pass Rate"}),U.map(T=>s.jsx(Fe,{children:s.jsx(vo,{rate:T.overallPassRate})},T.id))]}),s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Total Runs"}),U.map(T=>s.jsx(Fe,{className:"font-mono",children:T.totalRuns},T.id))]}),s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Tool Calls"}),U.map(T=>s.jsx(Fe,{className:"font-mono",children:T.avgToolCalls.toFixed(1)},T.id))]}),s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Avg Latency"}),U.map(T=>s.jsxs(Fe,{className:"font-mono",children:[T.avgLatency,"ms"]},T.id))]})]})]})})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Scenario Breakdown"})}),s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Scenario"}),U.map((T,D)=>s.jsx(Qe,{style:{color:jM[D]},className:"font-mono text-xs",children:T.id},T.id))]})}),s.jsx(Jr,{children:J.map(T=>s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium text-sm",children:T}),U.map(D=>{const Q=D.scenarios.find(F=>F.scenarioId===T);return s.jsx(Fe,{children:Q?s.jsx(vo,{rate:Q.passRate}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},D.id)})]},T))})]})})]})]}),t&&S==="snapshot"&&s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Run vs Snapshot"})}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Run"}),s.jsxs(sn,{value:P,onValueChange:A,children:[s.jsx(Jt,{children:s.jsx(on,{placeholder:"Select run"})}),s.jsx(Zt,{children:n.map(T=>s.jsx(at,{value:T.id,children:T.id},T.id))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Snapshot"}),s.jsxs(sn,{value:N,onValueChange:_,children:[s.jsx(Jt,{children:s.jsx(on,{placeholder:"Select snapshot"})}),s.jsx(Zt,{children:x.map(T=>s.jsx(at,{value:T.id,children:T.name},T.id))})]})]})]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",disabled:!P||!N,onClick:()=>{e.compareSnapshot(N,P).then(k)},children:"Compare"}),O&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm font-medium",children:["Overall score: ",O.overall_score]}),s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Scenario"}),s.jsx(Qe,{children:"Agents"}),s.jsx(Qe,{children:"Score"}),s.jsx(Qe,{children:"Status"}),s.jsx(Qe,{children:"Reasons"})]})}),s.jsx(Jr,{children:O.scenario_results.map(T=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:T.scenario_id}),s.jsxs(Fe,{className:"text-xs text-muted-foreground",children:["baseline: ",T.baseline_agents.join(", ")||"—"," · observed: ",T.observed_agents.join(", ")||"—"]}),s.jsx(Fe,{className:"font-mono text-xs",children:T.score}),s.jsx(Fe,{children:T.status}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:T.reasons.slice(0,2).join("; ")||"—"})]},T.scenario_id))})]})]})]})]})]})},NM=(e,t)=>{const n=new URLSearchParams;return t&&n.set("configId",t),n.set("embed","1"),`/results/${encodeURIComponent(e)}?${n.toString()}`},gge=()=>{const[e]=Ec(),t=e.get("left")??"",n=e.get("right")??"",r=e.get("leftConfig"),a=e.get("rightConfig");return!t||!n?s.jsxs(Be,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Full Result Compare"})}),s.jsxs(ze,{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Select exactly two runs in Compare and use the “Compare full results” action."}),s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:"/compare",children:"Back to Compare"})})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Full Result Compare"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Side-by-side Result Detail views for deep inspection."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(se,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs(yt,{to:"/compare",children:[s.jsx(A7,{className:"mr-1.5 h-4 w-4"}),"Back to Compare"]})}),s.jsx(se,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:`/results/${encodeURIComponent(t)}${r?`?configId=${encodeURIComponent(r)}`:""}`,target:"_blank",rel:"noreferrer",children:["Open Left",s.jsx(nh,{className:"ml-1.5 h-3.5 w-3.5"})]})}),s.jsx(se,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:`/results/${encodeURIComponent(n)}${a?`?configId=${encodeURIComponent(a)}`:""}`,target:"_blank",rel:"noreferrer",children:["Open Right",s.jsx(nh,{className:"ml-1.5 h-3.5 w-3.5"})]})})]})]}),s.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[s.jsxs(Be,{className:"overflow-hidden",children:[s.jsx(Ct,{className:"py-3",children:s.jsx(_t,{className:"text-sm font-mono",children:t})}),s.jsx(ze,{className:"p-0",children:s.jsx("iframe",{title:`Result ${t}`,src:NM(t,r),className:"h-[calc(100vh-15rem)] w-full border-0"})})]}),s.jsxs(Be,{className:"overflow-hidden",children:[s.jsx(Ct,{className:"py-3",children:s.jsx(_t,{className:"text-sm font-mono",children:n})}),s.jsx(ze,{className:"p-0",children:s.jsx("iframe",{title:`Result ${n}`,src:NM(n,a),className:"h-[calc(100vh-15rem)] w-full border-0"})})]})]})]})};function yge(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function xge(){const{source:e}=On(),[t,n]=v.useState([]),[r,a]=v.useState(!0),[i,o]=v.useState(null),[c,d]=v.useState(!1),f=async()=>{a(!0);try{n(await e.listMarkdownReports())}catch(g){Pe({title:"Could not load markdown reports",description:g instanceof Error?g.message:String(g),variant:"destructive"})}finally{a(!1)}};v.useEffect(()=>{f()},[]);const h=v.useMemo(()=>t[0],[t]),p=v.useMemo(()=>t.find(g=>g.relativePath===i)??null,[t,i]),y=async()=>{if(i){d(!0);try{await e.deleteMarkdownReport(i),n(g=>g.filter(S=>S.relativePath!==i)),Pe({title:"Markdown report deleted"}),o(null)}catch(g){Pe({title:"Could not delete markdown report",description:g instanceof Error?g.message:String(g),variant:"destructive"})}finally{d(!1)}}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(rh,{className:"h-6 w-6"}),"Markdown Reports"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Browse Markdown files under ",s.jsx("code",{children:"mcplab/reports"}),"."]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{variant:"outline",onClick:()=>{f()},children:"Refresh"}),h?s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:`/markdown-reports/view?path=${encodeURIComponent(h.relativePath)}`,children:"Open latest"})}):null]})]}),s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:r?s.jsx("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading markdown reports..."}):t.length===0?s.jsx("p",{className:"p-6 text-sm text-muted-foreground",children:"No markdown reports found yet."}):s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Report"}),s.jsx(Qe,{children:"Folder"}),s.jsx(Qe,{children:"Timestamp"}),s.jsx(Qe,{children:"Size"}),s.jsx(Qe,{className:"w-10"})]})}),s.jsx(Jr,{children:t.map(g=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsx(yt,{to:`/markdown-reports/view?path=${encodeURIComponent(g.relativePath)}`,className:"font-mono text-xs text-primary hover:underline",children:g.name}),s.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:g.relativePath})]})}),s.jsx(Fe,{className:"text-xs text-muted-foreground font-mono",children:g.relativePath.includes("/")?g.relativePath.slice(0,g.relativePath.lastIndexOf("/")):"."}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Nm,{className:"h-3 w-3"}),new Date(g.mtime).toLocaleString()]})}),s.jsx(Fe,{className:"font-mono text-sm",children:yge(g.sizeBytes)}),s.jsx(Fe,{children:s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8",children:s.jsx(Cm,{className:"h-4 w-4"})})}),s.jsxs(Wo,{align:"end",children:[s.jsx(hr,{asChild:!0,children:s.jsx(yt,{to:`/markdown-reports/view?path=${encodeURIComponent(g.relativePath)}`,children:"View"})}),s.jsxs(hr,{className:"text-destructive",onSelect:S=>{S.preventDefault(),o(g.relativePath)},children:[s.jsx(xa,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})})]},g.path))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:g=>!g&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete markdown report?"}),s.jsx(Ya,{children:p?`Delete '${p.name}' from disk? This cannot be undone.`:"Delete this report from disk? This cannot be undone."})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{disabled:c,children:"Cancel"}),s.jsx(Xa,{onClick:g=>{g.preventDefault(),y()},disabled:c,children:c?"Deleting...":"Delete"})]})]})})]})}function bge(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function wge(e){const t=e.relativePath.match(/(?:^|\/)(?:result-assistant|results?)\/([0-9]{8}-[0-9]{6})(?:-|\/)/i);return t?.[1]?t[1]:(e.content.match(/(?:^|\n)\s*\*\*Run:\*\*\s*`([^`]+)`/i)??e.content.match(/(?:^|\n)\s*Run ID:\s*([^\s]+)/i))?.[1]?.trim()||null}function Sge(){const{source:e}=On(),[t]=Ec(),n=(t.get("path")??"").trim(),[r,a]=v.useState(null),[i,o]=v.useState(!0),[c,d]=v.useState(!1),[f,h]=v.useState(!1);if(v.useEffect(()=>{let y=!0;if(a(null),d(!1),!n){o(!1);return}return o(!0),e.getMarkdownReport(n).then(g=>{y&&a(g)}).catch(g=>{if(!y)return;const S=g instanceof Error?g.message:String(g);if(S.includes("(404)")){d(!0);return}Pe({title:"Could not load markdown report",description:S,variant:"destructive"})}).finally(()=>{y&&o(!1)}),()=>{y=!1}},[n,e]),!n)return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Markdown Report"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing report path."}),s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:"/markdown-reports",children:"Back to Markdown Reports"})})]});if(i)return s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading markdown report..."});if(c||!r)return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Markdown Report"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Report not found."}),s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:"/markdown-reports",children:"Back to Markdown Reports"})})]});const p=wge(r);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"font-mono text-xl font-semibold",children:r.name}),s.jsx("p",{className:"truncate text-sm text-muted-foreground",children:r.relativePath}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[new Date(r.mtime).toLocaleString()," "," · "," ",bge(r.sizeBytes)]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p?s.jsxs(s.Fragment,{children:[s.jsx(se,{variant:"outline",size:"sm",onClick:()=>h(!0),children:"Open Result Panel"}),s.jsx(se,{asChild:!0,variant:"outline",size:"sm",children:s.jsx(yt,{to:`/results/${encodeURIComponent(p)}`,children:"Open Result"})})]}):null,s.jsx(se,{asChild:!0,variant:"outline",size:"sm",children:s.jsx(yt,{to:"/markdown-reports",children:"Back to reports"})})]})]}),s.jsx(Be,{children:s.jsx(ze,{className:"pt-6",children:s.jsx(Zu,{text:r.content,variant:"assistant"})})}),p?s.jsx(VD,{open:f,onOpenChange:h,children:s.jsxs(Vj,{side:"right",className:"w-[96vw] max-w-none p-0 sm:max-w-5xl",children:[s.jsx(KD,{className:"border-b px-4 py-3 pr-12",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs(GD,{className:"text-base",children:["Result ",p]}),s.jsx(se,{asChild:!0,variant:"outline",size:"sm",children:s.jsx(yt,{to:`/results/${encodeURIComponent(p)}`,target:"_blank",rel:"noreferrer",children:"Open full page"})})]})}),s.jsx("div",{className:"h-[calc(100vh-64px)]",children:s.jsx("iframe",{title:`Result ${p}`,src:`/results/${encodeURIComponent(p)}?embed=1`,className:"h-full w-full border-0"})})]})}):null]})}const jge=()=>{const e=vs();return v.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),s.jsx("p",{className:"mb-4 text-xl text-muted-foreground",children:"Oops! Page not found"}),s.jsx("a",{href:"/",className:"text-primary underline hover:text-primary/90",children:"Return to Home"})]})})},Nge=new dV;function Cge(){const{scenarioId:e}=Mo();return s.jsx(pD,{to:e?`/libraries/test-cases/${encodeURIComponent(e)}`:"/libraries/test-cases",replace:!0})}const _ge=()=>s.jsx(pV,{client:Nge,children:s.jsx(Y$,{children:s.jsx(jG,{children:s.jsx(AG,{children:s.jsxs(_G,{children:[s.jsx(yq,{}),s.jsx(Xq,{}),s.jsx(hH,{children:s.jsxs(sH,{children:[s.jsxs(Xt,{element:s.jsx(CG,{}),children:[s.jsx(Xt,{path:"/",element:s.jsx(efe,{})}),s.jsx(Xt,{path:"/mcp-evaluations",element:s.jsx(kpe,{})}),s.jsx(Xt,{path:"/mcp-evaluations/:id",element:s.jsx(eM,{})}),s.jsx(Xt,{path:"/mcp-evaluations/:id/:tab",element:s.jsx(eM,{})}),s.jsx(Xt,{path:"/tool-analysis",element:s.jsx(Yve,{})}),s.jsx(Xt,{path:"/tool-analysis-results",element:s.jsx(Xve,{})}),s.jsx(Xt,{path:"/tool-analysis-results/:id",element:s.jsx(Qve,{})}),s.jsx(Xt,{path:"/oauth-debugger",element:s.jsx(nge,{})}),s.jsx(Xt,{path:"/libraries/servers",element:s.jsx(mme,{})}),s.jsx(Xt,{path:"/libraries/servers/:serverId",element:s.jsx(gme,{})}),s.jsx(Xt,{path:"/libraries/agents",element:s.jsx(yme,{})}),s.jsx(Xt,{path:"/libraries/agents/:agentName",element:s.jsx(Ove,{})}),s.jsx(Xt,{path:"/libraries/test-cases",element:s.jsx(lM,{})}),s.jsx(Xt,{path:"/libraries/test-cases/:testCaseId",element:s.jsx(lM,{})}),s.jsx(Xt,{path:"/libraries/scenarios",element:s.jsx(pD,{to:"/libraries/test-cases",replace:!0})}),s.jsx(Xt,{path:"/libraries/scenarios/:scenarioId",element:s.jsx(Cge,{})}),s.jsx(Xt,{path:"/settings",element:s.jsx(kve,{})}),s.jsx(Xt,{path:"/run",element:s.jsx(rge,{})}),s.jsx(Xt,{path:"/results",element:s.jsx(age,{})}),s.jsx(Xt,{path:"/results/:id",element:s.jsx(uge,{})}),s.jsx(Xt,{path:"/markdown-reports",element:s.jsx(xge,{})}),s.jsx(Xt,{path:"/markdown-reports/view",element:s.jsx(Sge,{})}),s.jsx(Xt,{path:"/compare",element:s.jsx(vge,{})}),s.jsx(Xt,{path:"/compare/results",element:s.jsx(gge,{})})]}),s.jsx(Xt,{path:"*",element:s.jsx(jge,{})})]})})]})})})})});SU.createRoot(document.getElementById("root")).render(s.jsx(_ge,{}));
249
+ `);try{window.sessionStorage.setItem(lge,JSON.stringify({type:"result-assistant-handoff-v1",runId:c.id,configId:kn||c.configId||"",scenarioId:fe.id,prompt:nt,sourceReply:G})),t(`/libraries/test-cases/${encodeURIComponent(fe.id)}?assistantHandoff=1`)}catch(Re){Pe({title:"Could not create handoff",description:Re instanceof Error?Re.message:String(Re),variant:"destructive"})}},vn=G=>{c&&(hn(!1),re(G),Ne(yM(c.id)),je(!1),xe(!0))},Ln=()=>{c&&(hn(!0),re(""),Ne(yM(c.id)),je(!1),xe(!0))},Gt=async()=>{if(!c)return;if(!Ie.trim()){Pe({title:"No markdown to write",description:"The selected assistant response is empty.",variant:"destructive"});return}dt(!0);try{const fe=await r.applyResultAssistantReport({runId:c.id,markdown:Ie,outputPath:me.trim()||void 0,overwrite:tt});Pe({title:"Markdown report written",description:typeof fe.path=="string"&&fe.path?fe.path:fe.outputPath}),await _r(c.id,typeof fe.path=="string"&&fe.path||fe.outputPath||void 0),K&&ue("reports"),xe(!1)}catch(fe){Pe({title:"Could not write markdown report",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}finally{dt(!1)}},An=async G=>{try{await navigator.clipboard.writeText(G),Pe({title:"Copied"})}catch(fe){Pe({title:"Could not copy",description:fe instanceof Error?fe.message:String(fe),variant:"destructive"})}};return s.jsxs("div",{className:`${K?"xl:flex xl:h-[calc(100vh-2rem-48px)] xl:min-h-0 xl:flex-col xl:overflow-hidden":""}`,children:[s.jsx("div",{className:`${K?"xl:shrink-0 xl:pb-6":"mb-6"}`,children:s.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[s.jsx(se,{variant:"ghost",size:"icon",asChild:!0,children:s.jsx(yt,{to:"/results",children:s.jsx(xo,{className:"h-4 w-4"})})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("h1",{className:"text-2xl font-bold font-mono",children:c.id}),s.jsx(vo,{rate:c.overallPassRate}),a&&c.snapshotEval?.applied&&s.jsxs(Ke,{variant:"outline",className:"text-xs",children:["Snapshot policy · ",c.snapshotEval.mode," · ",c.snapshotEval.status]})]}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[new Date(c.timestamp).toLocaleString()," · Config hash: ",s.jsx("span",{className:"font-mono",children:c.configHash})]}),a&&c.snapshotEval?.applied&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Baseline: ",s.jsx("span",{className:"font-mono",children:c.snapshotEval.baselineSnapshotId})," · score: ",c.snapshotEval.overallScore]})]})]}),s.jsxs("div",{className:"ml-auto flex shrink-0 flex-wrap items-center justify-end gap-2",children:[a&&c.snapshotEval?.applied&&s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>{Ca()},disabled:A,children:[s.jsx(wj,{className:"h-3.5 w-3.5"}),A?"Reviewing drift...":"Review Drift"]}),s.jsxs(se,{variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>{const G=oge(c),fe=new Blob([G],{type:"text/html"}),nt=URL.createObjectURL(fe),Re=document.createElement("a");Re.href=nt,Re.download=`mcplab-report-${c.id}.html`,Re.click(),URL.revokeObjectURL(nt)},children:[s.jsx(ga,{className:"h-3.5 w-3.5"}),"Download Report"]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>Nn(),disabled:qe,children:[s.jsx(rh,{className:"h-3.5 w-3.5"}),qe?"Reference Reports...":`Reference Reports${be.length?` (${be.length})`:""}`]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"shrink-0 gap-1.5",onClick:()=>wt(),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"MCP Labs Assistant"]})]})]})}),s.jsxs("div",{className:`grid gap-6 items-start ${K?Z?"xl:grid-cols-[minmax(0,1fr)_52rem] xl:flex-1 xl:min-h-0 xl:overflow-hidden":"xl:grid-cols-[minmax(0,1fr)_28rem] xl:flex-1 xl:min-h-0 xl:overflow-hidden":"grid-cols-1"}`,children:[s.jsxs("div",{className:`min-w-0 space-y-6 ${K?"xl:h-full xl:min-h-0 xl:overflow-y-auto xl:pr-2":""}`,children:[a&&c.snapshotEval?.applied&&s.jsxs(Be,{className:"border-amber-500/30",children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Snapshot Drift Review"})}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[s.jsxs(Ke,{variant:"outline",children:["Mode: ",c.snapshotEval.mode]}),s.jsxs(Ke,{variant:"outline",children:["Status: ",c.snapshotEval.status]}),s.jsxs(Ke,{variant:"outline",children:["Overall score: ",c.snapshotEval.overallScore]}),s.jsxs(Ke,{variant:"outline",className:"font-mono",children:["Baseline: ",c.snapshotEval.baselineSnapshotId]})]}),c.snapshotEval.impactedScenarios.length>0&&s.jsxs("p",{className:"text-xs text-muted-foreground",children:["Impacted scenarios: ",c.snapshotEval.impactedScenarios.join(", ")]}),s.jsxs("div",{className:"grid gap-3 lg:grid-cols-[1.2fr_1fr_auto] items-end",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Target config for baseline update"}),s.jsxs(sn,{value:k,onValueChange:R,children:[s.jsx(Jt,{className:"h-8",children:s.jsx(on,{placeholder:"Select config to update"})}),s.jsx(Zt,{children:i.map(G=>s.jsx(at,{value:G.id,children:G.name},G.id))})]}),!k&&s.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Tip: open results from the Run page to prefill the config automatically."})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"New snapshot name (optional)"}),s.jsx("div",{className:"relative",children:s.jsx("input",{value:$,onChange:G=>z(G.target.value),placeholder:`Snapshot ${c.id}`,className:"h-8 w-full rounded-md border bg-background px-2 text-xs"})})]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5",onClick:()=>{Ca()},disabled:A,children:[s.jsx(Fa,{className:`h-3.5 w-3.5 ${A?"animate-spin":""}`}),"Review Drift"]}),s.jsx(se,{type:"button",size:"sm",className:"h-8",onClick:()=>{ti()},disabled:B||c.overallPassRate!==1,children:B?"Accepting...":"Accept as New Baseline"})]})]}),c.overallPassRate!==1&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Baseline updates require a fully passing run (same rule as snapshot creation)."})]})]}),s.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-5",children:[s.jsx(Ts,{title:"Scenarios",value:c.totalScenarios,icon:p1}),s.jsx(Ts,{title:"Total Runs",value:c.totalRuns,icon:JM}),s.jsx(Ts,{title:"Pass Rate",value:`${Math.round(c.overallPassRate*100)}%`,icon:ed}),s.jsx(Ts,{title:"Avg Tool Calls",value:xM(c.avgToolCalls),icon:Ol}),s.jsx(Ts,{title:"Avg Latency",value:`${c.avgLatency}ms`,icon:l$})]}),s.jsxs("div",{className:"grid gap-6 lg:grid-cols-2",children:[s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-2",children:s.jsx(_t,{className:"text-base",children:"Pass / Fail"})}),s.jsxs(ze,{className:"flex items-center justify-center",children:[s.jsxs(Zde,{width:180,height:180,children:[s.jsx(Js,{data:it,dataKey:"value",innerRadius:50,outerRadius:75,paddingAngle:3,children:it.map((G,fe)=>s.jsx(cv,{fill:G.color},fe))}),s.jsx(Hr,{})]}),s.jsxs("div",{className:"ml-4 space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"h-3 w-3 rounded-full bg-success"}),le," passed"]}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("div",{className:"h-3 w-3 rounded-full bg-destructive"}),ke," failed"]})]})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-2",children:s.jsx(_t,{className:"text-base",children:"Tool Usage"})}),s.jsx(ze,{children:s.jsx(X1,{width:"100%",height:180,children:s.jsxs(Jde,{data:zt,layout:"vertical",children:[s.jsx(Ao,{type:"number",tick:{fontSize:11}}),s.jsx(Eo,{type:"category",dataKey:"name",tick:{fontSize:11},width:120}),s.jsx(Hr,{}),s.jsx(zo,{dataKey:"count",fill:"hsl(38, 92%, 50%)",radius:[0,4,4,0]})]})})})]})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx(_t,{className:"text-base",children:"Scenarios"}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-8 gap-1.5 px-2 text-xs",onClick:()=>wt("Summarize the scenario results in this run. Highlight failed scenarios/checks first, then mention notable tool usage and extracted values."),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Ask Assistant"]})]})}),s.jsxs(ze,{className:"p-0",children:[a&&s.jsxs("div",{className:"flex flex-wrap items-end gap-2 border-b p-3",children:[s.jsxs("div",{className:"min-w-60 space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Snapshot"}),s.jsxs(sn,{value:j,onValueChange:N,children:[s.jsx(Jt,{className:"h-8",children:s.jsx(on,{placeholder:"Select snapshot"})}),s.jsx(Zt,{children:b.map(G=>s.jsx(at,{value:G.id,children:G.name},G.id))})]})]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",disabled:!j||A,onClick:()=>{ei()},children:A?"Comparing...":"Compare Snapshot"}),_&&s.jsxs(Ke,{variant:"outline",className:"h-8 px-2 py-0 text-xs",children:["Overall snapshot score: ",_.overall_score]})]}),s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{className:"w-8"}),s.jsx(Qe,{children:"Scenario"}),s.jsx(Qe,{children:"Agent"}),s.jsx(Qe,{children:"Runs"}),s.jsx(Qe,{children:"Pass Rate"}),s.jsx(Qe,{children:"Tool Calls"}),s.jsx(Qe,{children:"Snapshot"})]})}),s.jsx(Jr,{children:c.scenarios.map(G=>{const fe=mr(G.scenarioId,G.agentName),nt=G.scenarioName||G.scenarioId;return s.jsx(Ci,{open:p.has(fe),onOpenChange:()=>tn(fe),asChild:!0,children:s.jsxs(s.Fragment,{children:[s.jsx(Rs,{asChild:!0,children:s.jsxs(Bt,{className:"cursor-pointer hover:bg-muted/50",children:[s.jsx(Fe,{children:s.jsx(qt,{className:`h-4 w-4 transition-transform ${p.has(fe)?"rotate-180":""}`})}),s.jsx(Fe,{className:"font-medium text-sm",children:G.scenarioName}),s.jsx(Fe,{className:"text-sm",children:G.agentName}),s.jsx(Fe,{className:"font-mono text-sm",children:G.runs.length}),s.jsx(Fe,{children:s.jsx(vo,{rate:G.passRate})}),s.jsx(Fe,{className:"font-mono text-sm",children:xM(G.avgToolCalls)}),s.jsx(Fe,{children:(()=>{const Re=vr.get(G.scenarioId);if(!Re)return s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"});const Ot=Re.status==="Match"?"bg-success/15 text-success":Re.status==="Warn"?"bg-amber-500/15 text-amber-600":"bg-destructive/15 text-destructive";return s.jsxs(Ke,{variant:"outline",className:`text-xs ${Ot}`,children:[Re.status," · ",Re.score]})})()})]})}),s.jsx(_i,{asChild:!0,children:s.jsx("tr",{children:s.jsx("td",{colSpan:7,className:"p-0",children:s.jsxs("div",{className:"bg-muted/30 p-4 space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border bg-card px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"text-xs font-semibold",children:"Scenario details"}),s.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[nt," · ",G.agentName," · ",Math.round(G.passRate*100),"% pass rate"]})]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs shrink-0",onClick:()=>wt(`Explain why scenario '${nt}' failed (agent: ${G.agentName}). Summarize the likely cause from the result details and suggest what to inspect next.`,{scenarioId:G.scenarioId}),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Ask Assistant"]})]}),(()=>{const Re=vr.get(G.scenarioId);return!Re||Re.reasons.length===0?null:s.jsxs("div",{className:"rounded-md border bg-card p-2",children:[s.jsx("p",{className:"mb-1 text-xs font-semibold text-muted-foreground",children:"Snapshot reasons"}),s.jsxs("p",{className:"mb-1 text-[11px] text-muted-foreground",children:["Baseline agents: ",Re.baseline_agents.join(", ")||"—"," · observed agents: ",Re.observed_agents.join(", ")||"—"]}),s.jsx("ul",{className:"space-y-1 text-xs text-muted-foreground",children:Re.reasons.map((Ot,Nt)=>s.jsxs("li",{children:["• ",Ot]},Nt))})]})})(),G.runs.map(Re=>s.jsxs("div",{className:"flex items-start gap-3 rounded-md border bg-card p-3 text-sm",children:[s.jsx("div",{className:"mt-0.5",children:Re.passed?s.jsx(Ol,{className:"h-4 w-4 text-success"}):s.jsx(Xp,{className:"h-4 w-4 text-destructive"})}),s.jsxs("div",{className:"flex-1 space-y-1",children:[(()=>{const Ot=cn.get(G.scenarioId),Nt=Ot?pge(Ot.evalRules,Re.failureReasons):[],Tn=Nt.filter(Yt=>Yt.status==="failed"),Ja=Nt.filter(Yt=>Yt.status==="passed");return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsxs("span",{className:"font-mono text-xs text-muted-foreground",children:["Run #",Re.runIndex+1]}),s.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),s.jsxs("span",{className:"text-xs text-muted-foreground",children:[Re.duration,"ms"]}),!Re.passed&&s.jsx(Ke,{variant:"outline",className:"h-5 border-destructive/30 bg-destructive/10 text-destructive text-[10px]",children:"Failed"})]}),Re.failureReasons.length>0&&s.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-2",children:[s.jsxs("p",{className:"mb-1 flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-destructive",children:[s.jsx(Xp,{className:"h-3.5 w-3.5"}),"Failure reasons"]}),s.jsx("ul",{className:"space-y-1 text-xs text-destructive",children:Re.failureReasons.map((Yt,Fn)=>s.jsxs("li",{children:["• ",SM(Yt)]},Fn))})]}),Nt.length>0&&s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"checks")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"checks")),children:s.jsxs("div",{className:"rounded-md border bg-muted/20 p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full flex-wrap items-center gap-2 text-left",children:[s.jsx(qt,{className:`h-3.5 w-3.5 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"checks"))?"rotate-180":""}`}),s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Checks"}),s.jsxs(Ke,{variant:"outline",className:"h-5 border-success/30 bg-success/10 text-success text-[10px]",children:[Ja.length," passed"]}),s.jsxs(Ke,{variant:"outline",className:`h-5 text-[10px] ${Tn.length>0?"border-destructive/30 bg-destructive/10 text-destructive":""}`,children:[Tn.length," failed"]})]})}),s.jsx(_i,{children:s.jsx("div",{className:"space-y-1",children:Nt.map((Yt,Fn)=>s.jsxs("div",{className:`flex items-start justify-between gap-2 rounded-md border px-2 py-1.5 text-xs ${Yt.status==="failed"?"border-destructive/20 bg-destructive/5":"border-success/20 bg-success/5"}`,children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Yt.status==="failed"?s.jsx(Xp,{className:"h-3.5 w-3.5 shrink-0 text-destructive"}):s.jsx(Ol,{className:"h-3.5 w-3.5 shrink-0 text-success"}),s.jsx("span",{className:"font-medium",children:mge(Yt.rule)})]}),Yt.failureReason&&s.jsx("p",{className:"mt-1 pl-5 text-[11px] text-destructive",children:SM(Yt.failureReason)})]}),s.jsx(Ke,{variant:"outline",className:`shrink-0 text-[10px] ${Yt.status==="failed"?"border-destructive/30 text-destructive":"border-success/30 text-success"}`,children:Yt.status})]},`${Yt.rule.type}-${Yt.rule.value}-${Fn}`))})})]})})]})})(),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"extracts")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"extracts")),children:s.jsxs("div",{className:"rounded-md border border-violet-500/20 bg-violet-500/5 p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full flex-wrap items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(qt,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"extracts"))?"rotate-180":""}`}),s.jsxs("p",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(p1,{className:"h-3.5 w-3.5 text-violet-600"}),"Extracted values"]})]}),s.jsxs(Ke,{variant:"outline",className:"h-5 text-[10px]",children:[Object.keys(Re.extractedValues??{}).length," total"]})]})}),s.jsx(_i,{children:Object.keys(Re.extractedValues??{}).length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No extracted values captured for this run."}):s.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:Object.entries(Re.extractedValues??{}).map(([Ot,Nt])=>s.jsxs("div",{className:"rounded-md border bg-background px-2 py-1.5 text-xs",children:[s.jsx("div",{className:"mb-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:Ot}),s.jsx("div",{className:"font-mono break-all text-foreground",children:Nt===null?"null":String(Nt)})]},Ot))})})]})}),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"tools")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"tools")),children:s.jsxs("div",{className:"rounded-md border border-sky-500/20 bg-sky-500/5 p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full flex-wrap items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[s.jsx(qt,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"tools"))?"rotate-180":""}`}),s.jsxs("p",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(Is,{className:"h-3.5 w-3.5 text-sky-600"}),"Tool call sequence"]})]}),s.jsxs(Ke,{variant:"outline",className:"h-5 text-[10px]",children:[Re.toolCalls.length," total"]})]})}),s.jsx(_i,{children:Re.toolCalls.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No tool calls captured for this run."}):s.jsx("div",{className:"flex flex-wrap gap-1",children:Re.toolCalls.map((Ot,Nt)=>s.jsxs(Ke,{variant:"outline",className:"font-mono text-xs bg-background",children:[s.jsxs("span",{className:"mr-1 text-muted-foreground",children:["#",Nt+1]}),Ot.name,s.jsxs("span",{className:"ml-1 text-muted-foreground",children:[Ot.duration,"ms"]})]},Nt))})})]})}),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"final")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"final")),children:s.jsxs("div",{className:"rounded-md border border-muted-foreground/20 bg-card p-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"mb-2 flex w-full items-center gap-2 text-left",children:[s.jsx(qt,{className:`h-3.5 w-3.5 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"final"))?"rotate-180":""}`}),s.jsxs("p",{className:"flex items-center gap-1 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:[s.jsx(ha,{className:"h-3.5 w-3.5"}),"Final answer"]})]})}),s.jsx(_i,{children:s.jsx(mj,{text:Re.finalAnswer||"No final answer captured.",maxLength:1200,className:"text-xs text-foreground"})})]})}),s.jsx(Ci,{open:Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation")),onOpenChange:()=>Vt(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation")),children:s.jsxs("div",{className:"rounded-md border bg-muted/10 p-2",children:[s.jsxs("div",{className:"mb-2 flex flex-wrap items-center justify-between gap-2",children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 text-left",children:[s.jsx(qt,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation"))?"rotate-180":""}`}),s.jsx("p",{className:"text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",children:"Conversation trace"})]})}),s.jsx("div",{className:"flex flex-wrap gap-2",children:s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>wt(`Explain Run #${Re.runIndex+1} for scenario '${nt}'. It ${Re.passed?"passed":"failed"} in ${Re.duration}ms. Focus on the tool sequence and ${Re.passed?"why it passed":"what caused the failure"}.`,{scenarioId:G.scenarioId}),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Ask Assistant"]})})]}),s.jsx(_i,{children:s.jsx("div",{className:"space-y-2 rounded-md border bg-muted/20 p-2",children:Re.conversation.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:"No conversation trace captured."}):Re.conversation.map(Ot=>s.jsx(dge,{item:Ot,fallbackUserPrompt:cn.get(G.scenarioId)?.prompt},Ot.id))})}),!Ht(Et(G.scenarioId,G.agentName,Re.runIndex,"conversation"))&&s.jsx("p",{className:"text-xs text-muted-foreground",children:"Expand to inspect user/assistant/tool messages for this run."})]})})]})]},Re.runIndex))]})})})})]})},fe)})})]})]})]})]}),K&&s.jsxs("div",{className:"min-w-0 space-y-0 xl:flex xl:h-full xl:min-h-0 xl:flex-col",children:[s.jsx(tC,{value:ae,onValueChange:G=>ue(G),className:"min-w-0 -mb-px px-3 pt-1",children:s.jsxs(Uv,{className:"h-auto w-full justify-start rounded-none border-b bg-transparent p-0",children:[s.jsx(Po,{value:"assistant",className:"-mb-px h-9 rounded-none rounded-t border border-border border-b-border bg-muted/20 px-3 text-xs text-muted-foreground data-[state=active]:z-10 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-border data-[state=active]:border-b-card data-[state=active]:shadow-none",children:"Assistant"}),s.jsx(Po,{value:"reports",className:"-mb-px h-9 rounded-none rounded-t border border-border border-b-border bg-muted/20 px-3 text-xs text-muted-foreground data-[state=active]:z-10 data-[state=active]:bg-card data-[state=active]:text-foreground data-[state=active]:border-border data-[state=active]:border-b-card data-[state=active]:shadow-none",children:"Reports"})]})}),ae==="assistant"?s.jsxs(Be,{className:"min-w-0 overflow-hidden rounded-t-none xl:flex xl:h-full xl:min-h-0 xl:flex-col",children:[s.jsx(Ct,{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs(_t,{className:"flex items-center gap-2 text-base",children:[s.jsx(fa,{className:"h-4 w-4 text-amber-500"}),"MCP Labs Assistant"]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:()=>ye(G=>!G),children:[Z?s.jsx(sE,{className:"h-3.5 w-3.5"}):s.jsx(iE,{className:"h-3.5 w-3.5"}),Z?"Compact":"Expand"]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>U(!1),children:"Hide"})]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Ask questions about this run result, failures, tool usage, and snapshot drift."})]})}),s.jsxs(ze,{className:"flex h-[70vh] min-h-[520px] flex-col p-0 xl:h-auto xl:min-h-0 xl:flex-1",children:[s.jsx(xm,{className:"min-h-0 flex-1 bg-muted/15 px-4 py-4",children:s.jsxs("div",{className:"space-y-3 pr-2",children:[J.map((G,fe)=>{const nt=G.role==="user",Re=G.role==="assistant",Ot=G.role==="system",Nt=G.role==="tool",Tn=G.pendingToolCallId?D.find(qc=>qc.id===G.pendingToolCallId):void 0,Ja=Re&&!!G.pendingToolCallId;if(Nt&&/^(Approved|Denied) tool call\b/i.test(String(G.text??"").trim()))return null;Tn?.server??G.toolRequestServer;const Yt=Tn?.tool??G.toolRequestName,Fn=Tn?.publicToolName??G.toolRequestPublicName,yf=Re&&!Ja&&fge(G.text,!!ie);if(Ja){const qc=Yt??Fn??"unknown_tool";return Yt&&Yt.replace(/^mcplab_/,"").replace(/_/g," "),s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("details",{open:!!Tn,className:"group min-w-0 w-full max-w-[92%] overflow-hidden rounded-md border border-border/60 bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-3 px-3 py-2",children:[s.jsx("div",{className:"min-w-0 flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Is,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),s.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:`Tool call ${qc}`}),s.jsx("span",{className:`shrink-0 whitespace-nowrap rounded px-1.5 py-0.5 text-[10px] font-semibold ${Tn?"bg-amber-100 text-amber-900":"bg-muted text-muted-foreground"}`,children:Tn?"Needs approval":"Completed"})]})}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"min-w-0 space-y-2 border-t border-border/50 px-3 py-2",children:[s.jsx(Zu,{text:G.text,className:"text-sm"}),Tn&&s.jsxs(s.Fragment,{children:[s.jsx("pre",{className:"max-h-40 min-w-0 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre-wrap break-words rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{className:"break-words",children:JSON.stringify(Tn.arguments??{},null,2)})}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{jt(Tn.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{Ze(Tn.id)},children:"Approve"})]})]})]})]})]},`${G.id??`${G.role}-${fe}`}:${Tn?"pending":"completed"}`)}const Lr=nt||Re&&!Nt&&!Ot;return s.jsxs("div",{className:`flex items-start gap-2 ${nt?"justify-end":"justify-start"}`,children:[!nt&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:Ot?s.jsx(i$,{className:"h-3 w-3"}):s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("div",{className:"relative max-w-[92%]",children:[s.jsxs("div",{className:`max-w-full rounded-md border p-3 text-sm ${nt?"border-primary/20 bg-primary/10":Ot?"border-amber-400/30 bg-amber-50/70":Nt?"border-blue-300/30 bg-blue-50/50":"border-border/80 bg-background shadow-sm"}`,children:[!(nt||Ot)&&s.jsx("p",{className:`mb-2 text-[11px] font-semibold text-muted-foreground ${nt?"text-right":""}`,children:Nt?"Tool":"Assistant"}),s.jsx(Zu,{text:G.text,className:"text-sm"}),yf&&s.jsxs("div",{className:"mt-3 flex max-w-full flex-wrap justify-end gap-2 overflow-x-auto pb-1",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>We(G.text),children:[s.jsx(fa,{className:"h-3.5 w-3.5"}),"Send to Scenario Assistant"]}),s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>vn(G.text),children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),"Apply: Write Markdown Report"]})]}),!yf&&Re&&!Ja&&s.jsx("div",{className:"mt-3 flex max-w-full justify-end overflow-x-auto pb-1",children:s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1.5 px-2 text-xs",onClick:()=>vn(G.text),children:[s.jsx(Is,{className:"h-3.5 w-3.5"}),"Apply: Write Markdown Report"]})})]}),Lr&&s.jsx(se,{type:"button",variant:"ghost",size:"icon",className:"absolute -right-8 bottom-1 h-6 w-6 text-muted-foreground",onClick:()=>{An(G.text)},"aria-label":"Copy message",title:"Copy message",children:s.jsx(Ri,{className:"h-3.5 w-3.5"})})]}),nt&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-primary/30 bg-primary/15 text-primary",children:s.jsx(Nj,{className:"h-3 w-3"})})]},G.id??`${G.role}-${fe}`)}),D.filter(G=>!J.some(fe=>fe.pendingToolCallId===G.id)).length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:"Pending actions (approve/deny)"}),D.filter(G=>!J.some(fe=>fe.pendingToolCallId===G.id)).map(G=>s.jsxs("details",{open:!0,className:"group min-w-0 rounded-md border bg-background",children:[s.jsxs("summary",{className:"flex cursor-pointer list-none items-center justify-between gap-2 p-3",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("p",{className:"break-all font-mono text-xs font-semibold",children:G.publicToolName}),s.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:[G.server,"::",G.tool]})]}),s.jsx(qt,{className:"h-4 w-4 shrink-0 text-muted-foreground transition-transform group-open:rotate-180"})]}),s.jsxs("div",{className:"border-t px-3 pb-3 pt-2",children:[s.jsx("pre",{className:"max-h-48 min-w-0 w-full max-w-full overflow-x-auto overflow-y-auto whitespace-pre-wrap break-words rounded border bg-muted/50 p-2 text-xs",children:s.jsx("code",{className:"break-words",children:JSON.stringify(G.arguments??{},null,2)})}),s.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[s.jsx(se,{type:"button",size:"sm",variant:"outline",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{jt(G.id)},children:"Deny"}),s.jsx(se,{type:"button",size:"sm",className:"h-7 px-2 text-xs",disabled:ee,onClick:()=>{Ze(G.id)},children:"Approve"})]})]})]},G.id))]}),ee&&s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700",children:s.jsx(ha,{className:"h-3 w-3"})}),s.jsxs("div",{className:"inline-flex items-center gap-2 rounded-md border bg-background px-3 py-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Thinking..."]})]}),s.jsx("div",{ref:Dr})]})}),s.jsx("div",{className:"border-t bg-background px-4 py-3",children:s.jsxs("div",{className:"rounded-xl border bg-background p-2 shadow-sm",children:[s.jsx(Ks,{ref:Cr,value:F,onChange:G=>M(G.target.value),placeholder:"Ask about this result...",rows:1,className:"min-h-10 max-h-40 resize-none border-0 bg-transparent px-2 py-1 text-sm shadow-none focus-visible:ring-0 focus-visible:ring-offset-0",onKeyDown:G=>{G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),ee||H())}}),s.jsxs("div",{className:"mt-1 flex items-center justify-between gap-2 px-1 pt-1",children:[s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsxs(se,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1 px-1.5 text-[11px] font-normal text-muted-foreground/80 hover:text-muted-foreground",disabled:ee,children:[s.jsx(us,{className:"h-3 w-3"}),"Snippets",s.jsx(qt,{className:"h-3 w-3"})]})}),s.jsxs(Wo,{align:"start",className:"w-[360px]",children:[s.jsx(JN,{children:"Result Assistant Snippets"}),s.jsx(ZN,{}),cge.map(G=>s.jsx(hr,{className:"items-start whitespace-normal px-2 py-2",onSelect:()=>ge(G.prompt),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"text-xs font-medium leading-tight",children:G.label}),s.jsx("div",{className:"text-[11px] leading-snug text-muted-foreground",children:G.description})]})},G.label))]})]}),s.jsx(se,{type:"button",size:"icon",className:"h-8 w-8 shrink-0 rounded-full",onClick:()=>{H()},disabled:ee||!F.trim(),"aria-label":"Send assistant message",title:"Send assistant message",children:ee?s.jsx(sr,{className:"h-4 w-4 animate-spin"}):s.jsxs(s.Fragment,{children:[s.jsx(o$,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Ask"})]})})]})]})})]})]}):s.jsxs(Be,{className:"min-w-0 overflow-hidden rounded-t-none xl:flex xl:h-full xl:min-h-0 xl:flex-col",children:[s.jsx(Ct,{className:"border-b px-4 py-3",children:s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs(_t,{className:"flex items-center gap-2 text-base",children:[s.jsx(rh,{className:"h-4 w-4 text-muted-foreground"}),"Reference Reports"]}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsxs(se,{type:"button",variant:"outline",size:"sm",className:"h-7 gap-1 px-2 text-xs",onClick:()=>ye(G=>!G),children:[Z?s.jsx(sE,{className:"h-3.5 w-3.5"}):s.jsx(iE,{className:"h-3.5 w-3.5"}),Z?"Compact":"Expand"]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>U(!1),children:"Hide"})]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Review markdown reports for this run while keeping the result visible."})]})}),s.jsxs(ze,{className:"flex h-[70vh] min-h-[520px] flex-col p-0 xl:h-auto xl:min-h-0 xl:flex-1",children:[(qe||be.length===0||be.length>1)&&s.jsx("div",{className:"border-b px-4 py-3",children:qe?s.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading reference reports..."}):be.length===0?s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"No reference reports for this run yet."}),s.jsxs(se,{type:"button",size:"sm",variant:"outline",className:"shrink-0 gap-1.5",onClick:()=>Ln(),children:[s.jsx(us,{className:"h-3.5 w-3.5"}),"New Report"]})]}):s.jsx("div",{className:"space-y-2",children:be.length>1?s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Selected report"}),s.jsxs(sn,{value:Dt,onValueChange:Mt,children:[s.jsx(Jt,{className:"h-8",children:s.jsx(on,{placeholder:"Select a report"})}),s.jsx(Zt,{children:be.map(G=>s.jsx(at,{value:G.relativePath,children:G.name},G.path))})]})]}):null})}),s.jsx(xm,{className:"min-h-0 flex-1 bg-muted/15 px-4 py-4",children:be.length===0?s.jsx("div",{className:"text-sm text-muted-foreground",children:"No report selected."}):or?s.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(sr,{className:"h-4 w-4 animate-spin"}),"Loading report..."]}):Na?s.jsxs("div",{className:"rounded-md border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive",children:["Could not load report: ",Na]}):mn?s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"rounded-md border bg-background p-3",children:[s.jsx("p",{className:"font-mono text-xs font-semibold",children:mn.name}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:mn.relativePath}),s.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground",children:new Date(mn.mtime).toLocaleString()})]}),s.jsx("div",{className:"rounded-md border bg-background p-3",children:s.jsx(Zu,{text:mn.content,className:"text-sm"})})]}):s.jsx("div",{className:"text-sm text-muted-foreground",children:"Select a report to preview."})})]})]})]}),s.jsx(bs,{open:he,onOpenChange:G=>!et&&xe(G),children:s.jsxs(Va,{className:"max-w-2xl",children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:Pt?"Create markdown report":"Approve MCP action: write markdown report"}),s.jsx(Ya,{children:Pt?"Write a custom markdown report and save it to the workspace.":s.jsxs(s.Fragment,{children:["This will call ",s.jsx("code",{children:"mcplab_write_markdown_report"})," via the local MCPLab MCP server."]})})]}),s.jsxs("div",{className:"space-y-3",children:[!Pt&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Output path"}),s.jsx(ht,{value:me,onChange:G=>Ne(G.target.value),placeholder:"mcplab/reports/result-assistant/my-report.md",disabled:et})]}),s.jsxs("label",{className:"flex items-center gap-2 text-sm",children:[s.jsx(va,{checked:tt,onCheckedChange:G=>je(G===!0),disabled:et}),s.jsx("span",{children:"Overwrite if file exists"})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:Pt?"Markdown content":"Markdown preview (to be written)"}),s.jsx(Ks,{value:Ie,onChange:G=>re(G.target.value),rows:10,className:"font-mono text-xs",disabled:et})]})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{disabled:et,children:"Cancel"}),s.jsx(Xa,{onClick:G=>{G.preventDefault(),Gt()},disabled:et,children:et?"Writing...":Pt?"Save Report":"Approve & Write"})]})]})})]})]})};function dge({item:e,fallbackUserPrompt:t}){if(e.kind==="tool_call")return s.jsx(wM,{variant:"call",title:`Tool call · ${e.toolName||"unknown"}`,text:e.text});if(e.kind==="tool_result"){const d=e.ok?s.jsx(Ol,{className:"h-3.5 w-3.5 text-emerald-700 dark:text-emerald-300"}):s.jsx(Xp,{className:"h-3.5 w-3.5 text-rose-700 dark:text-rose-300"});return s.jsx(wM,{variant:e.ok?"result_ok":"result_error",title:`Tool result · ${e.toolName||"unknown"} · ${e.ok?"ok":"error"}${typeof e.durationMs=="number"?` · ${e.durationMs}ms`:""}`,text:e.text,icon:d})}const n=e.kind==="user_prompt",r=bM(e.text,e.kind),a=t?bM(t,"user_prompt"):"",i=n&&a.length>r.length?a:r,o=n?"User prompt":e.kind==="assistant_final"?"Agent final":"Agent",c=n?Nj:ha;return s.jsxs("div",{className:`flex items-start gap-2 text-xs ${n?"justify-end":"justify-start"}`,children:[!n&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",children:s.jsx(c,{className:"h-3 w-3"})}),s.jsxs("div",{className:`max-w-[90%] rounded-md p-2 ${n?"bg-primary/10":"bg-muted/50"}`,children:[s.jsx("p",{className:`mb-1 text-[11px] font-semibold text-muted-foreground ${n?"text-right":""}`,children:o}),n?s.jsx(mj,{text:i,maxLength:280,className:"text-xs"}):s.jsx(mj,{text:i,maxLength:500,className:"text-xs"})]}),n&&s.jsx("div",{className:"mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border border-primary/30 bg-primary/15 text-primary",children:s.jsx(c,{className:"h-3 w-3"})})]})}function bM(e,t){const r=String(e??"").replace(/^\s+/,"");return t==="user_prompt"?r.replace(/^user:\s*/i,""):t==="assistant_final"||t==="assistant_thought"?r.replace(/^assistant:\s*/i,""):r}function fge(e,t){if(!t)return!1;const n=String(e??"").toLowerCase();if(!n.trim())return!1;const r=["check","checks","rule","rules","regex","pattern","value capture","extract rule","update","change","replace","modify","adjust","use ","set "],a=["change ","replace ","update ","use ","set the","suggested","you should","try ","text match failed","text must match pattern"];if(["i can only read","i don't have write access","i cannot directly edit","what happened","summary"].some(h=>n.includes(h))&&!a.some(h=>n.includes(h)))return!1;const o=r.some(h=>n.includes(h)),c=a.some(h=>n.includes(h)),d=/(^|\n)\s*[-*]\s+/.test(e)||/(^|\n)\s*\d+\.\s+/.test(e),f=/["'`][^"'`\n]{2,}["'`]/.test(e);return o&&(c||d||f)}function wM({variant:e,title:t,text:n,icon:r}){const[a,i]=v.useState(!1),o={call:"border-sky-500/30 bg-sky-500/10 text-sky-700 dark:text-sky-300",result_ok:"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300",result_error:"border-rose-500/30 bg-rose-500/10 text-rose-700 dark:text-rose-300"};return s.jsx(Ci,{open:a,onOpenChange:i,children:s.jsxs("div",{className:`rounded-md border p-2 text-xs ${o[e]}`,children:[s.jsx(Rs,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-2 text-left",children:[s.jsxs("div",{className:"flex items-center gap-1.5 font-mono text-[11px]",children:[r??s.jsx(Is,{className:"h-3.5 w-3.5"}),s.jsx("span",{children:t})]}),s.jsx("span",{className:"text-[11px] font-semibold",children:a?"Hide content":"Show content"})]})}),s.jsx(_i,{children:s.jsx("p",{className:"mt-2 font-mono whitespace-pre-wrap text-foreground",children:n})})]})})}function mj({text:e,maxLength:t,className:n}){const[r,a]=v.useState(!1),i=e.length>t,o=r||!i?e:`${e.slice(0,t)}...`;return s.jsxs("div",{children:[s.jsx(Zu,{text:o,className:n}),i&&s.jsx("button",{type:"button",className:"mt-1 text-[11px] font-medium text-primary hover:underline",onClick:()=>a(c=>!c),children:r?"Show less":"Show all"})]})}function pge(e,t){return e.map(n=>{const r=hge(n,t);return{rule:n,status:r?"failed":"passed",failureReason:r}})}function hge(e,t){const n=e.type==="required_tool"?`Required tool not used: ${e.value}`:e.type==="forbidden_tool"?`Forbidden tool used: ${e.value}`:`Regex assertion failed: ${e.value}`,r=t.find(a=>a===n);if(r)return r;if(e.type==="response_contains"||e.type==="response_not_contains")return t.find(a=>a.startsWith("Regex assertion failed:")&&a.includes(e.value))}function mge(e){return e.type==="required_tool"?`Required tool · ${e.value}`:e.type==="forbidden_tool"?`Forbidden tool · ${e.value}`:e.type==="response_contains"?`Text must match pattern · ${e.value}`:e.type==="response_not_contains"?`Text must not match pattern · ${e.value}`:`${e.type} · ${e.value}`}function SM(e){const t=String(e??"").trim(),n=t.match(/^Regex assertion failed:\s*(.+)$/i);return n?`Text match failed: ${n[1]}`:t}const jM=["hsl(38, 92%, 50%)","hsl(200, 80%, 50%)","hsl(152, 69%, 40%)","hsl(280, 60%, 50%)","hsl(0, 72%, 51%)"],vge=()=>{const{source:e}=On(),t=mf("snapshots",!1),[n,r]=v.useState([]),[a,i]=v.useState(!1),[o,c]=v.useState(new Set),[d,f]=v.useState("timestamp"),[h,p]=v.useState("desc"),[y,g]=v.useState("all"),[S,b]=v.useState("runs"),[x,j]=v.useState([]),[N,_]=v.useState(""),[P,A]=v.useState(""),[O,k]=v.useState(null),R=async()=>{i(!0);try{r(await e.listResults())}catch(T){Pe({title:"Could not load results",description:T instanceof Error?T.message:String(T),variant:"destructive"})}finally{i(!1)}};v.useEffect(()=>{let T=!0;return i(!0),e.listResults().then(D=>{T&&r(D)}).catch(D=>{T&&Pe({title:"Could not load results",description:D instanceof Error?D.message:String(D),variant:"destructive"})}).finally(()=>{T&&i(!1)}),()=>{T=!1}},[e]),v.useEffect(()=>{let T=!0;return e.listSnapshots().then(D=>{T&&j(D)}).catch(()=>{T&&j([])}),()=>{T=!1}},[e]);const $=T=>{if(d===T){p(D=>D==="asc"?"desc":"asc");return}f(T),p(T==="timestamp"?"desc":"asc")},z=T=>{c(D=>{const Q=new Set(D);return Q.has(T)?Q.delete(T):Q.add(T),Q})},B=v.useMemo(()=>{const T=new Set;return n.forEach(D=>{D.scenarios.forEach(Q=>{const F=String(Q.scenarioName??"").trim(),M=String(Q.scenarioId??"").trim(),ee=F||M;ee&&T.add(ee)})}),Array.from(T).sort((D,Q)=>D.localeCompare(Q))},[n]),L=v.useMemo(()=>y==="all"?n:n.filter(T=>T.scenarios.some(D=>{const Q=String(D.scenarioName??"").trim(),F=String(D.scenarioId??"").trim();return(Q||F)===y})),[n,y]),K=v.useMemo(()=>[...L].sort((D,Q)=>{let F=0;return d==="id"&&(F=D.id.localeCompare(Q.id)),d==="timestamp"&&(F=new Date(D.timestamp).getTime()-new Date(Q.timestamp).getTime()),d==="passRate"&&(F=D.overallPassRate-Q.overallPassRate),d==="scenarios"&&(F=D.totalScenarios-Q.totalScenarios),h==="asc"?F:-F}),[L,d,h]),U=K.filter(T=>o.has(T.id)),V=T=>d!==T?s.jsx(Pl,{className:"h-3.5 w-3.5 text-muted-foreground"}):h==="asc"?s.jsx(is,{className:"h-3.5 w-3.5"}):s.jsx(qt,{className:"h-3.5 w-3.5"}),X=T=>{const D=Array.from(new Set(T.scenarios.map(ee=>ee.scenarioId).filter(Boolean))),Q=Array.from(new Set(T.scenarios.map(ee=>ee.agentName).filter(Boolean))),F=D.slice(0,2).join(", "),M=D.length>2?` +${D.length-2}`:"";return{scenarioCount:D.length,agentCount:Q.length,scenarioPreview:F?`${F}${M}`:"n/a"}},J=[...new Set(U.flatMap(T=>T.scenarios.map(D=>D.scenarioId)))];return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(wj,{className:"h-6 w-6"}),"Compare Runs"]}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Select 2–5 runs to compare"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[S==="runs"&&s.jsxs(sn,{value:y,onValueChange:g,children:[s.jsx(Jt,{className:"w-[260px]",children:s.jsx(on,{placeholder:"Filter by scenario"})}),s.jsxs(Zt,{children:[s.jsx(at,{value:"all",children:"All scenarios"}),B.map(T=>s.jsx(at,{value:T,children:T},T))]})]}),s.jsx(se,{variant:"outline",onClick:()=>{R()},disabled:a,children:a?"Refreshing...":"Refresh"})]})]}),S==="runs"&&s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{className:"w-10"}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("id"),children:["Run ID",V("id")]})}),s.jsx(Qe,{children:"Evaluated"}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("timestamp"),children:["Timestamp",V("timestamp")]})}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("passRate"),children:["Pass Rate",V("passRate")]})}),s.jsx(Qe,{children:s.jsxs("button",{type:"button",className:"inline-flex items-center gap-1 hover:text-foreground",onClick:()=>$("scenarios"),children:["Scenarios",V("scenarios")]})})]})}),s.jsx(Jr,{children:K.map(T=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:s.jsx(va,{checked:o.has(T.id),onCheckedChange:()=>z(T.id),disabled:!o.has(T.id)&&o.size>=5})}),s.jsx(Fe,{className:"font-mono text-xs",children:T.id}),s.jsx(Fe,{className:"text-[11px] text-muted-foreground",children:(()=>{const D=X(T);return s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs("div",{children:["Evaluated: ",D.scenarioCount," scenario",D.scenarioCount===1?"":"s"," · ",D.agentCount," agent",D.agentCount===1?"":"s"]}),s.jsx("div",{className:"font-mono text-xs text-foreground/80",children:D.scenarioPreview})]})})()}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:new Date(T.timestamp).toLocaleString()}),s.jsx(Fe,{children:s.jsx(vo,{rate:T.overallPassRate})}),s.jsx(Fe,{className:"font-mono text-sm",children:T.totalScenarios})]},T.id))})]})})}),S==="runs"&&U.length>=2&&s.jsxs(s.Fragment,{children:[U.length===2&&s.jsx(Be,{children:s.jsx(ze,{className:"pt-6",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium",children:"Need a deeper comparison?"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Open the two selected runs in a dedicated side-by-side full result compare view."})]}),s.jsx(se,{asChild:!0,size:"sm",children:s.jsx(yt,{to:`/compare/results?left=${encodeURIComponent(U[0].id)}&right=${encodeURIComponent(U[1].id)}&leftConfig=${encodeURIComponent(U[0].configId)}&rightConfig=${encodeURIComponent(U[1].configId)}`,children:"Compare full results"})})]})})}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Summary Comparison"})}),s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Metric"}),U.map((T,D)=>s.jsx(Qe,{style:{color:jM[D]},className:"font-mono text-xs",children:T.id},T.id))]})}),s.jsxs(Jr,{children:[s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Pass Rate"}),U.map(T=>s.jsx(Fe,{children:s.jsx(vo,{rate:T.overallPassRate})},T.id))]}),s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Total Runs"}),U.map(T=>s.jsx(Fe,{className:"font-mono",children:T.totalRuns},T.id))]}),s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Tool Calls"}),U.map(T=>s.jsx(Fe,{className:"font-mono",children:T.avgToolCalls.toFixed(1)},T.id))]}),s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium",children:"Avg Latency"}),U.map(T=>s.jsxs(Fe,{className:"font-mono",children:[T.avgLatency,"ms"]},T.id))]})]})]})})]}),s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Scenario Breakdown"})}),s.jsx(ze,{className:"p-0",children:s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Scenario"}),U.map((T,D)=>s.jsx(Qe,{style:{color:jM[D]},className:"font-mono text-xs",children:T.id},T.id))]})}),s.jsx(Jr,{children:J.map(T=>s.jsxs(Bt,{children:[s.jsx(Fe,{className:"font-medium text-sm",children:T}),U.map(D=>{const Q=D.scenarios.find(F=>F.scenarioId===T);return s.jsx(Fe,{children:Q?s.jsx(vo,{rate:Q.passRate}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"—"})},D.id)})]},T))})]})})]})]}),t&&S==="snapshot"&&s.jsxs(Be,{children:[s.jsx(Ct,{className:"pb-3",children:s.jsx(_t,{className:"text-base",children:"Run vs Snapshot"})}),s.jsxs(ze,{className:"space-y-3",children:[s.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Run"}),s.jsxs(sn,{value:P,onValueChange:A,children:[s.jsx(Jt,{children:s.jsx(on,{placeholder:"Select run"})}),s.jsx(Zt,{children:n.map(T=>s.jsx(at,{value:T.id,children:T.id},T.id))})]})]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"Snapshot"}),s.jsxs(sn,{value:N,onValueChange:_,children:[s.jsx(Jt,{children:s.jsx(on,{placeholder:"Select snapshot"})}),s.jsx(Zt,{children:x.map(T=>s.jsx(at,{value:T.id,children:T.name},T.id))})]})]})]}),s.jsx(se,{type:"button",variant:"outline",size:"sm",disabled:!P||!N,onClick:()=>{e.compareSnapshot(N,P).then(k)},children:"Compare"}),O&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("p",{className:"text-sm font-medium",children:["Overall score: ",O.overall_score]}),s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Scenario"}),s.jsx(Qe,{children:"Agents"}),s.jsx(Qe,{children:"Score"}),s.jsx(Qe,{children:"Status"}),s.jsx(Qe,{children:"Reasons"})]})}),s.jsx(Jr,{children:O.scenario_results.map(T=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:T.scenario_id}),s.jsxs(Fe,{className:"text-xs text-muted-foreground",children:["baseline: ",T.baseline_agents.join(", ")||"—"," · observed: ",T.observed_agents.join(", ")||"—"]}),s.jsx(Fe,{className:"font-mono text-xs",children:T.score}),s.jsx(Fe,{children:T.status}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:T.reasons.slice(0,2).join("; ")||"—"})]},T.scenario_id))})]})]})]})]})]})},NM=(e,t)=>{const n=new URLSearchParams;return t&&n.set("configId",t),n.set("embed","1"),`/results/${encodeURIComponent(e)}?${n.toString()}`},gge=()=>{const[e]=Ec(),t=e.get("left")??"",n=e.get("right")??"",r=e.get("leftConfig"),a=e.get("rightConfig");return!t||!n?s.jsxs(Be,{children:[s.jsx(Ct,{children:s.jsx(_t,{className:"text-base",children:"Full Result Compare"})}),s.jsxs(ze,{className:"space-y-3",children:[s.jsx("p",{className:"text-sm text-muted-foreground",children:"Select exactly two runs in Compare and use the “Compare full results” action."}),s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:"/compare",children:"Back to Compare"})})]})]}):s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Full Result Compare"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Side-by-side Result Detail views for deep inspection."})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(se,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs(yt,{to:"/compare",children:[s.jsx(A7,{className:"mr-1.5 h-4 w-4"}),"Back to Compare"]})}),s.jsx(se,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:`/results/${encodeURIComponent(t)}${r?`?configId=${encodeURIComponent(r)}`:""}`,target:"_blank",rel:"noreferrer",children:["Open Left",s.jsx(nh,{className:"ml-1.5 h-3.5 w-3.5"})]})}),s.jsx(se,{variant:"outline",size:"sm",asChild:!0,children:s.jsxs("a",{href:`/results/${encodeURIComponent(n)}${a?`?configId=${encodeURIComponent(a)}`:""}`,target:"_blank",rel:"noreferrer",children:["Open Right",s.jsx(nh,{className:"ml-1.5 h-3.5 w-3.5"})]})})]})]}),s.jsxs("div",{className:"grid gap-4 xl:grid-cols-2",children:[s.jsxs(Be,{className:"overflow-hidden",children:[s.jsx(Ct,{className:"py-3",children:s.jsx(_t,{className:"text-sm font-mono",children:t})}),s.jsx(ze,{className:"p-0",children:s.jsx("iframe",{title:`Result ${t}`,src:NM(t,r),className:"h-[calc(100vh-15rem)] w-full border-0"})})]}),s.jsxs(Be,{className:"overflow-hidden",children:[s.jsx(Ct,{className:"py-3",children:s.jsx(_t,{className:"text-sm font-mono",children:n})}),s.jsx(ze,{className:"p-0",children:s.jsx("iframe",{title:`Result ${n}`,src:NM(n,a),className:"h-[calc(100vh-15rem)] w-full border-0"})})]})]})]})};function yge(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function xge(){const{source:e}=On(),[t,n]=v.useState([]),[r,a]=v.useState(!0),[i,o]=v.useState(null),[c,d]=v.useState(!1),f=async()=>{a(!0);try{n(await e.listMarkdownReports())}catch(g){Pe({title:"Could not load markdown reports",description:g instanceof Error?g.message:String(g),variant:"destructive"})}finally{a(!1)}};v.useEffect(()=>{f()},[]);const h=v.useMemo(()=>t[0],[t]),p=v.useMemo(()=>t.find(g=>g.relativePath===i)??null,[t,i]),y=async()=>{if(i){d(!0);try{await e.deleteMarkdownReport(i),n(g=>g.filter(S=>S.relativePath!==i)),Pe({title:"Markdown report deleted"}),o(null)}catch(g){Pe({title:"Could not delete markdown report",description:g instanceof Error?g.message:String(g),variant:"destructive"})}finally{d(!1)}}};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{children:[s.jsxs("h1",{className:"inline-flex items-center gap-2 text-2xl font-bold",children:[s.jsx(rh,{className:"h-6 w-6"}),"Markdown Reports"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["Browse Markdown files under ",s.jsx("code",{children:"mcplab/reports"}),"."]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(se,{variant:"outline",onClick:()=>{f()},children:"Refresh"}),h?s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:`/markdown-reports/view?path=${encodeURIComponent(h.relativePath)}`,children:"Open latest"})}):null]})]}),s.jsx(Be,{children:s.jsx(ze,{className:"p-0",children:r?s.jsx("p",{className:"p-6 text-sm text-muted-foreground",children:"Loading markdown reports..."}):t.length===0?s.jsx("p",{className:"p-6 text-sm text-muted-foreground",children:"No markdown reports found yet."}):s.jsxs(Xr,{children:[s.jsx(Qr,{children:s.jsxs(Bt,{children:[s.jsx(Qe,{children:"Report"}),s.jsx(Qe,{children:"Folder"}),s.jsx(Qe,{children:"Timestamp"}),s.jsx(Qe,{children:"Size"}),s.jsx(Qe,{className:"w-10"})]})}),s.jsx(Jr,{children:t.map(g=>s.jsxs(Bt,{children:[s.jsx(Fe,{children:s.jsxs("div",{className:"space-y-1",children:[s.jsx(yt,{to:`/markdown-reports/view?path=${encodeURIComponent(g.relativePath)}`,className:"font-mono text-xs text-primary hover:underline",children:g.name}),s.jsx("div",{className:"font-mono text-[11px] text-muted-foreground",children:g.relativePath})]})}),s.jsx(Fe,{className:"text-xs text-muted-foreground font-mono",children:g.relativePath.includes("/")?g.relativePath.slice(0,g.relativePath.lastIndexOf("/")):"."}),s.jsx(Fe,{className:"text-xs text-muted-foreground",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(Nm,{className:"h-3 w-3"}),new Date(g.mtime).toLocaleString()]})}),s.jsx(Fe,{className:"font-mono text-sm",children:yge(g.sizeBytes)}),s.jsx(Fe,{children:s.jsxs(Fc,{children:[s.jsx(Bc,{asChild:!0,children:s.jsx(se,{variant:"ghost",size:"icon",className:"h-8 w-8",children:s.jsx(Cm,{className:"h-4 w-4"})})}),s.jsxs(Wo,{align:"end",children:[s.jsx(hr,{asChild:!0,children:s.jsx(yt,{to:`/markdown-reports/view?path=${encodeURIComponent(g.relativePath)}`,children:"View"})}),s.jsxs(hr,{className:"text-destructive",onSelect:S=>{S.preventDefault(),o(g.relativePath)},children:[s.jsx(xa,{className:"mr-2 h-3.5 w-3.5"})," Delete"]})]})]})})]},g.path))})]})})}),s.jsx(bs,{open:!!i,onOpenChange:g=>!g&&o(null),children:s.jsxs(Va,{children:[s.jsxs(Ha,{children:[s.jsx(Ga,{children:"Delete markdown report?"}),s.jsx(Ya,{children:p?`Delete '${p.name}' from disk? This cannot be undone.`:"Delete this report from disk? This cannot be undone."})]}),s.jsxs(Ka,{children:[s.jsx(Qa,{disabled:c,children:"Cancel"}),s.jsx(Xa,{onClick:g=>{g.preventDefault(),y()},disabled:c,children:c?"Deleting...":"Delete"})]})]})})]})}function bge(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function wge(e){const t=e.relativePath.match(/(?:^|\/)(?:result-assistant|results?)\/([0-9]{8}-[0-9]{6})(?:-|\/)/i);return t?.[1]?t[1]:(e.content.match(/(?:^|\n)\s*\*\*Run:\*\*\s*`([^`]+)`/i)??e.content.match(/(?:^|\n)\s*Run ID:\s*([^\s]+)/i))?.[1]?.trim()||null}function Sge(){const{source:e}=On(),[t]=Ec(),n=(t.get("path")??"").trim(),[r,a]=v.useState(null),[i,o]=v.useState(!0),[c,d]=v.useState(!1),[f,h]=v.useState(!1);if(v.useEffect(()=>{let y=!0;if(a(null),d(!1),!n){o(!1);return}return o(!0),e.getMarkdownReport(n).then(g=>{y&&a(g)}).catch(g=>{if(!y)return;const S=g instanceof Error?g.message:String(g);if(S.includes("(404)")){d(!0);return}Pe({title:"Could not load markdown report",description:S,variant:"destructive"})}).finally(()=>{y&&o(!1)}),()=>{y=!1}},[n,e]),!n)return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Markdown Report"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Missing report path."}),s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:"/markdown-reports",children:"Back to Markdown Reports"})})]});if(i)return s.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading markdown report..."});if(c||!r)return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h1",{className:"text-2xl font-bold",children:"Markdown Report"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Report not found."}),s.jsx(se,{asChild:!0,variant:"outline",children:s.jsx(yt,{to:"/markdown-reports",children:"Back to Markdown Reports"})})]});const p=wge(r);return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h1",{className:"font-mono text-xl font-semibold",children:r.name}),s.jsx("p",{className:"truncate text-sm text-muted-foreground",children:r.relativePath}),s.jsxs("p",{className:"text-xs text-muted-foreground",children:[new Date(r.mtime).toLocaleString()," "," · "," ",bge(r.sizeBytes)]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[p?s.jsxs(s.Fragment,{children:[s.jsx(se,{variant:"outline",size:"sm",onClick:()=>h(!0),children:"Open Result Panel"}),s.jsx(se,{asChild:!0,variant:"outline",size:"sm",children:s.jsx(yt,{to:`/results/${encodeURIComponent(p)}`,children:"Open Result"})})]}):null,s.jsx(se,{asChild:!0,variant:"outline",size:"sm",children:s.jsx(yt,{to:"/markdown-reports",children:"Back to reports"})})]})]}),s.jsx(Be,{children:s.jsx(ze,{className:"pt-6",children:s.jsx(Zu,{text:r.content,variant:"assistant"})})}),p?s.jsx(VD,{open:f,onOpenChange:h,children:s.jsxs(Vj,{side:"right",className:"w-[96vw] max-w-none p-0 sm:max-w-5xl",children:[s.jsx(KD,{className:"border-b px-4 py-3 pr-12",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs(GD,{className:"text-base",children:["Result ",p]}),s.jsx(se,{asChild:!0,variant:"outline",size:"sm",children:s.jsx(yt,{to:`/results/${encodeURIComponent(p)}`,target:"_blank",rel:"noreferrer",children:"Open full page"})})]})}),s.jsx("div",{className:"h-[calc(100vh-64px)]",children:s.jsx("iframe",{title:`Result ${p}`,src:`/results/${encodeURIComponent(p)}?embed=1`,className:"h-full w-full border-0"})})]})}):null]})}const jge=()=>{const e=vs();return v.useEffect(()=>{console.error("404 Error: User attempted to access non-existent route:",e.pathname)},[e.pathname]),s.jsx("div",{className:"flex min-h-screen items-center justify-center bg-muted",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h1",{className:"mb-4 text-4xl font-bold",children:"404"}),s.jsx("p",{className:"mb-4 text-xl text-muted-foreground",children:"Oops! Page not found"}),s.jsx("a",{href:"/",className:"text-primary underline hover:text-primary/90",children:"Return to Home"})]})})},Nge=new dV;function Cge(){const{scenarioId:e}=Mo();return s.jsx(pD,{to:e?`/libraries/test-cases/${encodeURIComponent(e)}`:"/libraries/test-cases",replace:!0})}const _ge=()=>s.jsx(pV,{client:Nge,children:s.jsx(Y$,{children:s.jsx(jG,{children:s.jsx(AG,{children:s.jsxs(_G,{children:[s.jsx(yq,{}),s.jsx(Xq,{}),s.jsx(hH,{children:s.jsxs(sH,{children:[s.jsxs(Xt,{element:s.jsx(CG,{}),children:[s.jsx(Xt,{path:"/",element:s.jsx(efe,{})}),s.jsx(Xt,{path:"/mcp-evaluations",element:s.jsx(kpe,{})}),s.jsx(Xt,{path:"/mcp-evaluations/:id",element:s.jsx(eM,{})}),s.jsx(Xt,{path:"/mcp-evaluations/:id/:tab",element:s.jsx(eM,{})}),s.jsx(Xt,{path:"/tool-analysis",element:s.jsx(Yve,{})}),s.jsx(Xt,{path:"/tool-analysis-results",element:s.jsx(Xve,{})}),s.jsx(Xt,{path:"/tool-analysis-results/:id",element:s.jsx(Qve,{})}),s.jsx(Xt,{path:"/oauth-debugger",element:s.jsx(nge,{})}),s.jsx(Xt,{path:"/libraries/servers",element:s.jsx(mme,{})}),s.jsx(Xt,{path:"/libraries/servers/:serverId",element:s.jsx(gme,{})}),s.jsx(Xt,{path:"/libraries/agents",element:s.jsx(yme,{})}),s.jsx(Xt,{path:"/libraries/agents/:agentName",element:s.jsx(Ove,{})}),s.jsx(Xt,{path:"/libraries/test-cases",element:s.jsx(lM,{})}),s.jsx(Xt,{path:"/libraries/test-cases/:testCaseId",element:s.jsx(lM,{})}),s.jsx(Xt,{path:"/libraries/scenarios",element:s.jsx(pD,{to:"/libraries/test-cases",replace:!0})}),s.jsx(Xt,{path:"/libraries/scenarios/:scenarioId",element:s.jsx(Cge,{})}),s.jsx(Xt,{path:"/settings",element:s.jsx(kve,{})}),s.jsx(Xt,{path:"/run",element:s.jsx(rge,{})}),s.jsx(Xt,{path:"/results",element:s.jsx(age,{})}),s.jsx(Xt,{path:"/results/:id",element:s.jsx(uge,{})}),s.jsx(Xt,{path:"/markdown-reports",element:s.jsx(xge,{})}),s.jsx(Xt,{path:"/markdown-reports/view",element:s.jsx(Sge,{})}),s.jsx(Xt,{path:"/compare",element:s.jsx(vge,{})}),s.jsx(Xt,{path:"/compare/results",element:s.jsx(gge,{})})]}),s.jsx(Xt,{path:"*",element:s.jsx(jge,{})})]})})]})})})})});SU.createRoot(document.getElementById("root")).render(s.jsx(_ge,{}));