@mastra/deployer-cloud 1.43.0 → 1.43.1-alpha.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.
- package/CHANGELOG.md +11 -0
- package/dist/studio/assets/{core-XYsT5xMn.js → core-DhS8L9Xh.js} +1 -1
- package/dist/studio/assets/{index-C6slVcS9.js → index-B3kVQPaN.js} +2 -2
- package/dist/studio/assets/{main-DRlaxB9R.js → main-Mr82AqYT.js} +3 -3
- package/dist/studio/index.html +1 -1
- package/package.json +6 -6
- package/versions.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./core-DhS8L9Xh.js","./engine-compile-BkERmzkH.js","./preload-helper-PPVm8Dsz.js","./engine-javascript-CSIo_1eZ.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{_ as wo}from"./preload-helper-PPVm8Dsz.js";function O8t(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in e)){const a=Object.getOwnPropertyDescriptor(r,s);a&&Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var kj=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function mc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var UQ={exports:{}},qI={};var hIe;function _8t(){if(hIe)return qI;hIe=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,s,a){var i=null;if(a!==void 0&&(i=""+a),s.key!==void 0&&(i=""+s.key),"key"in s){a={};for(var l in s)l!=="key"&&(a[l]=s[l])}else a=s;return s=a.ref,{$$typeof:e,type:r,key:i,ref:s!==void 0?s:null,props:a}}return qI.Fragment=t,qI.jsx=n,qI.jsxs=n,qI}var mIe;function C8t(){return mIe||(mIe=1,UQ.exports=_8t()),UQ.exports}var o=C8t(),qQ={exports:{}},zr={},gIe;function E8t(){if(gIe)return zr;gIe=1;var e={env:{}};var t=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.for("react.activity"),h=Symbol.iterator;function m(U){return U===null||typeof U!="object"?null:(U=h&&U[h]||U["@@iterator"],typeof U=="function"?U:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function w(U,R,q){this.props=U,this.context=R,this.refs=b,this.updater=q||g}w.prototype.isReactComponent={},w.prototype.setState=function(U,R){if(typeof U!="object"&&typeof U!="function"&&U!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,U,R,"setState")},w.prototype.forceUpdate=function(U){this.updater.enqueueForceUpdate(this,U,"forceUpdate")};function S(){}S.prototype=w.prototype;function O(U,R,q){this.props=U,this.context=R,this.refs=b,this.updater=q||g}var _=O.prototype=new S;_.constructor=O,v(_,w.prototype),_.isPureReactComponent=!0;var C=Array.isArray;function j(){}var E={H:null,A:null,T:null,S:null},N=Object.prototype.hasOwnProperty;function I(U,R,q){var W=q.ref;return{$$typeof:t,type:U,key:R,ref:W!==void 0?W:null,props:q}}function P(U,R){return I(U.type,R,U.props)}function $(U){return typeof U=="object"&&U!==null&&U.$$typeof===t}function B(U){var R={"=":"=0",":":"=2"};return"$"+U.replace(/[=:]/g,function(q){return R[q]})}var D=/\/+/g;function V(U,R){return typeof U=="object"&&U!==null&&U.key!=null?B(""+U.key):R.toString(36)}function H(U){switch(U.status){case"fulfilled":return U.value;case"rejected":throw U.reason;default:switch(typeof U.status=="string"?U.then(j,j):(U.status="pending",U.then(function(R){U.status==="pending"&&(U.status="fulfilled",U.value=R)},function(R){U.status==="pending"&&(U.status="rejected",U.reason=R)})),U.status){case"fulfilled":return U.value;case"rejected":throw U.reason}}throw U}function L(U,R,q,W,X){var ne=typeof U;(ne==="undefined"||ne==="boolean")&&(U=null);var ee=!1;if(U===null)ee=!0;else switch(ne){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(U.$$typeof){case t:case n:ee=!0;break;case f:return ee=U._init,L(ee(U._payload),R,q,W,X)}}if(ee)return X=X(U),ee=W===""?"."+V(U,0):W,C(X)?(q="",ee!=null&&(q=ee.replace(D,"$&/")+"/"),L(X,R,q,"",function(ue){return ue})):X!=null&&($(X)&&(X=P(X,q+(X.key==null||U&&U.key===X.key?"":(""+X.key).replace(D,"$&/")+"/")+ee)),R.push(X)),1;ee=0;var J=W===""?".":W+":";if(C(U))for(var ie=0;ie<U.length;ie++)W=U[ie],ne=J+V(W,ie),ee+=L(W,R,q,ne,X);else if(ie=m(U),typeof ie=="function")for(U=ie.call(U),ie=0;!(W=U.next()).done;)W=W.value,ne=J+V(W,ie++),ee+=L(W,R,q,ne,X);else if(ne==="object"){if(typeof U.then=="function")return L(H(U),R,q,W,X);throw R=String(U),Error("Objects are not valid as a React child (found: "+(R==="[object Object]"?"object with keys {"+Object.keys(U).join(", ")+"}":R)+"). If you meant to render a collection of children, use an array instead.")}return ee}function F(U,R,q){if(U==null)return U;var W=[],X=0;return L(U,W,"","",function(ne){return R.call(q,ne,X++)}),W}function z(U){if(U._status===-1){var R=U._result;R=R(),R.then(function(q){(U._status===0||U._status===-1)&&(U._status=1,U._result=q)},function(q){(U._status===0||U._status===-1)&&(U._status=2,U._result=q)}),U._status===-1&&(U._status=0,U._result=R)}if(U._status===1)return U._result.default;throw U._result}var M=typeof reportError=="function"?reportError:function(U){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var R=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof U=="object"&&U!==null&&typeof U.message=="string"?String(U.message):String(U),error:U});if(!window.dispatchEvent(R))return}else if(typeof e=="object"&&typeof e.emit=="function"){e.emit("uncaughtException",U);return}console.error(U)},G={map:F,forEach:function(U,R,q){F(U,function(){R.apply(this,arguments)},q)},count:function(U){var R=0;return F(U,function(){R++}),R},toArray:function(U){return F(U,function(R){return R})||[]},only:function(U){if(!$(U))throw Error("React.Children.only expected to receive a single React element child.");return U}};return zr.Activity=p,zr.Children=G,zr.Component=w,zr.Fragment=r,zr.Profiler=a,zr.PureComponent=O,zr.StrictMode=s,zr.Suspense=u,zr.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,zr.__COMPILER_RUNTIME={__proto__:null,c:function(U){return E.H.useMemoCache(U)}},zr.cache=function(U){return function(){return U.apply(null,arguments)}},zr.cacheSignal=function(){return null},zr.cloneElement=function(U,R,q){if(U==null)throw Error("The argument must be a React element, but you passed "+U+".");var W=v({},U.props),X=U.key;if(R!=null)for(ne in R.key!==void 0&&(X=""+R.key),R)!N.call(R,ne)||ne==="key"||ne==="__self"||ne==="__source"||ne==="ref"&&R.ref===void 0||(W[ne]=R[ne]);var ne=arguments.length-2;if(ne===1)W.children=q;else if(1<ne){for(var ee=Array(ne),J=0;J<ne;J++)ee[J]=arguments[J+2];W.children=ee}return I(U.type,X,W)},zr.createContext=function(U){return U={$$typeof:l,_currentValue:U,_currentValue2:U,_threadCount:0,Provider:null,Consumer:null},U.Provider=U,U.Consumer={$$typeof:i,_context:U},U},zr.createElement=function(U,R,q){var W,X={},ne=null;if(R!=null)for(W in R.key!==void 0&&(ne=""+R.key),R)N.call(R,W)&&W!=="key"&&W!=="__self"&&W!=="__source"&&(X[W]=R[W]);var ee=arguments.length-2;if(ee===1)X.children=q;else if(1<ee){for(var J=Array(ee),ie=0;ie<ee;ie++)J[ie]=arguments[ie+2];X.children=J}if(U&&U.defaultProps)for(W in ee=U.defaultProps,ee)X[W]===void 0&&(X[W]=ee[W]);return I(U,ne,X)},zr.createRef=function(){return{current:null}},zr.forwardRef=function(U){return{$$typeof:c,render:U}},zr.isValidElement=$,zr.lazy=function(U){return{$$typeof:f,_payload:{_status:-1,_result:U},_init:z}},zr.memo=function(U,R){return{$$typeof:d,type:U,compare:R===void 0?null:R}},zr.startTransition=function(U){var R=E.T,q={};E.T=q;try{var W=U(),X=E.S;X!==null&&X(q,W),typeof W=="object"&&W!==null&&typeof W.then=="function"&&W.then(j,M)}catch(ne){M(ne)}finally{R!==null&&q.types!==null&&(R.types=q.types),E.T=R}},zr.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},zr.use=function(U){return E.H.use(U)},zr.useActionState=function(U,R,q){return E.H.useActionState(U,R,q)},zr.useCallback=function(U,R){return E.H.useCallback(U,R)},zr.useContext=function(U){return E.H.useContext(U)},zr.useDebugValue=function(){},zr.useDeferredValue=function(U,R){return E.H.useDeferredValue(U,R)},zr.useEffect=function(U,R){return E.H.useEffect(U,R)},zr.useEffectEvent=function(U){return E.H.useEffectEvent(U)},zr.useId=function(){return E.H.useId()},zr.useImperativeHandle=function(U,R,q){return E.H.useImperativeHandle(U,R,q)},zr.useInsertionEffect=function(U,R){return E.H.useInsertionEffect(U,R)},zr.useLayoutEffect=function(U,R){return E.H.useLayoutEffect(U,R)},zr.useMemo=function(U,R){return E.H.useMemo(U,R)},zr.useOptimistic=function(U,R){return E.H.useOptimistic(U,R)},zr.useReducer=function(U,R,q){return E.H.useReducer(U,R,q)},zr.useRef=function(U){return E.H.useRef(U)},zr.useState=function(U){return E.H.useState(U)},zr.useSyncExternalStore=function(U,R,q){return E.H.useSyncExternalStore(U,R,q)},zr.useTransition=function(){return E.H.useTransition()},zr.version="19.2.6",zr}var vIe;function VT(){return vIe||(vIe=1,qQ.exports=E8t()),qQ.exports}var y=VT();const De=mc(y),HT=O8t({__proto__:null,default:De},[y]);var VQ={exports:{}},VI={},HQ={exports:{}},ZQ={};var yIe;function j8t(){return yIe||(yIe=1,(function(e){function t(H,L){var F=H.length;H.push(L);e:for(;0<F;){var z=F-1>>>1,M=H[z];if(0<s(M,L))H[z]=L,H[F]=M,F=z;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var L=H[0],F=H.pop();if(F!==L){H[0]=F;e:for(var z=0,M=H.length,G=M>>>1;z<G;){var U=2*(z+1)-1,R=H[U],q=U+1,W=H[q];if(0>s(R,F))q<M&&0>s(W,R)?(H[z]=W,H[q]=F,z=q):(H[z]=R,H[U]=F,z=U);else if(q<M&&0>s(W,F))H[z]=W,H[q]=F,z=q;else break e}}return L}function s(H,L){var F=H.sortIndex-L.sortIndex;return F!==0?F:H.id-L.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var c=[],u=[],d=1,f=null,p=3,h=!1,m=!1,g=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,w=typeof clearTimeout=="function"?clearTimeout:null,S=typeof setImmediate<"u"?setImmediate:null;function O(H){for(var L=n(u);L!==null;){if(L.callback===null)r(u);else if(L.startTime<=H)r(u),L.sortIndex=L.expirationTime,t(c,L);else break;L=n(u)}}function _(H){if(g=!1,O(H),!m)if(n(c)!==null)m=!0,C||(C=!0,$());else{var L=n(u);L!==null&&V(_,L.startTime-H)}}var C=!1,j=-1,E=5,N=-1;function I(){return v?!0:!(e.unstable_now()-N<E)}function P(){if(v=!1,C){var H=e.unstable_now();N=H;var L=!0;try{e:{m=!1,g&&(g=!1,w(j),j=-1),h=!0;var F=p;try{t:{for(O(H),f=n(c);f!==null&&!(f.expirationTime>H&&I());){var z=f.callback;if(typeof z=="function"){f.callback=null,p=f.priorityLevel;var M=z(f.expirationTime<=H);if(H=e.unstable_now(),typeof M=="function"){f.callback=M,O(H),L=!0;break t}f===n(c)&&r(c),O(H)}else r(c);f=n(c)}if(f!==null)L=!0;else{var G=n(u);G!==null&&V(_,G.startTime-H),L=!1}}break e}finally{f=null,p=F,h=!1}L=void 0}}finally{L?$():C=!1}}}var $;if(typeof S=="function")$=function(){S(P)};else if(typeof MessageChannel<"u"){var B=new MessageChannel,D=B.port2;B.port1.onmessage=P,$=function(){D.postMessage(null)}}else $=function(){b(P,0)};function V(H,L){j=b(function(){H(e.unstable_now())},L)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(H){H.callback=null},e.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):E=0<H?Math.floor(1e3/H):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_next=function(H){switch(p){case 1:case 2:case 3:var L=3;break;default:L=p}var F=p;p=L;try{return H()}finally{p=F}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(H,L){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var F=p;p=H;try{return L()}finally{p=F}},e.unstable_scheduleCallback=function(H,L,F){var z=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?z+F:z):F=z,H){case 1:var M=-1;break;case 2:M=250;break;case 5:M=1073741823;break;case 4:M=1e4;break;default:M=5e3}return M=F+M,H={id:d++,callback:L,priorityLevel:H,startTime:F,expirationTime:M,sortIndex:-1},F>z?(H.sortIndex=F,t(u,H),n(c)===null&&H===n(u)&&(g?(w(j),j=-1):g=!0,V(_,F-z))):(H.sortIndex=M,t(c,H),m||h||(m=!0,C||(C=!0,$()))),H},e.unstable_shouldYield=I,e.unstable_wrapCallback=function(H){var L=p;return function(){var F=p;p=L;try{return H.apply(this,arguments)}finally{p=F}}}})(ZQ)),ZQ}var bIe;function T8t(){return bIe||(bIe=1,HQ.exports=j8t()),HQ.exports}var WQ={exports:{}},Jc={};var xIe;function N8t(){if(xIe)return Jc;xIe=1;var e=VT();function t(c){var u="https://react.dev/errors/"+c;if(1<arguments.length){u+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)u+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+c+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},s=Symbol.for("react.portal");function a(c,u,d){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:s,key:f==null?null:""+f,children:c,containerInfo:u,implementation:d}}var i=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(c,u){if(c==="font")return"";if(typeof u=="string")return u==="use-credentials"?u:""}return Jc.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Jc.createPortal=function(c,u){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!u||u.nodeType!==1&&u.nodeType!==9&&u.nodeType!==11)throw Error(t(299));return a(c,u,null,d)},Jc.flushSync=function(c){var u=i.T,d=r.p;try{if(i.T=null,r.p=2,c)return c()}finally{i.T=u,r.p=d,r.d.f()}},Jc.preconnect=function(c,u){typeof c=="string"&&(u?(u=u.crossOrigin,u=typeof u=="string"?u==="use-credentials"?u:"":void 0):u=null,r.d.C(c,u))},Jc.prefetchDNS=function(c){typeof c=="string"&&r.d.D(c)},Jc.preinit=function(c,u){if(typeof c=="string"&&u&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin),p=typeof u.integrity=="string"?u.integrity:void 0,h=typeof u.fetchPriority=="string"?u.fetchPriority:void 0;d==="style"?r.d.S(c,typeof u.precedence=="string"?u.precedence:void 0,{crossOrigin:f,integrity:p,fetchPriority:h}):d==="script"&&r.d.X(c,{crossOrigin:f,integrity:p,fetchPriority:h,nonce:typeof u.nonce=="string"?u.nonce:void 0})}},Jc.preinitModule=function(c,u){if(typeof c=="string")if(typeof u=="object"&&u!==null){if(u.as==null||u.as==="script"){var d=l(u.as,u.crossOrigin);r.d.M(c,{crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0})}}else u==null&&r.d.M(c)},Jc.preload=function(c,u){if(typeof c=="string"&&typeof u=="object"&&u!==null&&typeof u.as=="string"){var d=u.as,f=l(d,u.crossOrigin);r.d.L(c,d,{crossOrigin:f,integrity:typeof u.integrity=="string"?u.integrity:void 0,nonce:typeof u.nonce=="string"?u.nonce:void 0,type:typeof u.type=="string"?u.type:void 0,fetchPriority:typeof u.fetchPriority=="string"?u.fetchPriority:void 0,referrerPolicy:typeof u.referrerPolicy=="string"?u.referrerPolicy:void 0,imageSrcSet:typeof u.imageSrcSet=="string"?u.imageSrcSet:void 0,imageSizes:typeof u.imageSizes=="string"?u.imageSizes:void 0,media:typeof u.media=="string"?u.media:void 0})}},Jc.preloadModule=function(c,u){if(typeof c=="string")if(u){var d=l(u.as,u.crossOrigin);r.d.m(c,{as:typeof u.as=="string"&&u.as!=="script"?u.as:void 0,crossOrigin:d,integrity:typeof u.integrity=="string"?u.integrity:void 0})}else r.d.m(c)},Jc.requestFormReset=function(c){r.d.r(c)},Jc.unstable_batchedUpdates=function(c,u){return c(u)},Jc.useFormState=function(c,u,d){return i.H.useFormState(c,u,d)},Jc.useFormStatus=function(){return i.H.useHostTransitionStatus()},Jc.version="19.2.6",Jc}var wIe;function net(){if(wIe)return WQ.exports;wIe=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),WQ.exports=N8t(),WQ.exports}var SIe;function I8t(){if(SIe)return VI;SIe=1;var e={env:{}};var t=T8t(),n=VT(),r=net();function s(x){var k="https://react.dev/errors/"+x;if(1<arguments.length){k+="?args[]="+encodeURIComponent(arguments[1]);for(var T=2;T<arguments.length;T++)k+="&args[]="+encodeURIComponent(arguments[T])}return"Minified React error #"+x+"; visit "+k+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(x){return!(!x||x.nodeType!==1&&x.nodeType!==9&&x.nodeType!==11)}function i(x){var k=x,T=x;if(x.alternate)for(;k.return;)k=k.return;else{x=k;do k=x,(k.flags&4098)!==0&&(T=k.return),x=k.return;while(x)}return k.tag===3?T:null}function l(x){if(x.tag===13){var k=x.memoizedState;if(k===null&&(x=x.alternate,x!==null&&(k=x.memoizedState)),k!==null)return k.dehydrated}return null}function c(x){if(x.tag===31){var k=x.memoizedState;if(k===null&&(x=x.alternate,x!==null&&(k=x.memoizedState)),k!==null)return k.dehydrated}return null}function u(x){if(i(x)!==x)throw Error(s(188))}function d(x){var k=x.alternate;if(!k){if(k=i(x),k===null)throw Error(s(188));return k!==x?null:x}for(var T=x,A=k;;){var Z=T.return;if(Z===null)break;var Q=Z.alternate;if(Q===null){if(A=Z.return,A!==null){T=A;continue}break}if(Z.child===Q.child){for(Q=Z.child;Q;){if(Q===T)return u(Z),x;if(Q===A)return u(Z),k;Q=Q.sibling}throw Error(s(188))}if(T.return!==A.return)T=Z,A=Q;else{for(var oe=!1,Se=Z.child;Se;){if(Se===T){oe=!0,T=Z,A=Q;break}if(Se===A){oe=!0,A=Z,T=Q;break}Se=Se.sibling}if(!oe){for(Se=Q.child;Se;){if(Se===T){oe=!0,T=Q,A=Z;break}if(Se===A){oe=!0,A=Q,T=Z;break}Se=Se.sibling}if(!oe)throw Error(s(189))}}if(T.alternate!==A)throw Error(s(190))}if(T.tag!==3)throw Error(s(188));return T.stateNode.current===T?x:k}function f(x){var k=x.tag;if(k===5||k===26||k===27||k===6)return x;for(x=x.child;x!==null;){if(k=f(x),k!==null)return k;x=x.sibling}return null}var p=Object.assign,h=Symbol.for("react.element"),m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),O=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),j=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),I=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),$=Symbol.iterator;function B(x){return x===null||typeof x!="object"?null:(x=$&&x[$]||x["@@iterator"],typeof x=="function"?x:null)}var D=Symbol.for("react.client.reference");function V(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===D?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case v:return"Fragment";case w:return"Profiler";case b:return"StrictMode";case C:return"Suspense";case j:return"SuspenseList";case I:return"Activity"}if(typeof x=="object")switch(x.$$typeof){case g:return"Portal";case O:return x.displayName||"Context";case S:return(x._context.displayName||"Context")+".Consumer";case _:var k=x.render;return x=x.displayName,x||(x=k.displayName||k.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case E:return k=x.displayName||null,k!==null?k:V(x.type)||"Memo";case N:k=x._payload,x=x._init;try{return V(x(k))}catch{}}return null}var H=Array.isArray,L=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,z={pending:!1,data:null,method:null,action:null},M=[],G=-1;function U(x){return{current:x}}function R(x){0>G||(x.current=M[G],M[G]=null,G--)}function q(x,k){G++,M[G]=x.current,x.current=k}var W=U(null),X=U(null),ne=U(null),ee=U(null);function J(x,k){switch(q(ne,k),q(X,x),q(W,null),k.nodeType){case 9:case 11:x=(x=k.documentElement)&&(x=x.namespaceURI)?DNe(x):0;break;default:if(x=k.tagName,k=k.namespaceURI)k=DNe(k),x=LNe(k,x);else switch(x){case"svg":x=1;break;case"math":x=2;break;default:x=0}}R(W),q(W,x)}function ie(){R(W),R(X),R(ne)}function ue(x){x.memoizedState!==null&&q(ee,x);var k=W.current,T=LNe(k,x.type);k!==T&&(q(X,x),q(W,T))}function Y(x){X.current===x&&(R(W),R(X)),ee.current===x&&(R(ee),FI._currentValue=z)}var te,le;function fe(x){if(te===void 0)try{throw Error()}catch(T){var k=T.stack.trim().match(/\n( *(at )?)/);te=k&&k[1]||"",le=-1<T.stack.indexOf(`
|
|
3
3
|
at`)?" (<anonymous>)":-1<T.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
4
4
|
`+te+x+le}var se=!1;function he(x,k){if(!x||se)return"";se=!0;var T=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var A={DetermineComponentFrameRoot:function(){try{if(k){var Ot=function(){throw Error()};if(Object.defineProperty(Ot.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Ot,[])}catch(dt){var it=dt}Reflect.construct(x,[],Ot)}else{try{Ot.call()}catch(dt){it=dt}x.call(Ot.prototype)}}else{try{throw Error()}catch(dt){it=dt}(Ot=x())&&typeof Ot.catch=="function"&&Ot.catch(function(){})}}catch(dt){if(dt&&it&&typeof dt.stack=="string")return[dt.stack,it.stack]}return[null,null]}};A.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var Z=Object.getOwnPropertyDescriptor(A.DetermineComponentFrameRoot,"name");Z&&Z.configurable&&Object.defineProperty(A.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var Q=A.DetermineComponentFrameRoot(),oe=Q[0],Se=Q[1];if(oe&&Se){var Be=oe.split(`
|
|
@@ -223,7 +223,7 @@ Please change the parent <Route path="${v}"> to <Route path="${v==="/"?"*":`${v}
|
|
|
223
223
|
\${}
|
|
224
224
|
}
|
|
225
225
|
}`,{label:"class",detail:"definition",type:"keyword"}),Td('import {${names}} from "${module}"\n${}',{label:"import",detail:"named",type:"keyword"}),Td('import ${name} from "${module}"\n${}',{label:"import",detail:"default",type:"keyword"})],Cft=Rbe.concat([Td("interface ${name} {\n ${}\n}",{label:"interface",detail:"definition",type:"keyword"}),Td("type ${name} = ${type}",{label:"type",detail:"definition",type:"keyword"}),Td("enum ${name} {\n ${}\n}",{label:"enum",detail:"definition",type:"keyword"})]),fDe=new Nct,Eft=new Set(["Script","Block","FunctionExpression","FunctionDeclaration","ArrowFunction","MethodDeclaration","ForStatement"]);function fA(e){return(t,n)=>{let r=t.node.getChild("VariableDefinition");return r&&n(r,e),!0}}const e_n=["FunctionDeclaration"],t_n={FunctionDeclaration:fA("function"),ClassDeclaration:fA("class"),ClassExpression:()=>!0,EnumDeclaration:fA("constant"),TypeAliasDeclaration:fA("type"),NamespaceDeclaration:fA("namespace"),VariableDefinition(e,t){e.matchContext(e_n)||t(e,"variable")},TypeDefinition(e,t){t(e,"type")},__proto__:null};function jft(e,t){let n=fDe.get(t);if(n)return n;let r=[],s=!0;function a(i,l){let c=e.sliceString(i.from,i.to);r.push({label:c,type:l})}return t.cursor(Aa.IncludeAnonymous).iterate(i=>{if(s)s=!1;else if(i.name){let l=t_n[i.name];if(l&&l(i,a)||Eft.has(i.name))return!1}else if(i.to-i.from>8192){for(let l of jft(e,i.node))r.push(l);return!1}}),fDe.set(t,r),r}const KF=/^[\w$\xa1-\uffff][\w$\d\xa1-\uffff]*$/,Pbe=["TemplateString","String","RegExp","LineComment","BlockComment","VariableDefinition","TypeDefinition","Label","PropertyDefinition","PropertyName","PrivatePropertyDefinition","PrivatePropertyName","JSXText","JSXAttributeValue","JSXOpenTag","JSXCloseTag","JSXSelfClosingTag",".","?."];function Tft(e){let t=pi(e.state).resolveInner(e.pos,-1);if(Pbe.indexOf(t.name)>-1)return null;let n=t.name=="VariableName"||t.to-t.from<20&&KF.test(e.state.sliceDoc(t.from,t.to));if(!n&&!e.explicit)return null;let r=[];for(let s=t;s;s=s.parent)Eft.has(s.name)&&(r=r.concat(jft(e.state.doc,s)));return{options:r,from:n?t.from:e.pos,validFor:KF}}function HY(e,t,n){var r;let s=[];for(;;){let a=t.firstChild,i;if(a?.name=="VariableName")return s.push(e(a)),{path:s.reverse(),name:n};if(a?.name=="MemberExpression"&&((r=i=a.lastChild)===null||r===void 0?void 0:r.name)=="PropertyName")s.push(e(i)),t=a;else return null}}function Nft(e){let t=r=>e.state.doc.sliceString(r.from,r.to),n=pi(e.state).resolveInner(e.pos,-1);return n.name=="PropertyName"?HY(t,n.parent,t(n)):(n.name=="."||n.name=="?.")&&n.parent.name=="MemberExpression"?HY(t,n.parent,""):Pbe.indexOf(n.name)>-1?null:n.name=="VariableName"||n.to-n.from<20&&KF.test(t(n))?{path:[],name:t(n)}:n.name=="MemberExpression"?HY(t,n,""):e.explicit?{path:[],name:""}:null}function n_n(e,t){let n=e,r=[],s=new Set;for(let a=0;;a++){for(let l of(Object.getOwnPropertyNames||Object.keys)(e)){if(!/^[a-zA-Z_$\xaa-\uffdc][\w$\xaa-\uffdc]*$/.test(l)||s.has(l))continue;s.add(l);let c;try{c=n[l]}catch{continue}r.push({label:l,type:typeof c=="function"?/^[A-Z]/.test(l)?"class":t?"function":"method":t?"variable":"property",boost:-a})}let i=Object.getPrototypeOf(e);if(!i)return r;e=i}}function r_n(e){let t=new Map;return n=>{let r=Nft(n);if(!r)return null;let s=e;for(let i of r.path)if(s=s[i],!s)return null;let a=t.get(s);return a||t.set(s,a=n_n(s,!r.path.length)),{from:n.pos-r.name.length,options:a,validFor:KF}}}const jh=sO.define({name:"javascript",parser:JOn.configure({props:[f_.add({IfStatement:nj({except:/^\s*({|else\b)/}),TryStatement:nj({except:/^\s*({|catch\b|finally\b)/}),LabeledStatement:Xwn,SwitchBody:e=>{let t=e.textAfter,n=/^\s*\}/.test(t),r=/^\s*(case|default)\b/.test(t);return e.baseIndent+(n?0:r?1:2)*e.unit},Block:Ywn({closing:"}"}),ArrowFunction:e=>e.baseIndent+e.unit,"TemplateString BlockComment":()=>null,"Statement Property":nj({except:/^\s*{/}),JSXElement(e){let t=/^\s*<\//.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},JSXEscape(e){let t=/\s*\}/.test(e.textAfter);return e.lineIndent(e.node.from)+(t?0:e.unit)},"JSXOpenTag JSXSelfClosingTag"(e){return e.column(e.node.from)+e.unit}}),p_.add({"Block ClassBody SwitchBody EnumBody ObjectExpression ArrayExpression ObjectType":pbe,BlockComment(e){return{from:e.from+2,to:e.to-2}},JSXElement(e){let t=e.firstChild;if(!t||t.name=="JSXSelfClosingTag")return null;let n=e.lastChild;return{from:t.to,to:n.type.isError?e.to:n.from}},"JSXSelfClosingTag JSXOpenTag"(e){var t;let n=(t=e.firstChild)===null||t===void 0?void 0:t.nextSibling,r=e.lastChild;return!n||n.type.isError?null:{from:n.to,to:r.type.isError?e.to:r.from}}})]}),languageData:{closeBrackets:{brackets:["(","[","{","'",'"',"`"]},commentTokens:{line:"//",block:{open:"/*",close:"*/"}},indentOnInput:/^\s*(?:case |default:|\{|\}|<\/)$/,wordChars:"$"}}),Ift={test:e=>/^JSX/.test(e.name),facet:LU({commentTokens:{block:{open:"{/*",close:"*/}"}}})},$be=jh.configure({dialect:"ts"},"typescript"),Mbe=jh.configure({dialect:"jsx",props:[ube.add(e=>e.isTop?[Ift]:void 0)]}),Dbe=jh.configure({dialect:"jsx ts",props:[ube.add(e=>e.isTop?[Ift]:void 0)]},"typescript");let Aft=e=>({label:e,type:"keyword"});const Rft="break case const continue default delete export extends false finally in instanceof let new return static super switch this throw true typeof var yield".split(" ").map(Aft),s_n=Rft.concat(["declare","implements","private","protected","public"].map(Aft));function JF(e={}){let t=e.jsx?e.typescript?Dbe:Mbe:e.typescript?$be:jh,n=e.typescript?Cft.concat(s_n):Rbe.concat(Rft);return new iO(t,[jh.data.of({autocomplete:M1n(Pbe,Idt(n))}),jh.data.of({autocomplete:Tft}),e.jsx?Pft:[]])}function a_n(e){for(;;){if(e.name=="JSXOpenTag"||e.name=="JSXSelfClosingTag"||e.name=="JSXFragmentTag")return e;if(e.name=="JSXEscape"||!e.parent)return null;e=e.parent}}function pDe(e,t,n=e.length){for(let r=t?.firstChild;r;r=r.nextSibling)if(r.name=="JSXIdentifier"||r.name=="JSXBuiltin"||r.name=="JSXNamespacedName"||r.name=="JSXMemberExpression")return e.sliceString(r.from,Math.min(r.to,n));return""}const i_n=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Pft=Nt.inputHandler.of((e,t,n,r,s)=>{if((i_n?e.composing:e.compositionStarted)||e.state.readOnly||t!=n||r!=">"&&r!="/"||!jh.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u;let{head:d}=c,f=pi(i).resolveInner(d-1,-1),p;if(f.name=="JSXStartTag"&&(f=f.parent),!(i.doc.sliceString(d-1,d)!=r||f.name=="JSXAttributeValue"&&f.to>d)){if(r==">"&&f.name=="JSXFragmentTag")return{range:c,changes:{from:d,insert:"</>"}};if(r=="/"&&f.name=="JSXStartCloseTag"){let h=f.parent,m=h.parent;if(m&&h.from==d-2&&((p=pDe(i.doc,m.firstChild,d))||((u=m.firstChild)===null||u===void 0?void 0:u.name)=="JSXFragmentTag")){let g=`${p}>`;return{range:vt.cursor(d+g.length,-1),changes:{from:d,insert:g}}}}else if(r==">"){let h=a_n(f);if(h&&h.name=="JSXOpenTag"&&!/^\/?>|^<\//.test(i.doc.sliceString(d,d+2))&&(p=pDe(i.doc,h,d)))return{range:c,changes:{from:d,insert:`</${p}>`}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)});function o_n(e,t){return t||(t={parserOptions:{ecmaVersion:2019,sourceType:"module"},env:{browser:!0,node:!0,es6:!0,es2015:!0,es2017:!0,es2020:!0},rules:{}},e.getRules().forEach((n,r)=>{var s;!((s=n.meta.docs)===null||s===void 0)&&s.recommended&&(t.rules[r]=2)})),n=>{let{state:r}=n,s=[];for(let{from:a,to:i}of jh.findRegions(r)){let l=r.doc.lineAt(a),c={line:l.number-1,col:a-l.from,pos:a};for(let u of e.verify(r.sliceDoc(a,i),t))s.push(l_n(u,r.doc,c))}return s}}function hDe(e,t,n,r){return n.line(e+r.line).from+t+(e==1?r.col-1:-1)}function l_n(e,t,n){let r=hDe(e.line,e.column,t,n),s={from:r,to:e.endLine!=null&&e.endColumn!=1?hDe(e.endLine,e.endColumn,t,n):r,message:e.message,source:e.ruleId?"eslint:"+e.ruleId:"eslint",severity:e.severity==1?"warning":"error"};if(e.fix){let{range:a,text:i}=e.fix,l=a[0]+n.pos-r,c=a[1]+n.pos-r;s.actions=[{name:"fix",apply(u,d){u.dispatch({changes:{from:d+l,to:d+c,insert:i},scrollIntoView:!0})}}]}return s}const vL=Object.freeze(Object.defineProperty({__proto__:null,autoCloseTags:Pft,completionPath:Nft,esLint:o_n,javascript:JF,javascriptLanguage:jh,jsxLanguage:Mbe,localCompletionSource:Tft,scopeCompletionSource:r_n,snippets:Rbe,tsxLanguage:Dbe,typescriptLanguage:$be,typescriptSnippets:Cft},Symbol.toStringTag,{value:"Module"})),pA=["_blank","_self","_top","_parent"],ZY=["ascii","utf-8","utf-16","latin1","latin1"],WY=["get","post","put","delete"],QY=["application/x-www-form-urlencoded","multipart/form-data","text/plain"],Lf=["true","false"],Xn={},c_n={a:{attrs:{href:null,ping:null,type:null,media:null,target:pA,hreflang:null}},abbr:Xn,address:Xn,area:{attrs:{alt:null,coords:null,href:null,target:null,ping:null,media:null,hreflang:null,type:null,shape:["default","rect","circle","poly"]}},article:Xn,aside:Xn,audio:{attrs:{src:null,mediagroup:null,crossorigin:["anonymous","use-credentials"],preload:["none","metadata","auto"],autoplay:["autoplay"],loop:["loop"],controls:["controls"]}},b:Xn,base:{attrs:{href:null,target:pA}},bdi:Xn,bdo:Xn,blockquote:{attrs:{cite:null}},body:Xn,br:Xn,button:{attrs:{form:null,formaction:null,name:null,value:null,autofocus:["autofocus"],disabled:["autofocus"],formenctype:QY,formmethod:WY,formnovalidate:["novalidate"],formtarget:pA,type:["submit","reset","button"]}},canvas:{attrs:{width:null,height:null}},caption:Xn,center:Xn,cite:Xn,code:Xn,col:{attrs:{span:null}},colgroup:{attrs:{span:null}},command:{attrs:{type:["command","checkbox","radio"],label:null,icon:null,radiogroup:null,command:null,title:null,disabled:["disabled"],checked:["checked"]}},data:{attrs:{value:null}},datagrid:{attrs:{disabled:["disabled"],multiple:["multiple"]}},datalist:{attrs:{data:null}},dd:Xn,del:{attrs:{cite:null,datetime:null}},details:{attrs:{open:["open"]}},dfn:Xn,div:Xn,dl:Xn,dt:Xn,em:Xn,embed:{attrs:{src:null,type:null,width:null,height:null}},eventsource:{attrs:{src:null}},fieldset:{attrs:{disabled:["disabled"],form:null,name:null}},figcaption:Xn,figure:Xn,footer:Xn,form:{attrs:{action:null,name:null,"accept-charset":ZY,autocomplete:["on","off"],enctype:QY,method:WY,novalidate:["novalidate"],target:pA}},h1:Xn,h2:Xn,h3:Xn,h4:Xn,h5:Xn,h6:Xn,head:{children:["title","base","link","style","meta","script","noscript","command"]},header:Xn,hgroup:Xn,hr:Xn,html:{attrs:{manifest:null}},i:Xn,iframe:{attrs:{src:null,srcdoc:null,name:null,width:null,height:null,sandbox:["allow-top-navigation","allow-same-origin","allow-forms","allow-scripts"],seamless:["seamless"]}},img:{attrs:{alt:null,src:null,ismap:null,usemap:null,width:null,height:null,crossorigin:["anonymous","use-credentials"]}},input:{attrs:{alt:null,dirname:null,form:null,formaction:null,height:null,list:null,max:null,maxlength:null,min:null,name:null,pattern:null,placeholder:null,size:null,src:null,step:null,value:null,width:null,accept:["audio/*","video/*","image/*"],autocomplete:["on","off"],autofocus:["autofocus"],checked:["checked"],disabled:["disabled"],formenctype:QY,formmethod:WY,formnovalidate:["novalidate"],formtarget:pA,multiple:["multiple"],readonly:["readonly"],required:["required"],type:["hidden","text","search","tel","url","email","password","datetime","date","month","week","time","datetime-local","number","range","color","checkbox","radio","file","submit","image","reset","button"]}},ins:{attrs:{cite:null,datetime:null}},kbd:Xn,keygen:{attrs:{challenge:null,form:null,name:null,autofocus:["autofocus"],disabled:["disabled"],keytype:["RSA"]}},label:{attrs:{for:null,form:null}},legend:Xn,li:{attrs:{value:null}},link:{attrs:{href:null,type:null,hreflang:null,media:null,sizes:["all","16x16","16x16 32x32","16x16 32x32 64x64"]}},map:{attrs:{name:null}},mark:Xn,menu:{attrs:{label:null,type:["list","context","toolbar"]}},meta:{attrs:{content:null,charset:ZY,name:["viewport","application-name","author","description","generator","keywords"],"http-equiv":["content-language","content-type","default-style","refresh"]}},meter:{attrs:{value:null,min:null,low:null,high:null,max:null,optimum:null}},nav:Xn,noscript:Xn,object:{attrs:{data:null,type:null,name:null,usemap:null,form:null,width:null,height:null,typemustmatch:["typemustmatch"]}},ol:{attrs:{reversed:["reversed"],start:null,type:["1","a","A","i","I"]},children:["li","script","template","ul","ol"]},optgroup:{attrs:{disabled:["disabled"],label:null}},option:{attrs:{disabled:["disabled"],label:null,selected:["selected"],value:null}},output:{attrs:{for:null,form:null,name:null}},p:Xn,param:{attrs:{name:null,value:null}},pre:Xn,progress:{attrs:{value:null,max:null}},q:{attrs:{cite:null}},rp:Xn,rt:Xn,ruby:Xn,samp:Xn,script:{attrs:{type:["text/javascript"],src:null,async:["async"],defer:["defer"],charset:ZY}},section:Xn,select:{attrs:{form:null,name:null,size:null,autofocus:["autofocus"],disabled:["disabled"],multiple:["multiple"]}},slot:{attrs:{name:null}},small:Xn,source:{attrs:{src:null,type:null,media:null}},span:Xn,strong:Xn,style:{attrs:{type:["text/css"],media:null,scoped:null}},sub:Xn,summary:Xn,sup:Xn,table:Xn,tbody:Xn,td:{attrs:{colspan:null,rowspan:null,headers:null}},template:Xn,textarea:{attrs:{dirname:null,form:null,maxlength:null,name:null,placeholder:null,rows:null,cols:null,autofocus:["autofocus"],disabled:["disabled"],readonly:["readonly"],required:["required"],wrap:["soft","hard"]}},tfoot:Xn,th:{attrs:{colspan:null,rowspan:null,headers:null,scope:["row","col","rowgroup","colgroup"]}},thead:Xn,time:{attrs:{datetime:null}},title:Xn,tr:Xn,track:{attrs:{src:null,label:null,default:null,kind:["subtitles","captions","descriptions","chapters","metadata"],srclang:null}},ul:{children:["li","script","template","ul","ol"]},var:Xn,video:{attrs:{src:null,poster:null,width:null,height:null,crossorigin:["anonymous","use-credentials"],preload:["auto","metadata","none"],autoplay:["autoplay"],mediagroup:["movie"],muted:["muted"],controls:["controls"]}},wbr:Xn},$ft={accesskey:null,class:null,contenteditable:Lf,contextmenu:null,dir:["ltr","rtl","auto"],draggable:["true","false","auto"],dropzone:["copy","move","link","string:","file:"],hidden:["hidden"],id:null,inert:["inert"],itemid:null,itemprop:null,itemref:null,itemscope:["itemscope"],itemtype:null,lang:["ar","bn","de","en-GB","en-US","es","fr","hi","id","ja","pa","pt","ru","tr","zh"],spellcheck:Lf,autocorrect:Lf,autocapitalize:Lf,style:null,tabindex:null,title:null,translate:["yes","no"],rel:["stylesheet","alternate","author","bookmark","help","license","next","nofollow","noreferrer","prefetch","prev","search","tag"],role:"alert application article banner button cell checkbox complementary contentinfo dialog document feed figure form grid gridcell heading img list listbox listitem main navigation region row rowgroup search switch tab table tabpanel textbox timer".split(" "),"aria-activedescendant":null,"aria-atomic":Lf,"aria-autocomplete":["inline","list","both","none"],"aria-busy":Lf,"aria-checked":["true","false","mixed","undefined"],"aria-controls":null,"aria-describedby":null,"aria-disabled":Lf,"aria-dropeffect":null,"aria-expanded":["true","false","undefined"],"aria-flowto":null,"aria-grabbed":["true","false","undefined"],"aria-haspopup":Lf,"aria-hidden":Lf,"aria-invalid":["true","false","grammar","spelling"],"aria-label":null,"aria-labelledby":null,"aria-level":null,"aria-live":["off","polite","assertive"],"aria-multiline":Lf,"aria-multiselectable":Lf,"aria-owns":null,"aria-posinset":null,"aria-pressed":["true","false","mixed","undefined"],"aria-readonly":Lf,"aria-relevant":null,"aria-required":Lf,"aria-selected":["true","false","undefined"],"aria-setsize":null,"aria-sort":["ascending","descending","none","other"],"aria-valuemax":null,"aria-valuemin":null,"aria-valuenow":null,"aria-valuetext":null},Mft="beforeunload copy cut dragstart dragover dragleave dragenter dragend drag paste focus blur change click load mousedown mouseenter mouseleave mouseup keydown keyup resize scroll unload".split(" ").map(e=>"on"+e);for(let e of Mft)$ft[e]=null;let zP=class{constructor(t,n){this.tags={...c_n,...t},this.globalAttrs={...$ft,...n},this.allTags=Object.keys(this.tags),this.globalAttrNames=Object.keys(this.globalAttrs)}};zP.default=new zP;function Hj(e,t,n=e.length){if(!t)return"";let r=t.firstChild,s=r&&r.getChild("TagName");return s?e.sliceString(s.from,Math.min(s.to,n)):""}function Zj(e,t=!1){for(;e;e=e.parent)if(e.name=="Element")if(t)t=!1;else return e;return null}function Dft(e,t,n){let r=n.tags[Hj(e,Zj(t))];return r?.children||n.allTags}function Lbe(e,t){let n=[];for(let r=Zj(t);r&&!r.type.isTop;r=Zj(r.parent)){let s=Hj(e,r);if(s&&r.lastChild.name=="CloseTag")break;s&&n.indexOf(s)<0&&(t.name=="EndTag"||t.from>=r.firstChild.to)&&n.push(s)}return n}const Lft=/^[:\-\.\w\u00b7-\uffff]*$/;function mDe(e,t,n,r,s){let a=/\s*>/.test(e.sliceDoc(s,s+5))?"":">",i=Zj(n,n.name=="StartTag"||n.name=="TagName");return{from:r,to:s,options:Dft(e.doc,i,t).map(l=>({label:l,type:"type"})).concat(Lbe(e.doc,n).map((l,c)=>({label:"/"+l,apply:"/"+l+a,type:"type",boost:99-c}))),validFor:/^\/?[:\-\.\w\u00b7-\uffff]*$/}}function gDe(e,t,n,r){let s=/\s*>/.test(e.sliceDoc(r,r+5))?"":">";return{from:n,to:r,options:Lbe(e.doc,t).map((a,i)=>({label:a,apply:a+s,type:"type",boost:99-i})),validFor:Lft}}function u_n(e,t,n,r){let s=[],a=0;for(let i of Dft(e.doc,n,t))s.push({label:"<"+i,type:"type"});for(let i of Lbe(e.doc,n))s.push({label:"</"+i+">",type:"type",boost:99-a++});return{from:r,to:r,options:s,validFor:/^<\/?[:\-\.\w\u00b7-\uffff]*$/}}function d_n(e,t,n,r,s){let a=Zj(n),i=a?t.tags[Hj(e.doc,a)]:null,l=i&&i.attrs?Object.keys(i.attrs):[],c=i&&i.globalAttrs===!1?l:l.length?l.concat(t.globalAttrNames):t.globalAttrNames;return{from:r,to:s,options:c.map(u=>({label:u,type:"property"})),validFor:Lft}}function f_n(e,t,n,r,s){var a;let i=(a=n.parent)===null||a===void 0?void 0:a.getChild("AttributeName"),l=[],c;if(i){let u=e.sliceDoc(i.from,i.to),d=t.globalAttrs[u];if(!d){let f=Zj(n),p=f?t.tags[Hj(e.doc,f)]:null;d=p?.attrs&&p.attrs[u]}if(d){let f=e.sliceDoc(r,s).toLowerCase(),p='"',h='"';/^['"]/.test(f)?(c=f[0]=='"'?/^[^"]*$/:/^[^']*$/,p="",h=e.sliceDoc(s,s+1)==f[0]?"":f[0],f=f.slice(1),r++):c=/^[^\s<>='"]*$/;for(let m of d)l.push({label:m,apply:p+m+h,type:"constant"})}}return{from:r,to:s,options:l,validFor:c}}function Fft(e,t){let{state:n,pos:r}=t,s=pi(n).resolveInner(r,-1),a=s.resolve(r);for(let i=r,l;a==s&&(l=s.childBefore(i));){let c=l.lastChild;if(!c||!c.type.isError||c.from<c.to)break;a=s=l,i=c.from}return s.name=="TagName"?s.parent&&/CloseTag$/.test(s.parent.name)?gDe(n,s,s.from,r):mDe(n,e,s,s.from,r):s.name=="StartTag"||s.name=="IncompleteTag"?mDe(n,e,s,r,r):s.name=="StartCloseTag"||s.name=="IncompleteCloseTag"?gDe(n,s,r,r):s.name=="OpenTag"||s.name=="SelfClosingTag"||s.name=="AttributeName"?d_n(n,e,s,s.name=="AttributeName"?s.from:r,r):s.name=="Is"||s.name=="AttributeValue"||s.name=="UnquotedAttributeValue"?f_n(n,e,s,s.name=="Is"?r:s.from,r):t.explicit&&(a.name=="Element"||a.name=="Text"||a.name=="Document")?u_n(n,e,s,r):null}function p_n(e){return Fft(zP.default,e)}function h_n(e){let{extraTags:t,extraGlobalAttributes:n}=e,r=n||t?new zP(t,n):zP.default;return s=>Fft(r,s)}const m_n=jh.parser.configure({top:"SingleExpression"}),zft=[{tag:"script",attrs:e=>e.type=="text/typescript"||e.lang=="ts",parser:$be.parser},{tag:"script",attrs:e=>e.type=="text/babel"||e.type=="text/jsx",parser:Mbe.parser},{tag:"script",attrs:e=>e.type=="text/typescript-jsx",parser:Dbe.parser},{tag:"script",attrs(e){return/^(importmap|speculationrules|application\/(.+\+)?json)$/i.test(e.type)},parser:m_n},{tag:"script",attrs(e){return!e.type||/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(e.type)},parser:jh.parser},{tag:"style",attrs(e){return(!e.lang||e.lang=="css")&&(!e.type||/^(text\/)?(x-)?(stylesheet|css)$/i.test(e.type))},parser:XF.parser}],Bft=[{name:"style",parser:XF.parser.configure({top:"Styles"})}].concat(Mft.map(e=>({name:e,parser:jh.parser}))),Uft=sO.define({name:"html",parser:zkn.configure({props:[f_.add({Element(e){let t=/^(\s*)(<\/)?/.exec(e.textAfter);return e.node.to<=e.pos+t[0].length?e.continue():e.lineIndent(e.node.from)+(t[2]?0:e.unit)},"OpenTag CloseTag SelfClosingTag"(e){return e.column(e.node.from)+e.unit},Document(e){if(e.pos+/\s*/.exec(e.textAfter)[0].length<e.node.to)return e.continue();let t=null,n;for(let r=e.node;;){let s=r.lastChild;if(!s||s.name!="Element"||s.to!=r.to)break;t=r=s}return t&&!((n=t.lastChild)&&(n.name=="CloseTag"||n.name=="SelfClosingTag"))?e.lineIndent(t.from)+e.unit:null}}),p_.add({Element(e){let t=e.firstChild,n=e.lastChild;return!t||t.name!="OpenTag"?null:{from:t.to,to:n.name=="CloseTag"?n.from:e.to}}}),Odt.add({"OpenTag CloseTag":e=>e.getChild("TagName")})]}),languageData:{commentTokens:{block:{open:"<!--",close:"-->"}},indentOnInput:/^\s*<\/\w+\W$/,wordChars:"-_"}}),Q8=Uft.configure({wrap:bft(zft,Bft)});function g_n(e={}){let t="",n;e.matchClosingTags===!1&&(t="noMatch"),e.selfClosingTags===!0&&(t=(t?t+" ":"")+"selfClosing"),(e.nestedLanguages&&e.nestedLanguages.length||e.nestedAttributes&&e.nestedAttributes.length)&&(n=bft((e.nestedLanguages||[]).concat(zft),(e.nestedAttributes||[]).concat(Bft)));let r=n?Uft.configure({wrap:n,dialect:t}):t?Q8.configure({dialect:t}):Q8;return new iO(r,[Q8.data.of({autocomplete:h_n(e)}),e.autoCloseTags!==!1?v_n:[],JF().support,SOn().support])}const vDe=new Set("area base br col command embed frame hr img input keygen link meta param source track wbr menuitem".split(" ")),v_n=Nt.inputHandler.of((e,t,n,r,s)=>{if(e.composing||e.state.readOnly||t!=n||r!=">"&&r!="/"||!Q8.isActiveAt(e.state,t,-1))return!1;let a=s(),{state:i}=a,l=i.changeByRange(c=>{var u,d,f;let p=i.doc.sliceString(c.from-1,c.to)==r,{head:h}=c,m=pi(i).resolveInner(h,-1),g;if(p&&r==">"&&m.name=="EndTag"){let v=m.parent;if(((d=(u=v.parent)===null||u===void 0?void 0:u.lastChild)===null||d===void 0?void 0:d.name)!="CloseTag"&&(g=Hj(i.doc,v.parent,h))&&!vDe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),w=`</${g}>`;return{range:c,changes:{from:h,to:b,insert:w}}}}else if(p&&r=="/"&&m.name=="IncompleteCloseTag"){let v=m.parent;if(m.from==h-2&&((f=v.lastChild)===null||f===void 0?void 0:f.name)!="CloseTag"&&(g=Hj(i.doc,v,h))&&!vDe.has(g)){let b=h+(i.doc.sliceString(h,h+1)===">"?1:0),w=`${g}>`;return{range:vt.cursor(h+w.length,-1),changes:{from:h,to:b,insert:w}}}}return{range:c}});return l.changes.empty?!1:(e.dispatch([a,i.update(l,{userEvent:"input.complete",scrollIntoView:!0})]),!0)}),qft=LU({commentTokens:{block:{open:"<!--",close:"-->"}}}),Vft=new Rr,Hft=USn.configure({props:[p_.add(e=>!e.is("Block")||e.is("Document")||qde(e)!=null||y_n(e)?void 0:(t,n)=>({from:n.doc.lineAt(t.from).to,to:t.to})),Vft.add(qde),f_.add({Document:()=>null}),nw.add({Document:qft})]});function qde(e){let t=/^(?:ATX|Setext)Heading(\d)$/.exec(e.name);return t?+t[1]:void 0}function y_n(e){return e.name=="OrderedList"||e.name=="BulletList"}function b_n(e,t){let n=e;for(;;){let r=n.nextSibling,s;if(!r||(s=qde(r.type))!=null&&s<=t)break;n=r}return n.to}const x_n=fdt.of((e,t,n)=>{for(let r=pi(e).resolveInner(n,-1);r&&!(r.from<t);r=r.parent){let s=r.type.prop(Vft);if(s==null)continue;let a=b_n(r,s);if(a>n)return{from:n,to:a}}return null});function Fbe(e){return new lp(qft,e,[],"markdown")}const Zft=Fbe(Hft),w_n=Hft.configure([JSn,tkn,ekn,nkn,{props:[p_.add({Table:(e,t)=>({from:t.doc.lineAt(e.from).to,to:e.to})})]}]),cO=Fbe(w_n);function S_n(e,t){return n=>{if(n&&e){let r=null;if(n=/\S*/.exec(n)[0],typeof e=="function"?r=e(n):r=Im.matchLanguageName(e,n,!0),r instanceof Im)return r.support?r.support.language.parser:aO.getSkippingParser(r.load());if(r)return r.parser}return t?t.parser:null}}class GY{constructor(t,n,r,s,a,i,l){this.node=t,this.from=n,this.to=r,this.spaceBefore=s,this.spaceAfter=a,this.type=i,this.item=l}blank(t,n=!0){let r=this.spaceBefore+(this.node.name=="Blockquote"?">":"");if(t!=null){for(;r.length<t;)r+=" ";return r}else{for(let s=this.to-this.from-r.length-this.spaceAfter.length;s>0;s--)r+=" ";return r+(n?this.spaceAfter:"")}}marker(t,n){let r=this.node.name=="OrderedList"?String(+Qft(this.item,t)[2]+n):"";return this.spaceBefore+r+this.type+this.spaceAfter}}function Wft(e,t){let n=[],r=[];for(let s=e;s;s=s.parent){if(s.name=="FencedCode")return r;(s.name=="ListItem"||s.name=="Blockquote")&&n.push(s)}for(let s=n.length-1;s>=0;s--){let a=n[s],i,l=t.lineAt(a.from),c=a.from-l.from;if(a.name=="Blockquote"&&(i=/^ *>( ?)/.exec(l.text.slice(c))))r.push(new GY(a,c,c+i[0].length,"",i[1],">",null));else if(a.name=="ListItem"&&a.parent.name=="OrderedList"&&(i=/^( *)\d+([.)])( *)/.exec(l.text.slice(c)))){let u=i[3],d=i[0].length;u.length>=4&&(u=u.slice(0,u.length-4),d-=4),r.push(new GY(a.parent,c,c+d,i[1],u,i[2],a))}else if(a.name=="ListItem"&&a.parent.name=="BulletList"&&(i=/^( *)([-+*])( {1,4}\[[ xX]\])?( +)/.exec(l.text.slice(c)))){let u=i[4],d=i[0].length;u.length>4&&(u=u.slice(0,u.length-4),d-=4);let f=i[2];i[3]&&(f+=i[3].replace(/[xX]/," ")),r.push(new GY(a.parent,c,c+d,i[1],u,f,a))}}return r}function Qft(e,t){return/^(\s*)(\d+)(?=[.)])/.exec(t.sliceString(e.from,e.from+10))}function YY(e,t,n,r=0){for(let s=-1,a=e;;){if(a.name=="ListItem"){let l=Qft(a,t),c=+l[2];if(s>=0){if(c!=s+1)return;n.push({from:a.from+l[1].length,to:a.from+l[0].length,insert:String(s+2+r)})}s=c}let i=a.nextSibling;if(!i)break;a=i}}function zbe(e,t){let n=/^[ \t]*/.exec(e)[0].length;if(!n||t.facet(dN)!=" ")return e;let r=ag(e,4,n),s="";for(let a=r;a>0;)a>=4?(s+=" ",a-=4):(s+=" ",a--);return s+e.slice(n)}const Gft=(e={})=>({state:t,dispatch:n})=>{let r=pi(t),{doc:s}=t,a=null,i=t.changeByRange(l=>{if(!l.empty||!cO.isActiveAt(t,l.from,-1)&&!cO.isActiveAt(t,l.from,1))return a={range:l};let c=l.from,u=s.lineAt(c),d=Wft(r.resolveInner(c,-1),s);for(;d.length&&d[d.length-1].from>c-u.from;)d.pop();if(!d.length)return a={range:l};let f=d[d.length-1];if(f.to-f.spaceAfter.length>c-u.from)return a={range:l};let p=c>=f.to-f.spaceAfter.length&&!/\S/.test(u.text.slice(f.to));if(f.item&&p){let b=f.node.firstChild,w=f.node.getChild("ListItem","ListItem");if(b.to>=c||w&&w.to<c||u.from>0&&!/[^\s>]/.test(s.lineAt(u.from-1).text)||e.nonTightLists===!1){let S=d.length>1?d[d.length-2]:null,O,_="";S&&S.item?(O=u.from+S.from,_=S.marker(s,1)):O=u.from+(S?S.to:0);let C=[{from:O,to:c,insert:_}];return f.node.name=="OrderedList"&&YY(f.item,s,C,-2),S&&S.node.name=="OrderedList"&&YY(S.item,s,C),{range:vt.cursor(O+_.length),changes:C}}else{let S=bDe(d,t,u);return{range:vt.cursor(c+S.length+1),changes:{from:u.from,insert:S+t.lineBreak}}}}if(f.node.name=="Blockquote"&&p&&u.from){let b=s.lineAt(u.from-1),w=/>\s*$/.exec(b.text);if(w&&w.index==f.from){let S=t.changes([{from:b.from+w.index,to:b.to},{from:u.from+f.from,to:u.to}]);return{range:l.map(S),changes:S}}}let h=[];f.node.name=="OrderedList"&&YY(f.item,s,h);let m=f.item&&f.item.from<u.from,g="";if(!m||/^[\s\d.)\-+*>]*/.exec(u.text)[0].length>=f.to)for(let b=0,w=d.length-1;b<=w;b++)g+=b==w&&!m?d[b].marker(s,1):d[b].blank(b<w?ag(u.text,4,d[b+1].from)-g.length:null);let v=c;for(;v>u.from&&/\s/.test(u.text.charAt(v-u.from-1));)v--;return g=zbe(g,t),k_n(f.node,t.doc)&&(g=bDe(d,t,u)+t.lineBreak+g),h.push({from:v,to:c,insert:t.lineBreak+g}),{range:vt.cursor(v+g.length+1),changes:h}});return a?!1:(n(t.update(i,{scrollIntoView:!0,userEvent:"input"})),!0)},Yft=Gft();function yDe(e){return e.name=="QuoteMark"||e.name=="ListMark"}function k_n(e,t){if(e.name!="OrderedList"&&e.name!="BulletList")return!1;let n=e.firstChild,r=e.getChild("ListItem","ListItem");if(!r)return!1;let s=t.lineAt(n.to),a=t.lineAt(r.from),i=/^[\s>]*$/.test(s.text);return s.number+(i?0:1)<a.number}function bDe(e,t,n){let r="";for(let s=0,a=e.length-2;s<=a;s++)r+=e[s].blank(s<a?ag(n.text,4,e[s+1].from)-r.length:null,s<a);return zbe(r,t)}function O_n(e,t){let n=e.resolveInner(t,-1),r=t;yDe(n)&&(r=n.from,n=n.parent);for(let s;s=n.childBefore(r);)if(yDe(s))r=s.from;else if(s.name=="OrderedList"||s.name=="BulletList")n=s.lastChild,r=n.to;else break;return n}const Xft=({state:e,dispatch:t})=>{let n=pi(e),r=null,s=e.changeByRange(a=>{let i=a.from,{doc:l}=e;if(a.empty&&cO.isActiveAt(e,a.from)){let c=l.lineAt(i),u=Wft(O_n(n,i),l);if(u.length){let d=u[u.length-1],f=d.to-d.spaceAfter.length+(d.spaceAfter?1:0);if(i-c.from>f&&!/\S/.test(c.text.slice(f,i-c.from)))return{range:vt.cursor(c.from+f),changes:{from:c.from+f,to:i}};if(i-c.from==f&&(!d.item||c.from<=d.item.from||!/\S/.test(c.text.slice(0,d.to)))){let p=c.from+d.from;if(d.item&&d.node.from<d.item.from&&/\S/.test(c.text.slice(d.from,d.to))){let h=d.blank(ag(c.text,4,d.to)-ag(c.text,4,d.from));return p==c.from&&(h=zbe(h,e)),{range:vt.cursor(p+h.length),changes:{from:p,to:c.from+d.to,insert:h}}}if(p<i)return{range:vt.cursor(p),changes:{from:p,to:i}}}}}return r={range:a}});return r?!1:(t(e.update(s,{scrollIntoView:!0,userEvent:"delete"})),!0)},Kft=[{key:"Enter",run:Yft},{key:"Backspace",run:Xft}],Jft=g_n({matchClosingTags:!1});function Bbe(e={}){let{codeLanguages:t,defaultCodeLanguage:n,addKeymap:r=!0,base:{parser:s}=Zft,completeHTMLTags:a=!0,pasteURLAsLink:i=!0,htmlTagLanguage:l=Jft}=e;if(!(s instanceof UU))throw new RangeError("Base parser provided to `markdown` should be a Markdown parser");let c=e.extensions?[e.extensions]:[],u=[l.support,x_n],d;i&&u.push(ept),n instanceof iO?(u.push(n.support),d=n.language):n&&(d=n);let f=t||d?S_n(t,d):void 0;c.push(VSn({codeParser:f,htmlParser:l.language.parser})),r&&u.push(xg.high(uN.of(Kft)));let p=Fbe(s.configure(c));return a&&u.push(p.data.of({autocomplete:__n})),new iO(p,u)}function __n(e){let{state:t,pos:n}=e,r=/<[:\-\.\w\u00b7-\uffff]*$/.exec(t.sliceDoc(n-25,n));if(!r)return null;let s=pi(t).resolveInner(n,-1);for(;s&&!s.type.isTop;){if(s.name=="CodeBlock"||s.name=="FencedCode"||s.name=="ProcessingInstructionBlock"||s.name=="CommentBlock"||s.name=="Link"||s.name=="Image")return null;s=s.parent}return{from:n-r[0].length,to:n,options:C_n(),validFor:/^<[:\-\.\w\u00b7-\uffff]*$/}}let XY=null;function C_n(){if(XY)return XY;let e=p_n(new vbe(os.create({extensions:Jft}),0,!0));return XY=e?e.options:[]}const E_n=/code|horizontalrule|html|link|comment|processing|escape|entity|image|mark|url/i,ept=Nt.domEventHandlers({paste:(e,t)=>{var n;let{main:r}=t.state.selection;if(r.empty)return!1;let s=(n=e.clipboardData)===null||n===void 0?void 0:n.getData("text/plain");if(!s||!/^(https?:\/\/|mailto:|xmpp:|www\.)/.test(s)||(/^www\./.test(s)&&(s="https://"+s),!cO.isActiveAt(t.state,r.from,1)))return!1;let a=pi(t.state),i=!1;return a.iterate({from:r.from,to:r.to,enter:l=>{(l.from>r.from||E_n.test(l.name))&&(i=!0)},leave:l=>{l.to<r.to&&(i=!0)}}),i?!1:(t.dispatch({changes:[{from:r.from,insert:"["},{from:r.to,insert:`](${s})`}],userEvent:"input.paste",scrollIntoView:!0}),!0)}}),j_n=Object.freeze(Object.defineProperty({__proto__:null,commonmarkLanguage:Zft,deleteMarkupBackward:Xft,insertNewlineContinueMarkup:Yft,insertNewlineContinueMarkupCommand:Gft,markdown:Bbe,markdownKeymap:Kft,markdownLanguage:cO,pasteURLAsLink:ept},Symbol.toStringTag,{value:"Module"}));function uO(){return uO=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},uO.apply(null,arguments)}var T_n=e=>{var t=e.theme,n=e.settings,r=n===void 0?{}:n,s=e.styles,a=s===void 0?[]:s,i={".cm-gutters":{}},l={};r.background&&(l.backgroundColor=r.background),r.backgroundImage&&(l.backgroundImage=r.backgroundImage),r.foreground&&(l.color=r.foreground),r.fontSize&&(l.fontSize=r.fontSize),(r.background||r.foreground)&&(i["&"]=l),r.fontFamily&&(i["&.cm-editor .cm-scroller"]={fontFamily:r.fontFamily}),r.gutterBackground&&(i[".cm-gutters"].backgroundColor=r.gutterBackground),r.gutterForeground&&(i[".cm-gutters"].color=r.gutterForeground),r.gutterBorder&&(i[".cm-gutters"].borderRightColor=r.gutterBorder),r.caret&&(i[".cm-content"]={caretColor:r.caret},i[".cm-cursor, .cm-dropCursor"]={borderLeftColor:r.caret});var c={};r.gutterActiveForeground&&(c.color=r.gutterActiveForeground),r.lineHighlight&&(i[".cm-activeLine"]={backgroundColor:r.lineHighlight},c.backgroundColor=r.lineHighlight),i[".cm-activeLineGutter"]=c,r.selection&&(i["&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection"]={background:r.selection+" !important"}),r.selectionMatch&&(i["& .cm-selectionMatch"]={backgroundColor:r.selectionMatch});var u=Nt.theme(i,{dark:t==="dark"}),d=wg.define(a),f=[u,S1(d)];return f},N_n={background:"#282a36",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"rgba(255, 255, 255, 0.1)",selectionMatch:"rgba(255, 255, 255, 0.2)",gutterBackground:"#282a36",gutterForeground:"#6D8A88",gutterBorder:"transparent",lineHighlight:"rgba(255, 255, 255, 0.1)"},I_n=[{tag:de.comment,color:"#6272a4"},{tag:de.string,color:"#f1fa8c"},{tag:de.atom,color:"#bd93f9"},{tag:de.meta,color:"#f8f8f2"},{tag:[de.keyword,de.operator,de.tagName],color:"#ff79c6"},{tag:[de.function(de.propertyName),de.propertyName],color:"#66d9ef"},{tag:[de.definition(de.variableName),de.function(de.variableName),de.className,de.attributeName],color:"#50fa7b"},{tag:de.atom,color:"#bd93f9"}],pN=e=>{var t=e||{},n=t.theme,r=n===void 0?"dark":n,s=t.settings,a=s===void 0?{}:s,i=t.styles,l=i===void 0?[]:i;return T_n({theme:r,settings:uO({},N_n,a),styles:[...I_n,...l]})};pN();function tpt(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}const A_n=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=qbe(e.state,n.from);return r.line?R_n(e):r.block?$_n(e):!1};function Ube(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=e(t,n);return s?(r(n.update(s)),!0):!1}}const R_n=Ube(L_n,0),P_n=Ube(npt,0),$_n=Ube((e,t)=>npt(e,t,D_n(t)),0);function qbe(e,t){let n=e.languageDataAt("commentTokens",t,1);return n.length?n[0]:{}}const hA=50;function M_n(e,{open:t,close:n},r,s){let a=e.sliceDoc(r-hA,r),i=e.sliceDoc(s,s+hA),l=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(i)[0].length,u=a.length-l;if(a.slice(u-t.length,u)==t&&i.slice(c,c+n.length)==n)return{open:{pos:r-l,margin:l&&1},close:{pos:s+c,margin:c&&1}};let d,f;s-r<=2*hA?d=f=e.sliceDoc(r,s):(d=e.sliceDoc(r,r+hA),f=e.sliceDoc(s-hA,s));let p=/^\s*/.exec(d)[0].length,h=/\s*$/.exec(f)[0].length,m=f.length-h-n.length;return d.slice(p,p+t.length)==t&&f.slice(m,m+n.length)==n?{open:{pos:r+p+t.length,margin:/\s/.test(d.charAt(p+t.length))?1:0},close:{pos:s-h-n.length,margin:/\s/.test(f.charAt(m-1))?1:0}}:null}function D_n(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),s=n.to<=r.to?r:e.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=s.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return t}function npt(e,t,n=t.selection.ranges){let r=n.map(a=>qbe(t,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,i)=>M_n(t,r[i],a.from,a.to));if(e!=2&&!s.every(a=>a))return{changes:t.changes(n.map((a,i)=>s[i]?[]:[{from:a.from,insert:r[i].open+" "},{from:a.to,insert:" "+r[i].close}]))};if(e!=1&&s.some(a=>a)){let a=[];for(let i=0,l;i<s.length;i++)if(l=s[i]){let c=r[i],{open:u,close:d}=l;a.push({from:u.pos-c.open.length,to:u.pos+u.margin},{from:d.pos-d.margin,to:d.pos+c.close.length})}return{changes:a}}return null}function L_n(e,t,n=t.selection.ranges){let r=[],s=-1;e:for(let{from:a,to:i}of n){let l=r.length,c=1e9,u;for(let d=a;d<=i;){let f=t.doc.lineAt(d);if(u==null&&(u=qbe(t,f.from).line,!u))continue e;if(f.from>s&&(a==i||i>f.from)){s=f.from;let p=/^\s*/.exec(f.text)[0].length,h=p==f.length,m=f.text.slice(p,p+u.length)==u?p:-1;p<f.text.length&&p<c&&(c=p),r.push({line:f,comment:m,token:u,indent:p,empty:h,single:!1})}d=f.to+1}if(c<1e9)for(let d=l;d<r.length;d++)r[d].indent<r[d].line.text.length&&(r[d].indent=c);r.length==l+1&&(r[l].single=!0)}if(e!=2&&r.some(a=>a.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:l,token:c,indent:u,empty:d,single:f}of r)(f||!d)&&a.push({from:l.from+u,insert:c+" "});let i=t.changes(a);return{changes:i,selection:t.selection.map(i,1)}}else if(e!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:i,comment:l,token:c}of r)if(l>=0){let u=i.from+l,d=u+c.length;i.text[d-i.from]==" "&&d++,a.push({from:u,to:d})}return{changes:a}}return null}const Vde=py.define(),F_n=py.define(),z_n=wn.define(),rpt=wn.define({combine(e){return hy(e,{minDepth:100,newGroupDelay:500,joinToEvent:(t,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(t,n)=>(r,s)=>t(r,s)||n(r,s)})}}),spt=cl.define({create(){return xv.empty},update(e,t){let n=t.state.facet(rpt),r=t.annotation(Vde);if(r){let c=qd.fromTransaction(t,r.selection),u=r.side,d=u==0?e.undone:e.done;return c?d=ez(d,d.length,n.minDepth,c):d=opt(d,t.startState.selection),new xv(u==0?r.rest:d,u==0?d:r.rest)}let s=t.annotation(F_n);if((s=="full"||s=="before")&&(e=e.isolate()),t.annotation(Sl.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=qd.fromTransaction(t),i=t.annotation(Sl.time),l=t.annotation(Sl.userEvent);return a?e=e.addChanges(a,i,l,n,t):t.selection&&(e=e.addSelection(t.startState.selection,i,l,n.newGroupDelay)),(s=="full"||s=="after")&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(t=>t.toJSON()),undone:e.undone.map(t=>t.toJSON())}},fromJSON(e){return new xv(e.done.map(qd.fromJSON),e.undone.map(qd.fromJSON))}});function B_n(e={}){return[spt,rpt.of(e),Nt.domEventHandlers({beforeinput(t,n){let r=t.inputType=="historyUndo"?apt:t.inputType=="historyRedo"?Hde:null;return r?(t.preventDefault(),r(n)):!1}})]}function qU(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let s=n.field(spt,!1);if(!s)return!1;let a=s.pop(e,n,t);return a?(r(a),!0):!1}}const apt=qU(0,!1),Hde=qU(1,!1),U_n=qU(0,!0),q_n=qU(1,!0);class qd{constructor(t,n,r,s,a){this.changes=t,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(t){return new qd(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){var t,n,r;return{changes:(t=this.changes)===null||t===void 0?void 0:t.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(t){return new qd(t.changes&&xl.fromJSON(t.changes),[],t.mapped&&Rv.fromJSON(t.mapped),t.startSelection&&vt.fromJSON(t.startSelection),t.selectionsAfter.map(vt.fromJSON))}static fromTransaction(t,n){let r=yh;for(let s of t.startState.facet(z_n)){let a=s(t);a.length&&(r=r.concat(a))}return!r.length&&t.changes.empty?null:new qd(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,yh)}static selection(t){return new qd(void 0,yh,void 0,void 0,t)}}function ez(e,t,n,r){let s=t+1>n+20?t-n-1:0,a=e.slice(s,t);return a.push(r),a}function V_n(e,t){let n=[],r=!1;return e.iterChangedRanges((s,a)=>n.push(s,a)),t.iterChangedRanges((s,a,i,l)=>{for(let c=0;c<n.length;){let u=n[c++],d=n[c++];l>=u&&i<=d&&(r=!0)}}),r}function H_n(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((n,r)=>n.empty!=t.ranges[r].empty).length===0}function ipt(e,t){return e.length?t.length?e.concat(t):e:t}const yh=[],Z_n=200;function opt(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Z_n));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),ez(e,e.length-1,1e9,n.setSelAfter(r)))}else return[qd.selection([t])]}function W_n(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function KY(e,t){if(!e.length)return e;let n=e.length,r=yh;for(;n;){let s=Q_n(e[n-1],t,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=e.slice(0,n);return a[n-1]=s,a}else t=s.mapped,n--,r=s.selectionsAfter}return r.length?[qd.selection(r)]:yh}function Q_n(e,t,n){let r=ipt(e.selectionsAfter.length?e.selectionsAfter.map(l=>l.map(t)):yh,n);if(!e.changes)return qd.selection(r);let s=e.changes.map(t),a=t.mapDesc(e.changes,!0),i=e.mapped?e.mapped.composeDesc(a):a;return new qd(s,mr.mapEffects(e.effects,t),i,e.startSelection.map(a),r)}const G_n=/^(input\.type|delete)($|\.)/;class xv{constructor(t,n,r=0,s=void 0){this.done=t,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new xv(this.done,this.undone):this}addChanges(t,n,r,s,a){let i=this.done,l=i[i.length-1];return l&&l.changes&&!l.changes.empty&&t.changes&&(!r||G_n.test(r))&&(!l.selectionsAfter.length&&n-this.prevTime<s.newGroupDelay&&s.joinToEvent(a,V_n(l.changes,t.changes))||r=="input.type.compose")?i=ez(i,i.length-1,s.minDepth,new qd(t.changes.compose(l.changes),ipt(mr.mapEffects(t.effects,l.changes),l.effects),l.mapped,l.startSelection,yh)):i=ez(i,i.length,s.minDepth,t),new xv(i,yh,n,r)}addSelection(t,n,r,s){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:yh;return a.length>0&&n-this.prevTime<s&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&H_n(a[a.length-1],t)?this:new xv(opt(this.done,t),this.undone,n,r)}addMapping(t){return new xv(KY(this.done,t),KY(this.undone,t),this.prevTime,this.prevUserEvent)}pop(t,n,r){let s=t==0?this.done:this.undone;if(s.length==0)return null;let a=s[s.length-1],i=a.selectionsAfter[0]||(a.startSelection?a.startSelection.map(a.changes.invertedDesc,1):n.selection);if(r&&a.selectionsAfter.length)return n.update({selection:a.selectionsAfter[a.selectionsAfter.length-1],annotations:Vde.of({side:t,rest:W_n(s),selection:i}),userEvent:t==0?"select.undo":"select.redo",scrollIntoView:!0});if(a.changes){let l=s.length==1?yh:s.slice(0,s.length-1);return a.mapped&&(l=KY(l,a.mapped)),n.update({changes:a.changes,selection:a.startSelection,effects:a.effects,annotations:Vde.of({side:t,rest:l,selection:i}),filter:!1,userEvent:t==0?"undo":"redo",scrollIntoView:!0})}else return null}}xv.empty=new xv(yh,yh);const Y_n=[{key:"Mod-z",run:apt,preventDefault:!0},{key:"Mod-y",mac:"Mod-Shift-z",run:Hde,preventDefault:!0},{linux:"Ctrl-Shift-z",run:Hde,preventDefault:!0},{key:"Mod-u",run:U_n,preventDefault:!0},{key:"Alt-u",mac:"Mod-Shift-u",run:q_n,preventDefault:!0}];function hN(e,t){return vt.create(e.ranges.map(t),e.mainIndex)}function Sg(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:"select"})}function kg({state:e,dispatch:t},n){let r=hN(e.selection,n);return r.eq(e.selection,!0)?!1:(t(Sg(e,r)),!0)}function VU(e,t){return vt.cursor(t?e.to:e.from)}function lpt(e,t){return kg(e,n=>n.empty?e.moveByChar(n,t):VU(n,t))}function Nu(e){return e.textDirectionAt(e.state.selection.main.head)==xi.LTR}const cpt=e=>lpt(e,!Nu(e)),upt=e=>lpt(e,Nu(e));function dpt(e,t){return kg(e,n=>n.empty?e.moveByGroup(n,t):VU(n,t))}const X_n=e=>dpt(e,!Nu(e)),K_n=e=>dpt(e,Nu(e));function J_n(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function HU(e,t,n){let r=pi(e).resolveInner(t.head),s=n?Rr.closedBy:Rr.openedBy;for(let c=t.head;;){let u=n?r.childAfter(c):r.childBefore(c);if(!u)break;J_n(e,u,s)?r=u:c=n?u.to:u.from}let a=r.type.prop(s),i,l;return a&&(i=n?bv(e,r.from,1):bv(e,r.to,-1))&&i.matched?l=n?i.end.to:i.end.from:l=n?r.to:r.from,vt.cursor(l,n?-1:1)}const eCn=e=>kg(e,t=>HU(e.state,t,!Nu(e))),tCn=e=>kg(e,t=>HU(e.state,t,Nu(e)));function fpt(e,t){return kg(e,n=>{if(!n.empty)return VU(n,t);let r=e.moveVertically(n,t);return r.head!=n.head?r:e.moveToLineBoundary(n,t)})}const ppt=e=>fpt(e,!1),hpt=e=>fpt(e,!0);function mpt(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,s;if(t){for(let a of e.state.facet(Nt.scrollMargins)){let i=a(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}s=e.scrollDOM.clientHeight-n-r}else s=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,s-5)}}function gpt(e,t){let n=mpt(e),{state:r}=e,s=hN(r.selection,i=>i.empty?e.moveVertically(i,t,n.height):VU(i,t));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let i=e.coordsAtPos(r.selection.main.head),l=e.scrollDOM.getBoundingClientRect(),c=l.top+n.marginTop,u=l.bottom-n.marginBottom;i&&i.top>c&&i.bottom<u&&(a=Nt.scrollIntoView(s.main.head,{y:"start",yMargin:i.top-c}))}return e.dispatch(Sg(r,s),{effects:a}),!0}const xDe=e=>gpt(e,!1),Zde=e=>gpt(e,!0);function k1(e,t,n){let r=e.lineBlockAt(t.head),s=e.moveToLineBoundary(t,n);if(s.head==t.head&&s.head!=(n?r.to:r.from)&&(s=e.moveToLineBoundary(t,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&t.head!=r.from+a&&(s=vt.cursor(r.from+a))}return s}const nCn=e=>kg(e,t=>k1(e,t,!0)),rCn=e=>kg(e,t=>k1(e,t,!1)),sCn=e=>kg(e,t=>k1(e,t,!Nu(e))),aCn=e=>kg(e,t=>k1(e,t,Nu(e))),iCn=e=>kg(e,t=>vt.cursor(e.lineBlockAt(t.head).from,1)),oCn=e=>kg(e,t=>vt.cursor(e.lineBlockAt(t.head).to,-1));function lCn(e,t,n){let r=!1,s=hN(e.selection,a=>{let i=bv(e,a.head,-1)||bv(e,a.head,1)||a.head>0&&bv(e,a.head-1,1)||a.head<e.doc.length&&bv(e,a.head+1,-1);if(!i||!i.end)return a;r=!0;let l=i.start.from==a.head?i.end.to:i.end.from;return vt.cursor(l)});return r?(t(Sg(e,s)),!0):!1}const cCn=({state:e,dispatch:t})=>lCn(e,t);function Kh(e,t){let n=hN(e.state.selection,r=>{let s=t(r);return vt.range(r.anchor,s.head,s.goalColumn,s.bidiLevel||void 0,s.assoc)});return n.eq(e.state.selection)?!1:(e.dispatch(Sg(e.state,n)),!0)}function vpt(e,t){return Kh(e,n=>e.moveByChar(n,t))}const ypt=e=>vpt(e,!Nu(e)),bpt=e=>vpt(e,Nu(e));function xpt(e,t){return Kh(e,n=>e.moveByGroup(n,t))}const uCn=e=>xpt(e,!Nu(e)),dCn=e=>xpt(e,Nu(e)),fCn=e=>Kh(e,t=>HU(e.state,t,!Nu(e))),pCn=e=>Kh(e,t=>HU(e.state,t,Nu(e)));function wpt(e,t){return Kh(e,n=>e.moveVertically(n,t))}const Spt=e=>wpt(e,!1),kpt=e=>wpt(e,!0);function Opt(e,t){return Kh(e,n=>e.moveVertically(n,t,mpt(e).height))}const wDe=e=>Opt(e,!1),SDe=e=>Opt(e,!0),hCn=e=>Kh(e,t=>k1(e,t,!0)),mCn=e=>Kh(e,t=>k1(e,t,!1)),gCn=e=>Kh(e,t=>k1(e,t,!Nu(e))),vCn=e=>Kh(e,t=>k1(e,t,Nu(e))),yCn=e=>Kh(e,t=>vt.cursor(e.lineBlockAt(t.head).from)),bCn=e=>Kh(e,t=>vt.cursor(e.lineBlockAt(t.head).to)),kDe=({state:e,dispatch:t})=>(t(Sg(e,{anchor:0})),!0),ODe=({state:e,dispatch:t})=>(t(Sg(e,{anchor:e.doc.length})),!0),_De=({state:e,dispatch:t})=>(t(Sg(e,{anchor:e.selection.main.anchor,head:0})),!0),CDe=({state:e,dispatch:t})=>(t(Sg(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),xCn=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:"select"})),!0),wCn=({state:e,dispatch:t})=>{let n=ZU(e).map(({from:r,to:s})=>vt.range(r,Math.min(s+1,e.doc.length)));return t(e.update({selection:vt.create(n),userEvent:"select"})),!0},SCn=({state:e,dispatch:t})=>{let n=hN(e.selection,r=>{let s=pi(e),a=s.resolveStack(r.from,1);if(r.empty){let i=s.resolveStack(r.from,-1);i.node.from>=a.node.from&&i.node.to<=a.node.to&&(a=i)}for(let i=a;i;i=i.next){let{node:l}=i;if((l.from<r.from&&l.to>=r.to||l.to>r.to&&l.from<=r.from)&&i.next)return vt.range(l.to,l.from)}return r});return n.eq(e.selection)?!1:(t(Sg(e,n)),!0)};function _pt(e,t){let{state:n}=e,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let i=n.doc.lineAt(a.head);if(t?i.to<e.state.doc.length:i.from>0)for(let l=a;;){let c=e.moveVertically(l,t);if(c.head<i.from||c.head>i.to){s.some(u=>u.head==c.head)||s.push(c);break}else{if(c.head==l.head)break;l=c}}}return s.length==r.ranges.length?!1:(e.dispatch(Sg(n,vt.create(s,s.length-1))),!0)}const kCn=e=>_pt(e,!1),OCn=e=>_pt(e,!0),_Cn=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=vt.create([n.main]):n.main.empty||(r=vt.create([vt.cursor(n.main.head)])),r?(t(Sg(e,r)),!0):!1};function f3(e,t){if(e.state.readOnly)return!1;let n="delete.selection",{state:r}=e,s=r.changeByRange(a=>{let{from:i,to:l}=a;if(i==l){let c=t(a);c<i?(n="delete.backward",c=yL(e,c,!1)):c>i&&(n="delete.forward",c=yL(e,c,!0)),i=Math.min(i,c),l=Math.max(l,c)}else i=yL(e,i,!1),l=yL(e,l,!0);return i==l?{range:a}:{changes:{from:i,to:l},range:vt.cursor(i,i<a.head?-1:1)}});return s.changes.empty?!1:(e.dispatch(r.update(s,{scrollIntoView:!0,userEvent:n,effects:n=="delete.selection"?Nt.announce.of(r.phrase("Selection deleted")):void 0})),!0)}function yL(e,t,n){if(e instanceof Nt)for(let r of e.state.facet(Nt.atomicRanges).map(s=>s(e)))r.between(t,t,(s,a)=>{s<t&&a>t&&(t=n?a:s)});return t}const Cpt=(e,t,n)=>f3(e,r=>{let s=r.from,{state:a}=e,i=a.doc.lineAt(s),l,c;if(n&&!t&&s>i.from&&s<i.from+200&&!/[^ \t]/.test(l=i.text.slice(0,s-i.from))){if(l[l.length-1]==" ")return s-1;let u=ag(l,a.tabSize),d=u%oO(a)||oO(a);for(let f=0;f<d&&l[l.length-1-f]==" ";f++)s--;c=s}else c=rc(i.text,s-i.from,t,t)+i.from,c==s&&i.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(i.text.slice(c-i.from,s-i.from))&&(c=rc(i.text,c-i.from,!1,!1)+i.from);return c}),Wde=e=>Cpt(e,!1,!0),Ept=e=>Cpt(e,!0,!1),jpt=(e,t)=>f3(e,n=>{let r=n.head,{state:s}=e,a=s.doc.lineAt(r),i=s.charCategorizer(r);for(let l=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?s.doc.lines:1)&&(r+=t?1:-1);break}let c=rc(a.text,r-a.from,t)+a.from,u=a.text.slice(Math.min(r,c)-a.from,Math.max(r,c)-a.from),d=i(u);if(l!=null&&d!=l)break;(u!=" "||r!=n.head)&&(l=d),r=c}return r}),Tpt=e=>jpt(e,!1),CCn=e=>jpt(e,!0),ECn=e=>f3(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),jCn=e=>f3(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),TCn=e=>f3(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),NCn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:ya.of(["",""])},range:vt.cursor(r.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},ICn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(r=>{if(!r.empty||r.from==0||r.from==e.doc.length)return{range:r};let s=r.from,a=e.doc.lineAt(s),i=s==a.from?s-1:rc(a.text,s-a.from,!1)+a.from,l=s==a.to?s+1:rc(a.text,s-a.from,!0)+a.from;return{changes:{from:i,to:l,insert:e.doc.slice(s,l).append(e.doc.slice(i,s))},range:vt.cursor(l)}});return n.changes.empty?!1:(t(e.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function ZU(e){let t=[],n=-1;for(let r of e.selection.ranges){let s=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=s.number){let i=t[t.length-1];i.to=a.to,i.ranges.push(r)}else t.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return t}function Npt(e,t,n){if(e.readOnly)return!1;let r=[],s=[];for(let a of ZU(e)){if(n?a.to==e.doc.length:a.from==0)continue;let i=e.doc.lineAt(n?a.to+1:a.from-1),l=i.length+1;if(n){r.push({from:a.to,to:i.to},{from:a.from,insert:i.text+e.lineBreak});for(let c of a.ranges)s.push(vt.range(Math.min(e.doc.length,c.anchor+l),Math.min(e.doc.length,c.head+l)))}else{r.push({from:i.from,to:a.from},{from:a.to,insert:e.lineBreak+i.text});for(let c of a.ranges)s.push(vt.range(c.anchor-l,c.head-l))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:vt.create(s,e.selection.mainIndex),userEvent:"move.line"})),!0):!1}const ACn=({state:e,dispatch:t})=>Npt(e,t,!1),RCn=({state:e,dispatch:t})=>Npt(e,t,!0);function Ipt(e,t,n){if(e.readOnly)return!1;let r=[];for(let a of ZU(e))n?r.push({from:a.from,insert:e.doc.slice(a.from,a.to)+e.lineBreak}):r.push({from:a.to,insert:e.lineBreak+e.doc.slice(a.from,a.to)});let s=e.changes(r);return t(e.update({changes:s,selection:e.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const PCn=({state:e,dispatch:t})=>Ipt(e,t,!1),$Cn=({state:e,dispatch:t})=>Ipt(e,t,!0),MCn=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(ZU(t).map(({from:s,to:a})=>(s>0?s--:a<t.doc.length&&a++,{from:s,to:a}))),r=hN(t.selection,s=>{let a;if(e.lineWrapping){let i=e.lineBlockAt(s.head),l=e.coordsAtPos(s.head,s.assoc||1);l&&(a=i.bottom+e.documentTop-l.bottom+e.defaultLineHeight/2)}return e.moveVertically(s,!0,a)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function DCn(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=pi(e).resolveInner(t),r=n.childBefore(t),s=n.childAfter(t),a;return r&&s&&r.to<=t&&s.from>=t&&(a=r.type.prop(Rr.closedBy))&&a.indexOf(s.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(s.from).from&&!/\S/.test(e.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const EDe=Apt(!1),LCn=Apt(!0);function Apt(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(s=>{let{from:a,to:i}=s,l=t.doc.lineAt(a),c=!e&&a==i&&DCn(t,a);e&&(a=i=(i<=l.to?l:t.doc.lineAt(i)).to);let u=new FU(t,{simulateBreak:a,simulateDoubleBreak:!!c}),d=dbe(u,a);for(d==null&&(d=ag(/^\s*/.exec(t.doc.lineAt(a).text)[0],t.tabSize));i<l.to&&/\s/.test(l.text[i-l.from]);)i++;c?{from:a,to:i}=c:a>l.from&&a<l.from+100&&!/\S/.test(l.text.slice(0,a))&&(a=l.from);let f=["",AP(t,d)];return c&&f.push(AP(t,u.lineIndent(l.from,-1))),{changes:{from:a,to:i,insert:ya.of(f)},range:vt.cursor(a+1+f[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:"input"})),!0}}function Vbe(e,t){let n=-1;return e.changeByRange(r=>{let s=[];for(let i=r.from;i<=r.to;){let l=e.doc.lineAt(i);l.number>n&&(r.empty||r.to>l.from)&&(t(l,s,r),n=l.number),i=l.to+1}let a=e.changes(s);return{changes:s,range:vt.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const FCn=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new FU(e,{overrideIndentation:a=>{let i=n[a];return i??-1}}),s=Vbe(e,(a,i,l)=>{let c=dbe(r,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let u=/^\s*/.exec(a.text)[0],d=AP(e,c);(u!=d||l.from<a.from+u.length)&&(n[a.from]=c,i.push({from:a.from,to:a.from+u.length,insert:d}))});return s.changes.empty||t(e.update(s,{userEvent:"indent"})),!0},Rpt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Vbe(e,(n,r)=>{r.push({from:n.from,insert:e.facet(dN)})}),{userEvent:"input.indent"})),!0),Ppt=({state:e,dispatch:t})=>e.readOnly?!1:(t(e.update(Vbe(e,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=ag(s,e.tabSize),i=0,l=AP(e,Math.max(0,a-oO(e)));for(;i<s.length&&i<l.length&&s.charCodeAt(i)==l.charCodeAt(i);)i++;r.push({from:n.from+i,to:n.from+s.length,insert:l.slice(i)})}),{userEvent:"delete.dedent"})),!0),zCn=e=>(e.setTabFocusMode(),!0),BCn=[{key:"Ctrl-b",run:cpt,shift:ypt,preventDefault:!0},{key:"Ctrl-f",run:upt,shift:bpt},{key:"Ctrl-p",run:ppt,shift:Spt},{key:"Ctrl-n",run:hpt,shift:kpt},{key:"Ctrl-a",run:iCn,shift:yCn},{key:"Ctrl-e",run:oCn,shift:bCn},{key:"Ctrl-d",run:Ept},{key:"Ctrl-h",run:Wde},{key:"Ctrl-k",run:ECn},{key:"Ctrl-Alt-h",run:Tpt},{key:"Ctrl-o",run:NCn},{key:"Ctrl-t",run:ICn},{key:"Ctrl-v",run:Zde}],UCn=[{key:"ArrowLeft",run:cpt,shift:ypt,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:X_n,shift:uCn,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:sCn,shift:gCn,preventDefault:!0},{key:"ArrowRight",run:upt,shift:bpt,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:K_n,shift:dCn,preventDefault:!0},{mac:"Cmd-ArrowRight",run:aCn,shift:vCn,preventDefault:!0},{key:"ArrowUp",run:ppt,shift:Spt,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kDe,shift:_De},{mac:"Ctrl-ArrowUp",run:xDe,shift:wDe},{key:"ArrowDown",run:hpt,shift:kpt,preventDefault:!0},{mac:"Cmd-ArrowDown",run:ODe,shift:CDe},{mac:"Ctrl-ArrowDown",run:Zde,shift:SDe},{key:"PageUp",run:xDe,shift:wDe},{key:"PageDown",run:Zde,shift:SDe},{key:"Home",run:rCn,shift:mCn,preventDefault:!0},{key:"Mod-Home",run:kDe,shift:_De},{key:"End",run:nCn,shift:hCn,preventDefault:!0},{key:"Mod-End",run:ODe,shift:CDe},{key:"Enter",run:EDe,shift:EDe},{key:"Mod-a",run:xCn},{key:"Backspace",run:Wde,shift:Wde,preventDefault:!0},{key:"Delete",run:Ept,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Tpt,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CCn,preventDefault:!0},{mac:"Mod-Backspace",run:jCn,preventDefault:!0},{mac:"Mod-Delete",run:TCn,preventDefault:!0}].concat(BCn.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),qCn=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:eCn,shift:fCn},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:tCn,shift:pCn},{key:"Alt-ArrowUp",run:ACn},{key:"Shift-Alt-ArrowUp",run:PCn},{key:"Alt-ArrowDown",run:RCn},{key:"Shift-Alt-ArrowDown",run:$Cn},{key:"Mod-Alt-ArrowUp",run:kCn},{key:"Mod-Alt-ArrowDown",run:OCn},{key:"Escape",run:_Cn},{key:"Mod-Enter",run:LCn},{key:"Alt-l",mac:"Ctrl-l",run:wCn},{key:"Mod-i",run:SCn,preventDefault:!0},{key:"Mod-[",run:Ppt},{key:"Mod-]",run:Rpt},{key:"Mod-Alt-\\",run:FCn},{key:"Shift-Mod-k",run:MCn},{key:"Shift-Mod-\\",run:cCn},{key:"Mod-/",run:A_n},{key:"Alt-A",run:P_n},{key:"Ctrl-m",mac:"Shift-Alt-m",run:zCn}].concat(UCn),VCn={key:"Tab",run:Rpt,shift:Ppt},jDe=typeof String.prototype.normalize=="function"?e=>e.normalize("NFKD"):e=>e;class ex{constructor(t,n,r=0,s=t.length,a,i){this.test=i,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=t.iterRange(r,s),this.bufferStart=r,this.normalize=a?l=>a(jDe(l)):jDe,this.query=this.normalize(n)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return $d(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let t=this.peek();if(t<0)return this.done=!0,this;let n=Zye(t),r=this.bufferStart+this.bufferPos;this.bufferPos+=lv(t);let s=this.normalize(n);if(s.length)for(let a=0,i=r,l=!0;;a++){let c=s.charCodeAt(a),u=this.match(c,i,l,this.bufferPos+this.bufferStart,a==s.length-1);if(u)return this.value=u,this;if(a==s.length-1)break;l&&a<n.length&&n.charCodeAt(a)==c?i++:l=!1}}}match(t,n,r,s,a){let i=null;for(let l=0;l<this.matches.length;){let c=this.matches[l],u=!1;this.query.charCodeAt(c.index)==t&&(c.index==this.query.length-1?i={from:c.from,to:s,precise:a&&c.precise}:(c.index++,u=!0)),u?l++:this.matches.splice(l,1)}return this.query.charCodeAt(0)==t&&(this.query.length==1?i={from:n,to:s,precise:r&&a}:this.matches.push({from:n,index:1,precise:r})),i&&this.test&&!this.test(i.from,i.to,this.buffer,this.bufferStart)&&(i=null),i}}typeof Symbol<"u"&&(ex.prototype[Symbol.iterator]=function(){return this});const $pt={from:-1,to:-1,match:/.*/.exec(""),precise:!0},Hbe="gm"+(/x/.unicode==null?"":"u");class Mpt{constructor(t,n,r,s=0,a=t.length){if(this.text=t,this.to=a,this.curLine="",this.done=!1,this.value=$pt,/\\[sWDnr]|\n|\r|\[\^/.test(n))return new Dpt(t,n,r,s,a);this.re=new RegExp(n,Hbe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.iter=t.iter();let i=t.lineAt(s);this.curLineStart=i.from,this.matchPos=tz(t,s),this.getLine(this.curLineStart)}getLine(t){this.iter.next(t),this.iter.lineBreak?this.curLine="":(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let t=this.matchPos-this.curLineStart;;){this.re.lastIndex=t;let n=this.matchPos<=this.to&&this.re.exec(this.curLine);if(n){let r=this.curLineStart+n.index,s=r+n[0].length;if(this.matchPos=tz(this.text,s+(r==s?1:0)),r==this.curLineStart+this.curLine.length&&this.nextLine(),(r<s||r>this.value.to)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,precise:!0,match:n},this;t=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),t=0;else return this.done=!0,this}}}const JY=new WeakMap;class sj{constructor(t,n){this.from=t,this.text=n}get to(){return this.from+this.text.length}static get(t,n,r){let s=JY.get(t);if(!s||s.from>=r||s.to<=n){let l=new sj(n,t.sliceString(n,r));return JY.set(t,l),l}if(s.from==n&&s.to==r)return s;let{text:a,from:i}=s;return i>n&&(a=t.sliceString(n,i)+a,i=n),s.to<r&&(a+=t.sliceString(s.to,r)),JY.set(t,new sj(i,a)),new sj(n,a.slice(n-i,r-i))}}class Dpt{constructor(t,n,r,s,a){this.text=t,this.to=a,this.done=!1,this.value=$pt,this.matchPos=tz(t,s),this.re=new RegExp(n,Hbe+(r?.ignoreCase?"i":"")),this.test=r?.test,this.flat=sj.get(t,s,this.chunkEnd(s+5e3))}chunkEnd(t){return t>=this.to?this.to:this.text.lineAt(t).to}next(){for(;;){let t=this.re.lastIndex=this.matchPos-this.flat.from,n=this.re.exec(this.flat.text);if(n&&!n[0]&&n.index==t&&(this.re.lastIndex=t+1,n=this.re.exec(this.flat.text)),n){let r=this.flat.from+n.index,s=r+n[0].length;if((this.flat.to>=this.to||n.index+n[0].length<=this.flat.text.length-10)&&(!this.test||this.test(r,s,n)))return this.value={from:r,to:s,precise:!0,match:n},this.matchPos=tz(this.text,s+(r==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=sj.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol<"u"&&(Mpt.prototype[Symbol.iterator]=Dpt.prototype[Symbol.iterator]=function(){return this});function HCn(e){try{return new RegExp(e,Hbe),!0}catch{return!1}}function tz(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}const ZCn=e=>{let{state:t}=e,n=String(t.doc.lineAt(e.state.selection.main.head).number),{close:r,result:s}=Ewn(e,{label:t.phrase("Go to line"),input:{type:"text",name:"line",value:n},focus:!0,submitLabel:t.phrase("go")});return s.then(a=>{let i=a&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(a.elements.line.value);if(!i){e.dispatch({effects:r});return}let l=t.doc.lineAt(t.selection.main.head),[,c,u,d,f]=i,p=d?+d.slice(1):0,h=u?+u:l.number;if(u&&f){let v=h/100;c&&(v=v*(c=="-"?-1:1)+l.number/t.doc.lines),h=Math.round(t.doc.lines*v)}else u&&c&&(h=h*(c=="-"?-1:1)+l.number);let m=t.doc.line(Math.max(1,Math.min(t.doc.lines,h))),g=vt.cursor(m.from+Math.max(0,Math.min(p,m.length)));e.dispatch({effects:[r,Nt.scrollIntoView(g.from,{y:"center"})],selection:g})}),!0},WCn={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},QCn=wn.define({combine(e){return hy(e,WCn,{highlightWordAroundCursor:(t,n)=>t||n,minSelectionLength:Math.min,maxMatches:Math.min})}});function GCn(e){return[eEn,JCn]}const YCn=Cn.mark({class:"cm-selectionMatch"}),XCn=Cn.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function TDe(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=oo.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=oo.Word)}function KCn(e,t,n,r){return e(t.sliceDoc(n,n+1))==oo.Word&&e(t.sliceDoc(r-1,r))==oo.Word}const JCn=po.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(QCn),{state:n}=e,r=n.selection;if(r.ranges.length>1)return Cn.none;let s=r.main,a,i=null;if(s.empty){if(!t.highlightWordAroundCursor)return Cn.none;let c=n.wordAt(s.head);if(!c)return Cn.none;i=n.charCategorizer(s.head),a=n.sliceDoc(c.from,c.to)}else{let c=s.to-s.from;if(c<t.minSelectionLength||c>200)return Cn.none;if(t.wholeWords){if(a=n.sliceDoc(s.from,s.to),i=n.charCategorizer(s.head),!(TDe(i,n,s.from,s.to)&&KCn(i,n,s.from,s.to)))return Cn.none}else if(a=n.sliceDoc(s.from,s.to),!a)return Cn.none}let l=[];for(let c of e.visibleRanges){let u=new ex(n.doc,a,c.from,c.to);for(;!u.next().done;){let{from:d,to:f}=u.value;if((!i||TDe(i,n,d,f))&&(s.empty&&d<=s.from&&f>=s.to?l.push(XCn.range(d,f)):(d>=s.to||f<=s.from)&&l.push(YCn.range(d,f)),l.length>t.maxMatches))return Cn.none}}return Cn.set(l)}},{decorations:e=>e.decorations}),eEn=Nt.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),tEn=({state:e,dispatch:t})=>{let{selection:n}=e,r=vt.create(n.ranges.map(s=>e.wordAt(s.head)||vt.cursor(s.head)),n.mainIndex);return r.eq(n)?!1:(t(e.update({selection:r})),!0)};function nEn(e,t){let{main:n,ranges:r}=e.selection,s=e.wordAt(n.head),a=s&&s.from==n.from&&s.to==n.to;for(let i=!1,l=new ex(e.doc,t,r[r.length-1].to);;)if(l.next(),l.done){if(i)return null;l=new ex(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),i=!0}else{if(i&&r.some(c=>c.from==l.value.from))continue;if(a){let c=e.wordAt(l.value.from);if(!c||c.from!=l.value.from||c.to!=l.value.to)continue}return l.value}}const rEn=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(a=>a.from===a.to))return tEn({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(a=>e.sliceDoc(a.from,a.to)!=r))return!1;let s=nEn(e,r);return s?(t(e.update({selection:e.selection.addRange(vt.range(s.from,s.to),!1),effects:Nt.scrollIntoView(s.to)})),!0):!1},mN=wn.define({combine(e){return hy(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:t=>new vEn(t),scrollToMatch:t=>Nt.scrollIntoView(t)})}});class Lpt{constructor(t){this.search=t.search,this.caseSensitive=!!t.caseSensitive,this.literal=!!t.literal,this.regexp=!!t.regexp,this.replace=t.replace||"",this.valid=!!this.search&&(!this.regexp||HCn(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!t.wholeWord,this.test=t.test}unquote(t){return this.literal?t:t.replace(/\\([nrt\\])/g,(n,r)=>r=="n"?`
|
|
226
|
-
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new cEn(this):new iEn(this)}getCursor(t,n=0,r){let s=t.doc?t:os.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?iE(this,s,n,r):aE(this,s,n,r)}}class Fpt{constructor(t){this.spec=t}}function sEn(e,t,n){return(r,s,a,i)=>{if(n&&!n(r,s,a,i))return!1;let l=r>=i&&s<=i+a.length?a.slice(r-i,s-i):t.doc.sliceString(r,s);return e(l,t,r,s)}}function aE(e,t,n,r){let s;return e.wholeWord&&(s=aEn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=sEn(e.test,t,s)),new ex(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function aEn(e,t){return(n,r,s,a)=>((a>n||a+s.length<r)&&(a=Math.max(0,n-2),s=e.sliceString(a,Math.min(e.length,r+2))),(t(nz(s,n-a))!=oo.Word||t(rz(s,n-a))!=oo.Word)&&(t(rz(s,r-a))!=oo.Word||t(nz(s,r-a))!=oo.Word))}class iEn extends Fpt{constructor(t){super(t)}nextMatch(t,n,r){let s=aE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=aE(this.spec,t,0,a).nextOverlapping()}return s.done||s.value.from==n&&s.value.to==r?null:s.value}prevMatchInRange(t,n,r){for(let s=r;;){let a=Math.max(n,s-1e4-this.spec.unquoted.length),i=aE(this.spec,t,a,s),l=null;for(;!i.nextOverlapping().done;)l=i.value;if(l)return l;if(a==n)return null;s-=1e4}}prevMatch(t,n,r){let s=this.prevMatchInRange(t,0,n);return s||(s=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),s&&(s.from!=n||s.to!=r)?s:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=aE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=aE(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function oEn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function iE(e,t,n,r){let s;return e.wholeWord&&(s=lEn(t.charCategorizer(t.selection.main.head))),e.test&&(s=oEn(e.test,t,s)),new Mpt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function nz(e,t){return e.slice(rc(e,t,!1),t)}function rz(e,t){return e.slice(t,rc(e,t))}function lEn(e){return(t,n,r)=>!r[0].length||(e(nz(r.input,r.index))!=oo.Word||e(rz(r.input,r.index))!=oo.Word)&&(e(rz(r.input,r.index+r[0].length))!=oo.Word||e(nz(r.input,r.index+r[0].length))!=oo.Word)}class cEn extends Fpt{nextMatch(t,n,r){let s=iE(this.spec,t,r,t.doc.length).next();return s.done&&(s=iE(this.spec,t,0,n).next()),s.done?null:s.value}prevMatchInRange(t,n,r){for(let s=1;;s++){let a=Math.max(n,r-s*1e4),i=iE(this.spec,t,a,r),l=null;for(;!i.next().done;)l=i.value;if(l&&(a==n||l.from>a+10))return l;if(a==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let s=r.length;s>0;s--){let a=+r.slice(0,s);if(a>0&&a<t.match.length)return t.match[a]+r.slice(s)}return n})}matchAll(t,n){let r=iE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=iE(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const BP=mr.define(),Zbe=mr.define(),yw=cl.define({create(e){return new eX(Qde(e).create(),null)},update(e,t){for(let n of t.effects)n.is(BP)?e=new eX(n.value.create(),e.panel):n.is(Zbe)&&(e=new eX(e.query,n.value?Wbe:null));return e},provide:e=>IP.from(e,t=>t.panel)});class eX{constructor(t,n){this.query=t,this.panel=n}}const uEn=Cn.mark({class:"cm-searchMatch"}),dEn=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),fEn=po.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(yw))}update(e){let t=e.state.field(yw);(t!=e.startState.field(yw)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Cn.none;let{view:n}=this,r=new dd;for(let s=0,a=n.visibleRanges,i=a.length;s<i;s++){let{from:l,to:c}=a[s];for(;s<i-1&&c>a[s+1].from-500;)c=a[++s].to;e.highlight(n.state,l,c,(u,d)=>{let f=n.state.selection.ranges.some(p=>p.from==u&&p.to==d);r.add(u,d,f?dEn:uEn)})}return r.finish()}},{decorations:e=>e.decorations});function p3(e){return t=>{let n=t.state.field(yw,!1);return n&&n.query.spec.valid?e(t,n):Upt(t)}}const sz=p3((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=vt.single(r.from,r.to),a=e.state.facet(mN);return e.dispatch({selection:s,effects:[Qbe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),Bpt(e),!0}),az=p3((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=vt.single(s.from,s.to),i=e.state.facet(mN);return e.dispatch({selection:a,effects:[Qbe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),Bpt(e),!0}),pEn=p3((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:vt.create(n.map(r=>vt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),hEn=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,a=[],i=0;for(let l=new ex(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(vt.range(l.value.from,l.value.to))}return t(e.update({selection:vt.create(a,i),userEvent:"select.search.matches"})),!0},NDe=p3((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let i=a,l=[],c,u,d=[];i.precise?i.from==r&&i.to==s&&(u=n.toText(t.getReplacement(i)),l.push({from:i.from,to:i.to,insert:u}),d.push(Nt.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=vt.single(i.from,i.to).map(f),d.push(Qbe(e,i)),d.push(n.facet(mN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),mEn=p3((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let s of t.matchAll(e.state,1e9)){let{from:a,to:i,precise:l}=s;l&&n.push({from:a,to:i,insert:t.getReplacement(s)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Nt.announce.of(r),userEvent:"input.replace.all"}),!0});function Wbe(e){return e.state.facet(mN).createPanel(e)}function Qde(e,t){var n,r,s,a,i;let l=e.selection.main,c=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!c)return t;let u=e.facet(mN);return new Lpt({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(s=t?.literal)!==null&&s!==void 0?s:u.literal,regexp:(a=t?.regexp)!==null&&a!==void 0?a:u.regexp,wholeWord:(i=t?.wholeWord)!==null&&i!==void 0?i:u.wholeWord})}function zpt(e){let t=cbe(e,Wbe);return t&&t.dom.querySelector("[main-field]")}function Bpt(e){let t=zpt(e);t&&t==e.root.activeElement&&t.select()}const Upt=e=>{let t=e.state.field(yw,!1);if(t&&t.panel){let n=zpt(e);if(n&&n!=e.root.activeElement){let r=Qde(e.state,t.query.spec);r.valid&&e.dispatch({effects:BP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Zbe.of(!0),t?BP.of(Qde(e.state,t.query.spec)):mr.appendConfig.of(bEn)]});return!0},qpt=e=>{let t=e.state.field(yw,!1);if(!t||!t.panel)return!1;let n=cbe(e,Wbe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Zbe.of(!1)}),!0},gEn=[{key:"Mod-f",run:Upt,scope:"editor search-panel"},{key:"F3",run:sz,shift:az,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:sz,shift:az,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:qpt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:hEn},{key:"Mod-Alt-g",run:ZCn},{key:"Mod-d",run:rEn,preventDefault:!0}];class vEn{constructor(t){this.view=t;let n=this.query=t.state.field(yw).query.spec;this.commit=this.commit.bind(this),this.searchField=oi("input",{value:n.search,placeholder:Ff(t,"Find"),"aria-label":Ff(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=oi("input",{value:n.replace,placeholder:Ff(t,"Replace"),"aria-label":Ff(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=oi("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=oi("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=oi("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return oi("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=oi("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>sz(t),[Ff(t,"next")]),r("prev",()=>az(t),[Ff(t,"previous")]),r("select",()=>pEn(t),[Ff(t,"all")]),oi("label",null,[this.caseField,Ff(t,"match case")]),oi("label",null,[this.reField,Ff(t,"regexp")]),oi("label",null,[this.wordField,Ff(t,"by word")]),...t.state.readOnly?[]:[oi("br"),this.replaceField,r("replace",()=>NDe(t),[Ff(t,"replace")]),r("replaceAll",()=>mEn(t),[Ff(t,"replace all")])],oi("button",{name:"close",onclick:()=>qpt(t),"aria-label":Ff(t,"close"),type:"button"},["×"])])}commit(){let t=new Lpt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:BP.of(t)}))}keydown(t){D0n(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?az:sz)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),NDe(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(BP)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(mN).top}}function Ff(e,t){return e.state.phrase(t)}const bL=30,xL=/[\s\.,:;?!]/;function Qbe(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-bL),i=Math.min(s,n+bL),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<bL;c++)if(!xL.test(l[c+1])&&xL.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-bL;c--)if(!xL.test(l[c-1])&&xL.test(l[c])){l=l.slice(0,c);break}}return Nt.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const yEn=Nt.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),bEn=[yw,xg.low(fEn),yEn];class IDe{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class JS{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(UP).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new dd,l=[],c=0;for(let d=0;;){let f=d==a.length?null:a[d];if(!f&&!l.length)break;let p,h;for(l.length?(p=c,h=l.reduce((g,v)=>Math.min(g,v.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let g=a[d];if(g.from==p&&(g.to>g.from||g.to==p))l.push(g),d++,h=Math.min(g.to,h);else{h=Math.min(g.from,h);break}}let m=AEn(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&r.doc.lineAt(g.from).to==g.from))i.add(p,p,Cn.widget({widget:new jEn(m),diagnostics:l.slice()}));else{let g=l.reduce((v,b)=>b.markClass?v+" "+b.markClass:v,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+g,diagnostics:l.slice(),inclusiveEnd:l.some(v=>v.to>h)}))}c=h;for(let g=0;g<l.length;g++)l[g].to<=c&&l.splice(g--,1)}let u=i.finish();return new JS(u,n,Wj(u))}}function Wj(e,t=null,n=0){let r=null;return e.between(n,1e9,(s,a,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new IDe(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new IDe(r.from,a,r.diagnostic)}}),r}function xEn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(UP).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(Vpt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function wEn(e,t){return e.field(cp,!1)?t:t.concat(mr.appendConfig.of(REn))}const Vpt=mr.define(),Gbe=mr.define(),Hpt=mr.define(),cp=cl.define({create(){return new JS(Cn.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,s=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=Wj(n,e.selected.diagnostic,a)||Wj(n,null,a)}!n.size&&s&&t.state.facet(UP).autoPanel&&(s=null),e=new JS(n,s,r)}for(let n of t.effects)if(n.is(Vpt)){let r=t.state.facet(UP).autoPanel?n.value.length?qP.open:null:e.panel;e=JS.init(n.value,r,t.state)}else n.is(Gbe)?e=new JS(e.diagnostics,n.value?qP.open:null,e.selected):n.is(Hpt)&&(e=new JS(e.diagnostics,e.panel,n.value));return e},provide:e=>[IP.from(e,t=>t.panel),Nt.decorations.from(e,t=>t.diagnostics)]}),SEn=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function kEn(e,t,n){let{diagnostics:r}=e.state.field(cp),s,a=-1,i=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(c,u,{spec:d})=>{if(t>=c&&t<=u&&(c==u||(t>c||n>0)&&(t<u||n<0)))return s=d.diagnostics,a=c,i=u,!1});let l=e.state.facet(UP).tooltipFilter;return s&&l&&(s=l(s,e.state)),s?{pos:a,end:i,above:e.state.doc.lineAt(a).to<i,create(){return{dom:OEn(e,s)}}}:null}function OEn(e,t){return oi("ul",{class:"cm-tooltip-lint"},t.map(n=>Wpt(e,n,!1)))}const _En=e=>{let t=e.state.field(cp,!1);(!t||!t.panel)&&e.dispatch({effects:wEn(e.state,[Gbe.of(!0)])});let n=cbe(e,qP.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},ADe=e=>{let t=e.state.field(cp,!1);return!t||!t.panel?!1:(e.dispatch({effects:Gbe.of(!1)}),!0)},CEn=e=>{let t=e.state.field(cp,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},EEn=[{key:"Mod-Shift-m",run:_En,preventDefault:!0},{key:"F8",run:CEn}],UP=wn.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...hy(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:RDe,tooltipFilter:RDe,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,s,a)=>t(r,s,a)||n(r,s,a):t:n,autoPanel:(t,n)=>t||n})}}});function RDe(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Zpt(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let s=n[r];if(/[a-zA-Z]/.test(s)&&!t.some(a=>a.toLowerCase()==s.toLowerCase())){t.push(s);continue e}}t.push("")}return t}function Wpt(e,t,n){var r;let s=n?Zpt(t.actions):[];return oi("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},oi("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((a,i)=>{let l=!1,c=h=>{if(h.preventDefault(),l)return;l=!0;let m=Wj(e.state.field(cp).diagnostics,t);m&&a.apply(e,m.from,m.to)},{name:u}=a,d=s[i]?u.indexOf(s[i]):-1,f=d<0?u:[u.slice(0,d),oi("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return oi("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&oi("div",{class:"cm-diagnosticSource"},t.source))}class jEn extends $p{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return oi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class PDe{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Wpt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qP{constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)ADe(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],i=Zpt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=Wj(this.view.state.field(cp).diagnostics,a);c&&a.actions[l].apply(t,c.from,c.to)}}else return;s.preventDefault()},r=s=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(s.target)&&this.moveSelection(a)};this.list=oi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=oi("div",{class:"cm-panel-lint"},this.list,oi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ADe(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(cp).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(cp),r=0,s=!1,a=null,i=new Set;for(t.between(0,this.view.state.doc.length,(l,c,{spec:u})=>{for(let d of u.diagnostics){if(i.has(d))continue;i.add(d);let f=-1,p;for(let h=r;h<this.items.length;h++)if(this.items[h].diagnostic==d){f=h;break}f<0?(p=new PDe(this.view,d),this.items.splice(r,0,p),s=!0):(p=this.items[f],f>r&&(this.items.splice(r,f-r),s=!0)),n&&p.diagnostic==n.diagnostic?p.dom.hasAttribute("aria-selected")||(p.dom.setAttribute("aria-selected","true"),a=p):p.dom.hasAttribute("aria-selected")&&p.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new PDe(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let u=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/u:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(cp),r=Wj(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Hpt.of(r)})}static open(t){return new qP(t)}}function TEn(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function wL(e){return TEn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const NEn=Nt.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:wL("#d11")},".cm-lintRange-warning":{backgroundImage:wL("orange")},".cm-lintRange-info":{backgroundImage:wL("#999")},".cm-lintRange-hint":{backgroundImage:wL("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function IEn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function AEn(e){let t="hint",n=1;for(let r of e){let s=IEn(r.severity);s>n&&(n=s,t=r.severity)}return t}const REn=[cp,Nt.decorations.compute([cp],e=>{let{selected:t,panel:n}=e.field(cp);return!t||!n||t.from==t.to?Cn.none:Cn.set([SEn.range(t.from,t.to)])}),_wn(kEn,{hideOn:xEn}),NEn];var $De=function(t){t===void 0&&(t={});var n=t,r=n.crosshairCursor,s=r===void 0?!1:r,a=[];t.closeBracketsKeymap!==!1&&(a=a.concat(SSn)),t.defaultKeymap!==!1&&(a=a.concat(qCn)),t.searchKeymap!==!1&&(a=a.concat(gEn)),t.historyKeymap!==!1&&(a=a.concat(Y_n)),t.foldKeymap!==!1&&(a=a.concat(o1n)),t.completionKeymap!==!1&&(a=a.concat(Bdt)),t.lintKeymap!==!1&&(a=a.concat(EEn));var i=[];return t.lineNumbers!==!1&&i.push(Dwn()),t.highlightActiveLineGutter!==!1&&i.push(zwn()),t.highlightSpecialChars!==!1&&i.push(J0n()),t.history!==!1&&i.push(B_n()),t.foldGutter!==!1&&i.push(d1n()),t.drawSelection!==!1&&i.push(q0n()),t.dropCursor!==!1&&i.push(Q0n()),t.allowMultipleSelections!==!1&&i.push(os.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(Jwn()),t.syntaxHighlighting!==!1&&i.push(S1(m1n,{fallback:!0})),t.bracketMatching!==!1&&i.push(S1n()),t.closeBrackets!==!1&&i.push(ySn()),t.autocompletion!==!1&&i.push(zdt()),t.rectangularSelection!==!1&&i.push(pwn()),s!==!1&&i.push(gwn()),t.highlightActiveLine!==!1&&i.push(awn()),t.highlightSelectionMatches!==!1&&i.push(GCn()),t.tabSize&&typeof t.tabSize=="number"&&i.push(dN.of(" ".repeat(t.tabSize))),i.concat([uN.of(a.flat())]).filter(Boolean)};const PEn="#e5c07b",MDe="#e06c75",$En="#56b6c2",MEn="#ffffff",G8="#abb2bf",Gde="#7d8799",DEn="#61afef",LEn="#98c379",DDe="#d19a66",FEn="#c678dd",zEn="#21252b",LDe="#2c313a",FDe="#282c34",tX="#353a42",BEn="#3E4451",zDe="#528bff",UEn=Nt.theme({"&":{color:G8,backgroundColor:FDe},".cm-content":{caretColor:zDe},".cm-cursor, .cm-dropCursor":{borderLeftColor:zDe},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:BEn},".cm-panels":{backgroundColor:zEn,color:G8},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:FDe,color:Gde,border:"none"},".cm-activeLineGutter":{backgroundColor:LDe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tX},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tX,borderBottomColor:tX},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:LDe,color:G8}}},{dark:!0}),qEn=wg.define([{tag:de.keyword,color:FEn},{tag:[de.name,de.deleted,de.character,de.propertyName,de.macroName],color:MDe},{tag:[de.function(de.variableName),de.labelName],color:DEn},{tag:[de.color,de.constant(de.name),de.standard(de.name)],color:DDe},{tag:[de.definition(de.name),de.separator],color:G8},{tag:[de.typeName,de.className,de.number,de.changed,de.annotation,de.modifier,de.self,de.namespace],color:PEn},{tag:[de.operator,de.operatorKeyword,de.url,de.escape,de.regexp,de.link,de.special(de.string)],color:$En},{tag:[de.meta,de.comment],color:Gde},{tag:de.strong,fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.link,color:Gde,textDecoration:"underline"},{tag:de.heading,fontWeight:"bold",color:MDe},{tag:[de.atom,de.bool,de.special(de.variableName)],color:DDe},{tag:[de.processingInstruction,de.string,de.inserted],color:LEn},{tag:de.invalid,color:MEn}]),VEn=[UEn,S1(qEn)];var HEn=Nt.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ZEn=function(t){t===void 0&&(t={});var n=t,r=n.indentWithTab,s=r===void 0?!0:r,a=n.editable,i=a===void 0?!0:a,l=n.readOnly,c=l===void 0?!1:l,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,p=f===void 0?"":f,h=n.basicSetup,m=h===void 0?!0:h,g=[];switch(s&&g.unshift(uN.of([VCn])),m&&(typeof m=="boolean"?g.unshift($De()):g.unshift($De(m))),p&&g.unshift(cwn(p)),d){case"light":g.push(HEn);break;case"dark":g.push(VEn);break;case"none":break;default:g.push(d);break}return i===!1&&g.push(Nt.editable.of(!1)),c&&g.push(os.readOnly.of(!0)),[...g]},WEn=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class QEn{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class BDe{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var nX=null,GEn=()=>typeof window>"u"?new BDe:(nX||(nX=new BDe),nX),UDe=py.define(),YEn=200,XEn=[];function KEn(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,a=e.onCreateEditor,i=e.onUpdate,l=e.extensions,c=l===void 0?XEn:l,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,p=e.height,h=p===void 0?null:p,m=e.minHeight,g=m===void 0?null:m,v=e.maxHeight,b=v===void 0?null:v,w=e.width,S=w===void 0?null:w,O=e.minWidth,_=O===void 0?null:O,C=e.maxWidth,j=C===void 0?null:C,E=e.placeholder,N=E===void 0?"":E,I=e.editable,P=I===void 0?!0:I,$=e.readOnly,B=$===void 0?!1:$,D=e.indentWithTab,V=D===void 0?!0:D,H=e.basicSetup,L=H===void 0?!0:H,F=e.root,z=e.initialState,M=y.useState(),G=M[0],U=M[1],R=y.useState(),q=R[0],W=R[1],X=y.useState(),ne=X[0],ee=X[1],J=y.useState(()=>({current:null}))[0],ie=y.useState(()=>({current:null}))[0],ue=Nt.theme({"&":{height:h,minHeight:g,maxHeight:b,width:S,minWidth:_,maxWidth:j},"& .cm-scroller":{height:"100% !important"}}),Y=Nt.updateListener.of(fe=>{if(fe.docChanged&&typeof r=="function"&&!fe.transactions.some(be=>be.annotation(UDe))){J.current?J.current.reset():(J.current=new QEn(()=>{if(ie.current){var be=ie.current;ie.current=null,be()}J.current=null},YEn),GEn().add(J.current));var se=fe.state.doc,he=se.toString();r(he,fe)}s&&s(WEn(fe))}),te=ZEn({theme:f,editable:P,readOnly:B,placeholder:N,indentWithTab:V,basicSetup:L}),le=[Y,ue,...te];return i&&typeof i=="function"&&le.push(Nt.updateListener.of(i)),le=le.concat(c),y.useLayoutEffect(()=>{if(G&&!ne){var fe={doc:t,selection:n,extensions:le},se=z?os.fromJSON(z.json,fe,z.fields):os.create(fe);if(ee(se),!q){var he=new Nt({state:se,parent:G,root:F});W(he),a&&a(he,se)}}return()=>{q&&(ee(void 0),W(void 0))}},[G,ne]),y.useEffect(()=>{e.container&&U(e.container)},[e.container]),y.useEffect(()=>()=>{q&&(q.destroy(),W(void 0)),J.current&&(J.current.cancel(),J.current=null)},[q]),y.useEffect(()=>{u&&q&&q.focus()},[u,q]),y.useEffect(()=>{q&&q.dispatch({effects:mr.reconfigure.of(le)})},[f,c,h,g,b,S,_,j,N,P,B,V,L,r,i]),y.useEffect(()=>{if(t!==void 0){var fe=q?q.state.doc.toString():"";if(q&&t!==fe){var se=J.current&&!J.current.isDone,he=()=>{q&&t!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:t||""},annotations:[UDe.of(!0)]})};se?ie.current=he:he()}}},[t,q]),{state:ne,setState:ee,view:q,setView:W,container:G,setContainer:U}}var JEn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Ou=y.forwardRef((e,t)=>{var n=e.className,r=e.value,s=r===void 0?"":r,a=e.selection,i=e.extensions,l=i===void 0?[]:i,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,p=e.autoFocus,h=e.theme,m=h===void 0?"light":h,g=e.height,v=e.minHeight,b=e.maxHeight,w=e.width,S=e.minWidth,O=e.maxWidth,_=e.basicSetup,C=e.placeholder,j=e.indentWithTab,E=e.editable,N=e.readOnly,I=e.root,P=e.initialState,$=tpt(e,JEn),B=y.useRef(null),D=KEn({root:I,value:s,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:w,minWidth:S,maxWidth:O,basicSetup:_,placeholder:C,indentWithTab:j,editable:E,readOnly:N,selection:a,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:l,initialState:P}),V=D.state,H=D.view,L=D.container,F=D.setContainer;y.useImperativeHandle(t,()=>({editor:B.current,state:V,view:H}),[B,L,V,H]);var z=y.useCallback(G=>{B.current=G,F(G)},[F]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var M=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",uO({ref:z,className:""+M+(n?" "+n:"")},$))});Ou.displayName="CodeMirror";const ejn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Qpt=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();var tjn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const njn=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>y.createElement("svg",{ref:c,...tjn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Qpt("lucide",s),...l},[...i.map(([u,d])=>y.createElement(u,d)),...Array.isArray(a)?a:[a]]));const gn=(e,t)=>{const n=y.forwardRef(({className:r,...s},a)=>y.createElement(njn,{ref:a,iconNode:t,className:Qpt(`lucide-${ejn(e)}`,r),...s}));return n.displayName=`${e}`,n};const rjn=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],iz=gn("AlignJustify",rjn);const sjn=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],VP=gn("AlignLeft",sjn);const ajn=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],WU=gn("ArrowDown",ajn);const ijn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],QU=gn("ArrowLeft",ijn);const ojn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],HP=gn("ArrowRight",ojn);const ljn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],GU=gn("ArrowUp",ljn);const cjn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Gpt=gn("Ban",cjn);const ujn=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],rw=gn("Braces",ujn);const djn=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],fjn=gn("Brain",djn);const pjn=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],qDe=gn("Calendar",pjn);const hjn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wx=gn("Check",hjn);const mjn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ybe=gn("ChevronDown",mjn);const gjn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],vjn=gn("ChevronLeft",gjn);const yjn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Qj=gn("ChevronRight",yjn);const bjn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xjn=gn("ChevronUp",bjn);const wjn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Xbe=gn("ChevronsDownUp",wjn);const Sjn=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],kjn=gn("ChevronsDown",Sjn);const Ojn=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],_jn=gn("ChevronsLeft",Ojn);const Cjn=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Ypt=gn("ChevronsRight",Cjn);const Ejn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],h3=gn("ChevronsUpDown",Ejn);const jjn=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Tjn=gn("ChevronsUp",jjn);const Njn=[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]],Ijn=gn("CircleGauge",Njn);const Ajn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Xpt=gn("CircleSlash",Ajn);const Rjn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Pjn=gn("CircleX",Rjn);const $jn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Mjn=gn("Circle",$jn);const Djn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],Ljn=gn("Clock",Djn);const Fjn=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],zjn=gn("Component",Fjn);const Bjn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Kpt=gn("Copy",Bjn);const Ujn=[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],qjn=gn("CornerDownRight",Ujn);const Vjn=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],Hjn=gn("Download",Vjn);const Zjn=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Wjn=gn("EllipsisVertical",Zjn);const Qjn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]],Gjn=gn("EqualNot",Qjn);const Yjn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Xjn=gn("Equal",Yjn);const Kjn=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],Jjn=gn("Expand",Kjn);const eTn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Kbe=gn("ExternalLink",eTn);const tTn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],nTn=gn("Eye",tTn);const rTn=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],Yde=gn("FileInput",rTn);const sTn=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],Xde=gn("FileOutput",sTn);const aTn=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],iTn=gn("FileText",aTn);const oTn=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],lTn=gn("File",oTn);const cTn=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],uTn=gn("Filter",cTn);const dTn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],fTn=gn("FoldVertical",dTn);const pTn=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],hTn=gn("Folder",pTn);const mTn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],gTn=gn("Gauge",mTn);const vTn=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Jbe=gn("Hash",vTn);const yTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Jpt=gn("Info",yTn);const bTn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],xTn=gn("Keyboard",bTn);const wTn=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],STn=gn("Lightbulb",wTn);const kTn=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],eht=gn("Link2",kTn);const OTn=[["path",{d:"M10 18h4",key:"1ulq68"}],["path",{d:"M11 6H3",key:"1u26ik"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 9V3",key:"xwwp7m"}],["path",{d:"M7 12h8",key:"7a1bxv"}]],_Tn=gn("ListFilterPlus",OTn);const CTn=[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]],ETn=gn("ListTree",CTn);const jTn=[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]],TTn=gn("ListX",jTn);const NTn=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],exe=gn("List",NTn);const ITn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ATn=gn("LoaderCircle",ITn);const RTn=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],PTn=gn("Lock",RTn);const $Tn=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],MTn=gn("LogIn",$Tn);const DTn=[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]],LTn=gn("Logs",DTn);const FTn=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],zTn=gn("Menu",FTn);const BTn=[["path",{d:"M5 12h14",key:"1ays0h"}]],UTn=gn("Minus",BTn);const qTn=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],VTn=gn("OctagonAlert",qTn);const HTn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],ZTn=gn("PanelRight",HTn);const WTn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],txe=gn("Plus",WTn);const QTn=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],tht=gn("Save",QTn);const GTn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Gj=gn("Search",GTn);const YTn=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],XTn=gn("ShieldX",YTn);const KTn=[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]],JTn=gn("TextSearch",KTn);const eNn=[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]],tNn=gn("Text",eNn);const nNn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],nxe=gn("ToggleLeft",nNn);const rNn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],nht=gn("Trash2",rNn);const sNn=[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]],aNn=gn("TrendingDown",sNn);const iNn=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],oNn=gn("TrendingUp",iNn);const lNn=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],YU=gn("TriangleAlert",lNn);const cNn=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],rxe=gn("Type",cNn);const uNn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],dNn=gn("UnfoldVertical",uNn);const fNn=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],pNn=gn("WandSparkles",fNn);const hNn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lf=gn("X",hNn);function mNn(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const gNn=e=>{switch(e){case"success":return bNn;case"info":return wNn;case"warning":return xNn;case"error":return SNn;default:return null}},vNn=Array(12).fill(0),yNn=({visible:e,className:t})=>De.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},De.createElement("div",{className:"sonner-spinner"},vNn.map((n,r)=>De.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),bNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),xNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),wNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),SNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),kNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},De.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),De.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ONn=()=>{const[e,t]=De.useState(document.hidden);return De.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Kde=1;class _Nn{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...s}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Kde++,i=this.toasts.find(c=>c.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(c=>c.id===a?(this.publish({...c,...t,id:a,title:r}),{...c,...t,id:a,dismissible:l,title:r}):c):this.addToast({title:r,...s,dismissible:l,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,i;const l=s.then(async u=>{if(i=["resolve",u],De.isValidElement(u))a=!1,this.create({id:r,type:"default",message:u});else if(ENn(u)&&!u.ok){a=!1;const f=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,p=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(u instanceof Error){a=!1;const f=typeof n.error=="function"?await n.error(u):n.error,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(n.success!==void 0){a=!1;const f=typeof n.success=="function"?await n.success(u):n.success,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"success",description:p,...m})}}).catch(async u=>{if(i=["reject",u],n.error!==void 0){a=!1;const d=typeof n.error=="function"?await n.error(u):n.error,f=typeof n.description=="function"?await n.description(u):n.description,h=typeof d=="object"&&!De.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:f,...h})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((u,d)=>l.then(()=>i[0]==="reject"?d(i[1]):u(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:c}:Object.assign(r,{unwrap:c})},this.custom=(t,n)=>{const r=n?.id||Kde++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ad=new _Nn,CNn=(e,t)=>{const n=t?.id||Kde++;return Ad.addToast({title:e,...t,id:n}),n},ENn=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jNn=CNn,TNn=()=>Ad.toasts,NNn=()=>Ad.getActiveToasts(),bu=Object.assign(jNn,{success:Ad.success,info:Ad.info,warning:Ad.warning,error:Ad.error,custom:Ad.custom,message:Ad.message,promise:Ad.promise,dismiss:Ad.dismiss,loading:Ad.loading},{getHistory:TNn,getToasts:NNn});mNn("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function SL(e){return e.label!==void 0}const INn=3,ANn="24px",RNn="16px",VDe=4e3,PNn=356,$Nn=14,MNn=45,DNn=200;function Vg(...e){return e.filter(Boolean).join(" ")}function LNn(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const FNn=e=>{var t,n,r,s,a,i,l,c,u;const{invert:d,toast:f,unstyled:p,interacting:h,setHeights:m,visibleToasts:g,heights:v,index:b,toasts:w,expanded:S,removeToast:O,defaultRichColors:_,closeButton:C,style:j,cancelButtonStyle:E,actionButtonStyle:N,className:I="",descriptionClassName:P="",duration:$,position:B,gap:D,expandByDefault:V,classNames:H,icons:L,closeButtonAriaLabel:F="Close toast"}=e,[z,M]=De.useState(null),[G,U]=De.useState(null),[R,q]=De.useState(!1),[W,X]=De.useState(!1),[ne,ee]=De.useState(!1),[J,ie]=De.useState(!1),[ue,Y]=De.useState(!1),[te,le]=De.useState(0),[fe,se]=De.useState(0),he=De.useRef(f.duration||$||VDe),be=De.useRef(null),we=De.useRef(null),Ie=b===0,ke=b+1<=g,je=f.type,Fe=f.dismissible!==!1,ce=f.className||"",ae=f.descriptionClassName||"",re=De.useMemo(()=>v.findIndex(bt=>bt.toastId===f.id)||0,[v,f.id]),me=De.useMemo(()=>{var bt;return(bt=f.closeButton)!=null?bt:C},[f.closeButton,C]),ye=De.useMemo(()=>f.duration||$||VDe,[f.duration,$]),Te=De.useRef(0),Re=De.useRef(0),Qe=De.useRef(0),Ze=De.useRef(null),[Oe,_e]=B.split("-"),Ce=De.useMemo(()=>v.reduce((bt,It,sn)=>sn>=re?bt:bt+It.height,0),[v,re]),Ee=ONn(),$e=f.invert||d,ze=je==="loading";Re.current=De.useMemo(()=>re*D+Ce,[re,Ce]),De.useEffect(()=>{he.current=ye},[ye]),De.useEffect(()=>{q(!0)},[]),De.useEffect(()=>{const bt=we.current;if(bt){const It=bt.getBoundingClientRect().height;return se(It),m(sn=>[{toastId:f.id,height:It,position:f.position},...sn]),()=>m(sn=>sn.filter(We=>We.toastId!==f.id))}},[m,f.id]),De.useLayoutEffect(()=>{if(!R)return;const bt=we.current,It=bt.style.height;bt.style.height="auto";const sn=bt.getBoundingClientRect().height;bt.style.height=It,se(sn),m(We=>We.find(ct=>ct.toastId===f.id)?We.map(ct=>ct.toastId===f.id?{...ct,height:sn}:ct):[{toastId:f.id,height:sn,position:f.position},...We])},[R,f.title,f.description,m,f.id,f.jsx,f.action,f.cancel]);const Ke=De.useCallback(()=>{X(!0),le(Re.current),m(bt=>bt.filter(It=>It.toastId!==f.id)),setTimeout(()=>{O(f)},DNn)},[f,O,m,Re]);De.useEffect(()=>{if(f.promise&&je==="loading"||f.duration===1/0||f.type==="loading")return;let bt;return S||h||Ee?(()=>{if(Qe.current<Te.current){const We=new Date().getTime()-Te.current;he.current=he.current-We}Qe.current=new Date().getTime()})():he.current!==1/0&&(Te.current=new Date().getTime(),bt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ke()},he.current)),()=>clearTimeout(bt)},[S,h,f,je,Ee,Ke]),De.useEffect(()=>{f.delete&&(Ke(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ke,f.delete]);function Ye(){var bt;if(L?.loading){var It;return De.createElement("div",{className:Vg(H?.loader,f==null||(It=f.classNames)==null?void 0:It.loader,"sonner-loader"),"data-visible":je==="loading"},L.loading)}return De.createElement(yNn,{className:Vg(H?.loader,f==null||(bt=f.classNames)==null?void 0:bt.loader),visible:je==="loading"})}const Rt=f.icon||L?.[je]||gNn(je);var Ct,en;return De.createElement("li",{tabIndex:0,ref:we,className:Vg(I,ce,H?.toast,f==null||(t=f.classNames)==null?void 0:t.toast,H?.default,H?.[je],f==null||(n=f.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(Ct=f.richColors)!=null?Ct:_,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":R,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":W,"data-visible":ke,"data-y-position":Oe,"data-x-position":_e,"data-index":b,"data-front":Ie,"data-swiping":ne,"data-dismissible":Fe,"data-type":je,"data-invert":$e,"data-swipe-out":J,"data-swipe-direction":G,"data-expanded":!!(S||V&&R),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${W?te:Re.current}px`,"--initial-height":V?"auto":`${fe}px`,...j,...f.style},onDragEnd:()=>{ee(!1),M(null),Ze.current=null},onPointerDown:bt=>{bt.button!==2&&(ze||!Fe||(be.current=new Date,le(Re.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(ee(!0),Ze.current={x:bt.clientX,y:bt.clientY})))},onPointerUp:()=>{var bt,It,sn;if(J||!Fe)return;Ze.current=null;const We=Number(((bt=we.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((It=we.current)==null?void 0:It.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((sn=be.current)==null?void 0:sn.getTime()),an=z==="x"?We:at,Xt=Math.abs(an)/ct;if(Math.abs(an)>=MNn||Xt>.11){le(Re.current),f.onDismiss==null||f.onDismiss.call(f,f),U(z==="x"?We>0?"right":"left":at>0?"down":"up"),Ke(),ie(!0);return}else{var On,Ne;(On=we.current)==null||On.style.setProperty("--swipe-amount-x","0px"),(Ne=we.current)==null||Ne.style.setProperty("--swipe-amount-y","0px")}Y(!1),ee(!1),M(null)},onPointerMove:bt=>{var It,sn,We;if(!Ze.current||!Fe||((It=window.getSelection())==null?void 0:It.toString().length)>0)return;const ct=bt.clientY-Ze.current.y,an=bt.clientX-Ze.current.x;var Xt;const On=(Xt=e.swipeDirections)!=null?Xt:LNn(B);!z&&(Math.abs(an)>1||Math.abs(ct)>1)&&M(Math.abs(an)>Math.abs(ct)?"x":"y");let Ne={x:0,y:0};const Le=Me=>1/(1.5+Math.abs(Me)/20);if(z==="y"){if(On.includes("top")||On.includes("bottom"))if(On.includes("top")&&ct<0||On.includes("bottom")&&ct>0)Ne.y=ct;else{const Me=ct*Le(ct);Ne.y=Math.abs(Me)<Math.abs(ct)?Me:ct}}else if(z==="x"&&(On.includes("left")||On.includes("right")))if(On.includes("left")&&an<0||On.includes("right")&&an>0)Ne.x=an;else{const Me=an*Le(an);Ne.x=Math.abs(Me)<Math.abs(an)?Me:an}(Math.abs(Ne.x)>0||Math.abs(Ne.y)>0)&&Y(!0),(sn=we.current)==null||sn.style.setProperty("--swipe-amount-x",`${Ne.x}px`),(We=we.current)==null||We.style.setProperty("--swipe-amount-y",`${Ne.y}px`)}},me&&!f.jsx&&je!=="loading"?De.createElement("button",{"aria-label":F,"data-disabled":ze,"data-close-button":!0,onClick:ze||!Fe?()=>{}:()=>{Ke(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Vg(H?.closeButton,f==null||(r=f.classNames)==null?void 0:r.closeButton)},(en=L?.close)!=null?en:kNn):null,(je||f.icon||f.promise)&&f.icon!==null&&(L?.[je]!==null||f.icon)?De.createElement("div",{"data-icon":"",className:Vg(H?.icon,f==null||(s=f.classNames)==null?void 0:s.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ye():null,f.type!=="loading"?Rt:null):null,De.createElement("div",{"data-content":"",className:Vg(H?.content,f==null||(a=f.classNames)==null?void 0:a.content)},De.createElement("div",{"data-title":"",className:Vg(H?.title,f==null||(i=f.classNames)==null?void 0:i.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?De.createElement("div",{"data-description":"",className:Vg(P,ae,H?.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),De.isValidElement(f.cancel)?f.cancel:f.cancel&&SL(f.cancel)?De.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||E,onClick:bt=>{SL(f.cancel)&&Fe&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,bt),Ke())},className:Vg(H?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,De.isValidElement(f.action)?f.action:f.action&&SL(f.action)?De.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:bt=>{SL(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,bt),!bt.defaultPrevented&&Ke())},className:Vg(H?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function HDe(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function zNn(e,t){const n={};return[e,t].forEach((r,s)=>{const a=s===1,i=a?"--mobile-offset":"--offset",l=a?RNn:ANn;function c(u){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${i}-${u}`]=l:n[`${i}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(l)}),n}const BNn=De.forwardRef(function(t,n){const{id:r,invert:s,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:l,closeButton:c,className:u,offset:d,mobileOffset:f,theme:p="light",richColors:h,duration:m,style:g,visibleToasts:v=INn,toastOptions:b,dir:w=HDe(),gap:S=$Nn,icons:O,containerAriaLabel:_="Notifications"}=t,[C,j]=De.useState([]),E=De.useMemo(()=>r?C.filter(R=>R.toasterId===r):C.filter(R=>!R.toasterId),[C,r]),N=De.useMemo(()=>Array.from(new Set([a].concat(E.filter(R=>R.position).map(R=>R.position)))),[E,a]),[I,P]=De.useState([]),[$,B]=De.useState(!1),[D,V]=De.useState(!1),[H,L]=De.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=De.useRef(null),z=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=De.useRef(null),G=De.useRef(!1),U=De.useCallback(R=>{j(q=>{var W;return(W=q.find(X=>X.id===R.id))!=null&&W.delete||Ad.dismiss(R.id),q.filter(({id:X})=>X!==R.id)})},[]);return De.useEffect(()=>Ad.subscribe(R=>{if(R.dismiss){requestAnimationFrame(()=>{j(q=>q.map(W=>W.id===R.id?{...W,delete:!0}:W))});return}setTimeout(()=>{Pve.flushSync(()=>{j(q=>{const W=q.findIndex(X=>X.id===R.id);return W!==-1?[...q.slice(0,W),{...q[W],...R},...q.slice(W+1)]:[R,...q]})})})}),[C]),De.useEffect(()=>{if(p!=="system"){L(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;const R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:q})=>{L(q?"dark":"light")})}catch{R.addListener(({matches:W})=>{try{L(W?"dark":"light")}catch(X){console.error(X)}})}},[p]),De.useEffect(()=>{C.length<=1&&B(!1)},[C]),De.useEffect(()=>{const R=q=>{var W;if(i.every(ee=>q[ee]||q.code===ee)){var ne;B(!0),(ne=F.current)==null||ne.focus()}q.code==="Escape"&&(document.activeElement===F.current||(W=F.current)!=null&&W.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),De.useEffect(()=>{if(F.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,G.current=!1)}},[F.current]),De.createElement("section",{ref:n,"aria-label":`${_} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((R,q)=>{var W;const[X,ne]=R.split("-");return E.length?De.createElement("ol",{key:R,dir:w==="auto"?HDe():w,tabIndex:-1,ref:F,className:u,"data-sonner-toaster":!0,"data-sonner-theme":H,"data-y-position":X,"data-x-position":ne,style:{"--front-toast-height":`${((W=I[0])==null?void 0:W.height)||0}px`,"--width":`${PNn}px`,"--gap":`${S}px`,...g,...zNn(d,f)},onBlur:ee=>{G.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(G.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||G.current||(G.current=!0,M.current=ee.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{D||B(!1)},onDragEnd:()=>B(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||V(!0)},onPointerUp:()=>V(!1)},E.filter(ee=>!ee.position&&q===0||ee.position===R).map((ee,J)=>{var ie,ue;return De.createElement(FNn,{key:ee.id,icons:O,index:J,toast:ee,defaultRichColors:h,duration:(ie=b?.duration)!=null?ie:m,className:b?.className,descriptionClassName:b?.descriptionClassName,invert:s,visibleToasts:v,closeButton:(ue=b?.closeButton)!=null?ue:c,interacting:D,position:R,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:U,toasts:E.filter(Y=>Y.position==ee.position),heights:I.filter(Y=>Y.position==ee.position),setHeights:P,expandByDefault:l,gap:S,expanded:$,swipeDirections:t.swipeDirections})})):null}))}),sxe=({className:e,toastOptions:t,...n})=>o.jsx(BNn,{...n,closeButton:!0,richColors:!0,className:K("mastra-toaster",e),toastOptions:{duration:5e3,...t}}),XU=(e,t)=>Array.isArray(e)?e.map(t):t(e),Ue=(e,t={})=>{if(Array.isArray(e))return e.map(n=>bu(n,t));if(De.isValidElement(e)||typeof e=="string")return bu(e,t);throw new Error("Invalid message type")};Ue.success=(e,t={})=>XU(e,n=>bu.success(n,t));Ue.error=(e,t={})=>XU(e,n=>bu.error(n,t));Ue.warning=(e,t={})=>XU(e,n=>bu.warning(n,t));Ue.info=(e,t={})=>XU(e,n=>bu.info(n,t));Ue.custom=(e,t={})=>bu(e,t);Ue.dismiss=e=>bu.dismiss(e);Ue.promise=({myPromise:e,loadingMessage:t,successMessage:n,errorMessage:r,onSuccess:s,onError:a,options:i={}})=>bu.promise(e,{loading:t??"Loading...",success:l=>(s?.(l),n),error:l=>(a?.(l),r||(l instanceof Error?l.message:"Error...")),...i});function og({text:e,copyMessage:t="Copied to clipboard!"}){const[n,r]=y.useState(!1),s=y.useRef(null),a=y.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{Ue.success(t),r(!0),s.current&&(clearTimeout(s.current),s.current=null),s.current=setTimeout(()=>{r(!1)},2e3)}).catch(()=>{Ue.error("Failed to copy to clipboard.")})},[e,t]);return{isCopied:n,handleCopy:a}}function Pa({content:e,copyMessage:t,tooltip:n="Copy to clipboard",size:r="sm",className:s}){const[a,i]=y.useState(!1),{handleCopy:l}=og({text:e,copyMessage:t}),c=()=>{l(),i(!0),setTimeout(()=>i(!1),2e3)};return o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx(pe,{onClick:c,type:"button",size:r,className:s,"aria-label":a?"Copied!":n,children:a?o.jsx(wx,{}):o.jsx(Kpt,{})})}),o.jsx(Hn,{children:a?"Copied!":n})]})}const UNn="mastra-theme",qNn="mastra-playground-store",Jde=e=>e==="dark"||e==="light"||e==="system",VNn=e=>{try{const t=e.getItem(qNn);if(!t)return;const r=JSON.parse(t)?.state?.theme;return Jde(r)?r:void 0}catch{return}},HNn=(e=UNn)=>({get(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(Jde(t))return t;const n=VNn(window.localStorage);return n?(window.localStorage.setItem(e,n),n):null}catch{return null}},set(t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}},subscribe(t){if(typeof window>"u")return()=>{};const n=r=>{if(r.key===e){if(r.newValue===null){t(null);return}Jde(r.newValue)&&t(r.newValue)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}}),rht=y.createContext(null),sht="(prefers-color-scheme: dark)",ZNn=typeof window>"u"?y.useEffect:y.useLayoutEffect,aht=()=>typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia(sht).matches?"dark":"light",iht=e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia(sht);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},WNn=(e,t)=>{e.classList.remove(t==="dark"?"light":"dark"),e.classList.add(t)},oht=({children:e,defaultTheme:t="system",storageKey:n,target:r})=>{const s=y.useMemo(()=>HNn(n),[n]),a=y.useRef(null),[i,l]=y.useState(()=>s.get()??t),c=y.useSyncExternalStore(iht,aht,()=>"dark");y.useEffect(()=>s.subscribe(f=>l(f??t)),[s,t]);const u=i==="system"?c:i;ZNn(()=>{const f=r??(typeof window>"u"?null:window.document.documentElement);a.current&&a.current!==f&&a.current.classList.remove("dark","light"),f&&WNn(f,u),a.current=f},[u,r]);const d=y.useMemo(()=>({theme:i,resolvedTheme:u,systemTheme:c,setTheme:f=>{l(f),s.set(f)}}),[i,u,c,s]);return o.jsx(rht.Provider,{value:d,children:e})},QNn=()=>{},gN=()=>{const e=y.useContext(rht),t=y.useSyncExternalStore(iht,aht,()=>"dark");return y.useMemo(()=>e??{theme:"system",resolvedTheme:t,systemTheme:t,setTheme:QNn},[e,t])};function GNn(e){return new iO(hbe.define(e))}const lht=[Im.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return wo(()=>Promise.resolve().then(()=>vL),[],import.meta.url).then(e=>e.javascript())}}),Im.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return wo(()=>Promise.resolve().then(()=>P1n),void 0,import.meta.url).then(e=>e.json())}}),Im.of({name:"JSX",extensions:["jsx"],load(){return wo(()=>Promise.resolve().then(()=>vL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Im.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return wo(()=>Promise.resolve().then(()=>j_n),void 0,import.meta.url).then(e=>e.markdown())}}),Im.of({name:"TSX",extensions:["tsx"],load(){return wo(()=>Promise.resolve().then(()=>vL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Im.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return wo(()=>Promise.resolve().then(()=>vL),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Im.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return wo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>GNn(e.shell))}})];function YNn(e,t=5){if(!e?.properties)return[];const n=[];function r(s,a,i){if(i>t)return;const l=Array.isArray(s.type)?s.type.join(" | "):s.type;if(n.push({path:a,label:a,description:s.description??s.title,type:l}),s.properties)for(const[c,u]of Object.entries(s.properties))r(u,`${a}.${c}`,i+1);if(s.items?.properties)for(const[c,u]of Object.entries(s.items.properties))r(u,`${a}[].${c}`,i+1)}for(const[s,a]of Object.entries(e.properties))r(a,s,1);return n}function XNn(e){const t=YNn(e);return zdt({override:[KNn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function KNn(e){return t=>{const r=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!r)return null;const s=r[1]??"",a=t.pos-s.length,i=s?e.filter(c=>c.path.toLowerCase().startsWith(s.toLowerCase())):e;if(i.length===0)return null;const l=i.map(c=>({label:c.path,displayLabel:c.path,detail:c.type,info:c.description,apply:(u,d,f,p)=>{const g=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:g},selection:{anchor:f+g.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const JNn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,eIn=Cn.mark({class:"cm-variable-highlight"}),ZDe=new edt({regexp:JNn,decoration:()=>eIn}),tIn=po.fromClass(class{decorations;constructor(e){this.decorations=ZDe.createDeco(e)}update(e){this.decorations=ZDe.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),nIn=tIn;function rIn(){const e=pN({settings:{fontFamily:"var(--font-mono)",fontSize:"0.8rem",lineHighlight:"transparent",gutterBackground:"transparent",gutterForeground:"var(--neutral2)",background:"transparent",foreground:"var(--neutral6)",caret:"var(--neutral6)"},styles:[{tag:[de.className,de.propertyName],color:"var(--neutral6)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic",color:"var(--neutral6)"},{tag:de.strong,fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.quote,fontStyle:"italic",color:"var(--neutral2)"}]}),t=Nt.theme({".cm-editor":{backgroundColor:"transparent"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{color:"var(--neutral3)"},".cm-cursor":{borderLeftColor:"var(--neutral6)"},".cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent3) 22%, transparent)"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}});return[e,t]}function sIn(){const e=Nt.theme({"&":{backgroundColor:"transparent",color:"var(--neutral6)",fontSize:"0.8rem"},"&.cm-editor .cm-scroller":{fontFamily:"var(--font-mono)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--neutral2)",borderRight:"none"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-activeLine":{backgroundColor:"transparent"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--neutral3)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--neutral6)"},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:"color-mix(in srgb, var(--accent3) 22%, transparent) !important"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}}),t=wg.define([{tag:[de.comment,de.bracket],color:"var(--neutral2)"},{tag:[de.string,de.meta,de.regexp],color:"var(--accent1)"},{tag:[de.atom,de.bool,de.special(de.variableName)],color:"var(--accent6)"},{tag:[de.keyword,de.operator,de.tagName],color:"var(--accent2)"},{tag:[de.function(de.propertyName),de.propertyName],color:"var(--accent5)"},{tag:[de.definition(de.variableName),de.function(de.variableName),de.className,de.attributeName],color:"var(--accent3)"},{tag:[de.variableName,de.number],color:"var(--accent5)"},{tag:[de.name,de.quote],color:"var(--accent1)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:[de.emphasis],fontStyle:"italic",color:"var(--neutral6)"},{tag:[de.strong],fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:[de.deleted],color:"var(--accent2)"},{tag:de.invalid,color:"var(--error)"},{tag:[de.standard(de.tagName)],color:"var(--accent1)"}]);return[e,S1(t)]}const Sx=()=>{const e=gN().resolvedTheme==="dark";return y.useMemo(()=>e?rIn():sIn(),[e])},Kr=y.forwardRef(({data:e,value:t,onChange:n,showCopyButton:r=!0,className:s,language:a="json",highlightVariables:i=!1,placeholder:l,schema:c,autoFocus:u,lineNumbers:d=!0,editable:f,...p},h)=>{const m=Sx(),g=e?JSON.stringify(e,null,2):t??"",v=y.useMemo(()=>{const b=[];return a==="json"?b.push(vp):a==="markdown"&&(b.push(Bbe({base:cO,codeLanguages:lht})),b.push(Nt.lineWrapping)),i&&a==="markdown"&&b.push(nIn),c&&a==="markdown"&&b.push(XNn(c)),f===!1&&b.push(os.readOnly.of(!0)),b},[a,i,c,f]);return o.jsxs("div",{className:K("rounded-md bg-surface3 p-1 font-mono relative border border-border1 overflow-hidden",s),...p,children:[r&&o.jsx(Pa,{content:g,className:"absolute top-2 right-2 z-20"}),o.jsx(Ou,{ref:h,value:g,theme:m,extensions:v,onChange:n,editable:f,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),aIn={js:"javascript",javascript:"javascript",mjs:"javascript",cjs:"javascript",node:"javascript",ts:"typescript",typescript:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",jsx:"jsx",json:"json",json5:"json",md:"markdown",markdown:"markdown",py:"python",python:"python",sh:"bash",bash:"bash",shell:"bash",zsh:"bash"};let rX=null;function iIn(){return rX||(rX=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([wo(()=>import("./core-XYsT5xMn.js"),__vite__mapDeps([0,1,2]),import.meta.url),wo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[wo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),wo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[wo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),wo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),wo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),wo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),wo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),wo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),wo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),wo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),rX}async function oIn(e,t){const n=aIn[t?.toLowerCase()];if(!n)return null;const r=await iIn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Qr({iconSlot:e,titleSlot:t,descriptionSlot:n,actionSlot:r,className:s,as:a="h3"}){return o.jsxs("div",{className:K("flex flex-col items-center justify-center text-center py-10 px-6","transition-opacity duration-normal ease-out-custom",s),children:[e&&o.jsx("div",{className:"mb-4",children:e}),o.jsx(a,{className:"font-medium text-neutral5 text-ui-md",children:t}),n&&o.jsx("p",{className:"mt-1.5 text-neutral3 text-ui-sm max-w-md",children:n}),r&&o.jsx("div",{className:"mt-5",children:r})]})}const gf=({children:e,className:t,onClick:n})=>o.jsx("div",{tabIndex:n?0:void 0,onKeyDown:r=>{n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n?.())},className:K("flex gap-3 group/entity bg-surface3 rounded-xl border border-border1 py-3 px-4",n&&"cursor-pointer hover:bg-surface4 transition-all",t),onClick:n,children:e}),cht=({children:e,className:t,style:n})=>o.jsx(Ge,{size:"lg",className:K("text-neutral3 mt-1 shrink-0",t),style:n,children:e}),vf=({children:e,className:t})=>o.jsx(ge,{as:"p",variant:"ui-lg",className:K("text-neutral6 font-medium",t),children:e}),Mp=({children:e,className:t})=>o.jsx(ge,{as:"div",variant:"ui-sm",className:K("text-neutral3",t),children:e}),yf=({children:e,className:t})=>o.jsx("div",{className:K("flex-1 w-full",t),children:e});function ks({resource:e,title:t,description:n,actionSlot:r,className:s}){const a="Permission Denied",i=e?`You don't have permission to access ${e}. Contact your administrator for access.`:"You don't have permission to access this resource. Contact your administrator for access.";return o.jsx(Qr,{className:s,iconSlot:o.jsx(Ge,{size:"lg",className:"text-neutral3",children:o.jsx(XTn,{})}),titleSlot:t??a,descriptionSlot:n??i,actionSlot:r})}function Ms({title:e,description:t,className:n}){const[r,s]=y.useState(!1),a=He(),i=y.useCallback(async()=>{try{s(!0);const{baseUrl:l="",apiPrefix:c}=a.options||{},u=(c||"/api").trim(),d=(u.startsWith("/")?u:`/${u}`).replace(/\/$/,""),f=new URLSearchParams({redirect_uri:window.location.href}),p=`${l}${d}/auth/sso/login?${f}`,h=await fetch(p,{credentials:"include",headers:{"Content-Type":"application/json"}});if(h.ok){const m=await h.json();window.location.href=m.url}}finally{s(!1)}},[a]);return o.jsx(Qr,{className:n,iconSlot:o.jsx(Ge,{size:"lg",className:"text-neutral3",children:o.jsx(MTn,{})}),titleSlot:e??"Session Expired",descriptionSlot:t??"Your session has expired. Please log in again to continue.",actionSlot:o.jsx(pe,{variant:"default",onClick:i,disabled:r,children:r?"Redirecting...":"Log in"})})}const axe=({children:e,border:t=!0,className:n})=>o.jsx("header",{className:K("h-header-default z-50 flex w-full items-center gap-4 bg-transparent px-3",{"border-b border-border1":t},n),children:e}),uht=({children:e})=>o.jsx(ge,{as:"h1",variant:"ui-md",className:"text-neutral6 flex items-center gap-2",children:e}),lIn=({children:e})=>o.jsx("div",{className:"ml-auto flex items-center gap-3",children:e}),Th=e=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 34 21",fill:"none",...e,children:o.jsx("path",{d:"M4.49805 11.6934C6.98237 11.6934 8.99609 13.7081 8.99609 16.1924C8.9959 18.6765 6.98225 20.6904 4.49805 20.6904C2.01394 20.6903 0.000196352 18.6765 0 16.1924C0 13.7081 2.01382 11.6935 4.49805 11.6934ZM10.3867 0C12.8709 0 14.8846 2.01388 14.8848 4.49805C14.8848 4.8377 14.847 5.16846 14.7755 5.48643C14.4618 6.88139 14.1953 8.4633 14.9928 9.65L16.2575 11.5319C16.3363 11.6491 16.4727 11.7115 16.6137 11.703C16.7369 11.6957 16.8525 11.6343 16.9214 11.5318L18.1876 9.64717C18.9772 8.47198 18.7236 6.90783 18.4205 5.52484C18.3523 5.21392 18.3164 4.89094 18.3164 4.55957C18.3167 2.07546 20.3313 0.0615234 22.8154 0.0615234C25.2994 0.0617476 27.3132 2.0756 27.3135 4.55957C27.3135 4.93883 27.2665 5.30712 27.178 5.65896C26.8547 6.94441 26.5817 8.37932 27.2446 9.52714L28.459 11.6301C28.4819 11.6697 28.5245 11.6934 28.5703 11.6934C31.0545 11.6935 33.0684 13.7081 33.0684 16.1924C33.0682 18.6765 31.0544 20.6903 28.5703 20.6904C26.0861 20.6904 24.0725 18.6765 24.0723 16.1924C24.0723 15.8049 24.1212 15.4288 24.2133 15.0701C24.5458 13.7746 24.8298 12.3251 24.1609 11.1668L23.0044 9.16384C22.9656 9.09659 22.8931 9.05859 22.8154 9.05859C22.7983 9.05859 22.7824 9.06614 22.7728 9.08033L21.4896 10.9895C20.686 12.1851 20.9622 13.781 21.284 15.1851C21.3582 15.5089 21.3975 15.8461 21.3975 16.1924C21.3973 18.6764 19.3834 20.6902 16.8994 20.6904C14.4152 20.6904 12.4006 18.6765 12.4004 16.1924C12.4004 15.932 12.4226 15.6768 12.4651 15.4286C12.6859 14.14 12.8459 12.7122 12.1167 11.6271L11.2419 10.3253C10.6829 9.49347 9.71913 9.05932 8.78286 8.70188C7.0906 8.05584 5.88867 6.41734 5.88867 4.49805C5.88886 2.0139 7.90254 3.29835e-05 10.3867 0Z",fill:"currentColor"})}),cIn={default:"[&>tbody>tr]:h-table-row",small:"[&>tbody>tr]:h-table-row-small"},uIn=({className:e,children:t,size:n="default",style:r})=>o.jsx("table",{className:K("w-full",cIn[n],e),style:r,children:t}),dIn=({className:e,children:t})=>o.jsx("thead",{children:o.jsx("tr",{className:K("h-table-header border-b border-border1 bg-surface2/80",e),children:t})}),fIn=({className:e,children:t,...n})=>o.jsx("th",{className:K("text-neutral2 text-ui-xs h-full whitespace-nowrap text-left font-medium uppercase tracking-wide first:pl-3 last:pr-3",e),...n,children:t}),pIn=({className:e,children:t,...n})=>o.jsx("tbody",{className:K("",e),...n,children:t}),hIn=y.forwardRef(({className:e,children:t,selected:n=!1,style:r,onClick:s,isActive:a=!1,...i},l)=>{const c=y.useRef(null);y.useEffect(()=>{l&&(typeof l=="function"?l(c.current):l.current=c.current)},[l]),y.useEffect(()=>{a&&c.current&&(c.current.focus(),c.current.scrollIntoView({block:"nearest"}))},[a]);const u=d=>{d.key==="Enter"&&s&&s()};return o.jsx("tr",{className:K("border-b border-border1","transition-colors duration-normal ease-out-custom","hover:bg-surface3","focus:bg-surface3 focus:outline-hidden focus:ring-1 focus:ring-inset focus:ring-accent1/50",n&&"bg-surface4",s&&"cursor-pointer",e),style:r,onClick:s,ref:c,tabIndex:s?0:void 0,onKeyDown:u,"data-active":a||void 0,...i,children:t})}),mIn=({className:e,children:t,...n})=>o.jsx("td",{className:K("text-neutral5 first:pl-3 last:pr-3",e),...n,children:o.jsx("div",{className:K("flex h-full w-full shrink-0 items-center"),children:t})}),gIn=Wc(K("flex w-full text-neutral6 border bg-transparent","transition-all duration-normal ease-out-custom","placeholder:text-neutral2 placeholder:transition-opacity placeholder:duration-normal","focus:placeholder:opacity-70","min-h-[80px] resize-y"),{variants:{variant:{default:K(jF,"rounded-xl",Ck),filled:K(jF,"rounded-xl",Ck),outline:K(kct,"rounded-xl",Ck),unstyled:Oct},size:{sm:"px-2 py-1.5 text-ui-sm",md:"px-3 py-2 text-ui-md",default:"px-3 py-2 text-ui-md",lg:"px-4 py-3 text-ui-lg"}},defaultVariants:{variant:"default",size:"default"}}),Ul=y.forwardRef(({className:e,size:t,testId:n,variant:r,error:s,...a},i)=>o.jsx("textarea",{className:K(gIn({variant:r,size:t}),s&&"border-error focus-visible:border-error",e),"data-testid":n,ref:i,"aria-invalid":s,...a}));Ul.displayName="Textarea";let WDe={},QDe={},GDe="";function vIn(e){if(typeof document>"u")return!1;const t=dr(e);return Xs(t).innerWidth-t.documentElement.clientWidth>0}function yIn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=dr(e),r=n.documentElement,s=n.body,a=b1(r)?r:s,i=a.style.overflowY,l=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const c=a.offsetWidth;a.style.overflowY="hidden";const u=a.offsetWidth;return a.style.overflowY=i,r.style.scrollbarGutter=l,c===u}function bIn(e){const t=dr(e),n=t.documentElement,r=t.body,s=b1(n)?n:r,a={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,a)}}function xIn(e){const t=dr(e),n=t.documentElement,r=t.body,s=Xs(n);let a=0,i=0,l=!1;const c=Pd.create();if(gU&&(s.visualViewport?.scale??1)!==1)return()=>{};function u(){const h=s.getComputedStyle(n),m=s.getComputedStyle(r),b=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,i=n.scrollLeft,WDe={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},GDe=n.style.scrollBehavior,QDe={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const w=n.scrollHeight>n.clientHeight,S=n.scrollWidth>n.clientWidth,O=h.overflowY==="scroll"||m.overflowY==="scroll",_=h.overflowX==="scroll"||m.overflowX==="scroll",C=Math.max(0,s.innerWidth-r.clientWidth),j=Math.max(0,s.innerHeight-r.clientHeight),E=parseFloat(m.marginTop)+parseFloat(m.marginBottom),N=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=b1(n)?n:r;if(l=yIn(e),l){n.style.scrollbarGutter=b,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(w||O)&&(n.style.overflowY="scroll"),(S||_)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:E||j?`calc(100dvh - ${E+j}px)`:"100dvh",width:N||C?`calc(100vw - ${N+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,WDe),Object.assign(r.style,QDe),l||(n.scrollTop=a,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=GDe)}function f(){d(),c.request(u)}u();const p=Br(s,"resize",f);return()=>{c.cancel(),d(),typeof s.removeEventListener=="function"&&p()}}class wIn{lockCount=0;restore=null;timeoutLock=Fh.create();timeoutUnlock=Fh.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=dr(t).documentElement,s=Xs(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ga;return}const a=mye||!vIn(t);this.restore=a?bIn(t):xIn(t)}}const SIn=new wIn;function dht(e=!0,t=null){Tt(()=>{if(e)return SIn.acquire(t)},[e,t])}function kIn(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:s}=e,a=t.useState("open");dct(t,a),JM(t);const{forceUnmount:i}=e3(a,t),l=y.useCallback(()=>{t.setOpen(!1,qt(GM))},[t]);return y.useImperativeHandle(r,()=>({unmount:i,close:l}),[i,l]),{parentContext:n,isDrawer:s}}function OIn({store:e,dialogRoot:t}){const{parentContext:n,isDrawer:r}=t,s=e.useState("open"),a=e.useState("disablePointerDismissal"),i=e.useState("modal"),l=e.useState("popupElement"),c=e.useState("floatingRootContext"),[u,d]=y.useState(0),[f,p]=y.useState(0),h=u===0,m=l_(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(w){if(!e.context.outsidePressEnabledRef.current||"button"in w&&w.button!==0||"touches"in w&&w.touches.length!==1)return!1;const S=Si(w);if(h&&!a){const O=S;return i&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===O||e.context.backdropRef.current===O||dn(O,l)&&!O?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:h});dht(s&&i===!0,l),e.useContextCallback("onNestedDialogOpen",(w,S)=>{d(w),p(S)}),e.useContextCallback("onNestedDialogClose",()=>{d(0),p(0)}),y.useEffect(()=>(n?.onNestedDialogOpen&&s&&n.onNestedDialogOpen(u+1,f+(r?1:0)),n?.onNestedDialogClose&&!s&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&s&&n.onNestedDialogClose()}),[r,s,u,f,n]);const g=m.reference??vs,v=m.trigger??vs,b=y.useMemo(()=>Eo(dy,m.floating),[m.floating]);return t3(e,{activeTriggerProps:g,inactiveTriggerProps:v,popupProps:b,nestedOpenDialogCount:u,nestedOpenDrawerCount:f}),null}const ixe=y.createContext(!1),fht=y.createContext(void 0);function gd(e){const t=y.useContext(fht);if(e===!1&&t===void 0)throw new Error(yr(27));return t}const _In={...r3,modal:lt(e=>e.modal),nested:lt(e=>e.nested),nestedOpenDialogCount:lt(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:lt(e=>e.nestedOpenDrawerCount),disablePointerDismissal:lt(e=>e.disablePointerDismissal),openMethod:lt(e=>e.openMethod),descriptionElementId:lt(e=>e.descriptionElementId),titleElementId:lt(e=>e.titleElementId),viewportElement:lt(e=>e.viewportElement),role:lt(e=>e.role)};class oxe extends rN{constructor(t,n,r=!1){const s=new c_,a=CIn(t);a.floatingRootContext=_U(s,n,r),super(a,{popupRef:y.createRef(),backdropRef:y.createRef(),internalBackdropRef:y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:s,onOpenChange:void 0,onOpenChangeComplete:void 0},_In)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,n);const r={open:t};OU(r,t,n.trigger),this.update(r)};static useStore(t,n){return kU(t,(s,a)=>new oxe(n,s,a),!0).store}}function CIn(e={}){return{...n3(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function pht(e,t="dialog"){const{children:n,open:r,defaultOpen:s=!1,onOpenChange:a,onOpenChangeComplete:i,disablePointerDismissal:l=!1,modal:c=!0,actionsRef:u,handle:d,triggerId:f,defaultTriggerId:p=null}=e,h=t==="drawer",m=t==="alert-dialog",g=m?!0:c,v=m||l,b=m?"alertdialog":"dialog",w=gd(!0),O={modal:g,disablePointerDismissal:v,nested:!!w,role:b},_=oxe.useStore(d?.store,{open:s,openProp:r,activeTriggerId:p,triggerIdProp:f,...O});s_(()=>{const $=r===void 0&&_.state.open===!1&&s===!0?{open:!0,activeTriggerId:p}:null;m?_.update($?{...O,...$}:O):$&&_.update($)}),_.useControlledProp("openProp",r),_.useControlledProp("triggerIdProp",f),_.useSyncedValues(O),_.useContextCallback("onOpenChange",a),_.useContextCallback("onOpenChangeComplete",i);const C=_.useState("open"),j=_.useState("mounted"),E=_.useState("payload"),N=kIn({store:_,actionsRef:u,parentContext:w?.store.context,isDrawer:h}),I=C||j,P=y.useMemo(()=>({store:_}),[_]);return o.jsx(ixe.Provider,{value:!1,children:o.jsxs(fht.Provider,{value:P,children:[I&&o.jsx(OIn,{store:_,dialogRoot:N}),typeof n=="function"?n({payload:E}):n]})})}function EIn(e){return pht(e,"alert-dialog")}const jIn={...mf,...ql},lxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,forceRender:i=!1,...l}=t,{store:c}=gd(),u=c.useState("open"),d=c.useState("nested"),f=c.useState("mounted"),p=c.useState("transitionStatus");return En("div",t,{state:{open:u,transitionStatus:p},ref:[c.context.backdropRef,n],stateAttributesMapping:jIn,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:i||!d})}),hht=y.createContext(void 0);function cxe(e=!1){const t=y.useContext(hht);if(t===void 0&&!e)throw new Error(yr(16));return t}function TIn(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:s=0,isNativeButton:a}=e,i=r&&t!==!1,l=r&&t===!1;return{props:y.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=s,!a&&n&&(u.tabIndex=t?s:-1)),(a&&(t||i)||!a&&n)&&(u["aria-disabled"]=n),a&&(!t||l)&&(u.disabled=n),u},[r,n,t,i,l,a,s])}}function vd(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:s=!0,composite:a}=e,i=y.useRef(null),l=cxe(!0),c=a??l!==void 0,{props:u}=TIn({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:s}),d=y.useCallback(()=>{const h=i.current;sX(h)&&c&&t&&u.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,u.disabled,c]);Tt(d,[d]);const f=y.useCallback((h={})=>{const{onClick:m,onMouseDown:g,onKeyUp:v,onKeyDown:b,onPointerDown:w,...S}=h;return Eo({onClick(O){if(t){O.preventDefault();return}m?.(O)},onMouseDown(O){t||g?.(O)},onKeyDown(O){if(t||(kF(O),b?.(O),O.baseUIHandlerPrevented))return;const _=O.target===O.currentTarget,C=O.currentTarget,j=sX(C),E=!s&&NIn(C),N=_&&(s?j:!E),I=O.key==="Enter",P=O.key===" ",$=C.getAttribute("role"),B=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(_&&c&&P){if(O.defaultPrevented&&B)return;O.preventDefault(),E||s&&j?(C.click(),O.preventBaseUIHandler()):N&&(m?.(O),O.preventBaseUIHandler());return}N&&(!s&&(P||I)&&O.preventDefault(),!s&&I&&m?.(O))},onKeyUp(O){if(!t){if(kF(O),v?.(O),O.target===O.currentTarget&&s&&c&&sX(O.currentTarget)&&O.key===" "){O.preventDefault();return}O.baseUIHandlerPrevented||O.target===O.currentTarget&&!s&&!c&&O.key===" "&&m?.(O)}},onPointerDown(O){if(t){O.preventDefault();return}w?.(O)}},s?{type:"button"}:{role:"button"},u,S)},[t,u,c,s]),p=mt(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:p}}function sX(e){return _a(e)&&e.tagName==="BUTTON"}function NIn(e){return!!(e?.tagName==="A"&&e?.href)}const m3=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,...c}=t,{store:u}=gd(),d=u.useState("open"),{getButtonProps:f,buttonRef:p}=vd({disabled:i,native:l}),h={disabled:i};function m(g){d&&u.setOpen(!1,qt(yye,g.nativeEvent))}return En("button",t,{state:h,ref:[n,p],props:[{onClick:m},c,f]})}),KU=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=gd(),u=Mi(i);return c.useSyncedValueWithCleanup("descriptionElementId",u),En("p",t,{ref:n,props:[{id:u},l]})});let IIn=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),AIn=(function(e){return e[e.open=ed.open]="open",e[e.closed=ed.closed]="closed",e[e.startingStyle=ed.startingStyle]="startingStyle",e[e.endingStyle=ed.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const mht=y.createContext(void 0);function uxe(){const e=y.useContext(mht);if(e===void 0)throw new Error(yr(26));return e}const aj="ArrowUp",pk="ArrowDown",ZP="ArrowLeft",ij="ArrowRight",g3="Home",v3="End",ght="PageUp",vht="PageDown",yht=new Set([ZP,ij]),RIn=new Set([ZP,ij,g3,v3]),bht=new Set([aj,pk]),PIn=new Set([aj,pk,g3,v3]),xht=new Set([...yht,...bht]),O1=new Set([...xht,g3,v3]),wht="Shift",$In="Control",MIn="Alt",DIn="Meta",LIn=new Set([wht,$In,MIn,DIn]);function FIn(e){return _a(e)&&e.tagName==="INPUT"}function YDe(e){return!!(FIn(e)&&e.selectionStart!=null||_a(e)&&e.tagName==="TEXTAREA")}function XDe(e,t,n,r){if(!e||!t||!t.scrollTo)return;let s=e.scrollLeft,a=e.scrollTop;const i=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(i&&r!=="vertical"){const c=KDe(e,t,"left"),u=kL(e),d=kL(t);n==="ltr"&&(c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight?s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight:c-d.scrollMarginLeft<e.scrollLeft+u.scrollPaddingLeft&&(s=c-d.scrollMarginLeft-u.scrollPaddingLeft)),n==="rtl"&&(c-d.scrollMarginRight<e.scrollLeft+u.scrollPaddingLeft?s=c-d.scrollMarginLeft-u.scrollPaddingLeft:c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight&&(s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight))}if(l&&r!=="horizontal"){const c=KDe(e,t,"top"),u=kL(e),d=kL(t);c-d.scrollMarginTop<e.scrollTop+u.scrollPaddingTop?a=c-d.scrollMarginTop-u.scrollPaddingTop:c+t.offsetHeight+d.scrollMarginBottom>e.scrollTop+e.clientHeight-u.scrollPaddingBottom&&(a=c+t.offsetHeight+d.scrollMarginBottom-e.clientHeight+u.scrollPaddingBottom)}e.scrollTo({left:s,top:a,behavior:"auto"})}function KDe(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let s=0;for(;t.offsetParent&&(s+=t[r],t.offsetParent!==e);)t=t.offsetParent;return s}function kL(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const zIn={...mf,...ql,nestedDialogOpen(e){return e?{[AIn.nestedDialogOpen]:""}:null}},dxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,finalFocus:i,initialFocus:l,...c}=t,{store:u}=gd(),d=u.useState("descriptionElementId"),f=u.useState("disablePointerDismissal"),p=u.useState("floatingRootContext"),h=u.useState("popupProps"),m=u.useState("modal"),g=u.useState("mounted"),v=u.useState("nested"),b=u.useState("nestedOpenDialogCount"),w=u.useState("open"),S=u.useState("openMethod"),O=u.useState("titleElementId"),_=u.useState("transitionStatus"),C=u.useState("role"),j=p.useState("floatingId"),E=c.id??j;uxe(),Vl({open:w,ref:u.context.popupRef,onComplete(){w&&u.context.onOpenChangeComplete?.(!0)}});function N(V){return V==="touch"?u.context.popupRef.current:!0}const I=l===void 0?N:l,P=b>0,$=u.useStateSetter("popupElement"),D=En("div",t,{state:{open:w,nested:v,transitionStatus:_,nestedDialogOpen:P},props:[h,{id:E,"aria-labelledby":O??void 0,"aria-describedby":d??void 0,role:C,...dy,hidden:!g,onKeyDown(V){O1.has(V.key)&&V.stopPropagation()},style:{[IIn.nestedDialogs]:b}},c],ref:[n,u.context.popupRef,$],stateAttributesMapping:zIn});return o.jsx(nN,{context:p,openInteractionType:S,disabled:!g,closeOnFocusOut:!f,initialFocus:I,returnFocus:i,modal:m!==!1,restoreFocus:"popup",children:D})}),y3=y.forwardRef(function(t,n){const{cutout:r,...s}=t;let a;if(r){const i=r.getBoundingClientRect();a=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),JU=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,{store:a}=gd(),i=a.useState("mounted"),l=a.useState("modal"),c=a.useState("open");return i||r?o.jsx(mht.Provider,{value:r,children:o.jsxs(XM,{ref:n,...s,children:[i&&l===!0&&o.jsx(y3,{ref:a.context.internalBackdropRef,inert:oN(!c)}),t.children]})}):null}),eq=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=gd(),u=Mi(i);return c.useSyncedValueWithCleanup("titleElementId",u),En("h2",t,{ref:n,props:[{id:u},l]})});function BIn(e){const t=y.useRef(""),n=y.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:y.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function wv(e,t){const n=y.useRef(e),r=mt(t);Tt(()=>{n.current!==e&&r(n.current)},[e,r]),Tt(()=>{n.current=e},[e])}function fxe(e,t){const n=mt((a,i)=>{(typeof e=="function"?e():e)||t(i||(mye?"touch":""))}),{onClick:r,onPointerDown:s}=BIn(n);return y.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function pxe(e){const[t,n]=y.useState(null),r=fxe(e,n);return wv(e,s=>{s&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Sht=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,id:c,payload:u,handle:d,...f}=t,p=gd(!0),h=d?.store??p?.store;if(!h)throw new Error(yr(79));const m=Mi(c),g=h.useState("floatingRootContext"),v=h.useState("isOpenedByTrigger",m),b=h.useState("triggerPopupId",m),w=y.useRef(null),{registerTrigger:S,isMountedByThisTrigger:O}=KM(m,w,h,{payload:u}),{getButtonProps:_,buttonRef:C}=vd({disabled:i,native:l}),j=o_(g,{enabled:g!=null}),E=fxe(()=>h.select("open"),P=>{h.set("openMethod",P)}),N={disabled:i,open:v},I=h.useState("triggerProps",O);return En("button",t,{state:N,ref:[C,n,S,w],props:[j.reference,I,E,{[_ye]:"",id:m,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":b},f,_],stateAttributesMapping:sN})}),UIn=Sht;let JDe=(function(e){return e[e.open=ed.open]="open",e[e.closed=ed.closed]="closed",e[e.startingStyle=ed.startingStyle]="startingStyle",e[e.endingStyle=ed.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const qIn={...mf,...ql,nested(e){return e?{[JDe.nested]:""}:null},nestedDialogOpen(e){return e?{[JDe.nestedDialogOpen]:""}:null}},VIn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,c=uxe(),{store:u}=gd(),d=u.useState("open"),f=u.useState("nested"),p=u.useState("transitionStatus"),h=u.useState("nestedOpenDialogCount"),m=u.useState("mounted"),g=u.useStateSetter("viewportElement"),v=h>0;return En("div",t,{enabled:c||m,state:{open:d,nested:f,transitionStatus:p,nestedDialogOpen:v},ref:[n,g],stateAttributesMapping:qIn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:d?void 0:"none"},children:i},l]})});function b3(e,t){return e&&y.isValidElement(t)?{render:t}:void 0}const HIn=EIn;function jt({open:e,onOpenChange:t,children:n}){return o.jsx(HIn,{open:e,onOpenChange:t,children:n})}const kht=y.forwardRef(({asChild:e,children:t,...n},r)=>o.jsx(UIn,{ref:r,...b3(e,t),...n,children:e?void 0:t}));kht.displayName="AlertDialogTrigger";const Oht=JU,hxe=y.forwardRef(({className:e,...t},n)=>o.jsx(lxe,{ref:n,className:K("dialog-overlay-anim fixed inset-0 z-50 bg-overlay backdrop-blur-xs",e),...t}));hxe.displayName="AlertDialogOverlay";const _ht=y.forwardRef(({className:e,...t},n)=>o.jsxs(Oht,{children:[o.jsx(hxe,{}),o.jsx(dxe,{ref:n,"data-slot":"alert-dialog-content",className:K("dialog-content-anim","fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%]","w-full max-w-[calc(100%-2rem)] sm:max-w-lg","rounded-xl border border-border1/40 bg-surface2/96 backdrop-blur-md shadow-dialog",e),...t})]}));_ht.displayName="AlertDialogContent";const Cht=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col gap-0.5 px-4 py-3 text-left",e),...t});Cht.displayName="AlertDialogHeader";const Eht=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col-reverse gap-1.5 px-4 py-2.5 sm:flex-row sm:justify-end",e),...t});Eht.displayName="AlertDialogFooter";const jht=({className:e,...t})=>o.jsx("div",{className:K("overflow-y-auto px-4 py-3.5 max-h-[50vh]",e),...t});jht.displayName="AlertDialogBody";const Tht=y.forwardRef(({className:e,...t},n)=>o.jsx(eq,{ref:n,className:K("text-ui-md font-medium",e),...t}));Tht.displayName="AlertDialogTitle";const Nht=y.forwardRef(({className:e,...t},n)=>o.jsx(KU,{ref:n,className:K("text-ui-sm text-neutral3",e),...t}));Nht.displayName="AlertDialogDescription";const Iht=y.forwardRef(({className:e,...t},n)=>o.jsx(m3,{ref:n,className:K(i3({variant:"primary",size:"lg"}),e),...t}));Iht.displayName="AlertDialogAction";const Aht=y.forwardRef(({className:e,...t},n)=>o.jsx(m3,{ref:n,className:K(i3({variant:"default",size:"lg"}),e),...t}));Aht.displayName="AlertDialogCancel";jt.Trigger=kht;jt.Portal=Oht;jt.Overlay=hxe;jt.Content=_ht;jt.Header=Cht;jt.Footer=Eht;jt.Body=jht;jt.Title=Tht;jt.Description=Nht;jt.Action=Iht;jt.Cancel=Aht;function Xd({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=y.useRef(e!==void 0),[a,i]=y.useState(t),l=s?e:a,c=y.useCallback(u=>{s||i(u)},[]);return[l,c]}function ZIn(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const r=t;if(r.type==="submit")return r}}return null}let e4e=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({}),t4e=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const WIn={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},OE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},QIn={disabled:!1,...OE},_1={valid(e){return e===null?null:e?{[t4e.valid]:""}:{[t4e.invalid]:""}}};function Rht(e){return y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[e4e.checked]:""}:{[e4e.unchecked]:""}},..._1}),[e.indeterminate])}const Pht={invalid:void 0,name:void 0,validityData:{state:WIn,errors:[],error:"",value:"",initialValue:null},setValidityData:ga,disabled:void 0,touched:OE.touched,setTouched:ga,dirty:OE.dirty,setDirty:ga,filled:OE.filled,setFilled:ga,focused:OE.focused,setFocused:ga,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:QIn,markedDirtyRef:{current:!1},registerFieldControl:ga,validation:{getValidationProps:(e=vs)=>e,getInputValidationProps:(e=vs)=>e,inputRef:{current:null},commit:async()=>{}}},$ht=y.createContext(Pht);function Jh(e=!0){const t=y.useContext($ht);if(t.setValidityData===ga&&!e)throw new Error(yr(28));return t}function vN(e,t,n,r,s=!0){const{registerFieldControl:a}=Jh(),i=y.useRef(null);i.current||(i.current=Symbol()),Tt(()=>{const l=i.current;return!l||!s?void 0:(a(l,{controlRef:e,getValue:r,id:t,value:n}),()=>{a(l,void 0)})},[e,s,r,t,a,n])}const GIn=y.createContext({disabled:!1});function Mht(){return y.useContext(GIn)}const YIn=y.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ga,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function yN(){return y.useContext(YIn)}const XIn=y.createContext({controlId:void 0,registerControlId:ga,labelId:void 0,setLabelId:ga,messageIds:[],setMessageIds:ga,getDescriptionProps:e=>e});function kx(){return y.useContext(XIn)}function mxe(e,t,n,r=!0,s){const[a,i]=y.useState(),l=Mi(s?`${s}-label`:void 0),c=e??t??a;return Tt(()=>{const u=e||t||!r?void 0:KIn(n.current,l);a!==u&&i(u)}),c}function KIn(e,t){const n=JIn(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function JIn(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const s=e.nextElementSibling;if(s&&s.htmlFor===n)return s}const r=e.labels;return r&&r[0]}const eAn=y.createContext(void 0);function tAn(e=!0){const t=y.useContext(eAn);if(t===void 0&&!e)throw new Error(yr(3));return t}const Dht=y.createContext(void 0);function nAn(){const e=y.useContext(Dht);if(e===void 0)throw new Error(yr(14));return e}const rAn="data-parent",sAn=y.forwardRef(function(t,n){const{checked:r,className:s,defaultChecked:a=!1,"aria-labelledby":i,disabled:l=!1,form:c,id:u,indeterminate:d=!1,inputRef:f,name:p,onCheckedChange:h,parent:m=!1,readOnly:g=!1,render:v,required:b=!1,uncheckedValue:w,value:S,nativeButton:O=!1,style:_,...C}=t,{clearErrors:j}=yN(),{disabled:E,name:N,setDirty:I,setFilled:P,setFocused:$,setTouched:B,state:D,validationMode:V,validityData:H,shouldValidateOnChange:L,validation:F}=Jh(),z=Mht(),{labelId:M,controlId:G,registerControlId:U,getDescriptionProps:R}=kx(),q=tAn(),W=q?.parent,X=W&&q.allValues,ne=E||z.disabled||q?.disabled||l,ee=N??p,J=S??ee,ie=Mi(),ue=Mi();let Y=G;X?Y=m?ue:`${W.id}-${J}`:u&&(Y=u);let te={};X&&(m?te=q.parent.getParentProps():J&&(te=q.parent.getChildProps(J)));const{checked:le=r,indeterminate:fe=d,onCheckedChange:se,...he}=te,be=q?.value,we=q?.setValue,Ie=q?.defaultValue,ke=y.useRef(null),je=cc(()=>Symbol("checkbox-control")),Fe=y.useRef(!1),{getButtonProps:ce,buttonRef:ae}=vd({disabled:ne,native:O}),re=q?.validation??F,[me,ye]=Xd({controlled:J&&be&&!m?be.includes(J):le,default:J&&Ie&&!m?Ie.includes(J):a,name:"Checkbox",state:"checked"});Tt(()=>{U!==ga&&(Fe.current=!0,U(je.current,Y))},[Y,U,je]),y.useEffect(()=>{const ze=je.current;return()=>{!Fe.current||U===ga||(Fe.current=!1,U(ze,void 0))}},[U,je]),vN(ke,ie,me,void 0,!q);const Te=y.useRef(null),Re=ku(f,Te,re.inputRef),Qe=mxe(i,M,Te,!O,Y??void 0);Tt(()=>{Te.current&&(Te.current.indeterminate=fe,me&&P(!0))},[me,fe,P]),wv(me,()=>{q&&!m||(j(ee),P(me),I(me!==H.initialValue),L()?re.commit(me):re.commit(me,!0))});const Ze=Eo({checked:me,disabled:ne,form:c,name:m?void 0:ee,id:O?void 0:Y??void 0,required:b,ref:Re,style:ee?tN:qw,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(ze){if(ze.nativeEvent.defaultPrevented)return;if(g){ze.preventDefault();return}const Ke=ze.currentTarget.checked,Ye=qt(Oo,ze.nativeEvent);if(se?.(Ke,Ye),h?.(Ke,Ye),!Ye.isCanceled&&(ye(Ke),J&&be&&we&&!m&&!X)){const Rt=Ke?[...be,J]:be.filter(Ct=>Ct!==J);we(Rt,Ye)}},onFocus(){ke.current?.focus()}},S!==void 0?{value:(q?me&&S:S)||""}:vs,R,q?re.getValidationProps:re.getInputValidationProps),Oe=X?!!le:me,_e=X&&fe||d;y.useEffect(()=>{if(!W||!J)return;const ze=W.disabledStatesRef.current;return ze.set(J,ne),()=>{ze.delete(J)}},[W,ne,J]);const Ce=y.useMemo(()=>({...D,checked:Oe,disabled:ne,readOnly:g,required:b,indeterminate:_e}),[D,Oe,ne,g,b,_e]),Ee=Rht(Ce),$e=En("span",t,{state:Ce,ref:[ae,ke,n,q?.registerControlRef],props:[{id:O?Y??void 0:ie,role:"checkbox","aria-checked":fe?"mixed":me,"aria-readonly":g||void 0,"aria-required":b||void 0,"aria-labelledby":Qe,[rAn]:m?"":void 0,onFocus(){$(!0)},onBlur(){const ze=Te.current;ze&&(B(!0),$(!1),V==="onBlur"&&re.commit(q?be:ze.checked))},onKeyDown(ze){if(ze.key!=="Enter"||(ze.preventBaseUIHandler(),ze.defaultPrevented))return;const Ke=Te.current?.form??null,Ye=ze.currentTarget,Rt=ze.nativeEvent,Ct=ze.preventDefault,en=Rt.preventDefault;let bt=!1;ze.preventDefault=()=>{bt=!0,Ct.call(ze)},Rt.preventDefault=()=>{bt=!0,en.call(Rt)},en.call(Rt),Xs(Ye).queueMicrotask(()=>{ze.preventDefault=Ct,Rt.preventDefault=en,bt||ZIn(Ke)?.click()})},onClick(ze){if(g||ne)return;ze.preventDefault();const Ke=Te.current;Ke&&Ke.dispatchEvent(new(Xs(Ke)).PointerEvent("click",{bubbles:!0,shiftKey:ze.shiftKey,ctrlKey:ze.ctrlKey,altKey:ze.altKey,metaKey:ze.metaKey}))}},R,re.getValidationProps,C,he,ce],stateAttributesMapping:Ee});return o.jsxs(Dht.Provider,{value:Ce,children:[$e,!me&&!q&&ee&&!m&&w!==void 0&&o.jsx("input",{type:"hidden",form:c,name:ee,value:w}),o.jsx("input",{...Ze,suppressHydrationWarning:!0})]})}),aAn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,keepMounted:i=!1,...l}=t,c=nAn(),u=c.checked||c.indeterminate,{mounted:d,transitionStatus:f,setMounted:p}=bg(u),h=y.useRef(null),m={...c,transitionStatus:f};Vl({open:u,ref:h,onComplete(){u||p(!1)}});const v={...Rht(c),...ql,..._1},b=i||d,w=En("span",t,{ref:[n,h],state:m,stateAttributesMapping:v,props:l});return b?w:null}),Go=y.forwardRef(({className:e,checked:t,indeterminate:n,...r},s)=>{const a=t==="indeterminate";return o.jsx(sAn,{ref:s,checked:a?!1:t,indeterminate:n??a,"data-slot":"checkbox",className:K("peer flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[0.3125rem]","border border-neutral6/[0.06] bg-neutral6/[0.12] text-surface1 outline-hidden",is.all,"hover:border-neutral6/[0.12] hover:bg-neutral6/[0.16]","active:scale-95 active:border-neutral6/[0.18] active:bg-neutral6/[0.18]","focus-visible:border-neutral5/50 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-neutral5/55","data-[checked]:border-neutral6 data-[checked]:bg-neutral6 data-[checked]:text-surface1","data-[indeterminate]:border-neutral6 data-[indeterminate]:bg-neutral6 data-[indeterminate]:text-surface1","data-[checked]:hover:border-neutral5 data-[checked]:hover:bg-neutral5","data-[indeterminate]:hover:border-neutral5 data-[indeterminate]:hover:bg-neutral5","data-[checked]:active:border-neutral4 data-[checked]:active:bg-neutral4","data-[indeterminate]:active:border-neutral4 data-[indeterminate]:active:bg-neutral4","data-[disabled]:cursor-not-allowed data-[disabled]:border-neutral6/[0.38] data-[disabled]:bg-neutral6/[0.38] data-[disabled]:hover:border-neutral6/[0.38] data-[disabled]:hover:bg-neutral6/[0.38] data-[disabled]:active:scale-100","data-[disabled]:data-[checked]:border-neutral6/[0.38] data-[disabled]:data-[checked]:bg-neutral6/[0.38] data-[disabled]:data-[checked]:text-neutral6","data-[disabled]:data-[indeterminate]:border-neutral6/[0.38] data-[disabled]:data-[indeterminate]:bg-neutral6/[0.38] data-[disabled]:data-[indeterminate]:text-neutral6",e),...r,children:o.jsx(aAn,{keepMounted:!0,className:K("group/checkbox-indicator flex items-center justify-center text-current","opacity-0 scale-75 transition-[opacity,transform] duration-200 ease-out-custom","data-[checked]:opacity-100 data-[checked]:scale-100","data-[indeterminate]:opacity-100 data-[indeterminate]:scale-100","data-[starting-style]:opacity-0 data-[starting-style]:scale-75","data-[ending-style]:opacity-0 data-[ending-style]:scale-75"),children:o.jsx(iAn,{})})})});Go.displayName="Checkbox";function iAn(){return o.jsxs(o.Fragment,{children:[o.jsx(wx,{className:K("size-3 scale-95 stroke-[3.25] transition-[stroke-dashoffset,transform] duration-200 ease-out-custom","[stroke-dasharray:28] [stroke-dashoffset:28]","group-data-[checked]/checkbox-indicator:[stroke-dashoffset:0]","group-data-[checked]/checkbox-indicator:scale-100","group-data-[indeterminate]/checkbox-indicator:hidden")}),o.jsx(UTn,{className:K("hidden size-3 scale-95 stroke-[3.25] transition-transform duration-200 ease-out-custom","group-data-[indeterminate]/checkbox-indicator:block","group-data-[indeterminate]/checkbox-indicator:scale-100")})]})}function oAn(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:s}=e,[a,i]=Xd({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=bg(a,!0,!0),d=Mi(),[f,p]=y.useState(),h=f??d,m=mt(g=>{const v=!a,b=qt(rg,g.nativeEvent);r(v,b),!b.isCanceled&&i(v)});return y.useMemo(()=>({disabled:s,handleTrigger:m,mounted:l,open:a,panelId:h,setMounted:c,setOpen:i,setPanelIdState:p,transitionStatus:u}),[s,m,l,a,h,c,i,p,u])}const Lht=y.createContext(void 0);function Fht(){const e=y.useContext(Lht);if(e===void 0)throw new Error(yr(15));return e}let gxe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=sg.startingStyle]="startingStyle",e[e.endingStyle=sg.endingStyle]="endingStyle",e})({}),lAn=(function(e){return e.panelOpen="data-panel-open",e})({});const cAn={[gxe.open]:""},uAn={[gxe.closed]:""},dAn={open(e){return e?{[lAn.panelOpen]:""}:null}},fAn={open(e){return e?cAn:uAn}},zht={...fAn,...ql},pAn=y.forwardRef(function(t,n){const{render:r,className:s,defaultOpen:a=!1,disabled:i=!1,onOpenChange:l,open:c,style:u,...d}=t,f=mt(l),p=oAn({open:c,defaultOpen:a,onOpenChange:f,disabled:i}),h=y.useMemo(()=>({open:p.open,disabled:p.disabled,transitionStatus:p.transitionStatus}),[p.open,p.disabled,p.transitionStatus]),m=y.useMemo(()=>({...p,onOpenChange:f,state:h}),[p,f,h]),g=En("div",t,{state:h,ref:n,props:d,stateAttributesMapping:zht});return o.jsx(Lht.Provider,{value:m,children:g})}),hAn={...dAn,...ql},mAn=y.forwardRef(function(t,n){const{panelId:r,open:s,handleTrigger:a,state:i,disabled:l}=Fht(),{className:c,disabled:u=l,id:d,render:f,nativeButton:p=!0,style:h,...m}=t,{getButtonProps:g,buttonRef:v}=vd({disabled:u,focusableWhenDisabled:!0,native:p});return En("button",t,{state:i,ref:[n,v],props:[{"aria-controls":s?r:void 0,"aria-expanded":s,onClick:a},m,g],stateAttributesMapping:hAn})}),mA={height:void 0,width:void 0};function gAn(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:s,mounted:a,onOpenChange:i,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=y.useRef(null),p=y.useRef(null),[h,m]=y.useState(mA),g=y.useRef(mA),v=y.useRef(!1),b=y.useRef(l),w=y.useRef(!1),[S,O]=y.useState(!1),_=y.useRef(null),C=ku(t,f),j=Yi({mounted:a,open:l}),E=SU(f,!1,!1),N=!l&&!a,I=S?"idle":d,P=l&&(b.current||w.current),$=!l&&a&&p.current==="css-animation"&&h.height===void 0&&h.width===void 0?g.current:h,B=n&&N&&p.current!=="css-animation",D=mt((z,M=!0)=>{M&&(g.current=z),m(z)}),V=mt(()=>{_.current?.(),_.current=null}),H=mt(z=>{V(),_.current=()=>{_.current=null,z()}}),L=mt(()=>{l&&a&&p.current==="css-animation"&&(w.current=!0)});Tt(()=>{!S||d==="starting"||O(!1)},[S,d]),y.useEffect(()=>()=>{L(),V()},[L,V]),Tt(()=>{const z=f.current;if(!z)return;!l&&_.current&&V();const M=vAn(z,P);if(p.current=M,l&&d==="idle"&&b.current&&M==="css-animation"){g.current=wC(z);return}if(l&&d==="starting"){const R=v.current;if(v.current=!1,M==="none"){D(wC(z)),O(!0);return}if(M==="css-transition"){const q=yAn(z);if(D(wC(z)),!R)return q;const W=gA(z,"transition-duration","0s");return H(W),O(!0),q}if(M==="css-animation"){if(D(wC(z)),!R){gA(z,"animation-name","none")();return}const q=gA(z,"animation-name","none"),W=gA(z,"animation-duration","0s");q(),H(W),O(!0);return}}if(!l&&a&&(d==="idle"||d==="starting")){if(M==="none"){D(mA,!1),c(!1);return}M==="css-animation"&&(b.current=!1,w.current=!1),D(wC(z));return}if(d!=="ending")return;if(M==="none"){c(!1);return}const G=wC(z);if(!((G.height??0)>0||(G.width??0)>0)){c(!1);return}D(G),M==="css-animation"&&gA(z,"animation-name","none")()},[a,l,V,D,c,H,P,d]),Vl({enabled:l&&a&&I==="idle",open:!0,ref:f,onComplete(){l&&D(mA,!1)}}),y.useEffect(()=>{if(l||!a||I!=="ending"||!f.current)return;const M=new AbortController;let G=-1;function U(){j.current.open||(c(!1),D(mA,!1))}return G=Pd.request(()=>{M.signal.aborted||E(U,M.signal)}),()=>{Pd.cancel(G),M.abort()}},[j,a,l,I,E,D,c]),Tt(()=>{const z=f.current;!z||!n||!N||z.setAttribute("hidden","until-found")},[N,n]),y.useEffect(function(){const M=f.current;if(!M)return;function G(U){v.current=!0,u(!0),i(!0,qt(Oo,U))}return Br(M,"beforematch",G)},[i,u]);const F=s||n||a||l;return{height:$.height,props:{...B?{[gxe.startingStyle]:""}:void 0,hidden:N,id:r},ref:C,shouldPreventOpenAnimation:P,shouldRender:F,transitionStatus:I,width:$.width}}function wC(e){return{height:e.scrollHeight,width:e.scrollWidth}}function vAn(e,t=!1){const n=Xs(e).getComputedStyle(e),r=(n.animationName.split(",").map(a=>a.trim()).some(a=>a!==""&&a!=="none")||t)&&n4e(n.animationDuration),s=n4e(n.transitionDuration);return r&&s||s?"css-transition":r?"css-animation":"none"}function n4e(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function gA(e,t,n){const r=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,s)}}function yAn(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(s=>{e.style.setProperty(s,"initial","important")});function n(){Object.entries(t).forEach(([s,a])=>{if(a===""){e.style.removeProperty(s);return}e.style.setProperty(s,a)})}const r=Pd.request(n);return()=>{Pd.cancel(r),n()}}let r4e=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const bAn=y.forwardRef(function(t,n){const{className:r,hiddenUntilFound:s,keepMounted:a,render:i,id:l,style:c,...u}=t,{mounted:d,onOpenChange:f,open:p,panelId:h,setMounted:m,setPanelIdState:g,setOpen:v,state:b,transitionStatus:w}=Fht(),S=s??!1,O=a??!1;Tt(()=>{if(l)return g(l),()=>{g(void 0)}},[l,g]);const{height:_,props:C,ref:j,shouldPreventOpenAnimation:E,shouldRender:N,transitionStatus:I,width:P}=gAn({externalRef:n,hiddenUntilFound:S,id:h,keepMounted:O,mounted:d,onOpenChange:f,open:p,setMounted:m,setOpen:v,transitionStatus:w}),$={...b,transitionStatus:I},B=Hlt(c,$),D=En("div",{...t,style:void 0},{state:$,ref:j,props:[C,{style:{[r4e.collapsiblePanelHeight]:_===void 0?"auto":`${_}px`,[r4e.collapsiblePanelWidth]:P===void 0?"auto":`${P}px`}},u,B?{style:B}:void 0,E?{style:{animationName:"none"}}:void 0],stateAttributesMapping:zht});return N?D:null}),lg=pAn,zh=De.forwardRef(({className:e,asChild:t,children:n,...r},s)=>{const a=t&&De.isValidElement(n)?{render:n}:{};return o.jsx(mAn,{ref:s,"data-slot":"collapsible-trigger",className:K("-outline-offset-2",is.colors,r_.visible,"hover:text-neutral5","[&>svg]:transition-transform [&>svg]:duration-normal [&>svg]:ease-out-custom","[&[data-panel-open]>svg]:rotate-90",e),...a,...r,children:t?void 0:n})});zh.displayName="CollapsibleTrigger";const Bh=De.forwardRef(({className:e,children:t,...n},r)=>o.jsx(bAn,{ref:r,"data-slot":"collapsible-content",className:K("overflow-hidden","h-[var(--collapsible-panel-height)] transition-[height] duration-normal ease-out-custom","data-[starting-style]:h-0 data-[ending-style]:h-0"),...n,children:o.jsx("div",{className:e,children:t})}));Bh.displayName="CollapsibleContent";const Bht=y.createContext(void 0),Uht=y.createContext(void 0),qht=y.createContext(void 0),Vht=y.createContext("");function my(){const e=y.useContext(Bht);if(!e)throw new Error(yr(22));return e}function tq(){const e=y.useContext(Uht);if(!e)throw new Error(yr(23));return e}function C1(){const e=y.useContext(qht);if(!e)throw new Error(yr(24));return e}function Hht(){return y.useContext(Vht)}const Zht=(e,t)=>Object.is(e,t);function Wv(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Wht(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Wv(t,r,n))}function bw(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Wv(r,t,n))}function Qht(e,t,n){return e.filter(r=>!Wv(t,r,n))}function oz(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function vxe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Ght(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(vxe(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function ou(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return oz(e)}function Dm(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?oz(e.value):oz(e)}function yxe(e,t,n){function r(){return ou(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const s=t,a=vxe(s)?s.flatMap(i=>i.items):s;if(e==null||typeof e!="object"){const i=a.find(l=>l.value===e);return i&&i.label!=null?i.label:r()}if("value"in e){const i=a.find(l=>l&&l.value===e.value);if(i&&i.label!=null)return i.label}}return r()}function Yht(e,t,n){return e.reduce((r,s,a)=>(a>0&&r.push(", "),r.push(o.jsx(y.Fragment,{children:yxe(s,t,n)},a)),r),[])}const on={id:lt(e=>e.id),labelId:lt(e=>e.labelId),items:lt(e=>e.items),selectedValue:lt(e=>e.selectedValue),hasSelectionChips:lt(e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:lt(e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:lt((e,t)=>t?Ght(e.items):!1),open:lt(e=>e.open),mounted:lt(e=>e.mounted),forceMounted:lt(e=>e.forceMounted),inline:lt(e=>e.inline),activeIndex:lt(e=>e.activeIndex),selectedIndex:lt(e=>e.selectedIndex),isActive:lt((e,t)=>e.activeIndex===t),isSelected:lt((e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(s=>Wv(t,s,n)):Wv(t,r,n)}),transitionStatus:lt(e=>e.transitionStatus),popupProps:lt(e=>e.popupProps),inputProps:lt(e=>e.inputProps),triggerProps:lt(e=>e.triggerProps),itemProps:lt(e=>e.itemProps),positionerElement:lt(e=>e.positionerElement),listElement:lt(e=>e.listElement),triggerElement:lt(e=>e.triggerElement),inputElement:lt(e=>e.inputElement),inputGroupElement:lt(e=>e.inputGroupElement),popupSide:lt(e=>e.popupSide),openMethod:lt(e=>e.openMethod),inputInsidePopup:lt(e=>e.inputInsidePopup),inputOwnsFormValue:lt(e=>e.inputOwnsFormValue),selectionMode:lt(e=>e.selectionMode),name:lt(e=>e.name),form:lt(e=>e.form),disabled:lt(e=>e.disabled),readOnly:lt(e=>e.readOnly),required:lt(e=>e.required),grid:lt(e=>e.grid),virtualized:lt(e=>e.virtualized),itemToStringLabel:lt(e=>e.itemToStringLabel),isItemEqualToValue:lt(e=>e.isItemEqualToValue),modal:lt(e=>e.modal),autoHighlight:lt(e=>e.autoHighlight),submitOnItemClick:lt(e=>e.submitOnItemClick)};function h_(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,registerControlId:a}=kx(),i=Mi(t),l=n?s:void 0,c=cc(()=>Symbol("labelable-control")),u=y.useRef(!1),d=y.useRef(t!=null),f=mt(()=>{!u.current||a===ga||(u.current=!1,a(c.current,void 0))});return Tt(()=>{if(a===ga)return;let p;if(n){const h=r?.current;wr(h)&&h.closest("label")!=null?p=t??null:p=l??i}else if(t!=null)d.current=!0,p=t;else if(d.current)p=i;else{f();return}if(p===void 0){f();return}u.current=!0,a(c.current,p)},[t,r,l,a,n,i,c,f]),y.useEffect(()=>f,[f]),s??i}function xAn(e,t){return(n,r)=>{if(n==null)return!1;const s=ou(n,t);return e.contains(s,r)}}function wAn(e,t,n){return(r,s)=>{if(r==null)return!1;if(!s)return!0;const a=ou(r,t),i=n!=null?ou(n,t):"";return i&&e.contains(i,s)&&i.length===s.length?!0:e.contains(a,s)}}const s4e=new Map;function SAn(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${Xht(e.locale)}|${JSON.stringify(t)}`,r=s4e.get(n);if(r)return r;const s=new Intl.Collator(e.locale,t),a={contains(i,l,c){if(!l)return!0;const u=ou(i,c);for(let d=0;d<=u.length-l.length;d+=1)if(s.compare(u.slice(d,d+l.length),l)===0)return!0;return!1},startsWith(i,l,c){if(!l)return!0;const u=ou(i,c);return s.compare(u.slice(0,l.length),l)===0},endsWith(i,l,c){if(!l)return!0;const u=ou(i,c),d=l.length;return u.length>=d&&s.compare(u.slice(u.length-d),l)===0}};return s4e.set(n,a),a}function Xht(e){return Array.isArray(e)?e.map(t=>Xht(t)).join(","):e==null?"":String(e)}const kAn=SAn,Kht=Symbol("none"),vS={value:Kht,index:-1};function OAn(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:s,onSelectedValueChange:a,defaultInputValue:i,inputValue:l,open:c,defaultOpen:u=!1,selectionMode:d="none",onItemHighlighted:f,name:p,form:h,disabled:m=!1,readOnly:g=!1,required:v=!1,inputRef:b,grid:w=!1,items:S,filteredItems:O,filter:_,openOnInputClick:C=!0,autoHighlight:j=!1,keepHighlight:E=!1,highlightItemOnHover:N=!0,loopFocus:I=!0,itemToStringLabel:P,itemToStringValue:$,isItemEqualToValue:B=Zht,virtualized:D=!1,inline:V=!1,fillInputOnItemPress:H=!0,modal:L=!1,limit:F=-1,autoComplete:z="list",formAutoComplete:M,locale:G,submitOnItemClick:U=!1}=e,{clearErrors:R}=yN(),{setDirty:q,validityData:W,shouldValidateOnChange:X,setFilled:ne,name:ee,disabled:J,setTouched:ie,setFocused:ue,validationMode:Y,validation:te}=Jh(),le=fy(),fe=h_({id:t}),se=kAn({locale:G}),[he,be]=y.useState(!1),[we,Ie]=y.useState(null),ke=y.useRef([]),je=y.useRef([]),Fe=y.useRef(null),ce=y.useRef(null),ae=y.useRef(null),re=y.useRef(null),me=y.useRef(null),ye=y.useRef(!0),Te=y.useRef(!1),Re=y.useRef(null),Qe=y.useRef(null),Ze=y.useRef(null),Oe=y.useRef(vS),_e=y.useRef(null),Ce=y.useRef([]),Ee=y.useRef([]),$e=J||m,ze=ee??p,Ke=d==="multiple",Ye=d==="single",Rt=l!==void 0||i!==void 0,Ct=S!==void 0,en=O!==void 0;let bt;j==="always"?bt="always":bt=j?"input-change":!1;const[It,sn]=Xd({controlled:s,default:Ke?r??hh:r,name:"Combobox",state:"selectedValue"}),We=y.useMemo(()=>_===null?()=>!0:_!==void 0?_:Ye&&!he?wAn(se,P,It):xAn(se,P),[_,Ye,It,he,se,P]),at=cc(()=>Rt?i??"":Ye?ou(It,P):"").current,[ct,an]=Xd({controlled:l,default:at,name:"Combobox",state:"inputValue"}),[Xt,On]=Xd({controlled:c,default:u,name:"Combobox",state:"open"}),Ne=vxe(S),Le=we??(ct===""?"":String(ct).trim()),Me=Ye?ou(It,P):"",Xe=Ye&&!he&&Le!==""&&Me!==""&&Me.length===Le.length&&se.contains(Me,Le),nt=Xe?"":Le,Mt=Ct&&en&&Xe,kt=y.useMemo(()=>S?Ne?S.flatMap(un=>un.items):S:hh,[S,Ne]),Lt=y.useMemo(()=>{if(O&&!Mt)return O;if(!S)return hh;if(Ne){const Qn=S,_s=[];let ka=0;for(const no of Qn){if(F>-1&&ka>=F)break;const za=nt===""?no.items:no.items.filter(jf=>We(jf,nt,P));if(za.length===0)continue;const fm=F>-1?F-ka:1/0,wd=za.slice(0,fm);if(wd.length>0){const jf={...no,items:wd};_s.push(jf),ka+=wd.length}}return _s}if(nt==="")return F>-1?kt.slice(0,F):kt;const un=[];for(const Qn of kt){if(F>-1&&un.length>=F)break;We(Qn,nt,P)&&un.push(Qn)}return un},[O,Mt,S,Ne,nt,F,We,P,kt]),At=y.useMemo(()=>Ne?Lt.flatMap(Qn=>Qn.items):Lt,[Lt,Ne]),Et=cc(()=>new Rye({id:fe,labelId:void 0,selectedValue:It,open:Xt,filter:We,query:Le,items:S,selectionMode:d,listRef:ke,labelsRef:je,popupRef:Fe,emptyRef:me,inputRef:ce,startDismissRef:ae,endDismissRef:re,keyboardActiveRef:ye,chipsContainerRef:Re,clearRef:Qe,valuesRef:Ce,allValuesRef:Ee,selectionEventRef:Ze,name:ze,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Ne,virtualized:D,openOnInputClick:C,itemToStringLabel:P,isItemEqualToValue:B,modal:L,autoHighlight:bt,submitOnItemClick:U,hasInputValue:Rt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:V,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:vs,positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d==="none",onOpenChangeComplete:n||ga,setOpen:ga,setInputValue:ga,setSelectedValue:ga,setIndices:ga,onItemHighlighted:ga,handleSelection:ga,forceMount:ga,requestSubmit:ga})).current,yn=d==="none"?ct:It,nr=y.useMemo(()=>d==="none"?yn:Array.isArray(It)?It.map(un=>Dm(un,$)):Dm(It,$),[yn,$,d,It]),qn=mt(f),Or=mt(n),pr=ht(Et,on.activeIndex),bs=ht(Et,on.selectedIndex),Mr=ht(Et,on.positionerElement),ur=ht(Et,on.listElement),qs=ht(Et,on.triggerElement),fa=ht(Et,on.inputElement),wa=ht(Et,on.inputGroupElement),Na=ht(Et,on.inline),Po=ht(Et,on.inputInsidePopup),dl=ht(Et,on.inputOwnsFormValue),el=Yi(qs),{mounted:lm,setMounted:Pu,transitionStatus:Ef}=bg(Xt),{openMethod:cm,triggerProps:$u}=pxe(Xt),Hr=mt(()=>nr);vN(Po?el:ce,fe,yn,Hr);const Sa=mt(()=>{S?je.current=At.map(un=>ou(un,P)):Et.set("forceMounted",!0)}),hi=y.useRef(It);Tt(()=>{It!==hi.current&&Sa()},[Sa,It]);const Ti=mt(un=>{Et.update(un);const Qn=un.type||"none";if(un.activeIndex!==void 0)if(un.activeIndex===null)Oe.current!==vS&&(Oe.current=vS,qn(void 0,XS(Qn,void 0,{index:-1})));else{const _s=Ce.current[un.activeIndex];Oe.current={value:_s,index:un.activeIndex},qn(_s,XS(Qn,void 0,{index:un.activeIndex}))}}),jl=mt((un,Qn)=>{if(Te.current=Qn.reason===hb,e.onInputValueChange?.(un,Qn),!Qn.isCanceled){if(Qn.reason===ck){const _s=Qn.event,ka=_s.inputType;if(_s.type==="compositionend"||ka!=null&&ka!==""&&ka!=="insertReplacementText"){const za=un.trim()!=="";za&&be(!0),_e.current={hasQuery:za},za&&bt&&Et.state.activeIndex==null&&Et.set("activeIndex",0)}}an(un)}}),Mu=mt((un,Qn)=>{if(Xt!==un&&(Qn.reason==="escape-key"&&Ct&&At.length===0&&!Et.state.emptyRef.current&&Qn.allowPropagation(),e.onOpenChange?.(un,Qn),!Qn.isCanceled&&(un&&Ke&&Po&&!Na&&we!==null&&(be(!1),Ie(null),ct!==""&&jl("",qt(hb,Qn.event))),!un&&he&&(Ye?(Na||Ie(Le),Le===""&&be(!1)):Ke&&(Na||Ie(Le),Po&&Ti({activeIndex:null}),(!Po||Na)&&jl("",qt(hb,Qn.event)))),On(un),!un&&Po&&(Qn.reason===Xb||Qn.reason===QM)&&(ie(!0),ue(!1),Y==="onBlur")))){const _s=d==="none"?ct:It;te.commit(_s)}}),Vs=mt((un,Qn)=>{if(a?.(un,Qn),Qn.isCanceled)return;sn(un),(d==="none"&&Fe.current&&H||Ye&&!Et.state.inputInsidePopup)&&jl(ou(un,P),qt(Qn.reason,Qn.event)),Ye&&un!=null&&Qn.reason!==ck&&he&&!Na&&Ie(Le)}),Kc=mt((un,Qn)=>{let _s=Qn;if(_s===void 0){if(pr===null)return;_s=Ce.current[pr]}const ka=Si(un),no=Ze.current??un;Ze.current=null;const za=qt(vw,no),fm=ka?.closest("a")?.getAttribute("href");if(fm){fm.startsWith("#")&&Mu(!1,za);return}if(Ke){const wd=Array.isArray(It)?It:[],nI=Wht(wd,_s,Et.state.isItemEqualToValue)?Qht(wd,_s,Et.state.isItemEqualToValue):[...wd,_s];if(Vs(nI,za),!(ce.current?ce.current.value.trim()!=="":!1))return;Et.state.inputInsidePopup?jl("",qt(hb,za.event)):Mu(!1,za)}else Vs(_s,za),Mu(!1,za)}),Ig=mt(()=>{if(!Et.state.submitOnItemClick)return;const un=te.inputRef.current?.form??Et.state.inputElement?.form;un&&typeof un.requestSubmit=="function"&&un.requestSubmit()}),$o=mt(()=>{if(Pu(!1),Or?.(!1),be(!1),Ie(null),Ti(d==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ke&&ce.current&&ce.current.value!==""&&!Te.current&&jl("",qt(hb)),Ye)if(Et.state.inputInsidePopup)ce.current&&ce.current.value!==""&&jl("",qt(hb));else{const un=ou(It,P);ce.current&&ce.current.value!==un&&jl(un,qt(un===""?hb:Oo))}}),F1=y.useMemo(()=>Na&&Mr?{current:Mr.closest('[role="dialog"]')}:Fe,[Na,Mr]);Vl({enabled:!e.actionsRef,open:Xt,ref:F1,onComplete(){Xt||$o()}}),y.useImperativeHandle(e.actionsRef,()=>({unmount:$o}),[$o]),Tt(function(){if(Xt||d==="none")return;const Qn=S?kt:Ee.current;if(Ke){const _s=Array.isArray(It)?It:[],ka=_s[_s.length-1],no=bw(Qn,ka,B);Ti({selectedIndex:no===-1?null:no})}else{const _s=bw(Qn,It,B);Ti({selectedIndex:_s===-1?null:_s})}},[Xt,It,S,d,kt,Ke,B,Ti]),Tt(()=>{S&&(Ce.current=At,ke.current.length=At.length)},[S,At]),Tt(()=>{const un=_e.current;if(un&&(un.hasQuery?bt&&Et.set("activeIndex",0):bt==="always"&&Et.set("activeIndex",0),_e.current=null),!Xt&&!Na)return;const _s=Ct||en?At:Ce.current,ka=Et.state.activeIndex;if(ka==null){if(bt==="always"&&_s.length>0){Et.set("activeIndex",0);return}Oe.current!==vS&&(Oe.current=vS,Et.state.onItemHighlighted(void 0,XS(Oo,void 0,{index:-1})));return}if(ka>=_s.length){Oe.current!==vS&&(Oe.current=vS,Et.state.onItemHighlighted(void 0,XS(Oo,void 0,{index:-1}))),Et.set("activeIndex",null);return}const no=_s[ka],za=Oe.current.value,fm=za!==Kht&&Wv(no,za,Et.state.isItemEqualToValue);(Oe.current.index!==ka||!fm)&&(Oe.current={value:no,index:ka},Et.state.onItemHighlighted(no,XS(Oo,void 0,{index:ka})))},[pr,bt,en,Ct,At,Na,Xt,Et]),Tt(()=>{if(d==="none"){ne(String(ct)!=="");return}ne(Ke?Array.isArray(It)&&It.length>0:It!=null)},[ne,d,ct,It,Ke]),y.useEffect(()=>{Ct&&bt&&At.length===0&&Ti({activeIndex:null})},[Ct,bt,At.length,Ti]),wv(Le,()=>{!Xt||Le===""||Le===String(at)||be(!0)}),wv(It,()=>{if(d!=="none"&&(R(ze),q(It!==W.initialValue),X()?te.commit(It):te.commit(It,!0),Ye&&!Rt&&!Po)){const un=ou(It,P);ct!==un&&jl(un,qt(Oo))}}),wv(ct,()=>{d==="none"&&(R(ze),q(ct!==W.initialValue),X()?te.commit(ct):te.commit(ct,!0))}),wv(S,()=>{if(!Ye||Rt||Po||he)return;const un=ou(It,P);ct!==un&&jl(un,qt(Oo))});const jy=$ye({open:Na?!0:Xt,onOpenChange:Mu,elements:{reference:Po?qs:fa,floating:Mr}});let Ag,Rg;Na||(Ag=w?"grid":"listbox",Rg=Xt?"true":"false");const z1=y.useMemo(()=>{const un=fa?.tagName==="INPUT",Qn=fa==null||un,_s=Qn||Xt,ka=Qn?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return _s&&(ka.role="combobox",ka["aria-expanded"]=Rg,ka["aria-haspopup"]=Ag,ka["aria-controls"]=Xt?ur?.id:void 0,ka["aria-autocomplete"]=z),{reference:ka,floating:{role:"presentation"}}},[fa,Xt,Rg,Ag,ur?.id,z]),eI=o_(jy,{enabled:!g&&!$e&&C,event:"mousedown-only",toggle:!1,touchOpenDelay:Po?0:100,reason:zgn}),um=l_(jy,{enabled:!g&&!$e&&!Na,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Na?!0:void 0,outsidePress(un){const Qn=Si(un);return!dn(qs,Qn)&&!dn(Qe.current,Qn)&&!dn(Re.current,Qn)&&!dn(wa,Qn)}}),Wx=Fye(jy,{enabled:!g&&!$e,id:fe,listRef:ke,activeIndex:pr,selectedIndex:bs,virtual:!0,loopFocus:I,allowEscape:I&&!bt,focusItemOnOpen:he||d==="none"&&!bt?!1:"auto",focusItemOnHover:N,resetOnPointerLeave:!E,cols:w?2:1,orientation:w?"horizontal":void 0,rtl:le==="rtl",disabledIndices:hh,onNavigate(un,Qn){!Qn&&!Xt||Ef==="ending"||Ti(Qn?{activeIndex:un,type:ye.current?"keyboard":"pointer"}:{activeIndex:un})}}),D_=y.useMemo(()=>Eo(Wx.reference,um.reference,eI.reference,z1.reference),[Wx.reference,um.reference,eI.reference,z1.reference]),L_=y.useMemo(()=>Eo(dy,Wx.floating,um.floating,z1.floating),[Wx.floating,um.floating,z1.floating]),B1=y.useMemo(()=>{const un=Wx.item;return un?{...un,onFocus:void 0}:vs},[Wx.item]);s_(()=>{Et.update({inline:V,popupProps:L_,inputProps:D_,triggerProps:$u,itemProps:B1,setOpen:Mu,setInputValue:jl,setSelectedValue:Vs,setIndices:Ti,onItemHighlighted:qn,handleSelection:Kc,forceMount:Sa,requestSubmit:Ig})}),Tt(()=>{Et.update({id:fe,selectedValue:It,open:Xt,mounted:lm,transitionStatus:Ef,items:S,inline:V,popupProps:L_,inputProps:D_,triggerProps:$u,openMethod:cm,itemProps:B1,selectionMode:d,name:ze,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Ne,virtualized:D,onOpenChangeComplete:Or,openOnInputClick:C,itemToStringLabel:P,modal:L,autoHighlight:bt,isItemEqualToValue:B,submitOnItemClick:U,hasInputValue:Rt,requestSubmit:Ig,inputOwnsFormValue:d==="none"&&(V||!Et.state.inputInsidePopup)})},[Et,fe,It,Xt,lm,Ef,S,L_,D_,B1,cm,$u,d,ze,$e,g,v,te,w,Ne,D,Or,C,P,L,B,U,Rt,V,Ig,bt,h]);const UZ=ku(b,te.inputRef),qZ=y.useMemo(()=>({query:Le,hasItems:Ct,filteredItems:Lt,flatFilteredItems:At}),[Le,Ct,Lt,At]),F_=y.useMemo(()=>Array.isArray(yn)?"":Dm(yn,$),[yn,$]),dm=Ke&&Array.isArray(It)&&It.length>0,U1=Ke||d==="none"&&dl?void 0:ze,tI=y.useMemo(()=>!Ke||!Array.isArray(It)||!ze?null:It.map(un=>{const Qn=Dm(un,$);return o.jsx("input",{type:"hidden",form:h,name:ze,value:Qn},Qn)}),[Ke,It,h,ze,$]),Qx=o.jsxs(y.Fragment,{children:[e.children,o.jsx("input",{...te.getInputValidationProps({onFocus(){if(Po){qs?.focus();return}(ce.current||qs)?.focus()},onChange(un){if(un.nativeEvent.defaultPrevented||$e||g){un.preventBaseUIHandler?.();return}const Qn=un.currentTarget.value,_s=qt(Oo,un.nativeEvent);function ka(){if(Ke)return;if(d==="none"){q(Qn!==W.initialValue),jl(Qn,_s),X()&&te.commit(Qn);return}const no=Ce.current.find(za=>Dm(za,$).toLowerCase()===Qn.toLowerCase()||ou(za,P).toLowerCase()===Qn.toLowerCase());no!=null&&(q(no!==W.initialValue),Vs?.(no,_s),X()&&te.commit(no))}S?ka():(Sa(),queueMicrotask(ka))}}),id:fe&&U1==null?`${fe}-hidden-input`:void 0,form:h,name:U1,autoComplete:M,disabled:$e,required:v&&!dm,readOnly:g,value:F_,ref:UZ,style:U1?tN:qw,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),tI]});return o.jsx(Bht.Provider,{value:Et,children:o.jsx(Uht.Provider,{value:jy,children:o.jsx(qht.Provider,{value:qZ,children:o.jsx(Vht.Provider,{value:ct,children:Qx})})})})}function Jht(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:s,autoComplete:a,...i}=e;return o.jsx(OAn,{...i,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:s,formAutoComplete:a})}function _An(e){return e==null?void 0:`${e}-label`}function nq(e,t){return e??t}function CAn(e){const{children:t,placeholder:n}=e,r=my(),s=ht(r,on.itemToStringLabel),a=ht(r,on.selectedValue),i=ht(r,on.items),l=ht(r,on.selectionMode)==="multiple",c=ht(r,on.hasSelectedValue),u=!c&&n!=null&&t==null,d=ht(r,on.hasNullItemLabel,u);let f=null;return typeof t=="function"?f=t(a):t!=null?f=t:!c&&n!=null&&!d?f=n:l&&Array.isArray(a)?f=Yht(a,i,s):f=yxe(a,i,s),o.jsx(y.Fragment,{children:f})}const emt={...xP,..._1,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},EAn=y.createContext(void 0);function jAn(){return y.useContext(EAn)}const tmt=y.createContext(void 0);function bxe(e){const t=y.useContext(tmt);if(t===void 0&&!e)throw new Error(yr(21));return t}const nmt=y.forwardRef(function(t,n){const r=my(),{buttonRef:s,getButtonProps:a}=vd({native:!1}),i=ku(n,s);function l(u){r.state.setOpen(!1,qt(yye,u.nativeEvent,u.currentTarget))}const c=a({onClick:l});return o.jsx("span",{ref:i,...c,"aria-label":"Dismiss",tabIndex:void 0,style:tN})}),rmt=y.forwardRef(function(t,n){const{render:r,className:s,disabled:a=!1,id:i,style:l,...c}=t,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:h,validation:m}=Jh(),{labelId:g}=kx(),v=jAn(),w=!!bxe(!0),S=my(),{filteredItems:O}=C1(),_=Hht(),C=fy(),j=ht(S,on.required),E=ht(S,on.disabled),N=ht(S,on.readOnly),I=ht(S,on.name),P=ht(S,on.form),$=ht(S,on.selectionMode),B=ht(S,on.autoHighlight),D=ht(S,on.inputProps),V=ht(S,on.triggerProps),H=ht(S,on.open),L=ht(S,on.mounted),F=ht(S,on.selectedValue),z=ht(S,on.popupSide),M=ht(S,on.positionerElement),G=ht(S,on.id),U=ht(S,on.inline),R=ht(S,on.modal),q=!!B,W=L&&M?z:null,X=d||E||a,ne=O.length===0,ee=w||U,J=!ee||R,ie=Mi(i??(ee?void 0:G)),ue=nq(g,void 0),Y=w?OE:u,[te,le]=y.useState(null),fe=y.useRef(!1),se=y.useRef(null),he=y.useRef(!1),be=$==="none"&&!w,we=mt(ae=>{const re=w||S.state.inline;re&&!S.state.hasInputValue&&S.state.setInputValue("",qt(Oo)),S.update({inputElement:ae,inputInsidePopup:re,inputOwnsFormValue:be})}),Ie=w||!m?c:m.getValidationProps(c),ke={...Y,open:H,disabled:X,readOnly:N,popupSide:W,listEmpty:ne};function je(ae){if(!v)return;let re;const{highlightedChipIndex:me}=v,ye=v.chipsRef.current.length,Te=C==="rtl",Re=Te?"ArrowRight":"ArrowLeft",Qe=Te?"ArrowLeft":"ArrowRight";if(me!==void 0){if(ae.key===Re)ae.preventDefault(),me>0?re=me-1:re=void 0;else if(ae.key===Qe)ae.preventDefault(),me<ye-1?re=me+1:re=void 0;else if(ae.key==="Backspace"||ae.key==="Delete"){ae.preventDefault();const Ze=me>=F.length-1?F.length-2:me;re=Ze>=0?Ze:void 0,S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return re}return ae.key===Re&&(ae.currentTarget.selectionStart??0)===0&&F.length>0?(ae.preventDefault(),re=ye>0?ye-1:void 0):ae.key==="Backspace"&&ae.currentTarget.value===""&&F.length>0&&(S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),ae.preventDefault()),re}const Fe=En("input",t,{state:ke,ref:[n,S.state.inputRef,we],props:[D,V,{type:"text",value:t.value??te??_,"aria-readonly":N||void 0,"aria-required":j||void 0,"aria-labelledby":ue,disabled:X,readOnly:N,required:$==="none"?j:void 0,form:P,...be&&I&&{name:I},id:ie,onFocus(){if(p(!0),!U||!he.current)return;he.current=!1;const ae=se.current;ae==null||!Object.hasOwn(S.state.valuesRef.current,ae)||S.state.setIndices({activeIndex:ae})},onBlur(){f(!0),p(!1);const ae=S.state.activeIndex;if(U&&ae!==null&&B!=="always"&&(se.current=ae,he.current=!0,S.state.setIndices({activeIndex:null})),h==="onBlur"){const re=$==="none"?_:F;m.commit(re)}},onCompositionStart(ae){vP||(fe.current=!0,le(ae.currentTarget.value))},onCompositionEnd(ae){fe.current=!1;const re=ae.currentTarget.value;le(null),S.state.setInputValue(re,qt(ck,ae.nativeEvent))},onChange(ae){const re=ae.nativeEvent.inputType,me=!re||re==="insertReplacementText",ye=fe.current||!me;if(fe.current){const Ze=ae.currentTarget.value;le(Ze),Ze===""&&!S.state.openOnInputClick&&!S.state.inputInsidePopup&&S.state.setOpen(!1,qt(hb,ae.nativeEvent));const Oe=Ze.trim(),_e=q&&Oe!=="";!N&&!X&&Oe&&ye&&(S.state.setOpen(!0,qt(ck,ae.nativeEvent)),q||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),H&&S.state.activeIndex!==null&&!_e&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"});return}S.state.setInputValue(ae.currentTarget.value,qt(ck,ae.nativeEvent));const Te=ae.currentTarget.value==="",Re=qt(hb,ae.nativeEvent);Te&&!S.state.inputInsidePopup&&($==="single"&&S.state.setSelectedValue(null,Re),S.state.openOnInputClick||S.state.setOpen(!1,Re));const Qe=ae.currentTarget.value.trim();!N&&!X&&Qe&&ye&&(S.state.setOpen(!0,qt(ck,ae.nativeEvent)),q||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),H&&S.state.activeIndex!==null&&!q&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(ae){if(X||N||ae.ctrlKey||ae.shiftKey||ae.altKey||ae.metaKey)return;S.state.keyboardActiveRef.current=!0;const re=ae.currentTarget,me=re.scrollWidth-re.clientWidth,ye=C==="rtl";if(ae.key==="Home"){Jl(ae);const Qe=E$e&&ye?re.value.length:0;re.setSelectionRange(Qe,Qe),re.scrollLeft=0;return}if(ae.key==="End"){Jl(ae);const Qe=E$e&&ye?0:re.value.length;re.setSelectionRange(Qe,Qe),re.scrollLeft=ye?-me:me;return}if(!L&&ae.key==="Escape"){const Qe=$==="multiple"&&Array.isArray(F)?F.length===0:F===null,Ze=qt(i_,ae.nativeEvent),Oe=$==="multiple"?[]:null;S.state.setInputValue("",Ze),S.state.setSelectedValue(Oe,Ze),!Qe&&!S.state.inline&&!Ze.isPropagationAllowed&&ae.stopPropagation();return}if(v&&ae.key==="Backspace"&&re.value===""&&v.highlightedChipIndex===void 0&&Array.isArray(F)&&F.length>0){const Qe=v.chipsRef.current.length,Ze=Qe>0?Qe-1:F.length-1,Oe=F.filter((_e,Ce)=>Ce!==Ze);S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"}),S.state.setSelectedValue(Oe,qt(Oo,ae.nativeEvent));return}const Te=v?.highlightedChipIndex!==void 0,Re=je(ae);if(v?.setHighlightedChipIndex(Re),Re!==void 0?v?.chipsRef.current[Re]?.focus():Te&&S.state.inputRef.current?.focus(),ae.which!==229&&ae.key==="Enter"&&H){const Qe=S.state.activeIndex,Ze=ae.nativeEvent;if(Qe===null){if(U)return;S.state.setOpen(!1,qt(Oo,Ze));return}Jl(ae);const Oe=S.state.listRef.current[Qe];Oe&&(S.state.selectionEventRef.current=Ze,Oe.click(),S.state.selectionEventRef.current=null)}},onPointerMove(){S.state.keyboardActiveRef.current=!1},onPointerDown(){S.state.keyboardActiveRef.current=!1}},Ie],stateAttributesMapping:emt}),ce=w?o.jsx($ht.Provider,{value:Pht,children:Fe}):Fe;return o.jsxs(y.Fragment,{children:[H&&J&&o.jsx(nmt,{ref:S.state.startDismissRef}),ce]})});function xxe(e){const t=e.getBoundingClientRect(),n=Xs(e),r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const i=parseFloat(r.width)||0,l=parseFloat(r.height)||0,c=parseFloat(s.width)||0,u=parseFloat(s.height)||0,d=Math.max(t.width,i,c),f=Math.max(t.height,l,u),p=d-t.width,h=f-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-h/2,bottom:t.bottom+h/2}}const OL=2,smt=y.forwardRef(function(t,n){const{render:r,className:s,nativeButton:a=!0,disabled:i=!1,id:l,style:c,...u}=t,{state:d,disabled:f,setTouched:p,setFocused:h,validationMode:m,validation:g}=Jh(),{labelId:v}=kx(),b=my(),{filteredItems:w}=C1(),S=ht(b,on.selectionMode),O=ht(b,on.disabled),_=ht(b,on.readOnly),C=ht(b,on.required),j=ht(b,on.mounted),E=ht(b,on.popupSide),N=ht(b,on.positionerElement),I=ht(b,on.listElement),P=ht(b,on.triggerProps),$=ht(b,on.triggerElement),B=ht(b,on.inputInsidePopup),D=ht(b,on.id),V=ht(b,on.labelId),H=ht(b,on.open),L=ht(b,on.selectedValue),F=ht(b,on.activeIndex),z=ht(b,on.selectedIndex),M=ht(b,on.hasSelectedValue),G=tq(),U=Hht(),R=co(),q=f||O||i,W=w.length===0,X=j&&N?E:null;h_({id:B?l:void 0});const ne=B?l??D:l,ee=nq(v,V),J=y.useRef("");function ie(we){J.current=we.pointerType}const ue=G.useState("domReferenceElement");y.useEffect(()=>{B&&$&&$!==ue&&G.set("domReferenceElement",$)},[$,ue,G,B]);const{reference:Y}=zye(G,{enabled:!H&&!_&&!O&&S==="single",listRef:b.state.labelsRef,activeIndex:F,selectedIndex:z,onMatch(we){const Ie=b.state.valuesRef.current[we];Ie!==void 0&&b.state.setSelectedValue(Ie,qt("none"))}}),{reference:te}=o_(G,{enabled:!_&&!O,event:"mousedown"}),{buttonRef:le,getButtonProps:fe}=vd({native:a,disabled:q}),se={...d,open:H,disabled:q,popupSide:X,listEmpty:W,placeholder:S==="none"?!1:!M},he=mt(we=>{b.set("triggerElement",we)});return En("button",t,{ref:[n,le,he],state:se,props:[P,te,Y,{id:ne,tabIndex:B?0:-1,role:B?"combobox":void 0,"aria-expanded":H?"true":"false","aria-haspopup":B?"dialog":"listbox","aria-controls":H?I?.id:void 0,"aria-required":B&&C||void 0,"aria-labelledby":ee,onPointerDown:ie,onPointerEnter:ie,onFocus(){h(!0),!(q||_)&&R.start(0,b.state.forceMount)},onBlur(we){if(!dn(N,we.relatedTarget)&&(p(!0),h(!1),m==="onBlur")){const Ie=S==="none"?U:L;g.commit(Ie)}},onMouseDown(we){if(q||_||(B||G.set("domReferenceElement",we.currentTarget),b.state.forceMount(),J.current!=="touch"&&(b.state.inputRef.current?.focus(),B||we.preventDefault()),H))return;const Ie=dr(we.currentTarget);function ke(je){if(!$)return;const Fe=Si(je),ce=b.state.positionerElement,ae=b.state.listElement;if(dn($,Fe)||dn(ce,Fe)||dn(ae,Fe)||Fe===$)return;const re=xxe($),me=je.clientX>=re.left-OL&&je.clientX<=re.right+OL,ye=je.clientY>=re.top-OL&&je.clientY<=re.bottom+OL;me&&ye||b.state.setOpen(!1,qt("cancel-open",je))}B&&Ie.addEventListener("mouseup",ke,{once:!0})},onKeyDown(we){q||_||(we.key==="ArrowDown"||we.key==="ArrowUp")&&(Jl(we),b.state.setOpen(!0,qt(wF,we.nativeEvent)),b.state.inputRef.current?.focus())}},g?g.getValidationProps(u):u,fe],stateAttributesMapping:emt})}),TAn=y.createContext(null);function NAn(){return y.useContext(TAn)}function IAn(e){const{children:t}=e,{filteredItems:n}=C1(),r=NAn(),s=r?r.items:n;return s?o.jsx(y.Fragment,{children:s.map(t)}):null}const amt=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function AAn(){return y.useContext(amt)}function bN(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,a=mt(s),i=y.useRef(0),l=cc(PAn).current,c=cc(RAn).current,[u,d]=y.useState(0),f=y.useRef(u),p=mt((b,w)=>{c.set(b,w??null),f.current+=1,d(f.current)}),h=mt(b=>{c.delete(b),f.current+=1,d(f.current)}),m=y.useMemo(()=>{const b=new Map;return Array.from(c.keys()).filter(S=>S.isConnected).sort($An).forEach((S,O)=>{const _=c.get(S)??{};b.set(S,{..._,index:O})}),b},[c,u]);Tt(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const b=new MutationObserver(w=>{const S=new Set,O=_=>S.has(_)?S.delete(_):S.add(_);w.forEach(_=>{_.removedNodes.forEach(O),_.addedNodes.forEach(O)}),S.size===0&&(f.current+=1,d(f.current))});return m.forEach((w,S)=>{S.parentElement&&b.observe(S.parentElement,{childList:!0})}),()=>{b.disconnect()}},[m]),Tt(()=>{f.current===u&&(n.current.length!==m.size&&(n.current.length=m.size),r&&r.current.length!==m.size&&(r.current.length=m.size),i.current=m.size),a(m)},[a,m,n,r,u]),Tt(()=>()=>{n.current=[]},[n]),Tt(()=>()=>{r&&(r.current=[])},[r]);const g=mt(b=>(l.add(b),()=>{l.delete(b)}));Tt(()=>{l.forEach(b=>b(m))},[l,m]);const v=y.useMemo(()=>({register:p,unregister:h,subscribeMapChange:g,elementsRef:n,labelsRef:r,nextIndexRef:i}),[p,h,g,n,r,i]);return o.jsx(amt.Provider,{value:v,children:t})}function RAn(){return new Map}function PAn(){return new Set}function $An(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const imt=y.forwardRef(function(t,n){var r;const{render:s,className:a,style:i,children:l,...c}=t,u=my(),d=tq(),f=!!bxe(!0),{filteredItems:p,hasItems:h}=C1(),m=ht(u,on.selectionMode),g=ht(u,on.grid),v=ht(u,on.popupProps),b=ht(u,on.virtualized),w=m==="multiple",S=p.length===0,O=mt(I=>{u.set("positionerElement",I)}),_=mt(I=>{u.set("listElement",I)}),C=y.useMemo(()=>typeof l=="function"?r||(r=o.jsx(IAn,{children:l})):l,[l]),j={empty:S},E=d.useState("floatingId"),N=En("div",t,{state:j,ref:[n,_,f?null:O],props:[v,{children:C,tabIndex:-1,id:E,role:g?"grid":"listbox","aria-multiselectable":w?"true":void 0,onKeyDown(I){if(!(u.state.disabled||u.state.readOnly)&&I.key==="Enter"){const P=u.state.activeIndex;if(P==null)return;Jl(I);const $=I.nativeEvent,B=u.state.listRef.current[P];B&&(u.state.selectionEventRef.current=$,B.click(),u.state.selectionEventRef.current=null)}},onKeyDownCapture(){u.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){u.state.keyboardActiveRef.current=!1}},c]});return b?N:o.jsx(bN,{elementsRef:u.state.listRef,labelsRef:h?void 0:u.state.labelsRef,children:N})}),MAn="",DAn=200;function LAn(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const r=t.currentNode;r.nodeValue!==""&&(n=r)}return n}function FAn(){const e=co(),t=y.useRef(null);return y.useEffect(()=>{if(mye)return;const n=t.current;if(n==null)return;const r=LAn(n);if(r==null)return;const s=r.nodeValue??"",a=`${s}${MAn}`;return r.nodeValue=a,e.start(DAn,()=>{r.nodeValue===a&&(r.nodeValue=s)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=s)}},[t,e]),t}const omt=y.createContext(void 0);function zAn(){const e=y.useContext(omt);if(e===void 0)throw new Error(yr(20));return e}const lmt=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,a=my(),i=ht(a,on.mounted),l=ht(a,on.forceMounted);return i||r||l?o.jsx(omt.Provider,{value:r,children:o.jsx(XM,{ref:n,...s})}):null}),BAn=20;function rq(e,t,n,r){const[s,a]=y.useState(!1);Tt(()=>{if(!e||!t||n==null){a(!1);return}const i=dr(n).documentElement.clientWidth,l=n.offsetWidth;a(i>0&&l>0&&l>=i-BAn)},[e,t,n]),dht(e&&(!t||s),r)}const cmt=y.forwardRef(function(t,n){const{render:r,className:s,anchor:a,positionMethod:i="absolute",side:l="bottom",align:c="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:p=5,arrowPadding:h=5,sticky:m=!1,disableAnchorTracking:g=!1,collisionAvoidance:v=Cye,style:b,...w}=t,S=my(),{filteredItems:O}=C1(),_=tq(),C=zAn(),j=ht(S,on.modal),E=ht(S,on.open),N=ht(S,on.mounted),I=ht(S,on.openMethod),P=ht(S,on.positionerElement),$=ht(S,on.triggerElement),B=ht(S,on.inputElement),D=ht(S,on.inputGroupElement),V=ht(S,on.inputInsidePopup),H=ht(S,on.transitionStatus),L=O.length===0,z=aN({anchor:a??(V?$:D??B),floatingRootContext:_,positionMethod:i,mounted:N,side:l,sideOffset:u,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,disableAnchorTracking:g,keepMounted:C,collisionAvoidance:v,lazyFlip:!0});rq(E&&j,I==="touch",P,$);const M={open:E,side:z.side,align:z.align,anchorHidden:z.anchorHidden,empty:L};Tt(()=>{S.set("popupSide",z.side)},[S,z.side]);const G=mt(R=>{S.set("positionerElement",R)}),U=iN(t,M,{styles:z.positionerStyles,transitionStatus:H,props:w,refs:[n,G],hidden:!N,inert:!E});return o.jsxs(tmt.Provider,{value:z,children:[N&&j&&o.jsx(y3,{inert:oN(!E),cutout:D??B??$}),U]})}),UAn={...mf,...ql},umt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,initialFocus:i,finalFocus:l,...c}=t,u=my(),d=bxe(),f=tq(),{filteredItems:p}=C1(),h=ht(u,on.mounted),m=ht(u,on.open),g=ht(u,on.openMethod),v=ht(u,on.transitionStatus),b=ht(u,on.inputInsidePopup),w=ht(u,on.inputElement),S=ht(u,on.modal),O=p.length===0;Vl({open:m,ref:u.state.popupRef,onComplete(){m&&u.state.onOpenChangeComplete(!0)}});const _={open:m,side:d.side,align:d.align,anchorHidden:d.anchorHidden,transitionStatus:v,empty:O},C=En("div",t,{state:_,ref:[n,u.state.popupRef],props:[{role:b?"dialog":"presentation",tabIndex:-1,onFocus(P){const $=Si(P.nativeEvent);g!=="touch"&&(dn(u.state.listElement,$)||$===P.currentTarget)&&u.state.inputRef.current?.focus()}},u_(v),c],stateAttributesMapping:UAn}),E=i===void 0?b?P=>P==="touch"?u.state.popupRef.current:w:!1:i;let N;l!=null?N=l:N=b?void 0:!1;const I=!b||S;return o.jsx(nN,{context:f,disabled:!h,modal:I,openInteractionType:g,initialFocus:E,returnFocus:N,getInsideElements:()=>[u.state.startDismissRef.current,u.state.endDismissRef.current],children:o.jsxs(y.Fragment,{children:[C,I&&o.jsx(nmt,{ref:u.state.endDismissRef})]})})});let wxe=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Ox(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:s,index:a}=e,{register:i,unregister:l,subscribeMapChange:c,elementsRef:u,labelsRef:d,nextIndexRef:f}=AAn(),p=y.useRef(-1),[h,m]=y.useState(a??(s===wxe.GuessFromOrder?()=>{if(p.current===-1){const b=f.current;f.current+=1,p.current=b}return p.current}:-1)),g=y.useRef(null),v=y.useCallback(b=>{if(g.current=b,h!==-1&&b!==null&&(u.current[h]=b,d)){const w=t!==void 0;d.current[h]=w?t:r?.current?.textContent??b.textContent}},[h,u,d,t,r]);return Tt(()=>{if(a!=null)return;const b=g.current;if(b)return i(b,n),()=>{l(b)}},[a,i,l,n]),Tt(()=>{if(a==null)return c(b=>{const w=g.current?b.get(g.current)?.index:null;w!=null&&m(w)})},[a,c,m]),y.useMemo(()=>({ref:v,index:h}),[h,v])}const dmt=y.createContext(void 0);function fmt(){const e=y.useContext(dmt);if(!e)throw new Error(yr(19));return e}const qAn=y.createContext(!1);function VAn(){return y.useContext(qAn)}const pmt=y.memo(y.forwardRef(function(t,n){const{render:r,className:s,style:a,value:i=null,index:l,disabled:c=!1,nativeButton:u=!1,...d}=t,f=y.useRef(!1),p=y.useRef(null),h=Ox({index:l,textRef:p,indexGuessBehavior:wxe.GuessFromOrder}),m=my(),g=VAn(),{flatFilteredItems:v,hasItems:b}=C1(),w=ht(m,on.open),S=ht(m,on.selectionMode),O=ht(m,on.readOnly),_=ht(m,on.virtualized),C=ht(m,on.isItemEqualToValue),j=S!=="none",E=l??(_?bw(v,i,C):h.index),N=h.index!==-1,I=ht(m,on.id),P=ht(m,on.isActive,E),$=ht(m,on.isSelected,i),B=ht(m,on.itemProps),D=y.useRef(null),V=I!=null&&N?`${I}-${E}`:void 0,H=$&&j;Tt(()=>{if(!(N&&(_||l!=null)))return;const W=m.state.listRef.current;return W[E]=D.current,()=>{delete W[E]}},[N,_,E,l,m]),Tt(()=>{if(!N||b)return;const q=m.state.valuesRef.current;return q[E]=i,S!=="none"&&m.state.allValuesRef.current.push(i),()=>{delete q[E]}},[N,b,E,i,m,S]),Tt(()=>{if(!w){f.current=!1;return}if(!N||b)return;const q=m.state.selectedValue,W=Array.isArray(q)?q[q.length-1]:q;Wv(i,W,C)&&m.set("selectedIndex",E)},[N,b,w,m,E,i,C]);const{getButtonProps:L,buttonRef:F}=vd({disabled:c,focusableWhenDisabled:!0,native:u,composite:!0}),z={disabled:c,selected:H,highlighted:P};function M(q){function W(){m.state.handleSelection(q,i)}m.state.submitOnItemClick?(fo.flushSync(W),m.state.requestSubmit()):W()}const G={id:V,role:g?"gridcell":"option","aria-selected":j?H:void 0,tabIndex:void 0,onPointerDownCapture(q){f.current=!0,q.preventDefault()},onMouseDown(q){q.preventDefault()},onClick(q){c||O||M(q.nativeEvent)},onMouseUp(q){const W=f.current;f.current=!1,!(c||O||q.button!==0||W||!P)&&M(q.nativeEvent)}},U=En("div",t,{ref:[F,n,h.ref,D],state:z,props:[B,G,d,L]}),R=y.useMemo(()=>({selected:H,textRef:p}),[H,p]);return o.jsx(dmt.Provider,{value:R,children:U})})),HAn=y.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=fmt();return r||s?o.jsx(ZAn,{...t,ref:n}):null}),ZAn=y.memo(y.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:a,...i}=e,{selected:l}=fmt(),c=y.useRef(null),{transitionStatus:u,setMounted:d}=bg(l),p=En("span",e,{ref:[t,c],state:{selected:l,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:ql});return Vl({open:l,ref:c,onComplete(){l||d(!1)}}),p})),hmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,{filteredItems:c}=C1(),u=my(),d=FAn(),f=c.length===0?i:null;return En("div",t,{ref:[n,u.state.emptyRef,d],props:[{children:f,role:"status","aria-live":"polite","aria-atomic":!0},l]})}),WAn=y.forwardRef(function(t,n){const{className:r,render:s,orientation:a="horizontal",style:i,...l}=t;return En("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})});function QAn(e){return e==="link"?"ghost":e}function mmt({variant:e,size:t,error:n,className:r}){const s=QAn(e);return K(i3({variant:s,size:t}),"w-full min-w-32 justify-between",wct[s],"data-[placeholder]:text-neutral3",n&&"border-error hover:border-error focus-visible:border-error",r)}const hs={root:"flex flex-col gap-1.5",chevron:"ml-2 h-4 w-4 shrink-0 opacity-60",placeholder:"text-neutral3",popup:K("min-w-(--anchor-width) w-max max-w-(--available-width) rounded-xl border border-border1 bg-surface3 text-neutral4","shadow-dialog","origin-(--transform-origin)","transition-[transform,scale,opacity] duration-150 ease-out","data-starting-style:scale-95 data-starting-style:opacity-0","data-ending-style:scale-95 data-ending-style:opacity-0"),positioner:"z-50 pointer-events-auto",searchContainer:K("flex items-center border-b border-border1 px-2.5 py-1.5",is.colors),searchIcon:K("mr-2 h-3.5 w-3.5 shrink-0 text-neutral3",is.colors),searchInput:K("flex h-7 w-full rounded-md bg-transparent py-1 text-ui-smd leading-ui-sm text-neutral6","placeholder:text-neutral3 disabled:cursor-not-allowed disabled:opacity-50","outline-none focus:outline-none focus-visible:outline-none",is.colors),empty:"not-empty:block hidden py-4 text-center text-ui-smd text-neutral3",list:"max-h-dropdown-max-height overflow-y-auto overflow-x-hidden p-1",item:K("group/item relative flex cursor-pointer select-none items-center gap-2 rounded-md","pl-2.5 pr-2 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",is.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemMulti:K("relative flex cursor-pointer select-none items-center gap-2.5 rounded-md","pl-2 pr-2.5 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",is.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemRightSlot:"ml-auto flex items-center gap-2 shrink-0",checkContainer:"flex h-4 w-4 shrink-0 items-center justify-center text-accent1",checkIcon:"h-3.5 w-3.5",checkbox:"flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border",checkboxSelected:"bg-accent1 border-accent1",checkboxUnselected:"border-border2",checkboxIcon:"h-3 w-3 text-surface1",optionContent:"flex items-center gap-2 w-full min-w-0",optionText:"flex flex-col gap-0.5 min-w-0",optionLabel:"truncate",optionDescription:"text-ui-sm text-neutral3 truncate",optionEnd:"ml-auto flex items-center shrink-0",error:"text-ui-sm text-accent2"};function gmt({options:e,value:t=[],onValueChange:n,placeholder:r="Select options...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.filter(b=>t.includes(b.value)),g=b=>{b&&n?.(b.map(w=>w.value))},v=m.length===0?r:`${m.length} selected`;return o.jsxs("div",{className:hs.root,children:[o.jsxs(Jht,{multiple:!0,items:e,value:m,onValueChange:g,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(smt,{className:mmt({variant:c,size:u,error:!!h,className:i}),children:[o.jsx("span",{className:K("truncate",m.length===0&&hs.placeholder),children:v}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(h3,{className:hs.chevron})})]}),o.jsx(lmt,{container:p,children:o.jsx(cmt,{align:"start",sideOffset:4,className:hs.positioner,children:o.jsxs(umt,{className:hs.popup,children:[o.jsxs("div",{className:hs.searchContainer,children:[o.jsx(Gj,{className:hs.searchIcon}),o.jsx(rmt,{className:hs.searchInput,placeholder:s})]}),o.jsx(hmt,{className:hs.empty,children:a}),o.jsx(imt,{className:hs.list,children:b=>{const w=t.includes(b.value);return o.jsxs(pmt,{value:b,className:hs.itemMulti,children:[o.jsx("span",{className:K(hs.checkbox,w?hs.checkboxSelected:hs.checkboxUnselected),children:w&&o.jsx(wx,{className:hs.checkboxIcon})}),o.jsxs("span",{className:hs.optionContent,children:[b.start,o.jsxs("span",{className:hs.optionText,children:[o.jsx("span",{className:hs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:hs.optionDescription,children:b.description})]}),b.end?o.jsx("div",{className:hs.optionEnd,children:b.end}):null]})]},b.value)}})]})})})]}),h&&o.jsx("span",{className:hs.error,children:h})]})}const vmt=y.createContext(void 0);function GAn({container:e,children:t}){return o.jsx(vmt.Provider,{value:e??void 0,children:t})}function x3(e){const t=y.useContext(vmt);return e??t??void 0}function Hc({options:e,value:t,onValueChange:n,placeholder:r="Select option...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.find(b=>b.value===t)??null,g=x3(p),v=b=>{b&&n?.(b.value)};return o.jsxs("div",{className:hs.root,children:[o.jsxs(Jht,{autoHighlight:!0,items:e,value:m,onValueChange:v,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(smt,{className:mmt({variant:c,size:u,error:!!h,className:i}),children:[o.jsxs("span",{className:"flex items-center gap-2 min-w-0 flex-1",children:[m?.start,o.jsx("span",{className:"truncate",children:o.jsx(CAn,{placeholder:r})})]}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(h3,{className:hs.chevron})})]}),o.jsx(lmt,{container:g,children:o.jsx(cmt,{align:"start",sideOffset:4,className:hs.positioner,children:o.jsxs(umt,{className:hs.popup,children:[o.jsxs("div",{className:hs.searchContainer,children:[o.jsx(Gj,{className:hs.searchIcon}),o.jsx(rmt,{className:hs.searchInput,placeholder:s})]}),o.jsx(hmt,{className:hs.empty,children:a}),o.jsx(imt,{className:hs.list,children:b=>o.jsxs(pmt,{value:b,className:hs.item,children:[b.start,o.jsxs("span",{className:hs.optionText,children:[o.jsx("span",{className:hs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:hs.optionDescription,children:b.description})]}),o.jsxs("span",{className:hs.itemRightSlot,children:[b.end?o.jsx("div",{className:hs.optionEnd,children:b.end}):null,o.jsx("span",{className:hs.checkContainer,children:o.jsx(HAn,{children:o.jsx(wx,{className:hs.checkIcon})})})]})]},b.value)})]})})})]}),h&&o.jsx("span",{className:hs.error,children:h})]})}var a4e=1,YAn=.9,XAn=.8,KAn=.17,aX=.1,iX=.999,JAn=.9999,eRn=.99,tRn=/[\\\/_+.#"@\[\(\{&]/,nRn=/[\\\/_+.#"@\[\(\{&]/g,rRn=/[\s-]/,ymt=/[\s-]/g;function efe(e,t,n,r,s,a,i){if(a===t.length)return s===e.length?a4e:eRn;var l=`${s},${a}`;if(i[l]!==void 0)return i[l];for(var c=r.charAt(a),u=n.indexOf(c,s),d=0,f,p,h,m;u>=0;)f=efe(e,t,n,r,u+1,a+1,i),f>d&&(u===s?f*=a4e:tRn.test(e.charAt(u-1))?(f*=XAn,h=e.slice(s,u-1).match(nRn),h&&s>0&&(f*=Math.pow(iX,h.length))):rRn.test(e.charAt(u-1))?(f*=YAn,m=e.slice(s,u-1).match(ymt),m&&s>0&&(f*=Math.pow(iX,m.length))):(f*=KAn,s>0&&(f*=Math.pow(iX,u-s))),e.charAt(u)!==t.charAt(a)&&(f*=JAn)),(f<aX&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a))&&(p=efe(e,t,n,r,u+1,a+2,i),p*aX>f&&(f=p*aX)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[l]=d,d}function i4e(e){return e.toLowerCase().replace(ymt," ")}function sRn(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,efe(e,t,i4e(e),i4e(t),0,0,{})}var oX="focusScope.autoFocusOnMount",lX="focusScope.autoFocusOnUnmount",o4e={bubbles:!1,cancelable:!0},aRn="FocusScope",bmt=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=y.useState(null),u=Rj(s),d=Rj(a),f=y.useRef(null),p=yg(t,g=>c(g)),h=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let g=function(S){if(h.paused||!l)return;const O=S.target;l.contains(O)?f.current=O:$0(f.current,{select:!0})},v=function(S){if(h.paused||!l)return;const O=S.relatedTarget;O!==null&&(l.contains(O)||$0(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const _ of S)_.removedNodes.length>0&&$0(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,h.paused]),y.useEffect(()=>{if(l){c4e.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(oX,o4e);l.addEventListener(oX,u),l.dispatchEvent(b),b.defaultPrevented||(iRn(dRn(xmt(l)),{select:!0}),document.activeElement===g&&$0(l))}return()=>{l.removeEventListener(oX,u),setTimeout(()=>{const b=new CustomEvent(lX,o4e);l.addEventListener(lX,d),l.dispatchEvent(b),b.defaultPrevented||$0(g??document.body,{select:!0}),l.removeEventListener(lX,d),c4e.remove(h)},0)}}},[l,u,d,h]);const m=y.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(v&&b){const w=g.currentTarget,[S,O]=oRn(w);S&&O?!g.shiftKey&&b===O?(g.preventDefault(),n&&$0(S,{select:!0})):g.shiftKey&&b===S&&(g.preventDefault(),n&&$0(O,{select:!0})):b===w&&g.preventDefault()}},[n,r,h.paused]);return o.jsx(pf.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});bmt.displayName=aRn;function iRn(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($0(r,{select:t}),document.activeElement!==n)return}function oRn(e){const t=xmt(e),n=l4e(t,e),r=l4e(t.reverse(),e);return[n,r]}function xmt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function l4e(e,t){for(const n of e)if(!lRn(n,{upTo:t}))return n}function lRn(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function cRn(e){return e instanceof HTMLInputElement&&"select"in e}function $0(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&cRn(e)&&t&&e.select()}}var c4e=uRn();function uRn(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=u4e(e,t),e.unshift(t)},remove(t){e=u4e(e,t),e[0]?.resume()}}}function u4e(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function dRn(e){return e.filter(t=>t.tagName!=="A")}var cX=0;function fRn(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??d4e()),document.body.insertAdjacentElement("beforeend",e[1]??d4e()),cX++,()=>{cX===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),cX--}},[])}function d4e(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var uv=function(){return uv=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},uv.apply(this,arguments)};function wmt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function pRn(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,a;r<s;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Y8="right-scroll-bar-position",X8="width-before-scroll-bar",hRn="with-scroll-bars-hidden",mRn="--removed-body-scroll-bar-size";function uX(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gRn(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var vRn=typeof window<"u"?y.useLayoutEffect:y.useEffect,f4e=new WeakMap;function yRn(e,t){var n=gRn(null,function(r){return e.forEach(function(s){return uX(s,r)})});return vRn(function(){var r=f4e.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||uX(l,null)}),a.forEach(function(l){s.has(l)||uX(l,i)})}f4e.set(n,e)},[e]),n}function bRn(e){return e}function xRn(e,t){t===void 0&&(t=bRn);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var d=i;i=[],d.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return s}function wRn(e){e===void 0&&(e={});var t=xRn(null);return t.options=uv({async:!0,ssr:!1},e),t}var Smt=function(e){var t=e.sideCar,n=wmt(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,uv({},n))};Smt.isSideCarExport=!0;function SRn(e,t){return e.useMedium(t),Smt}var kmt=wRn(),dX=function(){},sq=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:dX,onWheelCapture:dX,onTouchMoveCapture:dX}),s=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,S=e.gapMode,O=wmt(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=p,C=yRn([n,t]),j=uv(uv({},O),s);return y.createElement(y.Fragment,null,d&&y.createElement(_,{sideCar:kmt,removeScrollBar:u,shards:f,noRelative:h,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:S}),i?y.cloneElement(y.Children.only(l),uv(uv({},j),{ref:C})):y.createElement(w,uv({},j,{className:c,ref:C}),l))});sq.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sq.classNames={fullWidth:X8,zeroRight:Y8};var kRn=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ORn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=kRn();return t&&e.setAttribute("nonce",t),e}function _Rn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function CRn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ERn=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ORn())&&(_Rn(t,n),CRn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jRn=function(){var e=ERn();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Omt=function(){var e=jRn(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},TRn={left:0,top:0,right:0,gap:0},fX=function(e){return parseInt(e||"",10)||0},NRn=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[fX(n),fX(r),fX(s)]},IRn=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return TRn;var t=NRn(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ARn=Omt(),oj="data-scroll-locked",RRn=function(e,t,n,r){var s=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
226
|
+
`:r=="r"?"\r":r=="t"?" ":"\\")}eq(t){return this.search==t.search&&this.replace==t.replace&&this.caseSensitive==t.caseSensitive&&this.regexp==t.regexp&&this.wholeWord==t.wholeWord&&this.test==t.test}create(){return this.regexp?new cEn(this):new iEn(this)}getCursor(t,n=0,r){let s=t.doc?t:os.create({doc:t});return r==null&&(r=s.doc.length),this.regexp?iE(this,s,n,r):aE(this,s,n,r)}}class Fpt{constructor(t){this.spec=t}}function sEn(e,t,n){return(r,s,a,i)=>{if(n&&!n(r,s,a,i))return!1;let l=r>=i&&s<=i+a.length?a.slice(r-i,s-i):t.doc.sliceString(r,s);return e(l,t,r,s)}}function aE(e,t,n,r){let s;return e.wholeWord&&(s=aEn(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(s=sEn(e.test,t,s)),new ex(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:a=>a.toLowerCase(),s)}function aEn(e,t){return(n,r,s,a)=>((a>n||a+s.length<r)&&(a=Math.max(0,n-2),s=e.sliceString(a,Math.min(e.length,r+2))),(t(nz(s,n-a))!=oo.Word||t(rz(s,n-a))!=oo.Word)&&(t(rz(s,r-a))!=oo.Word||t(nz(s,r-a))!=oo.Word))}class iEn extends Fpt{constructor(t){super(t)}nextMatch(t,n,r){let s=aE(this.spec,t,r,t.doc.length).nextOverlapping();if(s.done){let a=Math.min(t.doc.length,n+this.spec.unquoted.length);s=aE(this.spec,t,0,a).nextOverlapping()}return s.done||s.value.from==n&&s.value.to==r?null:s.value}prevMatchInRange(t,n,r){for(let s=r;;){let a=Math.max(n,s-1e4-this.spec.unquoted.length),i=aE(this.spec,t,a,s),l=null;for(;!i.nextOverlapping().done;)l=i.value;if(l)return l;if(a==n)return null;s-=1e4}}prevMatch(t,n,r){let s=this.prevMatchInRange(t,0,n);return s||(s=this.prevMatchInRange(t,Math.max(0,r-this.spec.unquoted.length),t.doc.length)),s&&(s.from!=n||s.to!=r)?s:null}getReplacement(t){return this.spec.unquote(this.spec.replace)}matchAll(t,n){let r=aE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=aE(this.spec,t,Math.max(0,n-this.spec.unquoted.length),Math.min(r+this.spec.unquoted.length,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function oEn(e,t,n){return(r,s,a)=>(!n||n(r,s,a))&&e(a[0],t,r,s)}function iE(e,t,n,r){let s;return e.wholeWord&&(s=lEn(t.charCategorizer(t.selection.main.head))),e.test&&(s=oEn(e.test,t,s)),new Mpt(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:s},n,r)}function nz(e,t){return e.slice(rc(e,t,!1),t)}function rz(e,t){return e.slice(t,rc(e,t))}function lEn(e){return(t,n,r)=>!r[0].length||(e(nz(r.input,r.index))!=oo.Word||e(rz(r.input,r.index))!=oo.Word)&&(e(rz(r.input,r.index+r[0].length))!=oo.Word||e(nz(r.input,r.index+r[0].length))!=oo.Word)}class cEn extends Fpt{nextMatch(t,n,r){let s=iE(this.spec,t,r,t.doc.length).next();return s.done&&(s=iE(this.spec,t,0,n).next()),s.done?null:s.value}prevMatchInRange(t,n,r){for(let s=1;;s++){let a=Math.max(n,r-s*1e4),i=iE(this.spec,t,a,r),l=null;for(;!i.next().done;)l=i.value;if(l&&(a==n||l.from>a+10))return l;if(a==n)return null}}prevMatch(t,n,r){return this.prevMatchInRange(t,0,n)||this.prevMatchInRange(t,r,t.doc.length)}getReplacement(t){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(n,r)=>{if(r=="&")return t.match[0];if(r=="$")return"$";for(let s=r.length;s>0;s--){let a=+r.slice(0,s);if(a>0&&a<t.match.length)return t.match[a]+r.slice(s)}return n})}matchAll(t,n){let r=iE(this.spec,t,0,t.doc.length),s=[];for(;!r.next().done;){if(s.length>=n)return null;s.push(r.value)}return s}highlight(t,n,r,s){let a=iE(this.spec,t,Math.max(0,n-250),Math.min(r+250,t.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const BP=mr.define(),Zbe=mr.define(),yw=cl.define({create(e){return new eX(Qde(e).create(),null)},update(e,t){for(let n of t.effects)n.is(BP)?e=new eX(n.value.create(),e.panel):n.is(Zbe)&&(e=new eX(e.query,n.value?Wbe:null));return e},provide:e=>IP.from(e,t=>t.panel)});class eX{constructor(t,n){this.query=t,this.panel=n}}const uEn=Cn.mark({class:"cm-searchMatch"}),dEn=Cn.mark({class:"cm-searchMatch cm-searchMatch-selected"}),fEn=po.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(yw))}update(e){let t=e.state.field(yw);(t!=e.startState.field(yw)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return Cn.none;let{view:n}=this,r=new dd;for(let s=0,a=n.visibleRanges,i=a.length;s<i;s++){let{from:l,to:c}=a[s];for(;s<i-1&&c>a[s+1].from-500;)c=a[++s].to;e.highlight(n.state,l,c,(u,d)=>{let f=n.state.selection.ranges.some(p=>p.from==u&&p.to==d);r.add(u,d,f?dEn:uEn)})}return r.finish()}},{decorations:e=>e.decorations});function p3(e){return t=>{let n=t.state.field(yw,!1);return n&&n.query.spec.valid?e(t,n):Upt(t)}}const sz=p3((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let s=vt.single(r.from,r.to),a=e.state.facet(mN);return e.dispatch({selection:s,effects:[Qbe(e,r),a.scrollToMatch(s.main,e)],userEvent:"select.search"}),Bpt(e),!0}),az=p3((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,s=t.prevMatch(n,r,r);if(!s)return!1;let a=vt.single(s.from,s.to),i=e.state.facet(mN);return e.dispatch({selection:a,effects:[Qbe(e,s),i.scrollToMatch(a.main,e)],userEvent:"select.search"}),Bpt(e),!0}),pEn=p3((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:vt.create(n.map(r=>vt.range(r.from,r.to))),userEvent:"select.search.matches"}),!0)}),hEn=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:s}=n.main,a=[],i=0;for(let l=new ex(e.doc,e.sliceDoc(r,s));!l.next().done;){if(a.length>1e3)return!1;l.value.from==r&&(i=a.length),a.push(vt.range(l.value.from,l.value.to))}return t(e.update({selection:vt.create(a,i),userEvent:"select.search.matches"})),!0},NDe=p3((e,{query:t})=>{let{state:n}=e,{from:r,to:s}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let i=a,l=[],c,u,d=[];i.precise?i.from==r&&i.to==s&&(u=n.toText(t.getReplacement(i)),l.push({from:i.from,to:i.to,insert:u}),d.push(Nt.announce.of(n.phrase("replaced match on line $",n.doc.lineAt(r).number)+"."))):i=t.nextMatch(n,i.from,i.to);let f=e.state.changes(l);return i&&(c=vt.single(i.from,i.to).map(f),d.push(Qbe(e,i)),d.push(n.facet(mN).scrollToMatch(c.main,e))),e.dispatch({changes:f,selection:c,effects:d,userEvent:"input.replace"}),!0}),mEn=p3((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let s of t.matchAll(e.state,1e9)){let{from:a,to:i,precise:l}=s;l&&n.push({from:a,to:i,insert:t.getReplacement(s)})}if(!n.length)return!1;let r=e.state.phrase("replaced $ matches",n.length)+".";return e.dispatch({changes:n,effects:Nt.announce.of(r),userEvent:"input.replace.all"}),!0});function Wbe(e){return e.state.facet(mN).createPanel(e)}function Qde(e,t){var n,r,s,a,i;let l=e.selection.main,c=l.empty||l.to>l.from+100?"":e.sliceDoc(l.from,l.to);if(t&&!c)return t;let u=e.facet(mN);return new Lpt({search:((n=t?.literal)!==null&&n!==void 0?n:u.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(r=t?.caseSensitive)!==null&&r!==void 0?r:u.caseSensitive,literal:(s=t?.literal)!==null&&s!==void 0?s:u.literal,regexp:(a=t?.regexp)!==null&&a!==void 0?a:u.regexp,wholeWord:(i=t?.wholeWord)!==null&&i!==void 0?i:u.wholeWord})}function zpt(e){let t=cbe(e,Wbe);return t&&t.dom.querySelector("[main-field]")}function Bpt(e){let t=zpt(e);t&&t==e.root.activeElement&&t.select()}const Upt=e=>{let t=e.state.field(yw,!1);if(t&&t.panel){let n=zpt(e);if(n&&n!=e.root.activeElement){let r=Qde(e.state,t.query.spec);r.valid&&e.dispatch({effects:BP.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[Zbe.of(!0),t?BP.of(Qde(e.state,t.query.spec)):mr.appendConfig.of(bEn)]});return!0},qpt=e=>{let t=e.state.field(yw,!1);if(!t||!t.panel)return!1;let n=cbe(e,Wbe);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:Zbe.of(!1)}),!0},gEn=[{key:"Mod-f",run:Upt,scope:"editor search-panel"},{key:"F3",run:sz,shift:az,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:sz,shift:az,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:qpt,scope:"editor search-panel"},{key:"Mod-Shift-l",run:hEn},{key:"Mod-Alt-g",run:ZCn},{key:"Mod-d",run:rEn,preventDefault:!0}];class vEn{constructor(t){this.view=t;let n=this.query=t.state.field(yw).query.spec;this.commit=this.commit.bind(this),this.searchField=oi("input",{value:n.search,placeholder:Ff(t,"Find"),"aria-label":Ff(t,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=oi("input",{value:n.replace,placeholder:Ff(t,"Replace"),"aria-label":Ff(t,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=oi("input",{type:"checkbox",name:"case",form:"",checked:n.caseSensitive,onchange:this.commit}),this.reField=oi("input",{type:"checkbox",name:"re",form:"",checked:n.regexp,onchange:this.commit}),this.wordField=oi("input",{type:"checkbox",name:"word",form:"",checked:n.wholeWord,onchange:this.commit});function r(s,a,i){return oi("button",{class:"cm-button",name:s,onclick:a,type:"button"},i)}this.dom=oi("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,r("next",()=>sz(t),[Ff(t,"next")]),r("prev",()=>az(t),[Ff(t,"previous")]),r("select",()=>pEn(t),[Ff(t,"all")]),oi("label",null,[this.caseField,Ff(t,"match case")]),oi("label",null,[this.reField,Ff(t,"regexp")]),oi("label",null,[this.wordField,Ff(t,"by word")]),...t.state.readOnly?[]:[oi("br"),this.replaceField,r("replace",()=>NDe(t),[Ff(t,"replace")]),r("replaceAll",()=>mEn(t),[Ff(t,"replace all")])],oi("button",{name:"close",onclick:()=>qpt(t),"aria-label":Ff(t,"close"),type:"button"},["×"])])}commit(){let t=new Lpt({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});t.eq(this.query)||(this.query=t,this.view.dispatch({effects:BP.of(t)}))}keydown(t){D0n(this.view,t,"search-panel")?t.preventDefault():t.keyCode==13&&t.target==this.searchField?(t.preventDefault(),(t.shiftKey?az:sz)(this.view)):t.keyCode==13&&t.target==this.replaceField&&(t.preventDefault(),NDe(this.view))}update(t){for(let n of t.transactions)for(let r of n.effects)r.is(BP)&&!r.value.eq(this.query)&&this.setQuery(r.value)}setQuery(t){this.query=t,this.searchField.value=t.search,this.replaceField.value=t.replace,this.caseField.checked=t.caseSensitive,this.reField.checked=t.regexp,this.wordField.checked=t.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(mN).top}}function Ff(e,t){return e.state.phrase(t)}const bL=30,xL=/[\s\.,:;?!]/;function Qbe(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),s=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-bL),i=Math.min(s,n+bL),l=e.state.sliceDoc(a,i);if(a!=r.from){for(let c=0;c<bL;c++)if(!xL.test(l[c+1])&&xL.test(l[c])){l=l.slice(c);break}}if(i!=s){for(let c=l.length-1;c>l.length-bL;c--)if(!xL.test(l[c-1])&&xL.test(l[c])){l=l.slice(0,c);break}}return Nt.announce.of(`${e.state.phrase("current match")}. ${l} ${e.state.phrase("on line")} ${r.number}.`)}const yEn=Nt.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),bEn=[yw,xg.low(fEn),yEn];class IDe{constructor(t,n,r){this.from=t,this.to=n,this.diagnostic=r}}class JS{constructor(t,n,r){this.diagnostics=t,this.panel=n,this.selected=r}static init(t,n,r){let s=r.facet(UP).markerFilter;s&&(t=s(t,r));let a=t.slice().sort((d,f)=>d.from-f.from||d.to-f.to),i=new dd,l=[],c=0;for(let d=0;;){let f=d==a.length?null:a[d];if(!f&&!l.length)break;let p,h;for(l.length?(p=c,h=l.reduce((g,v)=>Math.min(g,v.to),f&&f.from>p?f.from:1e8)):(p=f.from,h=f.to,l.push(f),d++);d<a.length;){let g=a[d];if(g.from==p&&(g.to>g.from||g.to==p))l.push(g),d++,h=Math.min(g.to,h);else{h=Math.min(g.from,h);break}}let m=AEn(l);if(l.some(g=>g.from==g.to||g.from==g.to-1&&r.doc.lineAt(g.from).to==g.from))i.add(p,p,Cn.widget({widget:new jEn(m),diagnostics:l.slice()}));else{let g=l.reduce((v,b)=>b.markClass?v+" "+b.markClass:v,"");i.add(p,h,Cn.mark({class:"cm-lintRange cm-lintRange-"+m+g,diagnostics:l.slice(),inclusiveEnd:l.some(v=>v.to>h)}))}c=h;for(let g=0;g<l.length;g++)l[g].to<=c&&l.splice(g--,1)}let u=i.finish();return new JS(u,n,Wj(u))}}function Wj(e,t=null,n=0){let r=null;return e.between(n,1e9,(s,a,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0))if(!r)r=new IDe(s,a,t||i.diagnostics[0]);else{if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;r=new IDe(r.from,a,r.diagnostic)}}),r}function xEn(e,t){let n=t.pos,r=t.end||n,s=e.state.facet(UP).hideOn(e,n,r);if(s!=null)return s;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(i=>i.is(Vpt))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function wEn(e,t){return e.field(cp,!1)?t:t.concat(mr.appendConfig.of(REn))}const Vpt=mr.define(),Gbe=mr.define(),Hpt=mr.define(),cp=cl.define({create(){return new JS(Cn.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,s=e.panel;if(e.selected){let a=t.changes.mapPos(e.selected.from,1);r=Wj(n,e.selected.diagnostic,a)||Wj(n,null,a)}!n.size&&s&&t.state.facet(UP).autoPanel&&(s=null),e=new JS(n,s,r)}for(let n of t.effects)if(n.is(Vpt)){let r=t.state.facet(UP).autoPanel?n.value.length?qP.open:null:e.panel;e=JS.init(n.value,r,t.state)}else n.is(Gbe)?e=new JS(e.diagnostics,n.value?qP.open:null,e.selected):n.is(Hpt)&&(e=new JS(e.diagnostics,e.panel,n.value));return e},provide:e=>[IP.from(e,t=>t.panel),Nt.decorations.from(e,t=>t.diagnostics)]}),SEn=Cn.mark({class:"cm-lintRange cm-lintRange-active"});function kEn(e,t,n){let{diagnostics:r}=e.state.field(cp),s,a=-1,i=-1;r.between(t-(n<0?1:0),t+(n>0?1:0),(c,u,{spec:d})=>{if(t>=c&&t<=u&&(c==u||(t>c||n>0)&&(t<u||n<0)))return s=d.diagnostics,a=c,i=u,!1});let l=e.state.facet(UP).tooltipFilter;return s&&l&&(s=l(s,e.state)),s?{pos:a,end:i,above:e.state.doc.lineAt(a).to<i,create(){return{dom:OEn(e,s)}}}:null}function OEn(e,t){return oi("ul",{class:"cm-tooltip-lint"},t.map(n=>Wpt(e,n,!1)))}const _En=e=>{let t=e.state.field(cp,!1);(!t||!t.panel)&&e.dispatch({effects:wEn(e.state,[Gbe.of(!0)])});let n=cbe(e,qP.open);return n&&n.dom.querySelector(".cm-panel-lint ul").focus(),!0},ADe=e=>{let t=e.state.field(cp,!1);return!t||!t.panel?!1:(e.dispatch({effects:Gbe.of(!1)}),!0)},CEn=e=>{let t=e.state.field(cp,!1);if(!t)return!1;let n=e.state.selection.main,r=t.diagnostics.iter(n.to+1);return!r.value&&(r=t.diagnostics.iter(0),!r.value||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)},EEn=[{key:"Mod-Shift-m",run:_En,preventDefault:!0},{key:"F8",run:CEn}],UP=wn.define({combine(e){return{sources:e.map(t=>t.source).filter(t=>t!=null),...hy(e.map(t=>t.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:RDe,tooltipFilter:RDe,needsRefresh:(t,n)=>t?n?r=>t(r)||n(r):t:n,hideOn:(t,n)=>t?n?(r,s,a)=>t(r,s,a)||n(r,s,a):t:n,autoPanel:(t,n)=>t||n})}}});function RDe(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function Zpt(e){let t=[];if(e)e:for(let{name:n}of e){for(let r=0;r<n.length;r++){let s=n[r];if(/[a-zA-Z]/.test(s)&&!t.some(a=>a.toLowerCase()==s.toLowerCase())){t.push(s);continue e}}t.push("")}return t}function Wpt(e,t,n){var r;let s=n?Zpt(t.actions):[];return oi("li",{class:"cm-diagnostic cm-diagnostic-"+t.severity},oi("span",{class:"cm-diagnosticText"},t.renderMessage?t.renderMessage(e):t.message),(r=t.actions)===null||r===void 0?void 0:r.map((a,i)=>{let l=!1,c=h=>{if(h.preventDefault(),l)return;l=!0;let m=Wj(e.state.field(cp).diagnostics,t);m&&a.apply(e,m.from,m.to)},{name:u}=a,d=s[i]?u.indexOf(s[i]):-1,f=d<0?u:[u.slice(0,d),oi("u",u.slice(d,d+1)),u.slice(d+1)],p=a.markClass?" "+a.markClass:"";return oi("button",{type:"button",class:"cm-diagnosticAction"+p,onclick:c,onmousedown:c,"aria-label":` Action: ${u}${d<0?"":` (access key "${s[i]})"`}.`},f)}),t.source&&oi("div",{class:"cm-diagnosticSource"},t.source))}class jEn extends $p{constructor(t){super(),this.sev=t}eq(t){return t.sev==this.sev}toDOM(){return oi("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class PDe{constructor(t,n){this.diagnostic=n,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Wpt(t,n,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class qP{constructor(t){this.view=t,this.items=[];let n=s=>{if(s.keyCode==27)ADe(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],i=Zpt(a.actions);for(let l=0;l<i.length;l++)if(i[l].toUpperCase().charCodeAt(0)==s.keyCode){let c=Wj(this.view.state.field(cp).diagnostics,a);c&&a.actions[l].apply(t,c.from,c.to)}}else return;s.preventDefault()},r=s=>{for(let a=0;a<this.items.length;a++)this.items[a].dom.contains(s.target)&&this.moveSelection(a)};this.list=oi("ul",{tabIndex:0,role:"listbox","aria-label":this.view.state.phrase("Diagnostics"),onkeydown:n,onclick:r}),this.dom=oi("div",{class:"cm-panel-lint"},this.list,oi("button",{type:"button",name:"close","aria-label":this.view.state.phrase("close"),onclick:()=>ADe(this.view)},"×")),this.update()}get selectedIndex(){let t=this.view.state.field(cp).selected;if(!t)return-1;for(let n=0;n<this.items.length;n++)if(this.items[n].diagnostic==t.diagnostic)return n;return-1}update(){let{diagnostics:t,selected:n}=this.view.state.field(cp),r=0,s=!1,a=null,i=new Set;for(t.between(0,this.view.state.doc.length,(l,c,{spec:u})=>{for(let d of u.diagnostics){if(i.has(d))continue;i.add(d);let f=-1,p;for(let h=r;h<this.items.length;h++)if(this.items[h].diagnostic==d){f=h;break}f<0?(p=new PDe(this.view,d),this.items.splice(r,0,p),s=!0):(p=this.items[f],f>r&&(this.items.splice(r,f-r),s=!0)),n&&p.diagnostic==n.diagnostic?p.dom.hasAttribute("aria-selected")||(p.dom.setAttribute("aria-selected","true"),a=p):p.dom.hasAttribute("aria-selected")&&p.dom.removeAttribute("aria-selected"),r++}});r<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)s=!0,this.items.pop();this.items.length==0&&(this.items.push(new PDe(this.view,{from:-1,to:-1,severity:"info",message:this.view.state.phrase("No diagnostics")})),s=!0),a?(this.list.setAttribute("aria-activedescendant",a.id),this.view.requestMeasure({key:this,read:()=>({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:l,panel:c})=>{let u=c.height/this.list.offsetHeight;l.top<c.top?this.list.scrollTop-=(c.top-l.top)/u:l.bottom>c.bottom&&(this.list.scrollTop+=(l.bottom-c.bottom)/u)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let t=this.list.firstChild;function n(){let r=t;t=r.nextSibling,r.remove()}for(let r of this.items)if(r.dom.parentNode==this.list){for(;t!=r.dom;)n();t=r.dom.nextSibling}else this.list.insertBefore(r.dom,t);for(;t;)n()}moveSelection(t){if(this.selectedIndex<0)return;let n=this.view.state.field(cp),r=Wj(n.diagnostics,this.items[t].diagnostic);r&&this.view.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0,effects:Hpt.of(r)})}static open(t){return new qP(t)}}function TEn(e,t='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function wL(e){return TEn(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,'width="6" height="3"')}const NEn=Nt.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:wL("#d11")},".cm-lintRange-warning":{backgroundImage:wL("orange")},".cm-lintRange-info":{backgroundImage:wL("#999")},".cm-lintRange-hint":{backgroundImage:wL("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function IEn(e){return e=="error"?4:e=="warning"?3:e=="info"?2:1}function AEn(e){let t="hint",n=1;for(let r of e){let s=IEn(r.severity);s>n&&(n=s,t=r.severity)}return t}const REn=[cp,Nt.decorations.compute([cp],e=>{let{selected:t,panel:n}=e.field(cp);return!t||!n||t.from==t.to?Cn.none:Cn.set([SEn.range(t.from,t.to)])}),_wn(kEn,{hideOn:xEn}),NEn];var $De=function(t){t===void 0&&(t={});var n=t,r=n.crosshairCursor,s=r===void 0?!1:r,a=[];t.closeBracketsKeymap!==!1&&(a=a.concat(SSn)),t.defaultKeymap!==!1&&(a=a.concat(qCn)),t.searchKeymap!==!1&&(a=a.concat(gEn)),t.historyKeymap!==!1&&(a=a.concat(Y_n)),t.foldKeymap!==!1&&(a=a.concat(o1n)),t.completionKeymap!==!1&&(a=a.concat(Bdt)),t.lintKeymap!==!1&&(a=a.concat(EEn));var i=[];return t.lineNumbers!==!1&&i.push(Dwn()),t.highlightActiveLineGutter!==!1&&i.push(zwn()),t.highlightSpecialChars!==!1&&i.push(J0n()),t.history!==!1&&i.push(B_n()),t.foldGutter!==!1&&i.push(d1n()),t.drawSelection!==!1&&i.push(q0n()),t.dropCursor!==!1&&i.push(Q0n()),t.allowMultipleSelections!==!1&&i.push(os.allowMultipleSelections.of(!0)),t.indentOnInput!==!1&&i.push(Jwn()),t.syntaxHighlighting!==!1&&i.push(S1(m1n,{fallback:!0})),t.bracketMatching!==!1&&i.push(S1n()),t.closeBrackets!==!1&&i.push(ySn()),t.autocompletion!==!1&&i.push(zdt()),t.rectangularSelection!==!1&&i.push(pwn()),s!==!1&&i.push(gwn()),t.highlightActiveLine!==!1&&i.push(awn()),t.highlightSelectionMatches!==!1&&i.push(GCn()),t.tabSize&&typeof t.tabSize=="number"&&i.push(dN.of(" ".repeat(t.tabSize))),i.concat([uN.of(a.flat())]).filter(Boolean)};const PEn="#e5c07b",MDe="#e06c75",$En="#56b6c2",MEn="#ffffff",G8="#abb2bf",Gde="#7d8799",DEn="#61afef",LEn="#98c379",DDe="#d19a66",FEn="#c678dd",zEn="#21252b",LDe="#2c313a",FDe="#282c34",tX="#353a42",BEn="#3E4451",zDe="#528bff",UEn=Nt.theme({"&":{color:G8,backgroundColor:FDe},".cm-content":{caretColor:zDe},".cm-cursor, .cm-dropCursor":{borderLeftColor:zDe},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:BEn},".cm-panels":{backgroundColor:zEn,color:G8},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:FDe,color:Gde,border:"none"},".cm-activeLineGutter":{backgroundColor:LDe},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:tX},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:tX,borderBottomColor:tX},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:LDe,color:G8}}},{dark:!0}),qEn=wg.define([{tag:de.keyword,color:FEn},{tag:[de.name,de.deleted,de.character,de.propertyName,de.macroName],color:MDe},{tag:[de.function(de.variableName),de.labelName],color:DEn},{tag:[de.color,de.constant(de.name),de.standard(de.name)],color:DDe},{tag:[de.definition(de.name),de.separator],color:G8},{tag:[de.typeName,de.className,de.number,de.changed,de.annotation,de.modifier,de.self,de.namespace],color:PEn},{tag:[de.operator,de.operatorKeyword,de.url,de.escape,de.regexp,de.link,de.special(de.string)],color:$En},{tag:[de.meta,de.comment],color:Gde},{tag:de.strong,fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.link,color:Gde,textDecoration:"underline"},{tag:de.heading,fontWeight:"bold",color:MDe},{tag:[de.atom,de.bool,de.special(de.variableName)],color:DDe},{tag:[de.processingInstruction,de.string,de.inserted],color:LEn},{tag:de.invalid,color:MEn}]),VEn=[UEn,S1(qEn)];var HEn=Nt.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ZEn=function(t){t===void 0&&(t={});var n=t,r=n.indentWithTab,s=r===void 0?!0:r,a=n.editable,i=a===void 0?!0:a,l=n.readOnly,c=l===void 0?!1:l,u=n.theme,d=u===void 0?"light":u,f=n.placeholder,p=f===void 0?"":f,h=n.basicSetup,m=h===void 0?!0:h,g=[];switch(s&&g.unshift(uN.of([VCn])),m&&(typeof m=="boolean"?g.unshift($De()):g.unshift($De(m))),p&&g.unshift(cwn(p)),d){case"light":g.push(HEn);break;case"dark":g.push(VEn);break;case"none":break;default:g.push(d);break}return i===!1&&g.push(Nt.editable.of(!1)),c&&g.push(os.readOnly.of(!0)),[...g]},WEn=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(t=>!t.empty)});class QEn{constructor(t,n){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=n,this.timeoutMS=n,this.callbacks.push(t)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var t=this.callbacks.slice();this.callbacks.length=0,t.forEach(n=>{try{n()}catch(r){console.error("TimeoutLatch callback error:",r)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class BDe{constructor(){this.interval=null,this.latches=new Set}add(t){this.latches.add(t),this.start()}remove(t){this.latches.delete(t),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(t=>{t.tick(),t.isDone&&this.remove(t)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var nX=null,GEn=()=>typeof window>"u"?new BDe:(nX||(nX=new BDe),nX),UDe=py.define(),YEn=200,XEn=[];function KEn(e){var t=e.value,n=e.selection,r=e.onChange,s=e.onStatistics,a=e.onCreateEditor,i=e.onUpdate,l=e.extensions,c=l===void 0?XEn:l,u=e.autoFocus,d=e.theme,f=d===void 0?"light":d,p=e.height,h=p===void 0?null:p,m=e.minHeight,g=m===void 0?null:m,v=e.maxHeight,b=v===void 0?null:v,w=e.width,S=w===void 0?null:w,O=e.minWidth,_=O===void 0?null:O,C=e.maxWidth,j=C===void 0?null:C,E=e.placeholder,N=E===void 0?"":E,I=e.editable,P=I===void 0?!0:I,$=e.readOnly,B=$===void 0?!1:$,D=e.indentWithTab,V=D===void 0?!0:D,H=e.basicSetup,L=H===void 0?!0:H,F=e.root,z=e.initialState,M=y.useState(),G=M[0],U=M[1],R=y.useState(),q=R[0],W=R[1],X=y.useState(),ne=X[0],ee=X[1],J=y.useState(()=>({current:null}))[0],ie=y.useState(()=>({current:null}))[0],ue=Nt.theme({"&":{height:h,minHeight:g,maxHeight:b,width:S,minWidth:_,maxWidth:j},"& .cm-scroller":{height:"100% !important"}}),Y=Nt.updateListener.of(fe=>{if(fe.docChanged&&typeof r=="function"&&!fe.transactions.some(be=>be.annotation(UDe))){J.current?J.current.reset():(J.current=new QEn(()=>{if(ie.current){var be=ie.current;ie.current=null,be()}J.current=null},YEn),GEn().add(J.current));var se=fe.state.doc,he=se.toString();r(he,fe)}s&&s(WEn(fe))}),te=ZEn({theme:f,editable:P,readOnly:B,placeholder:N,indentWithTab:V,basicSetup:L}),le=[Y,ue,...te];return i&&typeof i=="function"&&le.push(Nt.updateListener.of(i)),le=le.concat(c),y.useLayoutEffect(()=>{if(G&&!ne){var fe={doc:t,selection:n,extensions:le},se=z?os.fromJSON(z.json,fe,z.fields):os.create(fe);if(ee(se),!q){var he=new Nt({state:se,parent:G,root:F});W(he),a&&a(he,se)}}return()=>{q&&(ee(void 0),W(void 0))}},[G,ne]),y.useEffect(()=>{e.container&&U(e.container)},[e.container]),y.useEffect(()=>()=>{q&&(q.destroy(),W(void 0)),J.current&&(J.current.cancel(),J.current=null)},[q]),y.useEffect(()=>{u&&q&&q.focus()},[u,q]),y.useEffect(()=>{q&&q.dispatch({effects:mr.reconfigure.of(le)})},[f,c,h,g,b,S,_,j,N,P,B,V,L,r,i]),y.useEffect(()=>{if(t!==void 0){var fe=q?q.state.doc.toString():"";if(q&&t!==fe){var se=J.current&&!J.current.isDone,he=()=>{q&&t!==q.state.doc.toString()&&q.dispatch({changes:{from:0,to:q.state.doc.toString().length,insert:t||""},annotations:[UDe.of(!0)]})};se?ie.current=he:he()}}},[t,q]),{state:ne,setState:ee,view:q,setView:W,container:G,setContainer:U}}var JEn=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Ou=y.forwardRef((e,t)=>{var n=e.className,r=e.value,s=r===void 0?"":r,a=e.selection,i=e.extensions,l=i===void 0?[]:i,c=e.onChange,u=e.onStatistics,d=e.onCreateEditor,f=e.onUpdate,p=e.autoFocus,h=e.theme,m=h===void 0?"light":h,g=e.height,v=e.minHeight,b=e.maxHeight,w=e.width,S=e.minWidth,O=e.maxWidth,_=e.basicSetup,C=e.placeholder,j=e.indentWithTab,E=e.editable,N=e.readOnly,I=e.root,P=e.initialState,$=tpt(e,JEn),B=y.useRef(null),D=KEn({root:I,value:s,autoFocus:p,theme:m,height:g,minHeight:v,maxHeight:b,width:w,minWidth:S,maxWidth:O,basicSetup:_,placeholder:C,indentWithTab:j,editable:E,readOnly:N,selection:a,onChange:c,onStatistics:u,onCreateEditor:d,onUpdate:f,extensions:l,initialState:P}),V=D.state,H=D.view,L=D.container,F=D.setContainer;y.useImperativeHandle(t,()=>({editor:B.current,state:V,view:H}),[B,L,V,H]);var z=y.useCallback(G=>{B.current=G,F(G)},[F]);if(typeof s!="string")throw new Error("value must be typeof string but got "+typeof s);var M=typeof m=="string"?"cm-theme-"+m:"cm-theme";return o.jsx("div",uO({ref:z,className:""+M+(n?" "+n:"")},$))});Ou.displayName="CodeMirror";const ejn=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Qpt=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();var tjn={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const njn=y.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:i,...l},c)=>y.createElement("svg",{ref:c,...tjn,width:t,height:t,stroke:e,strokeWidth:r?Number(n)*24/Number(t):n,className:Qpt("lucide",s),...l},[...i.map(([u,d])=>y.createElement(u,d)),...Array.isArray(a)?a:[a]]));const gn=(e,t)=>{const n=y.forwardRef(({className:r,...s},a)=>y.createElement(njn,{ref:a,iconNode:t,className:Qpt(`lucide-${ejn(e)}`,r),...s}));return n.displayName=`${e}`,n};const rjn=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],iz=gn("AlignJustify",rjn);const sjn=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],VP=gn("AlignLeft",sjn);const ajn=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],WU=gn("ArrowDown",ajn);const ijn=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],QU=gn("ArrowLeft",ijn);const ojn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],HP=gn("ArrowRight",ojn);const ljn=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],GU=gn("ArrowUp",ljn);const cjn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]],Gpt=gn("Ban",cjn);const ujn=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],rw=gn("Braces",ujn);const djn=[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]],fjn=gn("Brain",djn);const pjn=[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]],qDe=gn("Calendar",pjn);const hjn=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],wx=gn("Check",hjn);const mjn=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ybe=gn("ChevronDown",mjn);const gjn=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],vjn=gn("ChevronLeft",gjn);const yjn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Qj=gn("ChevronRight",yjn);const bjn=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],xjn=gn("ChevronUp",bjn);const wjn=[["path",{d:"m7 20 5-5 5 5",key:"13a0gw"}],["path",{d:"m7 4 5 5 5-5",key:"1kwcof"}]],Xbe=gn("ChevronsDownUp",wjn);const Sjn=[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]],kjn=gn("ChevronsDown",Sjn);const Ojn=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],_jn=gn("ChevronsLeft",Ojn);const Cjn=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],Ypt=gn("ChevronsRight",Cjn);const Ejn=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],h3=gn("ChevronsUpDown",Ejn);const jjn=[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]],Tjn=gn("ChevronsUp",jjn);const Njn=[["path",{d:"M15.6 2.7a10 10 0 1 0 5.7 5.7",key:"1e0p6d"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M13.4 10.6 19 5",key:"1kr7tw"}]],Ijn=gn("CircleGauge",Njn);const Ajn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Xpt=gn("CircleSlash",Ajn);const Rjn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],Pjn=gn("CircleX",Rjn);const $jn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Mjn=gn("Circle",$jn);const Djn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]],Ljn=gn("Clock",Djn);const Fjn=[["path",{d:"M15.536 11.293a1 1 0 0 0 0 1.414l2.376 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1uwlt4"}],["path",{d:"M2.297 11.293a1 1 0 0 0 0 1.414l2.377 2.377a1 1 0 0 0 1.414 0l2.377-2.377a1 1 0 0 0 0-1.414L6.088 8.916a1 1 0 0 0-1.414 0z",key:"10291m"}],["path",{d:"M8.916 17.912a1 1 0 0 0 0 1.415l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.415l-2.377-2.376a1 1 0 0 0-1.414 0z",key:"1tqoq1"}],["path",{d:"M8.916 4.674a1 1 0 0 0 0 1.414l2.377 2.376a1 1 0 0 0 1.414 0l2.377-2.376a1 1 0 0 0 0-1.414l-2.377-2.377a1 1 0 0 0-1.414 0z",key:"1x6lto"}]],zjn=gn("Component",Fjn);const Bjn=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Kpt=gn("Copy",Bjn);const Ujn=[["polyline",{points:"15 10 20 15 15 20",key:"1q7qjw"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]],qjn=gn("CornerDownRight",Ujn);const Vjn=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],Hjn=gn("Download",Vjn);const Zjn=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Wjn=gn("EllipsisVertical",Zjn);const Qjn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}],["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}]],Gjn=gn("EqualNot",Qjn);const Yjn=[["line",{x1:"5",x2:"19",y1:"9",y2:"9",key:"1nwqeh"}],["line",{x1:"5",x2:"19",y1:"15",y2:"15",key:"g8yjpy"}]],Xjn=gn("Equal",Yjn);const Kjn=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],Jjn=gn("Expand",Kjn);const eTn=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Kbe=gn("ExternalLink",eTn);const tTn=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],nTn=gn("Eye",tTn);const rTn=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 15h10",key:"jfw4w8"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],Yde=gn("FileInput",rTn);const sTn=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M4 7V4a2 2 0 0 1 2-2 2 2 0 0 0-2 2",key:"1vk7w2"}],["path",{d:"M4.063 20.999a2 2 0 0 0 2 1L18 22a2 2 0 0 0 2-2V7l-5-5H6",key:"1jink5"}],["path",{d:"m5 11-3 3",key:"1dgrs4"}],["path",{d:"m5 17-3-3h10",key:"1mvvaf"}]],Xde=gn("FileOutput",sTn);const aTn=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],iTn=gn("FileText",aTn);const oTn=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]],lTn=gn("File",oTn);const cTn=[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]],uTn=gn("Filter",cTn);const dTn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3-3-3 3",key:"e37ymu"}],["path",{d:"m15 5-3 3-3-3",key:"19d6lf"}]],fTn=gn("FoldVertical",dTn);const pTn=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],hTn=gn("Folder",pTn);const mTn=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],gTn=gn("Gauge",mTn);const vTn=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Jbe=gn("Hash",vTn);const yTn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Jpt=gn("Info",yTn);const bTn=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],xTn=gn("Keyboard",bTn);const wTn=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],STn=gn("Lightbulb",wTn);const kTn=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],eht=gn("Link2",kTn);const OTn=[["path",{d:"M10 18h4",key:"1ulq68"}],["path",{d:"M11 6H3",key:"1u26ik"}],["path",{d:"M15 6h6",key:"1jlkvy"}],["path",{d:"M18 9V3",key:"xwwp7m"}],["path",{d:"M7 12h8",key:"7a1bxv"}]],_Tn=gn("ListFilterPlus",OTn);const CTn=[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]],ETn=gn("ListTree",CTn);const jTn=[["path",{d:"M11 12H3",key:"51ecnj"}],["path",{d:"M16 6H3",key:"1wxfjs"}],["path",{d:"M16 18H3",key:"12xzn7"}],["path",{d:"m19 10-4 4",key:"1tz659"}],["path",{d:"m15 10 4 4",key:"1n7nei"}]],TTn=gn("ListX",jTn);const NTn=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],exe=gn("List",NTn);const ITn=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ATn=gn("LoaderCircle",ITn);const RTn=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],PTn=gn("Lock",RTn);const $Tn=[["path",{d:"M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4",key:"u53s6r"}],["polyline",{points:"10 17 15 12 10 7",key:"1ail0h"}],["line",{x1:"15",x2:"3",y1:"12",y2:"12",key:"v6grx8"}]],MTn=gn("LogIn",$Tn);const DTn=[["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M3 12h1",key:"lp3yf2"}],["path",{d:"M3 18h1",key:"1eiwyy"}],["path",{d:"M3 6h1",key:"rgxa97"}],["path",{d:"M8 12h1",key:"1con00"}],["path",{d:"M8 18h1",key:"13wk12"}],["path",{d:"M8 6h1",key:"tn6mkg"}]],LTn=gn("Logs",DTn);const FTn=[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]],zTn=gn("Menu",FTn);const BTn=[["path",{d:"M5 12h14",key:"1ays0h"}]],UTn=gn("Minus",BTn);const qTn=[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]],VTn=gn("OctagonAlert",qTn);const HTn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]],ZTn=gn("PanelRight",HTn);const WTn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],txe=gn("Plus",WTn);const QTn=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],tht=gn("Save",QTn);const GTn=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Gj=gn("Search",GTn);const YTn=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]],XTn=gn("ShieldX",YTn);const KTn=[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]],JTn=gn("TextSearch",KTn);const eNn=[["path",{d:"M17 6.1H3",key:"wptmhv"}],["path",{d:"M21 12.1H3",key:"1j38uz"}],["path",{d:"M15.1 18H3",key:"1nb16a"}]],tNn=gn("Text",eNn);const nNn=[["rect",{width:"20",height:"12",x:"2",y:"6",rx:"6",ry:"6",key:"f2vt7d"}],["circle",{cx:"8",cy:"12",r:"2",key:"1nvbw3"}]],nxe=gn("ToggleLeft",nNn);const rNn=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],nht=gn("Trash2",rNn);const sNn=[["polyline",{points:"22 17 13.5 8.5 8.5 13.5 2 7",key:"1r2t7k"}],["polyline",{points:"16 17 22 17 22 11",key:"11uiuu"}]],aNn=gn("TrendingDown",sNn);const iNn=[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]],oNn=gn("TrendingUp",iNn);const lNn=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],YU=gn("TriangleAlert",lNn);const cNn=[["polyline",{points:"4 7 4 4 20 4 20 7",key:"1nosan"}],["line",{x1:"9",x2:"15",y1:"20",y2:"20",key:"swin9y"}],["line",{x1:"12",x2:"12",y1:"4",y2:"20",key:"1tx1rr"}]],rxe=gn("Type",cNn);const uNn=[["path",{d:"M12 22v-6",key:"6o8u61"}],["path",{d:"M12 8V2",key:"1wkif3"}],["path",{d:"M4 12H2",key:"rhcxmi"}],["path",{d:"M10 12H8",key:"s88cx1"}],["path",{d:"M16 12h-2",key:"10asgb"}],["path",{d:"M22 12h-2",key:"14jgyd"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m15 5-3-3-3 3",key:"itvq4r"}]],dNn=gn("UnfoldVertical",uNn);const fNn=[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]],pNn=gn("WandSparkles",fNn);const hNn=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],lf=gn("X",hNn);function mNn(e){if(typeof document>"u")return;let t=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",t.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}const gNn=e=>{switch(e){case"success":return bNn;case"info":return wNn;case"warning":return xNn;case"error":return SNn;default:return null}},vNn=Array(12).fill(0),yNn=({visible:e,className:t})=>De.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},De.createElement("div",{className:"sonner-spinner"},vNn.map((n,r)=>De.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),bNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),xNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),wNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),SNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},De.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),kNn=De.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},De.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),De.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),ONn=()=>{const[e,t]=De.useState(document.hidden);return De.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let Kde=1;class _Nn{constructor(){this.subscribe=t=>(this.subscribers.push(t),()=>{const n=this.subscribers.indexOf(t);this.subscribers.splice(n,1)}),this.publish=t=>{this.subscribers.forEach(n=>n(t))},this.addToast=t=>{this.publish(t),this.toasts=[...this.toasts,t]},this.create=t=>{var n;const{message:r,...s}=t,a=typeof t?.id=="number"||((n=t.id)==null?void 0:n.length)>0?t.id:Kde++,i=this.toasts.find(c=>c.id===a),l=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),i?this.toasts=this.toasts.map(c=>c.id===a?(this.publish({...c,...t,id:a,title:r}),{...c,...t,id:a,dismissible:l,title:r}):c):this.addToast({title:r,...s,dismissible:l,id:a}),a},this.dismiss=t=>(t?(this.dismissedToasts.add(t),requestAnimationFrame(()=>this.subscribers.forEach(n=>n({id:t,dismiss:!0})))):this.toasts.forEach(n=>{this.subscribers.forEach(r=>r({id:n.id,dismiss:!0}))}),t),this.message=(t,n)=>this.create({...n,message:t}),this.error=(t,n)=>this.create({...n,message:t,type:"error"}),this.success=(t,n)=>this.create({...n,type:"success",message:t}),this.info=(t,n)=>this.create({...n,type:"info",message:t}),this.warning=(t,n)=>this.create({...n,type:"warning",message:t}),this.loading=(t,n)=>this.create({...n,type:"loading",message:t}),this.promise=(t,n)=>{if(!n)return;let r;n.loading!==void 0&&(r=this.create({...n,promise:t,type:"loading",message:n.loading,description:typeof n.description!="function"?n.description:void 0}));const s=Promise.resolve(t instanceof Function?t():t);let a=r!==void 0,i;const l=s.then(async u=>{if(i=["resolve",u],De.isValidElement(u))a=!1,this.create({id:r,type:"default",message:u});else if(ENn(u)&&!u.ok){a=!1;const f=typeof n.error=="function"?await n.error(`HTTP error! status: ${u.status}`):n.error,p=typeof n.description=="function"?await n.description(`HTTP error! status: ${u.status}`):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(u instanceof Error){a=!1;const f=typeof n.error=="function"?await n.error(u):n.error,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"error",description:p,...m})}else if(n.success!==void 0){a=!1;const f=typeof n.success=="function"?await n.success(u):n.success,p=typeof n.description=="function"?await n.description(u):n.description,m=typeof f=="object"&&!De.isValidElement(f)?f:{message:f};this.create({id:r,type:"success",description:p,...m})}}).catch(async u=>{if(i=["reject",u],n.error!==void 0){a=!1;const d=typeof n.error=="function"?await n.error(u):n.error,f=typeof n.description=="function"?await n.description(u):n.description,h=typeof d=="object"&&!De.isValidElement(d)?d:{message:d};this.create({id:r,type:"error",description:f,...h})}}).finally(()=>{a&&(this.dismiss(r),r=void 0),n.finally==null||n.finally.call(n)}),c=()=>new Promise((u,d)=>l.then(()=>i[0]==="reject"?d(i[1]):u(i[1])).catch(d));return typeof r!="string"&&typeof r!="number"?{unwrap:c}:Object.assign(r,{unwrap:c})},this.custom=(t,n)=>{const r=n?.id||Kde++;return this.create({jsx:t(r),id:r,...n}),r},this.getActiveToasts=()=>this.toasts.filter(t=>!this.dismissedToasts.has(t.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const Ad=new _Nn,CNn=(e,t)=>{const n=t?.id||Kde++;return Ad.addToast({title:e,...t,id:n}),n},ENn=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",jNn=CNn,TNn=()=>Ad.toasts,NNn=()=>Ad.getActiveToasts(),bu=Object.assign(jNn,{success:Ad.success,info:Ad.info,warning:Ad.warning,error:Ad.error,custom:Ad.custom,message:Ad.message,promise:Ad.promise,dismiss:Ad.dismiss,loading:Ad.loading},{getHistory:TNn,getToasts:NNn});mNn("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function SL(e){return e.label!==void 0}const INn=3,ANn="24px",RNn="16px",VDe=4e3,PNn=356,$Nn=14,MNn=45,DNn=200;function Vg(...e){return e.filter(Boolean).join(" ")}function LNn(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const FNn=e=>{var t,n,r,s,a,i,l,c,u;const{invert:d,toast:f,unstyled:p,interacting:h,setHeights:m,visibleToasts:g,heights:v,index:b,toasts:w,expanded:S,removeToast:O,defaultRichColors:_,closeButton:C,style:j,cancelButtonStyle:E,actionButtonStyle:N,className:I="",descriptionClassName:P="",duration:$,position:B,gap:D,expandByDefault:V,classNames:H,icons:L,closeButtonAriaLabel:F="Close toast"}=e,[z,M]=De.useState(null),[G,U]=De.useState(null),[R,q]=De.useState(!1),[W,X]=De.useState(!1),[ne,ee]=De.useState(!1),[J,ie]=De.useState(!1),[ue,Y]=De.useState(!1),[te,le]=De.useState(0),[fe,se]=De.useState(0),he=De.useRef(f.duration||$||VDe),be=De.useRef(null),we=De.useRef(null),Ie=b===0,ke=b+1<=g,je=f.type,Fe=f.dismissible!==!1,ce=f.className||"",ae=f.descriptionClassName||"",re=De.useMemo(()=>v.findIndex(bt=>bt.toastId===f.id)||0,[v,f.id]),me=De.useMemo(()=>{var bt;return(bt=f.closeButton)!=null?bt:C},[f.closeButton,C]),ye=De.useMemo(()=>f.duration||$||VDe,[f.duration,$]),Te=De.useRef(0),Re=De.useRef(0),Qe=De.useRef(0),Ze=De.useRef(null),[Oe,_e]=B.split("-"),Ce=De.useMemo(()=>v.reduce((bt,It,sn)=>sn>=re?bt:bt+It.height,0),[v,re]),Ee=ONn(),$e=f.invert||d,ze=je==="loading";Re.current=De.useMemo(()=>re*D+Ce,[re,Ce]),De.useEffect(()=>{he.current=ye},[ye]),De.useEffect(()=>{q(!0)},[]),De.useEffect(()=>{const bt=we.current;if(bt){const It=bt.getBoundingClientRect().height;return se(It),m(sn=>[{toastId:f.id,height:It,position:f.position},...sn]),()=>m(sn=>sn.filter(We=>We.toastId!==f.id))}},[m,f.id]),De.useLayoutEffect(()=>{if(!R)return;const bt=we.current,It=bt.style.height;bt.style.height="auto";const sn=bt.getBoundingClientRect().height;bt.style.height=It,se(sn),m(We=>We.find(ct=>ct.toastId===f.id)?We.map(ct=>ct.toastId===f.id?{...ct,height:sn}:ct):[{toastId:f.id,height:sn,position:f.position},...We])},[R,f.title,f.description,m,f.id,f.jsx,f.action,f.cancel]);const Ke=De.useCallback(()=>{X(!0),le(Re.current),m(bt=>bt.filter(It=>It.toastId!==f.id)),setTimeout(()=>{O(f)},DNn)},[f,O,m,Re]);De.useEffect(()=>{if(f.promise&&je==="loading"||f.duration===1/0||f.type==="loading")return;let bt;return S||h||Ee?(()=>{if(Qe.current<Te.current){const We=new Date().getTime()-Te.current;he.current=he.current-We}Qe.current=new Date().getTime()})():he.current!==1/0&&(Te.current=new Date().getTime(),bt=setTimeout(()=>{f.onAutoClose==null||f.onAutoClose.call(f,f),Ke()},he.current)),()=>clearTimeout(bt)},[S,h,f,je,Ee,Ke]),De.useEffect(()=>{f.delete&&(Ke(),f.onDismiss==null||f.onDismiss.call(f,f))},[Ke,f.delete]);function Ye(){var bt;if(L?.loading){var It;return De.createElement("div",{className:Vg(H?.loader,f==null||(It=f.classNames)==null?void 0:It.loader,"sonner-loader"),"data-visible":je==="loading"},L.loading)}return De.createElement(yNn,{className:Vg(H?.loader,f==null||(bt=f.classNames)==null?void 0:bt.loader),visible:je==="loading"})}const Rt=f.icon||L?.[je]||gNn(je);var Ct,en;return De.createElement("li",{tabIndex:0,ref:we,className:Vg(I,ce,H?.toast,f==null||(t=f.classNames)==null?void 0:t.toast,H?.default,H?.[je],f==null||(n=f.classNames)==null?void 0:n[je]),"data-sonner-toast":"","data-rich-colors":(Ct=f.richColors)!=null?Ct:_,"data-styled":!(f.jsx||f.unstyled||p),"data-mounted":R,"data-promise":!!f.promise,"data-swiped":ue,"data-removed":W,"data-visible":ke,"data-y-position":Oe,"data-x-position":_e,"data-index":b,"data-front":Ie,"data-swiping":ne,"data-dismissible":Fe,"data-type":je,"data-invert":$e,"data-swipe-out":J,"data-swipe-direction":G,"data-expanded":!!(S||V&&R),"data-testid":f.testId,style:{"--index":b,"--toasts-before":b,"--z-index":w.length-b,"--offset":`${W?te:Re.current}px`,"--initial-height":V?"auto":`${fe}px`,...j,...f.style},onDragEnd:()=>{ee(!1),M(null),Ze.current=null},onPointerDown:bt=>{bt.button!==2&&(ze||!Fe||(be.current=new Date,le(Re.current),bt.target.setPointerCapture(bt.pointerId),bt.target.tagName!=="BUTTON"&&(ee(!0),Ze.current={x:bt.clientX,y:bt.clientY})))},onPointerUp:()=>{var bt,It,sn;if(J||!Fe)return;Ze.current=null;const We=Number(((bt=we.current)==null?void 0:bt.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),at=Number(((It=we.current)==null?void 0:It.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),ct=new Date().getTime()-((sn=be.current)==null?void 0:sn.getTime()),an=z==="x"?We:at,Xt=Math.abs(an)/ct;if(Math.abs(an)>=MNn||Xt>.11){le(Re.current),f.onDismiss==null||f.onDismiss.call(f,f),U(z==="x"?We>0?"right":"left":at>0?"down":"up"),Ke(),ie(!0);return}else{var On,Ne;(On=we.current)==null||On.style.setProperty("--swipe-amount-x","0px"),(Ne=we.current)==null||Ne.style.setProperty("--swipe-amount-y","0px")}Y(!1),ee(!1),M(null)},onPointerMove:bt=>{var It,sn,We;if(!Ze.current||!Fe||((It=window.getSelection())==null?void 0:It.toString().length)>0)return;const ct=bt.clientY-Ze.current.y,an=bt.clientX-Ze.current.x;var Xt;const On=(Xt=e.swipeDirections)!=null?Xt:LNn(B);!z&&(Math.abs(an)>1||Math.abs(ct)>1)&&M(Math.abs(an)>Math.abs(ct)?"x":"y");let Ne={x:0,y:0};const Le=Me=>1/(1.5+Math.abs(Me)/20);if(z==="y"){if(On.includes("top")||On.includes("bottom"))if(On.includes("top")&&ct<0||On.includes("bottom")&&ct>0)Ne.y=ct;else{const Me=ct*Le(ct);Ne.y=Math.abs(Me)<Math.abs(ct)?Me:ct}}else if(z==="x"&&(On.includes("left")||On.includes("right")))if(On.includes("left")&&an<0||On.includes("right")&&an>0)Ne.x=an;else{const Me=an*Le(an);Ne.x=Math.abs(Me)<Math.abs(an)?Me:an}(Math.abs(Ne.x)>0||Math.abs(Ne.y)>0)&&Y(!0),(sn=we.current)==null||sn.style.setProperty("--swipe-amount-x",`${Ne.x}px`),(We=we.current)==null||We.style.setProperty("--swipe-amount-y",`${Ne.y}px`)}},me&&!f.jsx&&je!=="loading"?De.createElement("button",{"aria-label":F,"data-disabled":ze,"data-close-button":!0,onClick:ze||!Fe?()=>{}:()=>{Ke(),f.onDismiss==null||f.onDismiss.call(f,f)},className:Vg(H?.closeButton,f==null||(r=f.classNames)==null?void 0:r.closeButton)},(en=L?.close)!=null?en:kNn):null,(je||f.icon||f.promise)&&f.icon!==null&&(L?.[je]!==null||f.icon)?De.createElement("div",{"data-icon":"",className:Vg(H?.icon,f==null||(s=f.classNames)==null?void 0:s.icon)},f.promise||f.type==="loading"&&!f.icon?f.icon||Ye():null,f.type!=="loading"?Rt:null):null,De.createElement("div",{"data-content":"",className:Vg(H?.content,f==null||(a=f.classNames)==null?void 0:a.content)},De.createElement("div",{"data-title":"",className:Vg(H?.title,f==null||(i=f.classNames)==null?void 0:i.title)},f.jsx?f.jsx:typeof f.title=="function"?f.title():f.title),f.description?De.createElement("div",{"data-description":"",className:Vg(P,ae,H?.description,f==null||(l=f.classNames)==null?void 0:l.description)},typeof f.description=="function"?f.description():f.description):null),De.isValidElement(f.cancel)?f.cancel:f.cancel&&SL(f.cancel)?De.createElement("button",{"data-button":!0,"data-cancel":!0,style:f.cancelButtonStyle||E,onClick:bt=>{SL(f.cancel)&&Fe&&(f.cancel.onClick==null||f.cancel.onClick.call(f.cancel,bt),Ke())},className:Vg(H?.cancelButton,f==null||(c=f.classNames)==null?void 0:c.cancelButton)},f.cancel.label):null,De.isValidElement(f.action)?f.action:f.action&&SL(f.action)?De.createElement("button",{"data-button":!0,"data-action":!0,style:f.actionButtonStyle||N,onClick:bt=>{SL(f.action)&&(f.action.onClick==null||f.action.onClick.call(f.action,bt),!bt.defaultPrevented&&Ke())},className:Vg(H?.actionButton,f==null||(u=f.classNames)==null?void 0:u.actionButton)},f.action.label):null)};function HDe(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function zNn(e,t){const n={};return[e,t].forEach((r,s)=>{const a=s===1,i=a?"--mobile-offset":"--offset",l=a?RNn:ANn;function c(u){["top","right","bottom","left"].forEach(d=>{n[`${i}-${d}`]=typeof u=="number"?`${u}px`:u})}typeof r=="number"||typeof r=="string"?c(r):typeof r=="object"?["top","right","bottom","left"].forEach(u=>{r[u]===void 0?n[`${i}-${u}`]=l:n[`${i}-${u}`]=typeof r[u]=="number"?`${r[u]}px`:r[u]}):c(l)}),n}const BNn=De.forwardRef(function(t,n){const{id:r,invert:s,position:a="bottom-right",hotkey:i=["altKey","KeyT"],expand:l,closeButton:c,className:u,offset:d,mobileOffset:f,theme:p="light",richColors:h,duration:m,style:g,visibleToasts:v=INn,toastOptions:b,dir:w=HDe(),gap:S=$Nn,icons:O,containerAriaLabel:_="Notifications"}=t,[C,j]=De.useState([]),E=De.useMemo(()=>r?C.filter(R=>R.toasterId===r):C.filter(R=>!R.toasterId),[C,r]),N=De.useMemo(()=>Array.from(new Set([a].concat(E.filter(R=>R.position).map(R=>R.position)))),[E,a]),[I,P]=De.useState([]),[$,B]=De.useState(!1),[D,V]=De.useState(!1),[H,L]=De.useState(p!=="system"?p:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),F=De.useRef(null),z=i.join("+").replace(/Key/g,"").replace(/Digit/g,""),M=De.useRef(null),G=De.useRef(!1),U=De.useCallback(R=>{j(q=>{var W;return(W=q.find(X=>X.id===R.id))!=null&&W.delete||Ad.dismiss(R.id),q.filter(({id:X})=>X!==R.id)})},[]);return De.useEffect(()=>Ad.subscribe(R=>{if(R.dismiss){requestAnimationFrame(()=>{j(q=>q.map(W=>W.id===R.id?{...W,delete:!0}:W))});return}setTimeout(()=>{Pve.flushSync(()=>{j(q=>{const W=q.findIndex(X=>X.id===R.id);return W!==-1?[...q.slice(0,W),{...q[W],...R},...q.slice(W+1)]:[R,...q]})})})}),[C]),De.useEffect(()=>{if(p!=="system"){L(p);return}if(p==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?L("dark"):L("light")),typeof window>"u")return;const R=window.matchMedia("(prefers-color-scheme: dark)");try{R.addEventListener("change",({matches:q})=>{L(q?"dark":"light")})}catch{R.addListener(({matches:W})=>{try{L(W?"dark":"light")}catch(X){console.error(X)}})}},[p]),De.useEffect(()=>{C.length<=1&&B(!1)},[C]),De.useEffect(()=>{const R=q=>{var W;if(i.every(ee=>q[ee]||q.code===ee)){var ne;B(!0),(ne=F.current)==null||ne.focus()}q.code==="Escape"&&(document.activeElement===F.current||(W=F.current)!=null&&W.contains(document.activeElement))&&B(!1)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[i]),De.useEffect(()=>{if(F.current)return()=>{M.current&&(M.current.focus({preventScroll:!0}),M.current=null,G.current=!1)}},[F.current]),De.createElement("section",{ref:n,"aria-label":`${_} ${z}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},N.map((R,q)=>{var W;const[X,ne]=R.split("-");return E.length?De.createElement("ol",{key:R,dir:w==="auto"?HDe():w,tabIndex:-1,ref:F,className:u,"data-sonner-toaster":!0,"data-sonner-theme":H,"data-y-position":X,"data-x-position":ne,style:{"--front-toast-height":`${((W=I[0])==null?void 0:W.height)||0}px`,"--width":`${PNn}px`,"--gap":`${S}px`,...g,...zNn(d,f)},onBlur:ee=>{G.current&&!ee.currentTarget.contains(ee.relatedTarget)&&(G.current=!1,M.current&&(M.current.focus({preventScroll:!0}),M.current=null))},onFocus:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||G.current||(G.current=!0,M.current=ee.relatedTarget)},onMouseEnter:()=>B(!0),onMouseMove:()=>B(!0),onMouseLeave:()=>{D||B(!1)},onDragEnd:()=>B(!1),onPointerDown:ee=>{ee.target instanceof HTMLElement&&ee.target.dataset.dismissible==="false"||V(!0)},onPointerUp:()=>V(!1)},E.filter(ee=>!ee.position&&q===0||ee.position===R).map((ee,J)=>{var ie,ue;return De.createElement(FNn,{key:ee.id,icons:O,index:J,toast:ee,defaultRichColors:h,duration:(ie=b?.duration)!=null?ie:m,className:b?.className,descriptionClassName:b?.descriptionClassName,invert:s,visibleToasts:v,closeButton:(ue=b?.closeButton)!=null?ue:c,interacting:D,position:R,style:b?.style,unstyled:b?.unstyled,classNames:b?.classNames,cancelButtonStyle:b?.cancelButtonStyle,actionButtonStyle:b?.actionButtonStyle,closeButtonAriaLabel:b?.closeButtonAriaLabel,removeToast:U,toasts:E.filter(Y=>Y.position==ee.position),heights:I.filter(Y=>Y.position==ee.position),setHeights:P,expandByDefault:l,gap:S,expanded:$,swipeDirections:t.swipeDirections})})):null}))}),sxe=({className:e,toastOptions:t,...n})=>o.jsx(BNn,{...n,closeButton:!0,richColors:!0,className:K("mastra-toaster",e),toastOptions:{duration:5e3,...t}}),XU=(e,t)=>Array.isArray(e)?e.map(t):t(e),Ue=(e,t={})=>{if(Array.isArray(e))return e.map(n=>bu(n,t));if(De.isValidElement(e)||typeof e=="string")return bu(e,t);throw new Error("Invalid message type")};Ue.success=(e,t={})=>XU(e,n=>bu.success(n,t));Ue.error=(e,t={})=>XU(e,n=>bu.error(n,t));Ue.warning=(e,t={})=>XU(e,n=>bu.warning(n,t));Ue.info=(e,t={})=>XU(e,n=>bu.info(n,t));Ue.custom=(e,t={})=>bu(e,t);Ue.dismiss=e=>bu.dismiss(e);Ue.promise=({myPromise:e,loadingMessage:t,successMessage:n,errorMessage:r,onSuccess:s,onError:a,options:i={}})=>bu.promise(e,{loading:t??"Loading...",success:l=>(s?.(l),n),error:l=>(a?.(l),r||(l instanceof Error?l.message:"Error...")),...i});function og({text:e,copyMessage:t="Copied to clipboard!"}){const[n,r]=y.useState(!1),s=y.useRef(null),a=y.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{Ue.success(t),r(!0),s.current&&(clearTimeout(s.current),s.current=null),s.current=setTimeout(()=>{r(!1)},2e3)}).catch(()=>{Ue.error("Failed to copy to clipboard.")})},[e,t]);return{isCopied:n,handleCopy:a}}function Pa({content:e,copyMessage:t,tooltip:n="Copy to clipboard",size:r="sm",className:s}){const[a,i]=y.useState(!1),{handleCopy:l}=og({text:e,copyMessage:t}),c=()=>{l(),i(!0),setTimeout(()=>i(!1),2e3)};return o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx(pe,{onClick:c,type:"button",size:r,className:s,"aria-label":a?"Copied!":n,children:a?o.jsx(wx,{}):o.jsx(Kpt,{})})}),o.jsx(Hn,{children:a?"Copied!":n})]})}const UNn="mastra-theme",qNn="mastra-playground-store",Jde=e=>e==="dark"||e==="light"||e==="system",VNn=e=>{try{const t=e.getItem(qNn);if(!t)return;const r=JSON.parse(t)?.state?.theme;return Jde(r)?r:void 0}catch{return}},HNn=(e=UNn)=>({get(){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(Jde(t))return t;const n=VNn(window.localStorage);return n?(window.localStorage.setItem(e,n),n):null}catch{return null}},set(t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}},subscribe(t){if(typeof window>"u")return()=>{};const n=r=>{if(r.key===e){if(r.newValue===null){t(null);return}Jde(r.newValue)&&t(r.newValue)}};return window.addEventListener("storage",n),()=>window.removeEventListener("storage",n)}}),rht=y.createContext(null),sht="(prefers-color-scheme: dark)",ZNn=typeof window>"u"?y.useEffect:y.useLayoutEffect,aht=()=>typeof window>"u"||typeof window.matchMedia!="function"||window.matchMedia(sht).matches?"dark":"light",iht=e=>{if(typeof window>"u"||typeof window.matchMedia!="function")return()=>{};const t=window.matchMedia(sht);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)},WNn=(e,t)=>{e.classList.remove(t==="dark"?"light":"dark"),e.classList.add(t)},oht=({children:e,defaultTheme:t="system",storageKey:n,target:r})=>{const s=y.useMemo(()=>HNn(n),[n]),a=y.useRef(null),[i,l]=y.useState(()=>s.get()??t),c=y.useSyncExternalStore(iht,aht,()=>"dark");y.useEffect(()=>s.subscribe(f=>l(f??t)),[s,t]);const u=i==="system"?c:i;ZNn(()=>{const f=r??(typeof window>"u"?null:window.document.documentElement);a.current&&a.current!==f&&a.current.classList.remove("dark","light"),f&&WNn(f,u),a.current=f},[u,r]);const d=y.useMemo(()=>({theme:i,resolvedTheme:u,systemTheme:c,setTheme:f=>{l(f),s.set(f)}}),[i,u,c,s]);return o.jsx(rht.Provider,{value:d,children:e})},QNn=()=>{},gN=()=>{const e=y.useContext(rht),t=y.useSyncExternalStore(iht,aht,()=>"dark");return y.useMemo(()=>e??{theme:"system",resolvedTheme:t,systemTheme:t,setTheme:QNn},[e,t])};function GNn(e){return new iO(hbe.define(e))}const lht=[Im.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return wo(()=>Promise.resolve().then(()=>vL),[],import.meta.url).then(e=>e.javascript())}}),Im.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return wo(()=>Promise.resolve().then(()=>P1n),void 0,import.meta.url).then(e=>e.json())}}),Im.of({name:"JSX",extensions:["jsx"],load(){return wo(()=>Promise.resolve().then(()=>vL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),Im.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return wo(()=>Promise.resolve().then(()=>j_n),void 0,import.meta.url).then(e=>e.markdown())}}),Im.of({name:"TSX",extensions:["tsx"],load(){return wo(()=>Promise.resolve().then(()=>vL),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),Im.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return wo(()=>Promise.resolve().then(()=>vL),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),Im.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return wo(()=>import("./shell-CjFT_Tl9.js"),[],import.meta.url).then(e=>GNn(e.shell))}})];function YNn(e,t=5){if(!e?.properties)return[];const n=[];function r(s,a,i){if(i>t)return;const l=Array.isArray(s.type)?s.type.join(" | "):s.type;if(n.push({path:a,label:a,description:s.description??s.title,type:l}),s.properties)for(const[c,u]of Object.entries(s.properties))r(u,`${a}.${c}`,i+1);if(s.items?.properties)for(const[c,u]of Object.entries(s.items.properties))r(u,`${a}[].${c}`,i+1)}for(const[s,a]of Object.entries(e.properties))r(a,s,1);return n}function XNn(e){const t=YNn(e);return zdt({override:[KNn(t)],defaultKeymap:!0,closeOnBlur:!0,icons:!1})}function KNn(e){return t=>{const r=t.state.sliceDoc(Math.max(0,t.pos-50),t.pos).match(/\{\{([a-zA-Z0-9_.\[\]]*)?$/);if(!r)return null;const s=r[1]??"",a=t.pos-s.length,i=s?e.filter(c=>c.path.toLowerCase().startsWith(s.toLowerCase())):e;if(i.length===0)return null;const l=i.map(c=>({label:c.path,displayLabel:c.path,detail:c.type,info:c.description,apply:(u,d,f,p)=>{const g=u.state.sliceDoc(p,p+2)==="}}"?d.label:`${d.label}}}`;u.dispatch({changes:{from:f,to:p,insert:g},selection:{anchor:f+g.length}})}}));return{from:a,options:l,validFor:/^[a-zA-Z0-9_.\[\]]*$/}}}const JNn=/\{\{([a-zA-Z_][a-zA-Z0-9_]*(?:\.[a-zA-Z_][a-zA-Z0-9_]*)*)\}\}/g,eIn=Cn.mark({class:"cm-variable-highlight"}),ZDe=new edt({regexp:JNn,decoration:()=>eIn}),tIn=po.fromClass(class{decorations;constructor(e){this.decorations=ZDe.createDeco(e)}update(e){this.decorations=ZDe.updateDeco(e,this.decorations)}},{decorations:e=>e.decorations}),nIn=tIn;function rIn(){const e=pN({settings:{fontFamily:"var(--font-mono)",fontSize:"0.8rem",lineHighlight:"transparent",gutterBackground:"transparent",gutterForeground:"var(--neutral2)",background:"transparent",foreground:"var(--neutral6)",caret:"var(--neutral6)"},styles:[{tag:[de.className,de.propertyName],color:"var(--neutral6)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:de.emphasis,fontStyle:"italic",color:"var(--neutral6)"},{tag:de.strong,fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:de.quote,fontStyle:"italic",color:"var(--neutral2)"}]}),t=Nt.theme({".cm-editor":{backgroundColor:"transparent"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{color:"var(--neutral3)"},".cm-cursor":{borderLeftColor:"var(--neutral6)"},".cm-selectionBackground, .cm-content ::selection":{backgroundColor:"color-mix(in srgb, var(--accent3) 22%, transparent)"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}});return[e,t]}function sIn(){const e=Nt.theme({"&":{backgroundColor:"transparent",color:"var(--neutral6)",fontSize:"0.8rem"},"&.cm-editor .cm-scroller":{fontFamily:"var(--font-mono)"},".cm-gutters":{backgroundColor:"transparent",color:"var(--neutral2)",borderRight:"none"},".cm-content":{color:"var(--neutral6)",caretColor:"var(--neutral6)"},".cm-activeLine":{backgroundColor:"transparent"},".cm-lineNumbers .cm-gutterElement":{color:"var(--neutral2)"},".cm-activeLineGutter":{backgroundColor:"transparent",color:"var(--neutral3)"},".cm-cursor, .cm-dropCursor":{borderLeftColor:"var(--neutral6)"},"&.cm-focused .cm-selectionBackground, & .cm-line::selection, & .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{background:"color-mix(in srgb, var(--accent3) 22%, transparent) !important"},".cm-tooltip-autocomplete":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",borderRadius:"6px",boxShadow:"0 8px 16px rgba(0, 0, 0, 0.2)"},".cm-tooltip-autocomplete > ul":{fontFamily:"var(--font-mono)"},".cm-completionLabel":{color:"var(--neutral6)"},".cm-completionDetail":{color:"var(--neutral3)",fontSize:"0.7rem",marginLeft:"auto",paddingLeft:"12px"},".cm-completionInfo":{backgroundColor:"var(--surface2)",border:"1px solid var(--border1)",color:"var(--neutral3)",padding:"8px 12px"},".cm-completionIcon":{display:"none"},"ul.cm-completionList li[aria-selected]":{backgroundColor:"var(--surface4)",color:"var(--neutral6)"},".cm-line .cm-variable-highlight":{color:"var(--accent6) !important",fontWeight:"500"}}),t=wg.define([{tag:[de.comment,de.bracket],color:"var(--neutral2)"},{tag:[de.string,de.meta,de.regexp],color:"var(--accent1)"},{tag:[de.atom,de.bool,de.special(de.variableName)],color:"var(--accent6)"},{tag:[de.keyword,de.operator,de.tagName],color:"var(--accent2)"},{tag:[de.function(de.propertyName),de.propertyName],color:"var(--accent5)"},{tag:[de.definition(de.variableName),de.function(de.variableName),de.className,de.attributeName],color:"var(--accent3)"},{tag:[de.variableName,de.number],color:"var(--accent5)"},{tag:[de.name,de.quote],color:"var(--accent1)"},{tag:de.heading,color:"var(--accent3)",fontWeight:"bold"},{tag:[de.heading1,de.heading2,de.heading3,de.heading4,de.heading5,de.heading6],color:"var(--accent3)",fontWeight:"bold"},{tag:[de.emphasis],fontStyle:"italic",color:"var(--neutral6)"},{tag:[de.strong],fontWeight:"bold",color:"var(--neutral6)"},{tag:de.link,color:"var(--accent3)",textDecoration:"underline"},{tag:de.url,color:"var(--accent3)"},{tag:de.monospace,color:"var(--neutral6)"},{tag:de.strikethrough,textDecoration:"line-through"},{tag:[de.deleted],color:"var(--accent2)"},{tag:de.invalid,color:"var(--error)"},{tag:[de.standard(de.tagName)],color:"var(--accent1)"}]);return[e,S1(t)]}const Sx=()=>{const e=gN().resolvedTheme==="dark";return y.useMemo(()=>e?rIn():sIn(),[e])},Kr=y.forwardRef(({data:e,value:t,onChange:n,showCopyButton:r=!0,className:s,language:a="json",highlightVariables:i=!1,placeholder:l,schema:c,autoFocus:u,lineNumbers:d=!0,editable:f,...p},h)=>{const m=Sx(),g=e?JSON.stringify(e,null,2):t??"",v=y.useMemo(()=>{const b=[];return a==="json"?b.push(vp):a==="markdown"&&(b.push(Bbe({base:cO,codeLanguages:lht})),b.push(Nt.lineWrapping)),i&&a==="markdown"&&b.push(nIn),c&&a==="markdown"&&b.push(XNn(c)),f===!1&&b.push(os.readOnly.of(!0)),b},[a,i,c,f]);return o.jsxs("div",{className:K("rounded-md bg-surface3 p-1 font-mono relative border border-border1 overflow-hidden",s),...p,children:[r&&o.jsx(Pa,{content:g,className:"absolute top-2 right-2 z-20"}),o.jsx(Ou,{ref:h,value:g,theme:m,extensions:v,onChange:n,editable:f,"aria-label":"Code editor",placeholder:l,height:"100%",style:{height:"100%"},autoFocus:u,basicSetup:{lineNumbers:d}})]})}),aIn={js:"javascript",javascript:"javascript",mjs:"javascript",cjs:"javascript",node:"javascript",ts:"typescript",typescript:"typescript",mts:"typescript",cts:"typescript",tsx:"tsx",jsx:"jsx",json:"json",json5:"json",md:"markdown",markdown:"markdown",py:"python",python:"python",sh:"bash",bash:"bash",shell:"bash",zsh:"bash"};let rX=null;function iIn(){return rX||(rX=(async()=>{const[{createHighlighterCore:e},{createJavaScriptRegexEngine:t}]=await Promise.all([wo(()=>import("./core-DhS8L9Xh.js"),__vite__mapDeps([0,1,2]),import.meta.url),wo(()=>import("./engine-javascript-CSIo_1eZ.js"),__vite__mapDeps([3,1]),import.meta.url)]);return e({themes:[wo(()=>import("./github-light-DAi9KRSo.js"),[],import.meta.url),wo(()=>import("./github-dark-DHJKELXO.js"),[],import.meta.url)],langs:[wo(()=>import("./javascript-ySlJ1b_l.js"),[],import.meta.url),wo(()=>import("./typescript-Dj6nwHGl.js"),[],import.meta.url),wo(()=>import("./tsx-B6W0miNI.js"),[],import.meta.url),wo(()=>import("./jsx-BAng5TT0.js"),[],import.meta.url),wo(()=>import("./json-BQoSv7ci.js"),[],import.meta.url),wo(()=>import("./bash-atvbtKCR.js"),[],import.meta.url),wo(()=>import("./markdown-UIAJJxZW.js"),[],import.meta.url),wo(()=>import("./python-DhUJRlN_.js"),[],import.meta.url)],engine:t()})})()),rX}async function oIn(e,t){const n=aIn[t?.toLowerCase()];if(!n)return null;const r=await iIn(),{tokens:s}=r.codeToTokens(e,{lang:n,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return s}function Qr({iconSlot:e,titleSlot:t,descriptionSlot:n,actionSlot:r,className:s,as:a="h3"}){return o.jsxs("div",{className:K("flex flex-col items-center justify-center text-center py-10 px-6","transition-opacity duration-normal ease-out-custom",s),children:[e&&o.jsx("div",{className:"mb-4",children:e}),o.jsx(a,{className:"font-medium text-neutral5 text-ui-md",children:t}),n&&o.jsx("p",{className:"mt-1.5 text-neutral3 text-ui-sm max-w-md",children:n}),r&&o.jsx("div",{className:"mt-5",children:r})]})}const gf=({children:e,className:t,onClick:n})=>o.jsx("div",{tabIndex:n?0:void 0,onKeyDown:r=>{n&&(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),n?.())},className:K("flex gap-3 group/entity bg-surface3 rounded-xl border border-border1 py-3 px-4",n&&"cursor-pointer hover:bg-surface4 transition-all",t),onClick:n,children:e}),cht=({children:e,className:t,style:n})=>o.jsx(Ge,{size:"lg",className:K("text-neutral3 mt-1 shrink-0",t),style:n,children:e}),vf=({children:e,className:t})=>o.jsx(ge,{as:"p",variant:"ui-lg",className:K("text-neutral6 font-medium",t),children:e}),Mp=({children:e,className:t})=>o.jsx(ge,{as:"div",variant:"ui-sm",className:K("text-neutral3",t),children:e}),yf=({children:e,className:t})=>o.jsx("div",{className:K("flex-1 w-full",t),children:e});function ks({resource:e,title:t,description:n,actionSlot:r,className:s}){const a="Permission Denied",i=e?`You don't have permission to access ${e}. Contact your administrator for access.`:"You don't have permission to access this resource. Contact your administrator for access.";return o.jsx(Qr,{className:s,iconSlot:o.jsx(Ge,{size:"lg",className:"text-neutral3",children:o.jsx(XTn,{})}),titleSlot:t??a,descriptionSlot:n??i,actionSlot:r})}function Ms({title:e,description:t,className:n}){const[r,s]=y.useState(!1),a=He(),i=y.useCallback(async()=>{try{s(!0);const{baseUrl:l="",apiPrefix:c}=a.options||{},u=(c||"/api").trim(),d=(u.startsWith("/")?u:`/${u}`).replace(/\/$/,""),f=new URLSearchParams({redirect_uri:window.location.href}),p=`${l}${d}/auth/sso/login?${f}`,h=await fetch(p,{credentials:"include",headers:{"Content-Type":"application/json"}});if(h.ok){const m=await h.json();window.location.href=m.url}}finally{s(!1)}},[a]);return o.jsx(Qr,{className:n,iconSlot:o.jsx(Ge,{size:"lg",className:"text-neutral3",children:o.jsx(MTn,{})}),titleSlot:e??"Session Expired",descriptionSlot:t??"Your session has expired. Please log in again to continue.",actionSlot:o.jsx(pe,{variant:"default",onClick:i,disabled:r,children:r?"Redirecting...":"Log in"})})}const axe=({children:e,border:t=!0,className:n})=>o.jsx("header",{className:K("h-header-default z-50 flex w-full items-center gap-4 bg-transparent px-3",{"border-b border-border1":t},n),children:e}),uht=({children:e})=>o.jsx(ge,{as:"h1",variant:"ui-md",className:"text-neutral6 flex items-center gap-2",children:e}),lIn=({children:e})=>o.jsx("div",{className:"ml-auto flex items-center gap-3",children:e}),Th=e=>o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 34 21",fill:"none",...e,children:o.jsx("path",{d:"M4.49805 11.6934C6.98237 11.6934 8.99609 13.7081 8.99609 16.1924C8.9959 18.6765 6.98225 20.6904 4.49805 20.6904C2.01394 20.6903 0.000196352 18.6765 0 16.1924C0 13.7081 2.01382 11.6935 4.49805 11.6934ZM10.3867 0C12.8709 0 14.8846 2.01388 14.8848 4.49805C14.8848 4.8377 14.847 5.16846 14.7755 5.48643C14.4618 6.88139 14.1953 8.4633 14.9928 9.65L16.2575 11.5319C16.3363 11.6491 16.4727 11.7115 16.6137 11.703C16.7369 11.6957 16.8525 11.6343 16.9214 11.5318L18.1876 9.64717C18.9772 8.47198 18.7236 6.90783 18.4205 5.52484C18.3523 5.21392 18.3164 4.89094 18.3164 4.55957C18.3167 2.07546 20.3313 0.0615234 22.8154 0.0615234C25.2994 0.0617476 27.3132 2.0756 27.3135 4.55957C27.3135 4.93883 27.2665 5.30712 27.178 5.65896C26.8547 6.94441 26.5817 8.37932 27.2446 9.52714L28.459 11.6301C28.4819 11.6697 28.5245 11.6934 28.5703 11.6934C31.0545 11.6935 33.0684 13.7081 33.0684 16.1924C33.0682 18.6765 31.0544 20.6903 28.5703 20.6904C26.0861 20.6904 24.0725 18.6765 24.0723 16.1924C24.0723 15.8049 24.1212 15.4288 24.2133 15.0701C24.5458 13.7746 24.8298 12.3251 24.1609 11.1668L23.0044 9.16384C22.9656 9.09659 22.8931 9.05859 22.8154 9.05859C22.7983 9.05859 22.7824 9.06614 22.7728 9.08033L21.4896 10.9895C20.686 12.1851 20.9622 13.781 21.284 15.1851C21.3582 15.5089 21.3975 15.8461 21.3975 16.1924C21.3973 18.6764 19.3834 20.6902 16.8994 20.6904C14.4152 20.6904 12.4006 18.6765 12.4004 16.1924C12.4004 15.932 12.4226 15.6768 12.4651 15.4286C12.6859 14.14 12.8459 12.7122 12.1167 11.6271L11.2419 10.3253C10.6829 9.49347 9.71913 9.05932 8.78286 8.70188C7.0906 8.05584 5.88867 6.41734 5.88867 4.49805C5.88886 2.0139 7.90254 3.29835e-05 10.3867 0Z",fill:"currentColor"})}),cIn={default:"[&>tbody>tr]:h-table-row",small:"[&>tbody>tr]:h-table-row-small"},uIn=({className:e,children:t,size:n="default",style:r})=>o.jsx("table",{className:K("w-full",cIn[n],e),style:r,children:t}),dIn=({className:e,children:t})=>o.jsx("thead",{children:o.jsx("tr",{className:K("h-table-header border-b border-border1 bg-surface2/80",e),children:t})}),fIn=({className:e,children:t,...n})=>o.jsx("th",{className:K("text-neutral2 text-ui-xs h-full whitespace-nowrap text-left font-medium uppercase tracking-wide first:pl-3 last:pr-3",e),...n,children:t}),pIn=({className:e,children:t,...n})=>o.jsx("tbody",{className:K("",e),...n,children:t}),hIn=y.forwardRef(({className:e,children:t,selected:n=!1,style:r,onClick:s,isActive:a=!1,...i},l)=>{const c=y.useRef(null);y.useEffect(()=>{l&&(typeof l=="function"?l(c.current):l.current=c.current)},[l]),y.useEffect(()=>{a&&c.current&&(c.current.focus(),c.current.scrollIntoView({block:"nearest"}))},[a]);const u=d=>{d.key==="Enter"&&s&&s()};return o.jsx("tr",{className:K("border-b border-border1","transition-colors duration-normal ease-out-custom","hover:bg-surface3","focus:bg-surface3 focus:outline-hidden focus:ring-1 focus:ring-inset focus:ring-accent1/50",n&&"bg-surface4",s&&"cursor-pointer",e),style:r,onClick:s,ref:c,tabIndex:s?0:void 0,onKeyDown:u,"data-active":a||void 0,...i,children:t})}),mIn=({className:e,children:t,...n})=>o.jsx("td",{className:K("text-neutral5 first:pl-3 last:pr-3",e),...n,children:o.jsx("div",{className:K("flex h-full w-full shrink-0 items-center"),children:t})}),gIn=Wc(K("flex w-full text-neutral6 border bg-transparent","transition-all duration-normal ease-out-custom","placeholder:text-neutral2 placeholder:transition-opacity placeholder:duration-normal","focus:placeholder:opacity-70","min-h-[80px] resize-y"),{variants:{variant:{default:K(jF,"rounded-xl",Ck),filled:K(jF,"rounded-xl",Ck),outline:K(kct,"rounded-xl",Ck),unstyled:Oct},size:{sm:"px-2 py-1.5 text-ui-sm",md:"px-3 py-2 text-ui-md",default:"px-3 py-2 text-ui-md",lg:"px-4 py-3 text-ui-lg"}},defaultVariants:{variant:"default",size:"default"}}),Ul=y.forwardRef(({className:e,size:t,testId:n,variant:r,error:s,...a},i)=>o.jsx("textarea",{className:K(gIn({variant:r,size:t}),s&&"border-error focus-visible:border-error",e),"data-testid":n,ref:i,"aria-invalid":s,...a}));Ul.displayName="Textarea";let WDe={},QDe={},GDe="";function vIn(e){if(typeof document>"u")return!1;const t=dr(e);return Xs(t).innerWidth-t.documentElement.clientWidth>0}function yIn(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=dr(e),r=n.documentElement,s=n.body,a=b1(r)?r:s,i=a.style.overflowY,l=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const c=a.offsetWidth;a.style.overflowY="hidden";const u=a.offsetWidth;return a.style.overflowY=i,r.style.scrollbarGutter=l,c===u}function bIn(e){const t=dr(e),n=t.documentElement,r=t.body,s=b1(n)?n:r,a={overflowY:s.style.overflowY,overflowX:s.style.overflowX};return Object.assign(s.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(s.style,a)}}function xIn(e){const t=dr(e),n=t.documentElement,r=t.body,s=Xs(n);let a=0,i=0,l=!1;const c=Pd.create();if(gU&&(s.visualViewport?.scale??1)!==1)return()=>{};function u(){const h=s.getComputedStyle(n),m=s.getComputedStyle(r),b=(h.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,i=n.scrollLeft,WDe={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},GDe=n.style.scrollBehavior,QDe={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const w=n.scrollHeight>n.clientHeight,S=n.scrollWidth>n.clientWidth,O=h.overflowY==="scroll"||m.overflowY==="scroll",_=h.overflowX==="scroll"||m.overflowX==="scroll",C=Math.max(0,s.innerWidth-r.clientWidth),j=Math.max(0,s.innerHeight-r.clientHeight),E=parseFloat(m.marginTop)+parseFloat(m.marginBottom),N=parseFloat(m.marginLeft)+parseFloat(m.marginRight),I=b1(n)?n:r;if(l=yIn(e),l){n.style.scrollbarGutter=b,I.style.overflowY="hidden",I.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:b,overflowY:"hidden",overflowX:"hidden"}),(w||O)&&(n.style.overflowY="scroll"),(S||_)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:E||j?`calc(100dvh - ${E+j}px)`:"100dvh",width:N||C?`calc(100vw - ${N+C}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=i,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function d(){Object.assign(n.style,WDe),Object.assign(r.style,QDe),l||(n.scrollTop=a,n.scrollLeft=i,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=GDe)}function f(){d(),c.request(u)}u();const p=Br(s,"resize",f);return()=>{c.cancel(),d(),typeof s.removeEventListener=="function"&&p()}}class wIn{lockCount=0;restore=null;timeoutLock=Fh.create();timeoutUnlock=Fh.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=dr(t).documentElement,s=Xs(r).getComputedStyle(r).overflowY;if(s==="hidden"||s==="clip"){this.restore=ga;return}const a=mye||!vIn(t);this.restore=a?bIn(t):xIn(t)}}const SIn=new wIn;function dht(e=!0,t=null){Tt(()=>{if(e)return SIn.acquire(t)},[e,t])}function kIn(e){const{store:t,parentContext:n,actionsRef:r,isDrawer:s}=e,a=t.useState("open");dct(t,a),JM(t);const{forceUnmount:i}=e3(a,t),l=y.useCallback(()=>{t.setOpen(!1,qt(GM))},[t]);return y.useImperativeHandle(r,()=>({unmount:i,close:l}),[i,l]),{parentContext:n,isDrawer:s}}function OIn({store:e,dialogRoot:t}){const{parentContext:n,isDrawer:r}=t,s=e.useState("open"),a=e.useState("disablePointerDismissal"),i=e.useState("modal"),l=e.useState("popupElement"),c=e.useState("floatingRootContext"),[u,d]=y.useState(0),[f,p]=y.useState(0),h=u===0,m=l_(c,{outsidePressEvent(){return e.context.internalBackdropRef.current||e.context.backdropRef.current?"intentional":{mouse:i==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(w){if(!e.context.outsidePressEnabledRef.current||"button"in w&&w.button!==0||"touches"in w&&w.touches.length!==1)return!1;const S=Si(w);if(h&&!a){const O=S;return i&&(e.context.internalBackdropRef.current||e.context.backdropRef.current)?e.context.internalBackdropRef.current===O||e.context.backdropRef.current===O||dn(O,l)&&!O?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:h});dht(s&&i===!0,l),e.useContextCallback("onNestedDialogOpen",(w,S)=>{d(w),p(S)}),e.useContextCallback("onNestedDialogClose",()=>{d(0),p(0)}),y.useEffect(()=>(n?.onNestedDialogOpen&&s&&n.onNestedDialogOpen(u+1,f+(r?1:0)),n?.onNestedDialogClose&&!s&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&s&&n.onNestedDialogClose()}),[r,s,u,f,n]);const g=m.reference??vs,v=m.trigger??vs,b=y.useMemo(()=>Eo(dy,m.floating),[m.floating]);return t3(e,{activeTriggerProps:g,inactiveTriggerProps:v,popupProps:b,nestedOpenDialogCount:u,nestedOpenDrawerCount:f}),null}const ixe=y.createContext(!1),fht=y.createContext(void 0);function gd(e){const t=y.useContext(fht);if(e===!1&&t===void 0)throw new Error(yr(27));return t}const _In={...r3,modal:lt(e=>e.modal),nested:lt(e=>e.nested),nestedOpenDialogCount:lt(e=>e.nestedOpenDialogCount),nestedOpenDrawerCount:lt(e=>e.nestedOpenDrawerCount),disablePointerDismissal:lt(e=>e.disablePointerDismissal),openMethod:lt(e=>e.openMethod),descriptionElementId:lt(e=>e.descriptionElementId),titleElementId:lt(e=>e.titleElementId),viewportElement:lt(e=>e.viewportElement),role:lt(e=>e.role)};class oxe extends rN{constructor(t,n,r=!1){const s=new c_,a=CIn(t);a.floatingRootContext=_U(s,n,r),super(a,{popupRef:y.createRef(),backdropRef:y.createRef(),internalBackdropRef:y.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:s,onOpenChange:void 0,onOpenChangeComplete:void 0},_In)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(t,n);const r={open:t};OU(r,t,n.trigger),this.update(r)};static useStore(t,n){return kU(t,(s,a)=>new oxe(n,s,a),!0).store}}function CIn(e={}){return{...n3(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,nestedOpenDrawerCount:0,role:"dialog",...e}}function pht(e,t="dialog"){const{children:n,open:r,defaultOpen:s=!1,onOpenChange:a,onOpenChangeComplete:i,disablePointerDismissal:l=!1,modal:c=!0,actionsRef:u,handle:d,triggerId:f,defaultTriggerId:p=null}=e,h=t==="drawer",m=t==="alert-dialog",g=m?!0:c,v=m||l,b=m?"alertdialog":"dialog",w=gd(!0),O={modal:g,disablePointerDismissal:v,nested:!!w,role:b},_=oxe.useStore(d?.store,{open:s,openProp:r,activeTriggerId:p,triggerIdProp:f,...O});s_(()=>{const $=r===void 0&&_.state.open===!1&&s===!0?{open:!0,activeTriggerId:p}:null;m?_.update($?{...O,...$}:O):$&&_.update($)}),_.useControlledProp("openProp",r),_.useControlledProp("triggerIdProp",f),_.useSyncedValues(O),_.useContextCallback("onOpenChange",a),_.useContextCallback("onOpenChangeComplete",i);const C=_.useState("open"),j=_.useState("mounted"),E=_.useState("payload"),N=kIn({store:_,actionsRef:u,parentContext:w?.store.context,isDrawer:h}),I=C||j,P=y.useMemo(()=>({store:_}),[_]);return o.jsx(ixe.Provider,{value:!1,children:o.jsxs(fht.Provider,{value:P,children:[I&&o.jsx(OIn,{store:_,dialogRoot:N}),typeof n=="function"?n({payload:E}):n]})})}function EIn(e){return pht(e,"alert-dialog")}const jIn={...mf,...ql},lxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,forceRender:i=!1,...l}=t,{store:c}=gd(),u=c.useState("open"),d=c.useState("nested"),f=c.useState("mounted"),p=c.useState("transitionStatus");return En("div",t,{state:{open:u,transitionStatus:p},ref:[c.context.backdropRef,n],stateAttributesMapping:jIn,props:[{role:"presentation",hidden:!f,style:{userSelect:"none",WebkitUserSelect:"none"}},l],enabled:i||!d})}),hht=y.createContext(void 0);function cxe(e=!1){const t=y.useContext(hht);if(t===void 0&&!e)throw new Error(yr(16));return t}function TIn(e){const{focusableWhenDisabled:t,disabled:n,composite:r=!1,tabIndex:s=0,isNativeButton:a}=e,i=r&&t!==!1,l=r&&t===!1;return{props:y.useMemo(()=>{const u={onKeyDown(d){n&&t&&d.key!=="Tab"&&d.preventDefault()}};return r||(u.tabIndex=s,!a&&n&&(u.tabIndex=t?s:-1)),(a&&(t||i)||!a&&n)&&(u["aria-disabled"]=n),a&&(!t||l)&&(u.disabled=n),u},[r,n,t,i,l,a,s])}}function vd(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:r=0,native:s=!0,composite:a}=e,i=y.useRef(null),l=cxe(!0),c=a??l!==void 0,{props:u}=TIn({focusableWhenDisabled:n,disabled:t,composite:c,tabIndex:r,isNativeButton:s}),d=y.useCallback(()=>{const h=i.current;sX(h)&&c&&t&&u.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,u.disabled,c]);Tt(d,[d]);const f=y.useCallback((h={})=>{const{onClick:m,onMouseDown:g,onKeyUp:v,onKeyDown:b,onPointerDown:w,...S}=h;return Eo({onClick(O){if(t){O.preventDefault();return}m?.(O)},onMouseDown(O){t||g?.(O)},onKeyDown(O){if(t||(kF(O),b?.(O),O.baseUIHandlerPrevented))return;const _=O.target===O.currentTarget,C=O.currentTarget,j=sX(C),E=!s&&NIn(C),N=_&&(s?j:!E),I=O.key==="Enter",P=O.key===" ",$=C.getAttribute("role"),B=$?.startsWith("menuitem")||$==="option"||$==="gridcell";if(_&&c&&P){if(O.defaultPrevented&&B)return;O.preventDefault(),E||s&&j?(C.click(),O.preventBaseUIHandler()):N&&(m?.(O),O.preventBaseUIHandler());return}N&&(!s&&(P||I)&&O.preventDefault(),!s&&I&&m?.(O))},onKeyUp(O){if(!t){if(kF(O),v?.(O),O.target===O.currentTarget&&s&&c&&sX(O.currentTarget)&&O.key===" "){O.preventDefault();return}O.baseUIHandlerPrevented||O.target===O.currentTarget&&!s&&!c&&O.key===" "&&m?.(O)}},onPointerDown(O){if(t){O.preventDefault();return}w?.(O)}},s?{type:"button"}:{role:"button"},u,S)},[t,u,c,s]),p=mt(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:p}}function sX(e){return _a(e)&&e.tagName==="BUTTON"}function NIn(e){return!!(e?.tagName==="A"&&e?.href)}const m3=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,...c}=t,{store:u}=gd(),d=u.useState("open"),{getButtonProps:f,buttonRef:p}=vd({disabled:i,native:l}),h={disabled:i};function m(g){d&&u.setOpen(!1,qt(yye,g.nativeEvent))}return En("button",t,{state:h,ref:[n,p],props:[{onClick:m},c,f]})}),KU=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=gd(),u=Mi(i);return c.useSyncedValueWithCleanup("descriptionElementId",u),En("p",t,{ref:n,props:[{id:u},l]})});let IIn=(function(e){return e.nestedDialogs="--nested-dialogs",e})({}),AIn=(function(e){return e[e.open=ed.open]="open",e[e.closed=ed.closed]="closed",e[e.startingStyle=ed.startingStyle]="startingStyle",e[e.endingStyle=ed.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const mht=y.createContext(void 0);function uxe(){const e=y.useContext(mht);if(e===void 0)throw new Error(yr(26));return e}const aj="ArrowUp",pk="ArrowDown",ZP="ArrowLeft",ij="ArrowRight",g3="Home",v3="End",ght="PageUp",vht="PageDown",yht=new Set([ZP,ij]),RIn=new Set([ZP,ij,g3,v3]),bht=new Set([aj,pk]),PIn=new Set([aj,pk,g3,v3]),xht=new Set([...yht,...bht]),O1=new Set([...xht,g3,v3]),wht="Shift",$In="Control",MIn="Alt",DIn="Meta",LIn=new Set([wht,$In,MIn,DIn]);function FIn(e){return _a(e)&&e.tagName==="INPUT"}function YDe(e){return!!(FIn(e)&&e.selectionStart!=null||_a(e)&&e.tagName==="TEXTAREA")}function XDe(e,t,n,r){if(!e||!t||!t.scrollTo)return;let s=e.scrollLeft,a=e.scrollTop;const i=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(i&&r!=="vertical"){const c=KDe(e,t,"left"),u=kL(e),d=kL(t);n==="ltr"&&(c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight?s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight:c-d.scrollMarginLeft<e.scrollLeft+u.scrollPaddingLeft&&(s=c-d.scrollMarginLeft-u.scrollPaddingLeft)),n==="rtl"&&(c-d.scrollMarginRight<e.scrollLeft+u.scrollPaddingLeft?s=c-d.scrollMarginLeft-u.scrollPaddingLeft:c+t.offsetWidth+d.scrollMarginRight>e.scrollLeft+e.clientWidth-u.scrollPaddingRight&&(s=c+t.offsetWidth+d.scrollMarginRight-e.clientWidth+u.scrollPaddingRight))}if(l&&r!=="horizontal"){const c=KDe(e,t,"top"),u=kL(e),d=kL(t);c-d.scrollMarginTop<e.scrollTop+u.scrollPaddingTop?a=c-d.scrollMarginTop-u.scrollPaddingTop:c+t.offsetHeight+d.scrollMarginBottom>e.scrollTop+e.clientHeight-u.scrollPaddingBottom&&(a=c+t.offsetHeight+d.scrollMarginBottom-e.clientHeight+u.scrollPaddingBottom)}e.scrollTo({left:s,top:a,behavior:"auto"})}function KDe(e,t,n){const r=n==="left"?"offsetLeft":"offsetTop";let s=0;for(;t.offsetParent&&(s+=t[r],t.offsetParent!==e);)t=t.offsetParent;return s}function kL(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const zIn={...mf,...ql,nestedDialogOpen(e){return e?{[AIn.nestedDialogOpen]:""}:null}},dxe=y.forwardRef(function(t,n){const{render:r,className:s,style:a,finalFocus:i,initialFocus:l,...c}=t,{store:u}=gd(),d=u.useState("descriptionElementId"),f=u.useState("disablePointerDismissal"),p=u.useState("floatingRootContext"),h=u.useState("popupProps"),m=u.useState("modal"),g=u.useState("mounted"),v=u.useState("nested"),b=u.useState("nestedOpenDialogCount"),w=u.useState("open"),S=u.useState("openMethod"),O=u.useState("titleElementId"),_=u.useState("transitionStatus"),C=u.useState("role"),j=p.useState("floatingId"),E=c.id??j;uxe(),Vl({open:w,ref:u.context.popupRef,onComplete(){w&&u.context.onOpenChangeComplete?.(!0)}});function N(V){return V==="touch"?u.context.popupRef.current:!0}const I=l===void 0?N:l,P=b>0,$=u.useStateSetter("popupElement"),D=En("div",t,{state:{open:w,nested:v,transitionStatus:_,nestedDialogOpen:P},props:[h,{id:E,"aria-labelledby":O??void 0,"aria-describedby":d??void 0,role:C,...dy,hidden:!g,onKeyDown(V){O1.has(V.key)&&V.stopPropagation()},style:{[IIn.nestedDialogs]:b}},c],ref:[n,u.context.popupRef,$],stateAttributesMapping:zIn});return o.jsx(nN,{context:p,openInteractionType:S,disabled:!g,closeOnFocusOut:!f,initialFocus:I,returnFocus:i,modal:m!==!1,restoreFocus:"popup",children:D})}),y3=y.forwardRef(function(t,n){const{cutout:r,...s}=t;let a;if(r){const i=r.getBoundingClientRect();a=`polygon(0% 0%,100% 0%,100% 100%,0% 100%,0% 0%,${i.left}px ${i.top}px,${i.left}px ${i.bottom}px,${i.right}px ${i.bottom}px,${i.right}px ${i.top}px,${i.left}px ${i.top}px)`}return o.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...s,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),JU=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,{store:a}=gd(),i=a.useState("mounted"),l=a.useState("modal"),c=a.useState("open");return i||r?o.jsx(mht.Provider,{value:r,children:o.jsxs(XM,{ref:n,...s,children:[i&&l===!0&&o.jsx(y3,{ref:a.context.internalBackdropRef,inert:oN(!c)}),t.children]})}):null}),eq=y.forwardRef(function(t,n){const{render:r,className:s,style:a,id:i,...l}=t,{store:c}=gd(),u=Mi(i);return c.useSyncedValueWithCleanup("titleElementId",u),En("h2",t,{ref:n,props:[{id:u},l]})});function BIn(e){const t=y.useRef(""),n=y.useCallback(s=>{s.defaultPrevented||(t.current=s.pointerType,e(s,s.pointerType))},[e]);return{onClick:y.useCallback(s=>{if(s.detail===0){e(s,"keyboard");return}"pointerType"in s?e(s,s.pointerType):e(s,t.current),t.current=""},[e]),onPointerDown:n}}function wv(e,t){const n=y.useRef(e),r=mt(t);Tt(()=>{n.current!==e&&r(n.current)},[e,r]),Tt(()=>{n.current=e},[e])}function fxe(e,t){const n=mt((a,i)=>{(typeof e=="function"?e():e)||t(i||(mye?"touch":""))}),{onClick:r,onPointerDown:s}=BIn(n);return y.useMemo(()=>({onClick:r,onPointerDown:s}),[r,s])}function pxe(e){const[t,n]=y.useState(null),r=fxe(e,n);return wv(e,s=>{s&&!e&&n(null)}),y.useMemo(()=>({openMethod:t,triggerProps:r}),[t,r])}const Sht=y.forwardRef(function(t,n){const{render:r,className:s,style:a,disabled:i=!1,nativeButton:l=!0,id:c,payload:u,handle:d,...f}=t,p=gd(!0),h=d?.store??p?.store;if(!h)throw new Error(yr(79));const m=Mi(c),g=h.useState("floatingRootContext"),v=h.useState("isOpenedByTrigger",m),b=h.useState("triggerPopupId",m),w=y.useRef(null),{registerTrigger:S,isMountedByThisTrigger:O}=KM(m,w,h,{payload:u}),{getButtonProps:_,buttonRef:C}=vd({disabled:i,native:l}),j=o_(g,{enabled:g!=null}),E=fxe(()=>h.select("open"),P=>{h.set("openMethod",P)}),N={disabled:i,open:v},I=h.useState("triggerProps",O);return En("button",t,{state:N,ref:[C,n,S,w],props:[j.reference,I,E,{[_ye]:"",id:m,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":b},f,_],stateAttributesMapping:sN})}),UIn=Sht;let JDe=(function(e){return e[e.open=ed.open]="open",e[e.closed=ed.closed]="closed",e[e.startingStyle=ed.startingStyle]="startingStyle",e[e.endingStyle=ed.endingStyle]="endingStyle",e.nested="data-nested",e.nestedDialogOpen="data-nested-dialog-open",e})({});const qIn={...mf,...ql,nested(e){return e?{[JDe.nested]:""}:null},nestedDialogOpen(e){return e?{[JDe.nestedDialogOpen]:""}:null}},VIn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,c=uxe(),{store:u}=gd(),d=u.useState("open"),f=u.useState("nested"),p=u.useState("transitionStatus"),h=u.useState("nestedOpenDialogCount"),m=u.useState("mounted"),g=u.useStateSetter("viewportElement"),v=h>0;return En("div",t,{enabled:c||m,state:{open:d,nested:f,transitionStatus:p,nestedDialogOpen:v},ref:[n,g],stateAttributesMapping:qIn,props:[{role:"presentation",hidden:!m,style:{pointerEvents:d?void 0:"none"},children:i},l]})});function b3(e,t){return e&&y.isValidElement(t)?{render:t}:void 0}const HIn=EIn;function jt({open:e,onOpenChange:t,children:n}){return o.jsx(HIn,{open:e,onOpenChange:t,children:n})}const kht=y.forwardRef(({asChild:e,children:t,...n},r)=>o.jsx(UIn,{ref:r,...b3(e,t),...n,children:e?void 0:t}));kht.displayName="AlertDialogTrigger";const Oht=JU,hxe=y.forwardRef(({className:e,...t},n)=>o.jsx(lxe,{ref:n,className:K("dialog-overlay-anim fixed inset-0 z-50 bg-overlay backdrop-blur-xs",e),...t}));hxe.displayName="AlertDialogOverlay";const _ht=y.forwardRef(({className:e,...t},n)=>o.jsxs(Oht,{children:[o.jsx(hxe,{}),o.jsx(dxe,{ref:n,"data-slot":"alert-dialog-content",className:K("dialog-content-anim","fixed left-[50%] top-[50%] z-50 grid translate-x-[-50%] translate-y-[-50%]","w-full max-w-[calc(100%-2rem)] sm:max-w-lg","rounded-xl border border-border1/40 bg-surface2/96 backdrop-blur-md shadow-dialog",e),...t})]}));_ht.displayName="AlertDialogContent";const Cht=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col gap-0.5 px-4 py-3 text-left",e),...t});Cht.displayName="AlertDialogHeader";const Eht=({className:e,...t})=>o.jsx("div",{className:K("flex flex-col-reverse gap-1.5 px-4 py-2.5 sm:flex-row sm:justify-end",e),...t});Eht.displayName="AlertDialogFooter";const jht=({className:e,...t})=>o.jsx("div",{className:K("overflow-y-auto px-4 py-3.5 max-h-[50vh]",e),...t});jht.displayName="AlertDialogBody";const Tht=y.forwardRef(({className:e,...t},n)=>o.jsx(eq,{ref:n,className:K("text-ui-md font-medium",e),...t}));Tht.displayName="AlertDialogTitle";const Nht=y.forwardRef(({className:e,...t},n)=>o.jsx(KU,{ref:n,className:K("text-ui-sm text-neutral3",e),...t}));Nht.displayName="AlertDialogDescription";const Iht=y.forwardRef(({className:e,...t},n)=>o.jsx(m3,{ref:n,className:K(i3({variant:"primary",size:"lg"}),e),...t}));Iht.displayName="AlertDialogAction";const Aht=y.forwardRef(({className:e,...t},n)=>o.jsx(m3,{ref:n,className:K(i3({variant:"default",size:"lg"}),e),...t}));Aht.displayName="AlertDialogCancel";jt.Trigger=kht;jt.Portal=Oht;jt.Overlay=hxe;jt.Content=_ht;jt.Header=Cht;jt.Footer=Eht;jt.Body=jht;jt.Title=Tht;jt.Description=Nht;jt.Action=Iht;jt.Cancel=Aht;function Xd({controlled:e,default:t,name:n,state:r="value"}){const{current:s}=y.useRef(e!==void 0),[a,i]=y.useState(t),l=s?e:a,c=y.useCallback(u=>{s||i(u)},[]);return[l,c]}function ZIn(e){if(!e)return null;for(const t of e.elements){const n=t.tagName;if(n==="BUTTON"||n==="INPUT"){const r=t;if(r.type==="submit")return r}}return null}let e4e=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({}),t4e=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const WIn={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},OE={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},QIn={disabled:!1,...OE},_1={valid(e){return e===null?null:e?{[t4e.valid]:""}:{[t4e.invalid]:""}}};function Rht(e){return y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[e4e.checked]:""}:{[e4e.unchecked]:""}},..._1}),[e.indeterminate])}const Pht={invalid:void 0,name:void 0,validityData:{state:WIn,errors:[],error:"",value:"",initialValue:null},setValidityData:ga,disabled:void 0,touched:OE.touched,setTouched:ga,dirty:OE.dirty,setDirty:ga,filled:OE.filled,setFilled:ga,focused:OE.focused,setFocused:ga,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:QIn,markedDirtyRef:{current:!1},registerFieldControl:ga,validation:{getValidationProps:(e=vs)=>e,getInputValidationProps:(e=vs)=>e,inputRef:{current:null},commit:async()=>{}}},$ht=y.createContext(Pht);function Jh(e=!0){const t=y.useContext($ht);if(t.setValidityData===ga&&!e)throw new Error(yr(28));return t}function vN(e,t,n,r,s=!0){const{registerFieldControl:a}=Jh(),i=y.useRef(null);i.current||(i.current=Symbol()),Tt(()=>{const l=i.current;return!l||!s?void 0:(a(l,{controlRef:e,getValue:r,id:t,value:n}),()=>{a(l,void 0)})},[e,s,r,t,a,n])}const GIn=y.createContext({disabled:!1});function Mht(){return y.useContext(GIn)}const YIn=y.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:ga,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function yN(){return y.useContext(YIn)}const XIn=y.createContext({controlId:void 0,registerControlId:ga,labelId:void 0,setLabelId:ga,messageIds:[],setMessageIds:ga,getDescriptionProps:e=>e});function kx(){return y.useContext(XIn)}function mxe(e,t,n,r=!0,s){const[a,i]=y.useState(),l=Mi(s?`${s}-label`:void 0),c=e??t??a;return Tt(()=>{const u=e||t||!r?void 0:KIn(n.current,l);a!==u&&i(u)}),c}function KIn(e,t){const n=JIn(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function JIn(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const s=e.nextElementSibling;if(s&&s.htmlFor===n)return s}const r=e.labels;return r&&r[0]}const eAn=y.createContext(void 0);function tAn(e=!0){const t=y.useContext(eAn);if(t===void 0&&!e)throw new Error(yr(3));return t}const Dht=y.createContext(void 0);function nAn(){const e=y.useContext(Dht);if(e===void 0)throw new Error(yr(14));return e}const rAn="data-parent",sAn=y.forwardRef(function(t,n){const{checked:r,className:s,defaultChecked:a=!1,"aria-labelledby":i,disabled:l=!1,form:c,id:u,indeterminate:d=!1,inputRef:f,name:p,onCheckedChange:h,parent:m=!1,readOnly:g=!1,render:v,required:b=!1,uncheckedValue:w,value:S,nativeButton:O=!1,style:_,...C}=t,{clearErrors:j}=yN(),{disabled:E,name:N,setDirty:I,setFilled:P,setFocused:$,setTouched:B,state:D,validationMode:V,validityData:H,shouldValidateOnChange:L,validation:F}=Jh(),z=Mht(),{labelId:M,controlId:G,registerControlId:U,getDescriptionProps:R}=kx(),q=tAn(),W=q?.parent,X=W&&q.allValues,ne=E||z.disabled||q?.disabled||l,ee=N??p,J=S??ee,ie=Mi(),ue=Mi();let Y=G;X?Y=m?ue:`${W.id}-${J}`:u&&(Y=u);let te={};X&&(m?te=q.parent.getParentProps():J&&(te=q.parent.getChildProps(J)));const{checked:le=r,indeterminate:fe=d,onCheckedChange:se,...he}=te,be=q?.value,we=q?.setValue,Ie=q?.defaultValue,ke=y.useRef(null),je=cc(()=>Symbol("checkbox-control")),Fe=y.useRef(!1),{getButtonProps:ce,buttonRef:ae}=vd({disabled:ne,native:O}),re=q?.validation??F,[me,ye]=Xd({controlled:J&&be&&!m?be.includes(J):le,default:J&&Ie&&!m?Ie.includes(J):a,name:"Checkbox",state:"checked"});Tt(()=>{U!==ga&&(Fe.current=!0,U(je.current,Y))},[Y,U,je]),y.useEffect(()=>{const ze=je.current;return()=>{!Fe.current||U===ga||(Fe.current=!1,U(ze,void 0))}},[U,je]),vN(ke,ie,me,void 0,!q);const Te=y.useRef(null),Re=ku(f,Te,re.inputRef),Qe=mxe(i,M,Te,!O,Y??void 0);Tt(()=>{Te.current&&(Te.current.indeterminate=fe,me&&P(!0))},[me,fe,P]),wv(me,()=>{q&&!m||(j(ee),P(me),I(me!==H.initialValue),L()?re.commit(me):re.commit(me,!0))});const Ze=Eo({checked:me,disabled:ne,form:c,name:m?void 0:ee,id:O?void 0:Y??void 0,required:b,ref:Re,style:ee?tN:qw,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(ze){if(ze.nativeEvent.defaultPrevented)return;if(g){ze.preventDefault();return}const Ke=ze.currentTarget.checked,Ye=qt(Oo,ze.nativeEvent);if(se?.(Ke,Ye),h?.(Ke,Ye),!Ye.isCanceled&&(ye(Ke),J&&be&&we&&!m&&!X)){const Rt=Ke?[...be,J]:be.filter(Ct=>Ct!==J);we(Rt,Ye)}},onFocus(){ke.current?.focus()}},S!==void 0?{value:(q?me&&S:S)||""}:vs,R,q?re.getValidationProps:re.getInputValidationProps),Oe=X?!!le:me,_e=X&&fe||d;y.useEffect(()=>{if(!W||!J)return;const ze=W.disabledStatesRef.current;return ze.set(J,ne),()=>{ze.delete(J)}},[W,ne,J]);const Ce=y.useMemo(()=>({...D,checked:Oe,disabled:ne,readOnly:g,required:b,indeterminate:_e}),[D,Oe,ne,g,b,_e]),Ee=Rht(Ce),$e=En("span",t,{state:Ce,ref:[ae,ke,n,q?.registerControlRef],props:[{id:O?Y??void 0:ie,role:"checkbox","aria-checked":fe?"mixed":me,"aria-readonly":g||void 0,"aria-required":b||void 0,"aria-labelledby":Qe,[rAn]:m?"":void 0,onFocus(){$(!0)},onBlur(){const ze=Te.current;ze&&(B(!0),$(!1),V==="onBlur"&&re.commit(q?be:ze.checked))},onKeyDown(ze){if(ze.key!=="Enter"||(ze.preventBaseUIHandler(),ze.defaultPrevented))return;const Ke=Te.current?.form??null,Ye=ze.currentTarget,Rt=ze.nativeEvent,Ct=ze.preventDefault,en=Rt.preventDefault;let bt=!1;ze.preventDefault=()=>{bt=!0,Ct.call(ze)},Rt.preventDefault=()=>{bt=!0,en.call(Rt)},en.call(Rt),Xs(Ye).queueMicrotask(()=>{ze.preventDefault=Ct,Rt.preventDefault=en,bt||ZIn(Ke)?.click()})},onClick(ze){if(g||ne)return;ze.preventDefault();const Ke=Te.current;Ke&&Ke.dispatchEvent(new(Xs(Ke)).PointerEvent("click",{bubbles:!0,shiftKey:ze.shiftKey,ctrlKey:ze.ctrlKey,altKey:ze.altKey,metaKey:ze.metaKey}))}},R,re.getValidationProps,C,he,ce],stateAttributesMapping:Ee});return o.jsxs(Dht.Provider,{value:Ce,children:[$e,!me&&!q&&ee&&!m&&w!==void 0&&o.jsx("input",{type:"hidden",form:c,name:ee,value:w}),o.jsx("input",{...Ze,suppressHydrationWarning:!0})]})}),aAn=y.forwardRef(function(t,n){const{render:r,className:s,style:a,keepMounted:i=!1,...l}=t,c=nAn(),u=c.checked||c.indeterminate,{mounted:d,transitionStatus:f,setMounted:p}=bg(u),h=y.useRef(null),m={...c,transitionStatus:f};Vl({open:u,ref:h,onComplete(){u||p(!1)}});const v={...Rht(c),...ql,..._1},b=i||d,w=En("span",t,{ref:[n,h],state:m,stateAttributesMapping:v,props:l});return b?w:null}),Go=y.forwardRef(({className:e,checked:t,indeterminate:n,...r},s)=>{const a=t==="indeterminate";return o.jsx(sAn,{ref:s,checked:a?!1:t,indeterminate:n??a,"data-slot":"checkbox",className:K("peer flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[0.3125rem]","border border-neutral6/[0.06] bg-neutral6/[0.12] text-surface1 outline-hidden",is.all,"hover:border-neutral6/[0.12] hover:bg-neutral6/[0.16]","active:scale-95 active:border-neutral6/[0.18] active:bg-neutral6/[0.18]","focus-visible:border-neutral5/50 focus-visible:outline focus-visible:outline-1 focus-visible:outline-offset-2 focus-visible:outline-neutral5/55","data-[checked]:border-neutral6 data-[checked]:bg-neutral6 data-[checked]:text-surface1","data-[indeterminate]:border-neutral6 data-[indeterminate]:bg-neutral6 data-[indeterminate]:text-surface1","data-[checked]:hover:border-neutral5 data-[checked]:hover:bg-neutral5","data-[indeterminate]:hover:border-neutral5 data-[indeterminate]:hover:bg-neutral5","data-[checked]:active:border-neutral4 data-[checked]:active:bg-neutral4","data-[indeterminate]:active:border-neutral4 data-[indeterminate]:active:bg-neutral4","data-[disabled]:cursor-not-allowed data-[disabled]:border-neutral6/[0.38] data-[disabled]:bg-neutral6/[0.38] data-[disabled]:hover:border-neutral6/[0.38] data-[disabled]:hover:bg-neutral6/[0.38] data-[disabled]:active:scale-100","data-[disabled]:data-[checked]:border-neutral6/[0.38] data-[disabled]:data-[checked]:bg-neutral6/[0.38] data-[disabled]:data-[checked]:text-neutral6","data-[disabled]:data-[indeterminate]:border-neutral6/[0.38] data-[disabled]:data-[indeterminate]:bg-neutral6/[0.38] data-[disabled]:data-[indeterminate]:text-neutral6",e),...r,children:o.jsx(aAn,{keepMounted:!0,className:K("group/checkbox-indicator flex items-center justify-center text-current","opacity-0 scale-75 transition-[opacity,transform] duration-200 ease-out-custom","data-[checked]:opacity-100 data-[checked]:scale-100","data-[indeterminate]:opacity-100 data-[indeterminate]:scale-100","data-[starting-style]:opacity-0 data-[starting-style]:scale-75","data-[ending-style]:opacity-0 data-[ending-style]:scale-75"),children:o.jsx(iAn,{})})})});Go.displayName="Checkbox";function iAn(){return o.jsxs(o.Fragment,{children:[o.jsx(wx,{className:K("size-3 scale-95 stroke-[3.25] transition-[stroke-dashoffset,transform] duration-200 ease-out-custom","[stroke-dasharray:28] [stroke-dashoffset:28]","group-data-[checked]/checkbox-indicator:[stroke-dashoffset:0]","group-data-[checked]/checkbox-indicator:scale-100","group-data-[indeterminate]/checkbox-indicator:hidden")}),o.jsx(UTn,{className:K("hidden size-3 scale-95 stroke-[3.25] transition-transform duration-200 ease-out-custom","group-data-[indeterminate]/checkbox-indicator:block","group-data-[indeterminate]/checkbox-indicator:scale-100")})]})}function oAn(e){const{open:t,defaultOpen:n,onOpenChange:r,disabled:s}=e,[a,i]=Xd({controlled:t,default:n,name:"Collapsible",state:"open"}),{mounted:l,setMounted:c,transitionStatus:u}=bg(a,!0,!0),d=Mi(),[f,p]=y.useState(),h=f??d,m=mt(g=>{const v=!a,b=qt(rg,g.nativeEvent);r(v,b),!b.isCanceled&&i(v)});return y.useMemo(()=>({disabled:s,handleTrigger:m,mounted:l,open:a,panelId:h,setMounted:c,setOpen:i,setPanelIdState:p,transitionStatus:u}),[s,m,l,a,h,c,i,p,u])}const Lht=y.createContext(void 0);function Fht(){const e=y.useContext(Lht);if(e===void 0)throw new Error(yr(15));return e}let gxe=(function(e){return e.open="data-open",e.closed="data-closed",e[e.startingStyle=sg.startingStyle]="startingStyle",e[e.endingStyle=sg.endingStyle]="endingStyle",e})({}),lAn=(function(e){return e.panelOpen="data-panel-open",e})({});const cAn={[gxe.open]:""},uAn={[gxe.closed]:""},dAn={open(e){return e?{[lAn.panelOpen]:""}:null}},fAn={open(e){return e?cAn:uAn}},zht={...fAn,...ql},pAn=y.forwardRef(function(t,n){const{render:r,className:s,defaultOpen:a=!1,disabled:i=!1,onOpenChange:l,open:c,style:u,...d}=t,f=mt(l),p=oAn({open:c,defaultOpen:a,onOpenChange:f,disabled:i}),h=y.useMemo(()=>({open:p.open,disabled:p.disabled,transitionStatus:p.transitionStatus}),[p.open,p.disabled,p.transitionStatus]),m=y.useMemo(()=>({...p,onOpenChange:f,state:h}),[p,f,h]),g=En("div",t,{state:h,ref:n,props:d,stateAttributesMapping:zht});return o.jsx(Lht.Provider,{value:m,children:g})}),hAn={...dAn,...ql},mAn=y.forwardRef(function(t,n){const{panelId:r,open:s,handleTrigger:a,state:i,disabled:l}=Fht(),{className:c,disabled:u=l,id:d,render:f,nativeButton:p=!0,style:h,...m}=t,{getButtonProps:g,buttonRef:v}=vd({disabled:u,focusableWhenDisabled:!0,native:p});return En("button",t,{state:i,ref:[n,v],props:[{"aria-controls":s?r:void 0,"aria-expanded":s,onClick:a},m,g],stateAttributesMapping:hAn})}),mA={height:void 0,width:void 0};function gAn(e){const{externalRef:t,hiddenUntilFound:n,id:r,keepMounted:s,mounted:a,onOpenChange:i,open:l,setMounted:c,setOpen:u,transitionStatus:d}=e,f=y.useRef(null),p=y.useRef(null),[h,m]=y.useState(mA),g=y.useRef(mA),v=y.useRef(!1),b=y.useRef(l),w=y.useRef(!1),[S,O]=y.useState(!1),_=y.useRef(null),C=ku(t,f),j=Yi({mounted:a,open:l}),E=SU(f,!1,!1),N=!l&&!a,I=S?"idle":d,P=l&&(b.current||w.current),$=!l&&a&&p.current==="css-animation"&&h.height===void 0&&h.width===void 0?g.current:h,B=n&&N&&p.current!=="css-animation",D=mt((z,M=!0)=>{M&&(g.current=z),m(z)}),V=mt(()=>{_.current?.(),_.current=null}),H=mt(z=>{V(),_.current=()=>{_.current=null,z()}}),L=mt(()=>{l&&a&&p.current==="css-animation"&&(w.current=!0)});Tt(()=>{!S||d==="starting"||O(!1)},[S,d]),y.useEffect(()=>()=>{L(),V()},[L,V]),Tt(()=>{const z=f.current;if(!z)return;!l&&_.current&&V();const M=vAn(z,P);if(p.current=M,l&&d==="idle"&&b.current&&M==="css-animation"){g.current=wC(z);return}if(l&&d==="starting"){const R=v.current;if(v.current=!1,M==="none"){D(wC(z)),O(!0);return}if(M==="css-transition"){const q=yAn(z);if(D(wC(z)),!R)return q;const W=gA(z,"transition-duration","0s");return H(W),O(!0),q}if(M==="css-animation"){if(D(wC(z)),!R){gA(z,"animation-name","none")();return}const q=gA(z,"animation-name","none"),W=gA(z,"animation-duration","0s");q(),H(W),O(!0);return}}if(!l&&a&&(d==="idle"||d==="starting")){if(M==="none"){D(mA,!1),c(!1);return}M==="css-animation"&&(b.current=!1,w.current=!1),D(wC(z));return}if(d!=="ending")return;if(M==="none"){c(!1);return}const G=wC(z);if(!((G.height??0)>0||(G.width??0)>0)){c(!1);return}D(G),M==="css-animation"&&gA(z,"animation-name","none")()},[a,l,V,D,c,H,P,d]),Vl({enabled:l&&a&&I==="idle",open:!0,ref:f,onComplete(){l&&D(mA,!1)}}),y.useEffect(()=>{if(l||!a||I!=="ending"||!f.current)return;const M=new AbortController;let G=-1;function U(){j.current.open||(c(!1),D(mA,!1))}return G=Pd.request(()=>{M.signal.aborted||E(U,M.signal)}),()=>{Pd.cancel(G),M.abort()}},[j,a,l,I,E,D,c]),Tt(()=>{const z=f.current;!z||!n||!N||z.setAttribute("hidden","until-found")},[N,n]),y.useEffect(function(){const M=f.current;if(!M)return;function G(U){v.current=!0,u(!0),i(!0,qt(Oo,U))}return Br(M,"beforematch",G)},[i,u]);const F=s||n||a||l;return{height:$.height,props:{...B?{[gxe.startingStyle]:""}:void 0,hidden:N,id:r},ref:C,shouldPreventOpenAnimation:P,shouldRender:F,transitionStatus:I,width:$.width}}function wC(e){return{height:e.scrollHeight,width:e.scrollWidth}}function vAn(e,t=!1){const n=Xs(e).getComputedStyle(e),r=(n.animationName.split(",").map(a=>a.trim()).some(a=>a!==""&&a!=="none")||t)&&n4e(n.animationDuration),s=n4e(n.transitionDuration);return r&&s||s?"css-transition":r?"css-animation":"none"}function n4e(e){return e.split(",").map(t=>t.trim()).some(t=>t!==""&&Number.parseFloat(t)>0)}function gA(e,t,n){const r=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);return e.style.setProperty(t,n),()=>{if(r===""){e.style.removeProperty(t);return}e.style.setProperty(t,r,s)}}function yAn(e){const t={"justify-content":e.style.justifyContent,"align-items":e.style.alignItems,"align-content":e.style.alignContent,"justify-items":e.style.justifyItems};Object.keys(t).forEach(s=>{e.style.setProperty(s,"initial","important")});function n(){Object.entries(t).forEach(([s,a])=>{if(a===""){e.style.removeProperty(s);return}e.style.setProperty(s,a)})}const r=Pd.request(n);return()=>{Pd.cancel(r),n()}}let r4e=(function(e){return e.collapsiblePanelHeight="--collapsible-panel-height",e.collapsiblePanelWidth="--collapsible-panel-width",e})({});const bAn=y.forwardRef(function(t,n){const{className:r,hiddenUntilFound:s,keepMounted:a,render:i,id:l,style:c,...u}=t,{mounted:d,onOpenChange:f,open:p,panelId:h,setMounted:m,setPanelIdState:g,setOpen:v,state:b,transitionStatus:w}=Fht(),S=s??!1,O=a??!1;Tt(()=>{if(l)return g(l),()=>{g(void 0)}},[l,g]);const{height:_,props:C,ref:j,shouldPreventOpenAnimation:E,shouldRender:N,transitionStatus:I,width:P}=gAn({externalRef:n,hiddenUntilFound:S,id:h,keepMounted:O,mounted:d,onOpenChange:f,open:p,setMounted:m,setOpen:v,transitionStatus:w}),$={...b,transitionStatus:I},B=Hlt(c,$),D=En("div",{...t,style:void 0},{state:$,ref:j,props:[C,{style:{[r4e.collapsiblePanelHeight]:_===void 0?"auto":`${_}px`,[r4e.collapsiblePanelWidth]:P===void 0?"auto":`${P}px`}},u,B?{style:B}:void 0,E?{style:{animationName:"none"}}:void 0],stateAttributesMapping:zht});return N?D:null}),lg=pAn,zh=De.forwardRef(({className:e,asChild:t,children:n,...r},s)=>{const a=t&&De.isValidElement(n)?{render:n}:{};return o.jsx(mAn,{ref:s,"data-slot":"collapsible-trigger",className:K("-outline-offset-2",is.colors,r_.visible,"hover:text-neutral5","[&>svg]:transition-transform [&>svg]:duration-normal [&>svg]:ease-out-custom","[&[data-panel-open]>svg]:rotate-90",e),...a,...r,children:t?void 0:n})});zh.displayName="CollapsibleTrigger";const Bh=De.forwardRef(({className:e,children:t,...n},r)=>o.jsx(bAn,{ref:r,"data-slot":"collapsible-content",className:K("overflow-hidden","h-[var(--collapsible-panel-height)] transition-[height] duration-normal ease-out-custom","data-[starting-style]:h-0 data-[ending-style]:h-0"),...n,children:o.jsx("div",{className:e,children:t})}));Bh.displayName="CollapsibleContent";const Bht=y.createContext(void 0),Uht=y.createContext(void 0),qht=y.createContext(void 0),Vht=y.createContext("");function my(){const e=y.useContext(Bht);if(!e)throw new Error(yr(22));return e}function tq(){const e=y.useContext(Uht);if(!e)throw new Error(yr(23));return e}function C1(){const e=y.useContext(qht);if(!e)throw new Error(yr(24));return e}function Hht(){return y.useContext(Vht)}const Zht=(e,t)=>Object.is(e,t);function Wv(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function Wht(e,t,n){return!e||e.length===0?!1:e.some(r=>r===void 0?!1:Wv(t,r,n))}function bw(e,t,n){return!e||e.length===0?-1:e.findIndex(r=>r===void 0?!1:Wv(r,t,n))}function Qht(e,t,n){return e.filter(r=>!Wv(t,r,n))}function oz(e){if(e==null)return"";if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function vxe(e){return e!=null&&e.length>0&&typeof e[0]=="object"&&e[0]!=null&&"items"in e[0]}function Ght(e){if(!Array.isArray(e))return e!=null&&"null"in e;const t=e;if(vxe(t)){for(const n of t)for(const r of n.items)if(r&&r.value==null&&r.label!=null)return!0;return!1}for(const n of t)if(n&&n.value==null&&n.label!=null)return!0;return!1}function ou(e,t){if(t&&e!=null)return t(e)??"";if(e&&typeof e=="object"){if("label"in e&&e.label!=null)return String(e.label);if("value"in e)return String(e.value)}return oz(e)}function Dm(e,t){return t&&e!=null?t(e)??"":e&&typeof e=="object"&&"value"in e&&"label"in e?oz(e.value):oz(e)}function yxe(e,t,n){function r(){return ou(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e=="object"&&"label"in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return t[e]??r();if(Array.isArray(t)){const s=t,a=vxe(s)?s.flatMap(i=>i.items):s;if(e==null||typeof e!="object"){const i=a.find(l=>l.value===e);return i&&i.label!=null?i.label:r()}if("value"in e){const i=a.find(l=>l&&l.value===e.value);if(i&&i.label!=null)return i.label}}return r()}function Yht(e,t,n){return e.reduce((r,s,a)=>(a>0&&r.push(", "),r.push(o.jsx(y.Fragment,{children:yxe(s,t,n)},a)),r),[])}const on={id:lt(e=>e.id),labelId:lt(e=>e.labelId),items:lt(e=>e.items),selectedValue:lt(e=>e.selectedValue),hasSelectionChips:lt(e=>{const t=e.selectedValue;return Array.isArray(t)&&t.length>0}),hasSelectedValue:lt(e=>{const{selectedValue:t,selectionMode:n}=e;return t==null?!1:n==="multiple"&&Array.isArray(t)?t.length>0:!0}),hasNullItemLabel:lt((e,t)=>t?Ght(e.items):!1),open:lt(e=>e.open),mounted:lt(e=>e.mounted),forceMounted:lt(e=>e.forceMounted),inline:lt(e=>e.inline),activeIndex:lt(e=>e.activeIndex),selectedIndex:lt(e=>e.selectedIndex),isActive:lt((e,t)=>e.activeIndex===t),isSelected:lt((e,t)=>{const n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(s=>Wv(t,s,n)):Wv(t,r,n)}),transitionStatus:lt(e=>e.transitionStatus),popupProps:lt(e=>e.popupProps),inputProps:lt(e=>e.inputProps),triggerProps:lt(e=>e.triggerProps),itemProps:lt(e=>e.itemProps),positionerElement:lt(e=>e.positionerElement),listElement:lt(e=>e.listElement),triggerElement:lt(e=>e.triggerElement),inputElement:lt(e=>e.inputElement),inputGroupElement:lt(e=>e.inputGroupElement),popupSide:lt(e=>e.popupSide),openMethod:lt(e=>e.openMethod),inputInsidePopup:lt(e=>e.inputInsidePopup),inputOwnsFormValue:lt(e=>e.inputOwnsFormValue),selectionMode:lt(e=>e.selectionMode),name:lt(e=>e.name),form:lt(e=>e.form),disabled:lt(e=>e.disabled),readOnly:lt(e=>e.readOnly),required:lt(e=>e.required),grid:lt(e=>e.grid),virtualized:lt(e=>e.virtualized),itemToStringLabel:lt(e=>e.itemToStringLabel),isItemEqualToValue:lt(e=>e.isItemEqualToValue),modal:lt(e=>e.modal),autoHighlight:lt(e=>e.autoHighlight),submitOnItemClick:lt(e=>e.submitOnItemClick)};function h_(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:s,registerControlId:a}=kx(),i=Mi(t),l=n?s:void 0,c=cc(()=>Symbol("labelable-control")),u=y.useRef(!1),d=y.useRef(t!=null),f=mt(()=>{!u.current||a===ga||(u.current=!1,a(c.current,void 0))});return Tt(()=>{if(a===ga)return;let p;if(n){const h=r?.current;wr(h)&&h.closest("label")!=null?p=t??null:p=l??i}else if(t!=null)d.current=!0,p=t;else if(d.current)p=i;else{f();return}if(p===void 0){f();return}u.current=!0,a(c.current,p)},[t,r,l,a,n,i,c,f]),y.useEffect(()=>f,[f]),s??i}function xAn(e,t){return(n,r)=>{if(n==null)return!1;const s=ou(n,t);return e.contains(s,r)}}function wAn(e,t,n){return(r,s)=>{if(r==null)return!1;if(!s)return!0;const a=ou(r,t),i=n!=null?ou(n,t):"";return i&&e.contains(i,s)&&i.length===s.length?!0:e.contains(a,s)}}const s4e=new Map;function SAn(e={}){const t={usage:"search",sensitivity:"base",ignorePunctuation:!0,...e},n=`${Xht(e.locale)}|${JSON.stringify(t)}`,r=s4e.get(n);if(r)return r;const s=new Intl.Collator(e.locale,t),a={contains(i,l,c){if(!l)return!0;const u=ou(i,c);for(let d=0;d<=u.length-l.length;d+=1)if(s.compare(u.slice(d,d+l.length),l)===0)return!0;return!1},startsWith(i,l,c){if(!l)return!0;const u=ou(i,c);return s.compare(u.slice(0,l.length),l)===0},endsWith(i,l,c){if(!l)return!0;const u=ou(i,c),d=l.length;return u.length>=d&&s.compare(u.slice(u.length-d),l)===0}};return s4e.set(n,a),a}function Xht(e){return Array.isArray(e)?e.map(t=>Xht(t)).join(","):e==null?"":String(e)}const kAn=SAn,Kht=Symbol("none"),vS={value:Kht,index:-1};function OAn(e){const{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:s,onSelectedValueChange:a,defaultInputValue:i,inputValue:l,open:c,defaultOpen:u=!1,selectionMode:d="none",onItemHighlighted:f,name:p,form:h,disabled:m=!1,readOnly:g=!1,required:v=!1,inputRef:b,grid:w=!1,items:S,filteredItems:O,filter:_,openOnInputClick:C=!0,autoHighlight:j=!1,keepHighlight:E=!1,highlightItemOnHover:N=!0,loopFocus:I=!0,itemToStringLabel:P,itemToStringValue:$,isItemEqualToValue:B=Zht,virtualized:D=!1,inline:V=!1,fillInputOnItemPress:H=!0,modal:L=!1,limit:F=-1,autoComplete:z="list",formAutoComplete:M,locale:G,submitOnItemClick:U=!1}=e,{clearErrors:R}=yN(),{setDirty:q,validityData:W,shouldValidateOnChange:X,setFilled:ne,name:ee,disabled:J,setTouched:ie,setFocused:ue,validationMode:Y,validation:te}=Jh(),le=fy(),fe=h_({id:t}),se=kAn({locale:G}),[he,be]=y.useState(!1),[we,Ie]=y.useState(null),ke=y.useRef([]),je=y.useRef([]),Fe=y.useRef(null),ce=y.useRef(null),ae=y.useRef(null),re=y.useRef(null),me=y.useRef(null),ye=y.useRef(!0),Te=y.useRef(!1),Re=y.useRef(null),Qe=y.useRef(null),Ze=y.useRef(null),Oe=y.useRef(vS),_e=y.useRef(null),Ce=y.useRef([]),Ee=y.useRef([]),$e=J||m,ze=ee??p,Ke=d==="multiple",Ye=d==="single",Rt=l!==void 0||i!==void 0,Ct=S!==void 0,en=O!==void 0;let bt;j==="always"?bt="always":bt=j?"input-change":!1;const[It,sn]=Xd({controlled:s,default:Ke?r??hh:r,name:"Combobox",state:"selectedValue"}),We=y.useMemo(()=>_===null?()=>!0:_!==void 0?_:Ye&&!he?wAn(se,P,It):xAn(se,P),[_,Ye,It,he,se,P]),at=cc(()=>Rt?i??"":Ye?ou(It,P):"").current,[ct,an]=Xd({controlled:l,default:at,name:"Combobox",state:"inputValue"}),[Xt,On]=Xd({controlled:c,default:u,name:"Combobox",state:"open"}),Ne=vxe(S),Le=we??(ct===""?"":String(ct).trim()),Me=Ye?ou(It,P):"",Xe=Ye&&!he&&Le!==""&&Me!==""&&Me.length===Le.length&&se.contains(Me,Le),nt=Xe?"":Le,Mt=Ct&&en&&Xe,kt=y.useMemo(()=>S?Ne?S.flatMap(un=>un.items):S:hh,[S,Ne]),Lt=y.useMemo(()=>{if(O&&!Mt)return O;if(!S)return hh;if(Ne){const Qn=S,_s=[];let ka=0;for(const no of Qn){if(F>-1&&ka>=F)break;const za=nt===""?no.items:no.items.filter(jf=>We(jf,nt,P));if(za.length===0)continue;const fm=F>-1?F-ka:1/0,wd=za.slice(0,fm);if(wd.length>0){const jf={...no,items:wd};_s.push(jf),ka+=wd.length}}return _s}if(nt==="")return F>-1?kt.slice(0,F):kt;const un=[];for(const Qn of kt){if(F>-1&&un.length>=F)break;We(Qn,nt,P)&&un.push(Qn)}return un},[O,Mt,S,Ne,nt,F,We,P,kt]),At=y.useMemo(()=>Ne?Lt.flatMap(Qn=>Qn.items):Lt,[Lt,Ne]),Et=cc(()=>new Rye({id:fe,labelId:void 0,selectedValue:It,open:Xt,filter:We,query:Le,items:S,selectionMode:d,listRef:ke,labelsRef:je,popupRef:Fe,emptyRef:me,inputRef:ce,startDismissRef:ae,endDismissRef:re,keyboardActiveRef:ye,chipsContainerRef:Re,clearRef:Qe,valuesRef:Ce,allValuesRef:Ee,selectionEventRef:Ze,name:ze,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Ne,virtualized:D,openOnInputClick:C,itemToStringLabel:P,isItemEqualToValue:B,modal:L,autoHighlight:bt,submitOnItemClick:U,hasInputValue:Rt,mounted:!1,forceMounted:!1,transitionStatus:"idle",inline:V,activeIndex:null,selectedIndex:null,popupProps:{},inputProps:{},triggerProps:{},itemProps:vs,positionerElement:null,listElement:null,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:d==="none",onOpenChangeComplete:n||ga,setOpen:ga,setInputValue:ga,setSelectedValue:ga,setIndices:ga,onItemHighlighted:ga,handleSelection:ga,forceMount:ga,requestSubmit:ga})).current,yn=d==="none"?ct:It,nr=y.useMemo(()=>d==="none"?yn:Array.isArray(It)?It.map(un=>Dm(un,$)):Dm(It,$),[yn,$,d,It]),qn=mt(f),Or=mt(n),pr=ht(Et,on.activeIndex),bs=ht(Et,on.selectedIndex),Mr=ht(Et,on.positionerElement),ur=ht(Et,on.listElement),qs=ht(Et,on.triggerElement),fa=ht(Et,on.inputElement),wa=ht(Et,on.inputGroupElement),Na=ht(Et,on.inline),Po=ht(Et,on.inputInsidePopup),dl=ht(Et,on.inputOwnsFormValue),el=Yi(qs),{mounted:lm,setMounted:Pu,transitionStatus:Ef}=bg(Xt),{openMethod:cm,triggerProps:$u}=pxe(Xt),Hr=mt(()=>nr);vN(Po?el:ce,fe,yn,Hr);const Sa=mt(()=>{S?je.current=At.map(un=>ou(un,P)):Et.set("forceMounted",!0)}),hi=y.useRef(It);Tt(()=>{It!==hi.current&&Sa()},[Sa,It]);const Ti=mt(un=>{Et.update(un);const Qn=un.type||"none";if(un.activeIndex!==void 0)if(un.activeIndex===null)Oe.current!==vS&&(Oe.current=vS,qn(void 0,XS(Qn,void 0,{index:-1})));else{const _s=Ce.current[un.activeIndex];Oe.current={value:_s,index:un.activeIndex},qn(_s,XS(Qn,void 0,{index:un.activeIndex}))}}),jl=mt((un,Qn)=>{if(Te.current=Qn.reason===hb,e.onInputValueChange?.(un,Qn),!Qn.isCanceled){if(Qn.reason===ck){const _s=Qn.event,ka=_s.inputType;if(_s.type==="compositionend"||ka!=null&&ka!==""&&ka!=="insertReplacementText"){const za=un.trim()!=="";za&&be(!0),_e.current={hasQuery:za},za&&bt&&Et.state.activeIndex==null&&Et.set("activeIndex",0)}}an(un)}}),Mu=mt((un,Qn)=>{if(Xt!==un&&(Qn.reason==="escape-key"&&Ct&&At.length===0&&!Et.state.emptyRef.current&&Qn.allowPropagation(),e.onOpenChange?.(un,Qn),!Qn.isCanceled&&(un&&Ke&&Po&&!Na&&we!==null&&(be(!1),Ie(null),ct!==""&&jl("",qt(hb,Qn.event))),!un&&he&&(Ye?(Na||Ie(Le),Le===""&&be(!1)):Ke&&(Na||Ie(Le),Po&&Ti({activeIndex:null}),(!Po||Na)&&jl("",qt(hb,Qn.event)))),On(un),!un&&Po&&(Qn.reason===Xb||Qn.reason===QM)&&(ie(!0),ue(!1),Y==="onBlur")))){const _s=d==="none"?ct:It;te.commit(_s)}}),Vs=mt((un,Qn)=>{if(a?.(un,Qn),Qn.isCanceled)return;sn(un),(d==="none"&&Fe.current&&H||Ye&&!Et.state.inputInsidePopup)&&jl(ou(un,P),qt(Qn.reason,Qn.event)),Ye&&un!=null&&Qn.reason!==ck&&he&&!Na&&Ie(Le)}),Kc=mt((un,Qn)=>{let _s=Qn;if(_s===void 0){if(pr===null)return;_s=Ce.current[pr]}const ka=Si(un),no=Ze.current??un;Ze.current=null;const za=qt(vw,no),fm=ka?.closest("a")?.getAttribute("href");if(fm){fm.startsWith("#")&&Mu(!1,za);return}if(Ke){const wd=Array.isArray(It)?It:[],nI=Wht(wd,_s,Et.state.isItemEqualToValue)?Qht(wd,_s,Et.state.isItemEqualToValue):[...wd,_s];if(Vs(nI,za),!(ce.current?ce.current.value.trim()!=="":!1))return;Et.state.inputInsidePopup?jl("",qt(hb,za.event)):Mu(!1,za)}else Vs(_s,za),Mu(!1,za)}),Ig=mt(()=>{if(!Et.state.submitOnItemClick)return;const un=te.inputRef.current?.form??Et.state.inputElement?.form;un&&typeof un.requestSubmit=="function"&&un.requestSubmit()}),$o=mt(()=>{if(Pu(!1),Or?.(!1),be(!1),Ie(null),Ti(d==="none"?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),Ke&&ce.current&&ce.current.value!==""&&!Te.current&&jl("",qt(hb)),Ye)if(Et.state.inputInsidePopup)ce.current&&ce.current.value!==""&&jl("",qt(hb));else{const un=ou(It,P);ce.current&&ce.current.value!==un&&jl(un,qt(un===""?hb:Oo))}}),F1=y.useMemo(()=>Na&&Mr?{current:Mr.closest('[role="dialog"]')}:Fe,[Na,Mr]);Vl({enabled:!e.actionsRef,open:Xt,ref:F1,onComplete(){Xt||$o()}}),y.useImperativeHandle(e.actionsRef,()=>({unmount:$o}),[$o]),Tt(function(){if(Xt||d==="none")return;const Qn=S?kt:Ee.current;if(Ke){const _s=Array.isArray(It)?It:[],ka=_s[_s.length-1],no=bw(Qn,ka,B);Ti({selectedIndex:no===-1?null:no})}else{const _s=bw(Qn,It,B);Ti({selectedIndex:_s===-1?null:_s})}},[Xt,It,S,d,kt,Ke,B,Ti]),Tt(()=>{S&&(Ce.current=At,ke.current.length=At.length)},[S,At]),Tt(()=>{const un=_e.current;if(un&&(un.hasQuery?bt&&Et.set("activeIndex",0):bt==="always"&&Et.set("activeIndex",0),_e.current=null),!Xt&&!Na)return;const _s=Ct||en?At:Ce.current,ka=Et.state.activeIndex;if(ka==null){if(bt==="always"&&_s.length>0){Et.set("activeIndex",0);return}Oe.current!==vS&&(Oe.current=vS,Et.state.onItemHighlighted(void 0,XS(Oo,void 0,{index:-1})));return}if(ka>=_s.length){Oe.current!==vS&&(Oe.current=vS,Et.state.onItemHighlighted(void 0,XS(Oo,void 0,{index:-1}))),Et.set("activeIndex",null);return}const no=_s[ka],za=Oe.current.value,fm=za!==Kht&&Wv(no,za,Et.state.isItemEqualToValue);(Oe.current.index!==ka||!fm)&&(Oe.current={value:no,index:ka},Et.state.onItemHighlighted(no,XS(Oo,void 0,{index:ka})))},[pr,bt,en,Ct,At,Na,Xt,Et]),Tt(()=>{if(d==="none"){ne(String(ct)!=="");return}ne(Ke?Array.isArray(It)&&It.length>0:It!=null)},[ne,d,ct,It,Ke]),y.useEffect(()=>{Ct&&bt&&At.length===0&&Ti({activeIndex:null})},[Ct,bt,At.length,Ti]),wv(Le,()=>{!Xt||Le===""||Le===String(at)||be(!0)}),wv(It,()=>{if(d!=="none"&&(R(ze),q(It!==W.initialValue),X()?te.commit(It):te.commit(It,!0),Ye&&!Rt&&!Po)){const un=ou(It,P);ct!==un&&jl(un,qt(Oo))}}),wv(ct,()=>{d==="none"&&(R(ze),q(ct!==W.initialValue),X()?te.commit(ct):te.commit(ct,!0))}),wv(S,()=>{if(!Ye||Rt||Po||he)return;const un=ou(It,P);ct!==un&&jl(un,qt(Oo))});const jy=$ye({open:Na?!0:Xt,onOpenChange:Mu,elements:{reference:Po?qs:fa,floating:Mr}});let Ag,Rg;Na||(Ag=w?"grid":"listbox",Rg=Xt?"true":"false");const z1=y.useMemo(()=>{const un=fa?.tagName==="INPUT",Qn=fa==null||un,_s=Qn||Xt,ka=Qn?{autoComplete:"off",spellCheck:"false",autoCorrect:"off",autoCapitalize:"none"}:{};return _s&&(ka.role="combobox",ka["aria-expanded"]=Rg,ka["aria-haspopup"]=Ag,ka["aria-controls"]=Xt?ur?.id:void 0,ka["aria-autocomplete"]=z),{reference:ka,floating:{role:"presentation"}}},[fa,Xt,Rg,Ag,ur?.id,z]),eI=o_(jy,{enabled:!g&&!$e&&C,event:"mousedown-only",toggle:!1,touchOpenDelay:Po?0:100,reason:zgn}),um=l_(jy,{enabled:!g&&!$e&&!Na,outsidePressEvent:{mouse:"sloppy",touch:"intentional"},bubbles:Na?!0:void 0,outsidePress(un){const Qn=Si(un);return!dn(qs,Qn)&&!dn(Qe.current,Qn)&&!dn(Re.current,Qn)&&!dn(wa,Qn)}}),Wx=Fye(jy,{enabled:!g&&!$e,id:fe,listRef:ke,activeIndex:pr,selectedIndex:bs,virtual:!0,loopFocus:I,allowEscape:I&&!bt,focusItemOnOpen:he||d==="none"&&!bt?!1:"auto",focusItemOnHover:N,resetOnPointerLeave:!E,cols:w?2:1,orientation:w?"horizontal":void 0,rtl:le==="rtl",disabledIndices:hh,onNavigate(un,Qn){!Qn&&!Xt||Ef==="ending"||Ti(Qn?{activeIndex:un,type:ye.current?"keyboard":"pointer"}:{activeIndex:un})}}),D_=y.useMemo(()=>Eo(Wx.reference,um.reference,eI.reference,z1.reference),[Wx.reference,um.reference,eI.reference,z1.reference]),L_=y.useMemo(()=>Eo(dy,Wx.floating,um.floating,z1.floating),[Wx.floating,um.floating,z1.floating]),B1=y.useMemo(()=>{const un=Wx.item;return un?{...un,onFocus:void 0}:vs},[Wx.item]);s_(()=>{Et.update({inline:V,popupProps:L_,inputProps:D_,triggerProps:$u,itemProps:B1,setOpen:Mu,setInputValue:jl,setSelectedValue:Vs,setIndices:Ti,onItemHighlighted:qn,handleSelection:Kc,forceMount:Sa,requestSubmit:Ig})}),Tt(()=>{Et.update({id:fe,selectedValue:It,open:Xt,mounted:lm,transitionStatus:Ef,items:S,inline:V,popupProps:L_,inputProps:D_,triggerProps:$u,openMethod:cm,itemProps:B1,selectionMode:d,name:ze,form:h,disabled:$e,readOnly:g,required:v,grid:w,isGrouped:Ne,virtualized:D,onOpenChangeComplete:Or,openOnInputClick:C,itemToStringLabel:P,modal:L,autoHighlight:bt,isItemEqualToValue:B,submitOnItemClick:U,hasInputValue:Rt,requestSubmit:Ig,inputOwnsFormValue:d==="none"&&(V||!Et.state.inputInsidePopup)})},[Et,fe,It,Xt,lm,Ef,S,L_,D_,B1,cm,$u,d,ze,$e,g,v,te,w,Ne,D,Or,C,P,L,B,U,Rt,V,Ig,bt,h]);const UZ=ku(b,te.inputRef),qZ=y.useMemo(()=>({query:Le,hasItems:Ct,filteredItems:Lt,flatFilteredItems:At}),[Le,Ct,Lt,At]),F_=y.useMemo(()=>Array.isArray(yn)?"":Dm(yn,$),[yn,$]),dm=Ke&&Array.isArray(It)&&It.length>0,U1=Ke||d==="none"&&dl?void 0:ze,tI=y.useMemo(()=>!Ke||!Array.isArray(It)||!ze?null:It.map(un=>{const Qn=Dm(un,$);return o.jsx("input",{type:"hidden",form:h,name:ze,value:Qn},Qn)}),[Ke,It,h,ze,$]),Qx=o.jsxs(y.Fragment,{children:[e.children,o.jsx("input",{...te.getInputValidationProps({onFocus(){if(Po){qs?.focus();return}(ce.current||qs)?.focus()},onChange(un){if(un.nativeEvent.defaultPrevented||$e||g){un.preventBaseUIHandler?.();return}const Qn=un.currentTarget.value,_s=qt(Oo,un.nativeEvent);function ka(){if(Ke)return;if(d==="none"){q(Qn!==W.initialValue),jl(Qn,_s),X()&&te.commit(Qn);return}const no=Ce.current.find(za=>Dm(za,$).toLowerCase()===Qn.toLowerCase()||ou(za,P).toLowerCase()===Qn.toLowerCase());no!=null&&(q(no!==W.initialValue),Vs?.(no,_s),X()&&te.commit(no))}S?ka():(Sa(),queueMicrotask(ka))}}),id:fe&&U1==null?`${fe}-hidden-input`:void 0,form:h,name:U1,autoComplete:M,disabled:$e,required:v&&!dm,readOnly:g,value:F_,ref:UZ,style:U1?tN:qw,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),tI]});return o.jsx(Bht.Provider,{value:Et,children:o.jsx(Uht.Provider,{value:jy,children:o.jsx(qht.Provider,{value:qZ,children:o.jsx(Vht.Provider,{value:ct,children:Qx})})})})}function Jht(e){const{multiple:t=!1,defaultValue:n,value:r,onValueChange:s,autoComplete:a,...i}=e;return o.jsx(OAn,{...i,selectionMode:t?"multiple":"single",selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:s,formAutoComplete:a})}function _An(e){return e==null?void 0:`${e}-label`}function nq(e,t){return e??t}function CAn(e){const{children:t,placeholder:n}=e,r=my(),s=ht(r,on.itemToStringLabel),a=ht(r,on.selectedValue),i=ht(r,on.items),l=ht(r,on.selectionMode)==="multiple",c=ht(r,on.hasSelectedValue),u=!c&&n!=null&&t==null,d=ht(r,on.hasNullItemLabel,u);let f=null;return typeof t=="function"?f=t(a):t!=null?f=t:!c&&n!=null&&!d?f=n:l&&Array.isArray(a)?f=Yht(a,i,s):f=yxe(a,i,s),o.jsx(y.Fragment,{children:f})}const emt={...xP,..._1,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":""}:null},EAn=y.createContext(void 0);function jAn(){return y.useContext(EAn)}const tmt=y.createContext(void 0);function bxe(e){const t=y.useContext(tmt);if(t===void 0&&!e)throw new Error(yr(21));return t}const nmt=y.forwardRef(function(t,n){const r=my(),{buttonRef:s,getButtonProps:a}=vd({native:!1}),i=ku(n,s);function l(u){r.state.setOpen(!1,qt(yye,u.nativeEvent,u.currentTarget))}const c=a({onClick:l});return o.jsx("span",{ref:i,...c,"aria-label":"Dismiss",tabIndex:void 0,style:tN})}),rmt=y.forwardRef(function(t,n){const{render:r,className:s,disabled:a=!1,id:i,style:l,...c}=t,{state:u,disabled:d,setTouched:f,setFocused:p,validationMode:h,validation:m}=Jh(),{labelId:g}=kx(),v=jAn(),w=!!bxe(!0),S=my(),{filteredItems:O}=C1(),_=Hht(),C=fy(),j=ht(S,on.required),E=ht(S,on.disabled),N=ht(S,on.readOnly),I=ht(S,on.name),P=ht(S,on.form),$=ht(S,on.selectionMode),B=ht(S,on.autoHighlight),D=ht(S,on.inputProps),V=ht(S,on.triggerProps),H=ht(S,on.open),L=ht(S,on.mounted),F=ht(S,on.selectedValue),z=ht(S,on.popupSide),M=ht(S,on.positionerElement),G=ht(S,on.id),U=ht(S,on.inline),R=ht(S,on.modal),q=!!B,W=L&&M?z:null,X=d||E||a,ne=O.length===0,ee=w||U,J=!ee||R,ie=Mi(i??(ee?void 0:G)),ue=nq(g,void 0),Y=w?OE:u,[te,le]=y.useState(null),fe=y.useRef(!1),se=y.useRef(null),he=y.useRef(!1),be=$==="none"&&!w,we=mt(ae=>{const re=w||S.state.inline;re&&!S.state.hasInputValue&&S.state.setInputValue("",qt(Oo)),S.update({inputElement:ae,inputInsidePopup:re,inputOwnsFormValue:be})}),Ie=w||!m?c:m.getValidationProps(c),ke={...Y,open:H,disabled:X,readOnly:N,popupSide:W,listEmpty:ne};function je(ae){if(!v)return;let re;const{highlightedChipIndex:me}=v,ye=v.chipsRef.current.length,Te=C==="rtl",Re=Te?"ArrowRight":"ArrowLeft",Qe=Te?"ArrowLeft":"ArrowRight";if(me!==void 0){if(ae.key===Re)ae.preventDefault(),me>0?re=me-1:re=void 0;else if(ae.key===Qe)ae.preventDefault(),me<ye-1?re=me+1:re=void 0;else if(ae.key==="Backspace"||ae.key==="Delete"){ae.preventDefault();const Ze=me>=F.length-1?F.length-2:me;re=Ze>=0?Ze:void 0,S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"})}return re}return ae.key===Re&&(ae.currentTarget.selectionStart??0)===0&&F.length>0?(ae.preventDefault(),re=ye>0?ye-1:void 0):ae.key==="Backspace"&&ae.currentTarget.value===""&&F.length>0&&(S.state.setIndices({activeIndex:null,selectedIndex:null,type:"keyboard"}),ae.preventDefault()),re}const Fe=En("input",t,{state:ke,ref:[n,S.state.inputRef,we],props:[D,V,{type:"text",value:t.value??te??_,"aria-readonly":N||void 0,"aria-required":j||void 0,"aria-labelledby":ue,disabled:X,readOnly:N,required:$==="none"?j:void 0,form:P,...be&&I&&{name:I},id:ie,onFocus(){if(p(!0),!U||!he.current)return;he.current=!1;const ae=se.current;ae==null||!Object.hasOwn(S.state.valuesRef.current,ae)||S.state.setIndices({activeIndex:ae})},onBlur(){f(!0),p(!1);const ae=S.state.activeIndex;if(U&&ae!==null&&B!=="always"&&(se.current=ae,he.current=!0,S.state.setIndices({activeIndex:null})),h==="onBlur"){const re=$==="none"?_:F;m.commit(re)}},onCompositionStart(ae){vP||(fe.current=!0,le(ae.currentTarget.value))},onCompositionEnd(ae){fe.current=!1;const re=ae.currentTarget.value;le(null),S.state.setInputValue(re,qt(ck,ae.nativeEvent))},onChange(ae){const re=ae.nativeEvent.inputType,me=!re||re==="insertReplacementText",ye=fe.current||!me;if(fe.current){const Ze=ae.currentTarget.value;le(Ze),Ze===""&&!S.state.openOnInputClick&&!S.state.inputInsidePopup&&S.state.setOpen(!1,qt(hb,ae.nativeEvent));const Oe=Ze.trim(),_e=q&&Oe!=="";!N&&!X&&Oe&&ye&&(S.state.setOpen(!0,qt(ck,ae.nativeEvent)),q||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),H&&S.state.activeIndex!==null&&!_e&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"});return}S.state.setInputValue(ae.currentTarget.value,qt(ck,ae.nativeEvent));const Te=ae.currentTarget.value==="",Re=qt(hb,ae.nativeEvent);Te&&!S.state.inputInsidePopup&&($==="single"&&S.state.setSelectedValue(null,Re),S.state.openOnInputClick||S.state.setOpen(!1,Re));const Qe=ae.currentTarget.value.trim();!N&&!X&&Qe&&ye&&(S.state.setOpen(!0,qt(ck,ae.nativeEvent)),q||S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})),H&&S.state.activeIndex!==null&&!q&&S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"})},onKeyDown(ae){if(X||N||ae.ctrlKey||ae.shiftKey||ae.altKey||ae.metaKey)return;S.state.keyboardActiveRef.current=!0;const re=ae.currentTarget,me=re.scrollWidth-re.clientWidth,ye=C==="rtl";if(ae.key==="Home"){Jl(ae);const Qe=E$e&&ye?re.value.length:0;re.setSelectionRange(Qe,Qe),re.scrollLeft=0;return}if(ae.key==="End"){Jl(ae);const Qe=E$e&&ye?0:re.value.length;re.setSelectionRange(Qe,Qe),re.scrollLeft=ye?-me:me;return}if(!L&&ae.key==="Escape"){const Qe=$==="multiple"&&Array.isArray(F)?F.length===0:F===null,Ze=qt(i_,ae.nativeEvent),Oe=$==="multiple"?[]:null;S.state.setInputValue("",Ze),S.state.setSelectedValue(Oe,Ze),!Qe&&!S.state.inline&&!Ze.isPropagationAllowed&&ae.stopPropagation();return}if(v&&ae.key==="Backspace"&&re.value===""&&v.highlightedChipIndex===void 0&&Array.isArray(F)&&F.length>0){const Qe=v.chipsRef.current.length,Ze=Qe>0?Qe-1:F.length-1,Oe=F.filter((_e,Ce)=>Ce!==Ze);S.state.setIndices({activeIndex:null,selectedIndex:null,type:S.state.keyboardActiveRef.current?"keyboard":"pointer"}),S.state.setSelectedValue(Oe,qt(Oo,ae.nativeEvent));return}const Te=v?.highlightedChipIndex!==void 0,Re=je(ae);if(v?.setHighlightedChipIndex(Re),Re!==void 0?v?.chipsRef.current[Re]?.focus():Te&&S.state.inputRef.current?.focus(),ae.which!==229&&ae.key==="Enter"&&H){const Qe=S.state.activeIndex,Ze=ae.nativeEvent;if(Qe===null){if(U)return;S.state.setOpen(!1,qt(Oo,Ze));return}Jl(ae);const Oe=S.state.listRef.current[Qe];Oe&&(S.state.selectionEventRef.current=Ze,Oe.click(),S.state.selectionEventRef.current=null)}},onPointerMove(){S.state.keyboardActiveRef.current=!1},onPointerDown(){S.state.keyboardActiveRef.current=!1}},Ie],stateAttributesMapping:emt}),ce=w?o.jsx($ht.Provider,{value:Pht,children:Fe}):Fe;return o.jsxs(y.Fragment,{children:[H&&J&&o.jsx(nmt,{ref:S.state.startDismissRef}),ce]})});function xxe(e){const t=e.getBoundingClientRect(),n=Xs(e),r=n.getComputedStyle(e,"::before"),s=n.getComputedStyle(e,"::after");if(!(r.content!=="none"||s.content!=="none"))return t;const i=parseFloat(r.width)||0,l=parseFloat(r.height)||0,c=parseFloat(s.width)||0,u=parseFloat(s.height)||0,d=Math.max(t.width,i,c),f=Math.max(t.height,l,u),p=d-t.width,h=f-t.height;return{left:t.left-p/2,right:t.right+p/2,top:t.top-h/2,bottom:t.bottom+h/2}}const OL=2,smt=y.forwardRef(function(t,n){const{render:r,className:s,nativeButton:a=!0,disabled:i=!1,id:l,style:c,...u}=t,{state:d,disabled:f,setTouched:p,setFocused:h,validationMode:m,validation:g}=Jh(),{labelId:v}=kx(),b=my(),{filteredItems:w}=C1(),S=ht(b,on.selectionMode),O=ht(b,on.disabled),_=ht(b,on.readOnly),C=ht(b,on.required),j=ht(b,on.mounted),E=ht(b,on.popupSide),N=ht(b,on.positionerElement),I=ht(b,on.listElement),P=ht(b,on.triggerProps),$=ht(b,on.triggerElement),B=ht(b,on.inputInsidePopup),D=ht(b,on.id),V=ht(b,on.labelId),H=ht(b,on.open),L=ht(b,on.selectedValue),F=ht(b,on.activeIndex),z=ht(b,on.selectedIndex),M=ht(b,on.hasSelectedValue),G=tq(),U=Hht(),R=co(),q=f||O||i,W=w.length===0,X=j&&N?E:null;h_({id:B?l:void 0});const ne=B?l??D:l,ee=nq(v,V),J=y.useRef("");function ie(we){J.current=we.pointerType}const ue=G.useState("domReferenceElement");y.useEffect(()=>{B&&$&&$!==ue&&G.set("domReferenceElement",$)},[$,ue,G,B]);const{reference:Y}=zye(G,{enabled:!H&&!_&&!O&&S==="single",listRef:b.state.labelsRef,activeIndex:F,selectedIndex:z,onMatch(we){const Ie=b.state.valuesRef.current[we];Ie!==void 0&&b.state.setSelectedValue(Ie,qt("none"))}}),{reference:te}=o_(G,{enabled:!_&&!O,event:"mousedown"}),{buttonRef:le,getButtonProps:fe}=vd({native:a,disabled:q}),se={...d,open:H,disabled:q,popupSide:X,listEmpty:W,placeholder:S==="none"?!1:!M},he=mt(we=>{b.set("triggerElement",we)});return En("button",t,{ref:[n,le,he],state:se,props:[P,te,Y,{id:ne,tabIndex:B?0:-1,role:B?"combobox":void 0,"aria-expanded":H?"true":"false","aria-haspopup":B?"dialog":"listbox","aria-controls":H?I?.id:void 0,"aria-required":B&&C||void 0,"aria-labelledby":ee,onPointerDown:ie,onPointerEnter:ie,onFocus(){h(!0),!(q||_)&&R.start(0,b.state.forceMount)},onBlur(we){if(!dn(N,we.relatedTarget)&&(p(!0),h(!1),m==="onBlur")){const Ie=S==="none"?U:L;g.commit(Ie)}},onMouseDown(we){if(q||_||(B||G.set("domReferenceElement",we.currentTarget),b.state.forceMount(),J.current!=="touch"&&(b.state.inputRef.current?.focus(),B||we.preventDefault()),H))return;const Ie=dr(we.currentTarget);function ke(je){if(!$)return;const Fe=Si(je),ce=b.state.positionerElement,ae=b.state.listElement;if(dn($,Fe)||dn(ce,Fe)||dn(ae,Fe)||Fe===$)return;const re=xxe($),me=je.clientX>=re.left-OL&&je.clientX<=re.right+OL,ye=je.clientY>=re.top-OL&&je.clientY<=re.bottom+OL;me&&ye||b.state.setOpen(!1,qt("cancel-open",je))}B&&Ie.addEventListener("mouseup",ke,{once:!0})},onKeyDown(we){q||_||(we.key==="ArrowDown"||we.key==="ArrowUp")&&(Jl(we),b.state.setOpen(!0,qt(wF,we.nativeEvent)),b.state.inputRef.current?.focus())}},g?g.getValidationProps(u):u,fe],stateAttributesMapping:emt})}),TAn=y.createContext(null);function NAn(){return y.useContext(TAn)}function IAn(e){const{children:t}=e,{filteredItems:n}=C1(),r=NAn(),s=r?r.items:n;return s?o.jsx(y.Fragment,{children:s.map(t)}):null}const amt=y.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function AAn(){return y.useContext(amt)}function bN(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:s}=e,a=mt(s),i=y.useRef(0),l=cc(PAn).current,c=cc(RAn).current,[u,d]=y.useState(0),f=y.useRef(u),p=mt((b,w)=>{c.set(b,w??null),f.current+=1,d(f.current)}),h=mt(b=>{c.delete(b),f.current+=1,d(f.current)}),m=y.useMemo(()=>{const b=new Map;return Array.from(c.keys()).filter(S=>S.isConnected).sort($An).forEach((S,O)=>{const _=c.get(S)??{};b.set(S,{..._,index:O})}),b},[c,u]);Tt(()=>{if(typeof MutationObserver!="function"||m.size===0)return;const b=new MutationObserver(w=>{const S=new Set,O=_=>S.has(_)?S.delete(_):S.add(_);w.forEach(_=>{_.removedNodes.forEach(O),_.addedNodes.forEach(O)}),S.size===0&&(f.current+=1,d(f.current))});return m.forEach((w,S)=>{S.parentElement&&b.observe(S.parentElement,{childList:!0})}),()=>{b.disconnect()}},[m]),Tt(()=>{f.current===u&&(n.current.length!==m.size&&(n.current.length=m.size),r&&r.current.length!==m.size&&(r.current.length=m.size),i.current=m.size),a(m)},[a,m,n,r,u]),Tt(()=>()=>{n.current=[]},[n]),Tt(()=>()=>{r&&(r.current=[])},[r]);const g=mt(b=>(l.add(b),()=>{l.delete(b)}));Tt(()=>{l.forEach(b=>b(m))},[l,m]);const v=y.useMemo(()=>({register:p,unregister:h,subscribeMapChange:g,elementsRef:n,labelsRef:r,nextIndexRef:i}),[p,h,g,n,r,i]);return o.jsx(amt.Provider,{value:v,children:t})}function RAn(){return new Map}function PAn(){return new Set}function $An(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const imt=y.forwardRef(function(t,n){var r;const{render:s,className:a,style:i,children:l,...c}=t,u=my(),d=tq(),f=!!bxe(!0),{filteredItems:p,hasItems:h}=C1(),m=ht(u,on.selectionMode),g=ht(u,on.grid),v=ht(u,on.popupProps),b=ht(u,on.virtualized),w=m==="multiple",S=p.length===0,O=mt(I=>{u.set("positionerElement",I)}),_=mt(I=>{u.set("listElement",I)}),C=y.useMemo(()=>typeof l=="function"?r||(r=o.jsx(IAn,{children:l})):l,[l]),j={empty:S},E=d.useState("floatingId"),N=En("div",t,{state:j,ref:[n,_,f?null:O],props:[v,{children:C,tabIndex:-1,id:E,role:g?"grid":"listbox","aria-multiselectable":w?"true":void 0,onKeyDown(I){if(!(u.state.disabled||u.state.readOnly)&&I.key==="Enter"){const P=u.state.activeIndex;if(P==null)return;Jl(I);const $=I.nativeEvent,B=u.state.listRef.current[P];B&&(u.state.selectionEventRef.current=$,B.click(),u.state.selectionEventRef.current=null)}},onKeyDownCapture(){u.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){u.state.keyboardActiveRef.current=!1}},c]});return b?N:o.jsx(bN,{elementsRef:u.state.listRef,labelsRef:h?void 0:u.state.labelsRef,children:N})}),MAn="",DAn=200;function LAn(e){const t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT);let n=null;for(;t.nextNode();){const r=t.currentNode;r.nodeValue!==""&&(n=r)}return n}function FAn(){const e=co(),t=y.useRef(null);return y.useEffect(()=>{if(mye)return;const n=t.current;if(n==null)return;const r=LAn(n);if(r==null)return;const s=r.nodeValue??"",a=`${s}${MAn}`;return r.nodeValue=a,e.start(DAn,()=>{r.nodeValue===a&&(r.nodeValue=s)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=s)}},[t,e]),t}const omt=y.createContext(void 0);function zAn(){const e=y.useContext(omt);if(e===void 0)throw new Error(yr(20));return e}const lmt=y.forwardRef(function(t,n){const{keepMounted:r=!1,...s}=t,a=my(),i=ht(a,on.mounted),l=ht(a,on.forceMounted);return i||r||l?o.jsx(omt.Provider,{value:r,children:o.jsx(XM,{ref:n,...s})}):null}),BAn=20;function rq(e,t,n,r){const[s,a]=y.useState(!1);Tt(()=>{if(!e||!t||n==null){a(!1);return}const i=dr(n).documentElement.clientWidth,l=n.offsetWidth;a(i>0&&l>0&&l>=i-BAn)},[e,t,n]),dht(e&&(!t||s),r)}const cmt=y.forwardRef(function(t,n){const{render:r,className:s,anchor:a,positionMethod:i="absolute",side:l="bottom",align:c="center",sideOffset:u=0,alignOffset:d=0,collisionBoundary:f="clipping-ancestors",collisionPadding:p=5,arrowPadding:h=5,sticky:m=!1,disableAnchorTracking:g=!1,collisionAvoidance:v=Cye,style:b,...w}=t,S=my(),{filteredItems:O}=C1(),_=tq(),C=zAn(),j=ht(S,on.modal),E=ht(S,on.open),N=ht(S,on.mounted),I=ht(S,on.openMethod),P=ht(S,on.positionerElement),$=ht(S,on.triggerElement),B=ht(S,on.inputElement),D=ht(S,on.inputGroupElement),V=ht(S,on.inputInsidePopup),H=ht(S,on.transitionStatus),L=O.length===0,z=aN({anchor:a??(V?$:D??B),floatingRootContext:_,positionMethod:i,mounted:N,side:l,sideOffset:u,align:c,alignOffset:d,arrowPadding:h,collisionBoundary:f,collisionPadding:p,sticky:m,disableAnchorTracking:g,keepMounted:C,collisionAvoidance:v,lazyFlip:!0});rq(E&&j,I==="touch",P,$);const M={open:E,side:z.side,align:z.align,anchorHidden:z.anchorHidden,empty:L};Tt(()=>{S.set("popupSide",z.side)},[S,z.side]);const G=mt(R=>{S.set("positionerElement",R)}),U=iN(t,M,{styles:z.positionerStyles,transitionStatus:H,props:w,refs:[n,G],hidden:!N,inert:!E});return o.jsxs(tmt.Provider,{value:z,children:[N&&j&&o.jsx(y3,{inert:oN(!E),cutout:D??B??$}),U]})}),UAn={...mf,...ql},umt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,initialFocus:i,finalFocus:l,...c}=t,u=my(),d=bxe(),f=tq(),{filteredItems:p}=C1(),h=ht(u,on.mounted),m=ht(u,on.open),g=ht(u,on.openMethod),v=ht(u,on.transitionStatus),b=ht(u,on.inputInsidePopup),w=ht(u,on.inputElement),S=ht(u,on.modal),O=p.length===0;Vl({open:m,ref:u.state.popupRef,onComplete(){m&&u.state.onOpenChangeComplete(!0)}});const _={open:m,side:d.side,align:d.align,anchorHidden:d.anchorHidden,transitionStatus:v,empty:O},C=En("div",t,{state:_,ref:[n,u.state.popupRef],props:[{role:b?"dialog":"presentation",tabIndex:-1,onFocus(P){const $=Si(P.nativeEvent);g!=="touch"&&(dn(u.state.listElement,$)||$===P.currentTarget)&&u.state.inputRef.current?.focus()}},u_(v),c],stateAttributesMapping:UAn}),E=i===void 0?b?P=>P==="touch"?u.state.popupRef.current:w:!1:i;let N;l!=null?N=l:N=b?void 0:!1;const I=!b||S;return o.jsx(nN,{context:f,disabled:!h,modal:I,openInteractionType:g,initialFocus:E,returnFocus:N,getInsideElements:()=>[u.state.startDismissRef.current,u.state.endDismissRef.current],children:o.jsxs(y.Fragment,{children:[C,I&&o.jsx(nmt,{ref:u.state.endDismissRef})]})})});let wxe=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Ox(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:s,index:a}=e,{register:i,unregister:l,subscribeMapChange:c,elementsRef:u,labelsRef:d,nextIndexRef:f}=AAn(),p=y.useRef(-1),[h,m]=y.useState(a??(s===wxe.GuessFromOrder?()=>{if(p.current===-1){const b=f.current;f.current+=1,p.current=b}return p.current}:-1)),g=y.useRef(null),v=y.useCallback(b=>{if(g.current=b,h!==-1&&b!==null&&(u.current[h]=b,d)){const w=t!==void 0;d.current[h]=w?t:r?.current?.textContent??b.textContent}},[h,u,d,t,r]);return Tt(()=>{if(a!=null)return;const b=g.current;if(b)return i(b,n),()=>{l(b)}},[a,i,l,n]),Tt(()=>{if(a==null)return c(b=>{const w=g.current?b.get(g.current)?.index:null;w!=null&&m(w)})},[a,c,m]),y.useMemo(()=>({ref:v,index:h}),[h,v])}const dmt=y.createContext(void 0);function fmt(){const e=y.useContext(dmt);if(!e)throw new Error(yr(19));return e}const qAn=y.createContext(!1);function VAn(){return y.useContext(qAn)}const pmt=y.memo(y.forwardRef(function(t,n){const{render:r,className:s,style:a,value:i=null,index:l,disabled:c=!1,nativeButton:u=!1,...d}=t,f=y.useRef(!1),p=y.useRef(null),h=Ox({index:l,textRef:p,indexGuessBehavior:wxe.GuessFromOrder}),m=my(),g=VAn(),{flatFilteredItems:v,hasItems:b}=C1(),w=ht(m,on.open),S=ht(m,on.selectionMode),O=ht(m,on.readOnly),_=ht(m,on.virtualized),C=ht(m,on.isItemEqualToValue),j=S!=="none",E=l??(_?bw(v,i,C):h.index),N=h.index!==-1,I=ht(m,on.id),P=ht(m,on.isActive,E),$=ht(m,on.isSelected,i),B=ht(m,on.itemProps),D=y.useRef(null),V=I!=null&&N?`${I}-${E}`:void 0,H=$&&j;Tt(()=>{if(!(N&&(_||l!=null)))return;const W=m.state.listRef.current;return W[E]=D.current,()=>{delete W[E]}},[N,_,E,l,m]),Tt(()=>{if(!N||b)return;const q=m.state.valuesRef.current;return q[E]=i,S!=="none"&&m.state.allValuesRef.current.push(i),()=>{delete q[E]}},[N,b,E,i,m,S]),Tt(()=>{if(!w){f.current=!1;return}if(!N||b)return;const q=m.state.selectedValue,W=Array.isArray(q)?q[q.length-1]:q;Wv(i,W,C)&&m.set("selectedIndex",E)},[N,b,w,m,E,i,C]);const{getButtonProps:L,buttonRef:F}=vd({disabled:c,focusableWhenDisabled:!0,native:u,composite:!0}),z={disabled:c,selected:H,highlighted:P};function M(q){function W(){m.state.handleSelection(q,i)}m.state.submitOnItemClick?(fo.flushSync(W),m.state.requestSubmit()):W()}const G={id:V,role:g?"gridcell":"option","aria-selected":j?H:void 0,tabIndex:void 0,onPointerDownCapture(q){f.current=!0,q.preventDefault()},onMouseDown(q){q.preventDefault()},onClick(q){c||O||M(q.nativeEvent)},onMouseUp(q){const W=f.current;f.current=!1,!(c||O||q.button!==0||W||!P)&&M(q.nativeEvent)}},U=En("div",t,{ref:[F,n,h.ref,D],state:z,props:[B,G,d,L]}),R=y.useMemo(()=>({selected:H,textRef:p}),[H,p]);return o.jsx(dmt.Provider,{value:R,children:U})})),HAn=y.forwardRef(function(t,n){const r=t.keepMounted??!1,{selected:s}=fmt();return r||s?o.jsx(ZAn,{...t,ref:n}):null}),ZAn=y.memo(y.forwardRef((e,t)=>{const{render:n,className:r,style:s,keepMounted:a,...i}=e,{selected:l}=fmt(),c=y.useRef(null),{transitionStatus:u,setMounted:d}=bg(l),p=En("span",e,{ref:[t,c],state:{selected:l,transitionStatus:u},props:[{"aria-hidden":!0,children:"✔️"},i],stateAttributesMapping:ql});return Vl({open:l,ref:c,onComplete(){l||d(!1)}}),p})),hmt=y.forwardRef(function(t,n){const{render:r,className:s,style:a,children:i,...l}=t,{filteredItems:c}=C1(),u=my(),d=FAn(),f=c.length===0?i:null;return En("div",t,{ref:[n,u.state.emptyRef,d],props:[{children:f,role:"status","aria-live":"polite","aria-atomic":!0},l]})}),WAn=y.forwardRef(function(t,n){const{className:r,render:s,orientation:a="horizontal",style:i,...l}=t;return En("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})});function QAn(e){return e==="link"?"ghost":e}function mmt({variant:e,size:t,error:n,className:r}){const s=QAn(e);return K(i3({variant:s,size:t}),"w-full min-w-32 justify-between",wct[s],"data-[placeholder]:text-neutral3",n&&"border-error hover:border-error focus-visible:border-error",r)}const hs={root:"flex flex-col gap-1.5",chevron:"ml-2 h-4 w-4 shrink-0 opacity-60",placeholder:"text-neutral3",popup:K("min-w-(--anchor-width) w-max max-w-(--available-width) rounded-xl border border-border1 bg-surface3 text-neutral4","shadow-dialog","origin-(--transform-origin)","transition-[transform,scale,opacity] duration-150 ease-out","data-starting-style:scale-95 data-starting-style:opacity-0","data-ending-style:scale-95 data-ending-style:opacity-0"),positioner:"z-50 pointer-events-auto",searchContainer:K("flex items-center border-b border-border1 px-2.5 py-1.5",is.colors),searchIcon:K("mr-2 h-3.5 w-3.5 shrink-0 text-neutral3",is.colors),searchInput:K("flex h-7 w-full rounded-md bg-transparent py-1 text-ui-smd leading-ui-sm text-neutral6","placeholder:text-neutral3 disabled:cursor-not-allowed disabled:opacity-50","outline-none focus:outline-none focus-visible:outline-none",is.colors),empty:"not-empty:block hidden py-4 text-center text-ui-smd text-neutral3",list:"max-h-dropdown-max-height overflow-y-auto overflow-x-hidden p-1",item:K("group/item relative flex cursor-pointer select-none items-center gap-2 rounded-md","pl-2.5 pr-2 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",is.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemMulti:K("relative flex cursor-pointer select-none items-center gap-2.5 rounded-md","pl-2 pr-2.5 py-1.5 min-h-8","text-ui-smd leading-ui-sm text-neutral4","outline-none focus:outline-none focus-visible:outline-none",is.colors,"data-highlighted:bg-surface4 data-highlighted:text-neutral6","data-selected:text-neutral6"),itemRightSlot:"ml-auto flex items-center gap-2 shrink-0",checkContainer:"flex h-4 w-4 shrink-0 items-center justify-center text-accent1",checkIcon:"h-3.5 w-3.5",checkbox:"flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border",checkboxSelected:"bg-accent1 border-accent1",checkboxUnselected:"border-border2",checkboxIcon:"h-3 w-3 text-surface1",optionContent:"flex items-center gap-2 w-full min-w-0",optionText:"flex flex-col gap-0.5 min-w-0",optionLabel:"truncate",optionDescription:"text-ui-sm text-neutral3 truncate",optionEnd:"ml-auto flex items-center shrink-0",error:"text-ui-sm text-accent2"};function gmt({options:e,value:t=[],onValueChange:n,placeholder:r="Select options...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.filter(b=>t.includes(b.value)),g=b=>{b&&n?.(b.map(w=>w.value))},v=m.length===0?r:`${m.length} selected`;return o.jsxs("div",{className:hs.root,children:[o.jsxs(Jht,{multiple:!0,items:e,value:m,onValueChange:g,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(smt,{className:mmt({variant:c,size:u,error:!!h,className:i}),children:[o.jsx("span",{className:K("truncate",m.length===0&&hs.placeholder),children:v}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(h3,{className:hs.chevron})})]}),o.jsx(lmt,{container:p,children:o.jsx(cmt,{align:"start",sideOffset:4,className:hs.positioner,children:o.jsxs(umt,{className:hs.popup,children:[o.jsxs("div",{className:hs.searchContainer,children:[o.jsx(Gj,{className:hs.searchIcon}),o.jsx(rmt,{className:hs.searchInput,placeholder:s})]}),o.jsx(hmt,{className:hs.empty,children:a}),o.jsx(imt,{className:hs.list,children:b=>{const w=t.includes(b.value);return o.jsxs(pmt,{value:b,className:hs.itemMulti,children:[o.jsx("span",{className:K(hs.checkbox,w?hs.checkboxSelected:hs.checkboxUnselected),children:w&&o.jsx(wx,{className:hs.checkboxIcon})}),o.jsxs("span",{className:hs.optionContent,children:[b.start,o.jsxs("span",{className:hs.optionText,children:[o.jsx("span",{className:hs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:hs.optionDescription,children:b.description})]}),b.end?o.jsx("div",{className:hs.optionEnd,children:b.end}):null]})]},b.value)}})]})})})]}),h&&o.jsx("span",{className:hs.error,children:h})]})}const vmt=y.createContext(void 0);function GAn({container:e,children:t}){return o.jsx(vmt.Provider,{value:e??void 0,children:t})}function x3(e){const t=y.useContext(vmt);return e??t??void 0}function Hc({options:e,value:t,onValueChange:n,placeholder:r="Select option...",searchPlaceholder:s="Search...",emptyText:a="No option found.",className:i,disabled:l=!1,variant:c="default",size:u="md",open:d,onOpenChange:f,container:p,error:h}){const m=e.find(b=>b.value===t)??null,g=x3(p),v=b=>{b&&n?.(b.value)};return o.jsxs("div",{className:hs.root,children:[o.jsxs(Jht,{autoHighlight:!0,items:e,value:m,onValueChange:v,disabled:l,open:d,onOpenChange:f,children:[o.jsxs(smt,{className:mmt({variant:c,size:u,error:!!h,className:i}),children:[o.jsxs("span",{className:"flex items-center gap-2 min-w-0 flex-1",children:[m?.start,o.jsx("span",{className:"truncate",children:o.jsx(CAn,{placeholder:r})})]}),o.jsx("span",{className:"flex shrink-0 items-center",children:o.jsx(h3,{className:hs.chevron})})]}),o.jsx(lmt,{container:g,children:o.jsx(cmt,{align:"start",sideOffset:4,className:hs.positioner,children:o.jsxs(umt,{className:hs.popup,children:[o.jsxs("div",{className:hs.searchContainer,children:[o.jsx(Gj,{className:hs.searchIcon}),o.jsx(rmt,{className:hs.searchInput,placeholder:s})]}),o.jsx(hmt,{className:hs.empty,children:a}),o.jsx(imt,{className:hs.list,children:b=>o.jsxs(pmt,{value:b,className:hs.item,children:[b.start,o.jsxs("span",{className:hs.optionText,children:[o.jsx("span",{className:hs.optionLabel,children:b.label}),b.description&&o.jsx("span",{className:hs.optionDescription,children:b.description})]}),o.jsxs("span",{className:hs.itemRightSlot,children:[b.end?o.jsx("div",{className:hs.optionEnd,children:b.end}):null,o.jsx("span",{className:hs.checkContainer,children:o.jsx(HAn,{children:o.jsx(wx,{className:hs.checkIcon})})})]})]},b.value)})]})})})]}),h&&o.jsx("span",{className:hs.error,children:h})]})}var a4e=1,YAn=.9,XAn=.8,KAn=.17,aX=.1,iX=.999,JAn=.9999,eRn=.99,tRn=/[\\\/_+.#"@\[\(\{&]/,nRn=/[\\\/_+.#"@\[\(\{&]/g,rRn=/[\s-]/,ymt=/[\s-]/g;function efe(e,t,n,r,s,a,i){if(a===t.length)return s===e.length?a4e:eRn;var l=`${s},${a}`;if(i[l]!==void 0)return i[l];for(var c=r.charAt(a),u=n.indexOf(c,s),d=0,f,p,h,m;u>=0;)f=efe(e,t,n,r,u+1,a+1,i),f>d&&(u===s?f*=a4e:tRn.test(e.charAt(u-1))?(f*=XAn,h=e.slice(s,u-1).match(nRn),h&&s>0&&(f*=Math.pow(iX,h.length))):rRn.test(e.charAt(u-1))?(f*=YAn,m=e.slice(s,u-1).match(ymt),m&&s>0&&(f*=Math.pow(iX,m.length))):(f*=KAn,s>0&&(f*=Math.pow(iX,u-s))),e.charAt(u)!==t.charAt(a)&&(f*=JAn)),(f<aX&&n.charAt(u-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(u-1)!==r.charAt(a))&&(p=efe(e,t,n,r,u+1,a+2,i),p*aX>f&&(f=p*aX)),f>d&&(d=f),u=n.indexOf(c,u+1);return i[l]=d,d}function i4e(e){return e.toLowerCase().replace(ymt," ")}function sRn(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,efe(e,t,i4e(e),i4e(t),0,0,{})}var oX="focusScope.autoFocusOnMount",lX="focusScope.autoFocusOnUnmount",o4e={bubbles:!1,cancelable:!0},aRn="FocusScope",bmt=y.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,c]=y.useState(null),u=Rj(s),d=Rj(a),f=y.useRef(null),p=yg(t,g=>c(g)),h=y.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;y.useEffect(()=>{if(r){let g=function(S){if(h.paused||!l)return;const O=S.target;l.contains(O)?f.current=O:$0(f.current,{select:!0})},v=function(S){if(h.paused||!l)return;const O=S.relatedTarget;O!==null&&(l.contains(O)||$0(f.current,{select:!0}))},b=function(S){if(document.activeElement===document.body)for(const _ of S)_.removedNodes.length>0&&$0(l)};document.addEventListener("focusin",g),document.addEventListener("focusout",v);const w=new MutationObserver(b);return l&&w.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",g),document.removeEventListener("focusout",v),w.disconnect()}}},[r,l,h.paused]),y.useEffect(()=>{if(l){c4e.add(h);const g=document.activeElement;if(!l.contains(g)){const b=new CustomEvent(oX,o4e);l.addEventListener(oX,u),l.dispatchEvent(b),b.defaultPrevented||(iRn(dRn(xmt(l)),{select:!0}),document.activeElement===g&&$0(l))}return()=>{l.removeEventListener(oX,u),setTimeout(()=>{const b=new CustomEvent(lX,o4e);l.addEventListener(lX,d),l.dispatchEvent(b),b.defaultPrevented||$0(g??document.body,{select:!0}),l.removeEventListener(lX,d),c4e.remove(h)},0)}}},[l,u,d,h]);const m=y.useCallback(g=>{if(!n&&!r||h.paused)return;const v=g.key==="Tab"&&!g.altKey&&!g.ctrlKey&&!g.metaKey,b=document.activeElement;if(v&&b){const w=g.currentTarget,[S,O]=oRn(w);S&&O?!g.shiftKey&&b===O?(g.preventDefault(),n&&$0(S,{select:!0})):g.shiftKey&&b===S&&(g.preventDefault(),n&&$0(O,{select:!0})):b===w&&g.preventDefault()}},[n,r,h.paused]);return o.jsx(pf.div,{tabIndex:-1,...i,ref:p,onKeyDown:m})});bmt.displayName=aRn;function iRn(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if($0(r,{select:t}),document.activeElement!==n)return}function oRn(e){const t=xmt(e),n=l4e(t,e),r=l4e(t.reverse(),e);return[n,r]}function xmt(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const s=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||s?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function l4e(e,t){for(const n of e)if(!lRn(n,{upTo:t}))return n}function lRn(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function cRn(e){return e instanceof HTMLInputElement&&"select"in e}function $0(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&cRn(e)&&t&&e.select()}}var c4e=uRn();function uRn(){let e=[];return{add(t){const n=e[0];t!==n&&n?.pause(),e=u4e(e,t),e.unshift(t)},remove(t){e=u4e(e,t),e[0]?.resume()}}}function u4e(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function dRn(e){return e.filter(t=>t.tagName!=="A")}var cX=0;function fRn(){y.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??d4e()),document.body.insertAdjacentElement("beforeend",e[1]??d4e()),cX++,()=>{cX===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),cX--}},[])}function d4e(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var uv=function(){return uv=Object.assign||function(t){for(var n,r=1,s=arguments.length;r<s;r++){n=arguments[r];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t},uv.apply(this,arguments)};function wmt(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)t.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(n[r[s]]=e[r[s]]);return n}function pRn(e,t,n){if(n||arguments.length===2)for(var r=0,s=t.length,a;r<s;r++)(a||!(r in t))&&(a||(a=Array.prototype.slice.call(t,0,r)),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var Y8="right-scroll-bar-position",X8="width-before-scroll-bar",hRn="with-scroll-bars-hidden",mRn="--removed-body-scroll-bar-size";function uX(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function gRn(e,t){var n=y.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var s=n.value;s!==r&&(n.value=r,n.callback(r,s))}}}})[0];return n.callback=t,n.facade}var vRn=typeof window<"u"?y.useLayoutEffect:y.useEffect,f4e=new WeakMap;function yRn(e,t){var n=gRn(null,function(r){return e.forEach(function(s){return uX(s,r)})});return vRn(function(){var r=f4e.get(n);if(r){var s=new Set(r),a=new Set(e),i=n.current;s.forEach(function(l){a.has(l)||uX(l,null)}),a.forEach(function(l){s.has(l)||uX(l,i)})}f4e.set(n,e)},[e]),n}function bRn(e){return e}function xRn(e,t){t===void 0&&(t=bRn);var n=[],r=!1,s={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(a){var i=t(a,r);return n.push(i),function(){n=n.filter(function(l){return l!==i})}},assignSyncMedium:function(a){for(r=!0;n.length;){var i=n;n=[],i.forEach(a)}n={push:function(l){return a(l)},filter:function(){return n}}},assignMedium:function(a){r=!0;var i=[];if(n.length){var l=n;n=[],l.forEach(a),i=n}var c=function(){var d=i;i=[],d.forEach(a)},u=function(){return Promise.resolve().then(c)};u(),n={push:function(d){i.push(d),u()},filter:function(d){return i=i.filter(d),n}}}};return s}function wRn(e){e===void 0&&(e={});var t=xRn(null);return t.options=uv({async:!0,ssr:!1},e),t}var Smt=function(e){var t=e.sideCar,n=wmt(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return y.createElement(r,uv({},n))};Smt.isSideCarExport=!0;function SRn(e,t){return e.useMedium(t),Smt}var kmt=wRn(),dX=function(){},sq=y.forwardRef(function(e,t){var n=y.useRef(null),r=y.useState({onScrollCapture:dX,onWheelCapture:dX,onTouchMoveCapture:dX}),s=r[0],a=r[1],i=e.forwardProps,l=e.children,c=e.className,u=e.removeScrollBar,d=e.enabled,f=e.shards,p=e.sideCar,h=e.noRelative,m=e.noIsolation,g=e.inert,v=e.allowPinchZoom,b=e.as,w=b===void 0?"div":b,S=e.gapMode,O=wmt(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),_=p,C=yRn([n,t]),j=uv(uv({},O),s);return y.createElement(y.Fragment,null,d&&y.createElement(_,{sideCar:kmt,removeScrollBar:u,shards:f,noRelative:h,noIsolation:m,inert:g,setCallbacks:a,allowPinchZoom:!!v,lockRef:n,gapMode:S}),i?y.cloneElement(y.Children.only(l),uv(uv({},j),{ref:C})):y.createElement(w,uv({},j,{className:c,ref:C}),l))});sq.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};sq.classNames={fullWidth:X8,zeroRight:Y8};var kRn=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function ORn(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=kRn();return t&&e.setAttribute("nonce",t),e}function _Rn(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function CRn(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var ERn=function(){var e=0,t=null;return{add:function(n){e==0&&(t=ORn())&&(_Rn(t,n),CRn(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jRn=function(){var e=ERn();return function(t,n){y.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},Omt=function(){var e=jRn(),t=function(n){var r=n.styles,s=n.dynamic;return e(r,s),null};return t},TRn={left:0,top:0,right:0,gap:0},fX=function(e){return parseInt(e||"",10)||0},NRn=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],s=t[e==="padding"?"paddingRight":"marginRight"];return[fX(n),fX(r),fX(s)]},IRn=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return TRn;var t=NRn(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},ARn=Omt(),oj="data-scroll-locked",RRn=function(e,t,n,r){var s=e.left,a=e.top,i=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
227
227
|
.`.concat(hRn,` {
|
|
228
228
|
overflow: hidden `).concat(r,`;
|
|
229
229
|
padding-right: `).concat(l,"px ").concat(r,`;
|
|
@@ -764,7 +764,7 @@ window.parent.postMessage({jsonrpc:'2.0',method:'ui/notifications/sandbox-proxy-
|
|
|
764
764
|
"groundTruth": "Expected result (optional)",
|
|
765
765
|
"metadata": { "key": "value" } // optional
|
|
766
766
|
}
|
|
767
|
-
]`})]})]})}function HQr({errors:e,maxErrors:t=5}){if(e.length===0)return null;const n=e.slice(0,t),r=e.length-t;return o.jsxs("div",{className:"bg-accent2/10 border border-accent2/30 rounded-md p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-accent2 mb-2",children:[o.jsx(Ge,{children:o.jsx(gp,{className:"w-4 h-4"})}),o.jsxs("span",{className:"font-medium text-sm",children:[e.length," validation error",e.length!==1?"s":""]})]}),o.jsx("ul",{className:"text-sm text-accent2/80 space-y-1",children:n.map((s,a)=>o.jsxs("li",{className:"flex gap-2",children:[o.jsx("span",{className:"shrink-0",children:"•"}),o.jsx("span",{children:s.message})]},a))}),r>0&&o.jsxs("div",{className:"text-xs text-accent2/60 mt-2",children:["+",r," more error",r!==1?"s":""]})]})}function ZQr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("upload"),[i,l]=y.useState(null),[c,u]=y.useState({current:0,total:0}),[d,f]=y.useState(null),[p,h]=y.useState(!1),{parseFile:m,isParsing:g,error:v}=UWr(),{batchInsertItems:b}=Li(),w=y.useCallback(async I=>{try{const P=await m(I);l(P),a("preview")}catch{}},[m]),S=y.useCallback(async()=>{if(!i||i.items.length===0)return;a("importing"),h(!0);const{items:I}=i;u({current:0,total:I.length});try{await b.mutateAsync({datasetId:e,items:I.map(P=>({input:P.input,groundTruth:P.groundTruth,metadata:P.metadata}))}),f({success:I.length,errors:0})}catch{f({success:0,errors:I.length})}u({current:I.length,total:I.length}),h(!1),a("complete")},[i,b,e]),O=y.useCallback(()=>{n(!1),r?.(),d&&d.success>0&&Ue.success(`Imported ${d.success} item${d.success!==1?"s":""}`),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150)},[n,r,d]),_=y.useCallback(()=>{p||(n(!1),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150))},[p,n]),C=i&&i.items.length>0&&i.errors.length===0,j=()=>{switch(s){case"upload":return o.jsx(VQr,{onFileSelect:w,isParsing:g,error:v?.message});case"preview":return i?o.jsx("div",{className:"flex flex-col gap-4",children:i.errors.length>0?o.jsxs(o.Fragment,{children:[o.jsx(HQr,{errors:i.errors}),o.jsx("div",{className:"text-sm text-neutral4",children:"Please fix the errors in your JSON file and try again."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-sm text-neutral4",children:["Found ",i.items.length," valid item",i.items.length!==1?"s":""," to import."]}),o.jsx(qQr,{items:i.items,maxRows:5})]})}):null;case"importing":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx(Ht,{}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Importing items..."}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[c.current," of ",c.total]})]})]});case"complete":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx("div",{className:"text-4xl",children:d&&d.errors===0?"✓":"⚠"}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Import Complete"}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[d?.success??0," item",d?.success!==1?"s":""," imported",d&&d.errors>0&&o.jsxs("span",{className:"text-accent2",children:[" ","(",d.errors," error",d.errors!==1?"s":"",")"]})]})]})]})}},E=()=>{switch(s){case"upload":return o.jsx(pe,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(pe,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(pe,{variant:"primary",onClick:S,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(pe,{variant:"primary",onClick:O,children:"Done"})}},N={upload:"Import JSON",preview:"Preview Data",importing:"Importing",complete:"Import Complete"};return o.jsx(Nr,{open:t,onOpenChange:_,children:o.jsxs(_r,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:N[s]}),o.jsx(Qs,{children:"Import dataset items from a JSON file."})]}),o.jsx(Lr,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:j()}),o.jsx(uc,{className:"px-6 pt-4 flex justify-end gap-2",children:E()})]})})}const xEe=e=>{const t=He(),{data:n}=xM(e),r=n?.experiments;return xt({queryKey:["dataset-review-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="needs-review").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})},WQr=e=>{const t=He(),{data:n}=xM(e),r=n?.experiments;return xt({queryKey:["dataset-completed-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="complete").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})};function QQr(e,t){if(typeof e=="string")return e.length>t?e.slice(0,t)+"...":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t)+"...":n}catch{return String(e)}}function $5t({datasetId:e,experimentId:t,featuredItemId:n}){const r=He(),{data:s}=Dx(e),{data:a,isLoading:i}=xEe(e),{data:l,isLoading:c}=WQr(e),u=y.useMemo(()=>t?(a??[]).filter(Oe=>Oe.experimentId===t):a,[a,t]),d=y.useMemo(()=>t?(l??[]).filter(Oe=>Oe.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Li(),[p,h]=y.useState(n??null);y.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(""),[I,P]=y.useState(""),[$,B]=y.useState(""),[D,V]=y.useState([]),[H,L]=y.useState(!1),[F,z]=y.useState(null),M=y.useMemo(()=>F??u??[],[F,u]);y.useEffect(()=>{z(null)},[e,t]),y.useEffect(()=>{u&&F===null&&z(u)},[u,F]);const G=y.useMemo(()=>{const Oe=new Set;if(s?.tags)for(const _e of s.tags)Oe.add(_e);for(const _e of M)for(const Ce of _e.tags)Oe.add(Ce);return[...Oe].sort()},[s,M]),U=y.useCallback(Oe=>{!s||!e||(s.tags??[]).includes(Oe)},[s,e]),R=y.useMemo(()=>m?m==="__untagged__"?M.filter(Oe=>Oe.tags.length===0):M.filter(Oe=>Oe.tags.includes(m)):M,[M,m]),q=y.useMemo(()=>{const Oe=new Map;for(const _e of M)for(const Ce of _e.tags)Oe.set(Ce,(Oe.get(Ce)??0)+1);return[...Oe.entries()].sort((_e,Ce)=>Ce[1]-_e[1])},[M]),W=y.useMemo(()=>M.filter(Oe=>Oe.tags.length===0).length,[M]),X=y.useMemo(()=>{let Oe=0;return m&&Oe++,w&&Oe++,Oe},[m,w]),ne=y.useCallback((Oe,_e)=>{z(Ee=>(Ee??[]).map($e=>$e.id===Oe?{...$e,tags:_e}:$e));const Ce=M.find(Ee=>Ee.id===Oe);Ce?.experimentId&&Ce?.datasetId&&f.mutate({datasetId:Ce.datasetId,experimentId:Ce.experimentId,resultId:Ce.id,tags:_e})},[M,f]),ee=y.useCallback((Oe,_e)=>{const Ce=M.find(Ee=>Ee.id===Oe);Ce?.traceId&&_e!==void 0&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:_e==="positive"?1:-1,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),z(Ee=>(Ee??[]).map($e=>$e.id===Oe?{...$e,rating:_e}:$e))},[M,r]),J=y.useCallback((Oe,_e)=>{const Ce=M.find(Ee=>Ee.id===Oe);Ce?.traceId&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:_e,comment:_e,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),z(Ee=>(Ee??[]).map($e=>$e.id===Oe?{...$e,comment:_e}:$e))},[M,r]),ie=y.useCallback(Oe=>{const _e=M.find(Ce=>Ce.id===Oe);z(Ce=>(Ce??[]).filter(Ee=>Ee.id!==Oe)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(Oe),Ee}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[M,f,p]),ue=y.useCallback(Oe=>{const _e=M.find(Ce=>Ce.id===Oe);z(Ce=>(Ce??[]).filter(Ee=>Ee.id!==Oe)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(Oe),Ee}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[M,f,p]),Y=y.useMemo(()=>{const Oe=w?d??[]:R;return!w||!m?Oe:m==="__untagged__"?Oe.filter(_e=>_e.tags.length===0):Oe.filter(_e=>_e.tags.includes(m))},[w,d,R,m]),te=w?c:!1,le=y.useMemo(()=>new Set(Y.map(Oe=>Oe.id)),[Y]),fe=y.useMemo(()=>[...v].filter(Oe=>le.has(Oe)).length,[v,le]),se=Y.length>0&&fe===Y.length,he=fe>0&&!se,be=y.useCallback(Oe=>{b(_e=>{const Ce=new Set(_e);return Ce.has(Oe)?Ce.delete(Oe):Ce.add(Oe),Ce})},[]),we=y.useCallback(()=>{b(se?new Set:new Set(Y.map(Oe=>Oe.id)))},[se,Y]),Ie=y.useCallback(Oe=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&!Ce.tags.includes(Oe)&&ne(_e,[...Ce.tags,Oe])}},[M,v,ne]),ke=y.useCallback(Oe=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&Ce.tags.includes(Oe)&&ne(_e,Ce.tags.filter(Ee=>Ee!==Oe))}},[M,v,ne]),je=y.useCallback(()=>{for(const Oe of v)ue(Oe);b(new Set)},[v,ue]),Fe=y.useCallback(()=>{for(const Oe of v)ie(Oe);b(new Set)},[v,ie]),ce=y.useCallback(()=>{N(""),j(!0)},[]),ae=y.useCallback(async()=>{if(!(!I||!$)){_(!0),j(!1);try{const Oe=M.filter(Ce=>v.has(Ce.id));if(Oe.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${$}`,items:Oe.map(Ce=>({id:Ce.id,input:Ce.input,output:Ce.output??void 0,error:typeof Ce.error=="string"?Ce.error:Ce.error?String(Ce.error):void 0,scores:Ce.scores,existingTags:Ce.tags.length>0?Ce.tags:void 0})),availableTags:G.length>0?G:void 0,prompt:E||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(V(_e.proposedTags.map(Ce=>({...Ce,accepted:!0}))),L(!0))}catch(Oe){console.error("Analysis failed:",Oe)}finally{_(!1)}}},[I,$,M,v,r,G,E]),re=y.useCallback(()=>{for(const Oe of D){if(!Oe.accepted)continue;const _e=M.find(Ce=>Ce.id===Oe.itemId);if(_e){const Ce=[...new Set([..._e.tags,...Oe.tags])];ne(_e.id,Ce)}}L(!1)},[D,M,ne]),me=y.useCallback(Oe=>{h(_e=>_e===Oe?null:Oe)},[]),ye=y.useMemo(()=>p?Y.find(Oe=>Oe.id===p)??null:null,[p,Y]),Te=p?Y.findIndex(Oe=>Oe.id===p):-1,Re=Te>0?()=>h(Y[Te-1].id):void 0,Qe=Te>=0&&Te<Y.length-1?()=>h(Y[Te+1].id):void 0,Ze="auto minmax(15rem,1fr) 10rem 8rem 6rem 6rem";return i?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ht,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(Nr,{open:C,onOpenChange:j,children:o.jsxs(_r,{children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:"Analyze Items"}),o.jsx(Qs,{children:"Use an LLM to automatically suggest tags for the selected items."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(Pt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(_y,{value:I,onValueChange:P})]}),o.jsxs("div",{children:[o.jsx(Pt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(Cy,{llmId:I,value:$,onValueChange:B})]})]}),o.jsxs(ge,{variant:"ui-xs",className:"text-neutral3",children:[v.size," item",v.size!==1?"s":""," will be analyzed"]}),o.jsxs("div",{children:[o.jsx(Pt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(Ul,{value:E,onChange:Oe=>N(Oe.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(uc,{children:[o.jsx(pe,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),o.jsxs(pe,{onClick:ae,disabled:!I||!$||O,children:[O?o.jsx(Ht,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(Nr,{open:H,onOpenChange:L,children:o.jsxs(_r,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:"Review Proposed Tags"}),o.jsxs(Qs,{children:[D.filter(Oe=>Oe.accepted).length," of ",D.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:D.map((Oe,_e)=>{const Ce=M.find(Ee=>Ee.id===Oe.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Oe.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Go,{checked:Oe.accepted,onCheckedChange:Ee=>V($e=>$e.map((ze,Ke)=>Ke===_e?{...ze,accepted:!!Ee}:ze))}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate block",children:Ce?typeof Ce.input=="string"?Ce.input.slice(0,100):JSON.stringify(Ce.input).slice(0,100):Oe.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Oe.tags.map((Ee,$e)=>o.jsx(O5t,{tag:Ee,onRename:ze=>V(Ke=>Ke.map((Ye,Rt)=>Rt===_e?{...Ye,tags:Ye.tags.map((Ct,en)=>en===$e?ze:Ct)}:Ye)),onRemove:()=>V(ze=>ze.map((Ke,Ye)=>Ye===_e?{...Ke,tags:Ke.tags.filter((Rt,Ct)=>Ct!==$e)}:Ke))},`${Ee}-${$e}`))}),Oe.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Oe.reason})]})]})},Oe.itemId)})}),o.jsxs(uc,{children:[o.jsx(pe,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(pe,{onClick:re,disabled:D.filter(Oe=>Oe.accepted).length===0,children:["Accept ",D.filter(Oe=>Oe.accepted).length," proposals"]})]})]})}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",ye&&"grid-cols-[1fr_1fr]"),children:[o.jsxs("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between w-full flex-wrap gap-4 gap-x-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(pe,{variant:"outline",size:"md",children:[o.jsx(Aat,{}),"Filter",X>0&&o.jsx("span",{className:K("ml-0.5 inline-flex items-center justify-center rounded-full bg-accent1/50 text-neutral5 text-ui-sm w-5 h-5"),children:X})]})}),o.jsxs(ft.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Status",w&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!w,onCheckedChange:()=>{S(!1),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Review Queue"}),o.jsx(ft.CheckboxItem,{checked:w,onCheckedChange:()=>{S(!0),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Completed"})]})]}),o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:Oe=>Oe.preventDefault(),children:"All"}),W>0&&o.jsx(ft.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:Oe=>Oe.preventDefault(),children:"Untagged"}),q.length>0&&o.jsx(ft.Separator,{}),q.map(([Oe])=>o.jsx(ft.CheckboxItem,{checked:m===Oe,onCheckedChange:()=>g(m===Oe?null:Oe),onSelect:_e=>_e.preventDefault(),children:Oe},Oe))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:()=>{g(null),S(!1),h(null)},children:[o.jsx(ys,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(pe,{variant:"outline",size:"md",onClick:()=>{g(null),S(!1),h(null)},children:[o.jsx(ys,{}),"Reset"]})]}),!w&&v.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(k5t,{selectedCount:v.size,vocabulary:G,onApplyTag:Ie,onRemoveTag:ke,onNewTag:Oe=>Ie(Oe)}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(pe,{disabled:O,children:[O?o.jsx(Ht,{className:"w-4 h-4"}):o.jsx(Ge,{size:"sm",children:o.jsx(ea,{})}),"Actions"]})}),o.jsxs(ft.Content,{align:"end",children:[o.jsxs(ft.Item,{onSelect:je,children:[o.jsx(Ge,{size:"sm",children:o.jsx(Qk,{})}),"Complete"]}),o.jsxs(ft.Item,{onSelect:Fe,children:[o.jsx(Ge,{size:"sm",children:o.jsx(Zc,{})}),"Remove"]}),o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:ce,children:[o.jsx(Ge,{size:"sm",children:o.jsx(ng,{})}),"Analyze"]})]})]})]})]}),te?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ht,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:w?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:w?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(xe,{columns:Ze,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:!0,children:[w?o.jsx(xe.TopCell,{children:" "}):o.jsx(xe.TopSelectCell,{checked:se?!0:he?"indeterminate":!1,onToggle:()=>we(),"aria-label":"Select all"}),o.jsxs(xe.TopCells,{colStart:2,children:[o.jsx(xe.TopCell,{children:"Input"}),o.jsx(xe.TopCell,{children:"Comment"}),o.jsx(xe.TopCell,{children:"Tags"}),o.jsx(xe.TopCell,{children:"Rating"}),o.jsx(xe.TopCell,{children:"Scores"})]})]}),Y.map(Oe=>{const _e=Oe.scores?Object.entries(Oe.scores):[],Ce=p===Oe.id,Ee=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:QQr(Oe.input,200)})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:Oe.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Oe.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:Oe.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Oe.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(xe.Cell,{height:"compact",children:[Oe.rating==="positive"&&o.jsx(Ge,{size:"sm",className:"text-positive1",children:o.jsx(jve,{})}),Oe.rating==="negative"&&o.jsx(Ge,{size:"sm",className:"text-negative1",children:o.jsx(Eve,{})}),!Oe.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(xe.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ge,{size:"sm",className:"text-neutral3",children:o.jsx(tg,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(Jt,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(xe.RowWrapper,{children:[w?o.jsx(xe.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Oe.error?"Error":"Success",title:Oe.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Oe.error?"bg-red-700":"bg-green-600")})}):o.jsx(xe.SelectCell,{checked:v.has(Oe.id),onToggle:()=>be(Oe.id),"aria-label":`Select item ${Oe.id}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:Ce,onClick:()=>me(Oe.id),children:Ee})]},Oe.id)})]})]}),ye&&o.jsx(S5t,{item:ye,isCompleted:w,tagVocabulary:G,onRate:Oe=>ee(ye.id,Oe),onSetTags:Oe=>{ne(ye.id,Oe);for(const _e of Oe)G.includes(_e)||U(_e)},onComment:Oe=>J(ye.id,Oe),onRemove:()=>ie(ye.id),onComplete:w?void 0:()=>ue(ye.id),onPrevious:Re,onNext:Qe,onClose:()=>h(null)})]})]})}function GQr({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=vn(),[s,a]=zi(),{tab:i,activeVersion:l,handleTabChange:c}=bEe(s,a),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),[g,v]=y.useState([]),[b,w]=y.useState(!1),[S,O]=y.useState([]),[_,C]=y.useState(!1),[j,E]=y.useState([]),[N,I]=y.useState(0),[P,$]=y.useState(null),[B,D]=y.useState(""),[V]=a0e(B,300),{data:H}=Dx(e),{data:L=[],total:F,isLoading:z,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U}=HO(e,V||void 0,l),{total:R}=HO(e,void 0,l),[q,W]=y.useState({}),{data:X,isLoading:ne}=xM(e,void 0,q),{data:ee}=xM(e),{deleteItems:J}=Li(),ie=X?.experiments??[],ue=ee?.experiments??[],Y=mQr({hasSearchQuery:!!V,filteredItemsLength:L.length,unfilteredItemsTotal:R,itemsTotal:F}),{data:te}=xEe(e),le=te?.length??0,fe=re=>{$(re)},se=()=>{$(null)},he=re=>{v(re),m(!0)},be=re=>{O(re),w(!0)},we=re=>{w(re),re||(O([]),I(me=>me+1))},Ie=re=>{r(`/datasets/${e}/items?items=${re.join(",")}`)},ke=re=>{r(`/datasets/${e}/versions?ids=${re.join(",")}`)},je=re=>{E(re),C(!0)},Fe=async()=>{await J.mutateAsync({datasetId:e,itemIds:j}),Ue.success(`Deleted ${j.length} items`),C(!1),E([]),I(re=>re+1)},ce=re=>{m(!1),v([]),I(me=>me+1),n?.(re)},ae=re=>{m(re),re||(v([]),I(me=>me+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(vc,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(yc,{children:[o.jsxs(Ir,{value:"items",children:["Items ",o.jsx(Ys,{color:"gray",children:Y})]}),o.jsxs(Ir,{value:"experiments",children:["Experiments",o.jsx(Ys,{color:"gray",children:ie.length})]}),o.jsxs(Ir,{value:"review",children:["Review",le>0&&o.jsx(Ys,{color:"orange",children:le})]})]}),o.jsx(Wr,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(UQr,{datasetId:e,items:L,isLoading:z,featuredItemId:P,onItemSelect:fe,onItemClose:se,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:je,onCreateDatasetClick:he,onAddToDatasetClick:be,onCompareItemsClick:Ie,datasetName:H?.name,clearSelectionTrigger:N,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U,searchQuery:B,activeSearchQuery:V,onSearchChange:D,currentDatasetVersion:H?.version,onCompareVersionsClick:ke})}),o.jsx(Wr,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(IQr,{experiments:ie,allExperiments:ue,isLoading:ne,datasetId:e,filters:q,onFiltersChange:W})}),o.jsx(Wr,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx($5t,{datasetId:e})})]}),o.jsx(kQr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(ZQr,{datasetId:e,open:f,onOpenChange:p}),o.jsx(sQr,{open:h,onOpenChange:ae,items:g,onSuccess:ce}),o.jsx(aQr,{open:b,onOpenChange:we,items:S,currentDatasetId:e}),o.jsx(jt,{open:_,onOpenChange:C,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Items"}),o.jsxs(jt.Description,{children:["Are you sure you want to delete ",j.length," item",j.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:Fe,children:J.isPending?"Deleting...":"Delete"})]})]})})]})}function YQr(e){if(!(e instanceof Error))return null;const t=e.message.match(/- ({.*})$/);if(!t)return null;try{const n=JSON.parse(t[1]);if(n.field&&Array.isArray(n.errors))return{field:n.field,errors:n.errors}}catch{}return null}function JZe({field:e,errors:t}){return t.length?o.jsx("div",{className:"mt-2 space-y-1",children:t.map((n,r)=>o.jsxs("p",{className:"text-xs text-destructive",children:[o.jsxs("code",{className:"bg-destructive/10 px-1 rounded",children:[e,n.path!=="/"?n.path:""]}),": ",n.message]},r))}):null}function XQr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("{}"),[i,l]=y.useState(""),[c,u]=y.useState(""),[d,f]=y.useState(""),[p,h]=y.useState(null),{addItem:m}=Li(),g=async S=>{S.preventDefault();let O;try{O=JSON.parse(s)}catch{Ue.error("Input must be valid JSON");return}let _;if(i.trim())try{_=JSON.parse(i)}catch{Ue.error("Ground Truth must be valid JSON");return}let C;if(c.trim())try{C=JSON.parse(c)}catch{Ue.error("Expected Trajectory must be valid JSON");return}let j;if(d.trim())try{j=JSON.parse(d)}catch{Ue.error("Request Context must be valid JSON");return}try{await m.mutateAsync({datasetId:e,input:O,groundTruth:_,expectedTrajectory:C,requestContext:j}),Ue.success("Item added successfully"),h(null),a("{}"),l(""),u(""),f(""),n(!1),r?.()}catch(E){const N=YQr(E);N?h(N):Ue.error(`Failed to add item: ${E instanceof Error?E.message:"Unknown error"}`)}},v=S=>{a(S),p?.field==="input"&&h(null)},b=S=>{l(S),p?.field==="groundTruth"&&h(null)},w=()=>{a("{}"),l(""),u(""),f(""),h(null),n(!1)};return o.jsx(Nr,{open:t,onOpenChange:n,children:o.jsxs(_r,{className:"max-w-lg",children:[o.jsx(Cr,{children:o.jsx(Sr,{children:"Add Item"})}),o.jsx(Lr,{children:o.jsxs("form",{onSubmit:g,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(Kr,{value:s,onChange:v,showCopyButton:!1,className:"min-h-[120px]"}),p?.field==="input"&&o.jsx(JZe,{field:"input",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(Kr,{value:i,onChange:b,showCopyButton:!1,className:"min-h-[80px]"}),p?.field==="groundTruth"&&o.jsx(JZe,{field:"groundTruth",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(Kr,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(Kr,{value:d,onChange:f,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[o.jsx(pe,{type:"button",onClick:w,children:"Cancel"}),o.jsx(pe,{type:"submit",variant:"primary",disabled:m.isPending,children:m.isPending?"Adding...":"Add Item"})]})]})})]})})}function KQr({item:e}){return o.jsx(la,{withMargins:!1,children:o.jsxs(la.Column,{children:[o.jsxs(la.Title,{size:"smaller",children:[o.jsx(XT,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(Pa,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(la.Description,{children:[o.jsxs(ic,{children:[o.jsx(Sat,{})," Created ",Kn(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(ic,{children:[o.jsx(YO,{})," Version v",e.datasetVersion]})]})]})})}function wEe({item:e}){const t=e?.input?JSON.stringify(e.input,null,2):"null",n=e?.groundTruth?JSON.stringify(e.groundTruth,null,2):"null",r=e?.metadata?JSON.stringify(e.metadata,null,2):"null",s=e?.expectedTrajectory?JSON.stringify(e.expectedTrajectory,null,2):null;return o.jsxs(i0e,{children:[o.jsx(va.CodeSection,{title:"Input",icon:o.jsx(Gk,{}),codeStr:t}),o.jsx(va.CodeSection,{title:"Ground Truth",icon:o.jsx(Gm,{}),codeStr:n}),s&&o.jsx(va.CodeSection,{title:"Expected Trajectory",icon:o.jsx(Wat,{}),codeStr:s}),o.jsx(va.CodeSection,{title:"Metadata",icon:o.jsx(XO,{}),codeStr:r})]})}function JQr({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=Up(),i=y.useMemo(()=>s?Object.entries(s).map(([l,c])=>({value:l,label:c.scorer?.config?.name||l,description:c.scorer?.config?.description||""})):[],[s]);return o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Pt,{children:"Scorers (Optional)"}),o.jsx(gmt,{options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const eGr=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function tGr({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=sm(),{data:l,isLoading:c}=Ey(),{data:u,isLoading:d}=Up(),f=e==="agent"?Object.entries(a??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="workflow"?Object.entries(l??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="scorer"?Object.entries(u??{}).map(([g,v])=>({value:g,label:v.scorer?.config?.name??g})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=g=>{t(g),r("")},m=e==="agent"?"Agent":e==="workflow"?"Workflow":"Scorer";return o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Pt,{children:"Target Type"}),o.jsx(Hc,{options:eGr,value:e,onValueChange:h,placeholder:"Select target type",searchPlaceholder:"Search types...",emptyText:"No types available",container:s})]}),e&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Pt,{children:m}),o.jsx(Hc,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function nGr({requestContextSchema:e,onChange:t}){const n=y.useMemo(()=>{try{return hg(fg(e))}catch(r){return console.error("Failed to parse requestContextSchema:",r),null}},[e]);return n?o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{children:"Request Context"}),o.jsx(eH,{schema:n,onValuesChange:t,className:"[&_button[type=submit]]:hidden"})]}):o.jsx("p",{className:"text-sm text-destructive",children:"Failed to parse request context schema"})}function rGr({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=y.useRef(null),[l,c]=y.useState(""),[u,d]=y.useState(""),[f,p]=y.useState([]),[h,m]=y.useState({}),[g,v]=y.useState(""),{triggerExperiment:b}=Li(),w=!!(n&&Object.keys(n).length>0),S=l&&u,O=b.isPending,_=()=>{c(""),d(""),p([]),m({}),v("")},C=()=>{if(w){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},j=async()=>{if(!S)return;let N;try{N=C()}catch(I){const P=I instanceof Error?I.message:"Request Context must be valid JSON";bu.error(P);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});bu.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const P=I instanceof Error?I.message:"Failed to trigger experiment";bu.error(P)}},E=()=>{O||(s(!1),_())};return o.jsx(Nr,{open:r,onOpenChange:E,children:o.jsxs(_r,{ref:i,children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:"Run Experiment"}),o.jsx(Qs,{children:t?`Execute items from ${Kn(new Date(t),"MMM d, yyyy")} version against a target.`:"Execute all items in this dataset against a target."})]}),o.jsxs(Lr,{className:"grid gap-6",children:[o.jsx(tGr,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(JQr,{selectedScorers:f,setSelectedScorers:p,disabled:O,container:i}),w?o.jsx(nGr,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{children:"Request Context (JSON, optional)"}),o.jsx(Kr,{value:g,onChange:v,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(uc,{className:"px-6 pt-4",children:[o.jsx(pe,{onClick:E,disabled:O,children:"Cancel"}),o.jsx(pe,{variant:"primary",onClick:j,disabled:!S||O,children:O?o.jsxs(o.Fragment,{children:[o.jsx(Ht,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const sGr=e=>{const t=He();return xt({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})};function aGr({result:e,scores:t,onPrevious:n,onNext:r,onClose:s,onShowTrace:a,onOpenInReview:i,onScoreClick:l,featuredScoreId:c,onFlagForReview:u,collapsed:d,onCollapsedChange:f}){const[p,h]=y.useState(!1),m=d??p,g=f??h,v=!!e?.error,b=u8(e?.input),w=u8(e?.output),S=u8(e?.groundTruth),O=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(Sn,{collapsed:m,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[f&&o.jsx(pe,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>g(!m),children:m?o.jsx(Cat,{}):o.jsx(_at,{})}),o.jsx(Sn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(pe,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(bSe,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(Sn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(Ft,{children:[o.jsx(Ft.Key,{children:"Item Id"}),o.jsx(Ft.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(Ft.Key,{children:"Created"}),o.jsx(Ft.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),v&&o.jsx(Rn,{variant:"destructive",title:"Error",children:o.jsx(Rn.Message,{children:u8(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(xe,{columns:"1fr 1fr",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Scorer"}),o.jsx(xe.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(xe.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(xe.Cell,{height:"compact",children:C.scorerId}),o.jsx(xe.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),(e.status||_.length>0||O)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Sn.SectionHeading,{icon:o.jsx(XO,{}),className:"mb-2",children:"Review"}),(e.status||_.length>0)&&o.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.status&&o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${e.status==="needs-review"?"bg-orange-500/10 text-orange-400":e.status==="complete"?"bg-accent1/10 text-accent1":"bg-neutral3/10 text-neutral4"}`,children:e.status}),_.map(C=>o.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-surface4 text-neutral4",children:C},C))]}),O&&o.jsx("div",{children:o.jsxs(pe,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(KB,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(pe,{size:"sm",onClick:i,children:[o.jsx(ja,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:"Input",icon:o.jsx(XT,{}),codeStr:b}),o.jsx(Sn.CodeSection,{title:"Output",icon:o.jsx(Gm,{}),codeStr:w}),o.jsx(Sn.CodeSection,{title:"Ground Truth",icon:o.jsx(Cve,{}),codeStr:S})]})]})]})}function u8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function iGr({results:e,isLoading:t,featuredResultId:n,onResultClick:r,columns:s,scoresByItemId:a,scorerIds:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u,selectedIds:d,onToggleSelect:f}){const p=!!(d&&f),h=[p?"auto":"",...s.map(g=>g.size)].filter(Boolean).join(" "),m=s.some(g=>g.name==="input");return t?o.jsx(Wo,{columns:h}):o.jsxs(xe,{columns:h,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:p,children:[p&&o.jsx(xe.TopCell,{children:" "}),p?o.jsx(xe.TopCells,{colStart:2,children:s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(xe.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const v=!!g.error,b=g.id===n,w=o.jsxs(o.Fragment,{children:[o.jsx(xe.IdCell,{id:g.itemId}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("div",{className:"flex items-center justify-center w-10 relative bg-transparent h-full",children:o.jsx("div",{role:"img","aria-label":v?"Error":"Success",className:K("w-2 h-2 rounded-full",v?"bg-red-700":"bg-green-600")})})}),o.jsx(Hn,{children:v?"Error":"Success"})]})}),m&&o.jsx(xe.MonoCell,{children:lGr(oGr(g.input),200)}),i?.map(S=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===S);return o.jsx(xe.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},S)})]});return p?o.jsxs(xe.RowWrapper,{children:[o.jsx(xe.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:w})]},g.id):o.jsx(xe.RowButton,{featured:b,onClick:()=>r(g.id),children:w},g.id)}),o.jsx(xe.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function oGr(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function lGr(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function cGr(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function uGr({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=y.useState(!1),u=a??l,d=i??c,f=cGr(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(Sn,{collapsed:u,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[i&&o.jsx(pe,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(Cat,{}):o.jsx(_at,{})}),(n||t)&&o.jsx(Sn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(pe,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(bSe,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(Sn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(tg,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(Sn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(ah,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(ah,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(ah,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(ah,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const eWe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function dGr({scoresByItemId:e,experimentStatus:t}){const n=y.useMemo(()=>{if(!e)return[];const r={};for(const s of Object.values(e))for(const a of s)r[a.scorerId]||(r[a.scorerId]={sum:0,count:0}),r[a.scorerId].sum+=a.score,r[a.scorerId].count++;return Object.entries(r).map(([s,{sum:a,count:i}])=>({scorerId:s,avg:a/i,count:i})).sort((s,a)=>s.scorerId.localeCompare(a.scorerId))},[e]);if(n.length===0){const r=t==="running"||t==="pending",s=e!==void 0;let a,i;return r?(a="Experiment in progress",i="Summary metrics will appear here once the experiment completes."):s?(a="No scorers configured",i="Add scorers when triggering an experiment to evaluate results and see summary metrics here."):(a="Loading scores",i="Fetching scorer results…"),o.jsx("div",{className:"flex h-full items-center justify-center py-12",children:o.jsx(Qr,{iconSlot:o.jsx(tg,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:eWe,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{children:"Avg Score"}),o.jsx(hn.HeaderCol,{children:"Items Scored"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:n.map(({scorerId:r,avg:s,count:a})=>o.jsxs(hn.Row,{columns:eWe,children:[o.jsx(hn.TextCell,{children:r}),o.jsx(hn.TextCell,{className:"font-mono",children:s.toFixed(3)}),o.jsx(hn.TextCell,{className:"font-mono",children:a})]},r))})})]})}function M5t({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=y.useState(null),[d,f]=y.useState(null),[p,h]=y.useState(void 0),[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(!1),{updateExperimentResult:I}=Li(),P=y.useCallback(ae=>{b(re=>{const me=new Set(re);return me.has(ae)?me.delete(ae):me.add(ae),me})},[]),$=y.useCallback(()=>b(new Set),[]),B=y.useCallback(()=>{const ae=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(ae))},[r]),D=y.useCallback(async ae=>{if(w||ae.length===0)return;S(!0);let re=0;const me=new Set;try{for(const ye of ae)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:ye,status:"needs-review"}),re++,me.add(ye)}catch{}}finally{S(!1)}me.size>0&&b(ye=>{const Te=new Set(ye);for(const Re of me)Te.delete(Re);return Te}),re>0&&Ue(`${re} result${re>1?"s":""} flagged for review`)},[t,e,w,I]),V=r.find(ae=>ae.id===c)??null,[H,L]=y.useState("summary"),[F,z]=y.useState(null),M=ae=>{L(ae),ae!=="reviews"&&z(null)},{data:G}=xEe(t),U=(G??[]).filter(ae=>ae.experimentId===e).length,{data:R}=y5t(e,n),q=y.useMemo(()=>{if(!R)return[];const ae=new Set;for(const re of Object.values(R))for(const me of re)ae.add(me.scorerId);return[...ae].sort()},[R]),W=ae=>{u(ae),f(null),h(void 0),g(null)},X=ae=>{W(ae===c?null:ae)},ne=()=>{W(null)},ee=()=>{if(!V)return;const ae=r.findIndex(re=>re.id===V.id);if(ae>=0&&ae<r.length-1)return()=>W(r[ae+1].id)},J=()=>{if(!V)return;const ae=r.findIndex(re=>re.id===V.id);if(ae>0)return()=>W(r[ae-1].id)},ie=V?R?.[V.itemId]:void 0,ue=ie?.find(ae=>ae.id===m)??null,Y=ae=>{g(ae===m?null:ae),f(null),h(void 0)},te=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>=0&&ae<ie.length-1)return()=>g(ie[ae+1].id)},le=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>0)return()=>g(ie[ae-1].id)},{data:fe,isLoading:se}=sGr(d),he=fe?.spans,{data:be,isLoading:we}=iD(d,p),Ie=be?.span,{handlePreviousSpan:ke,handleNextSpan:je}=MSe(he,p??null,h),Fe=(()=>{const ae=[],re=!!ue,me=!!d;return ae.push(O?"auto":re||me?"2fr":"1fr"),re&&ae.push(E?"auto":"3fr"),me&&ae.push(C?"auto":"3fr"),me&&p&&ae.push("3fr"),ae.join(" ")})(),ce=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...q.map(ae=>({name:ae,label:ae,size:"12rem"}))],[q]);return o.jsxs(vc,{defaultTab:"summary",value:H,onValueChange:M,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(yc,{children:[o.jsx(Ir,{value:"summary",children:"Summary"}),o.jsx(Ir,{value:"results",children:"Results"}),o.jsxs(Ir,{value:"reviews",children:["Reviews",U>0&&o.jsx(Ys,{color:"orange",children:U})]})]}),o.jsx(Wr,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(dGr,{scoresByItemId:R,experimentStatus:n})}),o.jsx(Wr,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx($5t,{datasetId:t,experimentId:e,featuredItemId:F})}),o.jsxs(Wr,{value:"results",className:"grid grid-rows-[auto_1fr] overflow-hidden mt-2",children:[o.jsxs("div",{className:"mb-4",children:[v.size>0&&o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-surface3",children:[o.jsxs(ge,{variant:"ui-xs",className:"text-neutral5 font-medium",children:[v.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(pe,{variant:"outline",size:"sm",disabled:w,onClick:()=>D([...v]),children:[o.jsx(Ge,{size:"sm",children:o.jsx(KB,{})}),"Flag for Review"]}),o.jsx(pe,{variant:"ghost",size:"sm",onClick:$,children:"Clear"})]}),r.length>0&&v.size===0&&!s&&o.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:o.jsx(pe,{variant:"ghost",size:"sm",onClick:B,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",V&&"grid-cols-[1fr_1fr]"),children:[o.jsx("div",{className:"flex overflow-y-auto w-full",children:o.jsx("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:o.jsx(iGr,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:ce,scoresByItemId:R,scorerIds:q,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:v,onToggleSelect:P})})}),V&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:Fe},children:[o.jsx(aGr,{result:V,scores:ie,onPrevious:J(),onNext:ee(),onClose:ne,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{V.traceId&&(f(V.traceId),h(void 0),g(null),_(!0),j(!1))},onOpenInReview:()=>{z(V.id),L("reviews")},onFlagForReview:ae=>D([ae]),collapsed:O,onCollapsedChange:_}),ue&&o.jsx(uGr,{score:ue,onNext:te(),onPrevious:le(),onClose:()=>g(null),onShowTrace:()=>{ue.traceId&&(f(ue.traceId),h(void 0),_(!0),N(!0),j(!1))},collapsed:E,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(TSe,{traceId:d,spans:he,isLoading:se,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:j,LinkComponent:HN,traceHref:`/traces/${d}`}),p&&o.jsx(NSe,{traceId:d,spanId:p,span:Ie,isLoading:we,onPrevious:ke,onNext:je,onClose:()=>h(void 0)})]})]})]})]})]})}const fGr={pending:o.jsx(YT,{}),running:o.jsx(Sue,{}),completed:o.jsx(da,{}),failed:o.jsx(ys,{})};function pGr({experiment:e,className:t}){const n=e.status,r=e.totalItems-e.succeededCount-e.failedCount;return o.jsxs("div",{className:K("grid justify-items-end gap-3",t),children:[o.jsxs("div",{className:"flex p-1 px-3 text-ui-lg capitalize text-neutral4 gap-2 items-center bg-surface5 rounded-lg ",children:[o.jsx("span",{className:K("w-5 h-5 flex items-center justify-center rounded-full text-black","[&>svg]:w-4 [&>svg]:h-4",{"bg-green-700":n==="completed","bg-red-700":n==="failed","bg-cyan-600":n==="running","bg-yellow-600":n==="pending"}),children:fGr[n]}),e.status]}),o.jsxs("div",{className:K("flex items-center gap-3 text-neutral3 text-ui-md ","[&>span]:flex [&>span]:gap-1 [&>span]:items-center ","[&_b]:text-neutral4 [&_b]:font-semibold"),children:[o.jsxs("span",{children:["Total: ",o.jsx("b",{children:e.totalItems})]}),o.jsxs("span",{children:["Succeeded: ",o.jsx("b",{children:e.succeededCount})]}),o.jsxs("span",{children:["Failed: ",o.jsx("b",{children:e.failedCount})]}),(n==="pending"||n==="running")&&o.jsxs("span",{children:["Pending: ",o.jsx("b",{children:r})]})]})]})}function hGr({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs($r,{spacing:"close",children:[o.jsxs(pe,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx(GU,{})," Prev"]}),o.jsxs(pe,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(WU,{})]})]})}function SEe({delta:e}){const t=e>0?o.jsx(Ys,{size:"small",color:"green",intensity:"muted",children:o.jsx(AM,{})}):e<0?o.jsx(Ys,{size:"small",color:"red",intensity:"muted",children:o.jsx(Ssn,{})}):null;return o.jsxs("span",{className:K("font-mono text-sm text-neutral4 min-w-20"),children:[o.jsx("span",{className:"w-3 inline-block",children:e>0?"+ ":e<0?"- ":""}),Math.abs(e).toFixed(2)," ",t]})}function d8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function mGr({item:e,baselineId:t,contenderId:n,baselineVersion:r,contenderVersion:s,onPrevious:a,onNext:i,onClose:l}){const c=e.results[t],u=e.results[n],d=!!(c&&u),f=new Set;if(c)for(const h of Object.keys(c.scores))f.add(h);if(u)for(const h of Object.keys(u.scores))f.add(h);const p=[...f].sort();return o.jsxs(Zr,{withLeftSeparator:!0,children:[o.jsxs(Zr.Toolbar,{children:[o.jsx(hGr,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx($r,{children:o.jsx(pe,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(ys,{})})})]}),o.jsxs(Zr.Content,{className:"pb-6",children:[o.jsx(la,{withMargins:!1,children:o.jsx(la.Column,{children:o.jsxs(la.Title,{size:"smaller",children:[o.jsx(XT,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(i0e,{children:[p.length>0&&o.jsxs("div",{className:"grid gap-3",children:[o.jsx("h4",{className:"text-sm font-medium text-neutral5",children:"Scores"}),o.jsx("div",{className:"grid gap-2",children:p.map(h=>{const m=c?.scores[h]??null,g=u?.scores[h]??null,v=m!=null&&g!=null?g-m:null;return o.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2 rounded-lg bg-surface2",children:[o.jsx("span",{className:"text-sm text-neutral5 font-medium",children:h}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"text-sm text-neutral3",children:[m!=null?m.toFixed(3):"-"," →"," ",g!=null?g.toFixed(3):"-"]}),v!=null&&o.jsx(SEe,{delta:v})]})]},h)})})]}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Ys,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(Gm,{}),codeStr:d8(c?.output)}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Ys,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(Gm,{}),codeStr:d8(u?.output)}),o.jsx(va.CodeSection,{title:"Item Input",icon:o.jsx(Gk,{}),codeStr:d8(e.input)}),o.jsx(va.CodeSection,{title:"Item Ground Truth",icon:o.jsx(Cve,{}),codeStr:d8(e.groundTruth)})]})}):o.jsx(Rn,{variant:"warning",title:"Comparison not available",children:o.jsx(Rn.Message,{children:(()=>{const h=c?"Contender":"Baseline",m=c?s:r;return o.jsxs(o.Fragment,{children:["The ",h," experiment was run against dataset",m!=null?` v. ${m}`:"",", which does not contain this item."]})})()})})]})]})}function gGr({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Zr,{children:o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:a,children:[o.jsx(hn.HeaderCol,{children:"Item ID"}),!s&&r.map(l=>o.jsx(hn.HeaderCol,{className:"flex justify-center",children:l},l))]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:e.map(l=>{const c=l.results[t],u=l.results[n],d=!!(c&&u);return o.jsx(hn.Row,{children:o.jsxs(hn.RowButton,{item:{id:l.itemId},columns:a,isFeatured:s===l.itemId,onClick:i,children:[o.jsx(hn.IdCell,{id:l.itemId,className:d?"":"text-neutral1"}),!s&&o.jsx(o.Fragment,{children:r.map(f=>{const p=c?.scores[f]??null,h=u?.scores[f]??null,m=p!=null&&h!=null?h-p:null;return o.jsx(hn.Cell,{className:"flex items-center gap-5 justify-center font-mono",children:m!=null?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center text-neutral2 min-w-24",children:[p?.toFixed(2)," → ",h?.toFixed(2)]}),o.jsx(SEe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const vGr={baseline:{label:"Baseline",color:"purple",customStyle:"items-end justify-items-end [&>div]:justify-end border-r-0 rounded-r-none"},contender:{label:"Contender",color:"cyan",customStyle:"items-start justify-items-start [&>div]:justify-start border-l-0 rounded-l-none"}};function tWe({datasetId:e,experiment:t,type:n}){const{Link:r}=vn(),{label:s,color:a,customStyle:i}=vGr[n];if(!t)return null;const l=t.createdAt?new Date(t.createdAt):null;return o.jsxs("div",{className:`grid border-2 border-border1 rounded-lg p-5 gap-3 ${i}`,children:[o.jsxs("div",{className:"flex items-center gap-3 w-full overflow-clip",children:[n==="contender"&&o.jsxs(Ys,{size:"small",color:a,children:[s,o.jsx(Gh,{})]}),o.jsx(pe,{as:r,href:`/datasets/${e}/experiments/${t.id}`,children:o.jsx("span",{className:"truncate min-w-0",children:t.id})}),n==="baseline"&&o.jsxs(Ys,{size:"small",color:a,children:[o.jsx(gc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(ic,{children:[o.jsx(Cve,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(ic,{children:[o.jsx(Ove,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(ic,{children:[o.jsx(kat,{})," ",Kn(l,"MMM d, yyyy HH:mm")]})]})]})}function yGr({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=y.useState(null),{data:i,isLoading:l,error:c}=AWr(e,t,n),{data:u}=PB(e,t),{data:d}=PB(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=y.useMemo(()=>{if(!i)return[];const j=new Set;for(const E of i.items)for(const N of Object.values(E.results))if(N)for(const I of Object.keys(N.scores))j.add(I);return[...j].sort()},[i]),h=y.useMemo(()=>{if(!i||p.length===0)return[];const j=i.baselineId,E=t===j?n:t;return p.map(N=>{let I=0,P=0,$=0,B=0;for(const L of i.items){const F=L.results[j]?.scores[N],z=L.results[E]?.scores[N];F!=null&&(I+=F,$++),z!=null&&(P+=z,B++)}const D=$>0?I/$:null,V=B>0?P/B:null,H=D!=null&&V!=null?V-D:null;return{scorerId:N,avgA:D,avgB:V,delta:H}})},[i,p,t,n]),m=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"baselineAvg",label:"Baseline Avg",size:"1fr"},{name:"comparisonAvg",label:"Comparison Avg",size:"1fr"},{name:"delta",label:"Delta",size:"1fr"}],g=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"8rem"},...s?[]:p.map(j=>({name:j,label:j,size:"1fr"}))],[p,s]),v=i?.items.find(j=>j.itemId===s)??null,b=j=>{a(j===s?null:j)},w=()=>{a(null)},S=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>=0&&j<i.items.length-1)return()=>a(i.items[j+1].itemId)},O=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>0)return()=>a(i.items[j-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Ht,{})});if(c)return o.jsx(Rn,{variant:"warning",title:"Error loading comparison",children:o.jsx(Rn.Message,{children:c instanceof Error?c.message:"Unknown error"})});if(!i||i.items.length===0)return o.jsx("div",{className:"text-neutral4 text-sm text-center py-8",children:"No comparison data"});const _=i.baselineId,C=t===_?n:t;return o.jsxs("div",{className:"grid gap-10",children:[u&&d&&o.jsxs("div",{className:K("relative grid xl:grid-cols-[1fr_auto_1fr] gap-4 xl:gap-0"),children:[o.jsx(tWe,{datasetId:e,experiment:u,type:"baseline"}),o.jsx("div",{className:"relative flex items-center justify-center px-[2vw] before:absolute before:inset-y-0 before:left-1/2 before:-translate-x-1/2 before:w-[2px] before:bg-border1",children:o.jsx("div",{className:"relative z-1 bg-surface2 rounded-lg p-2",children:o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx(pe,{onClick:r,children:"VS"})}),o.jsx(Hn,{children:"Switch the order"})]})})}),o.jsx(tWe,{datasetId:e,experiment:d,type:"contender"})]}),f&&o.jsx(Rn,{variant:"warning",title:"Version mismatch",children:o.jsxs(Rn.Message,{children:["These experiments used different dataset versions (v",u.datasetVersion," vs v",d.datasetVersion,"). Results may not be directly comparable."]})}),h.length>0&&o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:m,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(GLe,{children:[o.jsx(Ys,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Ys,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(GLe,{children:[o.jsx(Ys,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Ys,{color:"cyan",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:"Delta"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:h.map(({scorerId:j,avgA:E,avgB:N,delta:I})=>o.jsxs(hn.Row,{columns:m,children:[o.jsx(hn.TextCell,{children:j}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:E!=null?E.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:N!=null?N.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"flex justify-center",children:I!=null?o.jsx(SEe,{delta:I}):"-"})]},j))})})]}),o.jsxs(Pv,{className:K({"grid-cols-[1fr_2fr]":!!v}),children:[o.jsx(gGr,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!v&&o.jsx(mGr,{item:v,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:O(),onNext:S(),onClose:w})]})]})}function bGr({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=yEe(e,t),[l,c]=y.useState(!1),[u,d]=y.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(w=>{const S=new Set(w);if(S.has(b))S.delete(b);else if(S.size>=2){const[O]=Array.from(S);return new Set([O,b])}else S.add(b);return S})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},v=()=>{u.size===2&&r?.([...u])};return o.jsxs(Zr,{className:"min-w-56",children:[l?o.jsx(Zr.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs($r,{children:[o.jsx(pe,{onClick:m,children:"Cancel"}),o.jsx(pe,{variant:"primary",disabled:u.size!==2,onClick:v,tooltip:u.size!==2?"Check 2 versions to compare":void 0,className:"grow",children:"Compare"})]})}):o.jsx(o.Fragment,{children:(a||[]).length>1&&o.jsx(Zr.Toolbar,{children:o.jsxs(pe,{onClick:g,className:"w-full",children:[o.jsx(Dw,{})," Compare Ver."]})})}),i?o.jsx(xGr,{}):o.jsxs(hn,{children:[o.jsx(hn.Header,{children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:a?.map(b=>{const w=String(b.datasetVersion),S=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(hn.Row,{isSelected:l&&u.has(w),children:[l&&o.jsx(hn.LabelCell,{children:o.jsx(Go,{checked:u.has(w),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:O=>{O.stopPropagation(),b.isDeleted||h(w)},"aria-label":`Select version ${b.datasetVersion}`})}),o.jsx(hn.RowButton,{item:b,columns:[{name:"version",label:"Item Version History",size:"1fr"}],isFeatured:p(b),onClick:()=>f(b),className:"py-2",children:o.jsx(hn.VersionCell,{version:b.datasetVersion,date:S,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function xGr(){return o.jsxs(hn,{children:[o.jsx(hn.Header,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Items,{children:Array.from({length:3}).map((e,t)=>o.jsx(hn.Row,{children:o.jsx(hn.RowButton,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.TextCell,{isLoading:!0,children:"Loading..."})})},t))})]})}function wGr(e,t){if(t){const n=typeof t=="string"?new Date(t):t;return`v${e} ${Kn(n,"MMM dd 'at' H:mm:ss a")}`}return`v${e}`}function SGr({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=mEe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${wGr(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Zr.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(ac,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(ac,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const kGr=[{name:"id",label:"ID",size:"1fr"},{name:"versionA",label:"Version A",size:"1fr"},{name:"versionB",label:"Version B",size:"1fr"},{name:"compare",label:"Compare",size:"10rem"}],OGr={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Ur,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Vat,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(Van,{}),tooltip:"Same in both versions"}};function qne({red:e=!1,tooltip:t}){return o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx(Asn,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Hn,{children:t})]})}function RS({variant:e,version:t}){if(!e)return o.jsxs("span",{className:"text-ui-md text-neutral4",children:["v. ",t]});const{color:n,icon:r,tooltip:s}=OGr[e];return o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsxs("div",{className:"grid grid-cols-[1fr_auto]",children:[t!==void 0&&o.jsxs("span",{className:"pr-3 text-ui-md text-neutral4 min-w-16 flex justify-end",children:["v. ",t]}),o.jsx(Ys,{color:n,size:"small",children:r})]})}),o.jsx(Hn,{children:s})]})}function _Gr(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function CGr({datasetId:e,versionA:t,versionB:n,allItems:r,itemsAMap:s,itemsBMap:a}){const{Link:i}=vn(),l=t>n;return o.jsx(hn,{children:o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:r.map(({id:c})=>{const u=s.get(c),d=a.get(c),f=_Gr(u,d);return o.jsxs(hn.Row,{columns:kGr,children:[o.jsx(hn.IdCell,{id:c,isShortened:!1}),f!=="same"?o.jsxs(o.Fragment,{children:[u?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!d&&l?o.jsx(RS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(RS,{variant:"changed",version:u.datasetVersion}):o.jsx(RS,{version:u.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(qne,{red:l,tooltip:l?"Deleted in this version":"Not present in this version"})}),d?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!u&&!l?o.jsx(RS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(RS,{variant:"changed",version:d.datasetVersion}):o.jsx(RS,{version:d.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(qne,{red:!l,tooltip:l?"Not present in this version":"Deleted in this version"})})]}):o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"col-span-2 gap-2",children:o.jsx(RS,{variant:"same",version:d?.datasetVersion})}),f==="changed"?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}/versions?ids=${u?.datasetVersion},${d?.datasetVersion}`,children:"Compare"}):o.jsx(hn.Cell,{children:o.jsx(qne,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const nWe={needsReview:"#facc15",complete:"#22c55e"},EGr=[{label:"Needs Review",color:nWe.needsReview},{label:"Reviewed",color:nWe.complete}];function jGr({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=y.useMemo(()=>{if(!e?.counts||!t)return{data:[],maxVal:0,totalInPipeline:0};const u=new Map;for(const m of t)u.set(m.id,m);const d=new Map;if(n)for(const m of n)d.set(m.id,m.name);let f=0,p=0;const h=[];for(const m of e.counts){const g=m.needsReview+m.complete;if(g===0)continue;p+=g,g>f&&(f=g);const v=u.get(m.experimentId),b=v?.datasetId?d.get(v.datasetId):void 0,w=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:w,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(zt,{children:[o.jsxs(zt.TopBar,{children:[o.jsx(zt.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(zt.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(zt.Loading,{}):s?o.jsx(zt.Error,{message:"Failed to load review data"}):o.jsx(zt.Content,{children:c?o.jsx(aT,{data:a,segments:EGr,maxVal:i,fmt:u=>String(u)}):o.jsx(zt.NoData,{message:"No items have been sent to review yet"})})]})}function kEe(){const e=He();return xt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function D5t(e){const t=new Map;if(!e?.counts)return t;for(const n of e.counts)t.set(n.experimentId,{needsReview:n.needsReview,complete:n.complete,total:n.total});return t}function TGr(e,t){const n=new Map,r=D5t(e);if(!r.size||!t)return n;for(const s of t){const a=r.get(s.id);if(!a||!s.datasetId||a.needsReview+a.complete===0)continue;const l=n.get(s.datasetId)??{needsReview:0,complete:0};l.needsReview+=a.needsReview,l.complete+=a.complete,n.set(s.datasetId,l)}return n}function NGr(e){return e?.counts?e.counts.reduce((t,n)=>({needsReview:t.needsReview+n.needsReview,complete:t.complete+n.complete,inPipeline:t.inPipeline+n.needsReview+n.complete}),{needsReview:0,complete:0,inPipeline:0}):{needsReview:0,complete:0,inPipeline:0}}const IGr=10;function AGr(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,a]=y.useState("all"),[i,l]=y.useState("all"),[c,u]=y.useState("all"),[d,f]=y.useState(0),{data:p,isLoading:h,error:m}=wy({page:d,perPage:IGr}),{data:g,isLoading:v,error:b}=MZ(),{data:w}=kEe(),S=y.useMemo(()=>p?.datasets??[],[p?.datasets]),O=p?.pagination?.hasMore??!1,_=y.useMemo(()=>g?.experiments??[],[g?.experiments]),C=y.useMemo(()=>YWr(S),[S]),j=y.useMemo(()=>TGr(w,_),[w,_]),E=h||v,N=m||b,I=()=>t(!0),P=y.useCallback(()=>f(z=>z+1),[]),$=y.useCallback(()=>f(z=>Math.max(0,z-1)),[]),B=y.useCallback(z=>{r(z),f(0)},[]),D=y.useCallback(z=>{a(z),f(0)},[]),V=y.useCallback(z=>{l(z),f(0)},[]),H=y.useCallback(z=>{u(z),f(0)},[]);if(N&&cs(N))return o.jsx(or,{children:o.jsx(Ms,{})});if(N&&ds(N))return o.jsx(or,{children:o.jsx(ks,{resource:"datasets"})});if(N)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load datasets",message:N.message})});if(S.length===0&&!E&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(or,{children:o.jsx(tQr,{onCreateClick:I})}),o.jsx(fge,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",F=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx(rQr,{search:n,onSearchChange:B,targetFilter:s,onTargetFilterChange:D,experimentFilter:i,onExperimentFilterChange:V,tagFilter:c,onTagFilterChange:H,tagOptions:C,onReset:F,hasActiveFilters:L,onCreateClick:I})}),o.jsx(eQr,{datasets:S,experiments:_,reviewByDataset:j,isLoading:E,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:O,onNextPage:P,onPrevPage:$}),o.jsx(fge,{open:e,onOpenChange:t})]})}function f8({children:e}){return o.jsxs(Dt,{height:"full",children:[o.jsx("div",{}),o.jsx(Dt.MainArea,{isCentered:!0,children:e})]})}function RGr(){const{datasetId:e}=vr(),t=Ks(),[n,r]=zi(),{activeVersion:s}=bEe(n,r),[a,i]=y.useState(!1),[l,c]=y.useState(!1),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),{data:g,error:v,isLoading:b}=Dx(e),{data:w=[],isLoading:S}=HO(e,void 0,s),O=!S&&w.length===0;if(b)return null;if(v&&cs(v))return o.jsx(f8,{children:o.jsx(Ms,{})});if(v&&ds(v))return o.jsx(f8,{children:o.jsx(ks,{resource:"datasets"})});if(v&&xSe(v)||!b&&!v&&!g)return o.jsx(f8,{children:o.jsx(Qr,{iconSlot:o.jsx(Uv,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(pe,{as:ui,to:"/datasets",children:[o.jsx(gc,{}),"Back to Datasets"]})})});if(v)return o.jsx(f8,{children:o.jsx(Di,{title:"Failed to load dataset",message:v instanceof Error?v.message:"An unexpected error occurred. Please try again."})});const _=j=>{t(`/datasets/${e}/experiments/${j}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Dt,{height:"full",children:[o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{children:[o.jsxs(Dt.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(Ft,{numOfCol:2,children:[o.jsx(Ft.Key,{children:"Created at"}),o.jsx(Ft.Value,{children:g?.createdAt?Kn(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(Ft.Key,{children:"Latest version"}),o.jsxs(Ft.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Dt.Column,{children:o.jsxs($r,{children:[O?o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("span",{className:"cursor-not-allowed",children:o.jsx("div",{className:"pointer-events-none opacity-50",inert:!0,"aria-disabled":"true",children:o.jsxs(pe,{variant:"primary",children:[o.jsx(Lw,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Hn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(pe,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Lw,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsx(pe,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(PM,{})})}),o.jsxs(ft.Content,{align:"end",className:"w-48",children:[o.jsxs(ft.Item,{onSelect:()=>d(!0),children:[o.jsx(Dh,{})," Edit Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>m(!0),children:[o.jsx(sf,{})," Duplicate Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Zc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Dt.MainArea,{children:o.jsx(GQr,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(rGr,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(XQr,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(cQr,{open:u,onOpenChange:d,dataset:{id:g.id,name:g.name,description:g?.description||"",targetType:g.targetType,inputSchema:g.inputSchema,groundTruthSchema:g.groundTruthSchema,requestContextSchema:g.requestContextSchema}}),g&&o.jsx(iQr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(dQr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function L5t({experiment:e}){const{Link:t,paths:n}=vn(),{data:r}=sm(),{data:s}=Ey(),{data:a}=Up(),i=()=>{switch(e.targetType){case"agent":return n.agentLink(e.targetId);case"workflow":return n.workflowLink(e.targetId);case"scorer":return n.scorerLink(e.targetId);default:return"#"}},l=()=>{const u=e.targetId;if(!u)return u;switch(e.targetType){case"agent":return r?.[u]?.name??u;case"workflow":return s?.[u]?.name??u;case"scorer":return a?.[u]?.scorer?.config?.name??u;default:return u}},c=e.agentVersion&&e.targetType==="agent"&&e.targetId?`${n.agentLink(e.targetId)}/editor?version=${encodeURIComponent(e.agentVersion)}`:null;return o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{children:[o.jsx(Dt.Column,{children:o.jsxs(Ft,{numOfCol:2,children:[o.jsx(Ft.Key,{children:"Created at"}),o.jsx(Ft.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(Ft.Key,{children:"Completed at"}),o.jsx(Ft.Value,{children:Kn(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(Ft.Key,{children:"Target"}),o.jsx(Ft.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(Ft.Key,{children:"Version"}),c?o.jsx(Ft.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(Ft.Value,{children:e.agentVersion})]})]})}),o.jsx(Dt.Column,{children:o.jsx(pGr,{experiment:e})})]})})}function p8({children:e}){return o.jsxs(Dt,{height:"full",children:[o.jsx("div",{}),o.jsx(Dt.MainArea,{isCentered:!0,children:e})]})}function PGr(){const{datasetId:e,experimentId:t}=vr(),{data:n,isLoading:r,error:s}=PB(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=RZ({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&cs(s)?o.jsx(p8,{children:o.jsx(Ms,{})}):s&&ds(s)?o.jsx(p8,{children:o.jsx(ks,{resource:"datasets"})}):s&&xSe(s)||!r&&!s&&!n?o.jsx(p8,{children:o.jsx(Qr,{iconSlot:o.jsx(wve,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(pe,{as:ui,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(gc,{}),"Back to Dataset"]})})}):s?o.jsx(p8,{children:o.jsx(Di,{title:"Failed to load experiment",message:s instanceof Error?s.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Dt,{height:"full",children:[o.jsx(L5t,{experiment:n}),o.jsx(Dt.MainArea,{children:o.jsx(M5t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function $Gr(){const{datasetId:e}=vr(),[t,n]=zi(),{error:r}=Dx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&cs(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):r&&ds(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsxs("div",{className:"text-neutral4 text-center py-8",children:[o.jsx("p",{children:"Select two experiments to compare."}),o.jsxs("p",{className:"text-sm mt-2",children:["Use the URL format: /datasets/","{datasetId}","/experiments?baseline=","{experimentIdA}","&contender=","{experimentIdB}"]})]})})}):o.jsx(ms,{children:o.jsx(Qv,{children:o.jsxs("div",{className:"max-w-[100rem] w-full px-12 mx-auto grid content-start ",children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Dw,{})," Dataset Experiments Comparison"]}),o.jsxs(la.Description,{children:["Comparing"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(la.Column,{children:o.jsxs(pe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(gc,{}),"Back to Dataset"]})})]}),o.jsx(yGr,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function MGr(){const{datasetId:e,itemId:t}=vr(),{Link:n}=vn(),r=Ks(),{data:s,isLoading:a,error:i}=yEe(e??"",t??""),{updateItem:l,deleteItem:c}=Li(),{data:u}=Dx(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=y.useState(null),m=y.useMemo(()=>!d||f?{input:"",groundTruth:"",metadata:"",trajectory:"",requestContext:""}:{input:JSON.stringify(d.input,null,2),groundTruth:d.groundTruth?JSON.stringify(d.groundTruth,null,2):"",metadata:d.metadata?JSON.stringify(d.metadata,null,2):"",trajectory:d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):"",requestContext:d.requestContext?JSON.stringify(d.requestContext,null,2):""},[d,f]),g=d?.datasetVersion??0,[v,b]=y.useState(!1),[w,S]=y.useState(m.input),[O,_]=y.useState(m.groundTruth),[C,j]=y.useState(m.metadata),[E,N]=y.useState(m.trajectory),[I,P]=y.useState(m.requestContext),[$,B]=y.useState(g);g!==$&&(B(g),S(m.input),_(m.groundTruth),j(m.metadata),N(m.trajectory),P(m.requestContext));const[D,V]=y.useState(!1),H=X=>{h(f?X:X.isLatest?null:X)},L=()=>{h(null)},F=!f&&p!=null,z=()=>{F||b(!0)},M=()=>{F||V(!0)},G=async()=>{if(!e||!t)return;let X;try{X=JSON.parse(w)}catch{Ue.error("Input must be valid JSON");return}let ne;if(O.trim())try{ne=JSON.parse(O)}catch{Ue.error("Ground Truth must be valid JSON");return}let ee;if(C.trim())try{ee=JSON.parse(C)}catch{Ue.error("Metadata must be valid JSON");return}let J;const ie=E!==m.trajectory;if(ie&&E.trim())try{J=JSON.parse(E)}catch{Ue.error("Expected Trajectory must be valid JSON");return}let ue;const Y=I!==m.requestContext;if(Y&&I.trim())try{ue=JSON.parse(I)}catch{Ue.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:X,groundTruth:ne,metadata:ee,...ie?{expectedTrajectory:J??null}:{},...Y?{requestContext:ue}:{}}),Ue.success("Item updated successfully"),b(!1)}catch(te){Ue.error(`Failed to update item: ${te instanceof Error?te.message:"Unknown error"}`)}},U=()=>{d&&(S(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),j(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),P(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},R=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),Ue.success("Item deleted successfully"),V(!1),r(`/datasets/${e}`)}catch(X){Ue.error(`Failed to delete item: ${X instanceof Error?X.message:"Unknown error"}`)}},q=p??d,W=q?{id:t??"",datasetId:e??"",datasetVersion:q.datasetVersion,input:q.input,groundTruth:q.groundTruth,expectedTrajectory:q.expectedTrajectory,metadata:q.metadata,createdAt:q.createdAt,updatedAt:q.updatedAt}:null;return i&&cs(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):i&&ds(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(ms,{children:o.jsx("div",{className:"h-full overflow-hidden px-6 pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[60rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(XT,{}),t," ",o.jsx(Pa,{content:t})]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:["Item of ",o.jsx(Uv,{})," ",u?.name]})}),o.jsxs(la.Description,{children:[o.jsxs(ic,{children:[o.jsx(Sat,{})," Created at"," ",d?.createdAt?Kn(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(ic,{children:[o.jsx(YO,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(la.Column,{children:!v&&!f&&o.jsxs($r,{children:[o.jsxs(pe,{onClick:z,disabled:F,title:F?"Return to latest version to edit":void 0,children:[o.jsx(Vat,{})," Edit"]}),o.jsxs(pe,{onClick:M,disabled:F,title:F?"Return to latest version to delete":void 0,children:[o.jsx(Zc,{})," Delete"]})]})})]}),o.jsxs(Pv,{className:v?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Zr,{withRightSeparator:!v,children:[f&&d&&o.jsx(Rn,{variant:"destructive",title:"Item deleted",children:o.jsxs(Rn.Message,{children:["This item was deleted at version v",d.datasetVersion]})}),!f&&F&&p&&o.jsx(Rn,{variant:"warning",title:"Previous version",action:o.jsxs(Rn.Button,{onClick:L,children:[o.jsx(vat,{})," Return to the latest version"]}),children:o.jsxs(Rn.Message,{children:["Viewing version v",p.datasetVersion]})}),v?o.jsx(P5t,{inputValue:w,setInputValue:S,groundTruthValue:O,setGroundTruthValue:_,metadataValue:C,setMetadataValue:j,trajectoryValue:E,setTrajectoryValue:N,requestContextValue:I,setRequestContextValue:P,validationErrors:null,onSave:G,onCancel:U,isSaving:l.isPending}):W?o.jsx(wEe,{item:W,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!v&&o.jsx(Zr,{children:o.jsx(bGr,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:H,onCompareVersionsClick:X=>{r(`/datasets/${e}/items/${t}/versions?ids=${X.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(jt,{open:D,onOpenChange:V,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Item"}),o.jsx(jt.Description,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:R,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function rWe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function DGr(){const{datasetId:e}=vr(),[t,n]=zi(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Dx(e??""),{Link:i}=vn(),[l,c]=y.useState(!1),{data:u}=cge(e??"",r[0]??""),{data:d}=cge(e??"",r[1]??"");return a&&cs(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):a&&ds(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two items to compare."})})})}):o.jsxs(ms,{children:[o.jsx(Sy,{owner:"dataset-items-compare",children:o.jsxs(pe,{as:ui,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(gc,{}),"Back to Dataset"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":l}),children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Items"]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:["Comparing ",r.length," items of"," ",o.jsx(ui,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(la.Column,{children:o.jsx($r,{children:o.jsx(pe,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(Tat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Man,{})," Diff View"]})})})})]}),o.jsx(Pv,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(y.Fragment,{children:[o.jsx(LGr,{datasetId:e,itemId:f,Link:i,idx:p,itemIds:r,showContent:!l,onItemChange:h=>{const m=[...r];m[p]=h,n({items:m.join(",")})}}),p==0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},f))}),l&&u&&d&&o.jsx(s0t,{codeA:rWe(u),codeB:rWe(d)})]})})]})}function LGr({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=cge(e,t),{data:u}=HO(e),d=new Set(s.filter((p,h)=>h!==r)),f=(u??[]).map(p=>({value:p.id,label:p.id,disabled:d.has(p.id)}));return o.jsxs(Zr,{children:[o.jsxs(Zr.Toolbar,{className:"flex gap-4",children:[o.jsxs($a,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(Da,{"aria-label":"Item",children:o.jsx(Ma,{placeholder:"Select item"})}),o.jsx(La,{children:f.map(p=>o.jsx(Xr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(pe,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(YO,{}),"Versions"]})]}),i&&o.jsx(Zr.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(KQr,{item:l}),o.jsx(wEe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function sWe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function FGr(){const{datasetId:e,itemId:t}=vr(),[n,r]=zi(),[s,a]=y.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Dx(e??""),{Link:u}=vn(),{data:d}=yEe(e??"",t??""),{data:f}=hge(e??"",t??"",i[0]??0,l?.version),{data:p}=hge(e??"",t??"",i[1]??0,l?.version);return c&&cs(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):c&&ds(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})}):o.jsxs(ms,{children:[o.jsx(Sy,{owner:"dataset-item-versions-compare",children:o.jsxs(pe,{as:ui,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(gc,{}),"Back to Item"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":s}),children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Item Versions"]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:["Comparing ",i.length," versions of"," ",o.jsx(ui,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(la.Column,{children:o.jsx($r,{children:o.jsx(pe,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(Tat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(vin,{})," Diff View"]})})})})]}),o.jsx(Pv,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(y.Fragment,{children:[o.jsx(zGr,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:g=>{const v=[...i];v[m]=g,r({ids:v.join(",")})}}),m===0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},h))}),s&&f&&p&&o.jsx(s0t,{codeA:sWe(f),codeB:sWe(p)})]})})]})}function zGr({datasetId:e,itemId:t,datasetVersion:n,latestVersion:r,allVersions:s,versionNumbers:a,Link:i,idx:l,showContent:c=!0,onVersionChange:u}){const{data:d,isLoading:f}=hge(e,t,n,r),p=new Set(a.filter((g,v)=>v!==l)),h=s.map(g=>{const v=typeof g.updatedAt=="string"?new Date(g.updatedAt):g.updatedAt;return{value:String(g.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",g.datasetVersion]})," - ",Kn(v,"MMM d, yyyy h:mm a"),g.isLatest?o.jsx(Ys,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(g.datasetVersion)}}),m=d?{id:d.id,datasetId:e,datasetVersion:d.datasetVersion,input:d.input,groundTruth:d.groundTruth,metadata:d.metadata,createdAt:d.createdAt,updatedAt:d.updatedAt}:null;return o.jsxs(Zr,{children:[o.jsxs(Zr.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(YO,{className:"w-6 h-6 opacity-50"}),o.jsxs($a,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(Da,{"aria-label":"Version",className:"w-full",children:o.jsx(Ma,{placeholder:"Select version"})}),o.jsx(La,{children:h.map(g=>o.jsx(Xr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Zr.Content,{children:f?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):!d||!m?o.jsxs("div",{className:"text-neutral4 text-sm",children:["Version ",n," not found"]}):o.jsx(wEe,{item:m,Link:i})})]})}function BGr(){const{datasetId:e}=vr(),[t]=zi(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=Ks(),{data:s,error:a}=Dx(e??""),i=HO(e??"",void 0,n[0]??null),l=HO(e??"",void 0,n[1]??null),c=y.useMemo(()=>i.data??[],[i.data]),u=y.useMemo(()=>l.data??[],[l.data]),d=y.useMemo(()=>{const g=new Map;for(const v of[...c,...u])g.has(v.id)||g.set(v.id,{id:v.id,createdAt:new Date(v.createdAt)});return[...g.values()].sort((v,b)=>b.createdAt.getTime()-v.createdAt.getTime())},[c,u]),f=y.useMemo(()=>new Map(c.map(g=>[g.id,g])),[c]),p=y.useMemo(()=>new Map(u.map(g=>[g.id,g])),[u]);if(a&&cs(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})});if(a&&ds(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})});const h=(g,v,b)=>{r(`/datasets/${e}/items/${g}/versions?ids=${v?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(g,v)=>{r(`/datasets/${e}/versions?ids=${g},${v}`,{replace:!0})};return o.jsx(ms,{children:o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Uon,{})," Compare Dataset Versions"]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:[o.jsx(YO,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(la.Column,{children:o.jsxs(pe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(gc,{}),"Back to Dataset"]})})]}),o.jsx(Pv,{children:o.jsxs(Zr,{children:[o.jsx(SGr,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(CGr,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function UGr(e){if(!e||e.length<2)return null;const t=[...e].sort((i,l)=>new Date(i.createdAt).getTime()-new Date(l.createdAt).getTime()),n=Math.floor(t.length/2),r=n,s=t.length-n;if(r===0)return null;const a=(s-r)/r*100;return{changePct:Math.round(a*10)/10,prevValue:String(r)}}function qGr({scorers:e,datasets:t,experiments:n,avgScore:r,prevAvgScore:s,totalNeedsReview:a,isLoadingScorers:i,isLoadingDatasets:l,isLoadingExperiments:c,isLoadingScores:u,isLoadingReview:d}){const f=e?Object.keys(e).length:void 0,p=t?.length,h=n?.length,m=r!=null&&s!=null&&s!==0?{changePct:Math.round((r-s)/s*100*10)/10,prevValue:String(s)}:null,g=UGr(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Total Scorers"}),i?o.jsx(Yr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(f)}),o.jsx(Yr.NoChange,{message:"Static count"})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Total Datasets"}),l?o.jsx(Yr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(p)}),o.jsx(Yr.NoChange,{message:"Static count"})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Avg Score"}),u?o.jsx(Yr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(r)}),m?o.jsx(Yr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Yr.NoChange,{})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Total Experiments"}),c?o.jsx(Yr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(h)}),g?o.jsx(Yr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Yr.NoChange,{})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Needs Review"}),d?o.jsx(Yr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(a)}),a>0?o.jsx(Yr.NoChange,{message:"items pending review"}):o.jsx(Yr.NoChange,{message:"All caught up"})]}):o.jsx(Yr.NoData,{})]})]})}const aWe="auto 1fr auto auto auto auto auto auto auto";function VGr(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const HGr={completed:"success",running:"warning",failed:"error",pending:"neutral"};function ZGr({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=vn(),u=y.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=y.useMemo(()=>[...e].sort((p,h)=>{const m=p.createdAt?new Date(p.createdAt).getTime():0;return(h.createdAt?new Date(h.createdAt).getTime():0)-m}),[e]),f=y.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",g=!p||h.id.toLowerCase().includes(p)||m.toLowerCase().includes(p)||(h.targetId??"").toLowerCase().includes(p),v=a==="all"||h.status===a,b=i==="all"||h.datasetId===i;return g&&v&&b})},[d,s,u,a,i]);return r?o.jsx(Wo,{columns:aWe}):o.jsxs(xe,{columns:aWe,variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Experiment"}),o.jsx(xe.TopCell,{children:"Dataset"}),o.jsx(xe.TopCell,{children:"Target"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{className:"text-center",children:"Items"}),o.jsx(xe.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(xe.TopCell,{className:"text-center",children:"Failed"}),o.jsx(xe.TopCell,{className:"text-center",children:"Review"}),o.jsx(xe.TopCell,{children:"Date"})]}),f.map(p=>{const h=p.datasetId?u.get(p.datasetId)??p.datasetId.slice(0,8):"—",m=p.status??"pending",g=p.succeededCount??0,v=p.failedCount??0,b=p.totalItems??0,w=b>0?Math.round(g/b*100):0;return o.jsxs(xe.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(xe.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(xe.TextCell,{children:h}),o.jsx(xe.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(xe.Cell,{children:o.jsx(_h,{variant:HGr[m]??"neutral",withDot:!0,children:m})}),o.jsx(xe.TextCell,{className:"text-center",children:b}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",w,"%)"]})}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsx("span",{className:v>0?"text-accent2":"",children:v})}),o.jsx(xe.Cell,{className:"text-center",children:(()=>{const S=n?.get(p.id);if(!S)return o.jsx("span",{className:"text-neutral2",children:"—"});const O=S.needsReview+S.complete;return O===0?o.jsx("span",{className:"text-neutral2",children:"—"}):S.needsReview>0?o.jsxs(Ys,{size:"small",color:"yellow",children:[S.needsReview," pending"]}):o.jsxs(Ys,{size:"small",color:"green",children:[S.complete,"/",O," reviewed"]})})()}),o.jsx(xe.TextCell,{children:VGr(p.createdAt)})]},p.id)})]})}const WGr=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function QGr(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const h8={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},GGr=[{label:"Completed",color:h8.completed},{label:"Running",color:h8.running},{label:"Pending",color:h8.pending},{label:"Failed",color:h8.failed}];function YGr({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=y.useMemo(()=>{if(!e||e.length===0)return{data:[],maxVal:0};const l=new Map;if(t)for(const f of t)l.set(f.id,f.name);const c=new Map;for(const f of e){const p=f.datasetId??"unknown";c.has(p)||c.set(p,{completed:0,running:0,pending:0,failed:0});const h=c.get(p),m=f.status;m in h&&h[m]++}let u=0;return{data:Array.from(c.entries()).map(([f,p])=>{const h=p.completed+p.running+p.pending+p.failed;return h>u&&(u=h),{name:l.get(f)??f.slice(0,12),values:[p.completed,p.running,p.pending,p.failed]}}),maxVal:u}},[e,t]),i=s.length>0;return o.jsxs(zt,{children:[o.jsxs(zt.TopBar,{children:[o.jsx(zt.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(zt.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(zt.Loading,{}):r?o.jsx(zt.Error,{message:"Failed to load experiments data"}):o.jsx(zt.Content,{children:i?o.jsx(aT,{data:s,segments:GGr,maxVal:a,fmt:l=>String(l)}):o.jsx(zt.NoData,{message:"No experiments have been run yet"})})]})}const XGr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"No Experiments yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Run an experiment from a dataset to evaluate ",o.jsx("br",{}),"your agents and workflows."]}),actionSlot:o.jsx("div",{className:"flex flex-col items-center gap-2",children:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(ja,{})]})})})});function KGr({search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:i,onReset:l,hasActiveFilters:c}){return o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(xf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs($r,{children:[o.jsx(ac,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...WGr],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(ac,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(pe,{onClick:l,size:"sm",variant:"default",children:[o.jsx(ys,{className:"size-3"})," Reset"]})]})]})}function JGr(){const{data:e,isLoading:t,error:n}=Up(),{data:r,isLoading:s,error:a}=wy(),{data:i,isLoading:l,error:c}=MZ(),{data:u,isLoading:d,isError:f,error:p}=Bqr(),{data:h,isLoading:m,isError:g,error:v}=kEe(),b=r?.datasets,w=i?.experiments,S=y.useMemo(()=>NGr(h),[h]),O=n||a||c||p||v;return O&&cs(O)?o.jsx(or,{children:o.jsx(Ms,{})}):O&&ds(O)?o.jsx(or,{children:o.jsx(ks,{resource:"evaluation"})}):O?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load evaluation data",message:O.message})}):o.jsx(Dt,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(gfe,{children:o.jsx(qGr,{scorers:e,datasets:b,experiments:w,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:S.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(Iqr,{summaryData:u?.summaryData??[],overTimeData:u?.overTimeData??[],scorerNames:u?.scorerNames??[],avgScore:u?.avgScore??null,isLoading:d,isError:f}),o.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[o.jsx(nQr,{experiments:w,isLoading:l,isError:!!c}),o.jsx(YGr,{experiments:w,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(jGr,{reviewSummary:h,experiments:w,datasets:b,isLoading:m,isError:!!g})]})})}function eYr(){const[e,t]=y.useState(""),[n,r]=y.useState("all"),[s,a]=y.useState("all"),{data:i,isLoading:l,error:c}=wy(),{data:u,isLoading:d,error:f}=MZ(),{data:p}=kEe(),h=y.useMemo(()=>i?.datasets??[],[i?.datasets]),m=y.useMemo(()=>u?.experiments??[],[u?.experiments]),g=y.useMemo(()=>QGr(h),[h]),v=y.useMemo(()=>D5t(p),[p]),b=l||d,w=f||c;if(w&&cs(w))return o.jsx(or,{children:o.jsx(Ms,{})});if(f&&ds(f))return o.jsx(or,{children:o.jsx(ks,{resource:"experiments"})});if(c&&ds(c))return o.jsx(or,{children:o.jsx(ks,{resource:"datasets"})});if(w)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load experiments",message:w.message})});if(m.length===0&&!b)return o.jsx(or,{children:o.jsx(XGr,{})});const S=n!=="all"||s!=="all"||e!=="",O=()=>{t(""),r("all"),a("all")};return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx(KGr,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:O,hasActiveFilters:S})}),o.jsx(ZGr,{experiments:m,datasets:h,reviewByExperiment:v,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function m8({children:e}){return o.jsxs(Dt,{height:"full",children:[o.jsx("div",{}),o.jsx(Dt.MainArea,{isCentered:!0,children:e})]})}function tYr(){const{experimentId:e}=vr(),{data:t,isLoading:n}=MZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=PB(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=RZ({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&cs(l)?o.jsx(m8,{children:o.jsx(Ms,{})}):l&&ds(l)?o.jsx(m8,{children:o.jsx(ks,{resource:"datasets"})}):l&&xSe(l)||!n&&!s||!i&&!l&&!a?o.jsx(m8,{children:o.jsx(Qr,{iconSlot:o.jsx(wve,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(pe,{as:ui,to:"/experiments",children:[o.jsx(gc,{}),"Back to Experiments"]})})}):l?o.jsx(m8,{children:o.jsx(Di,{title:"Failed to load experiment",message:l instanceof Error?l.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Dt,{height:"full",children:[o.jsx(L5t,{experiment:a}),o.jsx(Dt.MainArea,{children:o.jsx(M5t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function nYr({connection:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsxs("li",{className:"flex items-center justify-between border-b py-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"font-mono text-xs",children:e.connectionId}),o.jsxs("div",{className:"text-xs text-gray-500",children:[e.label??"(no label)"," · ",e.status,e.scope?` · ${e.scope}`:"",t&&e.authorId?` · author: ${e.authorId}`:""]})]}),o.jsx("button",{type:"button",className:"text-red-600 underline disabled:opacity-50",onClick:r,disabled:n,children:"Disconnect"})]})}function F5t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(nYr,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function rYr({groups:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("div",{className:"space-y-4",children:e.map(([s,a])=>o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-700","data-testid":`integration-author-group-${s}`,children:s==="shared"?"Shared":`Owned by ${s}`}),o.jsx(F5t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function sYr({providerId:e,toolkit:t,connections:n,groupedByAuthor:r,isAdmin:s,isLoading:a,error:i,disconnectPending:l,disconnectError:c,onDisconnect:u}){return o.jsxs("div",{className:"space-y-2 border rounded p-4",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Existing connections"}),!e||!t?o.jsx("p",{className:"text-gray-500",children:"Pick a provider and toolkit to list connections."}):a?o.jsx("p",{className:"text-gray-500",children:"Loading…"}):i?o.jsx("p",{className:"text-red-600",children:String(i)}):n.length===0?o.jsx("p",{className:"text-gray-500",children:"No connections."}):r?o.jsx(rYr,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(F5t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function aYr({providers:e,toolkits:t,providerId:n,toolkit:r,label:s,providersLoading:a,providersError:i,toolkitsLoading:l,toolkitsError:c,authorizePending:u,authorizeError:d,authorizedConnection:f,onProviderChange:p,onToolkitChange:h,onLabelChange:m,onConnect:g}){return o.jsxs("div",{className:"space-y-4 border rounded p-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"provider-select",children:"Provider"}),o.jsxs("select",{id:"provider-select",className:"border rounded px-2 py-1 w-full",value:n,onChange:v=>p(v.target.value),disabled:a,children:[o.jsx("option",{value:"",children:"— select provider —"}),e.map(v=>o.jsxs("option",{value:v.id,children:[v.displayName??v.name," (",v.id,")"]},v.id))]}),a&&o.jsx("span",{className:"text-gray-500",children:"Loading providers…"}),i?o.jsx("span",{className:"text-red-600",children:String(i)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"toolkit-select",children:"Toolkit"}),o.jsxs("select",{id:"toolkit-select",className:"border rounded px-2 py-1 w-full",value:r,onChange:v=>h(v.target.value),disabled:!n||l,children:[o.jsx("option",{value:"",children:"— select toolkit —"}),t.map(v=>o.jsxs("option",{value:v.slug,children:[v.name," (",v.slug,")"]},v.slug))]}),l&&o.jsx("span",{className:"text-gray-500",children:"Loading toolkits…"}),c?o.jsx("span",{className:"text-red-600",children:String(c)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"label-input",children:"Label (optional)"}),o.jsx("input",{id:"label-input",type:"text",className:"border rounded px-2 py-1 w-full",placeholder:"My personal Gmail",value:s,onChange:v=>m(v.target.value),disabled:!n||!r})]}),o.jsx("button",{type:"button",className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",onClick:g,disabled:!n||!r||u,children:u?"Authorizing…":"Connect"}),d?o.jsx("p",{className:"text-red-600",children:String(d)}):null,f&&o.jsxs("p",{className:"text-green-700",children:["Authorized: ",f.connectionId," (status: ",f.status,")"]})]})}const iWe=e=>e.authorId?.trim()||"shared",iYr=(e,t)=>{if(!t||new Set(e.map(iWe)).size<=1)return null;const r=new Map;for(const a of e){const i=iWe(a);r.set(i,[...r.get(i)??[],a])}const s=Array.from(r.entries());return s.sort(([a],[i])=>a==="shared"?1:i==="shared"?-1:a.localeCompare(i)),s},oYr=["*","tool-providers:*","tool-providers:admin"];function lYr(){const{data:e}=rm();return e?.permissions?.some(t=>oYr.includes(t))??!1}function cYr(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[s,a]=y.useState(""),i=QN(),l=kH(e||null),c=$At(e||null,n||null),u=PAt(),d=AAt(),f=lYr(),p=i.data?.providers??[],h=l.data?.data??[],m=y.useMemo(()=>c.data?.items??[],[c.data?.items]),g=y.useMemo(()=>iYr(m,f),[m,f]),v=S=>{t(S),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},w=S=>{d.mutate({providerId:e,connectionId:S})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(aYr,{providers:p,toolkits:h,providerId:e,toolkit:n,label:s,providersLoading:i.isLoading,providersError:i.error,toolkitsLoading:l.isLoading,toolkitsError:l.error,authorizePending:u.isPending,authorizeError:u.error,authorizedConnection:u.data,onProviderChange:v,onToolkitChange:r,onLabelChange:a,onConnect:b}),o.jsx(sYr,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:w})]})}function uYr({title:e,description:t,errorBanner:n,children:r}){return o.jsx("div",{"data-testid":"login-page",className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[o.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[o.jsx(Th,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function z5t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=Sc(),{mutate:i,isPending:l,error:c}=kRr(),{mutate:u,isPending:d,error:f}=_Rr(),{mutate:p,isPending:h}=eAt(),[m,g]=y.useState(n),[v,b]=y.useState(""),[w,S]=y.useState(""),[O,_]=y.useState("");if(a)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Loading..."})});if(!s?.enabled||!s?.login)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Authentication is not configured"})});const{login:C}=s,j=C.type==="sso"||C.type==="both",E=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,P=m==="signin"||!I,$=P?l:d,B=P?c:f,D=()=>{t?t():e?window.location.href=e:window.location.href="/"},V=M=>{M.preventDefault(),P?i({email:w,password:O},{onSuccess:D}):u({email:w,password:O,name:v||void 0},{onSuccess:D})},H=()=>{p({redirectUri:e},{onSuccess:M=>{window.location.href=M.url}})},L=()=>{g(P?"signup":"signin")},F=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(af,{className:"mt-0.5 h-4 w-4 shrink-0 text-neutral4"}),o.jsx("p",{className:"text-sm text-neutral3",children:C.description})]}):null,z=r?o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:r}):null;return o.jsxs(uYr,{title:P?"Sign in to Mastra Studio":"Create your account",description:F,errorBanner:z,children:[E&&o.jsxs("form",{onSubmit:V,className:"space-y-4",children:[!P&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(kn,{id:"name",type:"text",value:v,onChange:M=>b(M.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(kn,{id:"email",type:"email",value:w,onChange:M=>S(M.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(kn,{id:"password",type:"password",value:O,onChange:M=>_(M.target.value),placeholder:P?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),B&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:B.message}),o.jsx(pe,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?P?"Signing in...":"Creating account...":P?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:P?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:P?"Sign up":"Sign in"})]})]}),j&&E&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-border1"})}),o.jsx("div",{className:"relative flex justify-center text-sm",children:o.jsx("span",{className:"bg-surface1 px-2 text-neutral3",children:"or continue with"})})]}),j&&N&&o.jsxs(pe,{onClick:H,disabled:h,className:"w-full",size:"lg",variant:"outline",children:[N.icon&&o.jsx("span",{className:"mr-2",children:N.icon}),h?"Redirecting...":N.text||"Sign in"]})]})}function dYr(){const[e]=zi(),t=Ks(),n=e.get("redirect")||"/",s=e.get("mode")==="signup"?"signup":"signin",a=e.get("error_description")||e.get("error")||null,i=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(z5t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function fYr(){const[e,t]=zi(),n=Kvr(e,t),r=tyr(e,t),[s,a]=y.useState(),[i,l]=y.useState(!1),{data:c=[],isPending:u}=ASe(),{data:d=[],isPending:f}=RSe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=PSe(),{data:m=[],isPending:g}=$Se(),v=y.useMemo(()=>wgr({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:g,environments:h}}),[c,d,m,p,u,f,g,h]),b=y.useMemo(()=>_gr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:w=[],isLoading:S,error:O,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j}=Yvr({filters:b}),{logIdMap:E,featuredLog:N,handleLogClick:I,handlePreviousLog:P,handleNextLog:$}=syr(w,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:B,isLoading:D}=ISe(n.featuredTraceId??null),{data:V,isLoading:H}=iD(n.featuredTraceId??"",n.featuredSpanId??""),L=y.useCallback(()=>n.applyFilterTokens(Cgr(v,n.filterTokens)),[v,n]),F=y.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),z=y.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),M=y.useCallback((X,ne)=>n.handleFeaturedChange({traceId:X,spanId:ne}),[n]),G=y.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),U=y.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),R=y.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),q=o.jsxs(Dt.TopArea,{children:[o.jsx(Dt.Row,{children:o.jsxs(Dt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Nwe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:S,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(s0e,{fields:v,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:S,onStartTextFilter:a})]})}),o.jsx(Uvr,{isLoading:S,filterFields:v,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:L,onRemoveAll:n.handleRemoveAll,onSave:r.handleSave,onRemoveSaved:r.hasSavedFilters?r.handleRemoveSaved:void 0,autoFocusFilterFieldId:s})]});if(O)return o.jsxs(Dt,{width:"wide",height:"full",children:[q,o.jsx(Dt.MainArea,{isCentered:!0,children:o.jsx(Dvr,{error:O,resource:"logs",errorTitle:"Failed to load logs"})})]});const W=!!n.selectedEntityOption||n.filterTokens.length>0;return w.length===0&&!S&&!W?o.jsxs(Dt,{width:"wide",height:"full",children:[q,o.jsx(Dt.MainArea,{isCentered:!0,children:o.jsx(Zvr,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Dt,{width:"wide",height:"full",children:[q,o.jsx(Lvr,{logCollapsed:i,listSlot:o.jsx(Bvr,{logs:w,isLoading:S,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j,logIdMap:E,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(Mvr,{log:N,onClose:F,onTraceClick:z,onSpanClick:M,onPrevious:P,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(lvr,{traceId:n.featuredTraceId,spans:B?.spans,isLoading:D,onClose:G,onSpanSelect:R,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(ovr,{spanId:n.featuredSpanId,span:V?.span,isLoading:H,onClose:U}):null})]})}function pYr({server:e}){const{paths:t,Link:n}=vn(),s=He().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=$4t(e),l=Object.values(i||{}),c=l.length,u=l.filter(p=>p.toolType==="agent").length,d=l.filter(p=>p.toolType==="workflow").length,f=Vh(e.name,50);return o.jsxs(xe.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(xe.NameCell,{children:f}),o.jsx(xe.DescriptionCell,{children:a}),o.jsx(xe.TextCell,{className:"text-center",children:u||""}),o.jsx(xe.TextCell,{className:"text-center",children:c||""}),o.jsx(xe.TextCell,{className:"text-center",children:d||""})]})}function hYr({mcpServers:e,isLoading:t,search:n=""}){const r=y.useMemo(()=>{const s=n.toLowerCase();return e.filter(a=>a.name?.toLowerCase().includes(s)||a.id?.toLowerCase().includes(s))},[e,n]);return t?o.jsx(Wo,{columns:"auto 1fr auto auto auto"}):o.jsxs(xe,{columns:"auto 1fr auto auto auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"URL"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Xo,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Tools",short:o.jsx(cf,{}),tooltip:"Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Workflows",short:o.jsx(fd,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(xe.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(pYr,{server:s},s.id))]})}const mYr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"No MCP Servers yet",descriptionSlot:o.jsxs(o.Fragment,{children:["MCP servers are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(ja,{})]})})}),gYr=()=>{const{data:e=[],isLoading:t,error:n}=CZ(),[r,s]=y.useState("");return n&&cs(n)?o.jsx(or,{children:o.jsx(Ms,{})}):n&&ds(n)?o.jsx(or,{children:o.jsx(ks,{resource:"MCP servers"})}):n?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(or,{children:o.jsx(mYr,{})}):o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(xf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(hYr,{mcpServers:e,isLoading:t,search:r})]})},vYr=(e,t)=>{const n=new Map,r=Object.keys(t);for(const s of r){const a=t[s],i=a.tools,l=Object.keys(i);for(const c of l){const u=i[c];n.has(u.id)||n.set(u.id,{...u,agents:[]}),n.get(u.id).agents.push({...a,id:s})}}for(const[s,a]of Object.entries(e))n.has(a.id)||n.set(a.id,{...a,agents:[]});return Array.from(n.values())};function yYr({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=vn(),i=y.useMemo(()=>vYr(e,t),[e,t]),l=y.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(Wo,{columns:"auto 1fr auto"}):o.jsxs(xe,{columns:"auto 1fr auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"Description"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Xo,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(xe.NoMatch,{message:"No Tools match your search"}):null,l.map(c=>{const u=Vh(c.id,50),d=Vh(c.description??"",200),f=c.agents.length;return o.jsxs(xe.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(xe.NameCell,{children:u}),o.jsx(xe.DescriptionCell,{children:d}),o.jsx(xe.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const bYr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"No Tools yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Mastra tools are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(ja,{})]})})}),xYr=()=>{const e=He();return An({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new QO;Object.entries(r??{}).forEach(([a,i])=>{s.set(a,i)});try{return await e.getTool(t).execute({data:n,requestContext:s})}catch(a){throw Ue.error("Error executing dev tool"),console.error("Error executing dev tool:",a),a}}})},wYr=({toolId:e})=>{const{canExecute:t}=ul(),n=t("tools"),{data:r={}}=sm(),s=y.useMemo(()=>{for(const g of Object.values(r))if(g.tools){const v=Object.values(g.tools).find(b=>b.id===e);if(v)return v}return null},[r,e]),{data:a,isLoading:i,error:l}=$Ar(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=xYr(),{requestContext:p}=Os();y.useEffect(()=>{if(l){const g=l instanceof Error?l.message:"Failed to load tool";Ue.error(`Error loading tool: ${g}`)}},[l]);const h=async(g,v)=>{if(!c)return;const b={...p??{},...v??{}};return u({toolId:c.id,input:g,requestContext:b})},m=c?.inputSchema?hg(fg(px(c?.inputSchema))):ws({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(_n,{className:"h-8 w-48 mb-4"}),o.jsx(_n,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(lEe,{executionResult:f,isExecutingTool:d,zodInputSchema:m,handleExecuteTool:h,toolDescription:c.description,toolId:c.id,requestContextSchema:c.requestContextSchema}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})})};function SYr({value:e,onValueChange:t,placeholder:n="Select a tool...",searchPlaceholder:r="Search tools...",emptyText:s="No tools found.",className:a,disabled:i=!1,variant:l}){const{data:c={},isLoading:u,isError:d,error:f}=WN(),{data:p={},isLoading:h,isError:m,error:g}=sm(),{navigate:v,paths:b}=vn();y.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";Ue.error(`Error loading tools: ${_}`)}},[d,f]),y.useEffect(()=>{if(m){const _=g instanceof Error?g.message:"Failed to load agents";Ue.error(`Error loading agents: ${_}`)}},[m,g]);const w=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{w.has(C.id)||w.set(C.id,C)})}),Object.values(c).forEach(_=>{w.has(_.id)||w.set(_.id,_)});const S=Array.from(w.values()).map(_=>({label:_.id,value:_.id})),O=_=>{t?t(_):_&&_!==e&&v(b.toolLink(_))};return o.jsx(Hc,{options:S,value:e,onValueChange:O,placeholder:u||h?"Loading tools...":n,searchPlaceholder:r,emptyText:s,className:a,disabled:i||u||h||d||m,variant:l})}const kYr=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=y.useState({sseUrl:"",httpStreamUrl:""});if(y.useEffect(()=>{if(!t)return;const i=window.MASTRA_SERVER_HOST,l=window.MASTRA_SERVER_PORT;let c=null;i&&l&&(c=`http://${i}:${l}`);const u=c||"http://localhost:4111",d=`${u}/api/mcp/${t.id}/sse`,f=`${u}/api/mcp/${t.id}/mcp`;s({sseUrl:d,httpStreamUrl:f})},[t]),e)return null;if(!t)return o.jsx(Qv,{children:o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral3 font-medium py-20 text-center",children:"Server not found"})});const a=`npx -y mcp-remote ${n}`;return o.jsxs(Qv,{isDivided:!0,children:[o.jsxs("div",{className:"px-8 py-12 mx-auto max-w-2xl w-full",children:[o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral6 font-medium pb-4",children:t.name}),o.jsxs("div",{className:"flex items-center gap-1 pb-6",children:[o.jsx(Jt,{icon:o.jsx(J_t,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(Jt,{className:"rounded-l-sm text-neutral4!",children:t.version_detail.version})]}),o.jsx(ge,{className:"text-neutral3 pb-4",children:"This MCP server can be accessed through multiple transport methods. Choose the one that best fits your use case."}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(Jt,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"HTTP"}),children:"Regular HTTP Endpoint"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for stateless HTTP transport with streamable responses."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:r}),o.jsx("div",{className:"pt-1",children:o.jsx(Pa,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(Jt,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"SSE"}),children:"Server-Sent Events"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for real-time communication via SSE."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:n}),o.jsx("div",{className:"pt-1",children:o.jsx(Pa,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(Jt,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"CLI"}),children:"Command Line"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for local command-line access via npx and mcp-remote."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:a}),o.jsx("div",{className:"pt-1",children:o.jsx(Pa,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(OYr,{server:t})})]})},OYr=({server:e})=>{const{data:t={},isLoading:n}=$4t(e);if(n)return null;const r=Object.keys(t);return o.jsxs("div",{className:"p-5 overflow-y-scroll",children:[o.jsxs("div",{className:"text-neutral6 flex gap-2 items-center",children:[o.jsx(Ge,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(t1,{})}),o.jsx(ge,{variant:"header-md",as:"h2",className:"font-medium",children:"Available Tools"})]}),o.jsx("div",{className:"flex flex-col gap-2 pt-6",children:r.map(s=>{const a=t[s];return o.jsx(CYr,{tool:a,serverId:e.id},s)})})]})};function _Yr(e){if(!e)return!1;const t=e.ui;return!!(typeof t?.resourceUri=="string"&&t.resourceUri.startsWith("ui://")||typeof e["ui/resourceUri"]=="string"&&e["ui/resourceUri"].startsWith("ui://"))}const CYr=({tool:e,serverId:t})=>{const n=y.useRef(null),{Link:r,paths:s}=vn(),a=K4t[e.toolType||"tool"],i=_Yr(e._meta);return o.jsxs(gf,{onClick:()=>n.current?.click(),children:[o.jsx(cht,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(yf,{children:[o.jsx(vf,{children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(r,{ref:n,href:s.mcpServerToolLink(t,e.id),children:e.id}),i&&o.jsx(Jt,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Mp,{children:e.description})]})]})},EYr=()=>{const{serverId:e}=vr(),{data:t=[],isLoading:n}=CZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(kYr,{isLoading:n,server:r})})};function jYr(e){if(!e)return;const t=e.ui;if(t?.resourceUri)return t.resourceUri;const n=e["ui/resourceUri"];if(typeof n=="string")return n}const TYr=({toolId:e,serverId:t})=>{const{canExecute:n}=ul(),r=n("tools"),s=He(),{data:a,isLoading:i,error:l}=KCe(t,e),{mutateAsync:c,isPending:u,data:d}=qBr(t,e),f=a?jYr(a._meta):void 0,{data:p}=xt({queryKey:["mcp-app-resource",t,f],queryFn:async()=>f?(await s.readMcpServerResource(t,f)).contents[0]?.text??null:null,enabled:!!f}),h=y.useCallback(async(v,b)=>await c(b),[c]);y.useEffect(()=>{if(l){const v=l instanceof Error?l.message:"Failed to load tool";Ue.error(`Error loading tool: ${v}`)}},[l]);const m=async v=>{if(a)return await c(v)};if(i)return o.jsxs("div",{className:"p-6",children:[o.jsx(_n,{className:"h-8 w-48 mb-4"}),o.jsx(_n,{className:"h-32 w-full"})]});if(l)return null;if(!a)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})});if(!r)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})});let g;try{g=hg(fg(a.inputSchema))}catch(v){console.error("Error processing input schema:",v),Ue.error("Failed to process tool input schema."),g=ws({})}return o.jsxs("div",{className:"flex flex-col gap-4",children:[p&&o.jsx("div",{className:"border-b border-border1 p-4",children:o.jsx(P4t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(lEe,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},NYr=()=>{const{serverId:e,toolId:t}=vr(),{data:n,isLoading:r}=KCe(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(TYr,{toolId:t,serverId:e})})},oWe={agents:Ps.AGENT,workflows:Ps.WORKFLOW_RUN,tools:Ps.TOOL};function IYr(){const{data:e,isLoading:t,isError:n}=agr(),{getTracesHref:r,getBucketTracesHref:s}=VN(),{Link:a}=vn(),i=Ks();return o.jsx(Hmr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:oWe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(nD,{href:r({rootEntityType:oWe[l]}),LinkComponent:a})})}function AYr(){const e=hgr(),t=mgr(),{getTracesHref:n}=VN(),{Link:r}=vn();return o.jsx(Wmr,{threads:{data:e.data,isLoading:e.isLoading,isError:e.isError},resources:{data:t.data,isLoading:t.isLoading,isError:t.isError},LinkComponent:r,getThreadRowHref:s=>n({threadId:s.threadId,...s.resourceId?{resourceId:s.resourceId}:{}}),getResourceRowHref:s=>n({resourceId:s.resourceId})})}function RYr(){const{data:e,isLoading:t,isError:n}=vCt();return o.jsx(rD,{label:"Total Agent Runs",value:e?.value!=null?e.value.toLocaleString():null,prevValue:e?.previousValue!=null?e.previousValue.toLocaleString():void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function PYr(){const{data:e,isLoading:t,isError:n}=ngr();return o.jsx(rD,{label:"Total Model Cost",value:e?.cost!=null?Xm(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?Xm(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function $Yr(){const{data:e,isLoading:t,isError:n}=rgr();return o.jsx(rD,{label:"Total Tokens",value:e?.value!=null?sc(e.value):null,prevValue:e?.previousValue!=null?sc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function MYr(){const{data:e,isLoading:t,isError:n}=fgr();return o.jsx(rD,{label:"Total Threads",value:e?.value!=null?sc(e.value):null,prevValue:e?.previousValue!=null?sc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function DYr(){const{data:e,isLoading:t,isError:n}=pgr();return o.jsx(rD,{label:"Total Resources",value:e?.value!=null?sc(e.value):null,prevValue:e?.previousValue!=null?sc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function LYr({onClear:e,onRemoveAll:t,onSave:n,onRemoveSaved:r,isLoading:s,filterFields:a,filterTokens:i,onFilterTokensChange:l,autoFocusFilterFieldId:c}){const u=i.length>0,d=i.some(f=>FYr(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(r0e,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(t0e,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function FYr(e,t){const n=t.find(r=>r.id===e.fieldId);return n?n.kind==="text"?typeof e.value=="string"&&e.value.trim()!=="":n.kind==="pick-multi"?n.multi?Array.isArray(e.value)&&e.value.length>0:typeof e.value=="string"&&e.value!==""&&e.value!=="Any":n.kind==="multi-select"?Array.isArray(e.value)&&e.value.length>0:!1:!1}function zYr(){const{data:e,isLoading:t,isError:n}=sgr(),{getTracesHref:r}=VN(),{Link:s}=vn();return o.jsx(Qmr,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Ps.AGENT}),actions:o.jsx(nD,{href:r({rootEntityType:Ps.AGENT}),LinkComponent:s})})}function BYr(){const{data:e,isLoading:t,isError:n}=ogr(),{getTracesHref:r}=VN(),{Link:s}=vn();return o.jsx(Ymr,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Ps.AGENT,entityName:a.name}),actions:o.jsx(nD,{href:r({rootEntityType:Ps.AGENT}),LinkComponent:s})})}function UYr(){const{data:e,isLoading:t,isError:n}=dgr(),{getTracesHref:r}=VN(),{Link:s}=vn();return o.jsx(Jmr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(nD,{href:r(),LinkComponent:s})})}const g8={agents:Ps.AGENT,workflows:Ps.WORKFLOW_RUN,tools:Ps.TOOL};function qYr(){const{data:e,isLoading:t,isError:n}=igr(),{getTracesHref:r,getLogsHref:s}=VN(),{Link:a}=vn();return o.jsx(egr,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:g8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:g8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(nD,{href:r({rootEntityType:g8[i]}),LinkComponent:a}),o.jsx(qmr,{href:s({rootEntityType:g8[i],status:"error"}),LinkComponent:a})]})})}const VYr=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner"]),Vne="period",v8="dateFrom",y8="dateTo";function HYr(){const[e,t]=zi(),n=e.get(Vne),r=Mmr(n)?n:"24h",s=y.useMemo(()=>{if(r!=="custom")return;const d=h=>{if(!h)return;const m=new Date(h);return Number.isNaN(m.getTime())?void 0:m},f=d(e.get(v8)),p=d(e.get(y8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=y.useMemo(()=>Tmr(e),[e.toString()]),i=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(Vne):p.set(Vne,d),d!=="custom"&&(p.delete(v8),p.delete(y8)),p},{replace:!0})},[t]),l=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(v8,d.from.toISOString()):p.delete(v8),d?.to?p.set(y8,d.to.toISOString()):p.delete(y8),p},{replace:!0})},[t]),c=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return Imr(p,d),p},{replace:!0})},[t]),u=y.useRef(!1);return y.useEffect(()=>{if(u.current||(u.current=!0,Emr(e)))return;const d=hCt();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(Lmr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(ZYr,{})})}function ZYr(){const[e]=zi(),{error:t,isLoading:n}=vCt(),{filterTokens:r,setFilterTokens:s}=qV(),[a,i]=y.useState(),{data:l,isLoading:c}=i4(),u=l?.observabilityStorageType,d=u?VYr.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=ASe(),{data:m,isLoading:g}=RSe(),{data:v,isLoading:b}=$Se(),{data:w,isLoading:S}=PSe(),O=y.useMemo(()=>jmr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:v??[],availableEnvironments:w??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:S}}),[p,m,v,w,h,g,b,S]),[_,C]=y.useState(()=>hCt()!==null),j=y.useCallback(()=>{_mr(e),C(!0),Ue.success("Filters setting for Metrics saved")},[e]),E=y.useCallback(()=>{Cmr(),C(!1),Ue.success("Filters setting for Metrics cleared up")},[]),N=y.useCallback(()=>{s([])},[s]),I=y.useCallback(()=>{const P=r.map($=>{const B=O.find(D=>D.id===$.fieldId);return B?B.kind==="text"?{fieldId:$.fieldId,value:""}:B.kind==="pick-multi"?B.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:B.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(P)},[O,r,s]);return t&&cs(t)?o.jsx(or,{children:o.jsx(Ms,{})}):t&&ds(t)?o.jsx(or,{children:o.jsx(ks,{resource:"metrics"})}):t?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load metrics",message:t.message})}):o.jsxs(Dt,{width:"wide",height:"full",children:[o.jsxs(Dt.TopArea,{children:[o.jsx(Dt.Row,{children:o.jsxs(Dt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Umr,{}),o.jsx(s0e,{fields:O,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(LYr,{isLoading:n,filterFields:O,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:j,onRemoveSaved:_?E:void 0,autoFocusFilterFieldId:a})]}),c?null:d?o.jsxs("div",{className:"grid gap-8 content-start pb-10",children:[f&&o.jsx(Rn,{variant:"info",title:"Metrics are not persisted",children:o.jsx(Rn.Message,{children:"This project uses in-memory storage for observability. Metrics will be lost on every server restart. For persistent metrics, switch the observability storage to ClickHouse, DuckDB, or Spanner."})}),o.jsxs(gfe,{children:[o.jsx(RYr,{}),o.jsx(PYr,{}),o.jsx($Yr,{}),o.jsx(MYr,{}),o.jsx(DYr,{})]}),o.jsxs(gfe,{children:[o.jsx(zYr,{}),o.jsx(BYr,{}),o.jsx(UYr,{}),o.jsx(AYr,{}),o.jsx(qYr,{}),o.jsx(IYr,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"Metrics are not available with your current storage",descriptionSlot:"Metrics require ClickHouse, DuckDB, Spanner, or in-memory storage for observability. Relational databases (PostgreSQL, LibSQL) do not support metrics collection. To enable metrics on an existing project, switch the observability storage in the Mastra configuration.",actionSlot:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(ja,{})]})})})]})}function WYr(){const{paths:e}=vn(),{data:t,isLoading:n,error:r}=J4t(),{isCmsAvailable:s}=c4(),[a,i]=y.useState(""),l=t?.promptBlocks??[];return r&&cs(r)?o.jsx(or,{children:o.jsx(Ms,{})}):r&&ds(r)?o.jsx(or,{children:o.jsx(ks,{resource:"prompt blocks"})}):r?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(or,{children:o.jsx(NVr,{})}):o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(xf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(pe,{as:ui,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Ur,{}),"Create Prompt"]})]})}),o.jsx(TVr,{promptBlocks:l,isLoading:n,search:a})]})}function QYr(){return o.jsx(Dt,{width:"narrow",children:o.jsx(Dt.MainArea,{children:o.jsx(mUr,{children:o.jsx(D4t,{})})})})}const GYr=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:Ban,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:xat,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:ja,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:lP,href:"https://discord.gg/BTYqqHKUrf",external:!0},{title:"Share with your team",description:"Running Mastra Studio locally? Deploy to the cloud so your team can collaborate.",icon:jat,href:"https://mastra.ai/cloud",external:!0},{title:"Talk to our Sales team",description:"Get a custom demo, discuss on-prem deployments, and how we can help you accelerate getting agents into production.",icon:wat,href:"https://mastra.ai/contact?ref=studio",external:!0}];function YYr(){return o.jsx(Dt,{width:"narrow",children:o.jsx(Dt.MainArea,{children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-3xl",children:GYr.map(e=>o.jsxs("a",{href:e.href,...e.external?{target:"_blank",rel:"noreferrer"}:{},className:"group flex flex-col gap-3 rounded-lg border border-border1 bg-surface2 p-5 transition-colors hover:border-accent1 hover:bg-surface3",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(e.icon,{className:"h-5 w-5 text-icon3 group-hover:text-accent1 transition-colors"}),o.jsx("span",{className:"text-ui-md font-medium text-text1",children:e.title}),e.external&&o.jsx(ja,{className:"h-3.5 w-3.5 text-icon3 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),o.jsx("p",{className:"text-ui-sm text-text3 leading-relaxed",children:e.description})]},e.href))})})})}function XYr(){const{data:e={},isLoading:t,error:n}=Up(),[r,s]=y.useState(""),[a,i]=y.useState("all");if(n&&cs(n))return o.jsx(or,{children:o.jsx(Ms,{})});if(n&&ds(n))return o.jsx(or,{children:o.jsx(ks,{resource:"scorers"})});if(n)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(or,{children:o.jsx(Rqr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx($qr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(Aqr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function KYr(){const{scorerId:e}=vr(),[t,n]=zi(),r=t.get("scoreId")??void 0,[s,a]=y.useState(r),[i,l]=y.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=Tqr(e),{data:d={},isLoading:f,error:p}=sm(),{isLoading:h,error:m}=Ey(),{data:g=[],isLoading:v,error:b,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O}=jqr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=y.useMemo(()=>c?.agentIds?.filter(z=>d[z]).map(z=>({value:z,label:d[z].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=y.useMemo(()=>c?.workflowIds?.map(z=>({value:z,label:z,type:"WORKFLOW"}))||[],[c?.workflowIds]),j=y.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),E=t.get("entity")??"all",N=j.find(z=>z.value===E);N&&N.value!==i?.value&&l(N),y.useEffect(()=>{if(u){const z=u instanceof Error?u.message:"Failed to load scorer";Ue.error(`Error loading scorer: ${z}`)}},[u]),y.useEffect(()=>{if(p){const z=p instanceof Error?p.message:"Failed to load agents";Ue.error(`Error loading agents: ${z}`)}},[p]),y.useEffect(()=>{if(m){const z=m instanceof Error?m.message:"Failed to load workflows";Ue.error(`Error loading workflows: ${z}`)}},[m]);const I=z=>{z?.value&&n(M=>{const G=new URLSearchParams(M);return G.set("entity",z.value),G})};y.useEffect(()=>{const z=t.get("scoreId")??void 0;if(z===s)return;if(!z){a(void 0);return}g.find(G=>G.id===z)&&a(z)},[t,g]);const P=y.useCallback(z=>{a(z||void 0),n(M=>{const G=new URLSearchParams(M);return z?G.set("scoreId",z):G.delete("scoreId"),G})},[n]);if(!c)return null;const $=cs(u)||cs(p)||cs(m),B=u&&ds(u),D=!$&&!B&&(u||p||m),V=!v&&g.length===0,H=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(Sy,{owner:"scorer-detail",children:o.jsxs(pe,{variant:"default",as:ui,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Dh,{})," Edit"]})}):null;if($||B||D||V&&!H){const z=(u instanceof Error?u.message:void 0)??(p instanceof Error?p.message:void 0)??(m instanceof Error?m.message:void 0)??"An unexpected error occurred";return o.jsxs(Dt,{width:"wide",height:"full",children:[L,o.jsx(Dt.MainArea,{isCentered:!0,children:$?o.jsx(Ms,{}):B?o.jsx(ks,{resource:"scorers"}):D?o.jsx(Di,{title:"Failed to load scorer",message:z}):o.jsx(kqr,{})})]})}return o.jsxs(Dt,{width:"wide",children:[L,o.jsx(Dt.TopArea,{children:o.jsx(Oqr,{selectedEntity:i,entityOptions:j,onEntityChange:I,onReset:()=>{n(z=>{const M=new URLSearchParams(z);return M.set("entity","all"),M})},isLoading:v||f||h})}),o.jsx(Sqr,{scores:g,isLoading:v,selectedScoreId:s,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O,onScoreClick:P,errorMsg:b?.message})]})}function JYr({label:e,description:t,htmlFor:n,className:r,children:s}){return o.jsxs("div",{className:K("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",r),"data-slot":"settings-row",children:[o.jsxs("div",{children:[n?o.jsx(Pt,{htmlFor:n,className:"text-sm font-medium",children:e}):o.jsx("p",{className:"text-sm font-medium",children:e}),t&&o.jsx("p",{className:"text-sm text-neutral3",children:t})]}),s]})}const B5t=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"system",label:"System"}],eXr=e=>B5t.some(t=>t.value===e),tXr=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=FSe(),{theme:r,setTheme:s}=gN();return o.jsx(Dt,{width:"narrow",children:o.jsxs(Dt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Tfe,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(JYr,{label:"Theme mode",htmlFor:"theme",children:o.jsxs($a,{value:r,onValueChange:a=>{eXr(a)&&s(a)},children:[o.jsx(Da,{id:"theme",className:"w-full sm:w-48",children:o.jsx(Ma,{})}),o.jsx(La,{children:B5t.map(a=>o.jsx(Xr,{value:a.value,children:a.label},a.value))})]})})}),o.jsx(Tfe,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(F4t,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function nXr(){const[e]=zi(),t=Ks(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(z5t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}function rXr(e){return e.replace(/\/$/,"").split("/").pop()}function DZ({children:e,className:t}){return o.jsx("div",{className:K("border border-border1 rounded-lg mt-12 py-8 lg:min-h-[25rem] transition-height px-4 lg:px-12",t),children:e})}function sXr({templates:e,linkComponent:t,className:n,isLoading:r}){const s=t||"a";return r?o.jsx("div",{className:K("grid gap-y-4",n),children:Array.from({length:5}).map((a,i)=>o.jsx("div",{className:"h-16 bg-surface3 animate-pulse rounded-lg"},i))}):o.jsx("div",{className:K("grid gap-y-4",n),children:e.map(a=>{const i=a?.agents||a?.tools||a?.networks||a?.workflows||a?.mcp;return o.jsxs("article",{className:K("border border-border1 rounded-lg overflow-hidden w-full grid grid-cols-[1fr_auto] bg-surface3 transition-colors hover:bg-surface4"),children:[o.jsxs(s,{to:`/templates/${a.slug}`,className:K("grid [&:hover_p]:text-neutral5",{"grid-cols-[8rem_1fr] lg:grid-cols-[12rem_1fr]":a.imageURL}),children:[a.imageURL&&o.jsx("div",{className:K("overflow-hidden"),children:o.jsx("div",{className:"w-full h-full bg-cover thumb transition-scale duration-150",style:{backgroundImage:`url(${a.imageURL})`}})}),o.jsxs("div",{className:K("grid py-3 px-6 w-full gap-0.5","[&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-neutral3"),children:[o.jsx("h2",{className:"text-ui-lg text-neutral5",children:a.title}),o.jsx("p",{className:"text-ui-md text-neutral4 transition-colors duration-500",children:a.description}),o.jsxs("div",{className:"hidden 2xl:flex text-neutral3 text-ui-md flex-wrap items-center gap-4 mt-3",children:[i&&o.jsxs("ul",{className:K("flex gap-4 text-ui-md text-neutral3 m-0 p-0 list-none","[&>li]:flex [&>li]:items-center [&>li]:gap-0.5 text-neutral4"),children:[a?.agents&&a.agents.length>0&&o.jsxs("li",{children:[o.jsx(Xo,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(cf,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(zat,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(nU,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(t1,{})," ",a.mcp.length]})]}),i&&a.supportedProviders&&o.jsx("small",{children:"|"}),o.jsx("div",{className:"flex items-center text-neutral3 gap-4",children:a.supportedProviders.map(l=>o.jsx("span",{className:"",children:l},l))})]})]})]}),o.jsx("a",{href:a.githubUrl,className:K("group items-center gap-2 text-ui-md ml-auto pr-4 hidden","lg:flex"),target:"_blank",rel:"noopener noreferrer",children:o.jsxs("span",{className:"flex items-center gap-2 px-2 py-1 rounded bg-surface1 group-hover:bg-surface2 text-neutral3 transition-colors group-hover:text-neutral5",children:[o.jsx(G_t,{})," ",rXr(a.githubUrl)]})})]},a.slug)})})}function aXr({tagOptions:e,selectedTag:t,providerOptions:n,selectedProvider:r,onTagChange:s,onProviderChange:a,searchTerm:i,onSearchChange:l,onReset:c,className:u,isLoading:d}){return d?o.jsxs("div",{className:K("h-[6.5rem] flex items-center gap-8","[&>div]:bg-surface3 [&>div]:w-48 [&>div]:h-8 [&>div]:animate-pulse",u),children:[o.jsx("div",{})," ",o.jsx("div",{})," ",o.jsx("div",{})]}):o.jsxs("div",{className:K("flex flex-wrap mx-auto sticky top-0 gap-4 bg-surface2 py-8",u),children:[o.jsx(Yj,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(ac,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(ac,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(pe,{onClick:c,children:["Reset ",o.jsx(ys,{})]})]})}function iXr(){const{data:e,isLoading:t}=Uyr(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=y.useState("all"),[l,c]=y.useState("all"),[u,d]=y.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(w=>{f.push({value:w,label:w})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(w=>{p.push({value:w,label:w})});const h=(w,S)=>{S==="tag"?i(w):S==="provider"&&c(w)},m=w=>{d(w)},g=()=>{i("all"),c("all"),d("")},v=n.filter(w=>!(u&&!w.title.toLowerCase().includes(u)&&!w.description.toLowerCase().includes(u)||a!=="all"&&!w.tags.includes(a)||l!=="all"&&!w.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ms,{children:[o.jsx(axe,{children:o.jsxs(uht,{children:[o.jsx(Ge,{children:o.jsx(Tv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(aXr,{selectedTag:a,onTagChange:w=>h(w,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:w=>h(w,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(sXr,{templates:v,linkComponent:ui,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const oXr="1.43.0";function lXr({errorMsg:e,validationErrors:t}){const n=typeof e=="string"?e:e!=null?String(e):void 0,r=n?.includes("Invalid schema for function"),s=n?.includes("validation issue")||t&&t.length>0,a=()=>s?"Template installation completed but some validation issues remain. The template may still be functional, but you should review and fix these issues.":r?"There was an issue with the AI model configuration. This may be related to the selected model or AI SDK version compatibility.":"An unexpected error occurred during template installation.",i=()=>s?{icon:o.jsx(gp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(fin,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(DZ,{className:"space-y-4 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[l,o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx("p",{className:"text-ui-md font-medium text-neutral5",children:c}),o.jsx("p",{className:"text-ui-md text-neutral3",children:a()})]})]}),t&&t.length>0&&o.jsxs("details",{className:"text-xs",children:[o.jsxs("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:["Show Validation Issues (",t.length,")"]}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs overflow-auto max-h-60 text-left space-y-2",children:t.map((u,d)=>o.jsxs("div",{className:"border-l-2 border-red-400 pl-2",children:[o.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:u.type==="typescript"?"🔴 TypeScript Error":"⚠️ Lint Error"}),o.jsx("div",{className:"text-xs font-mono text-gray-700 dark:text-gray-300 mt-1 whitespace-pre-wrap wrap-break-word",children:u.message})]},d))})]}),n&&!s&&o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:"Show Details"}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono overflow-auto max-h-60 text-left",children:o.jsx("div",{className:"whitespace-pre-wrap wrap-break-word",children:n})})]})]})}function cXr({providerOptions:e,selectedProvider:t,onProviderChange:n,variables:r,errors:s,handleInstallTemplate:a,handleVariableChange:i,isLoadingEnvVars:l,isInstalling:c,defaultModelProvider:u,defaultModelId:d,onModelUpdate:f}){return o.jsx(DZ,{children:o.jsxs("div",{className:"max-w-[40rem] my-4 p-4 lg:p-8 mx-auto gap-8 grid",children:[o.jsxs("h2",{className:K("text-neutral4 text-header-sm font-semibold flex items-center gap-2","[&>svg]:w-[1.2em] [&_svg]:h-[1.2em] [&_svg]:opacity-70"),children:["Install Template ",o.jsx(Bat,{})]}),o.jsx(ac,{name:"template-provider",options:e,label:"Template AI Model Provider",onValueChange:n,value:t,placeholder:"Select",layout:"horizontal"}),t&&Object.entries(r||{}).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-neutral3 text-ui-md",children:"Set required Environmental Variables"}),o.jsx("div",{className:"grid grid-cols-[1fr_1fr] gap-4 items-start",children:l?o.jsxs("div",{className:K("flex items-center justify-center col-span-2 text-neutral3 text-ui-sm gap-4","[&_svg]:opacity-50 [&_svg]:w-[1.1em] [&_svg]:h-[1.1em]","animate-in fade-in duration-300"),children:[o.jsx(Ht,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(y.Fragment,{children:[o.jsx(pO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(pO,{name:p,labelIsHidden:!0,label:"Value",value:h,onChange:i,errorMsg:s.includes(p)?"Value is required.":"",autoComplete:"off",className:"w-full"})]},p))}),o.jsxs("div",{className:"border-t border-border1 pt-12 mt-3.5 relative",children:[o.jsx("div",{className:"absolute w-8 h-8 rounded-full bg-surface2 top-0 left-1/2 -translate-x-1/2 -translate-y-4 text-ui-sm text-neutral3 flex items-center justify-center",children:"And"}),o.jsx("h3",{className:"text-neutral4 text-ui-lg",children:"Set AI Model for Template Installation"}),o.jsx("p",{className:"text-neutral3 text-ui-md mt-2 mb-8",children:"This model will be used by the workflow to process and install the template"}),o.jsx(L4t,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(pe,{className:K("flex items-center gap-2 mt-4 justify-center text-ui-md w-full bg-surface5 min-h-10 rounded-lg text-neutral5 hover:bg-surface6 transition-colors","[&>svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-neutral5"),onClick:a,disabled:!t||!u||!d||s.length>0||c,children:c?o.jsxs(o.Fragment,{children:[o.jsx(Ht,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(Gh,{})]})})]})})}function uXr({title:e,description:t,githubUrl:n,isLoading:r,infoData:s,templateSlug:a}){const i=a?`feat/install-template-${a}`:"feat/install-template-[slug]";return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:K("grid mt-8 items-center"),children:o.jsxs("div",{className:K("text-header-lg flex items-center gap-3","[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",{"[&>svg]:opacity-20":r}),children:[o.jsx(Tv,{}),o.jsx("h2",{className:K({"bg-surface4 flex rounded-lg min-w-[50%]":r}),children:r?o.jsx(o.Fragment,{children:" "}):e})]})}),o.jsxs("div",{className:"grid lg:grid-cols-[1fr_1fr] gap-x-24",children:[o.jsxs("div",{className:"grid",children:[o.jsx("p",{className:K("mb-4 text-ui-md text-neutral4 mt-2 leading-7",{"bg-surface4 rounded-lg ":r}),children:r?o.jsx(o.Fragment,{children:" "}):t}),!r&&a&&o.jsxs("div",{className:K("bg-surface2 border border-surface4 rounded-lg p-4 mb-4","flex items-start gap-3"),children:[o.jsx("div",{className:"shrink-0 mt-0.5",children:o.jsx(g1,{className:"w-[1.1em] h-[1.1em] text-blue-500"})}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Sve,{className:"w-[1em] h-[1em] text-neutral4"}),o.jsx("span",{className:"text-ui-md font-medium text-neutral5",children:"A new Git branch will be created"})]}),o.jsxs("div",{className:"text-ui-sm text-neutral4 space-y-1",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Branch name:"})," ",o.jsx("code",{className:"bg-surface3 px-1.5 py-0.5 rounded text-ui-sm font-mono",children:i})]}),o.jsx("div",{children:"This ensures safe installation with easy rollback if needed. Your main branch remains unchanged."})]})]})]}),n&&o.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-auto text-neutral3 text-ui-md hover:text-neutral5",children:[o.jsx(G_t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(E0e,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function dXr({name:e,streamResult:t,runId:n,workflowInfo:r}){const s=t?.phase||"initializing",a=t?.payload?.workflowState,i=t?.payload?.currentStep,l=t?.error,c=a?.steps||{},u=Object.keys(c).length>0,d=g=>g==="input"||g.endsWith(".input")||g.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(g)||/[0-9a-f]{8,}/.test(g)?!1:r?.allSteps?g in r.allSteps:!0,f=Object.entries(c).filter(([g,v])=>d(g)),p=f.length,h=()=>{switch(s){case"initializing":return"Preparing template installation...";case"processing":return`Installing ${e} template`;case"completed":return"Template installation completed!";case"error":return"Template installation failed";default:return"Installing template..."}},m=f.map(([g,v])=>({id:g,status:v?.status,description:v?.description,title:g.charAt(0).toUpperCase()+g.slice(1).replace(/-/g," "),isActive:i?.id===g}));return o.jsxs(DZ,{className:"space-y-6 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("h3",{className:"text-lg font-semibold text-neutral5",children:h()}),(t?.runId||n)&&o.jsxs("div",{className:"mt-2 text-ui-sm text-neutral3",children:["Run ID: ",t?.runId??n]})]}),u&&p>0&&!["error"].includes(s)&&o.jsx("div",{className:"max-w-[30rem] w-full mx-auto px-6",children:o.jsx(oBn,{steps:m})}),l&&s==="error"&&o.jsxs("div",{className:K("rounded-lg text-neutral5 p-6 flex items-center gap-3 text-ui-md bg-red-500/10","[&>svg]:w-6 [&>svg]:h-6 [&>svg]:opacity-70 [&>svg]:text-red-500"),children:[o.jsx(don,{}),l||"Something went wrong"]}),u&&o.jsx(iBn,{steps:m,currentStep:i,className:"pb-4"}),!u&&s==="initializing"&&o.jsxs("div",{className:"text-center text-sm text-neutral3 grid gap-4 justify-items-center",children:[o.jsx(Ht,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function fXr({name:e,installedEntities:t}){return o.jsxs(DZ,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(Bat,{}),o.jsx("h2",{className:"text-header-md",children:"Done!"}),o.jsxs("p",{className:"text-ui-md text-center text-neutral3 ",children:["The ",o.jsx("b",{className:"text-neutral4",children:e})," template has been successfully installed.",t&&t.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("br",{})," Installed entities are listed below."]})]}),t&&t.length>0&&o.jsx(E0e,{data:t})]})}function pXr(){const{templateSlug:e}=vr(),[t,n]=zi(),[r,s]=y.useState(""),[a,i]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState({}),[f,p]=y.useState([]),[h,m]=y.useState(null),[g,v]=y.useState(!1),[b,w]=y.useState(""),[S,O]=y.useState(!1),[_,C]=y.useState(!1),[j,E]=y.useState([]),{data:N,isLoading:I}=qyr({repoOrSlug:e,owner:"mastra-ai"}),$=oXr?.includes("beta")??!1?"beta":"main",{data:B,isLoading:D}=Vyr({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:V,isLoading:H}=Hyr(),{mutateAsync:L,isPending:F}=Zyr(),{mutateAsync:z}=Wyr(),{streamInstall:M,streamResult:G,isStreaming:U}=Gyr(V),{observeInstall:R,streamResult:q,isStreaming:W}=Yyr(V);y.useEffect(()=>{const te=t.get("runId");te&&!g&&!h&&!U&&!W&&(console.info("🔄 Checking completed run after hot reload:",{runId:te}),w(te),z({runId:te}).then(le=>{const fe=le.snapshot;if(fe?.status==="success"&&fe?.result?.success)v(!0);else if(fe?.result?.success===!1)if(fe?.result?.validationResults&&!fe?.result?.validationResults?.valid&&fe?.result?.validationResults?.remainingErrors>0){const{remainingErrors:he,errors:be}=fe.result.validationResults,we=`Template installation completed but ${he} validation issue${he>1?"s":""} remain unresolved.`;m(we),E(be||[])}else{const he=fe?.result?.message||fe?.result?.error||"Template installation failed";m(typeof he=="string"?he:String(he))}}).catch(le=>{console.error("❌ Failed to fetch run details:",le),m("Failed to retrieve installation status after reload")}))},[t,g,h,U,W,z]),y.useEffect(()=>{const te=t.get("runId"),le=t.get("resume"),fe=t.get("provider");if(te&&le==="true"&&fe&&!U&&!W&&!S&&!_&&V){w(te),O(!0);try{z({runId:te}).then(se=>{if(se.snapshot?.status==="running")return R.mutateAsync({runId:te})}).then(()=>{n(se=>{const he=new URLSearchParams(se);return he.delete("resume"),he})}).catch(se=>{console.error("❌ Failed to resume template installation:",se),se.message?.includes("404")||se.message?.includes("not found")?m("Template installation run not found. It may have expired or been completed."):m("Failed to resume template installation. Please try again.")})}catch(se){console.error("❌ Auto-resume failed with error:",se),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,U,W,S,_,V,z,R,n]);const X=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"google",label:"Google"}],ne=[{key:"tools",label:"Tools",value:N?.tools?.length?N.tools.map(te=>te).join(", "):"n/a",icon:o.jsx(cf,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(te=>te).join(", "):"n/a",icon:o.jsx(Xo,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(te=>te).join(", "):"n/a",icon:o.jsx(nU,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Y0,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(XO,{})}],ee=[{...ne[0]},{...ne[1]},{...ne[2]}].filter(te=>te.value!=="n/a");y.useEffect(()=>{B&&d(B)},[B]),y.useEffect(()=>{const te=G||q;te?.phase==="error"&&te?.error&&m(typeof te.error=="string"?te.error:String(te.error))},[G?.phase,G?.error,q?.phase,q?.error]);const J=te=>{s(te)},ie=async te=>(i(te.provider),c(te.modelId),{message:"Model updated successfully"}),ue=async()=>{const te=Object.entries(u).reduce((le,[fe,se])=>(se===""&&le.push(fe),le),[]);if(te.length>0){p(te);return}if(N){m(null),v(!1),w(""),C(!0);try{const fe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:se}=await L({});w(se),n(he=>{const be=new URLSearchParams(he);return be.set("runId",se),be.set("resume","true"),be.set("provider",r||"openai"),be}),await M.mutateAsync({inputData:fe,selectedModel:{provider:a,modelId:l},runId:se})}catch(le){C(!1),m(le?.message||"Template installation failed"),console.error("Template installation failed",le)}}},Y=te=>{const{name:le,value:fe}=te.target;fe.trim()===""?p(se=>[...se,le]):p(se=>se.filter(he=>he!==le)),d(se=>({...se,[le]:fe}))};return o.jsx(ms,{children:o.jsx("div",{className:K("w-full lg:px-12 h-full overflow-y-scroll"),children:o.jsxs("div",{className:"p-6 w-full max-w-[80rem] mx-auto grid gap-y-4",children:[o.jsx(uXr,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:ne,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(U||W)&&o.jsx(dXr,{name:N.title,streamResult:W?q:G,runId:b,workflowInfo:V}),g&&o.jsx(fXr,{name:N.title,installedEntities:ee,linkComponent:ui}),h&&o.jsx(lXr,{errorMsg:h,validationErrors:j.length>0?j:G?.validationResults?.errors||q?.validationResults?.errors}),!U&&!W&&!g&&!h&&o.jsx(cXr,{providerOptions:X,selectedProvider:r,onProviderChange:J,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ue,handleVariableChange:Y,isLoadingEnvVars:D||H,isInstalling:F,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ie})]})]})})})}const hXr=()=>{const{toolId:e,agentId:t}=vr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(lVr,{toolId:e,agentId:t})})},mXr=()=>{const{toolId:e}=vr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(wYr,{toolId:e})})};function gXr(){const{traceId:e}=vr(),[t,n]=zi(),r=Ks(),s=t.get("spanId")||void 0,a=t.get("tab"),i=a==="scoring"?"scoring":a==="feedback"?"feedback":"details",l=t.get("scoreId")||void 0,[c,u]=y.useState(s??null),[d,f]=y.useState(),[p,h]=y.useState(i),[m,g]=y.useState(0),[v,b]=y.useState(!1),{data:w,isLoading:S,error:O}=ISe(e),_=y.useMemo(()=>w?.spans??[],[w?.spans]),C=y.useMemo(()=>_.find(ie=>ie.parentSpanId==null),[_]),{data:j,isLoading:E}=iD(e,c??"");y.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=Up(),{data:P,isLoading:$}=G4t({traceId:e,spanId:c??void 0,page:m}),[B,D]=y.useState(0);y.useEffect(()=>D(0),[e,c]);const{data:V,isLoading:H}=I5t({traceId:e,page:B});y.useEffect(()=>{if(l&&P?.scores&&!d){const ie=P.scores.find(ue=>ue.id===l);ie&&f(ie)}},[l,P?.scores,d]);const L=y.useCallback(ie=>{const ue=new URLSearchParams(t);for(const[Y,te]of Object.entries(ie))te===null||te===""?ue.delete(Y):ue.set(Y,te);n(ue,{replace:!0})},[t,n]),F=y.useCallback(ie=>{const ue=ie??null,Y=ue===c;u(ue),Y||(f(void 0),h("details"),L({spanId:ue,tab:null,scoreId:null}))},[c,L]),z=y.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),M=y.useCallback(ie=>{u(ie),f(void 0),h("details"),L({spanId:ie,tab:null,scoreId:null})},[L]),{handlePreviousSpan:G,handleNextSpan:U}=MSe(_,c,M),R=y.useCallback(ie=>{const ue=ie;h(ue),f(void 0),L({tab:ue==="details"?null:ue,scoreId:null})},[L]),q=y.useCallback(ie=>{f(ie),L({scoreId:ie.id})},[L]),W=y.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=y.useCallback(()=>{r("/observability")},[r]),ne=y.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),L({spanId:C.spanId,tab:"scoring",scoreId:null})):L({tab:"scoring"})},[C,c,L]),ee=C?o.jsx(Sy,{owner:"trace-detail",children:o.jsxs($r,{children:[o.jsxs(pe,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:ne,children:[o.jsx(uan,{}),"Evaluate"]}),o.jsxs(pe,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(ad,{}),"Save"]})]})}):null,J=C?o.jsx(Dt.Row,{children:o.jsx(Dt.Column,{children:o.jsx(kCt,{rootSpan:C,numOfCol:3})})}):null;return O?o.jsxs(Dt,{height:"full",children:[ee,J&&o.jsx(Dt.TopArea,{children:J}),o.jsx(Dt.MainArea,{isCentered:!0,children:o.jsx(CCt,{error:O,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Dt,{children:[ee,J&&o.jsx(Dt.TopArea,{children:J}),o.jsx(C5t,{rootSpanId:C?.spanId,traceId:e,isOpen:v,onClose:()=>b(!1)}),o.jsxs("div",{className:K("grid h-full min-h-0 gap-4 overflow-hidden items-start mt-4",c?"grid-cols-[2fr_3fr]":"grid-cols-[1fr]"),children:[o.jsx(TSe,{traceId:e,spans:_,isLoading:S,onClose:X,onSpanSelect:F,onEvaluateTrace:ne,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!S&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(NSe,{traceId:e,spanId:c,span:j?.span,isLoading:E,onClose:z,onPrevious:G,onNext:U,activeTab:p,onTabChange:R,feedbackTabBadge:V?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(j5t,{feedbackData:V,onPageChange:D,isLoadingFeedbackData:H}),scoringTabBadge:P?.pagination?.total??void 0,scoringTabSlot:({span:ie,traceId:ue,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(N5t,{traceId:ue,isTopLevelSpan:!ie.parentSpanId,spanId:Y,entityType:ie.attributes?.agentId||ie.entityType===Ps.AGENT?"Agent":ie.attributes?.workflowId||ie.entityType===Ps.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(T5t,{scoresData:P,onPageChange:g,isLoadingScoresData:$,onScoreSelect:q})]})}),d&&o.jsx(iEe,{score:d,onClose:W})]})]})]})}function vXr(){const{data:e,isLoading:t,error:n}=Ey(),[r,s]=y.useState("");return n&&cs(n)?o.jsx(or,{children:o.jsx(Ms,{})}):n&&ds(n)?o.jsx(or,{children:o.jsx(ks,{resource:"workflows"})}):n?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(or,{children:o.jsx(ZDr,{})}):o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(xf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(pe,{as:ui,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(RM,{}),"Schedules"]})]})}),o.jsx(HDr,{workflows:e||{},isLoading:t,search:r})]})}const yXr={active:"bg-accent1",paused:"bg-accent3"},bXr={active:"text-accent1",paused:"text-accent3"},U5t=({status:e})=>o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${yXr[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${bXr[e]}`,children:e})]}),Sj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),j2=e=>{if(!e||e<=0)return"—";const t=e-Date.now(),n=Math.abs(t),r=Math.floor(n/1e3);if(r<60)return t>=0?`in ${r}s`:`${r}s ago`;const s=Math.floor(r/60);if(s<60)return t>=0?`in ${s}m`:`${s}m ago`;const a=Math.floor(s/60);if(a<24)return t>=0?`in ${a}h`:`${a}h ago`;const i=Math.floor(a/24);return t>=0?`in ${i}d`:`${i}d ago`};function q5t({status:e}){const{icon:t,color:n}=xXr(e);return o.jsxs("span",{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm ${n}`,children:[o.jsx("span",{className:"inline-flex shrink-0 items-center","aria-hidden":!0,children:t}),o.jsx("span",{children:e})]})}function xXr(e){switch(e){case"success":return{icon:o.jsx(da,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(ys,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Ht,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(xve,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(ff,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(YT,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const lWe="auto auto auto auto 1fr";function wXr(e){if(e===void 0)return"—";if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${t}m ${n}s`}function SXr(e){const t=Math.abs(e),n=e<0?"-":"";return t<1e3?`${n}${t}ms`:t<6e4?`${n}${(t/1e3).toFixed(1)}s`:t<36e5?`${n}${(t/6e4).toFixed(1)}m`:`${n}${(t/36e5).toFixed(1)}h`}const kXr=3e4,OXr=5*6e4;function _Xr({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=vn();return t?o.jsx(Wo,{columns:lWe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(xe,{columns:lWe,className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Run"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Started"}),o.jsx(xe.TopCell,{children:"Duration"}),o.jsx(xe.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=SXr(u),f=`Scheduled ${Sj(c.scheduledFireAt)} — published ${Sj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>kXr&&m<=OXr,v=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),w=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),S=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",children:w}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2",children:[p?o.jsxs("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-accent2",children:[o.jsx(gp,{size:14}),"publish failed"]}):c.run?o.jsx(q5t,{status:c.run.status}):o.jsx("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-neutral3",children:"pending"}),h?o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(gp,{size:14})})}),o.jsx(Hn,{children:h})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:j2(c.actualFireAt)}),g?o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(gp,{size:14})})}),o.jsxs(Hn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:c.run?o.jsx("span",{children:wXr(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(xe.Cell,{height:"compact",children:" "})]});return b?o.jsx(xe.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:S},v):o.jsx(xe.RowStatic,{children:S},v)}),o.jsx(xe.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const CXr=e=>{const t=He();return xt({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},cWe=25,EXr=e=>{const t=He(),{inView:n,setRef:r}=C_(),s=I1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:cWe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<cWe))return u.triggers[u.triggers.length-1].actualFireAt},refetchInterval:u=>(u.state.data?.pages.flatMap(p=>p.triggers)??[]).some(p=>p.run?p.run.status==="pending"||p.run.status==="running"||p.run.status==="waiting":p.outcome==="published")?5e3:!1}),a=s.data?.pages.flatMap(u=>u?.triggers??[])??[],{hasNextPage:i,isFetchingNextPage:l,fetchNextPage:c}=s;return y.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},jXr=e=>{const t=He(),n=qr();return An({mutationFn:async r=>{if(!e)throw new Error("scheduleId is required");return r==="pause"?t.pauseSchedule(e):t.resumeSchedule(e)},onSuccess:(r,s)=>{n.invalidateQueries({queryKey:["schedule",e]}),n.invalidateQueries({queryKey:["schedules"]}),Ue.success(s==="pause"?"Schedule paused":"Schedule resumed")},onError:r=>{Ue.error(r.message)}})};function b8({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 uppercase tracking-wide",children:e}),o.jsx("div",{className:"text-ui-md",children:t})]})}function TXr(){const{scheduleId:e}=vr(),{paths:t}=vn(),{data:n,error:r}=CXr(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=EXr(e),d=jXr(e);if(r&&cs(r))return o.jsx(or,{children:o.jsx(Ms,{})});if(r&&ds(r))return o.jsx(or,{children:o.jsx(ks,{resource:"schedules"})});if(r)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load schedule",message:r.message})});const f=n?.target.type==="workflow"?n.target.workflowId:void 0;return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx(Dt.Row,{className:"justify-end",children:o.jsxs(Dt.Column,{className:"flex justify-end gap-2",children:[o.jsxs(pe,{as:ui,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(gc,{}),"Back to schedules"]}),f?o.jsx(pe,{as:ui,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(pe,{onClick:()=>d.mutate(n.status==="active"?"pause":"resume"),disabled:d.isPending,"data-testid":"schedule-toggle-button",children:n.status==="active"?o.jsxs(o.Fragment,{children:[o.jsx(qat,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Lw,{}),"Resume"]})}):null]})})}),n?o.jsxs("div",{className:"grid gap-6 h-full overflow-hidden grid-cols-[minmax(0,20rem)_1fr]",children:[o.jsxs("div",{className:"flex flex-col gap-4 border border-border1 rounded-md p-4 h-fit",children:[o.jsx(b8,{label:"Workflow",children:f?o.jsx(ui,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(b8,{label:"Cron",children:[o.jsx("code",{className:"font-mono text-ui-md",children:n.cron}),n.timezone?o.jsx("span",{className:"text-neutral4 ml-2 text-ui-sm",children:n.timezone}):null]}),o.jsx(b8,{label:"Status",children:o.jsx(U5t,{status:n.status})}),o.jsx(b8,{label:"Next fire",children:o.jsx("span",{title:Sj(n.nextFireAt),children:j2(n.nextFireAt)})})]}),o.jsxs("div",{className:"overflow-y-auto","data-testid":"schedule-triggers-panel",children:[o.jsx(ge,{variant:"ui-md",className:"mb-3",children:"Trigger history"}),i?o.jsx(Di,{title:"Failed to load trigger history",message:i.message}):o.jsx(_Xr,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const uWe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function NXr({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=vn(),a=y.useMemo(()=>{const i=n.toLowerCase();return i?e.filter(l=>l.id.toLowerCase().includes(i)||l.target.workflowId.toLowerCase().includes(i)):e},[e,n]);return t?o.jsx(Wo,{columns:uWe}):o.jsxs(xe,{columns:uWe,variant:"striped",className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Workflow"}),o.jsx(xe.TopCell,{children:"Schedule ID"}),o.jsx(xe.TopCell,{children:"Cron"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Next fire"}),o.jsx(xe.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(xe.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(xe.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(xe.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(xe.NameCell,{children:i.target.workflowId}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:o.jsx("span",{className:"block truncate font-mono text-ui-smd text-neutral3",title:i.id,children:i.id})}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("code",{className:"font-mono text-ui-sm",children:i.cron}),i.timezone?o.jsx("span",{className:"text-neutral4 text-ui-xs",children:i.timezone}):null]})}),o.jsx(xe.Cell,{height:"compact",children:o.jsx(U5t,{status:i.status})}),o.jsx(xe.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:Sj(i.nextFireAt),children:j2(i.nextFireAt)})}),o.jsx(xe.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx(q5t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:Sj(i.lastFireAt),children:i.lastFireAt?j2(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:Sj(i.lastFireAt),children:j2(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function IXr({workflowId:e}={}){const{data:t,isLoading:n,error:r}=zSe(e?{workflowId:e}:{}),[s,a]=y.useState("");return r?o.jsx(Di,{title:"Failed to load schedules",message:r.message}):o.jsxs("div",{className:"grid grid-rows-[auto_1fr] gap-4 h-full overflow-hidden",children:[o.jsx("div",{className:"max-w-120",children:o.jsx(xf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(NXr,{schedules:t??[],isLoading:n,search:s})})]})}function AXr(){const[e]=zi(),t=e.get("workflowId")??void 0,{error:n}=zSe(t?{workflowId:t}:{});return n&&cs(n)?o.jsx(or,{children:o.jsx(Ms,{})}):n&&ds(n)?o.jsx(or,{children:o.jsx(ks,{resource:"schedules"})}):o.jsx(Dt,{children:o.jsx("div",{className:"h-full",children:o.jsx(IXr,{workflowId:t})})})}const dWe=()=>{const{workflowId:e}=vr(),{data:t,isLoading:n,error:r}=lD(e);return r&&cs(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})}):r&&ds(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"workflows"})}):o.jsx(zRt,{workflowId:e,workflow:t??void 0,isLoading:n})};function RXr(e,t){if(e==null)return{};var n,r,s=tpt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function mge(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PXr(e){if(Array.isArray(e))return mge(e)}function $Xr(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function MXr(e,t){if(e){if(typeof e=="string")return mge(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mge(e,t):void 0}}function DXr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
767
|
+
]`})]})]})}function HQr({errors:e,maxErrors:t=5}){if(e.length===0)return null;const n=e.slice(0,t),r=e.length-t;return o.jsxs("div",{className:"bg-accent2/10 border border-accent2/30 rounded-md p-3",children:[o.jsxs("div",{className:"flex items-center gap-2 text-accent2 mb-2",children:[o.jsx(Ge,{children:o.jsx(gp,{className:"w-4 h-4"})}),o.jsxs("span",{className:"font-medium text-sm",children:[e.length," validation error",e.length!==1?"s":""]})]}),o.jsx("ul",{className:"text-sm text-accent2/80 space-y-1",children:n.map((s,a)=>o.jsxs("li",{className:"flex gap-2",children:[o.jsx("span",{className:"shrink-0",children:"•"}),o.jsx("span",{children:s.message})]},a))}),r>0&&o.jsxs("div",{className:"text-xs text-accent2/60 mt-2",children:["+",r," more error",r!==1?"s":""]})]})}function ZQr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("upload"),[i,l]=y.useState(null),[c,u]=y.useState({current:0,total:0}),[d,f]=y.useState(null),[p,h]=y.useState(!1),{parseFile:m,isParsing:g,error:v}=UWr(),{batchInsertItems:b}=Li(),w=y.useCallback(async I=>{try{const P=await m(I);l(P),a("preview")}catch{}},[m]),S=y.useCallback(async()=>{if(!i||i.items.length===0)return;a("importing"),h(!0);const{items:I}=i;u({current:0,total:I.length});try{await b.mutateAsync({datasetId:e,items:I.map(P=>({input:P.input,groundTruth:P.groundTruth,metadata:P.metadata}))}),f({success:I.length,errors:0})}catch{f({success:0,errors:I.length})}u({current:I.length,total:I.length}),h(!1),a("complete")},[i,b,e]),O=y.useCallback(()=>{n(!1),r?.(),d&&d.success>0&&Ue.success(`Imported ${d.success} item${d.success!==1?"s":""}`),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150)},[n,r,d]),_=y.useCallback(()=>{p||(n(!1),setTimeout(()=>{a("upload"),l(null),u({current:0,total:0}),f(null)},150))},[p,n]),C=i&&i.items.length>0&&i.errors.length===0,j=()=>{switch(s){case"upload":return o.jsx(VQr,{onFileSelect:w,isParsing:g,error:v?.message});case"preview":return i?o.jsx("div",{className:"flex flex-col gap-4",children:i.errors.length>0?o.jsxs(o.Fragment,{children:[o.jsx(HQr,{errors:i.errors}),o.jsx("div",{className:"text-sm text-neutral4",children:"Please fix the errors in your JSON file and try again."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"text-sm text-neutral4",children:["Found ",i.items.length," valid item",i.items.length!==1?"s":""," to import."]}),o.jsx(qQr,{items:i.items,maxRows:5})]})}):null;case"importing":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx(Ht,{}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Importing items..."}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[c.current," of ",c.total]})]})]});case"complete":return o.jsxs("div",{className:"flex flex-col items-center gap-4 py-8",children:[o.jsx("div",{className:"text-4xl",children:d&&d.errors===0?"✓":"⚠"}),o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-lg font-medium text-neutral1",children:"Import Complete"}),o.jsxs("div",{className:"text-sm text-neutral4 mt-1",children:[d?.success??0," item",d?.success!==1?"s":""," imported",d&&d.errors>0&&o.jsxs("span",{className:"text-accent2",children:[" ","(",d.errors," error",d.errors!==1?"s":"",")"]})]})]})]})}},E=()=>{switch(s){case"upload":return o.jsx(pe,{onClick:_,children:"Cancel"});case"preview":return o.jsxs(o.Fragment,{children:[o.jsx(pe,{onClick:()=>a("upload"),children:"Back"}),o.jsxs(pe,{variant:"primary",onClick:S,disabled:!C,children:["Import ",i?.items.length??0," Item",i?.items.length!==1?"s":""]})]});case"importing":return null;case"complete":return o.jsx(pe,{variant:"primary",onClick:O,children:"Done"})}},N={upload:"Import JSON",preview:"Preview Data",importing:"Importing",complete:"Import Complete"};return o.jsx(Nr,{open:t,onOpenChange:_,children:o.jsxs(_r,{className:"max-w-2xl max-h-[90vh]",children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:N[s]}),o.jsx(Qs,{children:"Import dataset items from a JSON file."})]}),o.jsx(Lr,{className:"min-h-[200px] max-h-[50vh] overflow-y-auto",children:j()}),o.jsx(uc,{className:"px-6 pt-4 flex justify-end gap-2",children:E()})]})})}const xEe=e=>{const t=He(),{data:n}=xM(e),r=n?.experiments;return xt({queryKey:["dataset-review-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="needs-review").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})},WQr=e=>{const t=He(),{data:n}=xM(e),r=n?.experiments;return xt({queryKey:["dataset-completed-items",e,r?.map(s=>s.id)],queryFn:async()=>!r||r.length===0?[]:(await Promise.all(r.map(async a=>{if(!a.datasetId)return[];try{const{results:i}=await t.listDatasetExperimentResults(a.datasetId,a.id);return i.filter(l=>l.status==="complete").map(l=>({id:l.id,input:l.input,output:l.output,error:l.error,itemId:l.itemId,experimentId:l.experimentId,datasetId:a.datasetId??void 0,traceId:l.traceId??void 0,scores:l.scores?Object.fromEntries(l.scores.map(c=>[c.scorerId,c.score??0])):{},tags:l.tags??[],comment:""}))}catch{return[]}}))).flat(),enabled:!!e&&!!r&&r.length>0,refetchOnWindowFocus:!1})};function QQr(e,t){if(typeof e=="string")return e.length>t?e.slice(0,t)+"...":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t)+"...":n}catch{return String(e)}}function $5t({datasetId:e,experimentId:t,featuredItemId:n}){const r=He(),{data:s}=Dx(e),{data:a,isLoading:i}=xEe(e),{data:l,isLoading:c}=WQr(e),u=y.useMemo(()=>t?(a??[]).filter(Oe=>Oe.experimentId===t):a,[a,t]),d=y.useMemo(()=>t?(l??[]).filter(Oe=>Oe.experimentId===t):l,[l,t]),{updateExperimentResult:f}=Li(),[p,h]=y.useState(n??null);y.useEffect(()=>{n!==void 0&&h(n)},[n]);const[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(""),[I,P]=y.useState(""),[$,B]=y.useState(""),[D,V]=y.useState([]),[H,L]=y.useState(!1),[F,z]=y.useState(null),M=y.useMemo(()=>F??u??[],[F,u]);y.useEffect(()=>{z(null)},[e,t]),y.useEffect(()=>{u&&F===null&&z(u)},[u,F]);const G=y.useMemo(()=>{const Oe=new Set;if(s?.tags)for(const _e of s.tags)Oe.add(_e);for(const _e of M)for(const Ce of _e.tags)Oe.add(Ce);return[...Oe].sort()},[s,M]),U=y.useCallback(Oe=>{!s||!e||(s.tags??[]).includes(Oe)},[s,e]),R=y.useMemo(()=>m?m==="__untagged__"?M.filter(Oe=>Oe.tags.length===0):M.filter(Oe=>Oe.tags.includes(m)):M,[M,m]),q=y.useMemo(()=>{const Oe=new Map;for(const _e of M)for(const Ce of _e.tags)Oe.set(Ce,(Oe.get(Ce)??0)+1);return[...Oe.entries()].sort((_e,Ce)=>Ce[1]-_e[1])},[M]),W=y.useMemo(()=>M.filter(Oe=>Oe.tags.length===0).length,[M]),X=y.useMemo(()=>{let Oe=0;return m&&Oe++,w&&Oe++,Oe},[m,w]),ne=y.useCallback((Oe,_e)=>{z(Ee=>(Ee??[]).map($e=>$e.id===Oe?{...$e,tags:_e}:$e));const Ce=M.find(Ee=>Ee.id===Oe);Ce?.experimentId&&Ce?.datasetId&&f.mutate({datasetId:Ce.datasetId,experimentId:Ce.experimentId,resultId:Ce.id,tags:_e})},[M,f]),ee=y.useCallback((Oe,_e)=>{const Ce=M.find(Ee=>Ee.id===Oe);Ce?.traceId&&_e!==void 0&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"rating",value:_e==="positive"?1:-1,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),z(Ee=>(Ee??[]).map($e=>$e.id===Oe?{...$e,rating:_e}:$e))},[M,r]),J=y.useCallback((Oe,_e)=>{const Ce=M.find(Ee=>Ee.id===Oe);Ce?.traceId&&r.createFeedback({feedback:{traceId:Ce.traceId,source:"studio",feedbackSource:"studio",feedbackType:"comment",value:_e,comment:_e,experimentId:Ce.experimentId??void 0,sourceId:Ce.id}}).catch(()=>{}),z(Ee=>(Ee??[]).map($e=>$e.id===Oe?{...$e,comment:_e}:$e))},[M,r]),ie=y.useCallback(Oe=>{const _e=M.find(Ce=>Ce.id===Oe);z(Ce=>(Ce??[]).filter(Ee=>Ee.id!==Oe)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(Oe),Ee}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:null})},[M,f,p]),ue=y.useCallback(Oe=>{const _e=M.find(Ce=>Ce.id===Oe);z(Ce=>(Ce??[]).filter(Ee=>Ee.id!==Oe)),b(Ce=>{const Ee=new Set(Ce);return Ee.delete(Oe),Ee}),p===Oe&&h(null),_e?.experimentId&&_e?.datasetId&&f.mutate({datasetId:_e.datasetId,experimentId:_e.experimentId,resultId:_e.id,status:"complete"})},[M,f,p]),Y=y.useMemo(()=>{const Oe=w?d??[]:R;return!w||!m?Oe:m==="__untagged__"?Oe.filter(_e=>_e.tags.length===0):Oe.filter(_e=>_e.tags.includes(m))},[w,d,R,m]),te=w?c:!1,le=y.useMemo(()=>new Set(Y.map(Oe=>Oe.id)),[Y]),fe=y.useMemo(()=>[...v].filter(Oe=>le.has(Oe)).length,[v,le]),se=Y.length>0&&fe===Y.length,he=fe>0&&!se,be=y.useCallback(Oe=>{b(_e=>{const Ce=new Set(_e);return Ce.has(Oe)?Ce.delete(Oe):Ce.add(Oe),Ce})},[]),we=y.useCallback(()=>{b(se?new Set:new Set(Y.map(Oe=>Oe.id)))},[se,Y]),Ie=y.useCallback(Oe=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&!Ce.tags.includes(Oe)&&ne(_e,[...Ce.tags,Oe])}},[M,v,ne]),ke=y.useCallback(Oe=>{for(const _e of v){const Ce=M.find(Ee=>Ee.id===_e);Ce&&Ce.tags.includes(Oe)&&ne(_e,Ce.tags.filter(Ee=>Ee!==Oe))}},[M,v,ne]),je=y.useCallback(()=>{for(const Oe of v)ue(Oe);b(new Set)},[v,ue]),Fe=y.useCallback(()=>{for(const Oe of v)ie(Oe);b(new Set)},[v,ie]),ce=y.useCallback(()=>{N(""),j(!0)},[]),ae=y.useCallback(async()=>{if(!(!I||!$)){_(!0),j(!1);try{const Oe=M.filter(Ce=>v.has(Ce.id));if(Oe.length===0){_(!1);return}const _e=await r.clusterFailures({modelId:`${I}/${$}`,items:Oe.map(Ce=>({id:Ce.id,input:Ce.input,output:Ce.output??void 0,error:typeof Ce.error=="string"?Ce.error:Ce.error?String(Ce.error):void 0,scores:Ce.scores,existingTags:Ce.tags.length>0?Ce.tags:void 0})),availableTags:G.length>0?G:void 0,prompt:E||void 0});_e.proposedTags&&_e.proposedTags.length>0&&(V(_e.proposedTags.map(Ce=>({...Ce,accepted:!0}))),L(!0))}catch(Oe){console.error("Analysis failed:",Oe)}finally{_(!1)}}},[I,$,M,v,r,G,E]),re=y.useCallback(()=>{for(const Oe of D){if(!Oe.accepted)continue;const _e=M.find(Ce=>Ce.id===Oe.itemId);if(_e){const Ce=[...new Set([..._e.tags,...Oe.tags])];ne(_e.id,Ce)}}L(!1)},[D,M,ne]),me=y.useCallback(Oe=>{h(_e=>_e===Oe?null:Oe)},[]),ye=y.useMemo(()=>p?Y.find(Oe=>Oe.id===p)??null:null,[p,Y]),Te=p?Y.findIndex(Oe=>Oe.id===p):-1,Re=Te>0?()=>h(Y[Te-1].id):void 0,Qe=Te>=0&&Te<Y.length-1?()=>h(Y[Te+1].id):void 0,Ze="auto minmax(15rem,1fr) 10rem 8rem 6rem 6rem";return i?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ht,{className:"w-6 h-6"})}):o.jsxs("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:[o.jsx(Nr,{open:C,onOpenChange:j,children:o.jsxs(_r,{children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:"Analyze Items"}),o.jsx(Qs,{children:"Use an LLM to automatically suggest tags for the selected items."})]}),o.jsxs("div",{className:"space-y-4 py-2",children:[o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx(Pt,{className:"text-xs mb-1 block",children:"Provider"}),o.jsx(_y,{value:I,onValueChange:P})]}),o.jsxs("div",{children:[o.jsx(Pt,{className:"text-xs mb-1 block",children:"Model"}),o.jsx(Cy,{llmId:I,value:$,onValueChange:B})]})]}),o.jsxs(ge,{variant:"ui-xs",className:"text-neutral3",children:[v.size," item",v.size!==1?"s":""," will be analyzed"]}),o.jsxs("div",{children:[o.jsx(Pt,{className:"text-xs",children:"Instructions (optional)"}),o.jsx(Ul,{value:E,onChange:Oe=>N(Oe.target.value),placeholder:"E.g., Focus on safety issues and factual errors...",rows:3,className:"text-xs mt-1"})]})]}),o.jsxs(uc,{children:[o.jsx(pe,{variant:"outline",onClick:()=>j(!1),children:"Cancel"}),o.jsxs(pe,{onClick:ae,disabled:!I||!$||O,children:[O?o.jsx(Ht,{className:"w-4 h-4 mr-1"}):null,"Analyze"]})]})]})}),o.jsx(Nr,{open:H,onOpenChange:L,children:o.jsxs(_r,{className:"max-w-2xl max-h-[80vh] overflow-y-auto",children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:"Review Proposed Tags"}),o.jsxs(Qs,{children:[D.filter(Oe=>Oe.accepted).length," of ",D.length," proposals selected"]})]}),o.jsx("div",{className:"space-y-3 py-2",children:D.map((Oe,_e)=>{const Ce=M.find(Ee=>Ee.id===Oe.itemId);return o.jsx("div",{className:K("p-3 border rounded-lg",!Oe.accepted&&"opacity-50"),children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Go,{checked:Oe.accepted,onCheckedChange:Ee=>V($e=>$e.map((ze,Ke)=>Ke===_e?{...ze,accepted:!!Ee}:ze))}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate block",children:Ce?typeof Ce.input=="string"?Ce.input.slice(0,100):JSON.stringify(Ce.input).slice(0,100):Oe.itemId}),o.jsx("div",{className:"flex gap-1 flex-wrap mt-1.5",children:Oe.tags.map((Ee,$e)=>o.jsx(O5t,{tag:Ee,onRename:ze=>V(Ke=>Ke.map((Ye,Rt)=>Rt===_e?{...Ye,tags:Ye.tags.map((Ct,en)=>en===$e?ze:Ct)}:Ye)),onRemove:()=>V(ze=>ze.map((Ke,Ye)=>Ye===_e?{...Ke,tags:Ke.tags.filter((Rt,Ct)=>Ct!==$e)}:Ke))},`${Ee}-${$e}`))}),Oe.reason&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-1 block italic",children:Oe.reason})]})]})},Oe.itemId)})}),o.jsxs(uc,{children:[o.jsx(pe,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),o.jsxs(pe,{onClick:re,disabled:D.filter(Oe=>Oe.accepted).length===0,children:["Accept ",D.filter(Oe=>Oe.accepted).length," proposals"]})]})]})}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",ye&&"grid-cols-[1fr_1fr]"),children:[o.jsxs("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between w-full flex-wrap gap-4 gap-x-6",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(pe,{variant:"outline",size:"md",children:[o.jsx(Aat,{}),"Filter",X>0&&o.jsx("span",{className:K("ml-0.5 inline-flex items-center justify-center rounded-full bg-accent1/50 text-neutral5 text-ui-sm w-5 h-5"),children:X})]})}),o.jsxs(ft.Content,{align:"start",className:K("min-w-48"),children:[o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Status",w&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!w,onCheckedChange:()=>{S(!1),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Review Queue"}),o.jsx(ft.CheckboxItem,{checked:w,onCheckedChange:()=>{S(!0),h(null)},onSelect:Oe=>Oe.preventDefault(),children:"Completed"})]})]}),o.jsxs(ft.Sub,{children:[o.jsxs(ft.SubTrigger,{children:["Tags",m&&o.jsx("span",{className:K("ml-auto text-ui-sm text-accent1"),children:"1"})]}),o.jsxs(ft.SubContent,{children:[o.jsx(ft.CheckboxItem,{checked:!m,onCheckedChange:()=>g(null),onSelect:Oe=>Oe.preventDefault(),children:"All"}),W>0&&o.jsx(ft.CheckboxItem,{checked:m==="__untagged__",onCheckedChange:()=>g(m==="__untagged__"?null:"__untagged__"),onSelect:Oe=>Oe.preventDefault(),children:"Untagged"}),q.length>0&&o.jsx(ft.Separator,{}),q.map(([Oe])=>o.jsx(ft.CheckboxItem,{checked:m===Oe,onCheckedChange:()=>g(m===Oe?null:Oe),onSelect:_e=>_e.preventDefault(),children:Oe},Oe))]})]}),X>0&&o.jsxs(o.Fragment,{children:[o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:()=>{g(null),S(!1),h(null)},children:[o.jsx(ys,{}),"Clear all filters"]})]})]})]}),X>0&&o.jsxs(pe,{variant:"outline",size:"md",onClick:()=>{g(null),S(!1),h(null)},children:[o.jsx(ys,{}),"Reset"]})]}),!w&&v.size>0&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(k5t,{selectedCount:v.size,vocabulary:G,onApplyTag:Ie,onRemoveTag:ke,onNewTag:Oe=>Ie(Oe)}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsxs(pe,{disabled:O,children:[O?o.jsx(Ht,{className:"w-4 h-4"}):o.jsx(Ge,{size:"sm",children:o.jsx(ea,{})}),"Actions"]})}),o.jsxs(ft.Content,{align:"end",children:[o.jsxs(ft.Item,{onSelect:je,children:[o.jsx(Ge,{size:"sm",children:o.jsx(Qk,{})}),"Complete"]}),o.jsxs(ft.Item,{onSelect:Fe,children:[o.jsx(Ge,{size:"sm",children:o.jsx(Zc,{})}),"Remove"]}),o.jsx(ft.Separator,{}),o.jsxs(ft.Item,{onSelect:ce,children:[o.jsx(Ge,{size:"sm",children:o.jsx(ng,{})}),"Analyze"]})]})]})]})]}),te?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Ht,{className:"w-6 h-6"})}):Y.length===0?o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsxs("div",{className:"text-center px-8",children:[o.jsx(ge,{variant:"ui-sm",className:"text-neutral3 block",children:w?"No completed reviews yet":"No items to review"}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 mt-2 block",children:w?"Items marked as complete will appear here for auditing.":"When experiment results are flagged for review, they will appear here."})]})}):o.jsxs(xe,{columns:Ze,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:!0,children:[w?o.jsx(xe.TopCell,{children:" "}):o.jsx(xe.TopSelectCell,{checked:se?!0:he?"indeterminate":!1,onToggle:()=>we(),"aria-label":"Select all"}),o.jsxs(xe.TopCells,{colStart:2,children:[o.jsx(xe.TopCell,{children:"Input"}),o.jsx(xe.TopCell,{children:"Comment"}),o.jsx(xe.TopCell,{children:"Tags"}),o.jsx(xe.TopCell,{children:"Rating"}),o.jsx(xe.TopCell,{children:"Scores"})]})]}),Y.map(Oe=>{const _e=Oe.scores?Object.entries(Oe.scores):[],Ce=p===Oe.id,Ee=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",className:"min-w-0 text-neutral4",children:o.jsx("span",{className:"block truncate",children:QQr(Oe.input,200)})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:Oe.comment?o.jsx(ge,{variant:"ui-xs",className:"text-neutral3 truncate",children:Oe.comment}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:Oe.tags.length>0?o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 truncate",children:Oe.tags.join(", ")}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})}),o.jsxs(xe.Cell,{height:"compact",children:[Oe.rating==="positive"&&o.jsx(Ge,{size:"sm",className:"text-positive1",children:o.jsx(jve,{})}),Oe.rating==="negative"&&o.jsx(Ge,{size:"sm",className:"text-negative1",children:o.jsx(Eve,{})}),!Oe.rating&&o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})]}),o.jsx(xe.Cell,{height:"compact",children:_e.length>0?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx(Ge,{size:"sm",className:"text-neutral3",children:o.jsx(tg,{})}),o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 font-mono",children:_e[0][1].toFixed(2)}),_e.length>1&&o.jsxs(Jt,{variant:"default",children:["+",_e.length-1]})]}):o.jsx(ge,{variant:"ui-xs",className:"text-neutral2",children:"—"})})]});return o.jsxs(xe.RowWrapper,{children:[w?o.jsx(xe.Cell,{height:"compact",className:"justify-items-center px-4",children:o.jsx("div",{role:"img","aria-label":Oe.error?"Error":"Success",title:Oe.error?"Error":"Success",className:K("w-2 h-2 rounded-full",Oe.error?"bg-red-700":"bg-green-600")})}):o.jsx(xe.SelectCell,{checked:v.has(Oe.id),onToggle:()=>be(Oe.id),"aria-label":`Select item ${Oe.id}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:Ce,onClick:()=>me(Oe.id),children:Ee})]},Oe.id)})]})]}),ye&&o.jsx(S5t,{item:ye,isCompleted:w,tagVocabulary:G,onRate:Oe=>ee(ye.id,Oe),onSetTags:Oe=>{ne(ye.id,Oe);for(const _e of Oe)G.includes(_e)||U(_e)},onComment:Oe=>J(ye.id,Oe),onRemove:()=>ie(ye.id),onComplete:w?void 0:()=>ue(ye.id),onPrevious:Re,onNext:Qe,onClose:()=>h(null)})]})]})}function GQr({datasetId:e,onAddItemClick:t,onNavigateToDataset:n}){const{navigate:r}=vn(),[s,a]=zi(),{tab:i,activeVersion:l,handleTabChange:c}=bEe(s,a),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),[g,v]=y.useState([]),[b,w]=y.useState(!1),[S,O]=y.useState([]),[_,C]=y.useState(!1),[j,E]=y.useState([]),[N,I]=y.useState(0),[P,$]=y.useState(null),[B,D]=y.useState(""),[V]=a0e(B,300),{data:H}=Dx(e),{data:L=[],total:F,isLoading:z,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U}=HO(e,V||void 0,l),{total:R}=HO(e,void 0,l),[q,W]=y.useState({}),{data:X,isLoading:ne}=xM(e,void 0,q),{data:ee}=xM(e),{deleteItems:J}=Li(),ie=X?.experiments??[],ue=ee?.experiments??[],Y=mQr({hasSearchQuery:!!V,filteredItemsLength:L.length,unfilteredItemsTotal:R,itemsTotal:F}),{data:te}=xEe(e),le=te?.length??0,fe=re=>{$(re)},se=()=>{$(null)},he=re=>{v(re),m(!0)},be=re=>{O(re),w(!0)},we=re=>{w(re),re||(O([]),I(me=>me+1))},Ie=re=>{r(`/datasets/${e}/items?items=${re.join(",")}`)},ke=re=>{r(`/datasets/${e}/versions?ids=${re.join(",")}`)},je=re=>{E(re),C(!0)},Fe=async()=>{await J.mutateAsync({datasetId:e,itemIds:j}),Ue.success(`Deleted ${j.length} items`),C(!1),E([]),I(re=>re+1)},ce=re=>{m(!1),v([]),I(me=>me+1),n?.(re)},ae=re=>{m(re),re||(v([]),I(me=>me+1))};return o.jsxs(o.Fragment,{children:[o.jsxs(vc,{defaultTab:"items",value:i,onValueChange:c,className:"grid grid-rows-[auto_1fr] h-full",children:[o.jsxs(yc,{children:[o.jsxs(Ir,{value:"items",children:["Items ",o.jsx(Ys,{color:"gray",children:Y})]}),o.jsxs(Ir,{value:"experiments",children:["Experiments",o.jsx(Ys,{color:"gray",children:ie.length})]}),o.jsxs(Ir,{value:"review",children:["Review",le>0&&o.jsx(Ys,{color:"orange",children:le})]})]}),o.jsx(Wr,{value:"items",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(UQr,{datasetId:e,items:L,isLoading:z,featuredItemId:P,onItemSelect:fe,onItemClose:se,onAddClick:t??(()=>{}),onImportClick:()=>d(!0),onImportJsonClick:()=>p(!0),onBulkDeleteClick:je,onCreateDatasetClick:he,onAddToDatasetClick:be,onCompareItemsClick:Ie,datasetName:H?.name,clearSelectionTrigger:N,setEndOfListElement:M,isFetchingNextPage:G,hasNextPage:U,searchQuery:B,activeSearchQuery:V,onSearchChange:D,currentDatasetVersion:H?.version,onCompareVersionsClick:ke})}),o.jsx(Wr,{value:"experiments",className:"grid overflow-auto mt-5 pb-0",children:o.jsx(IQr,{experiments:ie,allExperiments:ue,isLoading:ne,datasetId:e,filters:q,onFiltersChange:W})}),o.jsx(Wr,{value:"review",className:"overflow-auto mt-2 pb-0",children:o.jsx($5t,{datasetId:e})})]}),o.jsx(kQr,{datasetId:e,open:u,onOpenChange:d}),o.jsx(ZQr,{datasetId:e,open:f,onOpenChange:p}),o.jsx(sQr,{open:h,onOpenChange:ae,items:g,onSuccess:ce}),o.jsx(aQr,{open:b,onOpenChange:we,items:S,currentDatasetId:e}),o.jsx(jt,{open:_,onOpenChange:C,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Items"}),o.jsxs(jt.Description,{children:["Are you sure you want to delete ",j.length," item",j.length!==1?"s":"","? This action cannot be undone."]})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:Fe,children:J.isPending?"Deleting...":"Delete"})]})]})})]})}function YQr(e){if(!(e instanceof Error))return null;const t=e.message.match(/- ({.*})$/);if(!t)return null;try{const n=JSON.parse(t[1]);if(n.field&&Array.isArray(n.errors))return{field:n.field,errors:n.errors}}catch{}return null}function JZe({field:e,errors:t}){return t.length?o.jsx("div",{className:"mt-2 space-y-1",children:t.map((n,r)=>o.jsxs("p",{className:"text-xs text-destructive",children:[o.jsxs("code",{className:"bg-destructive/10 px-1 rounded",children:[e,n.path!=="/"?n.path:""]}),": ",n.message]},r))}):null}function XQr({datasetId:e,open:t,onOpenChange:n,onSuccess:r}){const[s,a]=y.useState("{}"),[i,l]=y.useState(""),[c,u]=y.useState(""),[d,f]=y.useState(""),[p,h]=y.useState(null),{addItem:m}=Li(),g=async S=>{S.preventDefault();let O;try{O=JSON.parse(s)}catch{Ue.error("Input must be valid JSON");return}let _;if(i.trim())try{_=JSON.parse(i)}catch{Ue.error("Ground Truth must be valid JSON");return}let C;if(c.trim())try{C=JSON.parse(c)}catch{Ue.error("Expected Trajectory must be valid JSON");return}let j;if(d.trim())try{j=JSON.parse(d)}catch{Ue.error("Request Context must be valid JSON");return}try{await m.mutateAsync({datasetId:e,input:O,groundTruth:_,expectedTrajectory:C,requestContext:j}),Ue.success("Item added successfully"),h(null),a("{}"),l(""),u(""),f(""),n(!1),r?.()}catch(E){const N=YQr(E);N?h(N):Ue.error(`Failed to add item: ${E instanceof Error?E.message:"Unknown error"}`)}},v=S=>{a(S),p?.field==="input"&&h(null)},b=S=>{l(S),p?.field==="groundTruth"&&h(null)},w=()=>{a("{}"),l(""),u(""),f(""),h(null),n(!1)};return o.jsx(Nr,{open:t,onOpenChange:n,children:o.jsxs(_r,{className:"max-w-lg",children:[o.jsx(Cr,{children:o.jsx(Sr,{children:"Add Item"})}),o.jsx(Lr,{children:o.jsxs("form",{onSubmit:g,className:"space-y-4",children:[o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-input",children:"Input (JSON) *"}),o.jsx(Kr,{value:s,onChange:v,showCopyButton:!1,className:"min-h-[120px]"}),p?.field==="input"&&o.jsx(JZe,{field:"input",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-ground-truth",children:"Ground Truth (JSON, optional)"}),o.jsx(Kr,{value:i,onChange:b,showCopyButton:!1,className:"min-h-[80px]"}),p?.field==="groundTruth"&&o.jsx(JZe,{field:"groundTruth",errors:p.errors})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-trajectory",children:"Expected Trajectory (JSON, optional)"}),o.jsx(Kr,{value:c,onChange:u,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{htmlFor:"item-request-context",children:"Request Context (JSON, optional)"}),o.jsx(Kr,{value:d,onChange:f,showCopyButton:!1,className:"min-h-[80px]"})]}),o.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[o.jsx(pe,{type:"button",onClick:w,children:"Cancel"}),o.jsx(pe,{type:"submit",variant:"primary",disabled:m.isPending,children:m.isPending?"Adding...":"Add Item"})]})]})})]})})}function KQr({item:e}){return o.jsx(la,{withMargins:!1,children:o.jsxs(la.Column,{children:[o.jsxs(la.Title,{size:"smaller",children:[o.jsx(XT,{}),o.jsx("span",{className:"truncate",children:e.id}),o.jsx(Pa,{content:e.id,tooltip:`Copy item ID: ${e.id}`})]}),o.jsxs(la.Description,{children:[o.jsxs(ic,{children:[o.jsx(Sat,{})," Created ",Kn(new Date(e.createdAt),"MMM d, yyyy h:mm aaa")]}),e.datasetVersion!=null&&o.jsxs(ic,{children:[o.jsx(YO,{})," Version v",e.datasetVersion]})]})]})})}function wEe({item:e}){const t=e?.input?JSON.stringify(e.input,null,2):"null",n=e?.groundTruth?JSON.stringify(e.groundTruth,null,2):"null",r=e?.metadata?JSON.stringify(e.metadata,null,2):"null",s=e?.expectedTrajectory?JSON.stringify(e.expectedTrajectory,null,2):null;return o.jsxs(i0e,{children:[o.jsx(va.CodeSection,{title:"Input",icon:o.jsx(Gk,{}),codeStr:t}),o.jsx(va.CodeSection,{title:"Ground Truth",icon:o.jsx(Gm,{}),codeStr:n}),s&&o.jsx(va.CodeSection,{title:"Expected Trajectory",icon:o.jsx(Wat,{}),codeStr:s}),o.jsx(va.CodeSection,{title:"Metadata",icon:o.jsx(XO,{}),codeStr:r})]})}function JQr({selectedScorers:e,setSelectedScorers:t,disabled:n=!1,container:r}){const{data:s,isLoading:a}=Up(),i=y.useMemo(()=>s?Object.entries(s).map(([l,c])=>({value:l,label:c.scorer?.config?.name||l,description:c.scorer?.config?.description||""})):[],[s]);return o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Pt,{children:"Scorers (Optional)"}),o.jsx(gmt,{options:i,value:e,onValueChange:t,placeholder:"Select scorers...",searchPlaceholder:"Search scorers...",emptyText:"No scorers available",disabled:n||a,container:r})]})}const eGr=[{value:"agent",label:"Agent"},{value:"workflow",label:"Workflow"},{value:"scorer",label:"Scorer"}];function tGr({targetType:e,setTargetType:t,targetId:n,setTargetId:r,container:s}){const{data:a,isLoading:i}=sm(),{data:l,isLoading:c}=Ey(),{data:u,isLoading:d}=Up(),f=e==="agent"?Object.entries(a??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="workflow"?Object.entries(l??{}).map(([g,v])=>({value:g,label:v.name??g})):e==="scorer"?Object.entries(u??{}).map(([g,v])=>({value:g,label:v.scorer?.config?.name??g})):[],p=e==="agent"&&i||e==="workflow"&&c||e==="scorer"&&d,h=g=>{t(g),r("")},m=e==="agent"?"Agent":e==="workflow"?"Workflow":"Scorer";return o.jsxs("div",{className:"grid gap-6",children:[o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Pt,{children:"Target Type"}),o.jsx(Hc,{options:eGr,value:e,onValueChange:h,placeholder:"Select target type",searchPlaceholder:"Search types...",emptyText:"No types available",container:s})]}),e&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Pt,{children:m}),o.jsx(Hc,{options:f,value:n,onValueChange:r,placeholder:`Select ${e}`,searchPlaceholder:"Search...",emptyText:"No targets available",disabled:p,container:s})]})]})}function nGr({requestContextSchema:e,onChange:t}){const n=y.useMemo(()=>{try{return hg(fg(e))}catch(r){return console.error("Failed to parse requestContextSchema:",r),null}},[e]);return n?o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{children:"Request Context"}),o.jsx(eH,{schema:n,onValuesChange:t,className:"[&_button[type=submit]]:hidden"})]}):o.jsx("p",{className:"text-sm text-destructive",children:"Failed to parse request context schema"})}function rGr({datasetId:e,version:t,requestContextSchema:n,open:r,onOpenChange:s,onSuccess:a}){const i=y.useRef(null),[l,c]=y.useState(""),[u,d]=y.useState(""),[f,p]=y.useState([]),[h,m]=y.useState({}),[g,v]=y.useState(""),{triggerExperiment:b}=Li(),w=!!(n&&Object.keys(n).length>0),S=l&&u,O=b.isPending,_=()=>{c(""),d(""),p([]),m({}),v("")},C=()=>{if(w){const N=Object.entries(h).filter(([,I])=>I!==void 0&&I!=="");return N.length>0?Object.fromEntries(N):void 0}if(g.trim()){let N;try{N=JSON.parse(g)}catch{throw new Error("Request Context must be valid JSON")}if(!N||typeof N!="object"||Array.isArray(N))throw new Error("Request Context must be a JSON object");return N}},j=async()=>{if(!S)return;let N;try{N=C()}catch(I){const P=I instanceof Error?I.message:"Request Context must be valid JSON";bu.error(P);return}try{const I=await b.mutateAsync({datasetId:e,targetType:l,targetId:u,scorerIds:f.length>0?f:void 0,version:t,requestContext:N});bu.success("Experiment triggered successfully"),s(!1),a?.(I.experimentId),_()}catch(I){const P=I instanceof Error?I.message:"Failed to trigger experiment";bu.error(P)}},E=()=>{O||(s(!1),_())};return o.jsx(Nr,{open:r,onOpenChange:E,children:o.jsxs(_r,{ref:i,children:[o.jsxs(Cr,{children:[o.jsx(Sr,{children:"Run Experiment"}),o.jsx(Qs,{children:t?`Execute items from ${Kn(new Date(t),"MMM d, yyyy")} version against a target.`:"Execute all items in this dataset against a target."})]}),o.jsxs(Lr,{className:"grid gap-6",children:[o.jsx(tGr,{targetType:l,setTargetType:c,targetId:u,setTargetId:d,container:i}),l&&l!=="scorer"&&o.jsx(JQr,{selectedScorers:f,setSelectedScorers:p,disabled:O,container:i}),w?o.jsx(nGr,{requestContextSchema:n,onChange:m}):o.jsxs("div",{className:"space-y-2",children:[o.jsx(Pt,{children:"Request Context (JSON, optional)"}),o.jsx(Kr,{value:g,onChange:v,showCopyButton:!1,className:"min-h-[80px]"})]})]}),o.jsxs(uc,{className:"px-6 pt-4",children:[o.jsx(pe,{onClick:E,disabled:O,children:"Cancel"}),o.jsx(pe,{variant:"primary",onClick:j,disabled:!S||O,children:O?o.jsxs(o.Fragment,{children:[o.jsx(Ht,{className:"w-4 h-4"}),"Running..."]}):"Run"})]})]})})}const sGr=e=>{const t=He();return xt({queryKey:["experiment-trace-light",e],queryFn:async()=>{if(!e)throw new Error("Trace ID is required");return t.getTraceLight(e)},enabled:!!e})};function aGr({result:e,scores:t,onPrevious:n,onNext:r,onClose:s,onShowTrace:a,onOpenInReview:i,onScoreClick:l,featuredScoreId:c,onFlagForReview:u,collapsed:d,onCollapsedChange:f}){const[p,h]=y.useState(!1),m=d??p,g=f??h,v=!!e?.error,b=u8(e?.input),w=u8(e?.output),S=u8(e?.groundTruth),O=u&&e.status!=="needs-review"&&e.status!=="complete",_=Array.isArray(e.tags)?e.tags:[];return o.jsxs(Sn,{collapsed:m,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Result ",o.jsxs("b",{children:["# ",e.id.length>12?`${e.id.slice(0,12)}…`:e.id]})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[f&&o.jsx(pe,{size:"md",tooltip:m?"Expand panel":"Collapse panel",onClick:()=>g(!m),children:m?o.jsx(Cat,{}):o.jsx(_at,{})}),o.jsx(Sn.NextPrevNav,{onPrevious:n,onNext:r,previousLabel:"Previous result",nextLabel:"Next result"}),o.jsxs(pe,{size:"md",onClick:a,disabled:!e.traceId,children:[o.jsx(bSe,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:s,tooltip:"Close result panel"})]})]}),!m&&o.jsxs(Sn.Content,{children:[o.jsxs("div",{className:"grid gap-4 mb-6",children:[o.jsxs(Ft,{children:[o.jsx(Ft.Key,{children:"Item Id"}),o.jsx(Ft.ValueWithCopyBtn,{copyTooltip:"Copy Item Id to clipboard",copyValue:e.itemId,children:e.itemId}),o.jsx(Ft.Key,{children:"Created"}),o.jsx(Ft.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")})]}),v&&o.jsx(Rn,{variant:"destructive",title:"Error",children:o.jsx(Rn.Message,{children:u8(e?.error&&typeof e.error=="object"?e.error.message:e?.error)})}),t&&t.length>0&&o.jsxs(xe,{columns:"1fr 1fr",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Scorer"}),o.jsx(xe.TopCell,{children:"Score"})]}),t.map(C=>o.jsxs(xe.RowButton,{featured:c===C.id,onClick:()=>l?.(C.id),children:[o.jsx(xe.Cell,{height:"compact",children:C.scorerId}),o.jsx(xe.MonoCell,{children:C.score.toFixed(3)})]},C.id))]}),(e.status||_.length>0||O)&&o.jsxs("div",{className:"grid gap-2",children:[o.jsx(Sn.SectionHeading,{icon:o.jsx(XO,{}),className:"mb-2",children:"Review"}),(e.status||_.length>0)&&o.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.status&&o.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${e.status==="needs-review"?"bg-orange-500/10 text-orange-400":e.status==="complete"?"bg-accent1/10 text-accent1":"bg-neutral3/10 text-neutral4"}`,children:e.status}),_.map(C=>o.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-surface4 text-neutral4",children:C},C))]}),O&&o.jsx("div",{children:o.jsxs(pe,{size:"sm",onClick:()=>u(e.id),children:[o.jsx(KB,{}),"Flag for Review"]})}),e.status==="needs-review"&&i&&o.jsx("div",{children:o.jsxs(pe,{size:"sm",onClick:i,children:[o.jsx(ja,{}),"Review"]})})]})]}),o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:"Input",icon:o.jsx(XT,{}),codeStr:b}),o.jsx(Sn.CodeSection,{title:"Output",icon:o.jsx(Gm,{}),codeStr:w}),o.jsx(Sn.CodeSection,{title:"Ground Truth",icon:o.jsx(Cve,{}),codeStr:S})]})]})]})}function u8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function iGr({results:e,isLoading:t,featuredResultId:n,onResultClick:r,columns:s,scoresByItemId:a,scorerIds:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u,selectedIds:d,onToggleSelect:f}){const p=!!(d&&f),h=[p?"auto":"",...s.map(g=>g.size)].filter(Boolean).join(" "),m=s.some(g=>g.name==="input");return t?o.jsx(Wo,{columns:h}):o.jsxs(xe,{columns:h,className:"min-w-0",children:[o.jsxs(xe.Top,{hasLeadingCell:p,children:[p&&o.jsx(xe.TopCell,{children:" "}),p?o.jsx(xe.TopCells,{colStart:2,children:s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))}):s.map(g=>o.jsx(xe.TopCell,{children:g.label},g.name))]}),e.length===0?o.jsx(xe.NoMatch,{message:"No results yet"}):o.jsxs(o.Fragment,{children:[e.map(g=>{const v=!!g.error,b=g.id===n,w=o.jsxs(o.Fragment,{children:[o.jsx(xe.IdCell,{id:g.itemId}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("div",{className:"flex items-center justify-center w-10 relative bg-transparent h-full",children:o.jsx("div",{role:"img","aria-label":v?"Error":"Success",className:K("w-2 h-2 rounded-full",v?"bg-red-700":"bg-green-600")})})}),o.jsx(Hn,{children:v?"Error":"Success"})]})}),m&&o.jsx(xe.MonoCell,{children:lGr(oGr(g.input),200)}),i?.map(S=>{const _=a?.[g.itemId]?.find(C=>C.scorerId===S);return o.jsx(xe.Cell,{height:"compact",className:"font-mono text-neutral3 text-ui-smd",children:_!=null?_.score.toFixed(3):"-"},S)})]});return p?o.jsxs(xe.RowWrapper,{children:[o.jsx(xe.SelectCell,{checked:d.has(g.id),onToggle:()=>f(g.id),"aria-label":`Select result ${g.itemId}`}),o.jsx(xe.RowButton,{flushLeft:!0,colStart:2,featured:b,onClick:()=>r(g.id),children:w})]},g.id):o.jsx(xe.RowButton,{featured:b,onClick:()=>r(g.id),children:w},g.id)}),o.jsx(xe.NextPageLoading,{isLoading:c,hasMore:u,setEndOfListElement:l})]})]})}function oGr(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function lGr(e,t){return e.length<=t?e:e.slice(0,t-1)+"..."}function cGr(e){const t=e.scorer;return t?.hasJudge===!1?!0:t?.hasJudge===!0?!1:!e.preprocessPrompt&&!e.analyzePrompt&&!e.generateScorePrompt&&!e.generateReasonPrompt}function uGr({score:e,onNext:t,onPrevious:n,onClose:r,onShowTrace:s,collapsed:a,onCollapsedChange:i}){const[l,c]=y.useState(!1),u=a??l,d=i??c,f=cGr(e),p=f?"N/A — code-based scorer":"N/A — step not configured";return o.jsxs(Sn,{collapsed:u,children:[o.jsxs(Sn.Header,{children:[o.jsxs(Sn.Heading,{children:["Score ",o.jsx("b",{children:e.scorerId})]}),o.jsxs($r,{className:"ml-auto shrink-0",children:[i&&o.jsx(pe,{size:"md",tooltip:u?"Expand panel":"Collapse panel",onClick:()=>d(!u),children:u?o.jsx(Cat,{}):o.jsx(_at,{})}),(n||t)&&o.jsx(Sn.NextPrevNav,{onPrevious:n,onNext:t,previousLabel:"Previous score",nextLabel:"Next score"}),s&&o.jsxs(pe,{size:"md",onClick:s,disabled:!e.traceId,children:[o.jsx(bSe,{}),"Trace"]}),o.jsx(Sn.CloseButton,{onClick:r,tooltip:"Close score panel"})]})]}),!u&&o.jsx(Sn.Content,{children:o.jsxs("div",{className:"grid gap-3",children:[o.jsx(Sn.CodeSection,{title:`Score: ${e.score}`,icon:o.jsx(tg,{}),codeStr:e.reason||p,simplified:!0}),!f&&o.jsxs(o.Fragment,{children:[o.jsx(Sn.CodeSection,{title:"Preprocess Prompt",icon:o.jsx(ah,{}),codeStr:e.preprocessPrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Analyze Prompt",icon:o.jsx(ah,{}),codeStr:e.analyzePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Score Prompt",icon:o.jsx(ah,{}),codeStr:e.generateScorePrompt||p,simplified:!0}),o.jsx(Sn.CodeSection,{title:"Generate Reason Prompt",icon:o.jsx(ah,{}),codeStr:e.generateReasonPrompt||p,simplified:!0})]})]})})]})}const eWe=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"avg",label:"Avg Score",size:"1fr"},{name:"count",label:"Items Scored",size:"1fr"}];function dGr({scoresByItemId:e,experimentStatus:t}){const n=y.useMemo(()=>{if(!e)return[];const r={};for(const s of Object.values(e))for(const a of s)r[a.scorerId]||(r[a.scorerId]={sum:0,count:0}),r[a.scorerId].sum+=a.score,r[a.scorerId].count++;return Object.entries(r).map(([s,{sum:a,count:i}])=>({scorerId:s,avg:a/i,count:i})).sort((s,a)=>s.scorerId.localeCompare(a.scorerId))},[e]);if(n.length===0){const r=t==="running"||t==="pending",s=e!==void 0;let a,i;return r?(a="Experiment in progress",i="Summary metrics will appear here once the experiment completes."):s?(a="No scorers configured",i="Add scorers when triggering an experiment to evaluate results and see summary metrics here."):(a="Loading scores",i="Fetching scorer results…"),o.jsx("div",{className:"flex h-full items-center justify-center py-12",children:o.jsx(Qr,{iconSlot:o.jsx(tg,{className:"w-8 h-8 text-neutral3"}),titleSlot:a,descriptionSlot:i})})}return o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:eWe,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{children:"Avg Score"}),o.jsx(hn.HeaderCol,{children:"Items Scored"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:n.map(({scorerId:r,avg:s,count:a})=>o.jsxs(hn.Row,{columns:eWe,children:[o.jsx(hn.TextCell,{children:r}),o.jsx(hn.TextCell,{className:"font-mono",children:s.toFixed(3)}),o.jsx(hn.TextCell,{className:"font-mono",children:a})]},r))})})]})}function M5t({experimentId:e,datasetId:t,experimentStatus:n,results:r,isLoading:s,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l}){const[c,u]=y.useState(null),[d,f]=y.useState(null),[p,h]=y.useState(void 0),[m,g]=y.useState(null),[v,b]=y.useState(new Set),[w,S]=y.useState(!1),[O,_]=y.useState(!1),[C,j]=y.useState(!1),[E,N]=y.useState(!1),{updateExperimentResult:I}=Li(),P=y.useCallback(ae=>{b(re=>{const me=new Set(re);return me.has(ae)?me.delete(ae):me.add(ae),me})},[]),$=y.useCallback(()=>b(new Set),[]),B=y.useCallback(()=>{const ae=r.filter(re=>!!re.error).map(re=>re.id);b(new Set(ae))},[r]),D=y.useCallback(async ae=>{if(w||ae.length===0)return;S(!0);let re=0;const me=new Set;try{for(const ye of ae)try{await I.mutateAsync({datasetId:t,experimentId:e,resultId:ye,status:"needs-review"}),re++,me.add(ye)}catch{}}finally{S(!1)}me.size>0&&b(ye=>{const Te=new Set(ye);for(const Re of me)Te.delete(Re);return Te}),re>0&&Ue(`${re} result${re>1?"s":""} flagged for review`)},[t,e,w,I]),V=r.find(ae=>ae.id===c)??null,[H,L]=y.useState("summary"),[F,z]=y.useState(null),M=ae=>{L(ae),ae!=="reviews"&&z(null)},{data:G}=xEe(t),U=(G??[]).filter(ae=>ae.experimentId===e).length,{data:R}=y5t(e,n),q=y.useMemo(()=>{if(!R)return[];const ae=new Set;for(const re of Object.values(R))for(const me of re)ae.add(me.scorerId);return[...ae].sort()},[R]),W=ae=>{u(ae),f(null),h(void 0),g(null)},X=ae=>{W(ae===c?null:ae)},ne=()=>{W(null)},ee=()=>{if(!V)return;const ae=r.findIndex(re=>re.id===V.id);if(ae>=0&&ae<r.length-1)return()=>W(r[ae+1].id)},J=()=>{if(!V)return;const ae=r.findIndex(re=>re.id===V.id);if(ae>0)return()=>W(r[ae-1].id)},ie=V?R?.[V.itemId]:void 0,ue=ie?.find(ae=>ae.id===m)??null,Y=ae=>{g(ae===m?null:ae),f(null),h(void 0)},te=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>=0&&ae<ie.length-1)return()=>g(ie[ae+1].id)},le=()=>{if(!m||!ie)return;const ae=ie.findIndex(re=>re.id===m);if(ae>0)return()=>g(ie[ae-1].id)},{data:fe,isLoading:se}=sGr(d),he=fe?.spans,{data:be,isLoading:we}=iD(d,p),Ie=be?.span,{handlePreviousSpan:ke,handleNextSpan:je}=MSe(he,p??null,h),Fe=(()=>{const ae=[],re=!!ue,me=!!d;return ae.push(O?"auto":re||me?"2fr":"1fr"),re&&ae.push(E?"auto":"3fr"),me&&ae.push(C?"auto":"3fr"),me&&p&&ae.push("3fr"),ae.join(" ")})(),ce=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"7rem"},{name:"status",label:"Status",size:"5rem"},{name:"input",label:"Input",size:"minmax(15rem,1fr)"},...q.map(ae=>({name:ae,label:ae,size:"12rem"}))],[q]);return o.jsxs(vc,{defaultTab:"summary",value:H,onValueChange:M,className:"grid grid-rows-[auto_1fr] h-full overflow-hidden",children:[o.jsxs(yc,{children:[o.jsx(Ir,{value:"summary",children:"Summary"}),o.jsx(Ir,{value:"results",children:"Results"}),o.jsxs(Ir,{value:"reviews",children:["Reviews",U>0&&o.jsx(Ys,{color:"orange",children:U})]})]}),o.jsx(Wr,{value:"summary",className:"overflow-y-auto mt-5",children:o.jsx(dGr,{scoresByItemId:R,experimentStatus:n})}),o.jsx(Wr,{value:"reviews",className:"overflow-auto mt-2 pb-0",children:o.jsx($5t,{datasetId:t,experimentId:e,featuredItemId:F})}),o.jsxs(Wr,{value:"results",className:"grid grid-rows-[auto_1fr] overflow-hidden mt-2",children:[o.jsxs("div",{className:"mb-4",children:[v.size>0&&o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-surface3",children:[o.jsxs(ge,{variant:"ui-xs",className:"text-neutral5 font-medium",children:[v.size," selected"]}),o.jsx("div",{className:"flex-1"}),o.jsxs(pe,{variant:"outline",size:"sm",disabled:w,onClick:()=>D([...v]),children:[o.jsx(Ge,{size:"sm",children:o.jsx(KB,{})}),"Flag for Review"]}),o.jsx(pe,{variant:"ghost",size:"sm",onClick:$,children:"Clear"})]}),r.length>0&&v.size===0&&!s&&o.jsx("div",{className:"flex items-center gap-2 px-4 py-2",children:o.jsx(pe,{variant:"ghost",size:"sm",onClick:B,children:"Select loaded failures"})})]}),o.jsxs("div",{className:K("grid w-full h-full grid-cols-1 gap-4 overflow-y-auto",V&&"grid-cols-[1fr_1fr]"),children:[o.jsx("div",{className:"flex overflow-y-auto w-full",children:o.jsx("div",{className:"grid gap-8 content-start w-full overflow-y-auto",children:o.jsx(iGr,{results:r,isLoading:s,featuredResultId:c,onResultClick:X,columns:ce,scoresByItemId:R,scorerIds:q,setEndOfListElement:a,isFetchingNextPage:i,hasNextPage:l,selectedIds:v,onToggleSelect:P})})}),V&&o.jsxs("div",{className:"grid gap-4 max-h-full min-h-0 overflow-auto content-start",style:{gridTemplateRows:Fe},children:[o.jsx(aGr,{result:V,scores:ie,onPrevious:J(),onNext:ee(),onClose:ne,onScoreClick:Y,featuredScoreId:m,onShowTrace:()=>{V.traceId&&(f(V.traceId),h(void 0),g(null),_(!0),j(!1))},onOpenInReview:()=>{z(V.id),L("reviews")},onFlagForReview:ae=>D([ae]),collapsed:O,onCollapsedChange:_}),ue&&o.jsx(uGr,{score:ue,onNext:te(),onPrevious:le(),onClose:()=>g(null),onShowTrace:()=>{ue.traceId&&(f(ue.traceId),h(void 0),_(!0),N(!0),j(!1))},collapsed:E,onCollapsedChange:N}),d&&o.jsxs(o.Fragment,{children:[o.jsx(TSe,{traceId:d,spans:he,isLoading:se,onClose:()=>{f(null),h(void 0),_(!1),N(!1)},onSpanSelect:h,initialSpanId:p??null,placement:"traces-list",showUnavailableFeaturesMsg:!1,collapsed:C,onCollapsedChange:j,LinkComponent:HN,traceHref:`/traces/${d}`}),p&&o.jsx(NSe,{traceId:d,spanId:p,span:Ie,isLoading:we,onPrevious:ke,onNext:je,onClose:()=>h(void 0)})]})]})]})]})]})}const fGr={pending:o.jsx(YT,{}),running:o.jsx(Sue,{}),completed:o.jsx(da,{}),failed:o.jsx(ys,{})};function pGr({experiment:e,className:t}){const n=e.status,r=e.totalItems-e.succeededCount-e.failedCount;return o.jsxs("div",{className:K("grid justify-items-end gap-3",t),children:[o.jsxs("div",{className:"flex p-1 px-3 text-ui-lg capitalize text-neutral4 gap-2 items-center bg-surface5 rounded-lg ",children:[o.jsx("span",{className:K("w-5 h-5 flex items-center justify-center rounded-full text-black","[&>svg]:w-4 [&>svg]:h-4",{"bg-green-700":n==="completed","bg-red-700":n==="failed","bg-cyan-600":n==="running","bg-yellow-600":n==="pending"}),children:fGr[n]}),e.status]}),o.jsxs("div",{className:K("flex items-center gap-3 text-neutral3 text-ui-md ","[&>span]:flex [&>span]:gap-1 [&>span]:items-center ","[&_b]:text-neutral4 [&_b]:font-semibold"),children:[o.jsxs("span",{children:["Total: ",o.jsx("b",{children:e.totalItems})]}),o.jsxs("span",{children:["Succeeded: ",o.jsx("b",{children:e.succeededCount})]}),o.jsxs("span",{children:["Failed: ",o.jsx("b",{children:e.failedCount})]}),(n==="pending"||n==="running")&&o.jsxs("span",{children:["Pending: ",o.jsx("b",{children:r})]})]})]})}function hGr({onPrevious:e,onNext:t,previousAriaLabel:n="Previous",nextAriaLabel:r="Next"}){return o.jsxs($r,{spacing:"close",children:[o.jsxs(pe,{onClick:e,disabled:!e,"aria-label":n,children:[o.jsx(GU,{})," Prev"]}),o.jsxs(pe,{onClick:t,disabled:!t,"aria-label":r,children:["Next",o.jsx(WU,{})]})]})}function SEe({delta:e}){const t=e>0?o.jsx(Ys,{size:"small",color:"green",intensity:"muted",children:o.jsx(AM,{})}):e<0?o.jsx(Ys,{size:"small",color:"red",intensity:"muted",children:o.jsx(Ssn,{})}):null;return o.jsxs("span",{className:K("font-mono text-sm text-neutral4 min-w-20"),children:[o.jsx("span",{className:"w-3 inline-block",children:e>0?"+ ":e<0?"- ":""}),Math.abs(e).toFixed(2)," ",t]})}function d8(e){return e==null?"-":typeof e=="string"?e:JSON.stringify(e,null,2)}function mGr({item:e,baselineId:t,contenderId:n,baselineVersion:r,contenderVersion:s,onPrevious:a,onNext:i,onClose:l}){const c=e.results[t],u=e.results[n],d=!!(c&&u),f=new Set;if(c)for(const h of Object.keys(c.scores))f.add(h);if(u)for(const h of Object.keys(u.scores))f.add(h);const p=[...f].sort();return o.jsxs(Zr,{withLeftSeparator:!0,children:[o.jsxs(Zr.Toolbar,{children:[o.jsx(hGr,{onPrevious:a,onNext:i,previousAriaLabel:"Previous comparison item",nextAriaLabel:"Next comparison item"}),o.jsx($r,{children:o.jsx(pe,{onClick:l,"aria-label":"Close comparison detail panel",children:o.jsx(ys,{})})})]}),o.jsxs(Zr.Content,{className:"pb-6",children:[o.jsx(la,{withMargins:!1,children:o.jsx(la.Column,{children:o.jsxs(la.Title,{size:"smaller",children:[o.jsx(XT,{})," ",e.itemId]})})}),d?o.jsx(o.Fragment,{children:o.jsxs(i0e,{children:[p.length>0&&o.jsxs("div",{className:"grid gap-3",children:[o.jsx("h4",{className:"text-sm font-medium text-neutral5",children:"Scores"}),o.jsx("div",{className:"grid gap-2",children:p.map(h=>{const m=c?.scores[h]??null,g=u?.scores[h]??null,v=m!=null&&g!=null?g-m:null;return o.jsxs("div",{className:"flex items-center justify-between gap-4 px-3 py-2 rounded-lg bg-surface2",children:[o.jsx("span",{className:"text-sm text-neutral5 font-medium",children:h}),o.jsxs("div",{className:"flex items-center gap-4",children:[o.jsxs("span",{className:"text-sm text-neutral3",children:[m!=null?m.toFixed(3):"-"," →"," ",g!=null?g.toFixed(3):"-"]}),v!=null&&o.jsx(SEe,{delta:v})]})]},h)})})]}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Ys,{color:"purple",children:"Baseline "})," Experiment Output"]}),icon:o.jsx(Gm,{}),codeStr:d8(c?.output)}),o.jsx(va.CodeSection,{title:o.jsxs(o.Fragment,{children:[o.jsx(Ys,{color:"cyan",children:"Contender "})," Experiment Output"]}),icon:o.jsx(Gm,{}),codeStr:d8(u?.output)}),o.jsx(va.CodeSection,{title:"Item Input",icon:o.jsx(Gk,{}),codeStr:d8(e.input)}),o.jsx(va.CodeSection,{title:"Item Ground Truth",icon:o.jsx(Cve,{}),codeStr:d8(e.groundTruth)})]})}):o.jsx(Rn,{variant:"warning",title:"Comparison not available",children:o.jsx(Rn.Message,{children:(()=>{const h=c?"Contender":"Baseline",m=c?s:r;return o.jsxs(o.Fragment,{children:["The ",h," experiment was run against dataset",m!=null?` v. ${m}`:"",", which does not contain this item."]})})()})})]})]})}function gGr({items:e,baselineId:t,contenderId:n,scorerIds:r,featuredItemId:s,columns:a,onItemClick:i}){return o.jsx(Zr,{children:o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:a,children:[o.jsx(hn.HeaderCol,{children:"Item ID"}),!s&&r.map(l=>o.jsx(hn.HeaderCol,{className:"flex justify-center",children:l},l))]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:e.map(l=>{const c=l.results[t],u=l.results[n],d=!!(c&&u);return o.jsx(hn.Row,{children:o.jsxs(hn.RowButton,{item:{id:l.itemId},columns:a,isFeatured:s===l.itemId,onClick:i,children:[o.jsx(hn.IdCell,{id:l.itemId,className:d?"":"text-neutral1"}),!s&&o.jsx(o.Fragment,{children:r.map(f=>{const p=c?.scores[f]??null,h=u?.scores[f]??null,m=p!=null&&h!=null?h-p:null;return o.jsx(hn.Cell,{className:"flex items-center gap-5 justify-center font-mono",children:m!=null?o.jsxs(o.Fragment,{children:[o.jsxs("span",{className:"flex items-center text-neutral2 min-w-24",children:[p?.toFixed(2)," → ",h?.toFixed(2)]}),o.jsx(SEe,{delta:m})]}):o.jsx("span",{className:"text-neutral1",children:"-"})},f)})})]})},l.itemId)})})})]})})}const vGr={baseline:{label:"Baseline",color:"purple",customStyle:"items-end justify-items-end [&>div]:justify-end border-r-0 rounded-r-none"},contender:{label:"Contender",color:"cyan",customStyle:"items-start justify-items-start [&>div]:justify-start border-l-0 rounded-l-none"}};function tWe({datasetId:e,experiment:t,type:n}){const{Link:r}=vn(),{label:s,color:a,customStyle:i}=vGr[n];if(!t)return null;const l=t.createdAt?new Date(t.createdAt):null;return o.jsxs("div",{className:`grid border-2 border-border1 rounded-lg p-5 gap-3 ${i}`,children:[o.jsxs("div",{className:"flex items-center gap-3 w-full overflow-clip",children:[n==="contender"&&o.jsxs(Ys,{size:"small",color:a,children:[s,o.jsx(Gh,{})]}),o.jsx(pe,{as:r,href:`/datasets/${e}/experiments/${t.id}`,children:o.jsx("span",{className:"truncate min-w-0",children:t.id})}),n==="baseline"&&o.jsxs(Ys,{size:"small",color:a,children:[o.jsx(gc,{})," ",s]})]}),o.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-ui-sm text-neutral3",children:[o.jsxs(ic,{children:[o.jsx(Cve,{})," ",t.targetType," / ",t.targetId]}),o.jsxs(ic,{children:[o.jsx(Ove,{})," v",t.datasetVersion??"—"]}),l&&o.jsxs(ic,{children:[o.jsx(kat,{})," ",Kn(l,"MMM d, yyyy HH:mm")]})]})]})}function yGr({datasetId:e,experimentIdA:t,experimentIdB:n,onSwap:r}){const[s,a]=y.useState(null),{data:i,isLoading:l,error:c}=AWr(e,t,n),{data:u}=PB(e,t),{data:d}=PB(e,n),f=u&&d&&u.datasetVersion!==d.datasetVersion,p=y.useMemo(()=>{if(!i)return[];const j=new Set;for(const E of i.items)for(const N of Object.values(E.results))if(N)for(const I of Object.keys(N.scores))j.add(I);return[...j].sort()},[i]),h=y.useMemo(()=>{if(!i||p.length===0)return[];const j=i.baselineId,E=t===j?n:t;return p.map(N=>{let I=0,P=0,$=0,B=0;for(const L of i.items){const F=L.results[j]?.scores[N],z=L.results[E]?.scores[N];F!=null&&(I+=F,$++),z!=null&&(P+=z,B++)}const D=$>0?I/$:null,V=B>0?P/B:null,H=D!=null&&V!=null?V-D:null;return{scorerId:N,avgA:D,avgB:V,delta:H}})},[i,p,t,n]),m=[{name:"scorer",label:"Scorer",size:"1fr"},{name:"baselineAvg",label:"Baseline Avg",size:"1fr"},{name:"comparisonAvg",label:"Comparison Avg",size:"1fr"},{name:"delta",label:"Delta",size:"1fr"}],g=y.useMemo(()=>[{name:"itemId",label:"Item ID",size:"8rem"},...s?[]:p.map(j=>({name:j,label:j,size:"1fr"}))],[p,s]),v=i?.items.find(j=>j.itemId===s)??null,b=j=>{a(j===s?null:j)},w=()=>{a(null)},S=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>=0&&j<i.items.length-1)return()=>a(i.items[j+1].itemId)},O=()=>{if(!i||!s)return;const j=i.items.findIndex(E=>E.itemId===s);if(j>0)return()=>a(i.items[j-1].itemId)};if(l)return o.jsx("div",{className:"flex items-center justify-center h-64",children:o.jsx(Ht,{})});if(c)return o.jsx(Rn,{variant:"warning",title:"Error loading comparison",children:o.jsx(Rn.Message,{children:c instanceof Error?c.message:"Unknown error"})});if(!i||i.items.length===0)return o.jsx("div",{className:"text-neutral4 text-sm text-center py-8",children:"No comparison data"});const _=i.baselineId,C=t===_?n:t;return o.jsxs("div",{className:"grid gap-10",children:[u&&d&&o.jsxs("div",{className:K("relative grid xl:grid-cols-[1fr_auto_1fr] gap-4 xl:gap-0"),children:[o.jsx(tWe,{datasetId:e,experiment:u,type:"baseline"}),o.jsx("div",{className:"relative flex items-center justify-center px-[2vw] before:absolute before:inset-y-0 before:left-1/2 before:-translate-x-1/2 before:w-[2px] before:bg-border1",children:o.jsx("div",{className:"relative z-1 bg-surface2 rounded-lg p-2",children:o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx(pe,{onClick:r,children:"VS"})}),o.jsx(Hn,{children:"Switch the order"})]})})}),o.jsx(tWe,{datasetId:e,experiment:d,type:"contender"})]}),f&&o.jsx(Rn,{variant:"warning",title:"Version mismatch",children:o.jsxs(Rn.Message,{children:["These experiments used different dataset versions (v",u.datasetVersion," vs v",d.datasetVersion,"). Results may not be directly comparable."]})}),h.length>0&&o.jsxs(hn,{children:[o.jsxs(hn.Header,{columns:m,children:[o.jsx(hn.HeaderCol,{children:"Scorer"}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(GLe,{children:[o.jsx(Ys,{color:"purple",size:"small",intensity:"muted",children:"Baseline"}),o.jsx(Ys,{color:"purple",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:o.jsxs(GLe,{children:[o.jsx(Ys,{color:"cyan",size:"small",intensity:"muted",children:"Contender"}),o.jsx(Ys,{color:"cyan",size:"small",children:"Avg"})]})}),o.jsx(hn.HeaderCol,{className:"flex justify-center",children:"Delta"})]}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:h.map(({scorerId:j,avgA:E,avgB:N,delta:I})=>o.jsxs(hn.Row,{columns:m,children:[o.jsx(hn.TextCell,{children:j}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:E!=null?E.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"text-center font-mono",children:N!=null?N.toFixed(3):"-"}),o.jsx(hn.TextCell,{className:"flex justify-center",children:I!=null?o.jsx(SEe,{delta:I}):"-"})]},j))})})]}),o.jsxs(Pv,{className:K({"grid-cols-[1fr_2fr]":!!v}),children:[o.jsx(gGr,{items:i.items,baselineId:_,contenderId:C,scorerIds:p,featuredItemId:s,columns:g,onItemClick:b}),!!v&&o.jsx(mGr,{item:v,baselineId:_,contenderId:C,baselineVersion:u?.datasetVersion,contenderVersion:d?.datasetVersion,onPrevious:O(),onNext:S(),onClose:w})]})]})}function bGr({datasetId:e,itemId:t,onVersionSelect:n,onCompareVersionsClick:r,activeVersion:s}){const{data:a,isLoading:i}=yEe(e,t),[l,c]=y.useState(!1),[u,d]=y.useState(new Set),f=b=>{n?.(b)},p=b=>s==null?b.isLatest:b.datasetVersion===s,h=b=>{d(w=>{const S=new Set(w);if(S.has(b))S.delete(b);else if(S.size>=2){const[O]=Array.from(S);return new Set([O,b])}else S.add(b);return S})},m=()=>{c(!1),d(new Set)},g=()=>{c(!0)},v=()=>{u.size===2&&r?.([...u])};return o.jsxs(Zr,{className:"min-w-56",children:[l?o.jsx(Zr.Toolbar,{className:"grid justify-stretch gap-3 w-full",children:o.jsxs($r,{children:[o.jsx(pe,{onClick:m,children:"Cancel"}),o.jsx(pe,{variant:"primary",disabled:u.size!==2,onClick:v,tooltip:u.size!==2?"Check 2 versions to compare":void 0,className:"grow",children:"Compare"})]})}):o.jsx(o.Fragment,{children:(a||[]).length>1&&o.jsx(Zr.Toolbar,{children:o.jsxs(pe,{onClick:g,className:"w-full",children:[o.jsx(Dw,{})," Compare Ver."]})})}),i?o.jsx(xGr,{}):o.jsxs(hn,{children:[o.jsx(hn.Header,{children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:a?.map(b=>{const w=String(b.datasetVersion),S=typeof b.updatedAt=="string"?new Date(b.updatedAt):b.updatedAt;return o.jsxs(hn.Row,{isSelected:l&&u.has(w),children:[l&&o.jsx(hn.LabelCell,{children:o.jsx(Go,{checked:u.has(w),disabled:b.isDeleted,onCheckedChange:()=>{},onClick:O=>{O.stopPropagation(),b.isDeleted||h(w)},"aria-label":`Select version ${b.datasetVersion}`})}),o.jsx(hn.RowButton,{item:b,columns:[{name:"version",label:"Item Version History",size:"1fr"}],isFeatured:p(b),onClick:()=>f(b),className:"py-2",children:o.jsx(hn.VersionCell,{version:b.datasetVersion,date:S,isLatest:b.isLatest,isDeleted:b.isDeleted})})]},String(b.datasetVersion))})})})]})]})}function xGr(){return o.jsxs(hn,{children:[o.jsx(hn.Header,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.HeaderCol,{children:"Item Version History"})}),o.jsx(hn.Items,{children:Array.from({length:3}).map((e,t)=>o.jsx(hn.Row,{children:o.jsx(hn.RowButton,{columns:[{name:"version",label:"Item Version History",size:"1fr"}],children:o.jsx(hn.TextCell,{isLoading:!0,children:"Loading..."})})},t))})]})}function wGr(e,t){if(t){const n=typeof t=="string"?new Date(t):t;return`v${e} ${Kn(n,"MMM dd 'at' H:mm:ss a")}`}return`v${e}`}function SGr({datasetId:e,versionA:t,versionB:n,onVersionChange:r}){const{data:s}=mEe(e),a=(s??[]).map(i=>({value:String(i.version),label:`${wGr(i.version,i.createdAt)}${i.isCurrent?" (current)":""}`}));return o.jsxs(Zr.Toolbar,{className:"grid grid-cols-[1fr_1fr_1fr_10rem] gap-4 w-full",children:[o.jsx("div",{}),o.jsx(ac,{label:"Version A",labelIsHidden:!0,name:"version-a",placeholder:"Select version",options:a,value:t??"",onValueChange:i=>r?.(i,n??"")}),o.jsx(ac,{label:"Version B",labelIsHidden:!0,name:"version-b",options:a,value:n??"",onValueChange:i=>r?.(t??"",i)}),o.jsx("div",{})]})}const kGr=[{name:"id",label:"ID",size:"1fr"},{name:"versionA",label:"Version A",size:"1fr"},{name:"versionB",label:"Version B",size:"1fr"},{name:"compare",label:"Compare",size:"10rem"}],OGr={added:{color:"blue",borderColor:"border-blue-900",icon:o.jsx(Ur,{}),tooltip:"Added in this version"},changed:{color:"orange",borderColor:"border-yellow-900",icon:o.jsx(Vat,{}),tooltip:"Changed in this version"},same:{color:"green",borderColor:"border-green-900",icon:o.jsx(Van,{}),tooltip:"Same in both versions"}};function qne({red:e=!1,tooltip:t}){return o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx(Asn,{className:K("text-neutral3/40 w-5 h-5 ",{"text-red-900":e})})}),t&&o.jsx(Hn,{children:t})]})}function RS({variant:e,version:t}){if(!e)return o.jsxs("span",{className:"text-ui-md text-neutral4",children:["v. ",t]});const{color:n,icon:r,tooltip:s}=OGr[e];return o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsxs("div",{className:"grid grid-cols-[1fr_auto]",children:[t!==void 0&&o.jsxs("span",{className:"pr-3 text-ui-md text-neutral4 min-w-16 flex justify-end",children:["v. ",t]}),o.jsx(Ys,{color:n,size:"small",children:r})]})}),o.jsx(Hn,{children:s})]})}function _Gr(e,t){return e&&t&&e.datasetVersion===t.datasetVersion?"same":e&&t&&e.datasetVersion!==t.datasetVersion?"changed":e?"added":"removed"}function CGr({datasetId:e,versionA:t,versionB:n,allItems:r,itemsAMap:s,itemsBMap:a}){const{Link:i}=vn(),l=t>n;return o.jsx(hn,{children:o.jsx(hn.Scroller,{children:o.jsx(hn.Items,{children:r.map(({id:c})=>{const u=s.get(c),d=a.get(c),f=_Gr(u,d);return o.jsxs(hn.Row,{columns:kGr,children:[o.jsx(hn.IdCell,{id:c,isShortened:!1}),f!=="same"?o.jsxs(o.Fragment,{children:[u?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!d&&l?o.jsx(RS,{variant:"added",version:u.datasetVersion}):f==="changed"&&l?o.jsx(RS,{variant:"changed",version:u.datasetVersion}):o.jsx(RS,{version:u.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(qne,{red:l,tooltip:l?"Deleted in this version":"Not present in this version"})}),d?.datasetVersion?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"gap-2",children:!u&&!l?o.jsx(RS,{variant:"added",version:d.datasetVersion}):f==="changed"&&!l?o.jsx(RS,{variant:"changed",version:d.datasetVersion}):o.jsx(RS,{version:d.datasetVersion})}):o.jsx(hn.Cell,{className:"justify-center flex items-center",children:o.jsx(qne,{red:!l,tooltip:l?"Not present in this version":"Deleted in this version"})})]}):o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}`,className:"col-span-2 gap-2",children:o.jsx(RS,{variant:"same",version:d?.datasetVersion})}),f==="changed"?o.jsx(hn.LinkCell,{LinkComponent:i,href:`/datasets/${e}/items/${c}/versions?ids=${u?.datasetVersion},${d?.datasetVersion}`,children:"Compare"}):o.jsx(hn.Cell,{children:o.jsx(qne,{tooltip:o.jsxs(o.Fragment,{children:["Comparing is available",o.jsx("br",{})," only for changed items"]})})})]},c)})})})})}const nWe={needsReview:"#facc15",complete:"#22c55e"},EGr=[{label:"Needs Review",color:nWe.needsReview},{label:"Reviewed",color:nWe.complete}];function jGr({reviewSummary:e,experiments:t,datasets:n,isLoading:r,isError:s}){const{data:a,maxVal:i,totalInPipeline:l}=y.useMemo(()=>{if(!e?.counts||!t)return{data:[],maxVal:0,totalInPipeline:0};const u=new Map;for(const m of t)u.set(m.id,m);const d=new Map;if(n)for(const m of n)d.set(m.id,m.name);let f=0,p=0;const h=[];for(const m of e.counts){const g=m.needsReview+m.complete;if(g===0)continue;p+=g,g>f&&(f=g);const v=u.get(m.experimentId),b=v?.datasetId?d.get(v.datasetId):void 0,w=b?`${b} · ${m.experimentId.slice(0,8)}`:m.experimentId.slice(0,8);h.push({name:w,values:[m.needsReview,m.complete]})}return{data:h,maxVal:f,totalInPipeline:p}},[e,t,n]),c=a.length>0;return o.jsxs(zt,{children:[o.jsxs(zt.TopBar,{children:[o.jsx(zt.TitleAndDescription,{title:"Review Pipeline",description:"Items in review across experiments."}),c&&o.jsx(zt.Summary,{value:String(l),label:"Items in pipeline"})]}),r?o.jsx(zt.Loading,{}):s?o.jsx(zt.Error,{message:"Failed to load review data"}):o.jsx(zt.Content,{children:c?o.jsx(aT,{data:a,segments:EGr,maxVal:i,fmt:u=>String(u)}):o.jsx(zt.NoData,{message:"No items have been sent to review yet"})})]})}function kEe(){const e=He();return xt({queryKey:["experiment-review-summary"],queryFn:()=>e.getExperimentReviewSummary()})}function D5t(e){const t=new Map;if(!e?.counts)return t;for(const n of e.counts)t.set(n.experimentId,{needsReview:n.needsReview,complete:n.complete,total:n.total});return t}function TGr(e,t){const n=new Map,r=D5t(e);if(!r.size||!t)return n;for(const s of t){const a=r.get(s.id);if(!a||!s.datasetId||a.needsReview+a.complete===0)continue;const l=n.get(s.datasetId)??{needsReview:0,complete:0};l.needsReview+=a.needsReview,l.complete+=a.complete,n.set(s.datasetId,l)}return n}function NGr(e){return e?.counts?e.counts.reduce((t,n)=>({needsReview:t.needsReview+n.needsReview,complete:t.complete+n.complete,inPipeline:t.inPipeline+n.needsReview+n.complete}),{needsReview:0,complete:0,inPipeline:0}):{needsReview:0,complete:0,inPipeline:0}}const IGr=10;function AGr(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,a]=y.useState("all"),[i,l]=y.useState("all"),[c,u]=y.useState("all"),[d,f]=y.useState(0),{data:p,isLoading:h,error:m}=wy({page:d,perPage:IGr}),{data:g,isLoading:v,error:b}=MZ(),{data:w}=kEe(),S=y.useMemo(()=>p?.datasets??[],[p?.datasets]),O=p?.pagination?.hasMore??!1,_=y.useMemo(()=>g?.experiments??[],[g?.experiments]),C=y.useMemo(()=>YWr(S),[S]),j=y.useMemo(()=>TGr(w,_),[w,_]),E=h||v,N=m||b,I=()=>t(!0),P=y.useCallback(()=>f(z=>z+1),[]),$=y.useCallback(()=>f(z=>Math.max(0,z-1)),[]),B=y.useCallback(z=>{r(z),f(0)},[]),D=y.useCallback(z=>{a(z),f(0)},[]),V=y.useCallback(z=>{l(z),f(0)},[]),H=y.useCallback(z=>{u(z),f(0)},[]);if(N&&cs(N))return o.jsx(or,{children:o.jsx(Ms,{})});if(N&&ds(N))return o.jsx(or,{children:o.jsx(ks,{resource:"datasets"})});if(N)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load datasets",message:N.message})});if(S.length===0&&!E&&d===0)return o.jsxs(o.Fragment,{children:[o.jsx(or,{children:o.jsx(tQr,{onCreateClick:I})}),o.jsx(fge,{open:e,onOpenChange:t})]});const L=s!=="all"||i!=="all"||c!=="all"||n!=="",F=()=>{r(""),a("all"),l("all"),u("all"),f(0)};return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx(rQr,{search:n,onSearchChange:B,targetFilter:s,onTargetFilterChange:D,experimentFilter:i,onExperimentFilterChange:V,tagFilter:c,onTagFilterChange:H,tagOptions:C,onReset:F,hasActiveFilters:L,onCreateClick:I})}),o.jsx(eQr,{datasets:S,experiments:_,reviewByDataset:j,isLoading:E,search:n,targetFilter:s,experimentFilter:i,tagFilter:c,currentPage:d,hasMore:O,onNextPage:P,onPrevPage:$}),o.jsx(fge,{open:e,onOpenChange:t})]})}function f8({children:e}){return o.jsxs(Dt,{height:"full",children:[o.jsx("div",{}),o.jsx(Dt.MainArea,{isCentered:!0,children:e})]})}function RGr(){const{datasetId:e}=vr(),t=Ks(),[n,r]=zi(),{activeVersion:s}=bEe(n,r),[a,i]=y.useState(!1),[l,c]=y.useState(!1),[u,d]=y.useState(!1),[f,p]=y.useState(!1),[h,m]=y.useState(!1),{data:g,error:v,isLoading:b}=Dx(e),{data:w=[],isLoading:S}=HO(e,void 0,s),O=!S&&w.length===0;if(b)return null;if(v&&cs(v))return o.jsx(f8,{children:o.jsx(Ms,{})});if(v&&ds(v))return o.jsx(f8,{children:o.jsx(ks,{resource:"datasets"})});if(v&&xSe(v)||!b&&!v&&!g)return o.jsx(f8,{children:o.jsx(Qr,{iconSlot:o.jsx(Uv,{}),titleSlot:"Dataset not found",descriptionSlot:`No dataset with id "${e}".`,actionSlot:o.jsxs(pe,{as:ui,to:"/datasets",children:[o.jsx(gc,{}),"Back to Datasets"]})})});if(v)return o.jsx(f8,{children:o.jsx(Di,{title:"Failed to load dataset",message:v instanceof Error?v.message:"An unexpected error occurred. Please try again."})});const _=j=>{t(`/datasets/${e}/experiments/${j}`)},C=()=>{t("/datasets")};return o.jsxs(o.Fragment,{children:[o.jsxs(Dt,{height:"full",children:[o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{children:[o.jsxs(Dt.Column,{children:[g?.description&&o.jsx("p",{className:"text-ui-smd text-neutral3 mb-1",children:g.description}),o.jsxs(Ft,{numOfCol:2,children:[o.jsx(Ft.Key,{children:"Created at"}),o.jsx(Ft.Value,{children:g?.createdAt?Kn(new Date(g.createdAt),"MMM d, yyyy"):""}),o.jsx(Ft.Key,{children:"Latest version"}),o.jsxs(Ft.Value,{children:["v",g?.version??""]})]})]}),o.jsx(Dt.Column,{children:o.jsxs($r,{children:[O?o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("span",{className:"cursor-not-allowed",children:o.jsx("div",{className:"pointer-events-none opacity-50",inert:!0,"aria-disabled":"true",children:o.jsxs(pe,{variant:"primary",children:[o.jsx(Lw,{}),s!=null?`Run on v${s}`:"Run Experiment"]})})})}),o.jsx(Hn,{children:"Add items to the dataset before running an experiment"})]}):o.jsxs(pe,{variant:"primary",onClick:()=>i(!0),children:[o.jsx(Lw,{}),s!=null?`Run on v${s}`:"Run Experiment"]}),o.jsxs(ft,{children:[o.jsx(ft.Trigger,{asChild:!0,children:o.jsx(pe,{size:"lg","aria-label":"Dataset actions menu",children:o.jsx(PM,{})})}),o.jsxs(ft.Content,{align:"end",className:"w-48",children:[o.jsxs(ft.Item,{onSelect:()=>d(!0),children:[o.jsx(Dh,{})," Edit Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>m(!0),children:[o.jsx(sf,{})," Duplicate Dataset"]}),o.jsxs(ft.Item,{onSelect:()=>p(!0),className:"text-red-500 focus:text-red-400",children:[o.jsx(Zc,{})," Delete Dataset"]})]})]})]})})]})}),o.jsx(Dt.MainArea,{children:o.jsx(GQr,{datasetId:e,onAddItemClick:()=>c(!0)})})]}),o.jsx(rGr,{datasetId:e,version:s??void 0,requestContextSchema:g?.requestContextSchema,open:a,onOpenChange:i,onSuccess:_}),o.jsx(XQr,{datasetId:e,open:l,onOpenChange:c}),g&&o.jsx(cQr,{open:u,onOpenChange:d,dataset:{id:g.id,name:g.name,description:g?.description||"",targetType:g.targetType,inputSchema:g.inputSchema,groundTruthSchema:g.groundTruthSchema,requestContextSchema:g.requestContextSchema}}),g&&o.jsx(iQr,{open:h,onOpenChange:m,sourceDatasetId:g.id,sourceDatasetName:g.name,sourceDatasetDescription:g.description,sourceDatasetTargetType:g.targetType}),g&&o.jsx(dQr,{open:f,onOpenChange:p,datasetId:g.id,datasetName:g.name,onSuccess:C})]})}function L5t({experiment:e}){const{Link:t,paths:n}=vn(),{data:r}=sm(),{data:s}=Ey(),{data:a}=Up(),i=()=>{switch(e.targetType){case"agent":return n.agentLink(e.targetId);case"workflow":return n.workflowLink(e.targetId);case"scorer":return n.scorerLink(e.targetId);default:return"#"}},l=()=>{const u=e.targetId;if(!u)return u;switch(e.targetType){case"agent":return r?.[u]?.name??u;case"workflow":return s?.[u]?.name??u;case"scorer":return a?.[u]?.scorer?.config?.name??u;default:return u}},c=e.agentVersion&&e.targetType==="agent"&&e.targetId?`${n.agentLink(e.targetId)}/editor?version=${encodeURIComponent(e.agentVersion)}`:null;return o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{children:[o.jsx(Dt.Column,{children:o.jsxs(Ft,{numOfCol:2,children:[o.jsx(Ft.Key,{children:"Created at"}),o.jsx(Ft.Value,{children:Kn(new Date(e.createdAt),"MMM d, yyyy 'at' h:mm a")}),e.completedAt&&o.jsxs(o.Fragment,{children:[o.jsx(Ft.Key,{children:"Completed at"}),o.jsx(Ft.Value,{children:Kn(new Date(e.completedAt),"MMM d, yyyy 'at' h:mm a")})]}),o.jsx(Ft.Key,{children:"Target"}),o.jsx(Ft.ValueLink,{href:i(),as:t,children:l()}),e.agentVersion&&o.jsxs(o.Fragment,{children:[o.jsx(Ft.Key,{children:"Version"}),c?o.jsx(Ft.ValueLink,{href:c,as:t,children:e.agentVersion}):o.jsx(Ft.Value,{children:e.agentVersion})]})]})}),o.jsx(Dt.Column,{children:o.jsx(pGr,{experiment:e})})]})})}function p8({children:e}){return o.jsxs(Dt,{height:"full",children:[o.jsx("div",{}),o.jsx(Dt.MainArea,{isCentered:!0,children:e})]})}function PGr(){const{datasetId:e,experimentId:t}=vr(),{data:n,isLoading:r,error:s}=PB(e,t),{data:a,isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u}=RZ({datasetId:e,experimentId:t,experimentStatus:n?.status});return!e||!t||r?null:s&&cs(s)?o.jsx(p8,{children:o.jsx(Ms,{})}):s&&ds(s)?o.jsx(p8,{children:o.jsx(ks,{resource:"datasets"})}):s&&xSe(s)||!r&&!s&&!n?o.jsx(p8,{children:o.jsx(Qr,{iconSlot:o.jsx(wve,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${t}".`,actionSlot:o.jsxs(pe,{as:ui,to:`/datasets/${e}?tab=experiments`,children:[o.jsx(gc,{}),"Back to Dataset"]})})}):s?o.jsx(p8,{children:o.jsx(Di,{title:"Failed to load experiment",message:s instanceof Error?s.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Dt,{height:"full",children:[o.jsx(L5t,{experiment:n}),o.jsx(Dt.MainArea,{children:o.jsx(M5t,{experimentId:t,datasetId:e,experimentStatus:n.status,results:a??[],isLoading:i,setEndOfListElement:l,isFetchingNextPage:c,hasNextPage:u})})]})}function $Gr(){const{datasetId:e}=vr(),[t,n]=zi(),{error:r}=Dx(e??""),s=t.get("baseline")??"",a=t.get("contender")??"";return r&&cs(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):r&&ds(r)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):!e||!s||!a?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsxs("div",{className:"text-neutral4 text-center py-8",children:[o.jsx("p",{children:"Select two experiments to compare."}),o.jsxs("p",{className:"text-sm mt-2",children:["Use the URL format: /datasets/","{datasetId}","/experiments?baseline=","{experimentIdA}","&contender=","{experimentIdB}"]})]})})}):o.jsx(ms,{children:o.jsx(Qv,{children:o.jsxs("div",{className:"max-w-[100rem] w-full px-12 mx-auto grid content-start ",children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Dw,{})," Dataset Experiments Comparison"]}),o.jsxs(la.Description,{children:["Comparing"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${s}`,children:s.slice(0,8)})," vs"," ",o.jsx(ui,{to:`/datasets/${e}/experiments/${a}`,children:a.slice(0,8)})]})]}),o.jsx(la.Column,{children:o.jsxs(pe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(gc,{}),"Back to Dataset"]})})]}),o.jsx(yGr,{datasetId:e,experimentIdA:s,experimentIdB:a,onSwap:()=>{n({baseline:a,contender:s})}})]})})})}function MGr(){const{datasetId:e,itemId:t}=vr(),{Link:n}=vn(),r=Ks(),{data:s,isLoading:a,error:i}=yEe(e??"",t??""),{updateItem:l,deleteItem:c}=Li(),{data:u}=Dx(e??""),d=s?.[0]??null,f=d?.isDeleted??!1,[p,h]=y.useState(null),m=y.useMemo(()=>!d||f?{input:"",groundTruth:"",metadata:"",trajectory:"",requestContext:""}:{input:JSON.stringify(d.input,null,2),groundTruth:d.groundTruth?JSON.stringify(d.groundTruth,null,2):"",metadata:d.metadata?JSON.stringify(d.metadata,null,2):"",trajectory:d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):"",requestContext:d.requestContext?JSON.stringify(d.requestContext,null,2):""},[d,f]),g=d?.datasetVersion??0,[v,b]=y.useState(!1),[w,S]=y.useState(m.input),[O,_]=y.useState(m.groundTruth),[C,j]=y.useState(m.metadata),[E,N]=y.useState(m.trajectory),[I,P]=y.useState(m.requestContext),[$,B]=y.useState(g);g!==$&&(B(g),S(m.input),_(m.groundTruth),j(m.metadata),N(m.trajectory),P(m.requestContext));const[D,V]=y.useState(!1),H=X=>{h(f?X:X.isLatest?null:X)},L=()=>{h(null)},F=!f&&p!=null,z=()=>{F||b(!0)},M=()=>{F||V(!0)},G=async()=>{if(!e||!t)return;let X;try{X=JSON.parse(w)}catch{Ue.error("Input must be valid JSON");return}let ne;if(O.trim())try{ne=JSON.parse(O)}catch{Ue.error("Ground Truth must be valid JSON");return}let ee;if(C.trim())try{ee=JSON.parse(C)}catch{Ue.error("Metadata must be valid JSON");return}let J;const ie=E!==m.trajectory;if(ie&&E.trim())try{J=JSON.parse(E)}catch{Ue.error("Expected Trajectory must be valid JSON");return}let ue;const Y=I!==m.requestContext;if(Y&&I.trim())try{ue=JSON.parse(I)}catch{Ue.error("Request Context must be valid JSON");return}try{await l.mutateAsync({datasetId:e,itemId:t,input:X,groundTruth:ne,metadata:ee,...ie?{expectedTrajectory:J??null}:{},...Y?{requestContext:ue}:{}}),Ue.success("Item updated successfully"),b(!1)}catch(te){Ue.error(`Failed to update item: ${te instanceof Error?te.message:"Unknown error"}`)}},U=()=>{d&&(S(JSON.stringify(d.input,null,2)),_(d.groundTruth?JSON.stringify(d.groundTruth,null,2):""),j(d.metadata?JSON.stringify(d.metadata,null,2):""),N(d.expectedTrajectory!=null?JSON.stringify(d.expectedTrajectory,null,2):""),P(d.requestContext?JSON.stringify(d.requestContext,null,2):"")),b(!1)},R=async()=>{if(!(!e||!t))try{await c.mutateAsync({datasetId:e,itemId:t}),Ue.success("Item deleted successfully"),V(!1),r(`/datasets/${e}`)}catch(X){Ue.error(`Failed to delete item: ${X instanceof Error?X.message:"Unknown error"}`)}},q=p??d,W=q?{id:t??"",datasetId:e??"",datasetVersion:q.datasetVersion,input:q.input,groundTruth:q.groundTruth,expectedTrajectory:q.expectedTrajectory,metadata:q.metadata,createdAt:q.createdAt,updatedAt:q.updatedAt}:null;return i&&cs(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):i&&ds(i)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):a?null:!e||!t||!s||s.length===0?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral3 p-4",children:"Item not found"})})}):o.jsxs(o.Fragment,{children:[o.jsx(ms,{children:o.jsx("div",{className:"h-full overflow-hidden px-6 pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[60rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(XT,{}),t," ",o.jsx(Pa,{content:t})]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:["Item of ",o.jsx(Uv,{})," ",u?.name]})}),o.jsxs(la.Description,{children:[o.jsxs(ic,{children:[o.jsx(Sat,{})," Created at"," ",d?.createdAt?Kn(new Date(d.createdAt),"MMM d, yyyy"):""]}),o.jsxs(ic,{children:[o.jsx(YO,{})," Latest version v",d?.datasetVersion??""]})]})]}),o.jsx(la.Column,{children:!v&&!f&&o.jsxs($r,{children:[o.jsxs(pe,{onClick:z,disabled:F,title:F?"Return to latest version to edit":void 0,children:[o.jsx(Vat,{})," Edit"]}),o.jsxs(pe,{onClick:M,disabled:F,title:F?"Return to latest version to delete":void 0,children:[o.jsx(Zc,{})," Delete"]})]})})]}),o.jsxs(Pv,{className:v?"grid-cols-1":"grid-cols-[1fr_auto]",children:[o.jsxs(Zr,{withRightSeparator:!v,children:[f&&d&&o.jsx(Rn,{variant:"destructive",title:"Item deleted",children:o.jsxs(Rn.Message,{children:["This item was deleted at version v",d.datasetVersion]})}),!f&&F&&p&&o.jsx(Rn,{variant:"warning",title:"Previous version",action:o.jsxs(Rn.Button,{onClick:L,children:[o.jsx(vat,{})," Return to the latest version"]}),children:o.jsxs(Rn.Message,{children:["Viewing version v",p.datasetVersion]})}),v?o.jsx(P5t,{inputValue:w,setInputValue:S,groundTruthValue:O,setGroundTruthValue:_,metadataValue:C,setMetadataValue:j,trajectoryValue:E,setTrajectoryValue:N,requestContextValue:I,setRequestContextValue:P,validationErrors:null,onSave:G,onCancel:U,isSaving:l.isPending}):W?o.jsx(wEe,{item:W,Link:n}):o.jsx("div",{className:"text-neutral4 text-sm",children:"Item data not available"})]}),!v&&o.jsx(Zr,{children:o.jsx(bGr,{datasetId:e,itemId:t,onClose:()=>{},onVersionSelect:H,onCompareVersionsClick:X=>{r(`/datasets/${e}/items/${t}/versions?ids=${X.join(",")}`)},activeVersion:p?.datasetVersion??null})})]})]})})}),o.jsx(jt,{open:D,onOpenChange:V,children:o.jsxs(jt.Content,{children:[o.jsxs(jt.Header,{children:[o.jsx(jt.Title,{children:"Delete Item"}),o.jsx(jt.Description,{children:"Are you sure you want to delete this item? This action cannot be undone."})]}),o.jsxs(jt.Footer,{children:[o.jsx(jt.Cancel,{children:"Cancel"}),o.jsx(jt.Action,{onClick:R,children:c.isPending?"Deleting...":"Delete"})]})]})})]})}function rWe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function DGr(){const{datasetId:e}=vr(),[t,n]=zi(),r=t.get("items")?.split(",").filter(Boolean)??[],{data:s,error:a}=Dx(e??""),{Link:i}=vn(),[l,c]=y.useState(!1),{data:u}=cge(e??"",r[0]??""),{data:d}=cge(e??"",r[1]??"");return a&&cs(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):a&&ds(a)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):!e||r.length<2?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two items to compare."})})})}):o.jsxs(ms,{children:[o.jsx(Sy,{owner:"dataset-items-compare",children:o.jsxs(pe,{as:ui,to:`/datasets/${e}`,variant:"outline",children:[o.jsx(gc,{}),"Back to Dataset"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":l}),children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Items"]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:["Comparing ",r.length," items of"," ",o.jsx(ui,{to:`/datasets/${e}`,className:"text-info1 hover:underline",children:s?.name||e?.slice(0,8)})]})})]}),o.jsx(la.Column,{children:o.jsx($r,{children:o.jsx(pe,{variant:"primary",onClick:()=>c(f=>!f),children:l?o.jsxs(o.Fragment,{children:[o.jsx(Tat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(Man,{})," Diff View"]})})})})]}),o.jsx(Pv,{className:"grid-cols-[1fr_3vw_1fr]",children:r.map((f,p)=>o.jsxs(y.Fragment,{children:[o.jsx(LGr,{datasetId:e,itemId:f,Link:i,idx:p,itemIds:r,showContent:!l,onItemChange:h=>{const m=[...r];m[p]=h,n({items:m.join(",")})}}),p==0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},f))}),l&&u&&d&&o.jsx(s0t,{codeA:rWe(u),codeB:rWe(d)})]})})]})}function LGr({datasetId:e,itemId:t,Link:n,idx:r,itemIds:s,onItemChange:a,showContent:i=!0}){const{data:l,isLoading:c}=cge(e,t),{data:u}=HO(e),d=new Set(s.filter((p,h)=>h!==r)),f=(u??[]).map(p=>({value:p.id,label:p.id,disabled:d.has(p.id)}));return o.jsxs(Zr,{children:[o.jsxs(Zr.Toolbar,{className:"flex gap-4",children:[o.jsxs($a,{name:`compare-item-${r}`,value:t,onValueChange:a,children:[o.jsx(Da,{"aria-label":"Item",children:o.jsx(Ma,{placeholder:"Select item"})}),o.jsx(La,{children:f.map(p=>o.jsx(Xr,{value:p.value,disabled:p.disabled,children:p.label},p.value))})]}),o.jsxs(pe,{as:n,to:`/datasets/${e}/items/${t}`,children:[o.jsx(YO,{}),"Versions"]})]}),i&&o.jsx(Zr.Content,{children:c?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):l?o.jsxs(o.Fragment,{children:[o.jsx(KQr,{item:l}),o.jsx(wEe,{item:l,Link:n})]}):o.jsxs("div",{className:"text-neutral4 text-sm",children:["Item ",t.slice(0,8)," not found"]})})]})}function sWe(e){return JSON.stringify({input:e.input??null,groundTruth:e.groundTruth??null,metadata:e.metadata??null},null,2)}function FGr(){const{datasetId:e,itemId:t}=vr(),[n,r]=zi(),[s,a]=y.useState(!1),i=n.get("ids")?.split(",").map(Number).filter(h=>!isNaN(h)&&h>0)??[],{data:l,error:c}=Dx(e??""),{Link:u}=vn(),{data:d}=yEe(e??"",t??""),{data:f}=hge(e??"",t??"",i[0]??0,l?.version),{data:p}=hge(e??"",t??"",i[1]??0,l?.version);return c&&cs(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})}):c&&ds(c)?o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})}):!e||!t||i.length<2?o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})}):o.jsxs(ms,{children:[o.jsx(Sy,{owner:"dataset-item-versions-compare",children:o.jsxs(pe,{as:ui,to:`/datasets/${e}/items/${t}`,variant:"outline",children:[o.jsx(gc,{}),"Back to Item"]})}),o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:K("grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",{"grid-rows-[auto_auto_1fr]":s}),children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Dw,{}),"Compare Dataset Item Versions"]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:["Comparing ",i.length," versions of"," ",o.jsx(ui,{to:`/datasets/${e}/items/${t}`,className:"text-info1 hover:underline",children:t})]})})]}),o.jsx(la.Column,{children:o.jsx($r,{children:o.jsx(pe,{variant:"primary",onClick:()=>a(h=>!h),children:s?o.jsxs(o.Fragment,{children:[o.jsx(Tat,{})," Default View"]}):o.jsxs(o.Fragment,{children:[o.jsx(vin,{})," Diff View"]})})})})]}),o.jsx(Pv,{className:"grid-cols-[1fr_3vw_1fr]",children:i.map((h,m)=>o.jsxs(y.Fragment,{children:[o.jsx(zGr,{datasetId:e,itemId:t,datasetVersion:h,latestVersion:l?.version,allVersions:d??[],versionNumbers:i,Link:u,idx:m,showContent:!s,onVersionChange:g=>{const v=[...i];v[m]=g,r({ids:v.join(",")})}}),m===0&&o.jsx("div",{className:K("bg-surface5 w-[3px] shrink-0 mx-[1.5vw]")})]},h))}),s&&f&&p&&o.jsx(s0t,{codeA:sWe(f),codeB:sWe(p)})]})})]})}function zGr({datasetId:e,itemId:t,datasetVersion:n,latestVersion:r,allVersions:s,versionNumbers:a,Link:i,idx:l,showContent:c=!0,onVersionChange:u}){const{data:d,isLoading:f}=hge(e,t,n,r),p=new Set(a.filter((g,v)=>v!==l)),h=s.map(g=>{const v=typeof g.updatedAt=="string"?new Date(g.updatedAt):g.updatedAt;return{value:String(g.datasetVersion),label:o.jsxs(o.Fragment,{children:[o.jsxs("b",{children:["v. ",g.datasetVersion]})," - ",Kn(v,"MMM d, yyyy h:mm a"),g.isLatest?o.jsx(Ys,{color:"blue",size:"small",children:"Latest"}):null]}),disabled:p.has(g.datasetVersion)}}),m=d?{id:d.id,datasetId:e,datasetVersion:d.datasetVersion,input:d.input,groundTruth:d.groundTruth,metadata:d.metadata,createdAt:d.createdAt,updatedAt:d.updatedAt}:null;return o.jsxs(Zr,{children:[o.jsxs(Zr.Toolbar,{className:"grid gap-4 grid-cols-[auto_1fr]",children:[o.jsx(YO,{className:"w-6 h-6 opacity-50"}),o.jsxs($a,{name:`compare-version-${l}`,value:String(n),onValueChange:g=>u(Number(g)),children:[o.jsx(Da,{"aria-label":"Version",className:"w-full",children:o.jsx(Ma,{placeholder:"Select version"})}),o.jsx(La,{children:h.map(g=>o.jsx(Xr,{value:g.value,disabled:g.disabled,children:g.label},g.value))})]})]}),c&&o.jsx(Zr.Content,{children:f?o.jsx("div",{className:"text-neutral4 text-sm",children:"Loading..."}):!d||!m?o.jsxs("div",{className:"text-neutral4 text-sm",children:["Version ",n," not found"]}):o.jsx(wEe,{item:m,Link:i})})]})}function BGr(){const{datasetId:e}=vr(),[t]=zi(),n=t.get("ids")?.split(",").map(Number).filter(g=>!isNaN(g)&&g>0)??[],r=Ks(),{data:s,error:a}=Dx(e??""),i=HO(e??"",void 0,n[0]??null),l=HO(e??"",void 0,n[1]??null),c=y.useMemo(()=>i.data??[],[i.data]),u=y.useMemo(()=>l.data??[],[l.data]),d=y.useMemo(()=>{const g=new Map;for(const v of[...c,...u])g.has(v.id)||g.set(v.id,{id:v.id,createdAt:new Date(v.createdAt)});return[...g.values()].sort((v,b)=>b.createdAt.getTime()-v.createdAt.getTime())},[c,u]),f=y.useMemo(()=>new Map(c.map(g=>[g.id,g])),[c]),p=y.useMemo(()=>new Map(u.map(g=>[g.id,g])),[u]);if(a&&cs(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})})});if(a&&ds(a))return o.jsx(ms,{children:o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"datasets"})})});if(!e||n.length<2)return o.jsx(ms,{children:o.jsx(Qv,{children:o.jsx("div",{className:"text-neutral4 text-center py-8",children:o.jsx("p",{children:"Select at least two versions to compare."})})})});const h=(g,v,b)=>{r(`/datasets/${e}/items/${g}/versions?ids=${v?.datasetVersion??""},${b?.datasetVersion??""}`)},m=(g,v)=>{r(`/datasets/${e}/versions?ids=${g},${v}`,{replace:!0})};return o.jsx(ms,{children:o.jsx("div",{className:"h-full overflow-hidden px-[3vw] pb-4",children:o.jsxs("div",{className:"grid gap-6 max-w-[140rem] mx-auto grid-rows-[auto_1fr] h-full",children:[o.jsxs(la,{children:[o.jsxs(la.Column,{children:[o.jsxs(la.Title,{children:[o.jsx(Uon,{})," Compare Dataset Versions"]}),o.jsx(la.Description,{children:o.jsxs(ic,{children:[o.jsx(YO,{})," Comparing ",n.length," versions of"," ",s?.name||e?.slice(0,8)]})})]}),o.jsx(la.Column,{children:o.jsxs(pe,{as:ui,to:`/datasets/${e}`,children:[o.jsx(gc,{}),"Back to Dataset"]})})]}),o.jsx(Pv,{children:o.jsxs(Zr,{children:[o.jsx(SGr,{datasetId:e,versionA:String(n[0]),versionB:String(n[1]),onVersionChange:m}),o.jsx(CGr,{datasetId:e,versionA:n[0],versionB:n[1],allItems:d,itemsAMap:f,itemsBMap:p,onItemClick:h})]})})]})})})}function UGr(e){if(!e||e.length<2)return null;const t=[...e].sort((i,l)=>new Date(i.createdAt).getTime()-new Date(l.createdAt).getTime()),n=Math.floor(t.length/2),r=n,s=t.length-n;if(r===0)return null;const a=(s-r)/r*100;return{changePct:Math.round(a*10)/10,prevValue:String(r)}}function qGr({scorers:e,datasets:t,experiments:n,avgScore:r,prevAvgScore:s,totalNeedsReview:a,isLoadingScorers:i,isLoadingDatasets:l,isLoadingExperiments:c,isLoadingScores:u,isLoadingReview:d}){const f=e?Object.keys(e).length:void 0,p=t?.length,h=n?.length,m=r!=null&&s!=null&&s!==0?{changePct:Math.round((r-s)/s*100*10)/10,prevValue:String(s)}:null,g=UGr(n);return o.jsxs(o.Fragment,{children:[o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Total Scorers"}),i?o.jsx(Yr.Loading,{}):f!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(f)}),o.jsx(Yr.NoChange,{message:"Static count"})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Total Datasets"}),l?o.jsx(Yr.Loading,{}):p!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(p)}),o.jsx(Yr.NoChange,{message:"Static count"})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Avg Score"}),u?o.jsx(Yr.Loading,{}):r!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(r)}),m?o.jsx(Yr.Change,{changePct:m.changePct,prevValue:m.prevValue}):o.jsx(Yr.NoChange,{})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Total Experiments"}),c?o.jsx(Yr.Loading,{}):h!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(h)}),g?o.jsx(Yr.Change,{changePct:g.changePct,prevValue:g.prevValue}):o.jsx(Yr.NoChange,{})]}):o.jsx(Yr.NoData,{})]}),o.jsxs(Yr,{children:[o.jsx(Yr.Label,{children:"Needs Review"}),d?o.jsx(Yr.Loading,{}):a!=null?o.jsxs(o.Fragment,{children:[o.jsx(Yr.Value,{children:String(a)}),a>0?o.jsx(Yr.NoChange,{message:"items pending review"}):o.jsx(Yr.NoChange,{message:"All caught up"})]}):o.jsx(Yr.NoData,{})]})]})}const aWe="auto 1fr auto auto auto auto auto auto auto";function VGr(e){return e?(typeof e=="string"?new Date(e):e).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}const HGr={completed:"success",running:"warning",failed:"error",pending:"neutral"};function ZGr({experiments:e,datasets:t,reviewByExperiment:n,isLoading:r,search:s="",statusFilter:a="all",datasetFilter:i="all"}){const{paths:l,Link:c}=vn(),u=y.useMemo(()=>{const p=new Map;return t?.forEach(h=>p.set(h.id,h.name)),p},[t]),d=y.useMemo(()=>[...e].sort((p,h)=>{const m=p.createdAt?new Date(p.createdAt).getTime():0;return(h.createdAt?new Date(h.createdAt).getTime():0)-m}),[e]),f=y.useMemo(()=>{const p=s.toLowerCase();return d.filter(h=>{const m=h.datasetId?u.get(h.datasetId)??"":"",g=!p||h.id.toLowerCase().includes(p)||m.toLowerCase().includes(p)||(h.targetId??"").toLowerCase().includes(p),v=a==="all"||h.status===a,b=i==="all"||h.datasetId===i;return g&&v&&b})},[d,s,u,a,i]);return r?o.jsx(Wo,{columns:aWe}):o.jsxs(xe,{columns:aWe,variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Experiment"}),o.jsx(xe.TopCell,{children:"Dataset"}),o.jsx(xe.TopCell,{children:"Target"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{className:"text-center",children:"Items"}),o.jsx(xe.TopCell,{className:"text-center",children:"Succeeded"}),o.jsx(xe.TopCell,{className:"text-center",children:"Failed"}),o.jsx(xe.TopCell,{className:"text-center",children:"Review"}),o.jsx(xe.TopCell,{children:"Date"})]}),f.map(p=>{const h=p.datasetId?u.get(p.datasetId)??p.datasetId.slice(0,8):"—",m=p.status??"pending",g=p.succeededCount??0,v=p.failedCount??0,b=p.totalItems??0,w=b>0?Math.round(g/b*100):0;return o.jsxs(xe.RowLink,{to:l.experimentLink(p.id),LinkComponent:c,children:[o.jsx(xe.NameCell,{className:"font-mono",children:p.id.slice(0,8)}),o.jsx(xe.TextCell,{children:h}),o.jsx(xe.Cell,{children:o.jsxs("span",{className:"truncate",children:[p.targetType," ",p.targetId]})}),o.jsx(xe.Cell,{children:o.jsx(_h,{variant:HGr[m]??"neutral",withDot:!0,children:m})}),o.jsx(xe.TextCell,{className:"text-center",children:b}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsxs("span",{className:g>0?"text-accent1":"",children:[g," (",w,"%)"]})}),o.jsx(xe.TextCell,{className:"text-center",children:o.jsx("span",{className:v>0?"text-accent2":"",children:v})}),o.jsx(xe.Cell,{className:"text-center",children:(()=>{const S=n?.get(p.id);if(!S)return o.jsx("span",{className:"text-neutral2",children:"—"});const O=S.needsReview+S.complete;return O===0?o.jsx("span",{className:"text-neutral2",children:"—"}):S.needsReview>0?o.jsxs(Ys,{size:"small",color:"yellow",children:[S.needsReview," pending"]}):o.jsxs(Ys,{size:"small",color:"green",children:[S.complete,"/",O," reviewed"]})})()}),o.jsx(xe.TextCell,{children:VGr(p.createdAt)})]},p.id)})]})}const WGr=[{value:"all",label:"All statuses"},{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"},{value:"pending",label:"Pending"}];function QGr(e){return[{value:"all",label:"All datasets"},...(e??[]).map(t=>({value:t.id,label:t.name}))]}const h8={completed:"#22c55e",running:"#facc15",pending:"#fb923c",failed:"#f87171"},GGr=[{label:"Completed",color:h8.completed},{label:"Running",color:h8.running},{label:"Pending",color:h8.pending},{label:"Failed",color:h8.failed}];function YGr({experiments:e,datasets:t,isLoading:n,isError:r}){const{data:s,maxVal:a}=y.useMemo(()=>{if(!e||e.length===0)return{data:[],maxVal:0};const l=new Map;if(t)for(const f of t)l.set(f.id,f.name);const c=new Map;for(const f of e){const p=f.datasetId??"unknown";c.has(p)||c.set(p,{completed:0,running:0,pending:0,failed:0});const h=c.get(p),m=f.status;m in h&&h[m]++}let u=0;return{data:Array.from(c.entries()).map(([f,p])=>{const h=p.completed+p.running+p.pending+p.failed;return h>u&&(u=h),{name:l.get(f)??f.slice(0,12),values:[p.completed,p.running,p.pending,p.failed]}}),maxVal:u}},[e,t]),i=s.length>0;return o.jsxs(zt,{children:[o.jsxs(zt.TopBar,{children:[o.jsx(zt.TitleAndDescription,{title:"Experiments by Dataset",description:"Experiment status breakdown per dataset."}),i&&o.jsx(zt.Summary,{value:String(e?.length??0),label:"Total experiments"})]}),n?o.jsx(zt.Loading,{}):r?o.jsx(zt.Error,{message:"Failed to load experiments data"}):o.jsx(zt.Content,{children:i?o.jsx(aT,{data:s,segments:GGr,maxVal:a,fmt:l=>String(l)}):o.jsx(zt.NoData,{message:"No experiments have been run yet"})})]})}const XGr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"No Experiments yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Run an experiment from a dataset to evaluate ",o.jsx("br",{}),"your agents and workflows."]}),actionSlot:o.jsx("div",{className:"flex flex-col items-center gap-2",children:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/en/docs/evals/datasets/running-experiments",target:"_blank",rel:"noopener noreferrer",children:["Experiments Documentation ",o.jsx(ja,{})]})})})});function KGr({search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:i,onReset:l,hasActiveFilters:c}){return o.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o.jsx(xf,{label:"Search experiments",placeholder:"Filter by experiment, dataset, or target",value:e,onSearch:t}),o.jsxs($r,{children:[o.jsx(ac,{label:"Status",labelIsHidden:!0,name:"filter-status",options:[...WGr],value:n,onValueChange:r,className:"whitespace-nowrap"}),o.jsx(ac,{label:"Dataset",labelIsHidden:!0,name:"filter-dataset",options:i,value:s,onValueChange:a,className:"whitespace-nowrap"}),l&&c&&o.jsxs(pe,{onClick:l,size:"sm",variant:"default",children:[o.jsx(ys,{className:"size-3"})," Reset"]})]})]})}function JGr(){const{data:e,isLoading:t,error:n}=Up(),{data:r,isLoading:s,error:a}=wy(),{data:i,isLoading:l,error:c}=MZ(),{data:u,isLoading:d,isError:f,error:p}=Bqr(),{data:h,isLoading:m,isError:g,error:v}=kEe(),b=r?.datasets,w=i?.experiments,S=y.useMemo(()=>NGr(h),[h]),O=n||a||c||p||v;return O&&cs(O)?o.jsx(or,{children:o.jsx(Ms,{})}):O&&ds(O)?o.jsx(or,{children:o.jsx(ks,{resource:"evaluation"})}):O?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load evaluation data",message:O.message})}):o.jsx(Dt,{width:"wide",height:"full",children:o.jsxs("div",{className:"flex flex-col gap-6",children:[o.jsx(gfe,{children:o.jsx(qGr,{scorers:e,datasets:b,experiments:w,avgScore:u?.avgScore??null,prevAvgScore:u?.prevAvgScore??null,totalNeedsReview:S.needsReview,isLoadingScorers:t,isLoadingDatasets:s,isLoadingExperiments:l,isLoadingScores:d,isLoadingReview:m})}),o.jsx(Iqr,{summaryData:u?.summaryData??[],overTimeData:u?.overTimeData??[],scorerNames:u?.scorerNames??[],avgScore:u?.avgScore??null,isLoading:d,isError:f}),o.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[o.jsx(nQr,{experiments:w,isLoading:l,isError:!!c}),o.jsx(YGr,{experiments:w,datasets:b,isLoading:l,isError:!!c})]}),o.jsx(jGr,{reviewSummary:h,experiments:w,datasets:b,isLoading:m,isError:!!g})]})})}function eYr(){const[e,t]=y.useState(""),[n,r]=y.useState("all"),[s,a]=y.useState("all"),{data:i,isLoading:l,error:c}=wy(),{data:u,isLoading:d,error:f}=MZ(),{data:p}=kEe(),h=y.useMemo(()=>i?.datasets??[],[i?.datasets]),m=y.useMemo(()=>u?.experiments??[],[u?.experiments]),g=y.useMemo(()=>QGr(h),[h]),v=y.useMemo(()=>D5t(p),[p]),b=l||d,w=f||c;if(w&&cs(w))return o.jsx(or,{children:o.jsx(Ms,{})});if(f&&ds(f))return o.jsx(or,{children:o.jsx(ks,{resource:"experiments"})});if(c&&ds(c))return o.jsx(or,{children:o.jsx(ks,{resource:"datasets"})});if(w)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load experiments",message:w.message})});if(m.length===0&&!b)return o.jsx(or,{children:o.jsx(XGr,{})});const S=n!=="all"||s!=="all"||e!=="",O=()=>{t(""),r("all"),a("all")};return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx(KGr,{search:e,onSearchChange:t,statusFilter:n,onStatusFilterChange:r,datasetFilter:s,onDatasetFilterChange:a,datasetOptions:g,onReset:O,hasActiveFilters:S})}),o.jsx(ZGr,{experiments:m,datasets:h,reviewByExperiment:v,isLoading:b,search:e,statusFilter:n,datasetFilter:s})]})}function m8({children:e}){return o.jsxs(Dt,{height:"full",children:[o.jsx("div",{}),o.jsx(Dt.MainArea,{isCentered:!0,children:e})]})}function tYr(){const{experimentId:e}=vr(),{data:t,isLoading:n}=MZ(),s=t?.experiments?.find(h=>h.id===e)?.datasetId??"",{data:a,isLoading:i,error:l}=PB(s,e??""),{data:c,isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p}=RZ({datasetId:s,experimentId:e??"",experimentStatus:a?.status});return!e||n||i?null:l&&cs(l)?o.jsx(m8,{children:o.jsx(Ms,{})}):l&&ds(l)?o.jsx(m8,{children:o.jsx(ks,{resource:"datasets"})}):l&&xSe(l)||!n&&!s||!i&&!l&&!a?o.jsx(m8,{children:o.jsx(Qr,{iconSlot:o.jsx(wve,{}),titleSlot:"Experiment not found",descriptionSlot:`No experiment with id "${e}".`,actionSlot:o.jsxs(pe,{as:ui,to:"/experiments",children:[o.jsx(gc,{}),"Back to Experiments"]})})}):l?o.jsx(m8,{children:o.jsx(Di,{title:"Failed to load experiment",message:l instanceof Error?l.message:"An unexpected error occurred. Please try again."})}):o.jsxs(Dt,{height:"full",children:[o.jsx(L5t,{experiment:a}),o.jsx(Dt.MainArea,{children:o.jsx(M5t,{experimentId:e,datasetId:s,experimentStatus:a.status,results:c??[],isLoading:u,setEndOfListElement:d,isFetchingNextPage:f,hasNextPage:p})})]})}function nYr({connection:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsxs("li",{className:"flex items-center justify-between border-b py-2",children:[o.jsxs("div",{children:[o.jsx("div",{className:"font-mono text-xs",children:e.connectionId}),o.jsxs("div",{className:"text-xs text-gray-500",children:[e.label??"(no label)"," · ",e.status,e.scope?` · ${e.scope}`:"",t&&e.authorId?` · author: ${e.authorId}`:""]})]}),o.jsx("button",{type:"button",className:"text-red-600 underline disabled:opacity-50",onClick:r,disabled:n,children:"Disconnect"})]})}function F5t({connections:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("ul",{className:"space-y-1",children:e.map(s=>o.jsx(nYr,{connection:s,isAdmin:t,disconnectPending:n,onDisconnect:()=>r(s.connectionId)},s.connectionId))})}function rYr({groups:e,isAdmin:t,disconnectPending:n,onDisconnect:r}){return o.jsx("div",{className:"space-y-4",children:e.map(([s,a])=>o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-semibold text-gray-700","data-testid":`integration-author-group-${s}`,children:s==="shared"?"Shared":`Owned by ${s}`}),o.jsx(F5t,{connections:a,isAdmin:t,disconnectPending:n,onDisconnect:r})]},s))})}function sYr({providerId:e,toolkit:t,connections:n,groupedByAuthor:r,isAdmin:s,isLoading:a,error:i,disconnectPending:l,disconnectError:c,onDisconnect:u}){return o.jsxs("div",{className:"space-y-2 border rounded p-4",children:[o.jsx("h2",{className:"text-lg font-semibold",children:"Existing connections"}),!e||!t?o.jsx("p",{className:"text-gray-500",children:"Pick a provider and toolkit to list connections."}):a?o.jsx("p",{className:"text-gray-500",children:"Loading…"}):i?o.jsx("p",{className:"text-red-600",children:String(i)}):n.length===0?o.jsx("p",{className:"text-gray-500",children:"No connections."}):r?o.jsx(rYr,{groups:r,isAdmin:s,disconnectPending:l,onDisconnect:u}):o.jsx(F5t,{connections:n,isAdmin:s,disconnectPending:l,onDisconnect:u}),c?o.jsx("p",{className:"text-red-600",children:String(c)}):null]})}function aYr({providers:e,toolkits:t,providerId:n,toolkit:r,label:s,providersLoading:a,providersError:i,toolkitsLoading:l,toolkitsError:c,authorizePending:u,authorizeError:d,authorizedConnection:f,onProviderChange:p,onToolkitChange:h,onLabelChange:m,onConnect:g}){return o.jsxs("div",{className:"space-y-4 border rounded p-4",children:[o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"provider-select",children:"Provider"}),o.jsxs("select",{id:"provider-select",className:"border rounded px-2 py-1 w-full",value:n,onChange:v=>p(v.target.value),disabled:a,children:[o.jsx("option",{value:"",children:"— select provider —"}),e.map(v=>o.jsxs("option",{value:v.id,children:[v.displayName??v.name," (",v.id,")"]},v.id))]}),a&&o.jsx("span",{className:"text-gray-500",children:"Loading providers…"}),i?o.jsx("span",{className:"text-red-600",children:String(i)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"toolkit-select",children:"Toolkit"}),o.jsxs("select",{id:"toolkit-select",className:"border rounded px-2 py-1 w-full",value:r,onChange:v=>h(v.target.value),disabled:!n||l,children:[o.jsx("option",{value:"",children:"— select toolkit —"}),t.map(v=>o.jsxs("option",{value:v.slug,children:[v.name," (",v.slug,")"]},v.slug))]}),l&&o.jsx("span",{className:"text-gray-500",children:"Loading toolkits…"}),c?o.jsx("span",{className:"text-red-600",children:String(c)}):null]}),o.jsxs("div",{className:"space-y-1",children:[o.jsx("label",{className:"block font-medium",htmlFor:"label-input",children:"Label (optional)"}),o.jsx("input",{id:"label-input",type:"text",className:"border rounded px-2 py-1 w-full",placeholder:"My personal Gmail",value:s,onChange:v=>m(v.target.value),disabled:!n||!r})]}),o.jsx("button",{type:"button",className:"bg-blue-600 text-white rounded px-4 py-2 disabled:opacity-50",onClick:g,disabled:!n||!r||u,children:u?"Authorizing…":"Connect"}),d?o.jsx("p",{className:"text-red-600",children:String(d)}):null,f&&o.jsxs("p",{className:"text-green-700",children:["Authorized: ",f.connectionId," (status: ",f.status,")"]})]})}const iWe=e=>e.authorId?.trim()||"shared",iYr=(e,t)=>{if(!t||new Set(e.map(iWe)).size<=1)return null;const r=new Map;for(const a of e){const i=iWe(a);r.set(i,[...r.get(i)??[],a])}const s=Array.from(r.entries());return s.sort(([a],[i])=>a==="shared"?1:i==="shared"?-1:a.localeCompare(i)),s},oYr=["*","tool-providers:*","tool-providers:admin"];function lYr(){const{data:e}=rm();return e?.permissions?.some(t=>oYr.includes(t))??!1}function cYr(){const[e,t]=y.useState(""),[n,r]=y.useState(""),[s,a]=y.useState(""),i=QN(),l=kH(e||null),c=$At(e||null,n||null),u=PAt(),d=AAt(),f=lYr(),p=i.data?.providers??[],h=l.data?.data??[],m=y.useMemo(()=>c.data?.items??[],[c.data?.items]),g=y.useMemo(()=>iYr(m,f),[m,f]),v=S=>{t(S),r("")},b=()=>{!e||!n||u.mutate({providerId:e,toolkit:n,label:s.trim()||null},{onSuccess:()=>{a(""),c.refetch()}})},w=S=>{d.mutate({providerId:e,connectionId:S})};return o.jsxs("div",{className:"p-6 max-w-3xl space-y-6 text-sm",children:[o.jsx("h1",{className:"text-2xl font-semibold",children:"Integrations"}),o.jsx("p",{className:"text-gray-500",children:"Minimal page to verify the ToolProvider backend. Pick a provider and toolkit, then connect."}),o.jsx(aYr,{providers:p,toolkits:h,providerId:e,toolkit:n,label:s,providersLoading:i.isLoading,providersError:i.error,toolkitsLoading:l.isLoading,toolkitsError:l.error,authorizePending:u.isPending,authorizeError:u.error,authorizedConnection:u.data,onProviderChange:v,onToolkitChange:r,onLabelChange:a,onConnect:b}),o.jsx(sYr,{providerId:e,toolkit:n,connections:m,groupedByAuthor:g,isAdmin:f,isLoading:c.isLoading,error:c.error,disconnectPending:d.isPending,disconnectError:d.error,onDisconnect:w})]})}function uYr({title:e,description:t,errorBanner:n,children:r}){return o.jsx("div",{"data-testid":"login-page",className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[o.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[o.jsx(Th,{className:"h-10 w-10"}),o.jsx("h1",{className:"text-xl font-semibold text-neutral6",children:e})]}),t,n,r]})})}function z5t({redirectUri:e,onSuccess:t,initialMode:n="signin",errorMessage:r}){const{data:s,isLoading:a}=Sc(),{mutate:i,isPending:l,error:c}=kRr(),{mutate:u,isPending:d,error:f}=_Rr(),{mutate:p,isPending:h}=eAt(),[m,g]=y.useState(n),[v,b]=y.useState(""),[w,S]=y.useState(""),[O,_]=y.useState("");if(a)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Loading..."})});if(!s?.enabled||!s?.login)return o.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface1",children:o.jsx("div",{className:"text-neutral3",children:"Authentication is not configured"})});const{login:C}=s,j=C.type==="sso"||C.type==="both",E=C.type==="credentials"||C.type==="both",N=C.sso,I=C.signUpEnabled!==!1,P=m==="signin"||!I,$=P?l:d,B=P?c:f,D=()=>{t?t():e?window.location.href=e:window.location.href="/"},V=M=>{M.preventDefault(),P?i({email:w,password:O},{onSuccess:D}):u({email:w,password:O,name:v||void 0},{onSuccess:D})},H=()=>{p({redirectUri:e},{onSuccess:M=>{window.location.href=M.url}})},L=()=>{g(P?"signup":"signin")},F=C.description?o.jsxs("div",{className:"flex items-start gap-2.5 rounded-md border border-border1 bg-surface1 p-3",children:[o.jsx(af,{className:"mt-0.5 h-4 w-4 shrink-0 text-neutral4"}),o.jsx("p",{className:"text-sm text-neutral3",children:C.description})]}):null,z=r?o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:r}):null;return o.jsxs(uYr,{title:P?"Sign in to Mastra Studio":"Create your account",description:F,errorBanner:z,children:[E&&o.jsxs("form",{onSubmit:V,className:"space-y-4",children:[!P&&o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"name",className:"block text-sm text-neutral4",children:"Name"}),o.jsx(kn,{id:"name",type:"text",value:v,onChange:M=>b(M.target.value),placeholder:"Your name",variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"email",className:"block text-sm text-neutral4",children:"Email"}),o.jsx(kn,{id:"email",type:"email",value:w,onChange:M=>S(M.target.value),placeholder:"you@example.com",required:!0,variant:"default",size:"lg"})]}),o.jsxs("div",{className:"space-y-2",children:[o.jsx("label",{htmlFor:"password",className:"block text-sm text-neutral4",children:"Password"}),o.jsx(kn,{id:"password",type:"password",value:O,onChange:M=>_(M.target.value),placeholder:P?"Enter your password":"Create a password",required:!0,variant:"default",size:"lg"})]}),B&&o.jsx("div",{className:"rounded-md bg-red-500/10 p-3 text-sm text-red-400",children:B.message}),o.jsx(pe,{type:"submit",disabled:$,className:"w-full",size:"lg",children:$?P?"Signing in...":"Creating account...":P?"Sign in":"Create account"}),I&&o.jsxs("div",{className:"text-center text-sm",children:[o.jsx("span",{className:"text-neutral3",children:P?"Don't have an account? ":"Already have an account? "}),o.jsx("button",{type:"button",onClick:L,className:"text-neutral6 hover:underline",children:P?"Sign up":"Sign in"})]})]}),j&&E&&o.jsxs("div",{className:"relative",children:[o.jsx("div",{className:"absolute inset-0 flex items-center",children:o.jsx("div",{className:"w-full border-t border-border1"})}),o.jsx("div",{className:"relative flex justify-center text-sm",children:o.jsx("span",{className:"bg-surface1 px-2 text-neutral3",children:"or continue with"})})]}),j&&N&&o.jsxs(pe,{onClick:H,disabled:h,className:"w-full",size:"lg",variant:"outline",children:[N.icon&&o.jsx("span",{className:"mr-2",children:N.icon}),h?"Redirecting...":N.text||"Sign in"]})]})}function dYr(){const[e]=zi(),t=Ks(),n=e.get("redirect")||"/",s=e.get("mode")==="signup"?"signup":"signin",a=e.get("error_description")||e.get("error")||null,i=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(z5t,{redirectUri:n,onSuccess:i,initialMode:s,errorMessage:a})}function fYr(){const[e,t]=zi(),n=Kvr(e,t),r=tyr(e,t),[s,a]=y.useState(),[i,l]=y.useState(!1),{data:c=[],isPending:u}=ASe(),{data:d=[],isPending:f}=RSe({entityType:n.selectedEntityOption?.entityType,rootOnly:!0}),{data:p=[],isPending:h}=PSe(),{data:m=[],isPending:g}=$Se(),v=y.useMemo(()=>wgr({availableTags:c,availableRootEntityNames:d,availableServiceNames:m,availableEnvironments:p,loading:{tags:u,entityNames:f,serviceNames:g,environments:h}}),[c,d,m,p,u,f,g,h]),b=y.useMemo(()=>_gr({rootEntityType:n.selectedEntityOption?.entityType,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,tokens:n.filterTokens}),[n.filterTokens,n.selectedDateFrom,n.selectedDateTo,n.selectedEntityOption]),{data:w=[],isLoading:S,error:O,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j}=Yvr({filters:b}),{logIdMap:E,featuredLog:N,handleLogClick:I,handlePreviousLog:P,handleNextLog:$}=syr(w,n.featuredLogId,n.handleFeaturedChange,n.featuredTraceId),{data:B,isLoading:D}=ISe(n.featuredTraceId??null),{data:V,isLoading:H}=iD(n.featuredTraceId??"",n.featuredSpanId??""),L=y.useCallback(()=>n.applyFilterTokens(Cgr(v,n.filterTokens)),[v,n]),F=y.useCallback(()=>n.handleFeaturedChange({logId:null}),[n]),z=y.useCallback(X=>n.handleFeaturedChange({traceId:X,spanId:null}),[n]),M=y.useCallback((X,ne)=>n.handleFeaturedChange({traceId:X,spanId:ne}),[n]),G=y.useCallback(()=>{n.handleFeaturedChange({traceId:null,spanId:null}),l(!1)},[n]),U=y.useCallback(()=>n.handleFeaturedChange({spanId:null}),[n]),R=y.useCallback(X=>n.handleFeaturedChange({spanId:X??null}),[n]),q=o.jsxs(Dt.TopArea,{children:[o.jsx(Dt.Row,{children:o.jsxs(Dt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Nwe,{preset:n.datePreset,onPresetChange:n.handleDatePresetChange,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo,onDateChange:n.handleDateChange,disabled:S,presets:["last-24h","last-3d","last-7d","last-14d","last-30d","custom"]}),o.jsx(s0e,{fields:v,tokens:n.filterTokens,onTokensChange:n.handleFilterTokensChange,disabled:S,onStartTextFilter:a})]})}),o.jsx(Uvr,{isLoading:S,filterFields:v,filterTokens:n.filterTokens,onFilterTokensChange:n.handleFilterTokensChange,onClear:L,onRemoveAll:n.handleRemoveAll,onSave:r.handleSave,onRemoveSaved:r.hasSavedFilters?r.handleRemoveSaved:void 0,autoFocusFilterFieldId:s})]});if(O)return o.jsxs(Dt,{width:"wide",height:"full",children:[q,o.jsx(Dt.MainArea,{isCentered:!0,children:o.jsx(Dvr,{error:O,resource:"logs",errorTitle:"Failed to load logs"})})]});const W=!!n.selectedEntityOption||n.filterTokens.length>0;return w.length===0&&!S&&!W?o.jsxs(Dt,{width:"wide",height:"full",children:[q,o.jsx(Dt.MainArea,{isCentered:!0,children:o.jsx(Zvr,{datePreset:n.datePreset,dateFrom:n.selectedDateFrom,dateTo:n.selectedDateTo})})]}):o.jsxs(Dt,{width:"wide",height:"full",children:[q,o.jsx(Lvr,{logCollapsed:i,listSlot:o.jsx(Bvr,{logs:w,isLoading:S,isFetchingNextPage:_,hasNextPage:C,setEndOfListElement:j,logIdMap:E,featuredLogId:n.featuredLogId,onLogClick:I}),logPanelSlot:N?o.jsx(Mvr,{log:N,onClose:F,onTraceClick:z,onSpanClick:M,onPrevious:P,onNext:$,collapsed:i,onCollapsedChange:l}):null,tracePanelSlot:n.featuredTraceId?o.jsx(lvr,{traceId:n.featuredTraceId,spans:B?.spans,isLoading:D,onClose:G,onSpanSelect:R,selectedSpanId:n.featuredSpanId}):null,spanPanelSlot:n.featuredTraceId&&n.featuredSpanId?o.jsx(ovr,{spanId:n.featuredSpanId,span:V?.span,isLoading:H,onClose:U}):null})]})}function pYr({server:e}){const{paths:t,Link:n}=vn(),s=He().options.baseUrl,a=s?`${s}/api/mcp/${e.id}/sse`:"",{data:i}=$4t(e),l=Object.values(i||{}),c=l.length,u=l.filter(p=>p.toolType==="agent").length,d=l.filter(p=>p.toolType==="workflow").length,f=Vh(e.name,50);return o.jsxs(xe.RowLink,{to:t.mcpServerLink(e.id),LinkComponent:n,children:[o.jsx(xe.NameCell,{children:f}),o.jsx(xe.DescriptionCell,{children:a}),o.jsx(xe.TextCell,{className:"text-center",children:u||""}),o.jsx(xe.TextCell,{className:"text-center",children:c||""}),o.jsx(xe.TextCell,{className:"text-center",children:d||""})]})}function hYr({mcpServers:e,isLoading:t,search:n=""}){const r=y.useMemo(()=>{const s=n.toLowerCase();return e.filter(a=>a.name?.toLowerCase().includes(s)||a.id?.toLowerCase().includes(s))},[e,n]);return t?o.jsx(Wo,{columns:"auto 1fr auto auto auto"}):o.jsxs(xe,{columns:"auto 1fr auto auto auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"URL"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Xo,{}),tooltip:"Agent Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Tools",short:o.jsx(cf,{}),tooltip:"Tools",className:"text-center"}),o.jsx(xe.TopCellSmart,{long:"Workflows",short:o.jsx(fd,{}),tooltip:"Workflow Tools",className:"text-center"})]}),r.length===0&&n?o.jsx(xe.NoMatch,{message:"No MCP Servers match your search"}):null,r.map(s=>o.jsx(pYr,{server:s},s.id))]})}const mYr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"No MCP Servers yet",descriptionSlot:o.jsxs(o.Fragment,{children:["MCP servers are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/tools-mcp/mcp-overview",target:"_blank",rel:"noopener noreferrer",children:["MCP Documentation ",o.jsx(ja,{})]})})}),gYr=()=>{const{data:e=[],isLoading:t,error:n}=CZ(),[r,s]=y.useState("");return n&&cs(n)?o.jsx(or,{children:o.jsx(Ms,{})}):n&&ds(n)?o.jsx(or,{children:o.jsx(ks,{resource:"MCP servers"})}):n?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load MCP servers",message:n.message})}):e.length===0&&!t?o.jsx(or,{children:o.jsx(mYr,{})}):o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx("div",{className:"max-w-120",children:o.jsx(xf,{onSearch:s,label:"Filter MCP servers",placeholder:"Filter by name"})})}),o.jsx(hYr,{mcpServers:e,isLoading:t,search:r})]})},vYr=(e,t)=>{const n=new Map,r=Object.keys(t);for(const s of r){const a=t[s],i=a.tools,l=Object.keys(i);for(const c of l){const u=i[c];n.has(u.id)||n.set(u.id,{...u,agents:[]}),n.get(u.id).agents.push({...a,id:s})}}for(const[s,a]of Object.entries(e))n.has(a.id)||n.set(a.id,{...a,agents:[]});return Array.from(n.values())};function yYr({tools:e,agents:t,isLoading:n,search:r=""}){const{paths:s,Link:a}=vn(),i=y.useMemo(()=>vYr(e,t),[e,t]),l=y.useMemo(()=>i.filter(c=>c.id.toLowerCase().includes(r.toLowerCase())),[i,r]);return n?o.jsx(Wo,{columns:"auto 1fr auto"}):o.jsxs(xe,{columns:"auto 1fr auto",variant:"striped",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Name"}),o.jsx(xe.TopCell,{children:"Description"}),o.jsx(xe.TopCellSmart,{long:"Agents",short:o.jsx(Xo,{}),tooltip:"Attached Agents",className:"text-center"})]}),l.length===0&&r?o.jsx(xe.NoMatch,{message:"No Tools match your search"}):null,l.map(c=>{const u=Vh(c.id,50),d=Vh(c.description??"",200),f=c.agents.length;return o.jsxs(xe.RowLink,{to:s.toolLink(c.id),LinkComponent:a,children:[o.jsx(xe.NameCell,{children:u}),o.jsx(xe.DescriptionCell,{children:d}),o.jsx(xe.TextCell,{className:"text-center",children:f||""})]},c.id)})]})}const bYr=()=>o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"No Tools yet",descriptionSlot:o.jsxs(o.Fragment,{children:["Mastra tools are not configured yet. ",o.jsx("br",{}),"More information in the documentation."]}),actionSlot:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/agents/using-tools-and-mcp",target:"_blank",rel:"noopener noreferrer",children:["Tools Documentation ",o.jsx(ja,{})]})})}),xYr=()=>{const e=He();return An({mutationFn:async({toolId:t,input:n,requestContext:r})=>{const s=new QO;Object.entries(r??{}).forEach(([a,i])=>{s.set(a,i)});try{return await e.getTool(t).execute({data:n,requestContext:s})}catch(a){throw Ue.error("Error executing dev tool"),console.error("Error executing dev tool:",a),a}}})},wYr=({toolId:e})=>{const{canExecute:t}=ul(),n=t("tools"),{data:r={}}=sm(),s=y.useMemo(()=>{for(const g of Object.values(r))if(g.tools){const v=Object.values(g.tools).find(b=>b.id===e);if(v)return v}return null},[r,e]),{data:a,isLoading:i,error:l}=$Ar(e,{enabled:!s}),c=s||a,{mutateAsync:u,isPending:d,data:f}=xYr(),{requestContext:p}=Os();y.useEffect(()=>{if(l){const g=l instanceof Error?l.message:"Failed to load tool";Ue.error(`Error loading tool: ${g}`)}},[l]);const h=async(g,v)=>{if(!c)return;const b={...p??{},...v??{}};return u({toolId:c.id,input:g,requestContext:b})},m=c?.inputSchema?hg(fg(px(c?.inputSchema))):ws({});return i?o.jsxs("div",{className:"p-6",children:[o.jsx(_n,{className:"h-8 w-48 mb-4"}),o.jsx(_n,{className:"h-32 w-full"})]}):l?null:c?n?o.jsx(lEe,{executionResult:f,isExecutingTool:d,zodInputSchema:m,handleExecuteTool:h,toolDescription:c.description,toolId:c.id,requestContextSchema:c.requestContextSchema}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})}):o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})})};function SYr({value:e,onValueChange:t,placeholder:n="Select a tool...",searchPlaceholder:r="Search tools...",emptyText:s="No tools found.",className:a,disabled:i=!1,variant:l}){const{data:c={},isLoading:u,isError:d,error:f}=WN(),{data:p={},isLoading:h,isError:m,error:g}=sm(),{navigate:v,paths:b}=vn();y.useEffect(()=>{if(d){const _=f instanceof Error?f.message:"Failed to load tools";Ue.error(`Error loading tools: ${_}`)}},[d,f]),y.useEffect(()=>{if(m){const _=g instanceof Error?g.message:"Failed to load agents";Ue.error(`Error loading agents: ${_}`)}},[m,g]);const w=new Map;Object.values(p).forEach(_=>{_.tools&&Object.values(_.tools).forEach(C=>{w.has(C.id)||w.set(C.id,C)})}),Object.values(c).forEach(_=>{w.has(_.id)||w.set(_.id,_)});const S=Array.from(w.values()).map(_=>({label:_.id,value:_.id})),O=_=>{t?t(_):_&&_!==e&&v(b.toolLink(_))};return o.jsx(Hc,{options:S,value:e,onValueChange:O,placeholder:u||h?"Loading tools...":n,searchPlaceholder:r,emptyText:s,className:a,disabled:i||u||h||d||m,variant:l})}const kYr=({isLoading:e,server:t})=>{const[{sseUrl:n,httpStreamUrl:r},s]=y.useState({sseUrl:"",httpStreamUrl:""});if(y.useEffect(()=>{if(!t)return;const i=window.MASTRA_SERVER_HOST,l=window.MASTRA_SERVER_PORT;let c=null;i&&l&&(c=`http://${i}:${l}`);const u=c||"http://localhost:4111",d=`${u}/api/mcp/${t.id}/sse`,f=`${u}/api/mcp/${t.id}/mcp`;s({sseUrl:d,httpStreamUrl:f})},[t]),e)return null;if(!t)return o.jsx(Qv,{children:o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral3 font-medium py-20 text-center",children:"Server not found"})});const a=`npx -y mcp-remote ${n}`;return o.jsxs(Qv,{isDivided:!0,children:[o.jsxs("div",{className:"px-8 py-12 mx-auto max-w-2xl w-full",children:[o.jsx(ge,{as:"h1",variant:"header-md",className:"text-neutral6 font-medium pb-4",children:t.name}),o.jsxs("div",{className:"flex items-center gap-1 pb-6",children:[o.jsx(Jt,{icon:o.jsx(J_t,{className:"text-neutral6"}),className:"rounded-r-sm text-neutral4!",children:"Version"}),o.jsx(Jt,{className:"rounded-l-sm text-neutral4!",children:t.version_detail.version})]}),o.jsx(ge,{className:"text-neutral3 pb-4",children:"This MCP server can be accessed through multiple transport methods. Choose the one that best fits your use case."}),o.jsxs("div",{className:"flex flex-col gap-4",children:[o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(Jt,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"HTTP"}),children:"Regular HTTP Endpoint"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for stateless HTTP transport with streamable responses."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:r}),o.jsx("div",{className:"pt-1",children:o.jsx(Pa,{tooltip:"Copy HTTP Stream URL",content:r})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(Jt,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"SSE"}),children:"Server-Sent Events"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for real-time communication via SSE."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:n}),o.jsx("div",{className:"pt-1",children:o.jsx(Pa,{tooltip:"Copy SSE URL",content:n})})]})]}),o.jsxs("div",{className:"rounded-lg border border-border1 bg-surface3 p-4",children:[o.jsx(Jt,{icon:o.jsx("span",{className:"font-mono w-6 text-accent1 font-medium mr-1",children:"CLI"}),children:"Command Line"}),o.jsx(ge,{className:"text-neutral3 pt-1 pb-2",children:"Use for local command-line access via npx and mcp-remote."}),o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(ge,{className:"px-2 py-1 bg-surface4 rounded-lg",children:a}),o.jsx("div",{className:"pt-1",children:o.jsx(Pa,{tooltip:"Copy Command Line Config",content:a})})]})]})]})]}),o.jsx("div",{className:"h-full overflow-y-scroll border-l border-border1",children:o.jsx(OYr,{server:t})})]})},OYr=({server:e})=>{const{data:t={},isLoading:n}=$4t(e);if(n)return null;const r=Object.keys(t);return o.jsxs("div",{className:"p-5 overflow-y-scroll",children:[o.jsxs("div",{className:"text-neutral6 flex gap-2 items-center",children:[o.jsx(Ge,{size:"lg",className:"bg-surface4 rounded-md p-1",children:o.jsx(t1,{})}),o.jsx(ge,{variant:"header-md",as:"h2",className:"font-medium",children:"Available Tools"})]}),o.jsx("div",{className:"flex flex-col gap-2 pt-6",children:r.map(s=>{const a=t[s];return o.jsx(CYr,{tool:a,serverId:e.id},s)})})]})};function _Yr(e){if(!e)return!1;const t=e.ui;return!!(typeof t?.resourceUri=="string"&&t.resourceUri.startsWith("ui://")||typeof e["ui/resourceUri"]=="string"&&e["ui/resourceUri"].startsWith("ui://"))}const CYr=({tool:e,serverId:t})=>{const n=y.useRef(null),{Link:r,paths:s}=vn(),a=K4t[e.toolType||"tool"],i=_Yr(e._meta);return o.jsxs(gf,{onClick:()=>n.current?.click(),children:[o.jsx(cht,{children:o.jsx(a,{className:"group-hover/entity:text-accent6"})}),o.jsxs(yf,{children:[o.jsx(vf,{children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(r,{ref:n,href:s.mcpServerToolLink(t,e.id),children:e.id}),i&&o.jsx(Jt,{className:"text-[10px] py-0",children:"App"})]})}),o.jsx(Mp,{children:e.description})]})]})},EYr=()=>{const{serverId:e}=vr(),{data:t=[],isLoading:n}=CZ(),r=t.find(s=>s.id===e);return o.jsx("div",{className:"h-full w-full overflow-hidden",children:o.jsx(kYr,{isLoading:n,server:r})})};function jYr(e){if(!e)return;const t=e.ui;if(t?.resourceUri)return t.resourceUri;const n=e["ui/resourceUri"];if(typeof n=="string")return n}const TYr=({toolId:e,serverId:t})=>{const{canExecute:n}=ul(),r=n("tools"),s=He(),{data:a,isLoading:i,error:l}=KCe(t,e),{mutateAsync:c,isPending:u,data:d}=qBr(t,e),f=a?jYr(a._meta):void 0,{data:p}=xt({queryKey:["mcp-app-resource",t,f],queryFn:async()=>f?(await s.readMcpServerResource(t,f)).contents[0]?.text??null:null,enabled:!!f}),h=y.useCallback(async(v,b)=>await c(b),[c]);y.useEffect(()=>{if(l){const v=l instanceof Error?l.message:"Failed to load tool";Ue.error(`Error loading tool: ${v}`)}},[l]);const m=async v=>{if(a)return await c(v)};if(i)return o.jsxs("div",{className:"p-6",children:[o.jsx(_n,{className:"h-8 w-48 mb-4"}),o.jsx(_n,{className:"h-32 w-full"})]});if(l)return null;if(!a)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"header-md",className:"text-neutral3",children:"Tool not found"})});if(!r)return o.jsx("div",{className:"py-12 text-center px-6",children:o.jsx(ge,{variant:"ui-sm",className:"text-neutral3",children:"You don't have permission to execute tools."})});let g;try{g=hg(fg(a.inputSchema))}catch(v){console.error("Error processing input schema:",v),Ue.error("Failed to process tool input schema."),g=ws({})}return o.jsxs("div",{className:"flex flex-col gap-4",children:[p&&o.jsx("div",{className:"border-b border-border1 p-4",children:o.jsx(P4t,{html:p,toolName:a.name??a.id,onToolCall:h})}),o.jsx(lEe,{executionResult:d,isExecutingTool:u,zodInputSchema:g,handleExecuteTool:m,toolDescription:a.description||"",toolId:a.id})]})},NYr=()=>{const{serverId:e,toolId:t}=vr(),{data:n,isLoading:r}=KCe(e,t);return r||!n?null:o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(TYr,{toolId:t,serverId:e})})},oWe={agents:Ps.AGENT,workflows:Ps.WORKFLOW_RUN,tools:Ps.TOOL};function IYr(){const{data:e,isLoading:t,isError:n}=agr(),{getTracesHref:r,getBucketTracesHref:s}=VN(),{Link:a}=vn(),i=Ks();return o.jsx(Hmr,{data:e,isLoading:t,isError:n,onPointClick:(l,c)=>{Number.isFinite(c.tsMs)&&i(s({rootEntityType:oWe[l]},c.tsMs,"1h"))},actions:l=>o.jsx(nD,{href:r({rootEntityType:oWe[l]}),LinkComponent:a})})}function AYr(){const e=hgr(),t=mgr(),{getTracesHref:n}=VN(),{Link:r}=vn();return o.jsx(Wmr,{threads:{data:e.data,isLoading:e.isLoading,isError:e.isError},resources:{data:t.data,isLoading:t.isLoading,isError:t.isError},LinkComponent:r,getThreadRowHref:s=>n({threadId:s.threadId,...s.resourceId?{resourceId:s.resourceId}:{}}),getResourceRowHref:s=>n({resourceId:s.resourceId})})}function RYr(){const{data:e,isLoading:t,isError:n}=vCt();return o.jsx(rD,{label:"Total Agent Runs",value:e?.value!=null?e.value.toLocaleString():null,prevValue:e?.previousValue!=null?e.previousValue.toLocaleString():void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function PYr(){const{data:e,isLoading:t,isError:n}=ngr();return o.jsx(rD,{label:"Total Model Cost",value:e?.cost!=null?Xm(e.cost,e.costUnit):null,prevValue:e?.previousCost!=null?Xm(e.previousCost,e.costUnit):void 0,changePct:e?.costChangePercent??null,isLoading:t,isError:n})}function $Yr(){const{data:e,isLoading:t,isError:n}=rgr();return o.jsx(rD,{label:"Total Tokens",value:e?.value!=null?sc(e.value):null,prevValue:e?.previousValue!=null?sc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function MYr(){const{data:e,isLoading:t,isError:n}=fgr();return o.jsx(rD,{label:"Total Threads",value:e?.value!=null?sc(e.value):null,prevValue:e?.previousValue!=null?sc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function DYr(){const{data:e,isLoading:t,isError:n}=pgr();return o.jsx(rD,{label:"Total Resources",value:e?.value!=null?sc(e.value):null,prevValue:e?.previousValue!=null?sc(e.previousValue):void 0,changePct:e?.changePercent??null,isLoading:t,isError:n})}function LYr({onClear:e,onRemoveAll:t,onSave:n,onRemoveSaved:r,isLoading:s,filterFields:a,filterTokens:i,onFilterTokensChange:l,autoFocusFilterFieldId:c}){const u=i.length>0,d=i.some(f=>FYr(f,a));return o.jsxs("div",{className:K("grid grid-cols-[1fr_auto] gap-3 items-start"),children:[o.jsx(r0e,{fields:a,tokens:i,onTokensChange:l,disabled:s,autoFocusFieldId:c}),u&&o.jsx(t0e,{disabled:s,onClear:d?e:void 0,onRemoveAll:t,onSave:n,onRemoveSaved:r})]})}function FYr(e,t){const n=t.find(r=>r.id===e.fieldId);return n?n.kind==="text"?typeof e.value=="string"&&e.value.trim()!=="":n.kind==="pick-multi"?n.multi?Array.isArray(e.value)&&e.value.length>0:typeof e.value=="string"&&e.value!==""&&e.value!=="Any":n.kind==="multi-select"?Array.isArray(e.value)&&e.value.length>0:!1:!1}function zYr(){const{data:e,isLoading:t,isError:n}=sgr(),{getTracesHref:r}=VN(),{Link:s}=vn();return o.jsx(Qmr,{rows:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:()=>r({rootEntityType:Ps.AGENT}),actions:o.jsx(nD,{href:r({rootEntityType:Ps.AGENT}),LinkComponent:s})})}function BYr(){const{data:e,isLoading:t,isError:n}=ogr(),{getTracesHref:r}=VN(),{Link:s}=vn();return o.jsx(Ymr,{data:e,isLoading:t,isError:n,LinkComponent:s,getRowHref:a=>r({rootEntityType:Ps.AGENT,entityName:a.name}),actions:o.jsx(nD,{href:r({rootEntityType:Ps.AGENT}),LinkComponent:s})})}function UYr(){const{data:e,isLoading:t,isError:n}=dgr(),{getTracesHref:r}=VN(),{Link:s}=vn();return o.jsx(Jmr,{data:e?.data,interval:e?.interval,isLoading:t,isError:n,actions:o.jsx(nD,{href:r(),LinkComponent:s})})}const g8={agents:Ps.AGENT,workflows:Ps.WORKFLOW_RUN,tools:Ps.TOOL};function qYr(){const{data:e,isLoading:t,isError:n}=igr(),{getTracesHref:r,getLogsHref:s}=VN(),{Link:a}=vn();return o.jsx(egr,{data:e,isLoading:t,isError:n,LinkComponent:a,getRowHref:(i,l)=>r({rootEntityType:g8[i],entityName:l.name}),getErrorSegmentHref:(i,l)=>l.errors>0?s({rootEntityType:g8[i],entityName:l.name,status:"error"}):void 0,actions:i=>o.jsxs(o.Fragment,{children:[o.jsx(nD,{href:r({rootEntityType:g8[i]}),LinkComponent:a}),o.jsx(qmr,{href:s({rootEntityType:g8[i],status:"error"}),LinkComponent:a})]})})}const VYr=new Set(["ObservabilityStorageClickhouseVNext","ObservabilityStorageDuckDB","ObservabilityInMemory","ObservabilitySpanner"]),Vne="period",v8="dateFrom",y8="dateTo";function HYr(){const[e,t]=zi(),n=e.get(Vne),r=Mmr(n)?n:"24h",s=y.useMemo(()=>{if(r!=="custom")return;const d=h=>{if(!h)return;const m=new Date(h);return Number.isNaN(m.getTime())?void 0:m},f=d(e.get(v8)),p=d(e.get(y8));if(!(!f&&!p))return{from:f,to:p}},[r,e.toString()]),a=y.useMemo(()=>Tmr(e),[e.toString()]),i=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d==="24h"?p.delete(Vne):p.set(Vne,d),d!=="custom"&&(p.delete(v8),p.delete(y8)),p},{replace:!0})},[t]),l=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return d?.from?p.set(v8,d.from.toISOString()):p.delete(v8),d?.to?p.set(y8,d.to.toISOString()):p.delete(y8),p},{replace:!0})},[t]),c=y.useCallback(d=>{t(f=>{const p=new URLSearchParams(f);return Imr(p,d),p},{replace:!0})},[t]),u=y.useRef(!1);return y.useEffect(()=>{if(u.current||(u.current=!0,Emr(e)))return;const d=hCt();d&&t(f=>{const p=new URLSearchParams(f);for(const[h,m]of d)p.append(h,m);return p},{replace:!0})},[]),o.jsx(Lmr,{preset:r,filterTokens:a,onPresetChange:i,onFilterTokensChange:c,customRange:s,onCustomRangeChange:l,children:o.jsx(ZYr,{})})}function ZYr(){const[e]=zi(),{error:t,isLoading:n}=vCt(),{filterTokens:r,setFilterTokens:s}=qV(),[a,i]=y.useState(),{data:l,isLoading:c}=i4(),u=l?.observabilityStorageType,d=u?VYr.has(u):!1,f=u==="ObservabilityInMemory",{data:p,isLoading:h}=ASe(),{data:m,isLoading:g}=RSe(),{data:v,isLoading:b}=$Se(),{data:w,isLoading:S}=PSe(),O=y.useMemo(()=>jmr({availableTags:p??[],availableEntityNames:m??[],availableServiceNames:v??[],availableEnvironments:w??[],loading:{tags:h,entityNames:g,serviceNames:b,environments:S}}),[p,m,v,w,h,g,b,S]),[_,C]=y.useState(()=>hCt()!==null),j=y.useCallback(()=>{_mr(e),C(!0),Ue.success("Filters setting for Metrics saved")},[e]),E=y.useCallback(()=>{Cmr(),C(!1),Ue.success("Filters setting for Metrics cleared up")},[]),N=y.useCallback(()=>{s([])},[s]),I=y.useCallback(()=>{const P=r.map($=>{const B=O.find(D=>D.id===$.fieldId);return B?B.kind==="text"?{fieldId:$.fieldId,value:""}:B.kind==="pick-multi"?B.multi?{fieldId:$.fieldId,value:[]}:{fieldId:$.fieldId,value:"Any"}:B.kind==="multi-select"?{fieldId:$.fieldId,value:[]}:$:$});s(P)},[O,r,s]);return t&&cs(t)?o.jsx(or,{children:o.jsx(Ms,{})}):t&&ds(t)?o.jsx(or,{children:o.jsx(ks,{resource:"metrics"})}):t?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load metrics",message:t.message})}):o.jsxs(Dt,{width:"wide",height:"full",children:[o.jsxs(Dt.TopArea,{children:[o.jsx(Dt.Row,{children:o.jsxs(Dt.Column,{className:"flex flex-wrap items-start justify-start gap-2",children:[o.jsx(Umr,{}),o.jsx(s0e,{fields:O,tokens:r,onTokensChange:s,disabled:n,onStartTextFilter:i})]})}),o.jsx(LYr,{isLoading:n,filterFields:O,filterTokens:r,onFilterTokensChange:s,onClear:I,onRemoveAll:N,onSave:j,onRemoveSaved:_?E:void 0,autoFocusFilterFieldId:a})]}),c?null:d?o.jsxs("div",{className:"grid gap-8 content-start pb-10",children:[f&&o.jsx(Rn,{variant:"info",title:"Metrics are not persisted",children:o.jsx(Rn.Message,{children:"This project uses in-memory storage for observability. Metrics will be lost on every server restart. For persistent metrics, switch the observability storage to ClickHouse, DuckDB, or Spanner."})}),o.jsxs(gfe,{children:[o.jsx(RYr,{}),o.jsx(PYr,{}),o.jsx($Yr,{}),o.jsx(MYr,{}),o.jsx(DYr,{})]}),o.jsxs(gfe,{children:[o.jsx(zYr,{}),o.jsx(BYr,{}),o.jsx(UYr,{}),o.jsx(AYr,{}),o.jsx(qYr,{}),o.jsx(IYr,{})]})]}):o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Qr,{iconSlot:o.jsx(ff,{}),titleSlot:"Metrics are not available with your current storage",descriptionSlot:"Metrics require ClickHouse, DuckDB, Spanner, or in-memory storage for observability. Relational databases (PostgreSQL, LibSQL) do not support metrics collection. To enable metrics on an existing project, switch the observability storage in the Mastra configuration.",actionSlot:o.jsxs(pe,{variant:"ghost",as:"a",href:"https://mastra.ai/docs/observability/metrics/overview",target:"_blank",rel:"noopener noreferrer",children:["Metrics Documentation ",o.jsx(ja,{})]})})})]})}function WYr(){const{paths:e}=vn(),{data:t,isLoading:n,error:r}=J4t(),{isCmsAvailable:s}=c4(),[a,i]=y.useState(""),l=t?.promptBlocks??[];return r&&cs(r)?o.jsx(or,{children:o.jsx(Ms,{})}):r&&ds(r)?o.jsx(or,{children:o.jsx(ks,{resource:"prompt blocks"})}):r?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load prompt blocks",message:r.message})}):l.length===0&&!n?o.jsx(or,{children:o.jsx(NVr,{})}):o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(xf,{onSearch:i,label:"Filter prompts",placeholder:"Filter by name or description"})}),s&&o.jsxs(pe,{as:ui,to:e.cmsPromptBlockCreateLink(),variant:"primary",className:"shrink-0",children:[o.jsx(Ur,{}),"Create Prompt"]})]})}),o.jsx(TVr,{promptBlocks:l,isLoading:n,search:a})]})}function QYr(){return o.jsx(Dt,{width:"narrow",children:o.jsx(Dt.MainArea,{children:o.jsx(mUr,{children:o.jsx(D4t,{})})})})}const GYr=[{title:"Mastra APIs",description:"Explore and test the available REST API endpoints with the interactive Swagger UI.",icon:Ban,href:"/swagger-ui",external:!1},{title:"Documentation",description:"Read the official Mastra documentation for guides, references, and tutorials.",icon:xat,href:"https://mastra.ai/en/docs",external:!0},{title:"Github",description:"Browse the source code, report issues, and contribute to the Mastra project.",icon:ja,href:"https://github.com/mastra-ai/mastra",external:!0},{title:"Community",description:"Join the Mastra Discord community for help, discussion, and collaboration.",icon:lP,href:"https://discord.gg/BTYqqHKUrf",external:!0},{title:"Share with your team",description:"Running Mastra Studio locally? Deploy to the cloud so your team can collaborate.",icon:jat,href:"https://mastra.ai/cloud",external:!0},{title:"Talk to our Sales team",description:"Get a custom demo, discuss on-prem deployments, and how we can help you accelerate getting agents into production.",icon:wat,href:"https://mastra.ai/contact?ref=studio",external:!0}];function YYr(){return o.jsx(Dt,{width:"narrow",children:o.jsx(Dt.MainArea,{children:o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 max-w-3xl",children:GYr.map(e=>o.jsxs("a",{href:e.href,...e.external?{target:"_blank",rel:"noreferrer"}:{},className:"group flex flex-col gap-3 rounded-lg border border-border1 bg-surface2 p-5 transition-colors hover:border-accent1 hover:bg-surface3",children:[o.jsxs("div",{className:"flex items-center gap-2.5",children:[o.jsx(e.icon,{className:"h-5 w-5 text-icon3 group-hover:text-accent1 transition-colors"}),o.jsx("span",{className:"text-ui-md font-medium text-text1",children:e.title}),e.external&&o.jsx(ja,{className:"h-3.5 w-3.5 text-icon3 ml-auto opacity-0 group-hover:opacity-100 transition-opacity"})]}),o.jsx("p",{className:"text-ui-sm text-text3 leading-relaxed",children:e.description})]},e.href))})})})}function XYr(){const{data:e={},isLoading:t,error:n}=Up(),[r,s]=y.useState(""),[a,i]=y.useState("all");if(n&&cs(n))return o.jsx(or,{children:o.jsx(Ms,{})});if(n&&ds(n))return o.jsx(or,{children:o.jsx(ks,{resource:"scorers"})});if(n)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load scorers",message:n.message})});if(Object.keys(e).length===0&&!t)return o.jsx(or,{children:o.jsx(Rqr,{})});const l=a!=="all"||r!=="",c=()=>{s(""),i("all")};return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx($qr,{search:r,onSearchChange:s,sourceFilter:a,onSourceFilterChange:i,onReset:c,hasActiveFilters:l})}),o.jsx(Aqr,{scorers:e,isLoading:t,search:r,sourceFilter:a})]})}function KYr(){const{scorerId:e}=vr(),[t,n]=zi(),r=t.get("scoreId")??void 0,[s,a]=y.useState(r),[i,l]=y.useState({value:"all",label:"All Entities",type:"ALL"}),{scorer:c,error:u}=Tqr(e),{data:d={},isLoading:f,error:p}=sm(),{isLoading:h,error:m}=Ey(),{data:g=[],isLoading:v,error:b,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O}=jqr({scorerId:e,entityId:i?.value==="all"?void 0:i?.value,entityType:i?.type==="ALL"?void 0:i?.type}),_=y.useMemo(()=>c?.agentIds?.filter(z=>d[z]).map(z=>({value:z,label:d[z].name,type:"AGENT"}))||[],[c?.agentIds,d]),C=y.useMemo(()=>c?.workflowIds?.map(z=>({value:z,label:z,type:"WORKFLOW"}))||[],[c?.workflowIds]),j=y.useMemo(()=>[{value:"all",label:"All Entities",type:"ALL"},..._,...C],[_,C]),E=t.get("entity")??"all",N=j.find(z=>z.value===E);N&&N.value!==i?.value&&l(N),y.useEffect(()=>{if(u){const z=u instanceof Error?u.message:"Failed to load scorer";Ue.error(`Error loading scorer: ${z}`)}},[u]),y.useEffect(()=>{if(p){const z=p instanceof Error?p.message:"Failed to load agents";Ue.error(`Error loading agents: ${z}`)}},[p]),y.useEffect(()=>{if(m){const z=m instanceof Error?m.message:"Failed to load workflows";Ue.error(`Error loading workflows: ${z}`)}},[m]);const I=z=>{z?.value&&n(M=>{const G=new URLSearchParams(M);return G.set("entity",z.value),G})};y.useEffect(()=>{const z=t.get("scoreId")??void 0;if(z===s)return;if(!z){a(void 0);return}g.find(G=>G.id===z)&&a(z)},[t,g]);const P=y.useCallback(z=>{a(z||void 0),n(M=>{const G=new URLSearchParams(M);return z?G.set("scoreId",z):G.delete("scoreId"),G})},[n]);if(!c)return null;const $=cs(u)||cs(p)||cs(m),B=u&&ds(u),D=!$&&!B&&(u||p||m),V=!v&&g.length===0,H=i?.value!=="all",L=c?.scorer?.source==="stored"?o.jsx(Sy,{owner:"scorer-detail",children:o.jsxs(pe,{variant:"default",as:ui,to:`/cms/scorers/${e}/edit`,size:"sm",children:[o.jsx(Dh,{})," Edit"]})}):null;if($||B||D||V&&!H){const z=(u instanceof Error?u.message:void 0)??(p instanceof Error?p.message:void 0)??(m instanceof Error?m.message:void 0)??"An unexpected error occurred";return o.jsxs(Dt,{width:"wide",height:"full",children:[L,o.jsx(Dt.MainArea,{isCentered:!0,children:$?o.jsx(Ms,{}):B?o.jsx(ks,{resource:"scorers"}):D?o.jsx(Di,{title:"Failed to load scorer",message:z}):o.jsx(kqr,{})})]})}return o.jsxs(Dt,{width:"wide",children:[L,o.jsx(Dt.TopArea,{children:o.jsx(Oqr,{selectedEntity:i,entityOptions:j,onEntityChange:I,onReset:()=>{n(z=>{const M=new URLSearchParams(z);return M.set("entity","all"),M})},isLoading:v||f||h})}),o.jsx(Sqr,{scores:g,isLoading:v,selectedScoreId:s,isFetchingNextPage:w,hasNextPage:S,setEndOfListElement:O,onScoreClick:P,errorMsg:b?.message})]})}function JYr({label:e,description:t,htmlFor:n,className:r,children:s}){return o.jsxs("div",{className:K("flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",r),"data-slot":"settings-row",children:[o.jsxs("div",{children:[n?o.jsx(Pt,{htmlFor:n,className:"text-sm font-medium",children:e}):o.jsx("p",{className:"text-sm font-medium",children:e}),t&&o.jsx("p",{className:"text-sm text-neutral3",children:t})]}),s]})}const B5t=[{value:"dark",label:"Dark"},{value:"light",label:"Light"},{value:"system",label:"System"}],eXr=e=>B5t.some(t=>t.value===e),tXr=()=>{const{baseUrl:e,headers:t,apiPrefix:n}=FSe(),{theme:r,setTheme:s}=gN();return o.jsx(Dt,{width:"narrow",children:o.jsxs(Dt.MainArea,{className:"flex flex-col gap-5 mt-6",children:[o.jsx(Tfe,{title:"Theme",description:"Customize the appearance of the studio.",children:o.jsx(JYr,{label:"Theme mode",htmlFor:"theme",children:o.jsxs($a,{value:r,onValueChange:a=>{eXr(a)&&s(a)},children:[o.jsx(Da,{id:"theme",className:"w-full sm:w-48",children:o.jsx(Ma,{})}),o.jsx(La,{children:B5t.map(a=>o.jsx(Xr,{value:a.value,children:a.label},a.value))})]})})}),o.jsx(Tfe,{title:"Mastra Connection",description:"Configure the Mastra instance URL, API prefix, and request headers used by the studio.",children:o.jsx(F4t,{initialConfig:{baseUrl:e,headers:t,apiPrefix:n}})})]})})};function nXr(){const[e]=zi(),t=Ks(),n=e.get("redirect")||"/",r=()=>{n.startsWith("http")?window.location.href=n:t(n,{replace:!0})};return o.jsx(z5t,{redirectUri:n,onSuccess:r,initialMode:"signup"})}function rXr(e){return e.replace(/\/$/,"").split("/").pop()}function DZ({children:e,className:t}){return o.jsx("div",{className:K("border border-border1 rounded-lg mt-12 py-8 lg:min-h-[25rem] transition-height px-4 lg:px-12",t),children:e})}function sXr({templates:e,linkComponent:t,className:n,isLoading:r}){const s=t||"a";return r?o.jsx("div",{className:K("grid gap-y-4",n),children:Array.from({length:5}).map((a,i)=>o.jsx("div",{className:"h-16 bg-surface3 animate-pulse rounded-lg"},i))}):o.jsx("div",{className:K("grid gap-y-4",n),children:e.map(a=>{const i=a?.agents||a?.tools||a?.networks||a?.workflows||a?.mcp;return o.jsxs("article",{className:K("border border-border1 rounded-lg overflow-hidden w-full grid grid-cols-[1fr_auto] bg-surface3 transition-colors hover:bg-surface4"),children:[o.jsxs(s,{to:`/templates/${a.slug}`,className:K("grid [&:hover_p]:text-neutral5",{"grid-cols-[8rem_1fr] lg:grid-cols-[12rem_1fr]":a.imageURL}),children:[a.imageURL&&o.jsx("div",{className:K("overflow-hidden"),children:o.jsx("div",{className:"w-full h-full bg-cover thumb transition-scale duration-150",style:{backgroundImage:`url(${a.imageURL})`}})}),o.jsxs("div",{className:K("grid py-3 px-6 w-full gap-0.5","[&_svg]:w-[1em] [&_svg]:h-[1em] [&_svg]:text-neutral3"),children:[o.jsx("h2",{className:"text-ui-lg text-neutral5",children:a.title}),o.jsx("p",{className:"text-ui-md text-neutral4 transition-colors duration-500",children:a.description}),o.jsxs("div",{className:"hidden 2xl:flex text-neutral3 text-ui-md flex-wrap items-center gap-4 mt-3",children:[i&&o.jsxs("ul",{className:K("flex gap-4 text-ui-md text-neutral3 m-0 p-0 list-none","[&>li]:flex [&>li]:items-center [&>li]:gap-0.5 text-neutral4"),children:[a?.agents&&a.agents.length>0&&o.jsxs("li",{children:[o.jsx(Xo,{})," ",a.agents.length]}),a?.tools&&a.tools.length>0&&o.jsxs("li",{children:[o.jsx(cf,{})," ",a.tools.length]}),a?.networks&&a.networks.length>0&&o.jsxs("li",{children:[o.jsx(zat,{})," ",a.networks.length]}),a?.workflows&&a.workflows.length>0&&o.jsxs("li",{children:[o.jsx(nU,{})," ",a.workflows.length]}),a?.mcp&&a.mcp.length>0&&o.jsxs("li",{children:[o.jsx(t1,{})," ",a.mcp.length]})]}),i&&a.supportedProviders&&o.jsx("small",{children:"|"}),o.jsx("div",{className:"flex items-center text-neutral3 gap-4",children:a.supportedProviders.map(l=>o.jsx("span",{className:"",children:l},l))})]})]})]}),o.jsx("a",{href:a.githubUrl,className:K("group items-center gap-2 text-ui-md ml-auto pr-4 hidden","lg:flex"),target:"_blank",rel:"noopener noreferrer",children:o.jsxs("span",{className:"flex items-center gap-2 px-2 py-1 rounded bg-surface1 group-hover:bg-surface2 text-neutral3 transition-colors group-hover:text-neutral5",children:[o.jsx(G_t,{})," ",rXr(a.githubUrl)]})})]},a.slug)})})}function aXr({tagOptions:e,selectedTag:t,providerOptions:n,selectedProvider:r,onTagChange:s,onProviderChange:a,searchTerm:i,onSearchChange:l,onReset:c,className:u,isLoading:d}){return d?o.jsxs("div",{className:K("h-[6.5rem] flex items-center gap-8","[&>div]:bg-surface3 [&>div]:w-48 [&>div]:h-8 [&>div]:animate-pulse",u),children:[o.jsx("div",{})," ",o.jsx("div",{})," ",o.jsx("div",{})]}):o.jsxs("div",{className:K("flex flex-wrap mx-auto sticky top-0 gap-4 bg-surface2 py-8",u),children:[o.jsx(Yj,{name:"search-templates",label:"Search templates",labelIsHidden:!0,value:i,onChange:f=>l?.(f.target.value),placeholder:"Search Template"}),o.jsx(ac,{label:"Filter by tag",labelIsHidden:!0,name:"filter-tag",value:t,onValueChange:s,options:e}),o.jsx(ac,{label:"Filter by provider",labelIsHidden:!0,name:"filter-provider",value:r,onValueChange:a,options:n}),c&&o.jsxs(pe,{onClick:c,children:["Reset ",o.jsx(ys,{})]})]})}function iXr(){const{data:e,isLoading:t}=Uyr(),{templates:n,tags:r,providers:s}=e??{templates:[],tags:[],providers:[]},[a,i]=y.useState("all"),[l,c]=y.useState("all"),[u,d]=y.useState(""),f=[{value:"all",label:"Any tag"}];(r||[]).forEach(w=>{f.push({value:w,label:w})});const p=[{value:"all",label:"Any provider"}];(s||[]).forEach(w=>{p.push({value:w,label:w})});const h=(w,S)=>{S==="tag"?i(w):S==="provider"&&c(w)},m=w=>{d(w)},g=()=>{i("all"),c("all"),d("")},v=n.filter(w=>!(u&&!w.title.toLowerCase().includes(u)&&!w.description.toLowerCase().includes(u)||a!=="all"&&!w.tags.includes(a)||l!=="all"&&!w.supportedProviders.includes(l))),b=u||a!=="all"||l!=="all";return o.jsxs(ms,{children:[o.jsx(axe,{children:o.jsxs(uht,{children:[o.jsx(Ge,{children:o.jsx(Tv,{})}),"Templates"]})}),o.jsxs("div",{className:K("overflow-y-auto w-full h-full px-8 pb-12 z-10"),children:[o.jsx(aXr,{selectedTag:a,onTagChange:w=>h(w,"tag"),tagOptions:f,selectedProvider:l,onProviderChange:w=>h(w,"provider"),providerOptions:p,searchTerm:u,onSearchChange:m,onReset:b?g:void 0,className:"max-w-[80rem]",isLoading:t}),o.jsx(sXr,{templates:v,linkComponent:ui,className:"max-w-[80rem] mx-auto",isLoading:t})]})]})}const oXr="1.43.1-alpha.0";function lXr({errorMsg:e,validationErrors:t}){const n=typeof e=="string"?e:e!=null?String(e):void 0,r=n?.includes("Invalid schema for function"),s=n?.includes("validation issue")||t&&t.length>0,a=()=>s?"Template installation completed but some validation issues remain. The template may still be functional, but you should review and fix these issues.":r?"There was an issue with the AI model configuration. This may be related to the selected model or AI SDK version compatibility.":"An unexpected error occurred during template installation.",i=()=>s?{icon:o.jsx(gp,{className:"text-yellow-500"}),title:"Template Installed with Warnings"}:{icon:o.jsx(fin,{}),title:"Template Installation Failed"},{icon:l,title:c}=i();return o.jsxs(DZ,{className:"space-y-4 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[l,o.jsxs("div",{className:"text-center space-y-2",children:[o.jsx("p",{className:"text-ui-md font-medium text-neutral5",children:c}),o.jsx("p",{className:"text-ui-md text-neutral3",children:a()})]})]}),t&&t.length>0&&o.jsxs("details",{className:"text-xs",children:[o.jsxs("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:["Show Validation Issues (",t.length,")"]}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs overflow-auto max-h-60 text-left space-y-2",children:t.map((u,d)=>o.jsxs("div",{className:"border-l-2 border-red-400 pl-2",children:[o.jsx("div",{className:"font-medium text-red-600 dark:text-red-400",children:u.type==="typescript"?"🔴 TypeScript Error":"⚠️ Lint Error"}),o.jsx("div",{className:"text-xs font-mono text-gray-700 dark:text-gray-300 mt-1 whitespace-pre-wrap wrap-break-word",children:u.message})]},d))})]}),n&&!s&&o.jsxs("details",{className:"text-xs",children:[o.jsx("summary",{className:"cursor-pointer text-neutral3 hover:text-neutral4 select-none text-center",children:"Show Details"}),o.jsx("div",{className:"mt-4 p-3 bg-gray-100 dark:bg-gray-800 rounded text-xs font-mono overflow-auto max-h-60 text-left",children:o.jsx("div",{className:"whitespace-pre-wrap wrap-break-word",children:n})})]})]})}function cXr({providerOptions:e,selectedProvider:t,onProviderChange:n,variables:r,errors:s,handleInstallTemplate:a,handleVariableChange:i,isLoadingEnvVars:l,isInstalling:c,defaultModelProvider:u,defaultModelId:d,onModelUpdate:f}){return o.jsx(DZ,{children:o.jsxs("div",{className:"max-w-[40rem] my-4 p-4 lg:p-8 mx-auto gap-8 grid",children:[o.jsxs("h2",{className:K("text-neutral4 text-header-sm font-semibold flex items-center gap-2","[&>svg]:w-[1.2em] [&_svg]:h-[1.2em] [&_svg]:opacity-70"),children:["Install Template ",o.jsx(Bat,{})]}),o.jsx(ac,{name:"template-provider",options:e,label:"Template AI Model Provider",onValueChange:n,value:t,placeholder:"Select",layout:"horizontal"}),t&&Object.entries(r||{}).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h3",{className:"text-neutral3 text-ui-md",children:"Set required Environmental Variables"}),o.jsx("div",{className:"grid grid-cols-[1fr_1fr] gap-4 items-start",children:l?o.jsxs("div",{className:K("flex items-center justify-center col-span-2 text-neutral3 text-ui-sm gap-4","[&_svg]:opacity-50 [&_svg]:w-[1.1em] [&_svg]:h-[1.1em]","animate-in fade-in duration-300"),children:[o.jsx(Ht,{})," Loading variables..."]}):Object.entries(r).map(([p,h])=>o.jsxs(y.Fragment,{children:[o.jsx(pO,{name:`env-${p}`,labelIsHidden:!0,label:"Key",value:p,disabled:!0,className:"w-full"}),o.jsx(pO,{name:p,labelIsHidden:!0,label:"Value",value:h,onChange:i,errorMsg:s.includes(p)?"Value is required.":"",autoComplete:"off",className:"w-full"})]},p))}),o.jsxs("div",{className:"border-t border-border1 pt-12 mt-3.5 relative",children:[o.jsx("div",{className:"absolute w-8 h-8 rounded-full bg-surface2 top-0 left-1/2 -translate-x-1/2 -translate-y-4 text-ui-sm text-neutral3 flex items-center justify-center",children:"And"}),o.jsx("h3",{className:"text-neutral4 text-ui-lg",children:"Set AI Model for Template Installation"}),o.jsx("p",{className:"text-neutral3 text-ui-md mt-2 mb-8",children:"This model will be used by the workflow to process and install the template"}),o.jsx(L4t,{defaultProvider:u||"",defaultModel:d||"",updateModel:f||(()=>Promise.resolve({message:"Updated"})),closeEditor:()=>{},autoSave:!0,selectProviderPlaceholder:"Provider"})]})]}),t&&!l&&o.jsx(pe,{className:K("flex items-center gap-2 mt-4 justify-center text-ui-md w-full bg-surface5 min-h-10 rounded-lg text-neutral5 hover:bg-surface6 transition-colors","[&>svg]:w-[1.1em] [&_svg]:h-[1.1em] [&_svg]:text-neutral5"),onClick:a,disabled:!t||!u||!d||s.length>0||c,children:c?o.jsxs(o.Fragment,{children:[o.jsx(Ht,{className:"w-4 h-4"})," Installing..."]}):o.jsxs(o.Fragment,{children:["Install ",o.jsx(Gh,{})]})})]})})}function uXr({title:e,description:t,githubUrl:n,isLoading:r,infoData:s,templateSlug:a}){const i=a?`feat/install-template-${a}`:"feat/install-template-[slug]";return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:K("grid mt-8 items-center"),children:o.jsxs("div",{className:K("text-header-lg flex items-center gap-3","[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",{"[&>svg]:opacity-20":r}),children:[o.jsx(Tv,{}),o.jsx("h2",{className:K({"bg-surface4 flex rounded-lg min-w-[50%]":r}),children:r?o.jsx(o.Fragment,{children:" "}):e})]})}),o.jsxs("div",{className:"grid lg:grid-cols-[1fr_1fr] gap-x-24",children:[o.jsxs("div",{className:"grid",children:[o.jsx("p",{className:K("mb-4 text-ui-md text-neutral4 mt-2 leading-7",{"bg-surface4 rounded-lg ":r}),children:r?o.jsx(o.Fragment,{children:" "}):t}),!r&&a&&o.jsxs("div",{className:K("bg-surface2 border border-surface4 rounded-lg p-4 mb-4","flex items-start gap-3"),children:[o.jsx("div",{className:"shrink-0 mt-0.5",children:o.jsx(g1,{className:"w-[1.1em] h-[1.1em] text-blue-500"})}),o.jsxs("div",{className:"flex-1 space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Sve,{className:"w-[1em] h-[1em] text-neutral4"}),o.jsx("span",{className:"text-ui-md font-medium text-neutral5",children:"A new Git branch will be created"})]}),o.jsxs("div",{className:"text-ui-sm text-neutral4 space-y-1",children:[o.jsxs("div",{children:[o.jsx("span",{className:"font-medium",children:"Branch name:"})," ",o.jsx("code",{className:"bg-surface3 px-1.5 py-0.5 rounded text-ui-sm font-mono",children:i})]}),o.jsx("div",{children:"This ensures safe installation with easy rollback if needed. Your main branch remains unchanged."})]})]})]}),n&&o.jsxs("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-auto text-neutral3 text-ui-md hover:text-neutral5",children:[o.jsx(G_t,{}),n?.split("/")?.pop()]})]}),s&&o.jsx(E0e,{data:s,labelsAreHidden:!0,isLoading:r})]})]})}function dXr({name:e,streamResult:t,runId:n,workflowInfo:r}){const s=t?.phase||"initializing",a=t?.payload?.workflowState,i=t?.payload?.currentStep,l=t?.error,c=a?.steps||{},u=Object.keys(c).length>0,d=g=>g==="input"||g.endsWith(".input")||g.startsWith("Mapping_")&&/[0-9a-f]{8}/.test(g)||/[0-9a-f]{8,}/.test(g)?!1:r?.allSteps?g in r.allSteps:!0,f=Object.entries(c).filter(([g,v])=>d(g)),p=f.length,h=()=>{switch(s){case"initializing":return"Preparing template installation...";case"processing":return`Installing ${e} template`;case"completed":return"Template installation completed!";case"error":return"Template installation failed";default:return"Installing template..."}},m=f.map(([g,v])=>({id:g,status:v?.status,description:v?.description,title:g.charAt(0).toUpperCase()+g.slice(1).replace(/-/g," "),isActive:i?.id===g}));return o.jsxs(DZ,{className:"space-y-6 text-neutral3 mb-8 content-center",children:[o.jsxs("div",{className:"text-center",children:[o.jsx("h3",{className:"text-lg font-semibold text-neutral5",children:h()}),(t?.runId||n)&&o.jsxs("div",{className:"mt-2 text-ui-sm text-neutral3",children:["Run ID: ",t?.runId??n]})]}),u&&p>0&&!["error"].includes(s)&&o.jsx("div",{className:"max-w-[30rem] w-full mx-auto px-6",children:o.jsx(oBn,{steps:m})}),l&&s==="error"&&o.jsxs("div",{className:K("rounded-lg text-neutral5 p-6 flex items-center gap-3 text-ui-md bg-red-500/10","[&>svg]:w-6 [&>svg]:h-6 [&>svg]:opacity-70 [&>svg]:text-red-500"),children:[o.jsx(don,{}),l||"Something went wrong"]}),u&&o.jsx(iBn,{steps:m,currentStep:i,className:"pb-4"}),!u&&s==="initializing"&&o.jsxs("div",{className:"text-center text-sm text-neutral3 grid gap-4 justify-items-center",children:[o.jsx(Ht,{}),o.jsx("p",{children:"This may take some time..."})]})]})}function fXr({name:e,installedEntities:t}){return o.jsxs(DZ,{className:K("grid items-center justify-items-center gap-4 content-center","[&>svg]:w-8 [&>svg]:h-8"),children:[o.jsx(Bat,{}),o.jsx("h2",{className:"text-header-md",children:"Done!"}),o.jsxs("p",{className:"text-ui-md text-center text-neutral3 ",children:["The ",o.jsx("b",{className:"text-neutral4",children:e})," template has been successfully installed.",t&&t.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("br",{})," Installed entities are listed below."]})]}),t&&t.length>0&&o.jsx(E0e,{data:t})]})}function pXr(){const{templateSlug:e}=vr(),[t,n]=zi(),[r,s]=y.useState(""),[a,i]=y.useState(""),[l,c]=y.useState(""),[u,d]=y.useState({}),[f,p]=y.useState([]),[h,m]=y.useState(null),[g,v]=y.useState(!1),[b,w]=y.useState(""),[S,O]=y.useState(!1),[_,C]=y.useState(!1),[j,E]=y.useState([]),{data:N,isLoading:I}=qyr({repoOrSlug:e,owner:"mastra-ai"}),$=oXr?.includes("beta")??!1?"beta":"main",{data:B,isLoading:D}=Vyr({repo:N?.githubUrl?new URL(N.githubUrl).pathname.split("/")[2]:`template-${e}`,owner:"mastra-ai",branch:$}),{data:V,isLoading:H}=Hyr(),{mutateAsync:L,isPending:F}=Zyr(),{mutateAsync:z}=Wyr(),{streamInstall:M,streamResult:G,isStreaming:U}=Gyr(V),{observeInstall:R,streamResult:q,isStreaming:W}=Yyr(V);y.useEffect(()=>{const te=t.get("runId");te&&!g&&!h&&!U&&!W&&(console.info("🔄 Checking completed run after hot reload:",{runId:te}),w(te),z({runId:te}).then(le=>{const fe=le.snapshot;if(fe?.status==="success"&&fe?.result?.success)v(!0);else if(fe?.result?.success===!1)if(fe?.result?.validationResults&&!fe?.result?.validationResults?.valid&&fe?.result?.validationResults?.remainingErrors>0){const{remainingErrors:he,errors:be}=fe.result.validationResults,we=`Template installation completed but ${he} validation issue${he>1?"s":""} remain unresolved.`;m(we),E(be||[])}else{const he=fe?.result?.message||fe?.result?.error||"Template installation failed";m(typeof he=="string"?he:String(he))}}).catch(le=>{console.error("❌ Failed to fetch run details:",le),m("Failed to retrieve installation status after reload")}))},[t,g,h,U,W,z]),y.useEffect(()=>{const te=t.get("runId"),le=t.get("resume"),fe=t.get("provider");if(te&&le==="true"&&fe&&!U&&!W&&!S&&!_&&V){w(te),O(!0);try{z({runId:te}).then(se=>{if(se.snapshot?.status==="running")return R.mutateAsync({runId:te})}).then(()=>{n(se=>{const he=new URLSearchParams(se);return he.delete("resume"),he})}).catch(se=>{console.error("❌ Failed to resume template installation:",se),se.message?.includes("404")||se.message?.includes("not found")?m("Template installation run not found. It may have expired or been completed."):m("Failed to resume template installation. Please try again.")})}catch(se){console.error("❌ Auto-resume failed with error:",se),m("Failed to resume template installation. Please refresh and try again.")}}},[t,e,U,W,S,_,V,z,R,n]);const X=[{value:"openai",label:"OpenAI"},{value:"anthropic",label:"Anthropic"},{value:"groq",label:"Groq"},{value:"google",label:"Google"}],ne=[{key:"tools",label:"Tools",value:N?.tools?.length?N.tools.map(te=>te).join(", "):"n/a",icon:o.jsx(cf,{})},{key:"agents",label:"Agents",value:N?.agents?.length?N.agents.map(te=>te).join(", "):"n/a",icon:o.jsx(Xo,{})},{key:"workflows",label:"Workflows",value:N?.workflows?.length?N.workflows.map(te=>te).join(", "):"n/a",icon:o.jsx(nU,{})},{key:"providers",label:"Providers",value:N?.supportedProviders?.length?N.supportedProviders.join(", "):"n/a",icon:o.jsx(Y0,{})},{key:"tags",label:"Tags",value:N?.tags?.length?N.tags.join(", "):"n/a",icon:o.jsx(XO,{})}],ee=[{...ne[0]},{...ne[1]},{...ne[2]}].filter(te=>te.value!=="n/a");y.useEffect(()=>{B&&d(B)},[B]),y.useEffect(()=>{const te=G||q;te?.phase==="error"&&te?.error&&m(typeof te.error=="string"?te.error:String(te.error))},[G?.phase,G?.error,q?.phase,q?.error]);const J=te=>{s(te)},ie=async te=>(i(te.provider),c(te.modelId),{message:"Model updated successfully"}),ue=async()=>{const te=Object.entries(u).reduce((le,[fe,se])=>(se===""&&le.push(fe),le),[]);if(te.length>0){p(te);return}if(N){m(null),v(!1),w(""),C(!0);try{const fe={repo:N.githubUrl||`https://github.com/mastra-ai/template-${N.slug}`,ref:$,slug:N.slug,variables:u},{runId:se}=await L({});w(se),n(he=>{const be=new URLSearchParams(he);return be.set("runId",se),be.set("resume","true"),be.set("provider",r||"openai"),be}),await M.mutateAsync({inputData:fe,selectedModel:{provider:a,modelId:l},runId:se})}catch(le){C(!1),m(le?.message||"Template installation failed"),console.error("Template installation failed",le)}}},Y=te=>{const{name:le,value:fe}=te.target;fe.trim()===""?p(se=>[...se,le]):p(se=>se.filter(he=>he!==le)),d(se=>({...se,[le]:fe}))};return o.jsx(ms,{children:o.jsx("div",{className:K("w-full lg:px-12 h-full overflow-y-scroll"),children:o.jsxs("div",{className:"p-6 w-full max-w-[80rem] mx-auto grid gap-y-4",children:[o.jsx(uXr,{isLoading:I,title:N?.title,description:N?.longDescription,imageURL:N?.imageURL,githubUrl:N?.githubUrl,infoData:ne,templateSlug:e}),N&&o.jsxs(o.Fragment,{children:[(U||W)&&o.jsx(dXr,{name:N.title,streamResult:W?q:G,runId:b,workflowInfo:V}),g&&o.jsx(fXr,{name:N.title,installedEntities:ee,linkComponent:ui}),h&&o.jsx(lXr,{errorMsg:h,validationErrors:j.length>0?j:G?.validationResults?.errors||q?.validationResults?.errors}),!U&&!W&&!g&&!h&&o.jsx(cXr,{providerOptions:X,selectedProvider:r,onProviderChange:J,variables:u,setVariables:d,errors:f,setErrors:p,handleInstallTemplate:ue,handleVariableChange:Y,isLoadingEnvVars:D||H,isInstalling:F,defaultModelProvider:a,defaultModelId:l,onModelUpdate:ie})]})]})})})}const hXr=()=>{const{toolId:e,agentId:t}=vr();return o.jsx("div",{className:"h-full w-full overflow-y-auto",children:o.jsx(lVr,{toolId:e,agentId:t})})},mXr=()=>{const{toolId:e}=vr();return o.jsx("div",{className:"h-full w-full overflow-y-hidden",children:o.jsx(wYr,{toolId:e})})};function gXr(){const{traceId:e}=vr(),[t,n]=zi(),r=Ks(),s=t.get("spanId")||void 0,a=t.get("tab"),i=a==="scoring"?"scoring":a==="feedback"?"feedback":"details",l=t.get("scoreId")||void 0,[c,u]=y.useState(s??null),[d,f]=y.useState(),[p,h]=y.useState(i),[m,g]=y.useState(0),[v,b]=y.useState(!1),{data:w,isLoading:S,error:O}=ISe(e),_=y.useMemo(()=>w?.spans??[],[w?.spans]),C=y.useMemo(()=>_.find(ie=>ie.parentSpanId==null),[_]),{data:j,isLoading:E}=iD(e,c??"");y.useEffect(()=>g(0),[e,c]);const{data:N,isLoading:I}=Up(),{data:P,isLoading:$}=G4t({traceId:e,spanId:c??void 0,page:m}),[B,D]=y.useState(0);y.useEffect(()=>D(0),[e,c]);const{data:V,isLoading:H}=I5t({traceId:e,page:B});y.useEffect(()=>{if(l&&P?.scores&&!d){const ie=P.scores.find(ue=>ue.id===l);ie&&f(ie)}},[l,P?.scores,d]);const L=y.useCallback(ie=>{const ue=new URLSearchParams(t);for(const[Y,te]of Object.entries(ie))te===null||te===""?ue.delete(Y):ue.set(Y,te);n(ue,{replace:!0})},[t,n]),F=y.useCallback(ie=>{const ue=ie??null,Y=ue===c;u(ue),Y||(f(void 0),h("details"),L({spanId:ue,tab:null,scoreId:null}))},[c,L]),z=y.useCallback(()=>{u(null),f(void 0),h("details"),L({spanId:null,tab:null,scoreId:null})},[L]),M=y.useCallback(ie=>{u(ie),f(void 0),h("details"),L({spanId:ie,tab:null,scoreId:null})},[L]),{handlePreviousSpan:G,handleNextSpan:U}=MSe(_,c,M),R=y.useCallback(ie=>{const ue=ie;h(ue),f(void 0),L({tab:ue==="details"?null:ue,scoreId:null})},[L]),q=y.useCallback(ie=>{f(ie),L({scoreId:ie.id})},[L]),W=y.useCallback(()=>{f(void 0),L({scoreId:null})},[L]),X=y.useCallback(()=>{r("/observability")},[r]),ne=y.useCallback(()=>{h("scoring"),C&&c!==C.spanId?(u(C.spanId),f(void 0),L({spanId:C.spanId,tab:"scoring",scoreId:null})):L({tab:"scoring"})},[C,c,L]),ee=C?o.jsx(Sy,{owner:"trace-detail",children:o.jsxs($r,{children:[o.jsxs(pe,{tooltip:"Evaluate Trace","aria-label":"Evaluate Trace",onClick:ne,children:[o.jsx(uan,{}),"Evaluate"]}),o.jsxs(pe,{tooltip:"Save as Dataset Item","aria-label":"Save as Dataset Item",onClick:()=>b(!0),children:[o.jsx(ad,{}),"Save"]})]})}):null,J=C?o.jsx(Dt.Row,{children:o.jsx(Dt.Column,{children:o.jsx(kCt,{rootSpan:C,numOfCol:3})})}):null;return O?o.jsxs(Dt,{height:"full",children:[ee,J&&o.jsx(Dt.TopArea,{children:J}),o.jsx(Dt.MainArea,{isCentered:!0,children:o.jsx(CCt,{error:O,resource:"traces",errorTitle:"Failed to load trace"})})]}):o.jsxs(Dt,{children:[ee,J&&o.jsx(Dt.TopArea,{children:J}),o.jsx(C5t,{rootSpanId:C?.spanId,traceId:e,isOpen:v,onClose:()=>b(!1)}),o.jsxs("div",{className:K("grid h-full min-h-0 gap-4 overflow-hidden items-start mt-4",c?"grid-cols-[2fr_3fr]":"grid-cols-[1fr]"),children:[o.jsx(TSe,{traceId:e,spans:_,isLoading:S,onClose:X,onSpanSelect:F,onEvaluateTrace:ne,initialSpanId:c,placement:"trace-page",timelineChartWidth:c?"default":"wide"}),c&&!S&&o.jsxs("div",{className:K("grid gap-4 max-h-full min-h-0 overflow-auto",d?"grid-rows-[1fr_1fr]":"grid-rows-[1fr]"),children:[o.jsx(NSe,{traceId:e,spanId:c,span:j?.span,isLoading:E,onClose:z,onPrevious:G,onNext:U,activeTab:p,onTabChange:R,feedbackTabBadge:V?.pagination?.total??void 0,feedbackTabSlot:()=>o.jsx(j5t,{feedbackData:V,onPageChange:D,isLoadingFeedbackData:H}),scoringTabBadge:P?.pagination?.total??void 0,scoringTabSlot:({span:ie,traceId:ue,spanId:Y})=>o.jsxs("div",{className:"grid gap-6",children:[o.jsx(N5t,{traceId:ue,isTopLevelSpan:!ie.parentSpanId,spanId:Y,entityType:ie.attributes?.agentId||ie.entityType===Ps.AGENT?"Agent":ie.attributes?.workflowId||ie.entityType===Ps.WORKFLOW_RUN?"Workflow":void 0,scorers:N,isLoadingScorers:I}),o.jsx(T5t,{scoresData:P,onPageChange:g,isLoadingScoresData:$,onScoreSelect:q})]})}),d&&o.jsx(iEe,{score:d,onClose:W})]})]})]})}function vXr(){const{data:e,isLoading:t,error:n}=Ey(),[r,s]=y.useState("");return n&&cs(n)?o.jsx(or,{children:o.jsx(Ms,{})}):n&&ds(n)?o.jsx(or,{children:o.jsx(ks,{resource:"workflows"})}):n?o.jsx(or,{children:o.jsx(Di,{title:"Failed to load workflows",message:n.message})}):Object.keys(e||{}).length===0&&!t?o.jsx(or,{children:o.jsx(ZDr,{})}):o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsxs(Dt.Row,{align:"center",stack:"responsive",children:[o.jsx("div",{className:"max-w-120 flex-1",children:o.jsx(xf,{onSearch:s,label:"Filter workflows",placeholder:"Filter by name or description"})}),o.jsxs(pe,{as:ui,to:"/workflows/schedules",variant:"primary",className:"shrink-0",children:[o.jsx(RM,{}),"Schedules"]})]})}),o.jsx(HDr,{workflows:e||{},isLoading:t,search:r})]})}const yXr={active:"bg-accent1",paused:"bg-accent3"},bXr={active:"text-accent1",paused:"text-accent3"},U5t=({status:e})=>o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${yXr[e]}`,"aria-hidden":!0}),o.jsx("span",{className:`text-ui-sm ${bXr[e]}`,children:e})]}),Sj=e=>!e||e<=0?"—":new Date(e).toLocaleString(),j2=e=>{if(!e||e<=0)return"—";const t=e-Date.now(),n=Math.abs(t),r=Math.floor(n/1e3);if(r<60)return t>=0?`in ${r}s`:`${r}s ago`;const s=Math.floor(r/60);if(s<60)return t>=0?`in ${s}m`:`${s}m ago`;const a=Math.floor(s/60);if(a<24)return t>=0?`in ${a}h`:`${a}h ago`;const i=Math.floor(a/24);return t>=0?`in ${i}d`:`${i}d ago`};function q5t({status:e}){const{icon:t,color:n}=xXr(e);return o.jsxs("span",{className:`inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm ${n}`,children:[o.jsx("span",{className:"inline-flex shrink-0 items-center","aria-hidden":!0,children:t}),o.jsx("span",{children:e})]})}function xXr(e){switch(e){case"success":return{icon:o.jsx(da,{size:14}),color:"text-accent1"};case"failed":return{icon:o.jsx(ys,{size:14}),color:"text-accent2"};case"running":return{icon:o.jsx(Ht,{}),color:"text-neutral3"};case"suspended":return{icon:o.jsx(xve,{size:14}),color:"text-accent3"};case"canceled":return{icon:o.jsx(ff,{size:14}),color:"text-neutral3"};case"pending":case"waiting":return{icon:o.jsx(YT,{size:14}),color:"text-neutral3"};default:return{icon:null,color:"text-neutral3"}}}const lWe="auto auto auto auto 1fr";function wXr(e){if(e===void 0)return"—";if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;const t=Math.floor(e/6e4),n=Math.floor(e%6e4/1e3);return`${t}m ${n}s`}function SXr(e){const t=Math.abs(e),n=e<0?"-":"";return t<1e3?`${n}${t}ms`:t<6e4?`${n}${(t/1e3).toFixed(1)}s`:t<36e5?`${n}${(t/6e4).toFixed(1)}m`:`${n}${(t/36e5).toFixed(1)}h`}const kXr=3e4,OXr=5*6e4;function _Xr({triggers:e,isLoading:t,workflowId:n,hasNextPage:r,isFetchingNextPage:s,setEndOfListElement:a}){const{Link:i,paths:l}=vn();return t?o.jsx(Wo,{columns:lWe}):e.length===0?o.jsx(ge,{variant:"ui-md",className:"text-neutral4 p-4",children:"No trigger history yet."}):o.jsxs(xe,{columns:lWe,className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Run"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Started"}),o.jsx(xe.TopCell,{children:"Duration"}),o.jsx(xe.TopCell,{children:" "})]}),e.map(c=>{const u=c.actualFireAt-c.scheduledFireAt,d=SXr(u),f=`Scheduled ${Sj(c.scheduledFireAt)} — published ${Sj(c.actualFireAt)} (drift ${d})`,p=c.outcome==="failed",h=p?c.error:c.run?.error,m=Math.abs(u),g=!p&&m>kXr&&m<=OXr,v=`${c.scheduleId}-${c.runId}-${c.actualFireAt}`,b=!!(n&&c.runId&&!p),w=o.jsx("span",{className:b?"text-accent1 font-mono text-ui-sm whitespace-nowrap":"text-neutral3 font-mono text-ui-sm whitespace-nowrap",children:c.runId}),S=o.jsxs(o.Fragment,{children:[o.jsx(xe.Cell,{height:"compact",children:w}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2",children:[p?o.jsxs("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-accent2",children:[o.jsx(gp,{size:14}),"publish failed"]}):c.run?o.jsx(q5t,{status:c.run.status}):o.jsx("span",{className:"inline-flex items-center gap-1.5 whitespace-nowrap text-ui-sm text-neutral3",children:"pending"}),h?o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("span",{className:"text-accent2 inline-flex",children:o.jsx(gp,{size:14})})}),o.jsx(Hn,{children:h})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("span",{title:f,children:j2(c.actualFireAt)}),g?o.jsxs(Wn,{children:[o.jsx(Vn,{asChild:!0,children:o.jsx("span",{className:"text-accent3 inline-flex",children:o.jsx(gp,{size:14})})}),o.jsxs(Hn,{children:["Published ",d," after the scheduled fire time"]})]}):null]})}),o.jsx(xe.Cell,{height:"compact",children:c.run?o.jsx("span",{children:wXr(c.run.durationMs)}):o.jsx("span",{className:"text-neutral4",children:"—"})}),o.jsx(xe.Cell,{height:"compact",children:" "})]});return b?o.jsx(xe.RowLink,{to:l.workflowRunLink(n,c.runId),LinkComponent:i,children:S},v):o.jsx(xe.RowStatic,{children:S},v)}),o.jsx(xe.NextPageLoading,{isLoading:s,hasMore:r,setEndOfListElement:a})]})}const CXr=e=>{const t=He();return xt({queryKey:["schedule",e],enabled:!!e,queryFn:async()=>{if(!e)throw new Error("scheduleId is required");return t.getSchedule(e)}})},cWe=25,EXr=e=>{const t=He(),{inView:n,setRef:r}=C_(),s=I1({queryKey:["schedule-triggers",e],enabled:!!e,initialPageParam:void 0,queryFn:async({pageParam:u})=>e?t.listScheduleTriggers(e,{limit:cWe,toActualFireAt:u}):{triggers:[]},getNextPageParam:u=>{if(!(!u?.triggers?.length||u.triggers.length<cWe))return u.triggers[u.triggers.length-1].actualFireAt},refetchInterval:u=>(u.state.data?.pages.flatMap(p=>p.triggers)??[]).some(p=>p.run?p.run.status==="pending"||p.run.status==="running"||p.run.status==="waiting":p.outcome==="published")?5e3:!1}),a=s.data?.pages.flatMap(u=>u?.triggers??[])??[],{hasNextPage:i,isFetchingNextPage:l,fetchNextPage:c}=s;return y.useEffect(()=>{n&&i&&!l&&c()},[n,i,l,c]),{...s,data:a,setEndOfListElement:r}},jXr=e=>{const t=He(),n=qr();return An({mutationFn:async r=>{if(!e)throw new Error("scheduleId is required");return r==="pause"?t.pauseSchedule(e):t.resumeSchedule(e)},onSuccess:(r,s)=>{n.invalidateQueries({queryKey:["schedule",e]}),n.invalidateQueries({queryKey:["schedules"]}),Ue.success(s==="pause"?"Schedule paused":"Schedule resumed")},onError:r=>{Ue.error(r.message)}})};function b8({label:e,children:t}){return o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx(ge,{variant:"ui-xs",className:"text-neutral4 uppercase tracking-wide",children:e}),o.jsx("div",{className:"text-ui-md",children:t})]})}function TXr(){const{scheduleId:e}=vr(),{paths:t}=vn(),{data:n,error:r}=CXr(e),{data:s,isLoading:a,error:i,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u}=EXr(e),d=jXr(e);if(r&&cs(r))return o.jsx(or,{children:o.jsx(Ms,{})});if(r&&ds(r))return o.jsx(or,{children:o.jsx(ks,{resource:"schedules"})});if(r)return o.jsx(or,{children:o.jsx(Di,{title:"Failed to load schedule",message:r.message})});const f=n?.target.type==="workflow"?n.target.workflowId:void 0;return o.jsxs(Dt,{children:[o.jsx(Dt.TopArea,{children:o.jsx(Dt.Row,{className:"justify-end",children:o.jsxs(Dt.Column,{className:"flex justify-end gap-2",children:[o.jsxs(pe,{as:ui,to:t.schedulesLink(),variant:"ghost",children:[o.jsx(gc,{}),"Back to schedules"]}),f?o.jsx(pe,{as:ui,to:t.workflowLink(f),variant:"ghost",children:"Open workflow"}):null,n?o.jsx(pe,{onClick:()=>d.mutate(n.status==="active"?"pause":"resume"),disabled:d.isPending,"data-testid":"schedule-toggle-button",children:n.status==="active"?o.jsxs(o.Fragment,{children:[o.jsx(qat,{}),"Pause"]}):o.jsxs(o.Fragment,{children:[o.jsx(Lw,{}),"Resume"]})}):null]})})}),n?o.jsxs("div",{className:"grid gap-6 h-full overflow-hidden grid-cols-[minmax(0,20rem)_1fr]",children:[o.jsxs("div",{className:"flex flex-col gap-4 border border-border1 rounded-md p-4 h-fit",children:[o.jsx(b8,{label:"Workflow",children:f?o.jsx(ui,{to:t.workflowLink(f),className:"text-accent1 hover:underline",children:f}):"—"}),o.jsxs(b8,{label:"Cron",children:[o.jsx("code",{className:"font-mono text-ui-md",children:n.cron}),n.timezone?o.jsx("span",{className:"text-neutral4 ml-2 text-ui-sm",children:n.timezone}):null]}),o.jsx(b8,{label:"Status",children:o.jsx(U5t,{status:n.status})}),o.jsx(b8,{label:"Next fire",children:o.jsx("span",{title:Sj(n.nextFireAt),children:j2(n.nextFireAt)})})]}),o.jsxs("div",{className:"overflow-y-auto","data-testid":"schedule-triggers-panel",children:[o.jsx(ge,{variant:"ui-md",className:"mb-3",children:"Trigger history"}),i?o.jsx(Di,{title:"Failed to load trigger history",message:i.message}):o.jsx(_Xr,{triggers:s??[],isLoading:a,workflowId:f,hasNextPage:l,isFetchingNextPage:c,setEndOfListElement:u})]})]}):null]})}const uWe="minmax(0, 1.2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto";function NXr({schedules:e,isLoading:t,search:n=""}){const{paths:r,Link:s}=vn(),a=y.useMemo(()=>{const i=n.toLowerCase();return i?e.filter(l=>l.id.toLowerCase().includes(i)||l.target.workflowId.toLowerCase().includes(i)):e},[e,n]);return t?o.jsx(Wo,{columns:uWe}):o.jsxs(xe,{columns:uWe,variant:"striped",className:"min-w-0",children:[o.jsxs(xe.Top,{children:[o.jsx(xe.TopCell,{children:"Workflow"}),o.jsx(xe.TopCell,{children:"Schedule ID"}),o.jsx(xe.TopCell,{children:"Cron"}),o.jsx(xe.TopCell,{children:"Status"}),o.jsx(xe.TopCell,{children:"Next fire"}),o.jsx(xe.TopCell,{children:"Last run"})]}),a.length===0&&n?o.jsx(xe.NoMatch,{message:"No schedules match your search"}):null,a.length===0&&!n?o.jsx(xe.NoMatch,{message:"No schedules configured"}):null,a.map(i=>o.jsxs(xe.RowLink,{to:r.scheduleLink(i.id),LinkComponent:s,children:[o.jsx(xe.NameCell,{children:i.target.workflowId}),o.jsx(xe.Cell,{height:"compact",className:"min-w-0",children:o.jsx("span",{className:"block truncate font-mono text-ui-smd text-neutral3",title:i.id,children:i.id})}),o.jsx(xe.Cell,{height:"compact",children:o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx("code",{className:"font-mono text-ui-sm",children:i.cron}),i.timezone?o.jsx("span",{className:"text-neutral4 text-ui-xs",children:i.timezone}):null]})}),o.jsx(xe.Cell,{height:"compact",children:o.jsx(U5t,{status:i.status})}),o.jsx(xe.Cell,{height:"compact",children:o.jsx("span",{className:"whitespace-nowrap",title:Sj(i.nextFireAt),children:j2(i.nextFireAt)})}),o.jsx(xe.Cell,{height:"compact",children:i.lastRun?o.jsxs("span",{className:"inline-flex items-center gap-2 whitespace-nowrap",children:[o.jsx(q5t,{status:i.lastRun.status}),o.jsx("span",{className:"text-neutral4 text-ui-sm",title:Sj(i.lastFireAt),children:i.lastFireAt?j2(i.lastFireAt):""})]}):i.lastFireAt?o.jsx("span",{className:"whitespace-nowrap",title:Sj(i.lastFireAt),children:j2(i.lastFireAt)}):o.jsx("span",{className:"text-neutral4",children:"Never"})})]},i.id))]})}function IXr({workflowId:e}={}){const{data:t,isLoading:n,error:r}=zSe(e?{workflowId:e}:{}),[s,a]=y.useState("");return r?o.jsx(Di,{title:"Failed to load schedules",message:r.message}):o.jsxs("div",{className:"grid grid-rows-[auto_1fr] gap-4 h-full overflow-hidden",children:[o.jsx("div",{className:"max-w-120",children:o.jsx(xf,{onSearch:a,label:"Filter schedules",placeholder:"Filter by id or workflow"})}),o.jsx("div",{className:"overflow-y-auto",children:o.jsx(NXr,{schedules:t??[],isLoading:n,search:s})})]})}function AXr(){const[e]=zi(),t=e.get("workflowId")??void 0,{error:n}=zSe(t?{workflowId:t}:{});return n&&cs(n)?o.jsx(or,{children:o.jsx(Ms,{})}):n&&ds(n)?o.jsx(or,{children:o.jsx(ks,{resource:"schedules"})}):o.jsx(Dt,{children:o.jsx("div",{className:"h-full",children:o.jsx(IXr,{workflowId:t})})})}const dWe=()=>{const{workflowId:e}=vr(),{data:t,isLoading:n,error:r}=lD(e);return r&&cs(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(Ms,{})}):r&&ds(r)?o.jsx("div",{className:"flex h-full items-center justify-center",children:o.jsx(ks,{resource:"workflows"})}):o.jsx(zRt,{workflowId:e,workflow:t??void 0,isLoading:n})};function RXr(e,t){if(e==null)return{};var n,r,s=tpt(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}function mge(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function PXr(e){if(Array.isArray(e))return mge(e)}function $Xr(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function MXr(e,t){if(e){if(typeof e=="string")return mge(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?mge(e,t):void 0}}function DXr(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
768
768
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gge(e){return PXr(e)||$Xr(e)||MXr(e)||DXr()}function SM(e){"@babel/helpers - typeof";return SM=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},SM(e)}function LXr(e,t){if(SM(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(SM(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function FXr(e){var t=LXr(e,"string");return SM(t)=="symbol"?t:t+""}function V5t(e,t,n){return(t=FXr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function fWe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function UE(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?fWe(Object(n),!0).forEach(function(r){V5t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fWe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function zXr(e){var t=e.length;if(t===0||t===1)return e;if(t===2)return[e[0],e[1],"".concat(e[0],".").concat(e[1]),"".concat(e[1],".").concat(e[0])];if(t===3)return[e[0],e[1],e[2],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0])];if(t>=4)return[e[0],e[1],e[2],e[3],"".concat(e[0],".").concat(e[1]),"".concat(e[0],".").concat(e[2]),"".concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[0]),"".concat(e[1],".").concat(e[2]),"".concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[1]),"".concat(e[2],".").concat(e[3]),"".concat(e[3],".").concat(e[0]),"".concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[0]),"".concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[0],".").concat(e[1],".").concat(e[2],".").concat(e[3]),"".concat(e[0],".").concat(e[1],".").concat(e[3],".").concat(e[2]),"".concat(e[0],".").concat(e[2],".").concat(e[1],".").concat(e[3]),"".concat(e[0],".").concat(e[2],".").concat(e[3],".").concat(e[1]),"".concat(e[0],".").concat(e[3],".").concat(e[1],".").concat(e[2]),"".concat(e[0],".").concat(e[3],".").concat(e[2],".").concat(e[1]),"".concat(e[1],".").concat(e[0],".").concat(e[2],".").concat(e[3]),"".concat(e[1],".").concat(e[0],".").concat(e[3],".").concat(e[2]),"".concat(e[1],".").concat(e[2],".").concat(e[0],".").concat(e[3]),"".concat(e[1],".").concat(e[2],".").concat(e[3],".").concat(e[0]),"".concat(e[1],".").concat(e[3],".").concat(e[0],".").concat(e[2]),"".concat(e[1],".").concat(e[3],".").concat(e[2],".").concat(e[0]),"".concat(e[2],".").concat(e[0],".").concat(e[1],".").concat(e[3]),"".concat(e[2],".").concat(e[0],".").concat(e[3],".").concat(e[1]),"".concat(e[2],".").concat(e[1],".").concat(e[0],".").concat(e[3]),"".concat(e[2],".").concat(e[1],".").concat(e[3],".").concat(e[0]),"".concat(e[2],".").concat(e[3],".").concat(e[0],".").concat(e[1]),"".concat(e[2],".").concat(e[3],".").concat(e[1],".").concat(e[0]),"".concat(e[3],".").concat(e[0],".").concat(e[1],".").concat(e[2]),"".concat(e[3],".").concat(e[0],".").concat(e[2],".").concat(e[1]),"".concat(e[3],".").concat(e[1],".").concat(e[0],".").concat(e[2]),"".concat(e[3],".").concat(e[1],".").concat(e[2],".").concat(e[0]),"".concat(e[3],".").concat(e[2],".").concat(e[0],".").concat(e[1]),"".concat(e[3],".").concat(e[2],".").concat(e[1],".").concat(e[0])]}var Hne={};function BXr(e){if(e.length===0||e.length===1)return e;var t=e.join(".");return Hne[t]||(Hne[t]=zXr(e)),Hne[t]}function UXr(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,r=e.filter(function(a){return a!=="token"}),s=BXr(r);return s.reduce(function(a,i){return UE(UE({},a),n[i])},t)}function pWe(e){return e.join(" ")}function qXr(e,t){var n=0;return function(r){return n+=1,r.map(function(s,a){return H5t({node:s,stylesheet:e,useInlineStyles:t,key:"code-segment-".concat(n,"-").concat(a)})})}}function H5t(e){var t=e.node,n=e.stylesheet,r=e.style,s=r===void 0?{}:r,a=e.useInlineStyles,i=e.key,l=t.properties,c=t.type,u=t.tagName,d=t.value;if(c==="text")return d;if(u){var f=qXr(n,a),p;if(!a)p=UE(UE({},l),{},{className:pWe(l.className)});else{var h=Object.keys(n).reduce(function(b,w){return w.split(".").forEach(function(S){b.includes(S)||b.push(S)}),b},[]),m=l.className&&l.className.includes("token")?["token"]:[],g=l.className&&m.concat(l.className.filter(function(b){return!h.includes(b)}));p=UE(UE({},l),{},{className:pWe(g)||void 0,style:UXr(l.className,Object.assign({},l.style,s),n)})}var v=f(t.children);return De.createElement(u,uO({key:i},p),v)}}const VXr=(function(e,t){var n=e.listLanguages();return n.indexOf(t)!==-1});var HXr=["language","children","style","customStyle","codeTagProps","useInlineStyles","showLineNumbers","showInlineLineNumbers","startingLineNumber","lineNumberContainerStyle","lineNumberStyle","wrapLines","wrapLongLines","lineProps","renderer","PreTag","CodeTag","code","astGenerator"];function hWe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,r)}return n}function dw(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hWe(Object(n),!0).forEach(function(r){V5t(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hWe(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var ZXr=/\n/g;function WXr(e){return e.match(ZXr)}function QXr(e){var t=e.lines,n=e.startingLineNumber,r=e.style;return t.map(function(s,a){var i=a+n;return De.createElement("span",{key:"line-".concat(a),className:"react-syntax-highlighter-line-number",style:typeof r=="function"?r(i):r},"".concat(i,`
|
|
769
769
|
`))})}function GXr(e){var t=e.codeString,n=e.codeStyle,r=e.containerStyle,s=r===void 0?{float:"left",paddingRight:"10px"}:r,a=e.numberStyle,i=a===void 0?{}:a,l=e.startingLineNumber;return De.createElement("code",{style:Object.assign({},n,s)},QXr({lines:t.replace(/\n$/,"").split(`
|
|
770
770
|
`),style:i,startingLineNumber:l}))}function YXr(e){return"".concat(e.toString().length,".25em")}function Z5t(e,t){return{type:"element",tagName:"span",properties:{key:"line-number--".concat(e),className:["comment","linenumber","react-syntax-highlighter-line-number"],style:t},children:[{type:"text",value:e}]}}function W5t(e,t,n){var r={display:"inline-block",minWidth:YXr(n),paddingRight:"1em",textAlign:"right",userSelect:"none"},s=typeof e=="function"?e(t):e,a=dw(dw({},r),s);return a}function N9(e){var t=e.children,n=e.lineNumber,r=e.lineNumberStyle,s=e.largestLineNumber,a=e.showInlineLineNumbers,i=e.lineProps,l=i===void 0?{}:i,c=e.className,u=c===void 0?[]:c,d=e.showLineNumbers,f=e.wrapLongLines,p=e.wrapLines,h=p===void 0?!1:p,m=h?dw({},typeof l=="function"?l(n):l):{};if(m.className=m.className?[].concat(gge(m.className.trim().split(/\s+/)),gge(u)):u,n&&a){var g=W5t(r,n,s);t.unshift(Z5t(n,g))}return f&d&&(m.style=dw({display:"flex"},m.style)),{type:"element",tagName:"span",properties:m,children:t}}function Q5t(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[],r=0;r<e.length;r++){var s=e[r];if(s.type==="text")n.push(N9({children:[s],className:gge(new Set(t))}));else if(s.children){var a=t.concat(s.properties.className);Q5t(s.children,a).forEach(function(i){return n.push(i)})}}return n}function XXr(e,t,n,r,s,a,i,l,c){var u,d=Q5t(e.value),f=[],p=-1,h=0;function m(_,C){var j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return N9({children:_,lineNumber:C,lineNumberStyle:l,largestLineNumber:i,showInlineLineNumbers:s,lineProps:n,className:j,showLineNumbers:r,wrapLongLines:c,wrapLines:t})}function g(_,C){if(r&&C&&s){var j=W5t(l,C,i);_.unshift(Z5t(C,j))}return _}function v(_,C){var j=arguments.length>2&&arguments[2]!==void 0?arguments[2]:[];return t||j.length>0?m(_,C,j):g(_,C)}for(var b=function(){var C=d[h],j=C.children[0].value,E=WXr(j);if(E){var N=j.split(`
|