vskill 0.5.125 → 0.5.127

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.
@@ -0,0 +1,102 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-O8YGQyMH.js","assets/fonts-i7Lkz2zN.css","assets/CommandPalette-LtejhB76.js","assets/FindSkillsPalette-Dbl2_IC4.js","assets/SkillDetailPanel-RQc5u4nm.js","assets/skill-url-BpZjDR8A.js","assets/CreateSkillPage-3RuqLQnm.js"])))=>i.map(i=>d[i]);
2
+ /* empty css */(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const u of c)if(u.type==="childList")for(const d of u.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function s(c){const u={};return c.integrity&&(u.integrity=c.integrity),c.referrerPolicy&&(u.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?u.credentials="include":c.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function o(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function iv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ud={exports:{}},As={};/**
3
+ * @license React
4
+ * react-jsx-runtime.production.js
5
+ *
6
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
7
+ *
8
+ * This source code is licensed under the MIT license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */var Nx;function i0(){if(Nx)return As;Nx=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(o,c,u){var d=null;if(u!==void 0&&(d=""+u),c.key!==void 0&&(d=""+c.key),"key"in c){u={};for(var h in c)h!=="key"&&(u[h]=c[h])}else u=c;return c=u.ref,{$$typeof:t,type:o,key:d,ref:c!==void 0?c:null,props:u}}return As.Fragment=a,As.jsx=s,As.jsxs=s,As}var Tx;function o0(){return Tx||(Tx=1,ud.exports=i0()),ud.exports}var r=o0(),dd={exports:{}},Ue={};/**
11
+ * @license React
12
+ * react.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var Rx;function c0(){if(Rx)return Ue;Rx=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.consumer"),d=Symbol.for("react.context"),h=Symbol.for("react.forward_ref"),g=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=b&&M[b]||M["@@iterator"],typeof M=="function"?M:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E=Object.assign,C={};function N(M,Y,G){this.props=M,this.context=Y,this.refs=C,this.updater=G||k}N.prototype.isReactComponent={},N.prototype.setState=function(M,Y){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,Y,"setState")},N.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function T(){}T.prototype=N.prototype;function A(M,Y,G){this.props=M,this.context=Y,this.refs=C,this.updater=G||k}var B=A.prototype=new T;B.constructor=A,E(B,N.prototype),B.isPureReactComponent=!0;var z=Array.isArray;function F(){}var w={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function D(M,Y,G){var te=G.ref;return{$$typeof:t,type:M,key:Y,ref:te!==void 0?te:null,props:G}}function U(M,Y){return D(M.type,Y,M.props)}function H(M){return typeof M=="object"&&M!==null&&M.$$typeof===t}function q(M){var Y={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(G){return Y[G]})}var X=/\/+/g;function J(M,Y){return typeof M=="object"&&M!==null&&M.key!=null?q(""+M.key):Y.toString(36)}function $(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(F,F):(M.status="pending",M.then(function(Y){M.status==="pending"&&(M.status="fulfilled",M.value=Y)},function(Y){M.status==="pending"&&(M.status="rejected",M.reason=Y)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function L(M,Y,G,te,fe){var oe=typeof M;(oe==="undefined"||oe==="boolean")&&(M=null);var ve=!1;if(M===null)ve=!0;else switch(oe){case"bigint":case"string":case"number":ve=!0;break;case"object":switch(M.$$typeof){case t:case a:ve=!0;break;case y:return ve=M._init,L(ve(M._payload),Y,G,te,fe)}}if(ve)return fe=fe(M),ve=te===""?"."+J(M,0):te,z(fe)?(G="",ve!=null&&(G=ve.replace(X,"$&/")+"/"),L(fe,Y,G,"",function(Re){return Re})):fe!=null&&(H(fe)&&(fe=U(fe,G+(fe.key==null||M&&M.key===fe.key?"":(""+fe.key).replace(X,"$&/")+"/")+ve)),Y.push(fe)),1;ve=0;var de=te===""?".":te+":";if(z(M))for(var je=0;je<M.length;je++)te=M[je],oe=de+J(te,je),ve+=L(te,Y,G,oe,fe);else if(je=S(M),typeof je=="function")for(M=je.call(M),je=0;!(te=M.next()).done;)te=te.value,oe=de+J(te,je++),ve+=L(te,Y,G,oe,fe);else if(oe==="object"){if(typeof M.then=="function")return L($(M),Y,G,te,fe);throw Y=String(M),Error("Objects are not valid as a React child (found: "+(Y==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":Y)+"). If you meant to render a collection of children, use an array instead.")}return ve}function _(M,Y,G){if(M==null)return M;var te=[],fe=0;return L(M,te,"","",function(oe){return Y.call(G,oe,fe++)}),te}function I(M){if(M._status===-1){var Y=M._result;Y=Y(),Y.then(function(G){(M._status===0||M._status===-1)&&(M._status=1,M._result=G)},function(G){(M._status===0||M._status===-1)&&(M._status=2,M._result=G)}),M._status===-1&&(M._status=0,M._result=Y)}if(M._status===1)return M._result.default;throw M._result}var V=typeof reportError=="function"?reportError:function(M){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Y=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof M=="object"&&M!==null&&typeof M.message=="string"?String(M.message):String(M),error:M});if(!window.dispatchEvent(Y))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",M);return}console.error(M)},ie={map:_,forEach:function(M,Y,G){_(M,function(){Y.apply(this,arguments)},G)},count:function(M){var Y=0;return _(M,function(){Y++}),Y},toArray:function(M){return _(M,function(Y){return Y})||[]},only:function(M){if(!H(M))throw Error("React.Children.only expected to receive a single React element child.");return M}};return Ue.Activity=v,Ue.Children=ie,Ue.Component=N,Ue.Fragment=s,Ue.Profiler=c,Ue.PureComponent=A,Ue.StrictMode=o,Ue.Suspense=g,Ue.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,Ue.__COMPILER_RUNTIME={__proto__:null,c:function(M){return w.H.useMemoCache(M)}},Ue.cache=function(M){return function(){return M.apply(null,arguments)}},Ue.cacheSignal=function(){return null},Ue.cloneElement=function(M,Y,G){if(M==null)throw Error("The argument must be a React element, but you passed "+M+".");var te=E({},M.props),fe=M.key;if(Y!=null)for(oe in Y.key!==void 0&&(fe=""+Y.key),Y)!O.call(Y,oe)||oe==="key"||oe==="__self"||oe==="__source"||oe==="ref"&&Y.ref===void 0||(te[oe]=Y[oe]);var oe=arguments.length-2;if(oe===1)te.children=G;else if(1<oe){for(var ve=Array(oe),de=0;de<oe;de++)ve[de]=arguments[de+2];te.children=ve}return D(M.type,fe,te)},Ue.createContext=function(M){return M={$$typeof:d,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null},M.Provider=M,M.Consumer={$$typeof:u,_context:M},M},Ue.createElement=function(M,Y,G){var te,fe={},oe=null;if(Y!=null)for(te in Y.key!==void 0&&(oe=""+Y.key),Y)O.call(Y,te)&&te!=="key"&&te!=="__self"&&te!=="__source"&&(fe[te]=Y[te]);var ve=arguments.length-2;if(ve===1)fe.children=G;else if(1<ve){for(var de=Array(ve),je=0;je<ve;je++)de[je]=arguments[je+2];fe.children=de}if(M&&M.defaultProps)for(te in ve=M.defaultProps,ve)fe[te]===void 0&&(fe[te]=ve[te]);return D(M,oe,fe)},Ue.createRef=function(){return{current:null}},Ue.forwardRef=function(M){return{$$typeof:h,render:M}},Ue.isValidElement=H,Ue.lazy=function(M){return{$$typeof:y,_payload:{_status:-1,_result:M},_init:I}},Ue.memo=function(M,Y){return{$$typeof:m,type:M,compare:Y===void 0?null:Y}},Ue.startTransition=function(M){var Y=w.T,G={};w.T=G;try{var te=M(),fe=w.S;fe!==null&&fe(G,te),typeof te=="object"&&te!==null&&typeof te.then=="function"&&te.then(F,V)}catch(oe){V(oe)}finally{Y!==null&&G.types!==null&&(Y.types=G.types),w.T=Y}},Ue.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},Ue.use=function(M){return w.H.use(M)},Ue.useActionState=function(M,Y,G){return w.H.useActionState(M,Y,G)},Ue.useCallback=function(M,Y){return w.H.useCallback(M,Y)},Ue.useContext=function(M){return w.H.useContext(M)},Ue.useDebugValue=function(){},Ue.useDeferredValue=function(M,Y){return w.H.useDeferredValue(M,Y)},Ue.useEffect=function(M,Y){return w.H.useEffect(M,Y)},Ue.useEffectEvent=function(M){return w.H.useEffectEvent(M)},Ue.useId=function(){return w.H.useId()},Ue.useImperativeHandle=function(M,Y,G){return w.H.useImperativeHandle(M,Y,G)},Ue.useInsertionEffect=function(M,Y){return w.H.useInsertionEffect(M,Y)},Ue.useLayoutEffect=function(M,Y){return w.H.useLayoutEffect(M,Y)},Ue.useMemo=function(M,Y){return w.H.useMemo(M,Y)},Ue.useOptimistic=function(M,Y){return w.H.useOptimistic(M,Y)},Ue.useReducer=function(M,Y,G){return w.H.useReducer(M,Y,G)},Ue.useRef=function(M){return w.H.useRef(M)},Ue.useState=function(M){return w.H.useState(M)},Ue.useSyncExternalStore=function(M,Y,G){return w.H.useSyncExternalStore(M,Y,G)},Ue.useTransition=function(){return w.H.useTransition()},Ue.version="19.2.4",Ue}var Ax;function mf(){return Ax||(Ax=1,dd.exports=c0()),dd.exports}var p=mf();const Ne=iv(p);var fd={exports:{}},Ms={},pd={exports:{}},md={};/**
19
+ * @license React
20
+ * scheduler.production.js
21
+ *
22
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
23
+ *
24
+ * This source code is licensed under the MIT license found in the
25
+ * LICENSE file in the root directory of this source tree.
26
+ */var Mx;function u0(){return Mx||(Mx=1,(function(t){function a(L,_){var I=L.length;L.push(_);e:for(;0<I;){var V=I-1>>>1,ie=L[V];if(0<c(ie,_))L[V]=_,L[I]=ie,I=V;else break e}}function s(L){return L.length===0?null:L[0]}function o(L){if(L.length===0)return null;var _=L[0],I=L.pop();if(I!==_){L[0]=I;e:for(var V=0,ie=L.length,M=ie>>>1;V<M;){var Y=2*(V+1)-1,G=L[Y],te=Y+1,fe=L[te];if(0>c(G,I))te<ie&&0>c(fe,G)?(L[V]=fe,L[te]=I,V=te):(L[V]=G,L[Y]=I,V=Y);else if(te<ie&&0>c(fe,I))L[V]=fe,L[te]=I,V=te;else break e}}return _}function c(L,_){var I=L.sortIndex-_.sortIndex;return I!==0?I:L.id-_.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var u=performance;t.unstable_now=function(){return u.now()}}else{var d=Date,h=d.now();t.unstable_now=function(){return d.now()-h}}var g=[],m=[],y=1,v=null,b=3,S=!1,k=!1,E=!1,C=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,A=typeof setImmediate<"u"?setImmediate:null;function B(L){for(var _=s(m);_!==null;){if(_.callback===null)o(m);else if(_.startTime<=L)o(m),_.sortIndex=_.expirationTime,a(g,_);else break;_=s(m)}}function z(L){if(E=!1,B(L),!k)if(s(g)!==null)k=!0,F||(F=!0,q());else{var _=s(m);_!==null&&$(z,_.startTime-L)}}var F=!1,w=-1,O=5,D=-1;function U(){return C?!0:!(t.unstable_now()-D<O)}function H(){if(C=!1,F){var L=t.unstable_now();D=L;var _=!0;try{e:{k=!1,E&&(E=!1,T(w),w=-1),S=!0;var I=b;try{t:{for(B(L),v=s(g);v!==null&&!(v.expirationTime>L&&U());){var V=v.callback;if(typeof V=="function"){v.callback=null,b=v.priorityLevel;var ie=V(v.expirationTime<=L);if(L=t.unstable_now(),typeof ie=="function"){v.callback=ie,B(L),_=!0;break t}v===s(g)&&o(g),B(L)}else o(g);v=s(g)}if(v!==null)_=!0;else{var M=s(m);M!==null&&$(z,M.startTime-L),_=!1}}break e}finally{v=null,b=I,S=!1}_=void 0}}finally{_?q():F=!1}}}var q;if(typeof A=="function")q=function(){A(H)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,J=X.port2;X.port1.onmessage=H,q=function(){J.postMessage(null)}}else q=function(){N(H,0)};function $(L,_){w=N(function(){L(t.unstable_now())},_)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125<L?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<L?Math.floor(1e3/L):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(L){switch(b){case 1:case 2:case 3:var _=3;break;default:_=b}var I=b;b=_;try{return L()}finally{b=I}},t.unstable_requestPaint=function(){C=!0},t.unstable_runWithPriority=function(L,_){switch(L){case 1:case 2:case 3:case 4:case 5:break;default:L=3}var I=b;b=L;try{return _()}finally{b=I}},t.unstable_scheduleCallback=function(L,_,I){var V=t.unstable_now();switch(typeof I=="object"&&I!==null?(I=I.delay,I=typeof I=="number"&&0<I?V+I:V):I=V,L){case 1:var ie=-1;break;case 2:ie=250;break;case 5:ie=1073741823;break;case 4:ie=1e4;break;default:ie=5e3}return ie=I+ie,L={id:y++,callback:_,priorityLevel:L,startTime:I,expirationTime:ie,sortIndex:-1},I>V?(L.sortIndex=I,a(m,L),s(g)===null&&L===s(m)&&(E?(T(w),w=-1):E=!0,$(z,I-V))):(L.sortIndex=ie,a(g,L),k||S||(k=!0,F||(F=!0,q()))),L},t.unstable_shouldYield=U,t.unstable_wrapCallback=function(L){var _=b;return function(){var I=b;b=_;try{return L.apply(this,arguments)}finally{b=I}}}})(md)),md}var Lx;function d0(){return Lx||(Lx=1,pd.exports=u0()),pd.exports}var hd={exports:{}},nn={};/**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var zx;function f0(){if(zx)return nn;zx=1;var t=mf();function a(g){var m="https://react.dev/errors/"+g;if(1<arguments.length){m+="?args[]="+encodeURIComponent(arguments[1]);for(var y=2;y<arguments.length;y++)m+="&args[]="+encodeURIComponent(arguments[y])}return"Minified React error #"+g+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var o={d:{f:s,r:function(){throw Error(a(522))},D:s,C:s,L:s,m:s,X:s,S:s,M:s},p:0,findDOMNode:null},c=Symbol.for("react.portal");function u(g,m,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:g,containerInfo:m,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(g,m){if(g==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return nn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,nn.createPortal=function(g,m){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!m||m.nodeType!==1&&m.nodeType!==9&&m.nodeType!==11)throw Error(a(299));return u(g,m,null,y)},nn.flushSync=function(g){var m=d.T,y=o.p;try{if(d.T=null,o.p=2,g)return g()}finally{d.T=m,o.p=y,o.d.f()}},nn.preconnect=function(g,m){typeof g=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,o.d.C(g,m))},nn.prefetchDNS=function(g){typeof g=="string"&&o.d.D(g)},nn.preinit=function(g,m){if(typeof g=="string"&&m&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin),b=typeof m.integrity=="string"?m.integrity:void 0,S=typeof m.fetchPriority=="string"?m.fetchPriority:void 0;y==="style"?o.d.S(g,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&o.d.X(g,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},nn.preinitModule=function(g,m){if(typeof g=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=h(m.as,m.crossOrigin);o.d.M(g,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&o.d.M(g)},nn.preload=function(g,m){if(typeof g=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin);o.d.L(g,y,{crossOrigin:v,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0,type:typeof m.type=="string"?m.type:void 0,fetchPriority:typeof m.fetchPriority=="string"?m.fetchPriority:void 0,referrerPolicy:typeof m.referrerPolicy=="string"?m.referrerPolicy:void 0,imageSrcSet:typeof m.imageSrcSet=="string"?m.imageSrcSet:void 0,imageSizes:typeof m.imageSizes=="string"?m.imageSizes:void 0,media:typeof m.media=="string"?m.media:void 0})}},nn.preloadModule=function(g,m){if(typeof g=="string")if(m){var y=h(m.as,m.crossOrigin);o.d.m(g,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else o.d.m(g)},nn.requestFormReset=function(g){o.d.r(g)},nn.unstable_batchedUpdates=function(g,m){return g(m)},nn.useFormState=function(g,m,y){return d.H.useFormState(g,m,y)},nn.useFormStatus=function(){return d.H.useHostTransitionStatus()},nn.version="19.2.4",nn}var Dx;function ov(){if(Dx)return hd.exports;Dx=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(a){console.error(a)}}return t(),hd.exports=f0(),hd.exports}/**
35
+ * @license React
36
+ * react-dom-client.production.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var _x;function p0(){if(_x)return Ms;_x=1;var t=d0(),a=mf(),s=ov();function o(e){var n="https://react.dev/errors/"+e;if(1<arguments.length){n+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)n+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+e+"; visit "+n+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function u(e){var n=e,l=e;if(e.alternate)for(;n.return;)n=n.return;else{e=n;do n=e,(n.flags&4098)!==0&&(l=n.return),e=n.return;while(e)}return n.tag===3?l:null}function d(e){if(e.tag===13){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function h(e){if(e.tag===31){var n=e.memoizedState;if(n===null&&(e=e.alternate,e!==null&&(n=e.memoizedState)),n!==null)return n.dehydrated}return null}function g(e){if(u(e)!==e)throw Error(o(188))}function m(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(o(188));return n!==e?null:e}for(var l=e,i=n;;){var f=l.return;if(f===null)break;var x=f.alternate;if(x===null){if(i=f.return,i!==null){l=i;continue}break}if(f.child===x.child){for(x=f.child;x;){if(x===l)return g(f),e;if(x===i)return g(f),n;x=x.sibling}throw Error(o(188))}if(l.return!==i.return)l=f,i=x;else{for(var j=!1,R=f.child;R;){if(R===l){j=!0,l=f,i=x;break}if(R===i){j=!0,i=f,l=x;break}R=R.sibling}if(!j){for(R=x.child;R;){if(R===l){j=!0,l=x,i=f;break}if(R===i){j=!0,i=x,l=f;break}R=R.sibling}if(!j)throw Error(o(189))}}if(l.alternate!==i)throw Error(o(190))}if(l.tag!==3)throw Error(o(188));return l.stateNode.current===l?e:n}function y(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e;for(e=e.child;e!==null;){if(n=y(e),n!==null)return n;e=e.sibling}return null}var v=Object.assign,b=Symbol.for("react.element"),S=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),A=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),U=Symbol.for("react.memo_cache_sentinel"),H=Symbol.iterator;function q(e){return e===null||typeof e!="object"?null:(e=H&&e[H]||e["@@iterator"],typeof e=="function"?e:null)}var X=Symbol.for("react.client.reference");function J(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===X?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case E:return"Fragment";case N:return"Profiler";case C:return"StrictMode";case z:return"Suspense";case F:return"SuspenseList";case D:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case k:return"Portal";case A:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case B:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case w:return n=e.displayName||null,n!==null?n:J(e.type)||"Memo";case O:n=e._payload,e=e._init;try{return J(e(n))}catch{}}return null}var $=Array.isArray,L=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,_=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},V=[],ie=-1;function M(e){return{current:e}}function Y(e){0>ie||(e.current=V[ie],V[ie]=null,ie--)}function G(e,n){ie++,V[ie]=e.current,e.current=n}var te=M(null),fe=M(null),oe=M(null),ve=M(null);function de(e,n){switch(G(oe,n),G(fe,e),G(te,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?Xh(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=Xh(n),e=Qh(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}Y(te),G(te,e)}function je(){Y(te),Y(fe),Y(oe)}function Re(e){e.memoizedState!==null&&G(ve,e);var n=te.current,l=Qh(n,e.type);n!==l&&(G(fe,e),G(te,l))}function _e(e){fe.current===e&&(Y(te),Y(fe)),ve.current===e&&(Y(ve),Es._currentValue=I)}var ae,he;function pe(e){if(ae===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);ae=n&&n[1]||"",he=-1<l.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+ae+e+he}var xe=!1;function be(e,n){if(!e||xe)return"";xe=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var i={DetermineComponentFrameRoot:function(){try{if(n){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(re){var ee=re}Reflect.construct(e,[],ue)}else{try{ue.call()}catch(re){ee=re}e.call(ue.prototype)}}else{try{throw Error()}catch(re){ee=re}(ue=e())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(re){if(re&&ee&&typeof re.stack=="string")return[re.stack,ee.stack]}return[null,null]}};i.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(i.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(i.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var x=i.DetermineComponentFrameRoot(),j=x[0],R=x[1];if(j&&R){var P=j.split(`
45
+ `),Z=R.split(`
46
+ `);for(f=i=0;i<P.length&&!P[i].includes("DetermineComponentFrameRoot");)i++;for(;f<Z.length&&!Z[f].includes("DetermineComponentFrameRoot");)f++;if(i===P.length||f===Z.length)for(i=P.length-1,f=Z.length-1;1<=i&&0<=f&&P[i]!==Z[f];)f--;for(;1<=i&&0<=f;i--,f--)if(P[i]!==Z[f]){if(i!==1||f!==1)do if(i--,f--,0>f||P[i]!==Z[f]){var se=`
47
+ `+P[i].replace(" at new "," at ");return e.displayName&&se.includes("<anonymous>")&&(se=se.replace("<anonymous>",e.displayName)),se}while(1<=i&&0<=f);break}}}finally{xe=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?pe(l):""}function Be(e,n){switch(e.tag){case 26:case 27:case 5:return pe(e.type);case 16:return pe("Lazy");case 13:return e.child!==n&&n!==null?pe("Suspense Fallback"):pe("Suspense");case 19:return pe("SuspenseList");case 0:case 15:return be(e.type,!1);case 11:return be(e.type.render,!1);case 1:return be(e.type,!0);case 31:return pe("Activity");default:return""}}function Oe(e){try{var n="",l=null;do n+=Be(e,l),l=e,e=e.return;while(e);return n}catch(i){return`
48
+ Error generating stack: `+i.message+`
49
+ `+i.stack}}var lt=Object.prototype.hasOwnProperty,Nt=t.unstable_scheduleCallback,xt=t.unstable_cancelCallback,_t=t.unstable_shouldYield,Tt=t.unstable_requestPaint,Ze=t.unstable_now,nt=t.unstable_getCurrentPriorityLevel,ye=t.unstable_ImmediatePriority,mt=t.unstable_UserBlockingPriority,Et=t.unstable_NormalPriority,Xt=t.unstable_LowPriority,fn=t.unstable_IdlePriority,Wt=t.log,ln=t.unstable_setDisableYieldValue,Mn=null,Lt=null;function vt(e){if(typeof Wt=="function"&&ln(e),Lt&&typeof Lt.setStrictMode=="function")try{Lt.setStrictMode(Mn,e)}catch{}}var gt=Math.clz32?Math.clz32:dr,Wn=Math.log,zr=Math.LN2;function dr(e){return e>>>=0,e===0?32:31-(Wn(e)/zr|0)|0}var Rt=256,qt=262144,Ie=4194304;function le(e){var n=e&42;if(n!==0)return n;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Se(e,n,l){var i=e.pendingLanes;if(i===0)return 0;var f=0,x=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var R=i&134217727;return R!==0?(i=R&~x,i!==0?f=le(i):(j&=R,j!==0?f=le(j):l||(l=R&~e,l!==0&&(f=le(l))))):(R=i&~x,R!==0?f=le(R):j!==0?f=le(j):l||(l=i&~e,l!==0&&(f=le(l)))),f===0?0:n!==0&&n!==f&&(n&x)===0&&(x=f&-f,l=n&-n,x>=l||x===32&&(l&4194048)!==0)?n:f}function Me(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function Fa(e,n){switch(e){case 1:case 2:case 4:case 8:case 64:return n+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return n+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function qn(){var e=Ie;return Ie<<=1,(Ie&62914560)===0&&(Ie=4194304),e}function Ul(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function fa(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Hl(e,n,l,i,f,x){var j=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var R=e.entanglements,P=e.expirationTimes,Z=e.hiddenUpdates;for(l=j&~l;0<l;){var se=31-gt(l),ue=1<<se;R[se]=0,P[se]=-1;var ee=Z[se];if(ee!==null)for(Z[se]=null,se=0;se<ee.length;se++){var re=ee[se];re!==null&&(re.lane&=-536870913)}l&=~ue}i!==0&&tr(e,i,0),x!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=x&~(j&~n))}function tr(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var i=31-gt(n);e.entangledLanes|=n,e.entanglements[i]=e.entanglements[i]|1073741824|l&261930}function pa(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var i=31-gt(l),f=1<<i;f&n|e[i]&n&&(e[i]|=n),l&=~f}}function ma(e,n){var l=n&-n;return l=(l&42)!==0?1:Ga(l),(l&(e.suspendedLanes|n))!==0?0:l}function Ga(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Dr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ot(){var e=_.p;return e!==0?e:(e=window.event,e===void 0?32:bx(e.type))}function ha(e,n){var l=_.p;try{return _.p=e,n()}finally{_.p=l}}var sn=Math.random().toString(36).slice(2),$t="__reactFiber$"+sn,ct="__reactProps$"+sn,xa="__reactContainer$"+sn,nr="__reactEvents$"+sn,tc="__reactListeners$"+sn,Qy="__reactHandles$"+sn,Bf="__reactResources$"+sn,$l="__reactMarker$"+sn;function nc(e){delete e[$t],delete e[ct],delete e[nr],delete e[tc],delete e[Qy]}function Wa(e){var n=e[$t];if(n)return n;for(var l=e.parentNode;l;){if(n=l[xa]||l[$t]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=ax(e);e!==null;){if(l=e[$t])return l;e=ax(e)}return n}e=l,l=e.parentNode}return null}function qa(e){if(e=e[$t]||e[xa]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function Vl(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(o(33))}function Ya(e){var n=e[Bf];return n||(n=e[Bf]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Yt(e){e[$l]=!0}var If=new Set,Uf={};function ga(e,n){Ka(e,n),Ka(e+"Capture",n)}function Ka(e,n){for(Uf[e]=n,e=0;e<n.length;e++)If.add(n[e])}var Zy=RegExp("^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),Hf={},$f={};function Jy(e){return lt.call($f,e)?!0:lt.call(Hf,e)?!1:Zy.test(e)?$f[e]=!0:(Hf[e]=!0,!1)}function li(e,n,l){if(Jy(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var i=n.toLowerCase().slice(0,5);if(i!=="data-"&&i!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function si(e,n,l){if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(n);return}e.setAttribute(n,""+l)}}function fr(e,n,l,i){if(i===null)e.removeAttribute(l);else{switch(typeof i){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+i)}}function Ln(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Vf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function eb(e,n,l){var i=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof i<"u"&&typeof i.get=="function"&&typeof i.set=="function"){var f=i.get,x=i.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,x.call(this,j)}}),Object.defineProperty(e,n,{enumerable:i.enumerable}),{getValue:function(){return l},setValue:function(j){l=""+j},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function rc(e){if(!e._valueTracker){var n=Vf(e)?"checked":"value";e._valueTracker=eb(e,n,""+e[n])}}function Pf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),i="";return e&&(i=Vf(e)?e.checked?"true":"false":e.value),e=i,e!==l?(n.setValue(e),!0):!1}function ii(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var tb=/[\n"\\]/g;function zn(e){return e.replace(tb,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function ac(e,n,l,i,f,x,j,R){e.name="",j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"?e.type=j:e.removeAttribute("type"),n!=null?j==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+Ln(n)):e.value!==""+Ln(n)&&(e.value=""+Ln(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?lc(e,j,Ln(n)):l!=null?lc(e,j,Ln(l)):i!=null&&e.removeAttribute("value"),f==null&&x!=null&&(e.defaultChecked=!!x),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),R!=null&&typeof R!="function"&&typeof R!="symbol"&&typeof R!="boolean"?e.name=""+Ln(R):e.removeAttribute("name")}function Ff(e,n,l,i,f,x,j,R){if(x!=null&&typeof x!="function"&&typeof x!="symbol"&&typeof x!="boolean"&&(e.type=x),n!=null||l!=null){if(!(x!=="submit"&&x!=="reset"||n!=null)){rc(e);return}l=l!=null?""+Ln(l):"",n=n!=null?""+Ln(n):l,R||n===e.value||(e.value=n),e.defaultValue=n}i=i??f,i=typeof i!="function"&&typeof i!="symbol"&&!!i,e.checked=R?e.checked:!!i,e.defaultChecked=!!i,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),rc(e)}function lc(e,n,l){n==="number"&&ii(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Xa(e,n,l,i){if(e=e.options,n){n={};for(var f=0;f<l.length;f++)n["$"+l[f]]=!0;for(l=0;l<e.length;l++)f=n.hasOwnProperty("$"+e[l].value),e[l].selected!==f&&(e[l].selected=f),f&&i&&(e[l].defaultSelected=!0)}else{for(l=""+Ln(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,i&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function Gf(e,n,l){if(n!=null&&(n=""+Ln(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Ln(l):""}function Wf(e,n,l,i){if(n==null){if(i!=null){if(l!=null)throw Error(o(92));if($(i)){if(1<i.length)throw Error(o(93));i=i[0]}l=i}l==null&&(l=""),n=l}l=Ln(n),e.defaultValue=l,i=e.textContent,i===l&&i!==""&&i!==null&&(e.value=i),rc(e)}function Qa(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var nb=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function qf(e,n,l){var i=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?i?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":i?e.setProperty(n,l):typeof l!="number"||l===0||nb.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function Yf(e,n,l){if(n!=null&&typeof n!="object")throw Error(o(62));if(e=e.style,l!=null){for(var i in l)!l.hasOwnProperty(i)||n!=null&&n.hasOwnProperty(i)||(i.indexOf("--")===0?e.setProperty(i,""):i==="float"?e.cssFloat="":e[i]="");for(var f in n)i=n[f],n.hasOwnProperty(f)&&l[f]!==i&&qf(e,f,i)}else for(var x in n)n.hasOwnProperty(x)&&qf(e,x,n[x])}function sc(e){if(e.indexOf("-")===-1)return!1;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var rb=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),ab=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function oi(e){return ab.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function pr(){}var ic=null;function oc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Za=null,Ja=null;function Kf(e){var n=qa(e);if(n&&(e=n.stateNode)){var l=e[ct]||null;e:switch(e=n.stateNode,n.type){case"input":if(ac(e,l.value,l.defaultValue,l.defaultValue,l.checked,l.defaultChecked,l.type,l.name),n=l.name,l.type==="radio"&&n!=null){for(l=e;l.parentNode;)l=l.parentNode;for(l=l.querySelectorAll('input[name="'+zn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var i=l[n];if(i!==e&&i.form===e.form){var f=i[ct]||null;if(!f)throw Error(o(90));ac(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)i=l[n],i.form===e.form&&Pf(i)}break e;case"textarea":Gf(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&Xa(e,!!l.multiple,n,!1)}}}var cc=!1;function Xf(e,n,l){if(cc)return e(n,l);cc=!0;try{var i=e(n);return i}finally{if(cc=!1,(Za!==null||Ja!==null)&&(Ki(),Za&&(n=Za,e=Ja,Ja=Za=null,Kf(n),e)))for(n=0;n<e.length;n++)Kf(e[n])}}function Pl(e,n){var l=e.stateNode;if(l===null)return null;var i=l[ct]||null;if(i===null)return null;l=i[n];e:switch(n){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(i=!i.disabled)||(e=e.type,i=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!i;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(o(231,n,typeof l));return l}var mr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),uc=!1;if(mr)try{var Fl={};Object.defineProperty(Fl,"passive",{get:function(){uc=!0}}),window.addEventListener("test",Fl,Fl),window.removeEventListener("test",Fl,Fl)}catch{uc=!1}var _r=null,dc=null,ci=null;function Qf(){if(ci)return ci;var e,n=dc,l=n.length,i,f="value"in _r?_r.value:_r.textContent,x=f.length;for(e=0;e<l&&n[e]===f[e];e++);var j=l-e;for(i=1;i<=j&&n[l-i]===f[x-i];i++);return ci=f.slice(e,1<i?1-i:void 0)}function ui(e){var n=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&n===13&&(e=13)):e=n,e===10&&(e=13),32<=e||e===13?e:0}function di(){return!0}function Zf(){return!1}function pn(e){function n(l,i,f,x,j){this._reactName=l,this._targetInst=f,this.type=i,this.nativeEvent=x,this.target=j,this.currentTarget=null;for(var R in e)e.hasOwnProperty(R)&&(l=e[R],this[R]=l?l(x):x[R]);return this.isDefaultPrevented=(x.defaultPrevented!=null?x.defaultPrevented:x.returnValue===!1)?di:Zf,this.isPropagationStopped=Zf,this}return v(n.prototype,{preventDefault:function(){this.defaultPrevented=!0;var l=this.nativeEvent;l&&(l.preventDefault?l.preventDefault():typeof l.returnValue!="unknown"&&(l.returnValue=!1),this.isDefaultPrevented=di)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=di)},persist:function(){},isPersistent:di}),n}var va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fi=pn(va),Gl=v({},va,{view:0,detail:0}),lb=pn(Gl),fc,pc,Wl,pi=v({},Gl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:hc,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==Wl&&(Wl&&e.type==="mousemove"?(fc=e.screenX-Wl.screenX,pc=e.screenY-Wl.screenY):pc=fc=0,Wl=e),fc)},movementY:function(e){return"movementY"in e?e.movementY:pc}}),Jf=pn(pi),sb=v({},pi,{dataTransfer:0}),ib=pn(sb),ob=v({},Gl,{relatedTarget:0}),mc=pn(ob),cb=v({},va,{animationName:0,elapsedTime:0,pseudoElement:0}),ub=pn(cb),db=v({},va,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),fb=pn(db),pb=v({},va,{data:0}),ep=pn(pb),mb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hb={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},xb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function gb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=xb[e])?!!n[e]:!1}function hc(){return gb}var vb=v({},Gl,{key:function(e){if(e.key){var n=mb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=ui(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?hb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:hc,charCode:function(e){return e.type==="keypress"?ui(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?ui(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),yb=pn(vb),bb=v({},pi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),tp=pn(bb),jb=v({},Gl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:hc}),Sb=pn(jb),kb=v({},va,{propertyName:0,elapsedTime:0,pseudoElement:0}),wb=pn(kb),Cb=v({},pi,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Eb=pn(Cb),Nb=v({},va,{newState:0,oldState:0}),Tb=pn(Nb),Rb=[9,13,27,32],xc=mr&&"CompositionEvent"in window,ql=null;mr&&"documentMode"in document&&(ql=document.documentMode);var Ab=mr&&"TextEvent"in window&&!ql,np=mr&&(!xc||ql&&8<ql&&11>=ql),rp=" ",ap=!1;function lp(e,n){switch(e){case"keyup":return Rb.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function sp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var el=!1;function Mb(e,n){switch(e){case"compositionend":return sp(n);case"keypress":return n.which!==32?null:(ap=!0,rp);case"textInput":return e=n.data,e===rp&&ap?null:e;default:return null}}function Lb(e,n){if(el)return e==="compositionend"||!xc&&lp(e,n)?(e=Qf(),ci=dc=_r=null,el=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(n.ctrlKey||n.altKey||n.metaKey)||n.ctrlKey&&n.altKey){if(n.char&&1<n.char.length)return n.char;if(n.which)return String.fromCharCode(n.which)}return null;case"compositionend":return np&&n.locale!=="ko"?null:n.data;default:return null}}var zb={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function ip(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!zb[e.type]:n==="textarea"}function op(e,n,l,i){Za?Ja?Ja.push(i):Ja=[i]:Za=i,n=no(n,"onChange"),0<n.length&&(l=new fi("onChange","change",null,l,i),e.push({event:l,listeners:n}))}var Yl=null,Kl=null;function Db(e){Fh(e,0)}function mi(e){var n=Vl(e);if(Pf(n))return e}function cp(e,n){if(e==="change")return n}var up=!1;if(mr){var gc;if(mr){var vc="oninput"in document;if(!vc){var dp=document.createElement("div");dp.setAttribute("oninput","return;"),vc=typeof dp.oninput=="function"}gc=vc}else gc=!1;up=gc&&(!document.documentMode||9<document.documentMode)}function fp(){Yl&&(Yl.detachEvent("onpropertychange",pp),Kl=Yl=null)}function pp(e){if(e.propertyName==="value"&&mi(Kl)){var n=[];op(n,Kl,e,oc(e)),Xf(Db,n)}}function _b(e,n,l){e==="focusin"?(fp(),Yl=n,Kl=l,Yl.attachEvent("onpropertychange",pp)):e==="focusout"&&fp()}function Ob(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return mi(Kl)}function Bb(e,n){if(e==="click")return mi(n)}function Ib(e,n){if(e==="input"||e==="change")return mi(n)}function Ub(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var yn=typeof Object.is=="function"?Object.is:Ub;function Xl(e,n){if(yn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),i=Object.keys(n);if(l.length!==i.length)return!1;for(i=0;i<l.length;i++){var f=l[i];if(!lt.call(n,f)||!yn(e[f],n[f]))return!1}return!0}function mp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function hp(e,n){var l=mp(e);e=0;for(var i;l;){if(l.nodeType===3){if(i=e+l.textContent.length,e<=n&&i>=n)return{node:l,offset:n-e};e=i}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=mp(l)}}function xp(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?xp(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function gp(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=ii(e.document);n instanceof e.HTMLIFrameElement;){try{var l=typeof n.contentWindow.location.href=="string"}catch{l=!1}if(l)e=n.contentWindow;else break;n=ii(e.document)}return n}function yc(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n&&(n==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||n==="textarea"||e.contentEditable==="true")}var Hb=mr&&"documentMode"in document&&11>=document.documentMode,tl=null,bc=null,Ql=null,jc=!1;function vp(e,n,l){var i=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;jc||tl==null||tl!==ii(i)||(i=tl,"selectionStart"in i&&yc(i)?i={start:i.selectionStart,end:i.selectionEnd}:(i=(i.ownerDocument&&i.ownerDocument.defaultView||window).getSelection(),i={anchorNode:i.anchorNode,anchorOffset:i.anchorOffset,focusNode:i.focusNode,focusOffset:i.focusOffset}),Ql&&Xl(Ql,i)||(Ql=i,i=no(bc,"onSelect"),0<i.length&&(n=new fi("onSelect","select",null,n,l),e.push({event:n,listeners:i}),n.target=tl)))}function ya(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var nl={animationend:ya("Animation","AnimationEnd"),animationiteration:ya("Animation","AnimationIteration"),animationstart:ya("Animation","AnimationStart"),transitionrun:ya("Transition","TransitionRun"),transitionstart:ya("Transition","TransitionStart"),transitioncancel:ya("Transition","TransitionCancel"),transitionend:ya("Transition","TransitionEnd")},Sc={},yp={};mr&&(yp=document.createElement("div").style,"AnimationEvent"in window||(delete nl.animationend.animation,delete nl.animationiteration.animation,delete nl.animationstart.animation),"TransitionEvent"in window||delete nl.transitionend.transition);function ba(e){if(Sc[e])return Sc[e];if(!nl[e])return e;var n=nl[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in yp)return Sc[e]=n[l];return e}var bp=ba("animationend"),jp=ba("animationiteration"),Sp=ba("animationstart"),$b=ba("transitionrun"),Vb=ba("transitionstart"),Pb=ba("transitioncancel"),kp=ba("transitionend"),wp=new Map,kc="abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");kc.push("scrollEnd");function Yn(e,n){wp.set(e,n),ga(n,[e])}var hi=typeof reportError=="function"?reportError:function(e){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var n=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof e=="object"&&e!==null&&typeof e.message=="string"?String(e.message):String(e),error:e});if(!window.dispatchEvent(n))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",e);return}console.error(e)},Dn=[],rl=0,wc=0;function xi(){for(var e=rl,n=wc=rl=0;n<e;){var l=Dn[n];Dn[n++]=null;var i=Dn[n];Dn[n++]=null;var f=Dn[n];Dn[n++]=null;var x=Dn[n];if(Dn[n++]=null,i!==null&&f!==null){var j=i.pending;j===null?f.next=f:(f.next=j.next,j.next=f),i.pending=f}x!==0&&Cp(l,f,x)}}function gi(e,n,l,i){Dn[rl++]=e,Dn[rl++]=n,Dn[rl++]=l,Dn[rl++]=i,wc|=i,e.lanes|=i,e=e.alternate,e!==null&&(e.lanes|=i)}function Cc(e,n,l,i){return gi(e,n,l,i),vi(e)}function ja(e,n){return gi(e,null,null,n),vi(e)}function Cp(e,n,l){e.lanes|=l;var i=e.alternate;i!==null&&(i.lanes|=l);for(var f=!1,x=e.return;x!==null;)x.childLanes|=l,i=x.alternate,i!==null&&(i.childLanes|=l),x.tag===22&&(e=x.stateNode,e===null||e._visibility&1||(f=!0)),e=x,x=x.return;return e.tag===3?(x=e.stateNode,f&&n!==null&&(f=31-gt(l),e=x.hiddenUpdates,i=e[f],i===null?e[f]=[n]:i.push(n),n.lane=l|536870912),x):null}function vi(e){if(50<ys)throw ys=0,Du=null,Error(o(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var al={};function Fb(e,n,l,i){this.tag=e,this.key=l,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=n,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=i,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function bn(e,n,l,i){return new Fb(e,n,l,i)}function Ec(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hr(e,n){var l=e.alternate;return l===null?(l=bn(e.tag,n,e.key,e.mode),l.elementType=e.elementType,l.type=e.type,l.stateNode=e.stateNode,l.alternate=e,e.alternate=l):(l.pendingProps=n,l.type=e.type,l.flags=0,l.subtreeFlags=0,l.deletions=null),l.flags=e.flags&65011712,l.childLanes=e.childLanes,l.lanes=e.lanes,l.child=e.child,l.memoizedProps=e.memoizedProps,l.memoizedState=e.memoizedState,l.updateQueue=e.updateQueue,n=e.dependencies,l.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext},l.sibling=e.sibling,l.index=e.index,l.ref=e.ref,l.refCleanup=e.refCleanup,l}function Ep(e,n){e.flags&=65011714;var l=e.alternate;return l===null?(e.childLanes=0,e.lanes=n,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=l.childLanes,e.lanes=l.lanes,e.child=l.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=l.memoizedProps,e.memoizedState=l.memoizedState,e.updateQueue=l.updateQueue,e.type=l.type,n=l.dependencies,e.dependencies=n===null?null:{lanes:n.lanes,firstContext:n.firstContext}),e}function yi(e,n,l,i,f,x){var j=0;if(i=e,typeof e=="function")Ec(e)&&(j=1);else if(typeof e=="string")j=K1(e,l,te.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case D:return e=bn(31,l,n,f),e.elementType=D,e.lanes=x,e;case E:return Sa(l.children,f,x,n);case C:j=8,f|=24;break;case N:return e=bn(12,l,n,f|2),e.elementType=N,e.lanes=x,e;case z:return e=bn(13,l,n,f),e.elementType=z,e.lanes=x,e;case F:return e=bn(19,l,n,f),e.elementType=F,e.lanes=x,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case A:j=10;break e;case T:j=9;break e;case B:j=11;break e;case w:j=14;break e;case O:j=16,i=null;break e}j=29,l=Error(o(130,e===null?"null":typeof e,"")),i=null}return n=bn(j,l,n,f),n.elementType=e,n.type=i,n.lanes=x,n}function Sa(e,n,l,i){return e=bn(7,e,i,n),e.lanes=l,e}function Nc(e,n,l){return e=bn(6,e,null,n),e.lanes=l,e}function Np(e){var n=bn(18,null,null,0);return n.stateNode=e,n}function Tc(e,n,l){return n=bn(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Tp=new WeakMap;function _n(e,n){if(typeof e=="object"&&e!==null){var l=Tp.get(e);return l!==void 0?l:(n={value:e,source:n,stack:Oe(n)},Tp.set(e,n),n)}return{value:e,source:n,stack:Oe(n)}}var ll=[],sl=0,bi=null,Zl=0,On=[],Bn=0,Or=null,rr=1,ar="";function xr(e,n){ll[sl++]=Zl,ll[sl++]=bi,bi=e,Zl=n}function Rp(e,n,l){On[Bn++]=rr,On[Bn++]=ar,On[Bn++]=Or,Or=e;var i=rr;e=ar;var f=32-gt(i)-1;i&=~(1<<f),l+=1;var x=32-gt(n)+f;if(30<x){var j=f-f%5;x=(i&(1<<j)-1).toString(32),i>>=j,f-=j,rr=1<<32-gt(n)+f|l<<f|i,ar=x+e}else rr=1<<x|l<<f|i,ar=e}function Rc(e){e.return!==null&&(xr(e,1),Rp(e,1,0))}function Ac(e){for(;e===bi;)bi=ll[--sl],ll[sl]=null,Zl=ll[--sl],ll[sl]=null;for(;e===Or;)Or=On[--Bn],On[Bn]=null,ar=On[--Bn],On[Bn]=null,rr=On[--Bn],On[Bn]=null}function Ap(e,n){On[Bn++]=rr,On[Bn++]=ar,On[Bn++]=Or,rr=n.id,ar=n.overflow,Or=e}var Qt=null,yt=null,Xe=!1,Br=null,In=!1,Mc=Error(o(519));function Ir(e){var n=Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Jl(_n(n,e)),Mc}function Mp(e){var n=e.stateNode,l=e.type,i=e.memoizedProps;switch(n[$t]=e,n[ct]=i,l){case"dialog":qe("cancel",n),qe("close",n);break;case"iframe":case"object":case"embed":qe("load",n);break;case"video":case"audio":for(l=0;l<js.length;l++)qe(js[l],n);break;case"source":qe("error",n);break;case"img":case"image":case"link":qe("error",n),qe("load",n);break;case"details":qe("toggle",n);break;case"input":qe("invalid",n),Ff(n,i.value,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name,!0);break;case"select":qe("invalid",n);break;case"textarea":qe("invalid",n),Wf(n,i.value,i.defaultValue,i.children)}l=i.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||i.suppressHydrationWarning===!0||Yh(n.textContent,l)?(i.popover!=null&&(qe("beforetoggle",n),qe("toggle",n)),i.onScroll!=null&&qe("scroll",n),i.onScrollEnd!=null&&qe("scrollend",n),i.onClick!=null&&(n.onclick=pr),n=!0):n=!1,n||Ir(e,!0)}function Lp(e){for(Qt=e.return;Qt;)switch(Qt.tag){case 5:case 31:case 13:In=!1;return;case 27:case 3:In=!0;return;default:Qt=Qt.return}}function il(e){if(e!==Qt)return!1;if(!Xe)return Lp(e),Xe=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||Ku(e.type,e.memoizedProps)),l=!l),l&&yt&&Ir(e),Lp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));yt=rx(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(317));yt=rx(e)}else n===27?(n=yt,Zr(e.type)?(e=ed,ed=null,yt=e):yt=n):yt=Qt?Hn(e.stateNode.nextSibling):null;return!0}function ka(){yt=Qt=null,Xe=!1}function Lc(){var e=Br;return e!==null&&(gn===null?gn=e:gn.push.apply(gn,e),Br=null),e}function Jl(e){Br===null?Br=[e]:Br.push(e)}var zc=M(null),wa=null,gr=null;function Ur(e,n,l){G(zc,n._currentValue),n._currentValue=l}function vr(e){e._currentValue=zc.current,Y(zc)}function Dc(e,n,l){for(;e!==null;){var i=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,i!==null&&(i.childLanes|=n)):i!==null&&(i.childLanes&n)!==n&&(i.childLanes|=n),e===l)break;e=e.return}}function _c(e,n,l,i){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var x=f.dependencies;if(x!==null){var j=f.child;x=x.firstContext;e:for(;x!==null;){var R=x;x=f;for(var P=0;P<n.length;P++)if(R.context===n[P]){x.lanes|=l,R=x.alternate,R!==null&&(R.lanes|=l),Dc(x.return,l,e),i||(j=null);break e}x=R.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(o(341));j.lanes|=l,x=j.alternate,x!==null&&(x.lanes|=l),Dc(j,l,e),j=null}else j=f.child;if(j!==null)j.return=f;else for(j=f;j!==null;){if(j===e){j=null;break}if(f=j.sibling,f!==null){f.return=j.return,j=f;break}j=j.return}f=j}}function ol(e,n,l,i){e=null;for(var f=n,x=!1;f!==null;){if(!x){if((f.flags&524288)!==0)x=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var j=f.alternate;if(j===null)throw Error(o(387));if(j=j.memoizedProps,j!==null){var R=f.type;yn(f.pendingProps.value,j.value)||(e!==null?e.push(R):e=[R])}}else if(f===ve.current){if(j=f.alternate,j===null)throw Error(o(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Es):e=[Es])}f=f.return}e!==null&&_c(n,e,l,i),n.flags|=262144}function ji(e){for(e=e.firstContext;e!==null;){if(!yn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ca(e){wa=e,gr=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Zt(e){return zp(wa,e)}function Si(e,n){return wa===null&&Ca(e),zp(e,n)}function zp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},gr===null){if(e===null)throw Error(o(308));gr=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else gr=gr.next=n;return l}var Gb=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,i){e.push(i)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},Wb=t.unstable_scheduleCallback,qb=t.unstable_NormalPriority,Ot={$$typeof:A,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Oc(){return{controller:new Gb,data:new Map,refCount:0}}function es(e){e.refCount--,e.refCount===0&&Wb(qb,function(){e.controller.abort()})}var ts=null,Bc=0,cl=0,ul=null;function Yb(e,n){if(ts===null){var l=ts=[];Bc=0,cl=Hu(),ul={status:"pending",value:void 0,then:function(i){l.push(i)}}}return Bc++,n.then(Dp,Dp),n}function Dp(){if(--Bc===0&&ts!==null){ul!==null&&(ul.status="fulfilled");var e=ts;ts=null,cl=0,ul=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function Kb(e,n){var l=[],i={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){i.status="fulfilled",i.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(i.status="rejected",i.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),i}var _p=L.S;L.S=function(e,n){vh=Ze(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&Yb(e,n),_p!==null&&_p(e,n)};var Ea=M(null);function Ic(){var e=Ea.current;return e!==null?e:ht.pooledCache}function ki(e,n){n===null?G(Ea,Ea.current):G(Ea,n.pool)}function Op(){var e=Ic();return e===null?null:{parent:Ot._currentValue,pool:e}}var dl=Error(o(460)),Uc=Error(o(474)),wi=Error(o(542)),Ci={then:function(){}};function Bp(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Ip(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(pr,pr),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Hp(e),e;default:if(typeof n.status=="string")n.then(pr,pr);else{if(e=ht,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=n,e.status="pending",e.then(function(i){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=i}},function(i){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=i}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Hp(e),e}throw Ta=n,dl}}function Na(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Ta=l,dl):l}}var Ta=null;function Up(){if(Ta===null)throw Error(o(459));var e=Ta;return Ta=null,e}function Hp(e){if(e===dl||e===wi)throw Error(o(483))}var fl=null,ns=0;function Ei(e){var n=ns;return ns+=1,fl===null&&(fl=[]),Ip(fl,e,n)}function rs(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function Ni(e,n){throw n.$$typeof===b?Error(o(525)):(e=Object.prototype.toString.call(n),Error(o(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function $p(e){function n(K,W){if(e){var Q=K.deletions;Q===null?(K.deletions=[W],K.flags|=16):Q.push(W)}}function l(K,W){if(!e)return null;for(;W!==null;)n(K,W),W=W.sibling;return null}function i(K){for(var W=new Map;K!==null;)K.key!==null?W.set(K.key,K):W.set(K.index,K),K=K.sibling;return W}function f(K,W){return K=hr(K,W),K.index=0,K.sibling=null,K}function x(K,W,Q){return K.index=Q,e?(Q=K.alternate,Q!==null?(Q=Q.index,Q<W?(K.flags|=67108866,W):Q):(K.flags|=67108866,W)):(K.flags|=1048576,W)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function R(K,W,Q,ce){return W===null||W.tag!==6?(W=Nc(Q,K.mode,ce),W.return=K,W):(W=f(W,Q),W.return=K,W)}function P(K,W,Q,ce){var Ae=Q.type;return Ae===E?se(K,W,Q.props.children,ce,Q.key):W!==null&&(W.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===O&&Na(Ae)===W.type)?(W=f(W,Q.props),rs(W,Q),W.return=K,W):(W=yi(Q.type,Q.key,Q.props,null,K.mode,ce),rs(W,Q),W.return=K,W)}function Z(K,W,Q,ce){return W===null||W.tag!==4||W.stateNode.containerInfo!==Q.containerInfo||W.stateNode.implementation!==Q.implementation?(W=Tc(Q,K.mode,ce),W.return=K,W):(W=f(W,Q.children||[]),W.return=K,W)}function se(K,W,Q,ce,Ae){return W===null||W.tag!==7?(W=Sa(Q,K.mode,ce,Ae),W.return=K,W):(W=f(W,Q),W.return=K,W)}function ue(K,W,Q){if(typeof W=="string"&&W!==""||typeof W=="number"||typeof W=="bigint")return W=Nc(""+W,K.mode,Q),W.return=K,W;if(typeof W=="object"&&W!==null){switch(W.$$typeof){case S:return Q=yi(W.type,W.key,W.props,null,K.mode,Q),rs(Q,W),Q.return=K,Q;case k:return W=Tc(W,K.mode,Q),W.return=K,W;case O:return W=Na(W),ue(K,W,Q)}if($(W)||q(W))return W=Sa(W,K.mode,Q,null),W.return=K,W;if(typeof W.then=="function")return ue(K,Ei(W),Q);if(W.$$typeof===A)return ue(K,Si(K,W),Q);Ni(K,W)}return null}function ee(K,W,Q,ce){var Ae=W!==null?W.key:null;if(typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint")return Ae!==null?null:R(K,W,""+Q,ce);if(typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:return Q.key===Ae?P(K,W,Q,ce):null;case k:return Q.key===Ae?Z(K,W,Q,ce):null;case O:return Q=Na(Q),ee(K,W,Q,ce)}if($(Q)||q(Q))return Ae!==null?null:se(K,W,Q,ce,null);if(typeof Q.then=="function")return ee(K,W,Ei(Q),ce);if(Q.$$typeof===A)return ee(K,W,Si(K,Q),ce);Ni(K,Q)}return null}function re(K,W,Q,ce,Ae){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return K=K.get(Q)||null,R(W,K,""+ce,Ae);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case S:return K=K.get(ce.key===null?Q:ce.key)||null,P(W,K,ce,Ae);case k:return K=K.get(ce.key===null?Q:ce.key)||null,Z(W,K,ce,Ae);case O:return ce=Na(ce),re(K,W,Q,ce,Ae)}if($(ce)||q(ce))return K=K.get(Q)||null,se(W,K,ce,Ae,null);if(typeof ce.then=="function")return re(K,W,Q,Ei(ce),Ae);if(ce.$$typeof===A)return re(K,W,Q,Si(W,ce),Ae);Ni(W,ce)}return null}function we(K,W,Q,ce){for(var Ae=null,Je=null,Ee=W,Pe=W=0,Ke=null;Ee!==null&&Pe<Q.length;Pe++){Ee.index>Pe?(Ke=Ee,Ee=null):Ke=Ee.sibling;var et=ee(K,Ee,Q[Pe],ce);if(et===null){Ee===null&&(Ee=Ke);break}e&&Ee&&et.alternate===null&&n(K,Ee),W=x(et,W,Pe),Je===null?Ae=et:Je.sibling=et,Je=et,Ee=Ke}if(Pe===Q.length)return l(K,Ee),Xe&&xr(K,Pe),Ae;if(Ee===null){for(;Pe<Q.length;Pe++)Ee=ue(K,Q[Pe],ce),Ee!==null&&(W=x(Ee,W,Pe),Je===null?Ae=Ee:Je.sibling=Ee,Je=Ee);return Xe&&xr(K,Pe),Ae}for(Ee=i(Ee);Pe<Q.length;Pe++)Ke=re(Ee,K,Pe,Q[Pe],ce),Ke!==null&&(e&&Ke.alternate!==null&&Ee.delete(Ke.key===null?Pe:Ke.key),W=x(Ke,W,Pe),Je===null?Ae=Ke:Je.sibling=Ke,Je=Ke);return e&&Ee.forEach(function(ra){return n(K,ra)}),Xe&&xr(K,Pe),Ae}function Le(K,W,Q,ce){if(Q==null)throw Error(o(151));for(var Ae=null,Je=null,Ee=W,Pe=W=0,Ke=null,et=Q.next();Ee!==null&&!et.done;Pe++,et=Q.next()){Ee.index>Pe?(Ke=Ee,Ee=null):Ke=Ee.sibling;var ra=ee(K,Ee,et.value,ce);if(ra===null){Ee===null&&(Ee=Ke);break}e&&Ee&&ra.alternate===null&&n(K,Ee),W=x(ra,W,Pe),Je===null?Ae=ra:Je.sibling=ra,Je=ra,Ee=Ke}if(et.done)return l(K,Ee),Xe&&xr(K,Pe),Ae;if(Ee===null){for(;!et.done;Pe++,et=Q.next())et=ue(K,et.value,ce),et!==null&&(W=x(et,W,Pe),Je===null?Ae=et:Je.sibling=et,Je=et);return Xe&&xr(K,Pe),Ae}for(Ee=i(Ee);!et.done;Pe++,et=Q.next())et=re(Ee,K,Pe,et.value,ce),et!==null&&(e&&et.alternate!==null&&Ee.delete(et.key===null?Pe:et.key),W=x(et,W,Pe),Je===null?Ae=et:Je.sibling=et,Je=et);return e&&Ee.forEach(function(s0){return n(K,s0)}),Xe&&xr(K,Pe),Ae}function ft(K,W,Q,ce){if(typeof Q=="object"&&Q!==null&&Q.type===E&&Q.key===null&&(Q=Q.props.children),typeof Q=="object"&&Q!==null){switch(Q.$$typeof){case S:e:{for(var Ae=Q.key;W!==null;){if(W.key===Ae){if(Ae=Q.type,Ae===E){if(W.tag===7){l(K,W.sibling),ce=f(W,Q.props.children),ce.return=K,K=ce;break e}}else if(W.elementType===Ae||typeof Ae=="object"&&Ae!==null&&Ae.$$typeof===O&&Na(Ae)===W.type){l(K,W.sibling),ce=f(W,Q.props),rs(ce,Q),ce.return=K,K=ce;break e}l(K,W);break}else n(K,W);W=W.sibling}Q.type===E?(ce=Sa(Q.props.children,K.mode,ce,Q.key),ce.return=K,K=ce):(ce=yi(Q.type,Q.key,Q.props,null,K.mode,ce),rs(ce,Q),ce.return=K,K=ce)}return j(K);case k:e:{for(Ae=Q.key;W!==null;){if(W.key===Ae)if(W.tag===4&&W.stateNode.containerInfo===Q.containerInfo&&W.stateNode.implementation===Q.implementation){l(K,W.sibling),ce=f(W,Q.children||[]),ce.return=K,K=ce;break e}else{l(K,W);break}else n(K,W);W=W.sibling}ce=Tc(Q,K.mode,ce),ce.return=K,K=ce}return j(K);case O:return Q=Na(Q),ft(K,W,Q,ce)}if($(Q))return we(K,W,Q,ce);if(q(Q)){if(Ae=q(Q),typeof Ae!="function")throw Error(o(150));return Q=Ae.call(Q),Le(K,W,Q,ce)}if(typeof Q.then=="function")return ft(K,W,Ei(Q),ce);if(Q.$$typeof===A)return ft(K,W,Si(K,Q),ce);Ni(K,Q)}return typeof Q=="string"&&Q!==""||typeof Q=="number"||typeof Q=="bigint"?(Q=""+Q,W!==null&&W.tag===6?(l(K,W.sibling),ce=f(W,Q),ce.return=K,K=ce):(l(K,W),ce=Nc(Q,K.mode,ce),ce.return=K,K=ce),j(K)):l(K,W)}return function(K,W,Q,ce){try{ns=0;var Ae=ft(K,W,Q,ce);return fl=null,Ae}catch(Ee){if(Ee===dl||Ee===wi)throw Ee;var Je=bn(29,Ee,null,K.mode);return Je.lanes=ce,Je.return=K,Je}finally{}}}var Ra=$p(!0),Vp=$p(!1),Hr=!1;function Hc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function $c(e,n){e=e.updateQueue,n.updateQueue===e&&(n.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function $r(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Vr(e,n,l){var i=e.updateQueue;if(i===null)return null;if(i=i.shared,(rt&2)!==0){var f=i.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),i.pending=n,n=vi(e),Cp(e,null,l),n}return gi(e,i,n,l),vi(e)}function as(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pa(e,l)}}function Vc(e,n){var l=e.updateQueue,i=e.alternate;if(i!==null&&(i=i.updateQueue,l===i)){var f=null,x=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};x===null?f=x=j:x=x.next=j,l=l.next}while(l!==null);x===null?f=x=n:x=x.next=n}else f=x=n;l={baseState:i.baseState,firstBaseUpdate:f,lastBaseUpdate:x,shared:i.shared,callbacks:i.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var Pc=!1;function ls(){if(Pc){var e=ul;if(e!==null)throw e}}function ss(e,n,l,i){Pc=!1;var f=e.updateQueue;Hr=!1;var x=f.firstBaseUpdate,j=f.lastBaseUpdate,R=f.shared.pending;if(R!==null){f.shared.pending=null;var P=R,Z=P.next;P.next=null,j===null?x=Z:j.next=Z,j=P;var se=e.alternate;se!==null&&(se=se.updateQueue,R=se.lastBaseUpdate,R!==j&&(R===null?se.firstBaseUpdate=Z:R.next=Z,se.lastBaseUpdate=P))}if(x!==null){var ue=f.baseState;j=0,se=Z=P=null,R=x;do{var ee=R.lane&-536870913,re=ee!==R.lane;if(re?(Ye&ee)===ee:(i&ee)===ee){ee!==0&&ee===cl&&(Pc=!0),se!==null&&(se=se.next={lane:0,tag:R.tag,payload:R.payload,callback:null,next:null});e:{var we=e,Le=R;ee=n;var ft=l;switch(Le.tag){case 1:if(we=Le.payload,typeof we=="function"){ue=we.call(ft,ue,ee);break e}ue=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Le.payload,ee=typeof we=="function"?we.call(ft,ue,ee):we,ee==null)break e;ue=v({},ue,ee);break e;case 2:Hr=!0}}ee=R.callback,ee!==null&&(e.flags|=64,re&&(e.flags|=8192),re=f.callbacks,re===null?f.callbacks=[ee]:re.push(ee))}else re={lane:ee,tag:R.tag,payload:R.payload,callback:R.callback,next:null},se===null?(Z=se=re,P=ue):se=se.next=re,j|=ee;if(R=R.next,R===null){if(R=f.shared.pending,R===null)break;re=R,R=re.next,re.next=null,f.lastBaseUpdate=re,f.shared.pending=null}}while(!0);se===null&&(P=ue),f.baseState=P,f.firstBaseUpdate=Z,f.lastBaseUpdate=se,x===null&&(f.shared.lanes=0),qr|=j,e.lanes=j,e.memoizedState=ue}}function Pp(e,n){if(typeof e!="function")throw Error(o(191,e));e.call(n)}function Fp(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Pp(l[e],n)}var pl=M(null),Ti=M(0);function Gp(e,n){e=Nr,G(Ti,e),G(pl,n),Nr=e|n.baseLanes}function Fc(){G(Ti,Nr),G(pl,pl.current)}function Gc(){Nr=Ti.current,Y(pl),Y(Ti)}var jn=M(null),Un=null;function Pr(e){var n=e.alternate;G(zt,zt.current&1),G(jn,e),Un===null&&(n===null||pl.current!==null||n.memoizedState!==null)&&(Un=e)}function Wc(e){G(zt,zt.current),G(jn,e),Un===null&&(Un=e)}function Wp(e){e.tag===22?(G(zt,zt.current),G(jn,e),Un===null&&(Un=e)):Fr()}function Fr(){G(zt,zt.current),G(jn,jn.current)}function Sn(e){Y(jn),Un===e&&(Un=null),Y(zt)}var zt=M(0);function Ri(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||Zu(l)||Ju(l)))return n}else if(n.tag===19&&(n.memoizedProps.revealOrder==="forwards"||n.memoizedProps.revealOrder==="backwards"||n.memoizedProps.revealOrder==="unstable_legacy-backwards"||n.memoizedProps.revealOrder==="together")){if((n.flags&128)!==0)return n}else if(n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return null;n=n.return}n.sibling.return=n.return,n=n.sibling}return null}var yr=0,$e=null,ut=null,Bt=null,Ai=!1,ml=!1,Aa=!1,Mi=0,is=0,hl=null,Xb=0;function At(){throw Error(o(321))}function qc(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!yn(e[l],n[l]))return!1;return!0}function Yc(e,n,l,i,f,x){return yr=x,$e=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,L.H=e===null||e.memoizedState===null?Rm:cu,Aa=!1,x=l(i,f),Aa=!1,ml&&(x=Yp(n,l,i,f)),qp(e),x}function qp(e){L.H=us;var n=ut!==null&&ut.next!==null;if(yr=0,Bt=ut=$e=null,Ai=!1,is=0,hl=null,n)throw Error(o(300));e===null||It||(e=e.dependencies,e!==null&&ji(e)&&(It=!0))}function Yp(e,n,l,i){$e=e;var f=0;do{if(ml&&(hl=null),is=0,ml=!1,25<=f)throw Error(o(301));if(f+=1,Bt=ut=null,e.updateQueue!=null){var x=e.updateQueue;x.lastEffect=null,x.events=null,x.stores=null,x.memoCache!=null&&(x.memoCache.index=0)}L.H=Am,x=n(l,i)}while(ml);return x}function Qb(){var e=L.H,n=e.useState()[0];return n=typeof n.then=="function"?os(n):n,e=e.useState()[0],(ut!==null?ut.memoizedState:null)!==e&&($e.flags|=1024),n}function Kc(){var e=Mi!==0;return Mi=0,e}function Xc(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function Qc(e){if(Ai){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Ai=!1}yr=0,Bt=ut=$e=null,ml=!1,is=Mi=0,hl=null}function on(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Bt===null?$e.memoizedState=Bt=e:Bt=Bt.next=e,Bt}function Dt(){if(ut===null){var e=$e.alternate;e=e!==null?e.memoizedState:null}else e=ut.next;var n=Bt===null?$e.memoizedState:Bt.next;if(n!==null)Bt=n,ut=e;else{if(e===null)throw $e.alternate===null?Error(o(467)):Error(o(310));ut=e,e={memoizedState:ut.memoizedState,baseState:ut.baseState,baseQueue:ut.baseQueue,queue:ut.queue,next:null},Bt===null?$e.memoizedState=Bt=e:Bt=Bt.next=e}return Bt}function Li(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function os(e){var n=is;return is+=1,hl===null&&(hl=[]),e=Ip(hl,e,n),n=$e,(Bt===null?n.memoizedState:Bt.next)===null&&(n=n.alternate,L.H=n===null||n.memoizedState===null?Rm:cu),e}function zi(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return os(e);if(e.$$typeof===A)return Zt(e)}throw Error(o(438,String(e)))}function Zc(e){var n=null,l=$e.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var i=$e.alternate;i!==null&&(i=i.updateQueue,i!==null&&(i=i.memoCache,i!=null&&(n={data:i.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Li(),$e.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),i=0;i<e;i++)l[i]=U;return n.index++,l}function br(e,n){return typeof n=="function"?n(e):n}function Di(e){var n=Dt();return Jc(n,ut,e)}function Jc(e,n,l){var i=e.queue;if(i===null)throw Error(o(311));i.lastRenderedReducer=l;var f=e.baseQueue,x=i.pending;if(x!==null){if(f!==null){var j=f.next;f.next=x.next,x.next=j}n.baseQueue=f=x,i.pending=null}if(x=e.baseState,f===null)e.memoizedState=x;else{n=f.next;var R=j=null,P=null,Z=n,se=!1;do{var ue=Z.lane&-536870913;if(ue!==Z.lane?(Ye&ue)===ue:(yr&ue)===ue){var ee=Z.revertLane;if(ee===0)P!==null&&(P=P.next={lane:0,revertLane:0,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null}),ue===cl&&(se=!0);else if((yr&ee)===ee){Z=Z.next,ee===cl&&(se=!0);continue}else ue={lane:0,revertLane:Z.revertLane,gesture:null,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ue,j=x):P=P.next=ue,$e.lanes|=ee,qr|=ee;ue=Z.action,Aa&&l(x,ue),x=Z.hasEagerState?Z.eagerState:l(x,ue)}else ee={lane:ue,revertLane:Z.revertLane,gesture:Z.gesture,action:Z.action,hasEagerState:Z.hasEagerState,eagerState:Z.eagerState,next:null},P===null?(R=P=ee,j=x):P=P.next=ee,$e.lanes|=ue,qr|=ue;Z=Z.next}while(Z!==null&&Z!==n);if(P===null?j=x:P.next=R,!yn(x,e.memoizedState)&&(It=!0,se&&(l=ul,l!==null)))throw l;e.memoizedState=x,e.baseState=j,e.baseQueue=P,i.lastRenderedState=x}return f===null&&(i.lanes=0),[e.memoizedState,i.dispatch]}function eu(e){var n=Dt(),l=n.queue;if(l===null)throw Error(o(311));l.lastRenderedReducer=e;var i=l.dispatch,f=l.pending,x=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do x=e(x,j.action),j=j.next;while(j!==f);yn(x,n.memoizedState)||(It=!0),n.memoizedState=x,n.baseQueue===null&&(n.baseState=x),l.lastRenderedState=x}return[x,i]}function Kp(e,n,l){var i=$e,f=Dt(),x=Xe;if(x){if(l===void 0)throw Error(o(407));l=l()}else l=n();var j=!yn((ut||f).memoizedState,l);if(j&&(f.memoizedState=l,It=!0),f=f.queue,ru(Zp.bind(null,i,f,e),[e]),f.getSnapshot!==n||j||Bt!==null&&Bt.memoizedState.tag&1){if(i.flags|=2048,xl(9,{destroy:void 0},Qp.bind(null,i,f,l,n),null),ht===null)throw Error(o(349));x||(yr&127)!==0||Xp(i,n,l)}return l}function Xp(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=$e.updateQueue,n===null?(n=Li(),$e.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function Qp(e,n,l,i){n.value=l,n.getSnapshot=i,Jp(n)&&em(e)}function Zp(e,n,l){return l(function(){Jp(n)&&em(e)})}function Jp(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!yn(e,l)}catch{return!0}}function em(e){var n=ja(e,2);n!==null&&vn(n,e,2)}function tu(e){var n=on();if(typeof e=="function"){var l=e;if(e=l(),Aa){vt(!0);try{l()}finally{vt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:e},n}function tm(e,n,l,i){return e.baseState=l,Jc(e,ut,typeof i=="function"?i:br)}function Zb(e,n,l,i,f){if(Bi(e))throw Error(o(485));if(e=n.action,e!==null){var x={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){x.listeners.push(j)}};L.T!==null?l(!0):x.isTransition=!1,i(x),l=n.pending,l===null?(x.next=n.pending=x,nm(n,x)):(x.next=l.next,n.pending=l.next=x)}}function nm(e,n){var l=n.action,i=n.payload,f=e.state;if(n.isTransition){var x=L.T,j={};L.T=j;try{var R=l(f,i),P=L.S;P!==null&&P(j,R),rm(e,n,R)}catch(Z){nu(e,n,Z)}finally{x!==null&&j.types!==null&&(x.types=j.types),L.T=x}}else try{x=l(f,i),rm(e,n,x)}catch(Z){nu(e,n,Z)}}function rm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(i){am(e,n,i)},function(i){return nu(e,n,i)}):am(e,n,l)}function am(e,n,l){n.status="fulfilled",n.value=l,lm(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,nm(e,l)))}function nu(e,n,l){var i=e.pending;if(e.pending=null,i!==null){i=i.next;do n.status="rejected",n.reason=l,lm(n),n=n.next;while(n!==i)}e.action=null}function lm(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function sm(e,n){return n}function im(e,n){if(Xe){var l=ht.formState;if(l!==null){e:{var i=$e;if(Xe){if(yt){t:{for(var f=yt,x=In;f.nodeType!==8;){if(!x){f=null;break t}if(f=Hn(f.nextSibling),f===null){f=null;break t}}x=f.data,f=x==="F!"||x==="F"?f:null}if(f){yt=Hn(f.nextSibling),i=f.data==="F!";break e}}Ir(i)}i=!1}i&&(n=l[0])}}return l=on(),l.memoizedState=l.baseState=n,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:sm,lastRenderedState:n},l.queue=i,l=Em.bind(null,$e,i),i.dispatch=l,i=tu(!1),x=ou.bind(null,$e,!1,i.queue),i=on(),f={state:n,dispatch:null,action:e,pending:null},i.queue=f,l=Zb.bind(null,$e,f,x,l),f.dispatch=l,i.memoizedState=e,[n,l,!1]}function om(e){var n=Dt();return cm(n,ut,e)}function cm(e,n,l){if(n=Jc(e,n,sm)[0],e=Di(br)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var i=os(n)}catch(j){throw j===dl?wi:j}else i=n;n=Dt();var f=n.queue,x=f.dispatch;return l!==n.memoizedState&&($e.flags|=2048,xl(9,{destroy:void 0},Jb.bind(null,f,l),null)),[i,x,e]}function Jb(e,n){e.action=n}function um(e){var n=Dt(),l=ut;if(l!==null)return cm(n,l,e);Dt(),n=n.memoizedState,l=Dt();var i=l.queue.dispatch;return l.memoizedState=e,[n,i,!1]}function xl(e,n,l,i){return e={tag:e,create:l,deps:i,inst:n,next:null},n=$e.updateQueue,n===null&&(n=Li(),$e.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(i=l.next,l.next=e,e.next=i,n.lastEffect=e),e}function dm(){return Dt().memoizedState}function _i(e,n,l,i){var f=on();$e.flags|=e,f.memoizedState=xl(1|n,{destroy:void 0},l,i===void 0?null:i)}function Oi(e,n,l,i){var f=Dt();i=i===void 0?null:i;var x=f.memoizedState.inst;ut!==null&&i!==null&&qc(i,ut.memoizedState.deps)?f.memoizedState=xl(n,x,l,i):($e.flags|=e,f.memoizedState=xl(1|n,x,l,i))}function fm(e,n){_i(8390656,8,e,n)}function ru(e,n){Oi(2048,8,e,n)}function e1(e){$e.flags|=4;var n=$e.updateQueue;if(n===null)n=Li(),$e.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function pm(e){var n=Dt().memoizedState;return e1({ref:n,nextImpl:e}),function(){if((rt&2)!==0)throw Error(o(440));return n.impl.apply(void 0,arguments)}}function mm(e,n){return Oi(4,2,e,n)}function hm(e,n){return Oi(4,4,e,n)}function xm(e,n){if(typeof n=="function"){e=e();var l=n(e);return function(){typeof l=="function"?l():n(null)}}if(n!=null)return e=e(),n.current=e,function(){n.current=null}}function gm(e,n,l){l=l!=null?l.concat([e]):null,Oi(4,4,xm.bind(null,n,e),l)}function au(){}function vm(e,n){var l=Dt();n=n===void 0?null:n;var i=l.memoizedState;return n!==null&&qc(n,i[1])?i[0]:(l.memoizedState=[e,n],e)}function ym(e,n){var l=Dt();n=n===void 0?null:n;var i=l.memoizedState;if(n!==null&&qc(n,i[1]))return i[0];if(i=e(),Aa){vt(!0);try{e()}finally{vt(!1)}}return l.memoizedState=[i,n],i}function lu(e,n,l){return l===void 0||(yr&1073741824)!==0&&(Ye&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=bh(),$e.lanes|=e,qr|=e,l)}function bm(e,n,l,i){return yn(l,n)?l:pl.current!==null?(e=lu(e,l,i),yn(e,n)||(It=!0),e):(yr&42)===0||(yr&1073741824)!==0&&(Ye&261930)===0?(It=!0,e.memoizedState=l):(e=bh(),$e.lanes|=e,qr|=e,n)}function jm(e,n,l,i,f){var x=_.p;_.p=x!==0&&8>x?x:8;var j=L.T,R={};L.T=R,ou(e,!1,n,l);try{var P=f(),Z=L.S;if(Z!==null&&Z(R,P),P!==null&&typeof P=="object"&&typeof P.then=="function"){var se=Kb(P,i);cs(e,n,se,Cn(e))}else cs(e,n,i,Cn(e))}catch(ue){cs(e,n,{then:function(){},status:"rejected",reason:ue},Cn())}finally{_.p=x,j!==null&&R.types!==null&&(j.types=R.types),L.T=j}}function t1(){}function su(e,n,l,i){if(e.tag!==5)throw Error(o(476));var f=Sm(e).queue;jm(e,f,n,I,l===null?t1:function(){return km(e),l(i)})}function Sm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:I},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:br,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function km(e){var n=Sm(e);n.next===null&&(n=e.alternate.memoizedState),cs(e,n.next.queue,{},Cn())}function iu(){return Zt(Es)}function wm(){return Dt().memoizedState}function Cm(){return Dt().memoizedState}function n1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=Cn();e=$r(l);var i=Vr(n,e,l);i!==null&&(vn(i,n,l),as(i,n,l)),n={cache:Oc()},e.payload=n;return}n=n.return}}function r1(e,n,l){var i=Cn();l={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Bi(e)?Nm(n,l):(l=Cc(e,n,l,i),l!==null&&(vn(l,e,i),Tm(l,n,i)))}function Em(e,n,l){var i=Cn();cs(e,n,l,i)}function cs(e,n,l,i){var f={lane:i,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Bi(e))Nm(n,f);else{var x=e.alternate;if(e.lanes===0&&(x===null||x.lanes===0)&&(x=n.lastRenderedReducer,x!==null))try{var j=n.lastRenderedState,R=x(j,l);if(f.hasEagerState=!0,f.eagerState=R,yn(R,j))return gi(e,n,f,0),ht===null&&xi(),!1}catch{}finally{}if(l=Cc(e,n,f,i),l!==null)return vn(l,e,i),Tm(l,n,i),!0}return!1}function ou(e,n,l,i){if(i={lane:2,revertLane:Hu(),gesture:null,action:i,hasEagerState:!1,eagerState:null,next:null},Bi(e)){if(n)throw Error(o(479))}else n=Cc(e,l,i,2),n!==null&&vn(n,e,2)}function Bi(e){var n=e.alternate;return e===$e||n!==null&&n===$e}function Nm(e,n){ml=Ai=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Tm(e,n,l){if((l&4194048)!==0){var i=n.lanes;i&=e.pendingLanes,l|=i,n.lanes=l,pa(e,l)}}var us={readContext:Zt,use:zi,useCallback:At,useContext:At,useEffect:At,useImperativeHandle:At,useLayoutEffect:At,useInsertionEffect:At,useMemo:At,useReducer:At,useRef:At,useState:At,useDebugValue:At,useDeferredValue:At,useTransition:At,useSyncExternalStore:At,useId:At,useHostTransitionStatus:At,useFormState:At,useActionState:At,useOptimistic:At,useMemoCache:At,useCacheRefresh:At};us.useEffectEvent=At;var Rm={readContext:Zt,use:zi,useCallback:function(e,n){return on().memoizedState=[e,n===void 0?null:n],e},useContext:Zt,useEffect:fm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,_i(4194308,4,xm.bind(null,n,e),l)},useLayoutEffect:function(e,n){return _i(4194308,4,e,n)},useInsertionEffect:function(e,n){_i(4,2,e,n)},useMemo:function(e,n){var l=on();n=n===void 0?null:n;var i=e();if(Aa){vt(!0);try{e()}finally{vt(!1)}}return l.memoizedState=[i,n],i},useReducer:function(e,n,l){var i=on();if(l!==void 0){var f=l(n);if(Aa){vt(!0);try{l(n)}finally{vt(!1)}}}else f=n;return i.memoizedState=i.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},i.queue=e,e=e.dispatch=r1.bind(null,$e,e),[i.memoizedState,e]},useRef:function(e){var n=on();return e={current:e},n.memoizedState=e},useState:function(e){e=tu(e);var n=e.queue,l=Em.bind(null,$e,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:au,useDeferredValue:function(e,n){var l=on();return lu(l,e,n)},useTransition:function(){var e=tu(!1);return e=jm.bind(null,$e,e.queue,!0,!1),on().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var i=$e,f=on();if(Xe){if(l===void 0)throw Error(o(407));l=l()}else{if(l=n(),ht===null)throw Error(o(349));(Ye&127)!==0||Xp(i,n,l)}f.memoizedState=l;var x={value:l,getSnapshot:n};return f.queue=x,fm(Zp.bind(null,i,x,e),[e]),i.flags|=2048,xl(9,{destroy:void 0},Qp.bind(null,i,x,l,n),null),l},useId:function(){var e=on(),n=ht.identifierPrefix;if(Xe){var l=ar,i=rr;l=(i&~(1<<32-gt(i)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Mi++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=Xb++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:iu,useFormState:im,useActionState:im,useOptimistic:function(e){var n=on();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=ou.bind(null,$e,!0,l),l.dispatch=n,[e,n]},useMemoCache:Zc,useCacheRefresh:function(){return on().memoizedState=n1.bind(null,$e)},useEffectEvent:function(e){var n=on(),l={impl:e};return n.memoizedState=l,function(){if((rt&2)!==0)throw Error(o(440));return l.impl.apply(void 0,arguments)}}},cu={readContext:Zt,use:zi,useCallback:vm,useContext:Zt,useEffect:ru,useImperativeHandle:gm,useInsertionEffect:mm,useLayoutEffect:hm,useMemo:ym,useReducer:Di,useRef:dm,useState:function(){return Di(br)},useDebugValue:au,useDeferredValue:function(e,n){var l=Dt();return bm(l,ut.memoizedState,e,n)},useTransition:function(){var e=Di(br)[0],n=Dt().memoizedState;return[typeof e=="boolean"?e:os(e),n]},useSyncExternalStore:Kp,useId:wm,useHostTransitionStatus:iu,useFormState:om,useActionState:om,useOptimistic:function(e,n){var l=Dt();return tm(l,ut,e,n)},useMemoCache:Zc,useCacheRefresh:Cm};cu.useEffectEvent=pm;var Am={readContext:Zt,use:zi,useCallback:vm,useContext:Zt,useEffect:ru,useImperativeHandle:gm,useInsertionEffect:mm,useLayoutEffect:hm,useMemo:ym,useReducer:eu,useRef:dm,useState:function(){return eu(br)},useDebugValue:au,useDeferredValue:function(e,n){var l=Dt();return ut===null?lu(l,e,n):bm(l,ut.memoizedState,e,n)},useTransition:function(){var e=eu(br)[0],n=Dt().memoizedState;return[typeof e=="boolean"?e:os(e),n]},useSyncExternalStore:Kp,useId:wm,useHostTransitionStatus:iu,useFormState:um,useActionState:um,useOptimistic:function(e,n){var l=Dt();return ut!==null?tm(l,ut,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:Zc,useCacheRefresh:Cm};Am.useEffectEvent=pm;function uu(e,n,l,i){n=e.memoizedState,l=l(i,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var du={enqueueSetState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$r(i);f.payload=n,l!=null&&(f.callback=l),n=Vr(e,f,i),n!==null&&(vn(n,e,i),as(n,e,i))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var i=Cn(),f=$r(i);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Vr(e,f,i),n!==null&&(vn(n,e,i),as(n,e,i))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=Cn(),i=$r(l);i.tag=2,n!=null&&(i.callback=n),n=Vr(e,i,l),n!==null&&(vn(n,e,l),as(n,e,l))}};function Mm(e,n,l,i,f,x,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(i,x,j):n.prototype&&n.prototype.isPureReactComponent?!Xl(l,i)||!Xl(f,x):!0}function Lm(e,n,l,i){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,i),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,i),n.state!==e&&du.enqueueReplaceState(n,n.state,null)}function Ma(e,n){var l=n;if("ref"in n){l={};for(var i in n)i!=="ref"&&(l[i]=n[i])}if(e=e.defaultProps){l===n&&(l=v({},l));for(var f in e)l[f]===void 0&&(l[f]=e[f])}return l}function zm(e){hi(e)}function Dm(e){console.error(e)}function _m(e){hi(e)}function Ii(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(i){setTimeout(function(){throw i})}}function Om(e,n,l){try{var i=e.onCaughtError;i(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function fu(e,n,l){return l=$r(l),l.tag=3,l.payload={element:null},l.callback=function(){Ii(e,n)},l}function Bm(e){return e=$r(e),e.tag=3,e}function Im(e,n,l,i){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var x=i.value;e.payload=function(){return f(x)},e.callback=function(){Om(n,l,i)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){Om(n,l,i),typeof f!="function"&&(Yr===null?Yr=new Set([this]):Yr.add(this));var R=i.stack;this.componentDidCatch(i.value,{componentStack:R!==null?R:""})})}function a1(e,n,l,i,f){if(l.flags|=32768,i!==null&&typeof i=="object"&&typeof i.then=="function"){if(n=l.alternate,n!==null&&ol(n,l,f,!0),l=jn.current,l!==null){switch(l.tag){case 31:case 13:return Un===null?Xi():l.alternate===null&&Mt===0&&(Mt=3),l.flags&=-257,l.flags|=65536,l.lanes=f,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([i]):n.add(i),Bu(e,i,f)),!1;case 22:return l.flags|=65536,i===Ci?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([i])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([i]):l.add(i)),Bu(e,i,f)),!1}throw Error(o(435,l.tag))}return Bu(e,i,f),Xi(),!1}if(Xe)return n=jn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,i!==Mc&&(e=Error(o(422),{cause:i}),Jl(_n(e,l)))):(i!==Mc&&(n=Error(o(423),{cause:i}),Jl(_n(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,i=_n(i,l),f=fu(e.stateNode,i,f),Vc(e,f),Mt!==4&&(Mt=2)),!1;var x=Error(o(520),{cause:i});if(x=_n(x,l),vs===null?vs=[x]:vs.push(x),Mt!==4&&(Mt=2),n===null)return!0;i=_n(i,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=fu(l.stateNode,i,e),Vc(l,e),!1;case 1:if(n=l.type,x=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(Yr===null||!Yr.has(x))))return l.flags|=65536,f&=-f,l.lanes|=f,f=Bm(f),Im(f,e,l,i),Vc(l,f),!1}l=l.return}while(l!==null);return!1}var pu=Error(o(461)),It=!1;function Jt(e,n,l,i){n.child=e===null?Vp(n,null,l,i):Ra(n,e.child,l,i)}function Um(e,n,l,i,f){l=l.render;var x=n.ref;if("ref"in i){var j={};for(var R in i)R!=="ref"&&(j[R]=i[R])}else j=i;return Ca(n),i=Yc(e,n,l,j,x,f),R=Kc(),e!==null&&!It?(Xc(e,n,f),jr(e,n,f)):(Xe&&R&&Rc(n),n.flags|=1,Jt(e,n,i,f),n.child)}function Hm(e,n,l,i,f){if(e===null){var x=l.type;return typeof x=="function"&&!Ec(x)&&x.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=x,$m(e,n,x,i,f)):(e=yi(l.type,null,i,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(x=e.child,!ju(e,f)){var j=x.memoizedProps;if(l=l.compare,l=l!==null?l:Xl,l(j,i)&&e.ref===n.ref)return jr(e,n,f)}return n.flags|=1,e=hr(x,i),e.ref=n.ref,e.return=n,n.child=e}function $m(e,n,l,i,f){if(e!==null){var x=e.memoizedProps;if(Xl(x,i)&&e.ref===n.ref)if(It=!1,n.pendingProps=i=x,ju(e,f))(e.flags&131072)!==0&&(It=!0);else return n.lanes=e.lanes,jr(e,n,f)}return mu(e,n,l,i,f)}function Vm(e,n,l,i){var f=i.children,x=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.mode==="hidden"){if((n.flags&128)!==0){if(x=x!==null?x.baseLanes|l:l,e!==null){for(i=n.child=e.child,f=0;i!==null;)f=f|i.lanes|i.childLanes,i=i.sibling;i=f&~x}else i=0,n.child=null;return Pm(e,n,x,l,i)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&ki(n,x!==null?x.cachePool:null),x!==null?Gp(n,x):Fc(),Wp(n);else return i=n.lanes=536870912,Pm(e,n,x!==null?x.baseLanes|l:l,l,i)}else x!==null?(ki(n,x.cachePool),Gp(n,x),Fr(),n.memoizedState=null):(e!==null&&ki(n,null),Fc(),Fr());return Jt(e,n,f,l),n.child}function ds(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Pm(e,n,l,i,f){var x=Ic();return x=x===null?null:{parent:Ot._currentValue,pool:x},n.memoizedState={baseLanes:l,cachePool:x},e!==null&&ki(n,null),Fc(),Wp(n),e!==null&&ol(e,n,i,!0),n.childLanes=f,null}function Ui(e,n){return n=$i({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function Fm(e,n,l){return Ra(n,e.child,null,l),e=Ui(n,n.pendingProps),e.flags|=2,Sn(n),n.memoizedState=null,e}function l1(e,n,l){var i=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Xe){if(i.mode==="hidden")return e=Ui(n,i),n.lanes=536870912,ds(null,e);if(Wc(n),(e=yt)?(e=nx(e,In),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Or!==null?{id:rr,overflow:ar}:null,retryLane:536870912,hydrationErrors:null},l=Np(e),l.return=n,n.child=l,Qt=n,yt=null)):e=null,e===null)throw Ir(n);return n.lanes=536870912,null}return Ui(n,i)}var x=e.memoizedState;if(x!==null){var j=x.dehydrated;if(Wc(n),f)if(n.flags&256)n.flags&=-257,n=Fm(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(o(558));else if(It||ol(e,n,l,!1),f=(l&e.childLanes)!==0,It||f){if(i=ht,i!==null&&(j=ma(i,l),j!==0&&j!==x.retryLane))throw x.retryLane=j,ja(e,j),vn(i,e,j),pu;Xi(),n=Fm(e,n,l)}else e=x.treeContext,yt=Hn(j.nextSibling),Qt=n,Xe=!0,Br=null,In=!1,e!==null&&Ap(n,e),n=Ui(n,i),n.flags|=4096;return n}return e=hr(e.child,{mode:i.mode,children:i.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Hi(e,n){var l=n.ref;if(l===null)e!==null&&e.ref!==null&&(n.flags|=4194816);else{if(typeof l!="function"&&typeof l!="object")throw Error(o(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function mu(e,n,l,i,f){return Ca(n),l=Yc(e,n,l,i,void 0,f),i=Kc(),e!==null&&!It?(Xc(e,n,f),jr(e,n,f)):(Xe&&i&&Rc(n),n.flags|=1,Jt(e,n,l,f),n.child)}function Gm(e,n,l,i,f,x){return Ca(n),n.updateQueue=null,l=Yp(n,i,l,f),qp(e),i=Kc(),e!==null&&!It?(Xc(e,n,x),jr(e,n,x)):(Xe&&i&&Rc(n),n.flags|=1,Jt(e,n,l,x),n.child)}function Wm(e,n,l,i,f){if(Ca(n),n.stateNode===null){var x=al,j=l.contextType;typeof j=="object"&&j!==null&&(x=Zt(j)),x=new l(i,x),n.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,x.updater=du,n.stateNode=x,x._reactInternals=n,x=n.stateNode,x.props=i,x.state=n.memoizedState,x.refs={},Hc(n),j=l.contextType,x.context=typeof j=="object"&&j!==null?Zt(j):al,x.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(uu(n,l,j,i),x.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(j=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),j!==x.state&&du.enqueueReplaceState(x,x.state,null),ss(n,i,x,f),ls(),x.state=n.memoizedState),typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!0}else if(e===null){x=n.stateNode;var R=n.memoizedProps,P=Ma(l,R);x.props=P;var Z=x.context,se=l.contextType;j=al,typeof se=="object"&&se!==null&&(j=Zt(se));var ue=l.getDerivedStateFromProps;se=typeof ue=="function"||typeof x.getSnapshotBeforeUpdate=="function",R=n.pendingProps!==R,se||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(R||Z!==j)&&Lm(n,x,i,j),Hr=!1;var ee=n.memoizedState;x.state=ee,ss(n,i,x,f),ls(),Z=n.memoizedState,R||ee!==Z||Hr?(typeof ue=="function"&&(uu(n,l,ue,i),Z=n.memoizedState),(P=Hr||Mm(n,l,P,i,ee,Z,j))?(se||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount()),typeof x.componentDidMount=="function"&&(n.flags|=4194308)):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=i,n.memoizedState=Z),x.props=i,x.state=Z,x.context=j,i=P):(typeof x.componentDidMount=="function"&&(n.flags|=4194308),i=!1)}else{x=n.stateNode,$c(e,n),j=n.memoizedProps,se=Ma(l,j),x.props=se,ue=n.pendingProps,ee=x.context,Z=l.contextType,P=al,typeof Z=="object"&&Z!==null&&(P=Zt(Z)),R=l.getDerivedStateFromProps,(Z=typeof R=="function"||typeof x.getSnapshotBeforeUpdate=="function")||typeof x.UNSAFE_componentWillReceiveProps!="function"&&typeof x.componentWillReceiveProps!="function"||(j!==ue||ee!==P)&&Lm(n,x,i,P),Hr=!1,ee=n.memoizedState,x.state=ee,ss(n,i,x,f),ls();var re=n.memoizedState;j!==ue||ee!==re||Hr||e!==null&&e.dependencies!==null&&ji(e.dependencies)?(typeof R=="function"&&(uu(n,l,R,i),re=n.memoizedState),(se=Hr||Mm(n,l,se,i,ee,re,P)||e!==null&&e.dependencies!==null&&ji(e.dependencies))?(Z||typeof x.UNSAFE_componentWillUpdate!="function"&&typeof x.componentWillUpdate!="function"||(typeof x.componentWillUpdate=="function"&&x.componentWillUpdate(i,re,P),typeof x.UNSAFE_componentWillUpdate=="function"&&x.UNSAFE_componentWillUpdate(i,re,P)),typeof x.componentDidUpdate=="function"&&(n.flags|=4),typeof x.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),n.memoizedProps=i,n.memoizedState=re),x.props=i,x.state=re,x.context=P,i=se):(typeof x.componentDidUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=4),typeof x.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ee===e.memoizedState||(n.flags|=1024),i=!1)}return x=i,Hi(e,n),i=(n.flags&128)!==0,x||i?(x=n.stateNode,l=i&&typeof l.getDerivedStateFromError!="function"?null:x.render(),n.flags|=1,e!==null&&i?(n.child=Ra(n,e.child,null,f),n.child=Ra(n,null,l,f)):Jt(e,n,l,f),n.memoizedState=x.state,e=n.child):e=jr(e,n,f),e}function qm(e,n,l,i){return ka(),n.flags|=256,Jt(e,n,l,i),n.child}var hu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function xu(e){return{baseLanes:e,cachePool:Op()}}function gu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=wn),e}function Ym(e,n,l){var i=n.pendingProps,f=!1,x=(n.flags&128)!==0,j;if((j=x)||(j=e!==null&&e.memoizedState===null?!1:(zt.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Xe){if(f?Pr(n):Fr(),(e=yt)?(e=nx(e,In),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Or!==null?{id:rr,overflow:ar}:null,retryLane:536870912,hydrationErrors:null},l=Np(e),l.return=n,n.child=l,Qt=n,yt=null)):e=null,e===null)throw Ir(n);return Ju(e)?n.lanes=32:n.lanes=536870912,null}var R=i.children;return i=i.fallback,f?(Fr(),f=n.mode,R=$i({mode:"hidden",children:R},f),i=Sa(i,f,l,null),R.return=n,i.return=n,R.sibling=i,n.child=R,i=n.child,i.memoizedState=xu(l),i.childLanes=gu(e,j,l),n.memoizedState=hu,ds(null,i)):(Pr(n),vu(n,R))}var P=e.memoizedState;if(P!==null&&(R=P.dehydrated,R!==null)){if(x)n.flags&256?(Pr(n),n.flags&=-257,n=yu(e,n,l)):n.memoizedState!==null?(Fr(),n.child=e.child,n.flags|=128,n=null):(Fr(),R=i.fallback,f=n.mode,i=$i({mode:"visible",children:i.children},f),R=Sa(R,f,l,null),R.flags|=2,i.return=n,R.return=n,i.sibling=R,n.child=i,Ra(n,e.child,null,l),i=n.child,i.memoizedState=xu(l),i.childLanes=gu(e,j,l),n.memoizedState=hu,n=ds(null,i));else if(Pr(n),Ju(R)){if(j=R.nextSibling&&R.nextSibling.dataset,j)var Z=j.dgst;j=Z,i=Error(o(419)),i.stack="",i.digest=j,Jl({value:i,source:null,stack:null}),n=yu(e,n,l)}else if(It||ol(e,n,l,!1),j=(l&e.childLanes)!==0,It||j){if(j=ht,j!==null&&(i=ma(j,l),i!==0&&i!==P.retryLane))throw P.retryLane=i,ja(e,i),vn(j,e,i),pu;Zu(R)||Xi(),n=yu(e,n,l)}else Zu(R)?(n.flags|=192,n.child=e.child,n=null):(e=P.treeContext,yt=Hn(R.nextSibling),Qt=n,Xe=!0,Br=null,In=!1,e!==null&&Ap(n,e),n=vu(n,i.children),n.flags|=4096);return n}return f?(Fr(),R=i.fallback,f=n.mode,P=e.child,Z=P.sibling,i=hr(P,{mode:"hidden",children:i.children}),i.subtreeFlags=P.subtreeFlags&65011712,Z!==null?R=hr(Z,R):(R=Sa(R,f,l,null),R.flags|=2),R.return=n,i.return=n,i.sibling=R,n.child=i,ds(null,i),i=n.child,R=e.child.memoizedState,R===null?R=xu(l):(f=R.cachePool,f!==null?(P=Ot._currentValue,f=f.parent!==P?{parent:P,pool:P}:f):f=Op(),R={baseLanes:R.baseLanes|l,cachePool:f}),i.memoizedState=R,i.childLanes=gu(e,j,l),n.memoizedState=hu,ds(e.child,i)):(Pr(n),l=e.child,e=l.sibling,l=hr(l,{mode:"visible",children:i.children}),l.return=n,l.sibling=null,e!==null&&(j=n.deletions,j===null?(n.deletions=[e],n.flags|=16):j.push(e)),n.child=l,n.memoizedState=null,l)}function vu(e,n){return n=$i({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function $i(e,n){return e=bn(22,e,null,n),e.lanes=0,e}function yu(e,n,l){return Ra(n,e.child,null,l),e=vu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function Km(e,n,l){e.lanes|=n;var i=e.alternate;i!==null&&(i.lanes|=n),Dc(e.return,n,l)}function bu(e,n,l,i,f,x){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:i,tail:l,tailMode:f,treeForkCount:x}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=i,j.tail=l,j.tailMode=f,j.treeForkCount=x)}function Xm(e,n,l){var i=n.pendingProps,f=i.revealOrder,x=i.tail;i=i.children;var j=zt.current,R=(j&2)!==0;if(R?(j=j&1|2,n.flags|=128):j&=1,G(zt,j),Jt(e,n,i,l),i=Xe?Zl:0,!R&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Km(e,l,n);else if(e.tag===19)Km(e,l,n);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===n)break e;for(;e.sibling===null;){if(e.return===null||e.return===n)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(f){case"forwards":for(l=n.child,f=null;l!==null;)e=l.alternate,e!==null&&Ri(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),bu(n,!1,f,l,x,i);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&Ri(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}bu(n,!0,l,null,x,i);break;case"together":bu(n,!1,null,null,void 0,i);break;default:n.memoizedState=null}return n.child}function jr(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),qr|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(ol(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(o(153));if(n.child!==null){for(e=n.child,l=hr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=hr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function ju(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&ji(e)))}function s1(e,n,l){switch(n.tag){case 3:de(n,n.stateNode.containerInfo),Ur(n,Ot,e.memoizedState.cache),ka();break;case 27:case 5:Re(n);break;case 4:de(n,n.stateNode.containerInfo);break;case 10:Ur(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,Wc(n),null;break;case 13:var i=n.memoizedState;if(i!==null)return i.dehydrated!==null?(Pr(n),n.flags|=128,null):(l&n.child.childLanes)!==0?Ym(e,n,l):(Pr(n),e=jr(e,n,l),e!==null?e.sibling:null);Pr(n);break;case 19:var f=(e.flags&128)!==0;if(i=(l&n.childLanes)!==0,i||(ol(e,n,l,!1),i=(l&n.childLanes)!==0),f){if(i)return Xm(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),G(zt,zt.current),i)break;return null;case 22:return n.lanes=0,Vm(e,n,l,n.pendingProps);case 24:Ur(n,Ot,e.memoizedState.cache)}return jr(e,n,l)}function Qm(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)It=!0;else{if(!ju(e,l)&&(n.flags&128)===0)return It=!1,s1(e,n,l);It=(e.flags&131072)!==0}else It=!1,Xe&&(n.flags&1048576)!==0&&Rp(n,Zl,n.index);switch(n.lanes=0,n.tag){case 16:e:{var i=n.pendingProps;if(e=Na(n.elementType),n.type=e,typeof e=="function")Ec(e)?(i=Ma(e,i),n.tag=1,n=Wm(null,n,e,i,l)):(n.tag=0,n=mu(null,n,e,i,l));else{if(e!=null){var f=e.$$typeof;if(f===B){n.tag=11,n=Um(null,n,e,i,l);break e}else if(f===w){n.tag=14,n=Hm(null,n,e,i,l);break e}}throw n=J(e)||e,Error(o(306,n,""))}}return n;case 0:return mu(e,n,n.type,n.pendingProps,l);case 1:return i=n.type,f=Ma(i,n.pendingProps),Wm(e,n,i,f,l);case 3:e:{if(de(n,n.stateNode.containerInfo),e===null)throw Error(o(387));i=n.pendingProps;var x=n.memoizedState;f=x.element,$c(e,n),ss(n,i,null,l);var j=n.memoizedState;if(i=j.cache,Ur(n,Ot,i),i!==x.cache&&_c(n,[Ot],l,!0),ls(),i=j.element,x.isDehydrated)if(x={element:i,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=x,n.memoizedState=x,n.flags&256){n=qm(e,n,i,l);break e}else if(i!==f){f=_n(Error(o(424)),n),Jl(f),n=qm(e,n,i,l);break e}else{switch(e=n.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName==="HTML"?e.ownerDocument.body:e}for(yt=Hn(e.firstChild),Qt=n,Xe=!0,Br=null,In=!0,l=Vp(n,null,i,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(ka(),i===f){n=jr(e,n,l);break e}Jt(e,n,i,l)}n=n.child}return n;case 26:return Hi(e,n),e===null?(l=ox(n.type,null,n.pendingProps,null))?n.memoizedState=l:Xe||(l=n.type,e=n.pendingProps,i=ro(oe.current).createElement(l),i[$t]=n,i[ct]=e,en(i,l,e),Yt(i),n.stateNode=i):n.memoizedState=ox(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Re(n),e===null&&Xe&&(i=n.stateNode=lx(n.type,n.pendingProps,oe.current),Qt=n,In=!0,f=yt,Zr(n.type)?(ed=f,yt=Hn(i.firstChild)):yt=f),Jt(e,n,n.pendingProps.children,l),Hi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Xe&&((f=i=yt)&&(i=O1(i,n.type,n.pendingProps,In),i!==null?(n.stateNode=i,Qt=n,yt=Hn(i.firstChild),In=!1,f=!0):f=!1),f||Ir(n)),Re(n),f=n.type,x=n.pendingProps,j=e!==null?e.memoizedProps:null,i=x.children,Ku(f,x)?i=null:j!==null&&Ku(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=Yc(e,n,Qb,null,null,l),Es._currentValue=f),Hi(e,n),Jt(e,n,i,l),n.child;case 6:return e===null&&Xe&&((e=l=yt)&&(l=B1(l,n.pendingProps,In),l!==null?(n.stateNode=l,Qt=n,yt=null,e=!0):e=!1),e||Ir(n)),null;case 13:return Ym(e,n,l);case 4:return de(n,n.stateNode.containerInfo),i=n.pendingProps,e===null?n.child=Ra(n,null,i,l):Jt(e,n,i,l),n.child;case 11:return Um(e,n,n.type,n.pendingProps,l);case 7:return Jt(e,n,n.pendingProps,l),n.child;case 8:return Jt(e,n,n.pendingProps.children,l),n.child;case 12:return Jt(e,n,n.pendingProps.children,l),n.child;case 10:return i=n.pendingProps,Ur(n,n.type,i.value),Jt(e,n,i.children,l),n.child;case 9:return f=n.type._context,i=n.pendingProps.children,Ca(n),f=Zt(f),i=i(f),n.flags|=1,Jt(e,n,i,l),n.child;case 14:return Hm(e,n,n.type,n.pendingProps,l);case 15:return $m(e,n,n.type,n.pendingProps,l);case 19:return Xm(e,n,l);case 31:return l1(e,n,l);case 22:return Vm(e,n,l,n.pendingProps);case 24:return Ca(n),i=Zt(Ot),e===null?(f=Ic(),f===null&&(f=ht,x=Oc(),f.pooledCache=x,x.refCount++,x!==null&&(f.pooledCacheLanes|=l),f=x),n.memoizedState={parent:i,cache:f},Hc(n),Ur(n,Ot,f)):((e.lanes&l)!==0&&($c(e,n),ss(n,null,null,l),ls()),f=e.memoizedState,x=n.memoizedState,f.parent!==i?(f={parent:i,cache:i},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Ur(n,Ot,i)):(i=x.cache,Ur(n,Ot,i),i!==f.cache&&_c(n,[Ot],l,!0))),Jt(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(o(156,n.tag))}function Sr(e){e.flags|=4}function Su(e,n,l,i,f){if((n=(e.mode&32)!==0)&&(n=!1),n){if(e.flags|=16777216,(f&335544128)===f)if(e.stateNode.complete)e.flags|=8192;else if(wh())e.flags|=8192;else throw Ta=Ci,Uc}else e.flags&=-16777217}function Zm(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!px(n))if(wh())e.flags|=8192;else throw Ta=Ci,Uc}function Vi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?qn():536870912,e.lanes|=n,bl|=n)}function fs(e,n){if(!Xe)switch(e.tailMode){case"hidden":n=e.tail;for(var l=null;n!==null;)n.alternate!==null&&(l=n),n=n.sibling;l===null?e.tail=null:l.sibling=null;break;case"collapsed":l=e.tail;for(var i=null;l!==null;)l.alternate!==null&&(i=l),l=l.sibling;i===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:i.sibling=null}}function bt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,i=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags&65011712,i|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,i|=f.subtreeFlags,i|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=i,e.childLanes=l,n}function i1(e,n,l){var i=n.pendingProps;switch(Ac(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return bt(n),null;case 1:return bt(n),null;case 3:return l=n.stateNode,i=null,e!==null&&(i=e.memoizedState.cache),n.memoizedState.cache!==i&&(n.flags|=2048),vr(Ot),je(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(il(n)?Sr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Lc())),bt(n),null;case 26:var f=n.type,x=n.memoizedState;return e===null?(Sr(n),x!==null?(bt(n),Zm(n,x)):(bt(n),Su(n,f,null,i,l))):x?x!==e.memoizedState?(Sr(n),bt(n),Zm(n,x)):(bt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==i&&Sr(n),bt(n),Su(n,f,e,i,l)),null;case 27:if(_e(n),l=oe.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return bt(n),null}e=te.current,il(n)?Mp(n):(e=lx(f,i,l),n.stateNode=e,Sr(n))}return bt(n),null;case 5:if(_e(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(!i){if(n.stateNode===null)throw Error(o(166));return bt(n),null}if(x=te.current,il(n))Mp(n);else{var j=ro(oe.current);switch(x){case 1:x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":x=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":x=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":x=j.createElement("div"),x.innerHTML="<script><\/script>",x=x.removeChild(x.firstChild);break;case"select":x=typeof i.is=="string"?j.createElement("select",{is:i.is}):j.createElement("select"),i.multiple?x.multiple=!0:i.size&&(x.size=i.size);break;default:x=typeof i.is=="string"?j.createElement(f,{is:i.is}):j.createElement(f)}}x[$t]=n,x[ct]=i;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)x.appendChild(j.stateNode);else if(j.tag!==4&&j.tag!==27&&j.child!==null){j.child.return=j,j=j.child;continue}if(j===n)break e;for(;j.sibling===null;){if(j.return===null||j.return===n)break e;j=j.return}j.sibling.return=j.return,j=j.sibling}n.stateNode=x;e:switch(en(x,f,i),f){case"button":case"input":case"select":case"textarea":i=!!i.autoFocus;break e;case"img":i=!0;break e;default:i=!1}i&&Sr(n)}}return bt(n),Su(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==i&&Sr(n);else{if(typeof i!="string"&&n.stateNode===null)throw Error(o(166));if(e=oe.current,il(n)){if(e=n.stateNode,l=n.memoizedProps,i=null,f=Qt,f!==null)switch(f.tag){case 27:case 5:i=f.memoizedProps}e[$t]=n,e=!!(e.nodeValue===l||i!==null&&i.suppressHydrationWarning===!0||Yh(e.nodeValue,l)),e||Ir(n,!0)}else e=ro(e).createTextNode(i),e[$t]=n,n.stateNode=e}return bt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(i=il(n),l!==null){if(e===null){if(!i)throw Error(o(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(o(557));e[$t]=n}else ka(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),e=!1}else l=Lc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Sn(n),n):(Sn(n),null);if((n.flags&128)!==0)throw Error(o(558))}return bt(n),null;case 13:if(i=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=il(n),i!==null&&i.dehydrated!==null){if(e===null){if(!f)throw Error(o(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(o(317));f[$t]=n}else ka(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;bt(n),f=!1}else f=Lc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Sn(n),n):(Sn(n),null)}return Sn(n),(n.flags&128)!==0?(n.lanes=l,n):(l=i!==null,e=e!==null&&e.memoizedState!==null,l&&(i=n.child,f=null,i.alternate!==null&&i.alternate.memoizedState!==null&&i.alternate.memoizedState.cachePool!==null&&(f=i.alternate.memoizedState.cachePool.pool),x=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(x=i.memoizedState.cachePool.pool),x!==f&&(i.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Vi(n,n.updateQueue),bt(n),null);case 4:return je(),e===null&&Fu(n.stateNode.containerInfo),bt(n),null;case 10:return vr(n.type),bt(n),null;case 19:if(Y(zt),i=n.memoizedState,i===null)return bt(n),null;if(f=(n.flags&128)!==0,x=i.rendering,x===null)if(f)fs(i,!1);else{if(Mt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(x=Ri(e),x!==null){for(n.flags|=128,fs(i,!1),e=x.updateQueue,n.updateQueue=e,Vi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Ep(l,e),l=l.sibling;return G(zt,zt.current&1|2),Xe&&xr(n,i.treeForkCount),n.child}e=e.sibling}i.tail!==null&&Ze()>qi&&(n.flags|=128,f=!0,fs(i,!1),n.lanes=4194304)}else{if(!f)if(e=Ri(x),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,Vi(n,e),fs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!x.alternate&&!Xe)return bt(n),null}else 2*Ze()-i.renderingStartTime>qi&&l!==536870912&&(n.flags|=128,f=!0,fs(i,!1),n.lanes=4194304);i.isBackwards?(x.sibling=n.child,n.child=x):(e=i.last,e!==null?e.sibling=x:n.child=x,i.last=x)}return i.tail!==null?(e=i.tail,i.rendering=e,i.tail=e.sibling,i.renderingStartTime=Ze(),e.sibling=null,l=zt.current,G(zt,f?l&1|2:l&1),Xe&&xr(n,i.treeForkCount),e):(bt(n),null);case 22:case 23:return Sn(n),Gc(),i=n.memoizedState!==null,e!==null?e.memoizedState!==null!==i&&(n.flags|=8192):i&&(n.flags|=8192),i?(l&536870912)!==0&&(n.flags&128)===0&&(bt(n),n.subtreeFlags&6&&(n.flags|=8192)):bt(n),l=n.updateQueue,l!==null&&Vi(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),i=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(i=n.memoizedState.cachePool.pool),i!==l&&(n.flags|=2048),e!==null&&Y(Ea),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),vr(Ot),bt(n),null;case 25:return null;case 30:return null}throw Error(o(156,n.tag))}function o1(e,n){switch(Ac(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return vr(Ot),je(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return _e(n),null;case 31:if(n.memoizedState!==null){if(Sn(n),n.alternate===null)throw Error(o(340));ka()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Sn(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(o(340));ka()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return Y(zt),null;case 4:return je(),null;case 10:return vr(n.type),null;case 22:case 23:return Sn(n),Gc(),e!==null&&Y(Ea),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return vr(Ot),null;case 25:return null;default:return null}}function Jm(e,n){switch(Ac(n),n.tag){case 3:vr(Ot),je();break;case 26:case 27:case 5:_e(n);break;case 4:je();break;case 31:n.memoizedState!==null&&Sn(n);break;case 13:Sn(n);break;case 19:Y(zt);break;case 10:vr(n.type);break;case 22:case 23:Sn(n),Gc(),e!==null&&Y(Ea);break;case 24:vr(Ot)}}function ps(e,n){try{var l=n.updateQueue,i=l!==null?l.lastEffect:null;if(i!==null){var f=i.next;l=f;do{if((l.tag&e)===e){i=void 0;var x=l.create,j=l.inst;i=x(),j.destroy=i}l=l.next}while(l!==f)}}catch(R){it(n,n.return,R)}}function Gr(e,n,l){try{var i=n.updateQueue,f=i!==null?i.lastEffect:null;if(f!==null){var x=f.next;i=x;do{if((i.tag&e)===e){var j=i.inst,R=j.destroy;if(R!==void 0){j.destroy=void 0,f=n;var P=l,Z=R;try{Z()}catch(se){it(f,P,se)}}}i=i.next}while(i!==x)}}catch(se){it(n,n.return,se)}}function eh(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{Fp(n,l)}catch(i){it(e,e.return,i)}}}function th(e,n,l){l.props=Ma(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(i){it(e,n,i)}}function ms(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var i=e.stateNode;break;case 30:i=e.stateNode;break;default:i=e.stateNode}typeof l=="function"?e.refCleanup=l(i):l.current=i}}catch(f){it(e,n,f)}}function lr(e,n){var l=e.ref,i=e.refCleanup;if(l!==null)if(typeof i=="function")try{i()}catch(f){it(e,n,f)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(f){it(e,n,f)}else l.current=null}function nh(e){var n=e.type,l=e.memoizedProps,i=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&i.focus();break e;case"img":l.src?i.src=l.src:l.srcSet&&(i.srcset=l.srcSet)}}catch(f){it(e,e.return,f)}}function ku(e,n,l){try{var i=e.stateNode;A1(i,e.type,l,n),i[ct]=n}catch(f){it(e,e.return,f)}}function rh(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zr(e.type)||e.tag===4}function wu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||rh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zr(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Cu(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,n):(n=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,n.appendChild(e),l=l._reactRootContainer,l!=null||n.onclick!==null||(n.onclick=pr));else if(i!==4&&(i===27&&Zr(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(Cu(e,n,l),e=e.sibling;e!==null;)Cu(e,n,l),e=e.sibling}function Pi(e,n,l){var i=e.tag;if(i===5||i===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(i!==4&&(i===27&&Zr(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Pi(e,n,l),e=e.sibling;e!==null;)Pi(e,n,l),e=e.sibling}function ah(e){var n=e.stateNode,l=e.memoizedProps;try{for(var i=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);en(n,i,l),n[$t]=e,n[ct]=l}catch(x){it(e,e.return,x)}}var kr=!1,Ut=!1,Eu=!1,lh=typeof WeakSet=="function"?WeakSet:Set,Kt=null;function c1(e,n){if(e=e.containerInfo,qu=uo,e=gp(e),yc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var i=l.getSelection&&l.getSelection();if(i&&i.rangeCount!==0){l=i.anchorNode;var f=i.anchorOffset,x=i.focusNode;i=i.focusOffset;try{l.nodeType,x.nodeType}catch{l=null;break e}var j=0,R=-1,P=-1,Z=0,se=0,ue=e,ee=null;t:for(;;){for(var re;ue!==l||f!==0&&ue.nodeType!==3||(R=j+f),ue!==x||i!==0&&ue.nodeType!==3||(P=j+i),ue.nodeType===3&&(j+=ue.nodeValue.length),(re=ue.firstChild)!==null;)ee=ue,ue=re;for(;;){if(ue===e)break t;if(ee===l&&++Z===f&&(R=j),ee===x&&++se===i&&(P=j),(re=ue.nextSibling)!==null)break;ue=ee,ee=ue.parentNode}ue=re}l=R===-1||P===-1?null:{start:R,end:P}}else l=null}l=l||{start:0,end:0}}else l=null;for(Yu={focusedElem:e,selectionRange:l},uo=!1,Kt=n;Kt!==null;)if(n=Kt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Kt=e;else for(;Kt!==null;){switch(n=Kt,x=n.alternate,e=n.flags,n.tag){case 0:if((e&4)!==0&&(e=n.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l<e.length;l++)f=e[l],f.ref.impl=f.nextImpl;break;case 11:case 15:break;case 1:if((e&1024)!==0&&x!==null){e=void 0,l=n,f=x.memoizedProps,x=x.memoizedState,i=l.stateNode;try{var we=Ma(l.type,f);e=i.getSnapshotBeforeUpdate(we,x),i.__reactInternalSnapshotBeforeUpdate=e}catch(Le){it(l,l.return,Le)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)Qu(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":Qu(e);break;default:e.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((e&1024)!==0)throw Error(o(163))}if(e=n.sibling,e!==null){e.return=n.return,Kt=e;break}Kt=n.return}}function sh(e,n,l){var i=l.flags;switch(l.tag){case 0:case 11:case 15:Cr(e,l),i&4&&ps(5,l);break;case 1:if(Cr(e,l),i&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){it(l,l.return,j)}else{var f=Ma(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){it(l,l.return,j)}}i&64&&eh(l),i&512&&ms(l,l.return);break;case 3:if(Cr(e,l),i&64&&(e=l.updateQueue,e!==null)){if(n=null,l.child!==null)switch(l.child.tag){case 27:case 5:n=l.child.stateNode;break;case 1:n=l.child.stateNode}try{Fp(e,n)}catch(j){it(l,l.return,j)}}break;case 27:n===null&&i&4&&ah(l);case 26:case 5:Cr(e,l),n===null&&i&4&&nh(l),i&512&&ms(l,l.return);break;case 12:Cr(e,l);break;case 31:Cr(e,l),i&4&&ch(e,l);break;case 13:Cr(e,l),i&4&&uh(e,l),i&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=v1.bind(null,l),I1(e,l))));break;case 22:if(i=l.memoizedState!==null||kr,!i){n=n!==null&&n.memoizedState!==null||Ut,f=kr;var x=Ut;kr=i,(Ut=n)&&!x?Er(e,l,(l.subtreeFlags&8772)!==0):Cr(e,l),kr=f,Ut=x}break;case 30:break;default:Cr(e,l)}}function ih(e){var n=e.alternate;n!==null&&(e.alternate=null,ih(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&nc(n)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var kt=null,mn=!1;function wr(e,n,l){for(l=l.child;l!==null;)oh(e,n,l),l=l.sibling}function oh(e,n,l){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(Mn,l)}catch{}switch(l.tag){case 26:Ut||lr(l,n),wr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Ut||lr(l,n);var i=kt,f=mn;Zr(l.type)&&(kt=l.stateNode,mn=!1),wr(e,n,l),ks(l.stateNode),kt=i,mn=f;break;case 5:Ut||lr(l,n);case 6:if(i=kt,f=mn,kt=null,wr(e,n,l),kt=i,mn=f,kt!==null)if(mn)try{(kt.nodeType===9?kt.body:kt.nodeName==="HTML"?kt.ownerDocument.body:kt).removeChild(l.stateNode)}catch(x){it(l,n,x)}else try{kt.removeChild(l.stateNode)}catch(x){it(l,n,x)}break;case 18:kt!==null&&(mn?(e=kt,ex(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),Tl(e)):ex(kt,l.stateNode));break;case 4:i=kt,f=mn,kt=l.stateNode.containerInfo,mn=!0,wr(e,n,l),kt=i,mn=f;break;case 0:case 11:case 14:case 15:Gr(2,l,n),Ut||Gr(4,l,n),wr(e,n,l);break;case 1:Ut||(lr(l,n),i=l.stateNode,typeof i.componentWillUnmount=="function"&&th(l,n,i)),wr(e,n,l);break;case 21:wr(e,n,l);break;case 22:Ut=(i=Ut)||l.memoizedState!==null,wr(e,n,l),Ut=i;break;default:wr(e,n,l)}}function ch(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Tl(e)}catch(l){it(n,n.return,l)}}}function uh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Tl(e)}catch(l){it(n,n.return,l)}}function u1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new lh),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new lh),n;default:throw Error(o(435,e.tag))}}function Fi(e,n){var l=u1(e);n.forEach(function(i){if(!l.has(i)){l.add(i);var f=y1.bind(null,e,i);i.then(f,f)}})}function hn(e,n){var l=n.deletions;if(l!==null)for(var i=0;i<l.length;i++){var f=l[i],x=e,j=n,R=j;e:for(;R!==null;){switch(R.tag){case 27:if(Zr(R.type)){kt=R.stateNode,mn=!1;break e}break;case 5:kt=R.stateNode,mn=!1;break e;case 3:case 4:kt=R.stateNode.containerInfo,mn=!0;break e}R=R.return}if(kt===null)throw Error(o(160));oh(x,j,f),kt=null,mn=!1,x=f.alternate,x!==null&&(x.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)dh(n,e),n=n.sibling}var Kn=null;function dh(e,n){var l=e.alternate,i=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hn(n,e),xn(e),i&4&&(Gr(3,e,e.return),ps(3,e),Gr(5,e,e.return));break;case 1:hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),i&64&&kr&&(e=e.updateQueue,e!==null&&(i=e.callbacks,i!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?i:l.concat(i))));break;case 26:var f=Kn;if(hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),i&4){var x=l!==null?l.memoizedState:null;if(i=e.memoizedState,l===null)if(i===null)if(e.stateNode===null){e:{i=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(i){case"title":x=f.getElementsByTagName("title")[0],(!x||x[$l]||x[$t]||x.namespaceURI==="http://www.w3.org/2000/svg"||x.hasAttribute("itemprop"))&&(x=f.createElement(i),f.head.insertBefore(x,f.querySelector("head > title"))),en(x,i,l),x[$t]=e,Yt(x),i=x;break e;case"link":var j=dx("link","href",f).get(i+(l.href||""));if(j){for(var R=0;R<j.length;R++)if(x=j[R],x.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&x.getAttribute("rel")===(l.rel==null?null:l.rel)&&x.getAttribute("title")===(l.title==null?null:l.title)&&x.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(R,1);break t}}x=f.createElement(i),en(x,i,l),f.head.appendChild(x);break;case"meta":if(j=dx("meta","content",f).get(i+(l.content||""))){for(R=0;R<j.length;R++)if(x=j[R],x.getAttribute("content")===(l.content==null?null:""+l.content)&&x.getAttribute("name")===(l.name==null?null:l.name)&&x.getAttribute("property")===(l.property==null?null:l.property)&&x.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&x.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(R,1);break t}}x=f.createElement(i),en(x,i,l),f.head.appendChild(x);break;default:throw Error(o(468,i))}x[$t]=e,Yt(x),i=x}e.stateNode=i}else fx(f,e.type,e.stateNode);else e.stateNode=ux(f,i,e.memoizedProps);else x!==i?(x===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):x.count--,i===null?fx(f,e.type,e.stateNode):ux(f,i,e.memoizedProps)):i===null&&e.stateNode!==null&&ku(e,e.memoizedProps,l.memoizedProps)}break;case 27:hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),l!==null&&i&4&&ku(e,e.memoizedProps,l.memoizedProps);break;case 5:if(hn(n,e),xn(e),i&512&&(Ut||l===null||lr(l,l.return)),e.flags&32){f=e.stateNode;try{Qa(f,"")}catch(we){it(e,e.return,we)}}i&4&&e.stateNode!=null&&(f=e.memoizedProps,ku(e,f,l!==null?l.memoizedProps:f)),i&1024&&(Eu=!0);break;case 6:if(hn(n,e),xn(e),i&4){if(e.stateNode===null)throw Error(o(162));i=e.memoizedProps,l=e.stateNode;try{l.nodeValue=i}catch(we){it(e,e.return,we)}}break;case 3:if(so=null,f=Kn,Kn=ao(n.containerInfo),hn(n,e),Kn=f,xn(e),i&4&&l!==null&&l.memoizedState.isDehydrated)try{Tl(n.containerInfo)}catch(we){it(e,e.return,we)}Eu&&(Eu=!1,fh(e));break;case 4:i=Kn,Kn=ao(e.stateNode.containerInfo),hn(n,e),xn(e),Kn=i;break;case 12:hn(n,e),xn(e);break;case 31:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 13:hn(n,e),xn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Wi=Ze()),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 22:f=e.memoizedState!==null;var P=l!==null&&l.memoizedState!==null,Z=kr,se=Ut;if(kr=Z||f,Ut=se||P,hn(n,e),Ut=se,kr=Z,xn(e),i&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||P||kr||Ut||La(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){P=l=n;try{if(x=P.stateNode,f)j=x.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{R=P.stateNode;var ue=P.memoizedProps.style,ee=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;R.style.display=ee==null||typeof ee=="boolean"?"":(""+ee).trim()}}catch(we){it(P,P.return,we)}}}else if(n.tag===6){if(l===null){P=n;try{P.stateNode.nodeValue=f?"":P.memoizedProps}catch(we){it(P,P.return,we)}}}else if(n.tag===18){if(l===null){P=n;try{var re=P.stateNode;f?tx(re,!0):tx(P.stateNode,!1)}catch(we){it(P,P.return,we)}}}else if((n.tag!==22&&n.tag!==23||n.memoizedState===null||n===e)&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break e;for(;n.sibling===null;){if(n.return===null||n.return===e)break e;l===n&&(l=null),n=n.return}l===n&&(l=null),n.sibling.return=n.return,n=n.sibling}i&4&&(i=e.updateQueue,i!==null&&(l=i.retryQueue,l!==null&&(i.retryQueue=null,Fi(e,l))));break;case 19:hn(n,e),xn(e),i&4&&(i=e.updateQueue,i!==null&&(e.updateQueue=null,Fi(e,i)));break;case 30:break;case 21:break;default:hn(n,e),xn(e)}}function xn(e){var n=e.flags;if(n&2){try{for(var l,i=e.return;i!==null;){if(rh(i)){l=i;break}i=i.return}if(l==null)throw Error(o(160));switch(l.tag){case 27:var f=l.stateNode,x=wu(e);Pi(e,x,f);break;case 5:var j=l.stateNode;l.flags&32&&(Qa(j,""),l.flags&=-33);var R=wu(e);Pi(e,R,j);break;case 3:case 4:var P=l.stateNode.containerInfo,Z=wu(e);Cu(e,Z,P);break;default:throw Error(o(161))}}catch(se){it(e,e.return,se)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function fh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;fh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Cr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)sh(e,n.alternate,n),n=n.sibling}function La(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:Gr(4,n,n.return),La(n);break;case 1:lr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&th(n,n.return,l),La(n);break;case 27:ks(n.stateNode);case 26:case 5:lr(n,n.return),La(n);break;case 22:n.memoizedState===null&&La(n);break;case 30:La(n);break;default:La(n)}e=e.sibling}}function Er(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var i=n.alternate,f=e,x=n,j=x.flags;switch(x.tag){case 0:case 11:case 15:Er(f,x,l),ps(4,x);break;case 1:if(Er(f,x,l),i=x,f=i.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(Z){it(i,i.return,Z)}if(i=x,f=i.updateQueue,f!==null){var R=i.stateNode;try{var P=f.shared.hiddenCallbacks;if(P!==null)for(f.shared.hiddenCallbacks=null,f=0;f<P.length;f++)Pp(P[f],R)}catch(Z){it(i,i.return,Z)}}l&&j&64&&eh(x),ms(x,x.return);break;case 27:ah(x);case 26:case 5:Er(f,x,l),l&&i===null&&j&4&&nh(x),ms(x,x.return);break;case 12:Er(f,x,l);break;case 31:Er(f,x,l),l&&j&4&&ch(f,x);break;case 13:Er(f,x,l),l&&j&4&&uh(f,x);break;case 22:x.memoizedState===null&&Er(f,x,l),ms(x,x.return);break;case 30:break;default:Er(f,x,l)}n=n.sibling}}function Nu(e,n){var l=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),e=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(e=n.memoizedState.cachePool.pool),e!==l&&(e!=null&&e.refCount++,l!=null&&es(l))}function Tu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&es(e))}function Xn(e,n,l,i){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)ph(e,n,l,i),n=n.sibling}function ph(e,n,l,i){var f=n.flags;switch(n.tag){case 0:case 11:case 15:Xn(e,n,l,i),f&2048&&ps(9,n);break;case 1:Xn(e,n,l,i);break;case 3:Xn(e,n,l,i),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&es(e)));break;case 12:if(f&2048){Xn(e,n,l,i),e=n.stateNode;try{var x=n.memoizedProps,j=x.id,R=x.onPostCommit;typeof R=="function"&&R(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(P){it(n,n.return,P)}}else Xn(e,n,l,i);break;case 31:Xn(e,n,l,i);break;case 13:Xn(e,n,l,i);break;case 23:break;case 22:x=n.stateNode,j=n.alternate,n.memoizedState!==null?x._visibility&2?Xn(e,n,l,i):hs(e,n):x._visibility&2?Xn(e,n,l,i):(x._visibility|=2,gl(e,n,l,i,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Nu(j,n);break;case 24:Xn(e,n,l,i),f&2048&&Tu(n.alternate,n);break;default:Xn(e,n,l,i)}}function gl(e,n,l,i,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var x=e,j=n,R=l,P=i,Z=j.flags;switch(j.tag){case 0:case 11:case 15:gl(x,j,R,P,f),ps(8,j);break;case 23:break;case 22:var se=j.stateNode;j.memoizedState!==null?se._visibility&2?gl(x,j,R,P,f):hs(x,j):(se._visibility|=2,gl(x,j,R,P,f)),f&&Z&2048&&Nu(j.alternate,j);break;case 24:gl(x,j,R,P,f),f&&Z&2048&&Tu(j.alternate,j);break;default:gl(x,j,R,P,f)}n=n.sibling}}function hs(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,i=n,f=i.flags;switch(i.tag){case 22:hs(l,i),f&2048&&Nu(i.alternate,i);break;case 24:hs(l,i),f&2048&&Tu(i.alternate,i);break;default:hs(l,i)}n=n.sibling}}var xs=8192;function vl(e,n,l){if(e.subtreeFlags&xs)for(e=e.child;e!==null;)mh(e,n,l),e=e.sibling}function mh(e,n,l){switch(e.tag){case 26:vl(e,n,l),e.flags&xs&&e.memoizedState!==null&&X1(l,Kn,e.memoizedState,e.memoizedProps);break;case 5:vl(e,n,l);break;case 3:case 4:var i=Kn;Kn=ao(e.stateNode.containerInfo),vl(e,n,l),Kn=i;break;case 22:e.memoizedState===null&&(i=e.alternate,i!==null&&i.memoizedState!==null?(i=xs,xs=16777216,vl(e,n,l),xs=i):vl(e,n,l));break;default:vl(e,n,l)}}function hh(e){var n=e.alternate;if(n!==null&&(e=n.child,e!==null)){n.child=null;do n=e.sibling,e.sibling=null,e=n;while(e!==null)}}function gs(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];Kt=i,gh(i,e)}hh(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)xh(e),e=e.sibling}function xh(e){switch(e.tag){case 0:case 11:case 15:gs(e),e.flags&2048&&Gr(9,e,e.return);break;case 3:gs(e);break;case 12:gs(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Gi(e)):gs(e);break;default:gs(e)}}function Gi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var i=n[l];Kt=i,gh(i,e)}hh(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:Gr(8,n,n.return),Gi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Gi(n));break;default:Gi(n)}e=e.sibling}}function gh(e,n){for(;Kt!==null;){var l=Kt;switch(l.tag){case 0:case 11:case 15:Gr(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var i=l.memoizedState.cachePool.pool;i!=null&&i.refCount++}break;case 24:es(l.memoizedState.cache)}if(i=l.child,i!==null)i.return=l,Kt=i;else e:for(l=e;Kt!==null;){i=Kt;var f=i.sibling,x=i.return;if(ih(i),i===l){Kt=null;break e}if(f!==null){f.return=x,Kt=f;break e}Kt=x}}}var d1={getCacheForType:function(e){var n=Zt(Ot),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return Zt(Ot).controller.signal}},f1=typeof WeakMap=="function"?WeakMap:Map,rt=0,ht=null,We=null,Ye=0,st=0,kn=null,Wr=!1,yl=!1,Ru=!1,Nr=0,Mt=0,qr=0,za=0,Au=0,wn=0,bl=0,vs=null,gn=null,Mu=!1,Wi=0,vh=0,qi=1/0,Yi=null,Yr=null,Vt=0,Kr=null,jl=null,Tr=0,Lu=0,zu=null,yh=null,ys=0,Du=null;function Cn(){return(rt&2)!==0&&Ye!==0?Ye&-Ye:L.T!==null?Hu():ot()}function bh(){if(wn===0)if((Ye&536870912)===0||Xe){var e=qt;qt<<=1,(qt&3932160)===0&&(qt=262144),wn=e}else wn=536870912;return e=jn.current,e!==null&&(e.flags|=32),wn}function vn(e,n,l){(e===ht&&(st===2||st===9)||e.cancelPendingCommit!==null)&&(Sl(e,0),Xr(e,Ye,wn,!1)),fa(e,l),((rt&2)===0||e!==ht)&&(e===ht&&((rt&2)===0&&(za|=l),Mt===4&&Xr(e,Ye,wn,!1)),sr(e))}function jh(e,n,l){if((rt&6)!==0)throw Error(o(327));var i=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Me(e,n),f=i?h1(e,n):Ou(e,n,!0),x=i;do{if(f===0){yl&&!i&&Xr(e,n,0,!1);break}else{if(l=e.current.alternate,x&&!p1(l)){f=Ou(e,n,!1),x=!1;continue}if(f===2){if(x=n,e.errorRecoveryDisabledLanes&x)var j=0;else j=e.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){n=j;e:{var R=e;f=vs;var P=R.current.memoizedState.isDehydrated;if(P&&(Sl(R,j).flags|=256),j=Ou(R,j,!1),j!==2){if(Ru&&!P){R.errorRecoveryDisabledLanes|=x,za|=x,f=4;break e}x=gn,gn=f,x!==null&&(gn===null?gn=x:gn.push.apply(gn,x))}f=j}if(x=!1,f!==2)continue}}if(f===1){Sl(e,0),Xr(e,n,0,!0);break}e:{switch(i=e,x=f,x){case 0:case 1:throw Error(o(345));case 4:if((n&4194048)!==n)break;case 6:Xr(i,n,wn,!Wr);break e;case 2:gn=null;break;case 3:case 5:break;default:throw Error(o(329))}if((n&62914560)===n&&(f=Wi+300-Ze(),10<f)){if(Xr(i,n,wn,!Wr),Se(i,0,!0)!==0)break e;Tr=n,i.timeoutHandle=Zh(Sh.bind(null,i,l,gn,Yi,Mu,n,wn,za,bl,Wr,x,"Throttled",-0,0),f);break e}Sh(i,l,gn,Yi,Mu,n,wn,za,bl,Wr,x,null,-0,0)}}break}while(!0);sr(e)}function Sh(e,n,l,i,f,x,j,R,P,Z,se,ue,ee,re){if(e.timeoutHandle=-1,ue=n.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pr},mh(n,x,ue);var we=(x&62914560)===x?Wi-Ze():(x&4194048)===x?vh-Ze():0;if(we=Q1(ue,we),we!==null){Tr=x,e.cancelPendingCommit=we(Ah.bind(null,e,n,x,l,i,f,j,R,P,se,ue,null,ee,re)),Xr(e,x,j,!Z);return}}Ah(e,n,x,l,i,f,j,R,P)}function p1(e){for(var n=e;;){var l=n.tag;if((l===0||l===11||l===15)&&n.flags&16384&&(l=n.updateQueue,l!==null&&(l=l.stores,l!==null)))for(var i=0;i<l.length;i++){var f=l[i],x=f.getSnapshot;f=f.value;try{if(!yn(x(),f))return!1}catch{return!1}}if(l=n.child,n.subtreeFlags&16384&&l!==null)l.return=n,n=l;else{if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return!0;n=n.return}n.sibling.return=n.return,n=n.sibling}}return!0}function Xr(e,n,l,i){n&=~Au,n&=~za,e.suspendedLanes|=n,e.pingedLanes&=~n,i&&(e.warmLanes|=n),i=e.expirationTimes;for(var f=n;0<f;){var x=31-gt(f),j=1<<x;i[x]=-1,f&=~j}l!==0&&tr(e,l,n)}function Ki(){return(rt&6)===0?(bs(0),!1):!0}function _u(){if(We!==null){if(st===0)var e=We.return;else e=We,gr=wa=null,Qc(e),fl=null,ns=0,e=We;for(;e!==null;)Jm(e.alternate,e),e=e.return;We=null}}function Sl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,z1(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Tr=0,_u(),ht=e,We=l=hr(e.current,null),Ye=n,st=0,kn=null,Wr=!1,yl=Me(e,n),Ru=!1,bl=wn=Au=za=qr=Mt=0,gn=vs=null,Mu=!1,(n&8)!==0&&(n|=n&32);var i=e.entangledLanes;if(i!==0)for(e=e.entanglements,i&=n;0<i;){var f=31-gt(i),x=1<<f;n|=e[f],i&=~x}return Nr=n,xi(),l}function kh(e,n){$e=null,L.H=us,n===dl||n===wi?(n=Up(),st=3):n===Uc?(n=Up(),st=4):st=n===pu?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,kn=n,We===null&&(Mt=1,Ii(e,_n(n,e.current)))}function wh(){var e=jn.current;return e===null?!0:(Ye&4194048)===Ye?Un===null:(Ye&62914560)===Ye||(Ye&536870912)!==0?e===Un:!1}function Ch(){var e=L.H;return L.H=us,e===null?us:e}function Eh(){var e=L.A;return L.A=d1,e}function Xi(){Mt=4,Wr||(Ye&4194048)!==Ye&&jn.current!==null||(yl=!0),(qr&134217727)===0&&(za&134217727)===0||ht===null||Xr(ht,Ye,wn,!1)}function Ou(e,n,l){var i=rt;rt|=2;var f=Ch(),x=Eh();(ht!==e||Ye!==n)&&(Yi=null,Sl(e,n)),n=!1;var j=Mt;e:do try{if(st!==0&&We!==null){var R=We,P=kn;switch(st){case 8:_u(),j=6;break e;case 3:case 2:case 9:case 6:jn.current===null&&(n=!0);var Z=st;if(st=0,kn=null,kl(e,R,P,Z),l&&yl){j=0;break e}break;default:Z=st,st=0,kn=null,kl(e,R,P,Z)}}m1(),j=Mt;break}catch(se){kh(e,se)}while(!0);return n&&e.shellSuspendCounter++,gr=wa=null,rt=i,L.H=f,L.A=x,We===null&&(ht=null,Ye=0,xi()),j}function m1(){for(;We!==null;)Nh(We)}function h1(e,n){var l=rt;rt|=2;var i=Ch(),f=Eh();ht!==e||Ye!==n?(Yi=null,qi=Ze()+500,Sl(e,n)):yl=Me(e,n);e:do try{if(st!==0&&We!==null){n=We;var x=kn;t:switch(st){case 1:st=0,kn=null,kl(e,n,x,1);break;case 2:case 9:if(Bp(x)){st=0,kn=null,Th(n);break}n=function(){st!==2&&st!==9||ht!==e||(st=7),sr(e)},x.then(n,n);break e;case 3:st=7;break e;case 4:st=5;break e;case 7:Bp(x)?(st=0,kn=null,Th(n)):(st=0,kn=null,kl(e,n,x,7));break;case 5:var j=null;switch(We.tag){case 26:j=We.memoizedState;case 5:case 27:var R=We;if(j?px(j):R.stateNode.complete){st=0,kn=null;var P=R.sibling;if(P!==null)We=P;else{var Z=R.return;Z!==null?(We=Z,Qi(Z)):We=null}break t}}st=0,kn=null,kl(e,n,x,5);break;case 6:st=0,kn=null,kl(e,n,x,6);break;case 8:_u(),Mt=6;break e;default:throw Error(o(462))}}x1();break}catch(se){kh(e,se)}while(!0);return gr=wa=null,L.H=i,L.A=f,rt=l,We!==null?0:(ht=null,Ye=0,xi(),Mt)}function x1(){for(;We!==null&&!_t();)Nh(We)}function Nh(e){var n=Qm(e.alternate,e,Nr);e.memoizedProps=e.pendingProps,n===null?Qi(e):We=n}function Th(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=Gm(l,n,n.pendingProps,n.type,void 0,Ye);break;case 11:n=Gm(l,n,n.pendingProps,n.type.render,n.ref,Ye);break;case 5:Qc(n);default:Jm(l,n),n=We=Ep(n,Nr),n=Qm(l,n,Nr)}e.memoizedProps=e.pendingProps,n===null?Qi(e):We=n}function kl(e,n,l,i){gr=wa=null,Qc(n),fl=null,ns=0;var f=n.return;try{if(a1(e,f,n,l,Ye)){Mt=1,Ii(e,_n(l,e.current)),We=null;return}}catch(x){if(f!==null)throw We=f,x;Mt=1,Ii(e,_n(l,e.current)),We=null;return}n.flags&32768?(Xe||i===1?e=!0:yl||(Ye&536870912)!==0?e=!1:(Wr=e=!0,(i===2||i===9||i===3||i===6)&&(i=jn.current,i!==null&&i.tag===13&&(i.flags|=16384))),Rh(n,e)):Qi(n)}function Qi(e){var n=e;do{if((n.flags&32768)!==0){Rh(n,Wr);return}e=n.return;var l=i1(n.alternate,n,Nr);if(l!==null){We=l;return}if(n=n.sibling,n!==null){We=n;return}We=n=e}while(n!==null);Mt===0&&(Mt=5)}function Rh(e,n){do{var l=o1(e.alternate,e);if(l!==null){l.flags&=32767,We=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){We=e;return}We=e=l}while(e!==null);Mt=6,We=null}function Ah(e,n,l,i,f,x,j,R,P){e.cancelPendingCommit=null;do Zi();while(Vt!==0);if((rt&6)!==0)throw Error(o(327));if(n!==null){if(n===e.current)throw Error(o(177));if(x=n.lanes|n.childLanes,x|=wc,Hl(e,l,x,j,R,P),e===ht&&(We=ht=null,Ye=0),jl=n,Kr=e,Tr=l,Lu=x,zu=f,yh=i,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,b1(Et,function(){return _h(),null})):(e.callbackNode=null,e.callbackPriority=0),i=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||i){i=L.T,L.T=null,f=_.p,_.p=2,j=rt,rt|=4;try{c1(e,n,l)}finally{rt=j,_.p=f,L.T=i}}Vt=1,Mh(),Lh(),zh()}}function Mh(){if(Vt===1){Vt=0;var e=Kr,n=jl,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=rt;rt|=4;try{dh(n,e);var x=Yu,j=gp(e.containerInfo),R=x.focusedElem,P=x.selectionRange;if(j!==R&&R&&R.ownerDocument&&xp(R.ownerDocument.documentElement,R)){if(P!==null&&yc(R)){var Z=P.start,se=P.end;if(se===void 0&&(se=Z),"selectionStart"in R)R.selectionStart=Z,R.selectionEnd=Math.min(se,R.value.length);else{var ue=R.ownerDocument||document,ee=ue&&ue.defaultView||window;if(ee.getSelection){var re=ee.getSelection(),we=R.textContent.length,Le=Math.min(P.start,we),ft=P.end===void 0?Le:Math.min(P.end,we);!re.extend&&Le>ft&&(j=ft,ft=Le,Le=j);var K=hp(R,Le),W=hp(R,ft);if(K&&W&&(re.rangeCount!==1||re.anchorNode!==K.node||re.anchorOffset!==K.offset||re.focusNode!==W.node||re.focusOffset!==W.offset)){var Q=ue.createRange();Q.setStart(K.node,K.offset),re.removeAllRanges(),Le>ft?(re.addRange(Q),re.extend(W.node,W.offset)):(Q.setEnd(W.node,W.offset),re.addRange(Q))}}}}for(ue=[],re=R;re=re.parentNode;)re.nodeType===1&&ue.push({element:re,left:re.scrollLeft,top:re.scrollTop});for(typeof R.focus=="function"&&R.focus(),R=0;R<ue.length;R++){var ce=ue[R];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}uo=!!qu,Yu=qu=null}finally{rt=f,_.p=i,L.T=l}}e.current=n,Vt=2}}function Lh(){if(Vt===2){Vt=0;var e=Kr,n=jl,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=L.T,L.T=null;var i=_.p;_.p=2;var f=rt;rt|=4;try{sh(e,n.alternate,n)}finally{rt=f,_.p=i,L.T=l}}Vt=3}}function zh(){if(Vt===4||Vt===3){Vt=0,Tt();var e=Kr,n=jl,l=Tr,i=yh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Vt=5:(Vt=0,jl=Kr=null,Dh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(Yr=null),Dr(l),n=n.stateNode,Lt&&typeof Lt.onCommitFiberRoot=="function")try{Lt.onCommitFiberRoot(Mn,n,void 0,(n.current.flags&128)===128)}catch{}if(i!==null){n=L.T,f=_.p,_.p=2,L.T=null;try{for(var x=e.onRecoverableError,j=0;j<i.length;j++){var R=i[j];x(R.value,{componentStack:R.stack})}}finally{L.T=n,_.p=f}}(Tr&3)!==0&&Zi(),sr(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===Du?ys++:(ys=0,Du=e):ys=0,bs(0)}}function Dh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,es(n)))}function Zi(){return Mh(),Lh(),zh(),_h()}function _h(){if(Vt!==5)return!1;var e=Kr,n=Lu;Lu=0;var l=Dr(Tr),i=L.T,f=_.p;try{_.p=32>l?32:l,L.T=null,l=zu,zu=null;var x=Kr,j=Tr;if(Vt=0,jl=Kr=null,Tr=0,(rt&6)!==0)throw Error(o(331));var R=rt;if(rt|=4,xh(x.current),ph(x,x.current,j,l),rt=R,bs(0,!1),Lt&&typeof Lt.onPostCommitFiberRoot=="function")try{Lt.onPostCommitFiberRoot(Mn,x)}catch{}return!0}finally{_.p=f,L.T=i,Dh(e,n)}}function Oh(e,n,l){n=_n(l,n),n=fu(e.stateNode,n,2),e=Vr(e,n,2),e!==null&&(fa(e,2),sr(e))}function it(e,n,l){if(e.tag===3)Oh(e,e,l);else for(;n!==null;){if(n.tag===3){Oh(n,e,l);break}else if(n.tag===1){var i=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof i.componentDidCatch=="function"&&(Yr===null||!Yr.has(i))){e=_n(l,e),l=Bm(2),i=Vr(n,l,2),i!==null&&(Im(l,i,n,e),fa(i,2),sr(i));break}}n=n.return}}function Bu(e,n,l){var i=e.pingCache;if(i===null){i=e.pingCache=new f1;var f=new Set;i.set(n,f)}else f=i.get(n),f===void 0&&(f=new Set,i.set(n,f));f.has(l)||(Ru=!0,f.add(l),e=g1.bind(null,e,n,l),n.then(e,e))}function g1(e,n,l){var i=e.pingCache;i!==null&&i.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,ht===e&&(Ye&l)===l&&(Mt===4||Mt===3&&(Ye&62914560)===Ye&&300>Ze()-Wi?(rt&2)===0&&Sl(e,0):Au|=l,bl===Ye&&(bl=0)),sr(e)}function Bh(e,n){n===0&&(n=qn()),e=ja(e,n),e!==null&&(fa(e,n),sr(e))}function v1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),Bh(e,l)}function y1(e,n){var l=0;switch(e.tag){case 31:case 13:var i=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:i=e.stateNode;break;case 22:i=e.stateNode._retryCache;break;default:throw Error(o(314))}i!==null&&i.delete(n),Bh(e,l)}function b1(e,n){return Nt(e,n)}var Ji=null,wl=null,Iu=!1,eo=!1,Uu=!1,Qr=0;function sr(e){e!==wl&&e.next===null&&(wl===null?Ji=wl=e:wl=wl.next=e),eo=!0,Iu||(Iu=!0,S1())}function bs(e,n){if(!Uu&&eo){Uu=!0;do for(var l=!1,i=Ji;i!==null;){if(e!==0){var f=i.pendingLanes;if(f===0)var x=0;else{var j=i.suspendedLanes,R=i.pingedLanes;x=(1<<31-gt(42|e)+1)-1,x&=f&~(j&~R),x=x&201326741?x&201326741|1:x?x|2:0}x!==0&&(l=!0,$h(i,x))}else x=Ye,x=Se(i,i===ht?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),(x&3)===0||Me(i,x)||(l=!0,$h(i,x));i=i.next}while(l);Uu=!1}}function j1(){Ih()}function Ih(){eo=Iu=!1;var e=0;Qr!==0&&L1()&&(e=Qr);for(var n=Ze(),l=null,i=Ji;i!==null;){var f=i.next,x=Uh(i,n);x===0?(i.next=null,l===null?Ji=f:l.next=f,f===null&&(wl=l)):(l=i,(e!==0||(x&3)!==0)&&(eo=!0)),i=f}Vt!==0&&Vt!==5||bs(e),Qr!==0&&(Qr=0)}function Uh(e,n){for(var l=e.suspendedLanes,i=e.pingedLanes,f=e.expirationTimes,x=e.pendingLanes&-62914561;0<x;){var j=31-gt(x),R=1<<j,P=f[j];P===-1?((R&l)===0||(R&i)!==0)&&(f[j]=Fa(R,n)):P<=n&&(e.expiredLanes|=R),x&=~R}if(n=ht,l=Ye,l=Se(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i=e.callbackNode,l===0||e===n&&(st===2||st===9)||e.cancelPendingCommit!==null)return i!==null&&i!==null&&xt(i),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Me(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(i!==null&&xt(i),Dr(l)){case 2:case 8:l=mt;break;case 32:l=Et;break;case 268435456:l=fn;break;default:l=Et}return i=Hh.bind(null,e),l=Nt(l,i),e.callbackPriority=n,e.callbackNode=l,n}return i!==null&&i!==null&&xt(i),e.callbackPriority=2,e.callbackNode=null,2}function Hh(e,n){if(Vt!==0&&Vt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(Zi()&&e.callbackNode!==l)return null;var i=Ye;return i=Se(e,e===ht?i:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),i===0?null:(jh(e,i,n),Uh(e,Ze()),e.callbackNode!=null&&e.callbackNode===l?Hh.bind(null,e):null)}function $h(e,n){if(Zi())return null;jh(e,n,!0)}function S1(){D1(function(){(rt&6)!==0?Nt(ye,j1):Ih()})}function Hu(){if(Qr===0){var e=cl;e===0&&(e=Rt,Rt<<=1,(Rt&261888)===0&&(Rt=256)),Qr=e}return Qr}function Vh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:oi(""+e)}function Ph(e,n){var l=n.ownerDocument.createElement("input");return l.name=n.name,l.value=n.value,e.id&&l.setAttribute("form",e.id),n.parentNode.insertBefore(l,n),e=new FormData(e),l.parentNode.removeChild(l),e}function k1(e,n,l,i,f){if(n==="submit"&&l&&l.stateNode===f){var x=Vh((f[ct]||null).action),j=i.submitter;j&&(n=(n=j[ct]||null)?Vh(n.formAction):j.getAttribute("formAction"),n!==null&&(x=n,j=null));var R=new fi("action","action",null,i,f);e.push({event:R,listeners:[{instance:null,listener:function(){if(i.defaultPrevented){if(Qr!==0){var P=j?Ph(f,j):new FormData(f);su(l,{pending:!0,data:P,method:f.method,action:x},null,P)}}else typeof x=="function"&&(R.preventDefault(),P=j?Ph(f,j):new FormData(f),su(l,{pending:!0,data:P,method:f.method,action:x},x,P))},currentTarget:f}]})}}for(var $u=0;$u<kc.length;$u++){var Vu=kc[$u],w1=Vu.toLowerCase(),C1=Vu[0].toUpperCase()+Vu.slice(1);Yn(w1,"on"+C1)}Yn(bp,"onAnimationEnd"),Yn(jp,"onAnimationIteration"),Yn(Sp,"onAnimationStart"),Yn("dblclick","onDoubleClick"),Yn("focusin","onFocus"),Yn("focusout","onBlur"),Yn($b,"onTransitionRun"),Yn(Vb,"onTransitionStart"),Yn(Pb,"onTransitionCancel"),Yn(kp,"onTransitionEnd"),Ka("onMouseEnter",["mouseout","mouseover"]),Ka("onMouseLeave",["mouseout","mouseover"]),Ka("onPointerEnter",["pointerout","pointerover"]),Ka("onPointerLeave",["pointerout","pointerover"]),ga("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ga("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ga("onBeforeInput",["compositionend","keypress","textInput","paste"]),ga("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ga("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var js="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),E1=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(js));function Fh(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var i=e[l],f=i.event;i=i.listeners;e:{var x=void 0;if(n)for(var j=i.length-1;0<=j;j--){var R=i[j],P=R.instance,Z=R.currentTarget;if(R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(se){hi(se)}f.currentTarget=null,x=P}else for(j=0;j<i.length;j++){if(R=i[j],P=R.instance,Z=R.currentTarget,R=R.listener,P!==x&&f.isPropagationStopped())break e;x=R,f.currentTarget=Z;try{x(f)}catch(se){hi(se)}f.currentTarget=null,x=P}}}}function qe(e,n){var l=n[nr];l===void 0&&(l=n[nr]=new Set);var i=e+"__bubble";l.has(i)||(Gh(n,e,2,!1),l.add(i))}function Pu(e,n,l){var i=0;n&&(i|=4),Gh(l,e,i,n)}var to="_reactListening"+Math.random().toString(36).slice(2);function Fu(e){if(!e[to]){e[to]=!0,If.forEach(function(l){l!=="selectionchange"&&(E1.has(l)||Pu(l,!1,e),Pu(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[to]||(n[to]=!0,Pu("selectionchange",!1,n))}}function Gh(e,n,l,i){switch(bx(n)){case 2:var f=e0;break;case 8:f=t0;break;default:f=ld}l=f.bind(null,n,l,e),f=void 0,!uc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),i?f!==void 0?e.addEventListener(n,l,{capture:!0,passive:f}):e.addEventListener(n,l,!0):f!==void 0?e.addEventListener(n,l,{passive:f}):e.addEventListener(n,l,!1)}function Gu(e,n,l,i,f){var x=i;if((n&1)===0&&(n&2)===0&&i!==null)e:for(;;){if(i===null)return;var j=i.tag;if(j===3||j===4){var R=i.stateNode.containerInfo;if(R===f)break;if(j===4)for(j=i.return;j!==null;){var P=j.tag;if((P===3||P===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;R!==null;){if(j=Wa(R),j===null)return;if(P=j.tag,P===5||P===6||P===26||P===27){i=x=j;continue e}R=R.parentNode}}i=i.return}Xf(function(){var Z=x,se=oc(l),ue=[];e:{var ee=wp.get(e);if(ee!==void 0){var re=fi,we=e;switch(e){case"keypress":if(ui(l)===0)break e;case"keydown":case"keyup":re=yb;break;case"focusin":we="focus",re=mc;break;case"focusout":we="blur",re=mc;break;case"beforeblur":case"afterblur":re=mc;break;case"click":if(l.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":re=Jf;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":re=ib;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":re=Sb;break;case bp:case jp:case Sp:re=ub;break;case kp:re=wb;break;case"scroll":case"scrollend":re=lb;break;case"wheel":re=Eb;break;case"copy":case"cut":case"paste":re=fb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":re=tp;break;case"toggle":case"beforetoggle":re=Tb}var Le=(n&4)!==0,ft=!Le&&(e==="scroll"||e==="scrollend"),K=Le?ee!==null?ee+"Capture":null:ee;Le=[];for(var W=Z,Q;W!==null;){var ce=W;if(Q=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||Q===null||K===null||(ce=Pl(W,K),ce!=null&&Le.push(Ss(W,ce,Q))),ft)break;W=W.return}0<Le.length&&(ee=new re(ee,we,null,l,se),ue.push({event:ee,listeners:Le}))}}if((n&7)===0){e:{if(ee=e==="mouseover"||e==="pointerover",re=e==="mouseout"||e==="pointerout",ee&&l!==ic&&(we=l.relatedTarget||l.fromElement)&&(Wa(we)||we[xa]))break e;if((re||ee)&&(ee=se.window===se?se:(ee=se.ownerDocument)?ee.defaultView||ee.parentWindow:window,re?(we=l.relatedTarget||l.toElement,re=Z,we=we?Wa(we):null,we!==null&&(ft=u(we),Le=we.tag,we!==ft||Le!==5&&Le!==27&&Le!==6)&&(we=null)):(re=null,we=Z),re!==we)){if(Le=Jf,ce="onMouseLeave",K="onMouseEnter",W="mouse",(e==="pointerout"||e==="pointerover")&&(Le=tp,ce="onPointerLeave",K="onPointerEnter",W="pointer"),ft=re==null?ee:Vl(re),Q=we==null?ee:Vl(we),ee=new Le(ce,W+"leave",re,l,se),ee.target=ft,ee.relatedTarget=Q,ce=null,Wa(se)===Z&&(Le=new Le(K,W+"enter",we,l,se),Le.target=Q,Le.relatedTarget=ft,ce=Le),ft=ce,re&&we)t:{for(Le=N1,K=re,W=we,Q=0,ce=K;ce;ce=Le(ce))Q++;ce=0;for(var Ae=W;Ae;Ae=Le(Ae))ce++;for(;0<Q-ce;)K=Le(K),Q--;for(;0<ce-Q;)W=Le(W),ce--;for(;Q--;){if(K===W||W!==null&&K===W.alternate){Le=K;break t}K=Le(K),W=Le(W)}Le=null}else Le=null;re!==null&&Wh(ue,ee,re,Le,!1),we!==null&&ft!==null&&Wh(ue,ft,we,Le,!0)}}e:{if(ee=Z?Vl(Z):window,re=ee.nodeName&&ee.nodeName.toLowerCase(),re==="select"||re==="input"&&ee.type==="file")var Je=cp;else if(ip(ee))if(up)Je=Ib;else{Je=Ob;var Ee=_b}else re=ee.nodeName,!re||re.toLowerCase()!=="input"||ee.type!=="checkbox"&&ee.type!=="radio"?Z&&sc(Z.elementType)&&(Je=cp):Je=Bb;if(Je&&(Je=Je(e,Z))){op(ue,Je,l,se);break e}Ee&&Ee(e,ee,Z),e==="focusout"&&Z&&ee.type==="number"&&Z.memoizedProps.value!=null&&lc(ee,"number",ee.value)}switch(Ee=Z?Vl(Z):window,e){case"focusin":(ip(Ee)||Ee.contentEditable==="true")&&(tl=Ee,bc=Z,Ql=null);break;case"focusout":Ql=bc=tl=null;break;case"mousedown":jc=!0;break;case"contextmenu":case"mouseup":case"dragend":jc=!1,vp(ue,l,se);break;case"selectionchange":if(Hb)break;case"keydown":case"keyup":vp(ue,l,se)}var Pe;if(xc)e:{switch(e){case"compositionstart":var Ke="onCompositionStart";break e;case"compositionend":Ke="onCompositionEnd";break e;case"compositionupdate":Ke="onCompositionUpdate";break e}Ke=void 0}else el?lp(e,l)&&(Ke="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Ke="onCompositionStart");Ke&&(np&&l.locale!=="ko"&&(el||Ke!=="onCompositionStart"?Ke==="onCompositionEnd"&&el&&(Pe=Qf()):(_r=se,dc="value"in _r?_r.value:_r.textContent,el=!0)),Ee=no(Z,Ke),0<Ee.length&&(Ke=new ep(Ke,e,null,l,se),ue.push({event:Ke,listeners:Ee}),Pe?Ke.data=Pe:(Pe=sp(l),Pe!==null&&(Ke.data=Pe)))),(Pe=Ab?Mb(e,l):Lb(e,l))&&(Ke=no(Z,"onBeforeInput"),0<Ke.length&&(Ee=new ep("onBeforeInput","beforeinput",null,l,se),ue.push({event:Ee,listeners:Ke}),Ee.data=Pe)),k1(ue,e,Z,l,se)}Fh(ue,n)})}function Ss(e,n,l){return{instance:e,listener:n,currentTarget:l}}function no(e,n){for(var l=n+"Capture",i=[];e!==null;){var f=e,x=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||x===null||(f=Pl(e,l),f!=null&&i.unshift(Ss(e,f,x)),f=Pl(e,n),f!=null&&i.push(Ss(e,f,x))),e.tag===3)return i;e=e.return}return[]}function N1(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Wh(e,n,l,i,f){for(var x=n._reactName,j=[];l!==null&&l!==i;){var R=l,P=R.alternate,Z=R.stateNode;if(R=R.tag,P!==null&&P===i)break;R!==5&&R!==26&&R!==27||Z===null||(P=Z,f?(Z=Pl(l,x),Z!=null&&j.unshift(Ss(l,Z,P))):f||(Z=Pl(l,x),Z!=null&&j.push(Ss(l,Z,P)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var T1=/\r\n?/g,R1=/\u0000|\uFFFD/g;function qh(e){return(typeof e=="string"?e:""+e).replace(T1,`
50
+ `).replace(R1,"")}function Yh(e,n){return n=qh(n),qh(e)===n}function dt(e,n,l,i,f,x){switch(l){case"children":typeof i=="string"?n==="body"||n==="textarea"&&i===""||Qa(e,i):(typeof i=="number"||typeof i=="bigint")&&n!=="body"&&Qa(e,""+i);break;case"className":si(e,"class",i);break;case"tabIndex":si(e,"tabindex",i);break;case"dir":case"role":case"viewBox":case"width":case"height":si(e,l,i);break;case"style":Yf(e,i,x);break;case"data":if(n!=="object"){si(e,"data",i);break}case"src":case"href":if(i===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(i==null||typeof i=="function"||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"action":case"formAction":if(typeof i=="function"){e.setAttribute(l,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof x=="function"&&(l==="formAction"?(n!=="input"&&dt(e,n,"name",f.name,f,null),dt(e,n,"formEncType",f.formEncType,f,null),dt(e,n,"formMethod",f.formMethod,f,null),dt(e,n,"formTarget",f.formTarget,f,null)):(dt(e,n,"encType",f.encType,f,null),dt(e,n,"method",f.method,f,null),dt(e,n,"target",f.target,f,null)));if(i==null||typeof i=="symbol"||typeof i=="boolean"){e.removeAttribute(l);break}i=oi(""+i),e.setAttribute(l,i);break;case"onClick":i!=null&&(e.onclick=pr);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"multiple":e.multiple=i&&typeof i!="function"&&typeof i!="symbol";break;case"muted":e.muted=i&&typeof i!="function"&&typeof i!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(i==null||typeof i=="function"||typeof i=="boolean"||typeof i=="symbol"){e.removeAttribute("xlink:href");break}l=oi(""+i),e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",l);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""+i):e.removeAttribute(l);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":i&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":i===!0?e.setAttribute(l,""):i!==!1&&i!=null&&typeof i!="function"&&typeof i!="symbol"?e.setAttribute(l,i):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":i!=null&&typeof i!="function"&&typeof i!="symbol"&&!isNaN(i)&&1<=i?e.setAttribute(l,i):e.removeAttribute(l);break;case"rowSpan":case"start":i==null||typeof i=="function"||typeof i=="symbol"||isNaN(i)?e.removeAttribute(l):e.setAttribute(l,i);break;case"popover":qe("beforetoggle",e),qe("toggle",e),li(e,"popover",i);break;case"xlinkActuate":fr(e,"http://www.w3.org/1999/xlink","xlink:actuate",i);break;case"xlinkArcrole":fr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",i);break;case"xlinkRole":fr(e,"http://www.w3.org/1999/xlink","xlink:role",i);break;case"xlinkShow":fr(e,"http://www.w3.org/1999/xlink","xlink:show",i);break;case"xlinkTitle":fr(e,"http://www.w3.org/1999/xlink","xlink:title",i);break;case"xlinkType":fr(e,"http://www.w3.org/1999/xlink","xlink:type",i);break;case"xmlBase":fr(e,"http://www.w3.org/XML/1998/namespace","xml:base",i);break;case"xmlLang":fr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",i);break;case"xmlSpace":fr(e,"http://www.w3.org/XML/1998/namespace","xml:space",i);break;case"is":li(e,"is",i);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=rb.get(l)||l,li(e,l,i))}}function Wu(e,n,l,i,f,x){switch(l){case"style":Yf(e,i,x);break;case"dangerouslySetInnerHTML":if(i!=null){if(typeof i!="object"||!("__html"in i))throw Error(o(61));if(l=i.__html,l!=null){if(f.children!=null)throw Error(o(60));e.innerHTML=l}}break;case"children":typeof i=="string"?Qa(e,i):(typeof i=="number"||typeof i=="bigint")&&Qa(e,""+i);break;case"onScroll":i!=null&&qe("scroll",e);break;case"onScrollEnd":i!=null&&qe("scrollend",e);break;case"onClick":i!=null&&(e.onclick=pr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Uf.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),x=e[ct]||null,x=x!=null?x[l]:null,typeof x=="function"&&e.removeEventListener(n,x,f),typeof i=="function")){typeof x!="function"&&x!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,i,f);break e}l in e?e[l]=i:i===!0?e.setAttribute(l,""):li(e,l,i)}}}function en(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":qe("error",e),qe("load",e);var i=!1,f=!1,x;for(x in l)if(l.hasOwnProperty(x)){var j=l[x];if(j!=null)switch(x){case"src":i=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:dt(e,n,x,j,l,null)}}f&&dt(e,n,"srcSet",l.srcSet,l,null),i&&dt(e,n,"src",l.src,l,null);return;case"input":qe("invalid",e);var R=x=j=f=null,P=null,Z=null;for(i in l)if(l.hasOwnProperty(i)){var se=l[i];if(se!=null)switch(i){case"name":f=se;break;case"type":j=se;break;case"checked":P=se;break;case"defaultChecked":Z=se;break;case"value":x=se;break;case"defaultValue":R=se;break;case"children":case"dangerouslySetInnerHTML":if(se!=null)throw Error(o(137,n));break;default:dt(e,n,i,se,l,null)}}Ff(e,x,R,P,Z,j,f,!1);return;case"select":qe("invalid",e),i=j=x=null;for(f in l)if(l.hasOwnProperty(f)&&(R=l[f],R!=null))switch(f){case"value":x=R;break;case"defaultValue":j=R;break;case"multiple":i=R;default:dt(e,n,f,R,l,null)}n=x,l=j,e.multiple=!!i,n!=null?Xa(e,!!i,n,!1):l!=null&&Xa(e,!!i,l,!0);return;case"textarea":qe("invalid",e),x=f=i=null;for(j in l)if(l.hasOwnProperty(j)&&(R=l[j],R!=null))switch(j){case"value":i=R;break;case"defaultValue":f=R;break;case"children":x=R;break;case"dangerouslySetInnerHTML":if(R!=null)throw Error(o(91));break;default:dt(e,n,j,R,l,null)}Wf(e,i,f,x);return;case"option":for(P in l)if(l.hasOwnProperty(P)&&(i=l[P],i!=null))switch(P){case"selected":e.selected=i&&typeof i!="function"&&typeof i!="symbol";break;default:dt(e,n,P,i,l,null)}return;case"dialog":qe("beforetoggle",e),qe("toggle",e),qe("cancel",e),qe("close",e);break;case"iframe":case"object":qe("load",e);break;case"video":case"audio":for(i=0;i<js.length;i++)qe(js[i],e);break;case"image":qe("error",e),qe("load",e);break;case"details":qe("toggle",e);break;case"embed":case"source":case"link":qe("error",e),qe("load",e);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(Z in l)if(l.hasOwnProperty(Z)&&(i=l[Z],i!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":throw Error(o(137,n));default:dt(e,n,Z,i,l,null)}return;default:if(sc(n)){for(se in l)l.hasOwnProperty(se)&&(i=l[se],i!==void 0&&Wu(e,n,se,i,l,void 0));return}}for(R in l)l.hasOwnProperty(R)&&(i=l[R],i!=null&&dt(e,n,R,i,l,null))}function A1(e,n,l,i){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,x=null,j=null,R=null,P=null,Z=null,se=null;for(re in l){var ue=l[re];if(l.hasOwnProperty(re)&&ue!=null)switch(re){case"checked":break;case"value":break;case"defaultValue":P=ue;default:i.hasOwnProperty(re)||dt(e,n,re,null,i,ue)}}for(var ee in i){var re=i[ee];if(ue=l[ee],i.hasOwnProperty(ee)&&(re!=null||ue!=null))switch(ee){case"type":x=re;break;case"name":f=re;break;case"checked":Z=re;break;case"defaultChecked":se=re;break;case"value":j=re;break;case"defaultValue":R=re;break;case"children":case"dangerouslySetInnerHTML":if(re!=null)throw Error(o(137,n));break;default:re!==ue&&dt(e,n,ee,re,i,ue)}}ac(e,j,R,P,Z,se,x,f);return;case"select":re=j=R=ee=null;for(x in l)if(P=l[x],l.hasOwnProperty(x)&&P!=null)switch(x){case"value":break;case"multiple":re=P;default:i.hasOwnProperty(x)||dt(e,n,x,null,i,P)}for(f in i)if(x=i[f],P=l[f],i.hasOwnProperty(f)&&(x!=null||P!=null))switch(f){case"value":ee=x;break;case"defaultValue":R=x;break;case"multiple":j=x;default:x!==P&&dt(e,n,f,x,i,P)}n=R,l=j,i=re,ee!=null?Xa(e,!!l,ee,!1):!!i!=!!l&&(n!=null?Xa(e,!!l,n,!0):Xa(e,!!l,l?[]:"",!1));return;case"textarea":re=ee=null;for(R in l)if(f=l[R],l.hasOwnProperty(R)&&f!=null&&!i.hasOwnProperty(R))switch(R){case"value":break;case"children":break;default:dt(e,n,R,null,i,f)}for(j in i)if(f=i[j],x=l[j],i.hasOwnProperty(j)&&(f!=null||x!=null))switch(j){case"value":ee=f;break;case"defaultValue":re=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(o(91));break;default:f!==x&&dt(e,n,j,f,i,x)}Gf(e,ee,re);return;case"option":for(var we in l)if(ee=l[we],l.hasOwnProperty(we)&&ee!=null&&!i.hasOwnProperty(we))switch(we){case"selected":e.selected=!1;break;default:dt(e,n,we,null,i,ee)}for(P in i)if(ee=i[P],re=l[P],i.hasOwnProperty(P)&&ee!==re&&(ee!=null||re!=null))switch(P){case"selected":e.selected=ee&&typeof ee!="function"&&typeof ee!="symbol";break;default:dt(e,n,P,ee,i,re)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Le in l)ee=l[Le],l.hasOwnProperty(Le)&&ee!=null&&!i.hasOwnProperty(Le)&&dt(e,n,Le,null,i,ee);for(Z in i)if(ee=i[Z],re=l[Z],i.hasOwnProperty(Z)&&ee!==re&&(ee!=null||re!=null))switch(Z){case"children":case"dangerouslySetInnerHTML":if(ee!=null)throw Error(o(137,n));break;default:dt(e,n,Z,ee,i,re)}return;default:if(sc(n)){for(var ft in l)ee=l[ft],l.hasOwnProperty(ft)&&ee!==void 0&&!i.hasOwnProperty(ft)&&Wu(e,n,ft,void 0,i,ee);for(se in i)ee=i[se],re=l[se],!i.hasOwnProperty(se)||ee===re||ee===void 0&&re===void 0||Wu(e,n,se,ee,i,re);return}}for(var K in l)ee=l[K],l.hasOwnProperty(K)&&ee!=null&&!i.hasOwnProperty(K)&&dt(e,n,K,null,i,ee);for(ue in i)ee=i[ue],re=l[ue],!i.hasOwnProperty(ue)||ee===re||ee==null&&re==null||dt(e,n,ue,ee,i,re)}function Kh(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function M1(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),i=0;i<l.length;i++){var f=l[i],x=f.transferSize,j=f.initiatorType,R=f.duration;if(x&&R&&Kh(j)){for(j=0,R=f.responseEnd,i+=1;i<l.length;i++){var P=l[i],Z=P.startTime;if(Z>R)break;var se=P.transferSize,ue=P.initiatorType;se&&Kh(ue)&&(P=P.responseEnd,j+=se*(P<R?1:(R-Z)/(P-Z)))}if(--i,n+=8*(x+j)/(f.duration/1e3),e++,10<e)break}}if(0<e)return n/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e=="number")?e:5}var qu=null,Yu=null;function ro(e){return e.nodeType===9?e:e.ownerDocument}function Xh(e){switch(e){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Qh(e,n){if(e===0)switch(n){case"svg":return 1;case"math":return 2;default:return 0}return e===1&&n==="foreignObject"?0:e}function Ku(e,n){return e==="textarea"||e==="noscript"||typeof n.children=="string"||typeof n.children=="number"||typeof n.children=="bigint"||typeof n.dangerouslySetInnerHTML=="object"&&n.dangerouslySetInnerHTML!==null&&n.dangerouslySetInnerHTML.__html!=null}var Xu=null;function L1(){var e=window.event;return e&&e.type==="popstate"?e===Xu?!1:(Xu=e,!0):(Xu=null,!1)}var Zh=typeof setTimeout=="function"?setTimeout:void 0,z1=typeof clearTimeout=="function"?clearTimeout:void 0,Jh=typeof Promise=="function"?Promise:void 0,D1=typeof queueMicrotask=="function"?queueMicrotask:typeof Jh<"u"?function(e){return Jh.resolve(null).then(e).catch(_1)}:Zh;function _1(e){setTimeout(function(){throw e})}function Zr(e){return e==="head"}function ex(e,n){var l=n,i=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(i===0){e.removeChild(f),Tl(n);return}i--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")i++;else if(l==="html")ks(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,ks(l);for(var x=l.firstChild;x;){var j=x.nextSibling,R=x.nodeName;x[$l]||R==="SCRIPT"||R==="STYLE"||R==="LINK"&&x.rel.toLowerCase()==="stylesheet"||l.removeChild(x),x=j}}else l==="body"&&ks(e.ownerDocument.body);l=f}while(l);Tl(n)}function tx(e,n){var l=e;e=0;do{var i=l.nextSibling;if(l.nodeType===1?n?(l._stashedDisplay=l.style.display,l.style.display="none"):(l.style.display=l._stashedDisplay||"",l.getAttribute("style")===""&&l.removeAttribute("style")):l.nodeType===3&&(n?(l._stashedText=l.nodeValue,l.nodeValue=""):l.nodeValue=l._stashedText||""),i&&i.nodeType===8)if(l=i.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=i}while(l)}function Qu(e){var n=e.firstChild;for(n&&n.nodeType===10&&(n=n.nextSibling);n;){var l=n;switch(n=n.nextSibling,l.nodeName){case"HTML":case"HEAD":case"BODY":Qu(l),nc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function O1(e,n,l,i){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!i&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(i){if(!e[$l])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(x=e.getAttribute("rel"),x==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(x!==f.rel||e.getAttribute("href")!==(f.href==null||f.href===""?null:f.href)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin)||e.getAttribute("title")!==(f.title==null?null:f.title))break;return e;case"style":if(e.hasAttribute("data-precedence"))break;return e;case"script":if(x=e.getAttribute("src"),(x!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&x&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var x=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===x)return e}else return e;if(e=Hn(e.nextSibling),e===null)break}return null}function B1(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Hn(e.nextSibling),e===null))return null;return e}function nx(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Hn(e.nextSibling),e===null))return null;return e}function Zu(e){return e.data==="$?"||e.data==="$~"}function Ju(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function I1(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var i=function(){n(),l.removeEventListener("DOMContentLoaded",i)};l.addEventListener("DOMContentLoaded",i),e._reactRetry=i}}function Hn(e){for(;e!=null;e=e.nextSibling){var n=e.nodeType;if(n===1||n===3)break;if(n===8){if(n=e.data,n==="$"||n==="$!"||n==="$?"||n==="$~"||n==="&"||n==="F!"||n==="F")break;if(n==="/$"||n==="/&")return null}}return e}var ed=null;function rx(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Hn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function ax(e){e=e.previousSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="$"||l==="$!"||l==="$?"||l==="$~"||l==="&"){if(n===0)return e;n--}else l!=="/$"&&l!=="/&"||n++}e=e.previousSibling}return null}function lx(e,n,l){switch(n=ro(l),e){case"html":if(e=n.documentElement,!e)throw Error(o(452));return e;case"head":if(e=n.head,!e)throw Error(o(453));return e;case"body":if(e=n.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function ks(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);nc(e)}var $n=new Map,sx=new Set;function ao(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Rr=_.d;_.d={f:U1,r:H1,D:$1,C:V1,L:P1,m:F1,X:W1,S:G1,M:q1};function U1(){var e=Rr.f(),n=Ki();return e||n}function H1(e){var n=qa(e);n!==null&&n.tag===5&&n.type==="form"?km(n):Rr.r(e)}var Cl=typeof document>"u"?null:document;function ix(e,n,l){var i=Cl;if(i&&typeof n=="string"&&n){var f=zn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),sx.has(f)||(sx.add(f),e={rel:e,crossOrigin:l,href:n},i.querySelector(f)===null&&(n=i.createElement("link"),en(n,"link",e),Yt(n),i.head.appendChild(n)))}}function $1(e){Rr.D(e),ix("dns-prefetch",e,null)}function V1(e,n){Rr.C(e,n),ix("preconnect",e,n)}function P1(e,n,l){Rr.L(e,n,l);var i=Cl;if(i&&e&&n){var f='link[rel="preload"][as="'+zn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+zn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+zn(l.imageSizes)+'"]')):f+='[href="'+zn(e)+'"]';var x=f;switch(n){case"style":x=El(e);break;case"script":x=Nl(e)}$n.has(x)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),$n.set(x,e),i.querySelector(f)!==null||n==="style"&&i.querySelector(ws(x))||n==="script"&&i.querySelector(Cs(x))||(n=i.createElement("link"),en(n,"link",e),Yt(n),i.head.appendChild(n)))}}function F1(e,n){Rr.m(e,n);var l=Cl;if(l&&e){var i=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+zn(i)+'"][href="'+zn(e)+'"]',x=f;switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":x=Nl(e)}if(!$n.has(x)&&(e=v({rel:"modulepreload",href:e},n),$n.set(x,e),l.querySelector(f)===null)){switch(i){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Cs(x)))return}i=l.createElement("link"),en(i,"link",e),Yt(i),l.head.appendChild(i)}}}function G1(e,n,l){Rr.S(e,n,l);var i=Cl;if(i&&e){var f=Ya(i).hoistableStyles,x=El(e);n=n||"default";var j=f.get(x);if(!j){var R={loading:0,preload:null};if(j=i.querySelector(ws(x)))R.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=$n.get(x))&&td(e,l);var P=j=i.createElement("link");Yt(P),en(P,"link",e),P._p=new Promise(function(Z,se){P.onload=Z,P.onerror=se}),P.addEventListener("load",function(){R.loading|=1}),P.addEventListener("error",function(){R.loading|=2}),R.loading|=4,lo(j,n,i)}j={type:"stylesheet",instance:j,count:1,state:R},f.set(x,j)}}}function W1(e,n){Rr.X(e,n);var l=Cl;if(l&&e){var i=Ya(l).hoistableScripts,f=Nl(e),x=i.get(f);x||(x=l.querySelector(Cs(f)),x||(e=v({src:e,async:!0},n),(n=$n.get(f))&&nd(e,n),x=l.createElement("script"),Yt(x),en(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function q1(e,n){Rr.M(e,n);var l=Cl;if(l&&e){var i=Ya(l).hoistableScripts,f=Nl(e),x=i.get(f);x||(x=l.querySelector(Cs(f)),x||(e=v({src:e,async:!0,type:"module"},n),(n=$n.get(f))&&nd(e,n),x=l.createElement("script"),Yt(x),en(x,"link",e),l.head.appendChild(x)),x={type:"script",instance:x,count:1,state:null},i.set(f,x))}}function ox(e,n,l,i){var f=(f=oe.current)?ao(f):null;if(!f)throw Error(o(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=El(l.href),l=Ya(f).hoistableStyles,i=l.get(n),i||(i={type:"style",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=El(l.href);var x=Ya(f).hoistableStyles,j=x.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},x.set(e,j),(x=f.querySelector(ws(e)))&&!x._p&&(j.instance=x,j.state.loading=5),$n.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},$n.set(e,l),x||Y1(f,e,l,j.state))),n&&i===null)throw Error(o(528,""));return j}if(n&&i!==null)throw Error(o(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Nl(l),l=Ya(f).hoistableScripts,i=l.get(n),i||(i={type:"script",instance:null,count:0,state:null},l.set(n,i)),i):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,e))}}function El(e){return'href="'+zn(e)+'"'}function ws(e){return'link[rel="stylesheet"]['+e+"]"}function cx(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function Y1(e,n,l,i){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?i.loading=1:(n=e.createElement("link"),i.preload=n,n.addEventListener("load",function(){return i.loading|=1}),n.addEventListener("error",function(){return i.loading|=2}),en(n,"link",l),Yt(n),e.head.appendChild(n))}function Nl(e){return'[src="'+zn(e)+'"]'}function Cs(e){return"script[async]"+e}function ux(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var i=e.querySelector('style[data-href~="'+zn(l.href)+'"]');if(i)return n.instance=i,Yt(i),i;var f=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return i=(e.ownerDocument||e).createElement("style"),Yt(i),en(i,"style",f),lo(i,l.precedence,e),n.instance=i;case"stylesheet":f=El(l.href);var x=e.querySelector(ws(f));if(x)return n.state.loading|=4,n.instance=x,Yt(x),x;i=cx(l),(f=$n.get(f))&&td(i,f),x=(e.ownerDocument||e).createElement("link"),Yt(x);var j=x;return j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),en(x,"link",i),n.state.loading|=4,lo(x,l.precedence,e),n.instance=x;case"script":return x=Nl(l.src),(f=e.querySelector(Cs(x)))?(n.instance=f,Yt(f),f):(i=l,(f=$n.get(x))&&(i=v({},l),nd(i,f)),e=e.ownerDocument||e,f=e.createElement("script"),Yt(f),en(f,"link",i),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(o(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(i=n.instance,n.state.loading|=4,lo(i,l.precedence,e));return n.instance}function lo(e,n,l){for(var i=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=i.length?i[i.length-1]:null,x=f,j=0;j<i.length;j++){var R=i[j];if(R.dataset.precedence===n)x=R;else if(x!==f)break}x?x.parentNode.insertBefore(e,x.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function td(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function nd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var so=null;function dx(e,n,l){if(so===null){var i=new Map,f=so=new Map;f.set(l,i)}else f=so,i=f.get(l),i||(i=new Map,f.set(l,i));if(i.has(e))return i;for(i.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var x=l[f];if(!(x[$l]||x[$t]||e==="link"&&x.getAttribute("rel")==="stylesheet")&&x.namespaceURI!=="http://www.w3.org/2000/svg"){var j=x.getAttribute(n)||"";j=e+j;var R=i.get(j);R?R.push(x):i.set(j,[x])}}return i}function fx(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function K1(e,n,l){if(l===1||n.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof n.precedence!="string"||typeof n.href!="string"||n.href==="")break;return!0;case"link":if(typeof n.rel!="string"||typeof n.href!="string"||n.href===""||n.onLoad||n.onError)break;switch(n.rel){case"stylesheet":return e=n.disabled,typeof n.precedence=="string"&&e==null;default:return!0}case"script":if(n.async&&typeof n.async!="function"&&typeof n.async!="symbol"&&!n.onLoad&&!n.onError&&n.src&&typeof n.src=="string")return!0}return!1}function px(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function X1(e,n,l,i){if(l.type==="stylesheet"&&(typeof i.media!="string"||matchMedia(i.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=El(i.href),x=n.querySelector(ws(f));if(x){n=x._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=io.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=x,Yt(x);return}x=n.ownerDocument||n,i=cx(i),(f=$n.get(f))&&td(i,f),x=x.createElement("link"),Yt(x);var j=x;j._p=new Promise(function(R,P){j.onload=R,j.onerror=P}),en(x,"link",i),l.instance=x}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=io.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var rd=0;function Q1(e,n){return e.stylesheets&&e.count===0&&co(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var i=setTimeout(function(){if(e.stylesheets&&co(e,e.stylesheets),e.unsuspend){var x=e.unsuspend;e.unsuspend=null,x()}},6e4+n);0<e.imgBytes&&rd===0&&(rd=62500*M1());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&co(e,e.stylesheets),e.unsuspend)){var x=e.unsuspend;e.unsuspend=null,x()}},(e.imgBytes>rd?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(i),clearTimeout(f)}}:null}function io(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)co(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var oo=null;function co(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,oo=new Map,n.forEach(Z1,e),oo=null,io.call(e))}function Z1(e,n){if(!(n.state.loading&4)){var l=oo.get(e);if(l)var i=l.get(null);else{l=new Map,oo.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),x=0;x<f.length;x++){var j=f[x];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(l.set(j.dataset.precedence,j),i=j)}i&&l.set(null,i)}f=n.instance,j=f.getAttribute("data-precedence"),x=l.get(j)||i,x===i&&l.set(null,f),l.set(j,f),this.count++,i=io.bind(this),f.addEventListener("load",i),f.addEventListener("error",i),x?x.parentNode.insertBefore(f,x.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var Es={$$typeof:A,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function J1(e,n,l,i,f,x,j,R,P){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ul(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ul(0),this.hiddenUpdates=Ul(null),this.identifierPrefix=i,this.onUncaughtError=f,this.onCaughtError=x,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=P,this.incompleteTransitions=new Map}function mx(e,n,l,i,f,x,j,R,P,Z,se,ue){return e=new J1(e,n,l,j,P,Z,se,ue,R),n=1,x===!0&&(n|=24),x=bn(3,null,null,n),e.current=x,x.stateNode=e,n=Oc(),n.refCount++,e.pooledCache=n,n.refCount++,x.memoizedState={element:i,isDehydrated:l,cache:n},Hc(x),e}function hx(e){return e?(e=al,e):al}function xx(e,n,l,i,f,x){f=hx(f),i.context===null?i.context=f:i.pendingContext=f,i=$r(n),i.payload={element:l},x=x===void 0?null:x,x!==null&&(i.callback=x),l=Vr(e,i,n),l!==null&&(vn(l,e,n),as(l,e,n))}function gx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function ad(e,n){gx(e,n),(e=e.alternate)&&gx(e,n)}function vx(e){if(e.tag===13||e.tag===31){var n=ja(e,67108864);n!==null&&vn(n,e,67108864),ad(e,67108864)}}function yx(e){if(e.tag===13||e.tag===31){var n=Cn();n=Ga(n);var l=ja(e,n);l!==null&&vn(l,e,n),ad(e,n)}}var uo=!0;function e0(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=2,ld(e,n,l,i)}finally{_.p=x,L.T=f}}function t0(e,n,l,i){var f=L.T;L.T=null;var x=_.p;try{_.p=8,ld(e,n,l,i)}finally{_.p=x,L.T=f}}function ld(e,n,l,i){if(uo){var f=sd(i);if(f===null)Gu(e,n,i,fo,l),jx(e,i);else if(r0(f,e,n,l,i))i.stopPropagation();else if(jx(e,i),n&4&&-1<n0.indexOf(e)){for(;f!==null;){var x=qa(f);if(x!==null)switch(x.tag){case 3:if(x=x.stateNode,x.current.memoizedState.isDehydrated){var j=le(x.pendingLanes);if(j!==0){var R=x;for(R.pendingLanes|=2,R.entangledLanes|=2;j;){var P=1<<31-gt(j);R.entanglements[1]|=P,j&=~P}sr(x),(rt&6)===0&&(qi=Ze()+500,bs(0))}}break;case 31:case 13:R=ja(x,2),R!==null&&vn(R,x,2),Ki(),ad(x,2)}if(x=sd(i),x===null&&Gu(e,n,i,fo,l),x===f)break;f=x}f!==null&&i.stopPropagation()}else Gu(e,n,i,null,l)}}function sd(e){return e=oc(e),id(e)}var fo=null;function id(e){if(fo=null,e=Wa(e),e!==null){var n=u(e);if(n===null)e=null;else{var l=n.tag;if(l===13){if(e=d(n),e!==null)return e;e=null}else if(l===31){if(e=h(n),e!==null)return e;e=null}else if(l===3){if(n.stateNode.current.memoizedState.isDehydrated)return n.tag===3?n.stateNode.containerInfo:null;e=null}else n!==e&&(e=null)}}return fo=e,null}function bx(e){switch(e){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(nt()){case ye:return 2;case mt:return 8;case Et:case Xt:return 32;case fn:return 268435456;default:return 32}default:return 32}}var od=!1,Jr=null,ea=null,ta=null,Ns=new Map,Ts=new Map,na=[],n0="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function jx(e,n){switch(e){case"focusin":case"focusout":Jr=null;break;case"dragenter":case"dragleave":ea=null;break;case"mouseover":case"mouseout":ta=null;break;case"pointerover":case"pointerout":Ns.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ts.delete(n.pointerId)}}function Rs(e,n,l,i,f,x){return e===null||e.nativeEvent!==x?(e={blockedOn:n,domEventName:l,eventSystemFlags:i,nativeEvent:x,targetContainers:[f]},n!==null&&(n=qa(n),n!==null&&vx(n)),e):(e.eventSystemFlags|=i,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function r0(e,n,l,i,f){switch(n){case"focusin":return Jr=Rs(Jr,e,n,l,i,f),!0;case"dragenter":return ea=Rs(ea,e,n,l,i,f),!0;case"mouseover":return ta=Rs(ta,e,n,l,i,f),!0;case"pointerover":var x=f.pointerId;return Ns.set(x,Rs(Ns.get(x)||null,e,n,l,i,f)),!0;case"gotpointercapture":return x=f.pointerId,Ts.set(x,Rs(Ts.get(x)||null,e,n,l,i,f)),!0}return!1}function Sx(e){var n=Wa(e.target);if(n!==null){var l=u(n);if(l!==null){if(n=l.tag,n===13){if(n=d(l),n!==null){e.blockedOn=n,ha(e.priority,function(){yx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,ha(e.priority,function(){yx(l)});return}}else if(n===3&&l.stateNode.current.memoizedState.isDehydrated){e.blockedOn=l.tag===3?l.stateNode.containerInfo:null;return}}}e.blockedOn=null}function po(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=sd(e.nativeEvent);if(l===null){l=e.nativeEvent;var i=new l.constructor(l.type,l);ic=i,l.target.dispatchEvent(i),ic=null}else return n=qa(l),n!==null&&vx(n),e.blockedOn=l,!1;n.shift()}return!0}function kx(e,n,l){po(e)&&l.delete(n)}function a0(){od=!1,Jr!==null&&po(Jr)&&(Jr=null),ea!==null&&po(ea)&&(ea=null),ta!==null&&po(ta)&&(ta=null),Ns.forEach(kx),Ts.forEach(kx)}function mo(e,n){e.blockedOn===n&&(e.blockedOn=null,od||(od=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,a0)))}var ho=null;function wx(e){ho!==e&&(ho=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){ho===e&&(ho=null);for(var n=0;n<e.length;n+=3){var l=e[n],i=e[n+1],f=e[n+2];if(typeof i!="function"){if(id(i||l)===null)continue;break}var x=qa(l);x!==null&&(e.splice(n,3),n-=3,su(x,{pending:!0,data:f,method:l.method,action:i},i,f))}}))}function Tl(e){function n(P){return mo(P,e)}Jr!==null&&mo(Jr,e),ea!==null&&mo(ea,e),ta!==null&&mo(ta,e),Ns.forEach(n),Ts.forEach(n);for(var l=0;l<na.length;l++){var i=na[l];i.blockedOn===e&&(i.blockedOn=null)}for(;0<na.length&&(l=na[0],l.blockedOn===null);)Sx(l),l.blockedOn===null&&na.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(i=0;i<l.length;i+=3){var f=l[i],x=l[i+1],j=f[ct]||null;if(typeof x=="function")j||wx(l);else if(j){var R=null;if(x&&x.hasAttribute("formAction")){if(f=x,j=x[ct]||null)R=j.formAction;else if(id(f)!==null)continue}else R=j.action;typeof R=="function"?l[i+1]=R:(l.splice(i,3),i-=3),wx(l)}}}function Cx(){function e(x){x.canIntercept&&x.info==="react-transition"&&x.intercept({handler:function(){return new Promise(function(j){return f=j})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),i||setTimeout(l,20)}function l(){if(!i&&!navigation.transition){var x=navigation.currentEntry;x&&x.url!=null&&navigation.navigate(x.url,{state:x.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var i=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){i=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function cd(e){this._internalRoot=e}xo.prototype.render=cd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(o(409));var l=n.current,i=Cn();xx(l,i,e,n,null,null)},xo.prototype.unmount=cd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;xx(e.current,2,null,e,null,null),Ki(),n[xa]=null}};function xo(e){this._internalRoot=e}xo.prototype.unstable_scheduleHydration=function(e){if(e){var n=ot();e={blockedOn:null,target:e,priority:n};for(var l=0;l<na.length&&n!==0&&n<na[l].priority;l++);na.splice(l,0,e),l===0&&Sx(e)}};var Ex=a.version;if(Ex!=="19.2.4")throw Error(o(527,Ex,"19.2.4"));_.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(o(188)):(e=Object.keys(e).join(","),Error(o(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var l0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:L,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var go=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!go.isDisabled&&go.supportsFiber)try{Mn=go.inject(l0),Lt=go}catch{}}return Ms.createRoot=function(e,n){if(!c(e))throw Error(o(299));var l=!1,i="",f=zm,x=Dm,j=_m;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(x=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=mx(e,1,!1,null,null,l,i,null,f,x,j,Cx),e[xa]=n.current,Fu(e),new cd(n)},Ms.hydrateRoot=function(e,n,l){if(!c(e))throw Error(o(299));var i=!1,f="",x=zm,j=Dm,R=_m,P=null;return l!=null&&(l.unstable_strictMode===!0&&(i=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(x=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(R=l.onRecoverableError),l.formState!==void 0&&(P=l.formState)),n=mx(e,1,!0,n,l??null,i,f,P,x,j,R,Cx),n.context=hx(null),l=n.current,i=Cn(),i=Ga(i),f=$r(i),f.callback=null,Vr(l,f,i),l=i,n.current.lanes=l,fa(n,l),sr(n),e[xa]=n.current,Fu(e),new xo(n)},Ms.version="19.2.4",Ms}var Ox;function m0(){if(Ox)return fd.exports;Ox=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(a){console.error(a)}}return t(),fd.exports=p0(),fd.exports}var h0=m0();/**
51
+ * react-router v7.13.1
52
+ *
53
+ * Copyright (c) Remix Software Inc.
54
+ *
55
+ * This source code is licensed under the MIT license found in the
56
+ * LICENSE.md file in the root directory of this source tree.
57
+ *
58
+ * @license MIT
59
+ */var Bx="popstate";function Ix(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function x0(t={}){function a(c,u){let{pathname:d="/",search:h="",hash:g=""}=_l(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),Kd("",{pathname:d,search:h,hash:g},u.state&&u.state.usr||null,u.state&&u.state.key||"default")}function s(c,u){let d=c.document.querySelector("base"),h="";if(d&&d.getAttribute("href")){let g=c.location.href,m=g.indexOf("#");h=m===-1?g:g.slice(0,m)}return h+"#"+(typeof u=="string"?u:Ps(u))}function o(c,u){Zn(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return v0(a,s,o,t)}function Gt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Zn(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function g0(){return Math.random().toString(36).substring(2,10)}function Ux(t,a){return{usr:t.state,key:t.key,idx:a,masked:t.unstable_mask?{pathname:t.pathname,search:t.search,hash:t.hash}:void 0}}function Kd(t,a,s=null,o,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?_l(a):a,state:s,key:a&&a.key||o||g0(),unstable_mask:c}}function Ps({pathname:t="/",search:a="",hash:s=""}){return a&&a!=="?"&&(t+=a.charAt(0)==="?"?a:"?"+a),s&&s!=="#"&&(t+=s.charAt(0)==="#"?s:"#"+s),t}function _l(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let o=t.indexOf("?");o>=0&&(a.search=t.substring(o),t=t.substring(0,o)),t&&(a.pathname=t)}return a}function v0(t,a,s,o={}){let{window:c=document.defaultView,v5Compat:u=!1}=o,d=c.history,h="POP",g=null,m=y();m==null&&(m=0,d.replaceState({...d.state,idx:m},""));function y(){return(d.state||{idx:null}).idx}function v(){h="POP";let C=y(),N=C==null?null:C-m;m=C,g&&g({action:h,location:E.location,delta:N})}function b(C,N){h="PUSH";let T=Ix(C)?C:Kd(E.location,C,N);s&&s(T,C),m=y()+1;let A=Ux(T,m),B=E.createHref(T.unstable_mask||T);try{d.pushState(A,"",B)}catch(z){if(z instanceof DOMException&&z.name==="DataCloneError")throw z;c.location.assign(B)}u&&g&&g({action:h,location:E.location,delta:1})}function S(C,N){h="REPLACE";let T=Ix(C)?C:Kd(E.location,C,N);s&&s(T,C),m=y();let A=Ux(T,m),B=E.createHref(T.unstable_mask||T);d.replaceState(A,"",B),u&&g&&g({action:h,location:E.location,delta:0})}function k(C){return y0(C)}let E={get action(){return h},get location(){return t(c,d)},listen(C){if(g)throw new Error("A history only accepts one active listener");return c.addEventListener(Bx,v),g=C,()=>{c.removeEventListener(Bx,v),g=null}},createHref(C){return a(c,C)},createURL:k,encodeLocation(C){let N=k(C);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(C){return d.go(C)}};return E}function y0(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Gt(s,"No window.location.(origin|href) available to create URL");let o=typeof t=="string"?t:Ps(t);return o=o.replace(/ $/,"%20"),!a&&o.startsWith("//")&&(o=s+o),new URL(o,s)}function cv(t,a,s="/"){return b0(t,a,s,!1)}function b0(t,a,s,o){let c=typeof a=="string"?_l(a):a,u=Mr(c.pathname||"/",s);if(u==null)return null;let d=uv(t);j0(d);let h=null;for(let g=0;h==null&&g<d.length;++g){let m=L0(u);h=A0(d[g],m,o)}return h}function uv(t,a=[],s=[],o="",c=!1){let u=(d,h,g=c,m)=>{let y={relativePath:m===void 0?d.path||"":m,caseSensitive:d.caseSensitive===!0,childrenIndex:h,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&g)return;Gt(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=cr([o,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Gt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),uv(d.children,a,b,v,g)),!(d.path==null&&!d.index)&&a.push({path:v,score:T0(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var g;if(d.path===""||!((g=d.path)!=null&&g.includes("?")))u(d,h);else for(let m of dv(d.path))u(d,h,!0,m)}),a}function dv(t){let a=t.split("/");if(a.length===0)return[];let[s,...o]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(o.length===0)return c?[u,""]:[u];let d=dv(o.join("/")),h=[];return h.push(...d.map(g=>g===""?u:[u,g].join("/"))),c&&h.push(...d),h.map(g=>t.startsWith("/")&&g===""?"/":g)}function j0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:R0(a.routesMeta.map(o=>o.childrenIndex),s.routesMeta.map(o=>o.childrenIndex)))}var S0=/^:[\w-]+$/,k0=3,w0=2,C0=1,E0=10,N0=-2,Hx=t=>t==="*";function T0(t,a){let s=t.split("/"),o=s.length;return s.some(Hx)&&(o+=N0),a&&(o+=w0),s.filter(c=>!Hx(c)).reduce((c,u)=>c+(S0.test(u)?k0:u===""?C0:E0),o)}function R0(t,a){return t.length===a.length&&t.slice(0,-1).every((o,c)=>o===a[c])?t[t.length-1]-a[a.length-1]:0}function A0(t,a,s=!1){let{routesMeta:o}=t,c={},u="/",d=[];for(let h=0;h<o.length;++h){let g=o[h],m=h===o.length-1,y=u==="/"?a:a.slice(u.length)||"/",v=Oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:m},y),b=g.route;if(!v&&m&&s&&!o[o.length-1].route.index&&(v=Oo({path:g.relativePath,caseSensitive:g.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:cr([u,v.pathname]),pathnameBase:O0(cr([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=cr([u,v.pathnameBase]))}return d}function Oo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,o]=M0(t.path,t.caseSensitive,t.end),c=a.match(s);if(!c)return null;let u=c[0],d=u.replace(/(.)\/+$/,"$1"),h=c.slice(1);return{params:o.reduce((m,{paramName:y,isOptional:v},b)=>{if(y==="*"){let k=h[b]||"";d=u.slice(0,u.length-k.length).replace(/(.)\/+$/,"$1")}const S=h[b];return v&&!S?m[y]=void 0:m[y]=(S||"").replace(/%2F/g,"/"),m},{}),pathname:u,pathnameBase:d,pattern:t}}function M0(t,a=!1,s=!0){Zn(t==="*"||!t.endsWith("*")||t.endsWith("/*"),`Route path "${t}" will be treated as if it were "${t.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${t.replace(/\*$/,"/*")}".`);let o=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,g,m,y)=>{if(o.push({paramName:h,isOptional:g!=null}),g){let v=y.charAt(m+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(o.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),o]}function L0(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return Zn(!1,`The URL path "${t}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${a}).`),t}}function Mr(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,o=t.charAt(s);return o&&o!=="/"?null:t.slice(s)||"/"}var z0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function D0(t,a="/"){let{pathname:s,search:o="",hash:c=""}=typeof t=="string"?_l(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=$x(s.substring(1),"/"):u=$x(s,a)):u=a,{pathname:u,search:B0(o),hash:I0(c)}}function $x(t,a){let s=a.replace(/\/+$/,"").split("/");return t.split("/").forEach(c=>{c===".."?s.length>1&&s.pop():c!=="."&&s.push(c)}),s.length>1?s.join("/"):"/"}function xd(t,a,s,o){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${s}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function _0(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function fv(t){let a=_0(t);return a.map((s,o)=>o===a.length-1?s.pathname:s.pathnameBase)}function hf(t,a,s,o=!1){let c;typeof t=="string"?c=_l(t):(c={...t},Gt(!c.pathname||!c.pathname.includes("?"),xd("?","pathname","search",c)),Gt(!c.pathname||!c.pathname.includes("#"),xd("#","pathname","hash",c)),Gt(!c.search||!c.search.includes("#"),xd("#","search","hash",c)));let u=t===""||c.pathname==="",d=u?"/":c.pathname,h;if(d==null)h=s;else{let v=a.length-1;if(!o&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?a[v]:"/"}let g=D0(c,h),m=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!g.pathname.endsWith("/")&&(m||y)&&(g.pathname+="/"),g}var cr=t=>t.join("/").replace(/\/\/+/g,"/"),O0=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),B0=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,I0=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,U0=class{constructor(t,a,s,o=!1){this.status=t,this.statusText=a||"",this.internal=o,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function H0(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function $0(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var pv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function mv(t,a){let s=t;if(typeof s!="string"||!z0.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let o=s,c=!1;if(pv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Mr(d.pathname,a);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{Zn(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var hv=["POST","PUT","PATCH","DELETE"];new Set(hv);var V0=["GET",...hv];new Set(V0);var Ol=p.createContext(null);Ol.displayName="DataRouter";var Vo=p.createContext(null);Vo.displayName="DataRouterState";var P0=p.createContext(!1),xv=p.createContext({isTransitioning:!1});xv.displayName="ViewTransition";var F0=p.createContext(new Map);F0.displayName="Fetchers";var G0=p.createContext(null);G0.displayName="Await";var Gn=p.createContext(null);Gn.displayName="Navigation";var Po=p.createContext(null);Po.displayName="Location";var Lr=p.createContext({outlet:null,matches:[],isDataRoute:!1});Lr.displayName="Route";var xf=p.createContext(null);xf.displayName="RouteError";var gv="REACT_ROUTER_ERROR",W0="REDIRECT",q0="ROUTE_ERROR_RESPONSE";function Y0(t){if(t.startsWith(`${gv}:${W0}:{`))try{let a=JSON.parse(t.slice(28));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string"&&typeof a.location=="string"&&typeof a.reloadDocument=="boolean"&&typeof a.replace=="boolean")return a}catch{}}function K0(t){if(t.startsWith(`${gv}:${q0}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new U0(a.status,a.statusText,a.data)}catch{}}function X0(t,{relative:a}={}){Gt(Qs(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:o}=p.useContext(Gn),{hash:c,pathname:u,search:d}=Zs(t,{relative:a}),h=u;return s!=="/"&&(h=u==="/"?s:cr([s,u])),o.createHref({pathname:h,search:d,hash:c})}function Qs(){return p.useContext(Po)!=null}function oa(){return Gt(Qs(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Po).location}var vv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function yv(t){p.useContext(Gn).static||p.useLayoutEffect(t)}function Q0(){let{isDataRoute:t}=p.useContext(Lr);return t?uj():Z0()}function Z0(){Gt(Qs(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Ol),{basename:a,navigator:s}=p.useContext(Gn),{matches:o}=p.useContext(Lr),{pathname:c}=oa(),u=JSON.stringify(fv(o)),d=p.useRef(!1);return yv(()=>{d.current=!0}),p.useCallback((g,m={})=>{if(Zn(d.current,vv),!d.current)return;if(typeof g=="number"){s.go(g);return}let y=hf(g,JSON.parse(u),c,m.relative==="path");t==null&&a!=="/"&&(y.pathname=y.pathname==="/"?a:cr([a,y.pathname])),(m.replace?s.replace:s.push)(y,m.state,m)},[a,s,u,c,t])}p.createContext(null);function Zs(t,{relative:a}={}){let{matches:s}=p.useContext(Lr),{pathname:o}=oa(),c=JSON.stringify(fv(s));return p.useMemo(()=>hf(t,JSON.parse(c),o,a==="path"),[t,c,o,a])}function J0(t,a,s){Gt(Qs(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:o}=p.useContext(Gn),{matches:c}=p.useContext(Lr),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",g=u?u.pathnameBase:"/",m=u&&u.route;{let C=m&&m.path||"";jv(h,!m||C.endsWith("*")||C.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${C}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
60
+
61
+ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}/*`}">.`)}let y=oa(),v;v=y;let b=v.pathname||"/",S=b;if(g!=="/"){let C=g.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(C.length).join("/")}let k=cv(t,{pathname:S});return Zn(m||k!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Zn(k==null||k[k.length-1].route.element!==void 0||k[k.length-1].route.Component!==void 0||k[k.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`),aj(k&&k.map(C=>Object.assign({},C,{params:Object.assign({},d,C.params),pathname:cr([g,o.encodeLocation?o.encodeLocation(C.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathname]),pathnameBase:C.pathnameBase==="/"?g:cr([g,o.encodeLocation?o.encodeLocation(C.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:C.pathnameBase])})),c,s)}function ej(){let t=cj(),a=H0(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,o="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:o},u={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",t),d=p.createElement(p.Fragment,null,p.createElement("p",null,"💿 Hey developer 👋"),p.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",p.createElement("code",{style:u},"ErrorBoundary")," or"," ",p.createElement("code",{style:u},"errorElement")," prop on your route.")),p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},a),s?p.createElement("pre",{style:c},s):null,d)}var tj=p.createElement(ej,null),bv=class extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,a){return a.location!==t.location||a.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:a.error,location:a.location,revalidation:t.revalidation||a.revalidation}}componentDidCatch(t,a){this.props.onError?this.props.onError(t,a):console.error("React Router caught the following error during render",t)}render(){let t=this.state.error;if(this.context&&typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){const s=K0(t.digest);s&&(t=s)}let a=t!==void 0?p.createElement(Lr.Provider,{value:this.props.routeContext},p.createElement(xf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(nj,{error:t},a):a}};bv.contextType=P0;var gd=new WeakMap;function nj({children:t,error:a}){let{basename:s}=p.useContext(Gn);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let o=Y0(a.digest);if(o){let c=gd.get(a);if(c)throw c;let u=mv(o.location,s);if(pv&&!gd.get(a))if(u.isExternal||o.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:o.replace}));throw gd.set(a,d),d}return p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function rj({routeContext:t,match:a,children:s}){let o=p.useContext(Ol);return o&&o.static&&o.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=a.route.id),p.createElement(Lr.Provider,{value:t},s)}function aj(t,a=[],s){let o=s==null?void 0:s.state;if(t==null){if(!o)return null;if(o.errors)t=o.matches;else if(a.length===0&&!o.initialized&&o.matches.length>0)t=o.matches;else return null}let c=t,u=o==null?void 0:o.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Gt(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(u).join(",")}`),c=c.slice(0,Math.min(c.length,y+1))}let d=!1,h=-1;if(s&&o){d=o.renderFallback;for(let y=0;y<c.length;y++){let v=c[y];if((v.route.HydrateFallback||v.route.hydrateFallbackElement)&&(h=y),v.route.id){let{loaderData:b,errors:S}=o,k=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||k){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let g=s==null?void 0:s.onError,m=o&&g?(y,v)=>{var b,S;g(y,{location:o.location,params:((S=(b=o.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:$0(o.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,k=!1,E=null,C=null;o&&(S=u&&v.route.id?u[v.route.id]:void 0,E=v.route.errorElement||tj,d&&(h<0&&b===0?(jv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),k=!0,C=null):h===b&&(k=!0,C=v.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let A;return S?A=E:k?A=C:v.route.Component?A=p.createElement(v.route.Component,null):v.route.element?A=v.route.element:A=y,p.createElement(rj,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:o!=null},children:A})};return o&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?p.createElement(bv,{location:o.location,revalidation:o.revalidation,component:E,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:m}):T()},null)}function gf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function lj(t){let a=p.useContext(Ol);return Gt(a,gf(t)),a}function sj(t){let a=p.useContext(Vo);return Gt(a,gf(t)),a}function ij(t){let a=p.useContext(Lr);return Gt(a,gf(t)),a}function vf(t){let a=ij(t),s=a.matches[a.matches.length-1];return Gt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function oj(){return vf("useRouteId")}function cj(){var o;let t=p.useContext(xf),a=sj("useRouteError"),s=vf("useRouteError");return t!==void 0?t:(o=a.errors)==null?void 0:o[s]}function uj(){let{router:t}=lj("useNavigate"),a=vf("useNavigate"),s=p.useRef(!1);return yv(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{Zn(s.current,vv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var Vx={};function jv(t,a,s){!a&&!Vx[t]&&(Vx[t]=!0,Zn(!1,s))}p.memo(dj);function dj({routes:t,future:a,state:s,isStatic:o,onError:c}){return J0(t,void 0,{state:s,isStatic:o,onError:c})}function fj({basename:t="/",children:a=null,location:s,navigationType:o="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Gt(!Qs(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),g=p.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=_l(s));let{pathname:m="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:k}=s,E=p.useMemo(()=>{let C=Mr(m,h);return C==null?null:{location:{pathname:C,search:y,hash:v,state:b,key:S,unstable_mask:k},navigationType:o}},[h,m,y,v,b,S,o,k]);return Zn(E!=null,`<Router basename="${h}"> is not able to match the URL "${m}${y}${v}" because it does not start with the basename, so the <Router> won't render anything.`),E==null?null:p.createElement(Gn.Provider,{value:g},p.createElement(Po.Provider,{children:a,value:E}))}var Ro="get",Ao="application/x-www-form-urlencoded";function Fo(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function pj(t){return Fo(t)&&t.tagName.toLowerCase()==="button"}function mj(t){return Fo(t)&&t.tagName.toLowerCase()==="form"}function hj(t){return Fo(t)&&t.tagName.toLowerCase()==="input"}function xj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function gj(t,a){return t.button===0&&(!a||a==="_self")&&!xj(t)}var vo=null;function vj(){if(vo===null)try{new FormData(document.createElement("form"),0),vo=!1}catch{vo=!0}return vo}var yj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function vd(t){return t!=null&&!yj.has(t)?(Zn(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Ao}"`),null):t}function bj(t,a){let s,o,c,u,d;if(mj(t)){let h=t.getAttribute("action");o=h?Mr(h,a):null,s=t.getAttribute("method")||Ro,c=vd(t.getAttribute("enctype"))||Ao,u=new FormData(t)}else if(pj(t)||hj(t)&&(t.type==="submit"||t.type==="image")){let h=t.form;if(h==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let g=t.getAttribute("formaction")||h.getAttribute("action");if(o=g?Mr(g,a):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||Ro,c=vd(t.getAttribute("formenctype"))||vd(h.getAttribute("enctype"))||Ao,u=new FormData(h,t),!vj()){let{name:m,type:y,value:v}=t;if(y==="image"){let b=m?`${m}.`:"";u.append(`${b}x`,"0"),u.append(`${b}y`,"0")}else m&&u.append(m,v)}}else{if(Fo(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Ro,o=null,c=Ao,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:o,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function yf(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function jj(t,a,s,o){let c=typeof t=="string"?new URL(t,typeof window>"u"?"server://singlefetch/":window.location.origin):t;return s?c.pathname.endsWith("/")?c.pathname=`${c.pathname}_.${o}`:c.pathname=`${c.pathname}.${o}`:c.pathname==="/"?c.pathname=`_root.${o}`:a&&Mr(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${o}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${o}`,c}async function Sj(t,a){if(t.id in a)return a[t.id];try{let s=await import(t.module);return a[t.id]=s,s}catch(s){return console.error(`Error loading route module \`${t.module}\`, reloading page...`),console.error(s),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function kj(t){return t==null?!1:t.href==null?t.rel==="preload"&&typeof t.imageSrcSet=="string"&&typeof t.imageSizes=="string":typeof t.rel=="string"&&typeof t.href=="string"}async function wj(t,a,s){let o=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await Sj(u,s);return d.links?d.links():[]}return[]}));return Tj(o.flat(1).filter(kj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Px(t,a,s,o,c,u){let d=(g,m)=>s[m]?g.route.id!==s[m].route.id:!0,h=(g,m)=>{var y;return s[m].pathname!==g.pathname||((y=s[m].route.path)==null?void 0:y.endsWith("*"))&&s[m].params["*"]!==g.params["*"]};return u==="assets"?a.filter((g,m)=>d(g,m)||h(g,m)):u==="data"?a.filter((g,m)=>{var v;let y=o.routes[g.route.id];if(!y||!y.hasLoader)return!1;if(d(g,m)||h(g,m))return!0;if(g.route.shouldRevalidate){let b=g.route.shouldRevalidate({currentUrl:new URL(c.pathname+c.search+c.hash,window.origin),currentParams:((v=s[0])==null?void 0:v.params)||{},nextUrl:new URL(t,window.origin),nextParams:g.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function Cj(t,a,{includeHydrateFallback:s}={}){return Ej(t.map(o=>{let c=a.routes[o.route.id];if(!c)return[];let u=[c.module];return c.clientActionModule&&(u=u.concat(c.clientActionModule)),c.clientLoaderModule&&(u=u.concat(c.clientLoaderModule)),s&&c.hydrateFallbackModule&&(u=u.concat(c.hydrateFallbackModule)),c.imports&&(u=u.concat(c.imports)),u}).flat(1))}function Ej(t){return[...new Set(t)]}function Nj(t){let a={},s=Object.keys(t).sort();for(let o of s)a[o]=t[o];return a}function Tj(t,a){let s=new Set;return new Set(a),t.reduce((o,c)=>{let u=JSON.stringify(Nj(c));return s.has(u)||(s.add(u),o.push({key:u,link:c})),o},[])}function Sv(){let t=p.useContext(Ol);return yf(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function Rj(){let t=p.useContext(Vo);return yf(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var bf=p.createContext(void 0);bf.displayName="FrameworkContext";function kv(){let t=p.useContext(bf);return yf(t,"You must render this element inside a <HydratedRouter> element"),t}function Aj(t,a){let s=p.useContext(bf),[o,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:h,onBlur:g,onMouseEnter:m,onMouseLeave:y,onTouchStart:v}=a,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let E=N=>{N.forEach(T=>{d(T.isIntersecting)})},C=new IntersectionObserver(E,{threshold:.5});return b.current&&C.observe(b.current),()=>{C.disconnect()}}},[t]),p.useEffect(()=>{if(o){let E=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(E)}}},[o]);let S=()=>{c(!0)},k=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Ls(h,S),onBlur:Ls(g,k),onMouseEnter:Ls(m,S),onMouseLeave:Ls(y,k),onTouchStart:Ls(v,S)}]:[!1,b,{}]}function Ls(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function Mj({page:t,...a}){let{router:s}=Sv(),o=p.useMemo(()=>cv(s.routes,t,s.basename),[s.routes,t,s.basename]);return o?p.createElement(zj,{page:t,matches:o,...a}):null}function Lj(t){let{manifest:a,routeModules:s}=kv(),[o,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return wj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),o}function zj({page:t,matches:a,...s}){let o=oa(),{future:c,manifest:u,routeModules:d}=kv(),{basename:h}=Sv(),{loaderData:g,matches:m}=Rj(),y=p.useMemo(()=>Px(t,a,m,u,o,"data"),[t,a,m,u,o]),v=p.useMemo(()=>Px(t,a,m,u,o,"assets"),[t,a,m,u,o]),b=p.useMemo(()=>{if(t===o.pathname+o.search+o.hash)return[];let E=new Set,C=!1;if(a.forEach(T=>{var B;let A=u.routes[T.route.id];!A||!A.hasLoader||(!y.some(z=>z.route.id===T.route.id)&&T.route.id in g&&((B=d[T.route.id])!=null&&B.shouldRevalidate)||A.hasClientLoader?C=!0:E.add(T.route.id))}),E.size===0)return[];let N=jj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return C&&E.size>0&&N.searchParams.set("_routes",a.filter(T=>E.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,g,o,u,y,a,t,d]),S=p.useMemo(()=>Cj(v,u),[v,u]),k=Lj(v);return p.createElement(p.Fragment,null,b.map(E=>p.createElement("link",{key:E,rel:"prefetch",as:"fetch",href:E,...s})),S.map(E=>p.createElement("link",{key:E,rel:"modulepreload",href:E,...s})),k.map(({key:E,link:C})=>p.createElement("link",{key:E,nonce:s.nonce,...C,crossOrigin:C.crossOrigin??s.crossOrigin})))}function Dj(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var _j=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{_j&&(window.__reactRouterVersion="7.13.1")}catch{}function Oj({basename:t,children:a,unstable_useTransitions:s,window:o}){let c=p.useRef();c.current==null&&(c.current=x0({window:o,v5Compat:!0}));let u=c.current,[d,h]=p.useState({action:u.action,location:u.location}),g=p.useCallback(m=>{s===!1?h(m):p.startTransition(()=>h(m))},[s]);return p.useLayoutEffect(()=>u.listen(g),[u,g]),p.createElement(fj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var wv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Cv=p.forwardRef(function({onClick:a,discover:s="render",prefetch:o="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:g,target:m,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...k},E){let{basename:C,navigator:N,unstable_useTransitions:T}=p.useContext(Gn),A=typeof y=="string"&&wv.test(y),B=mv(y,C);y=B.to;let z=X0(y,{relative:c}),F=oa(),w=null;if(h){let $=hf(h,[],F.unstable_mask?F.unstable_mask.pathname:"/",!0);C!=="/"&&($.pathname=$.pathname==="/"?C:cr([C,$.pathname])),w=N.createHref($)}let[O,D,U]=Aj(o,k),H=Hj(y,{replace:d,unstable_mask:h,state:g,target:m,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function q($){a&&a($),$.defaultPrevented||H($)}let X=!(B.isExternal||u),J=p.createElement("a",{...k,...U,href:(X?w:void 0)||B.absoluteURL||z,onClick:X?q:a,ref:Dj(E,D),target:m,"data-discover":!A&&s==="render"?"true":void 0});return O&&!A?p.createElement(p.Fragment,null,J,p.createElement(Mj,{page:z})):J});Cv.displayName="Link";var Bj=p.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:o="",end:c=!1,style:u,to:d,viewTransition:h,children:g,...m},y){let v=Zs(d,{relative:m.relative}),b=oa(),S=p.useContext(Vo),{navigator:k,basename:E}=p.useContext(Gn),C=S!=null&&Gj(v)&&h===!0,N=k.encodeLocation?k.encodeLocation(v).pathname:v.pathname,T=b.pathname,A=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(T=T.toLowerCase(),A=A?A.toLowerCase():null,N=N.toLowerCase()),A&&E&&(A=Mr(A,E)||A);const B=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let z=T===N||!c&&T.startsWith(N)&&T.charAt(B)==="/",F=A!=null&&(A===N||!c&&A.startsWith(N)&&A.charAt(N.length)==="/"),w={isActive:z,isPending:F,isTransitioning:C},O=z?a:void 0,D;typeof o=="function"?D=o(w):D=[o,z?"active":null,F?"pending":null,C?"transitioning":null].filter(Boolean).join(" ");let U=typeof u=="function"?u(w):u;return p.createElement(Cv,{...m,"aria-current":O,className:D,ref:y,style:U,to:d,viewTransition:h},typeof g=="function"?g(w):g)});Bj.displayName="NavLink";var Ij=p.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:o,replace:c,state:u,method:d=Ro,action:h,onSubmit:g,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},k)=>{let{unstable_useTransitions:E}=p.useContext(Gn),C=Pj(),N=Fj(h,{relative:m}),T=d.toLowerCase()==="get"?"get":"post",A=typeof h=="string"&&wv.test(h),B=z=>{if(g&&g(z),z.defaultPrevented)return;z.preventDefault();let F=z.nativeEvent.submitter,w=(F==null?void 0:F.getAttribute("formmethod"))||d,O=()=>C(F||z.currentTarget,{fetcherKey:a,method:w,navigate:s,replace:c,state:u,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});E&&s!==!1?p.startTransition(()=>O()):O()};return p.createElement("form",{ref:k,method:T,action:N,onSubmit:o?g:B,...S,"data-discover":!A&&t==="render"?"true":void 0})});Ij.displayName="Form";function Uj(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ev(t){let a=p.useContext(Ol);return Gt(a,Uj(t)),a}function Hj(t,{target:a,replace:s,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g,unstable_useTransitions:m}={}){let y=Q0(),v=oa(),b=Zs(t,{relative:d});return p.useCallback(S=>{if(gj(S,a)){S.preventDefault();let k=s!==void 0?s:Ps(v)===Ps(b),E=()=>y(t,{replace:k,unstable_mask:o,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:g});m?p.startTransition(()=>E()):E()}},[v,y,b,s,o,c,a,t,u,d,h,g,m])}var $j=0,Vj=()=>`__${String(++$j)}__`;function Pj(){let{router:t}=Ev("useSubmit"),{basename:a}=p.useContext(Gn),s=oj(),o=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:h,method:g,encType:m,formData:y,body:v}=bj(u,a);if(d.navigate===!1){let b=d.fetcherKey||Vj();await o(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||m,flushSync:d.flushSync})}else await c(d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||g,formEncType:d.encType||m,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[o,c,a,s])}function Fj(t,{relative:a}={}){let{basename:s}=p.useContext(Gn),o=p.useContext(Lr);Gt(o,"useFormAction must be used inside a RouteContext");let[c]=o.matches.slice(-1),u={...Zs(t||".",{relative:a})},d=oa();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),g=h.getAll("index");if(g.some(y=>y==="")){h.delete("index"),g.filter(v=>v).forEach(v=>h.append("index",v));let y=h.toString();u.search=y?`?${y}`:""}}return(!t||t===".")&&c.route.index&&(u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index"),s!=="/"&&(u.pathname=u.pathname==="/"?s:cr([s,u.pathname])),Ps(u)}function Gj(t,{relative:a}={}){let s=p.useContext(xv);Gt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:o}=Ev("useViewTransitionState"),c=Zs(t,{relative:a});if(!s.isTransitioning)return!1;let u=Mr(s.currentLocation.pathname,o)||s.currentLocation.pathname,d=Mr(s.nextLocation.pathname,o)||s.nextLocation.pathname;return Oo(c.pathname,d)!=null||Oo(c.pathname,u)!=null}var Go=ov();const Wj=iv(Go),qj="modulepreload",Yj=function(t){return"/"+t},Fx={},Ha=function(a,s,o){let c=Promise.resolve();if(s&&s.length>0){let d=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(v=>({status:"fulfilled",value:v}),v=>({status:"rejected",reason:v}))))};document.getElementsByTagName("link");const h=document.querySelector("meta[property=csp-nonce]"),g=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(m=>{if(m=Yj(m),m in Fx)return;Fx[m]=!0;const y=m.endsWith(".css"),v=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${v}`))return;const b=document.createElement("link");if(b.rel=y?"stylesheet":qj,y||(b.as="script"),b.crossOrigin="",b.href=m,g&&b.setAttribute("nonce",g),document.head.appendChild(b),y)return new Promise((S,k)=>{b.addEventListener("load",S),b.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${m}`)))})}))}function u(d){const h=new Event("vite:preloadError",{cancelable:!0});if(h.payload=d,window.dispatchEvent(h),!h.defaultPrevented)throw d}return c.then(d=>{for(const h of d||[])h.status==="rejected"&&u(h.reason);return a().catch(u)})},Kj=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function yd(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!Kj.test(a)?null:a}function Nv(t){const a=yd(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=yd(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const o=yd(t.pluginVersion);return o?{version:o,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const Gx={own:"authoring-project",installed:"available-project",global:"available-personal"},Xd=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function Xj(t){if(typeof t=="string"){if(Xd.has(t))return t;if(Object.prototype.hasOwnProperty.call(Gx,t))return Gx[t]}return"authoring-project"}function Qj(t){return t.startsWith("available-")?"available":"authoring"}function Zj(t){const a=t.indexOf("-");return t.slice(a+1)}const Vn="";class Us extends Error{constructor(a,s){super(a),this.name="ApiError",this.status=s}}async function Ve(t,a){const s=await fetch(`${Vn}${t}`,a);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Us(o.error||`HTTP ${s.status}`,s.status)}return s.json()}function tn(t){return typeof t=="string"&&t.length>0?t:null}function Jj(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function bd(t){if(!Array.isArray(t))return null;const a=t.filter(s=>typeof s=="string"&&s.length>0);return a.length>0?a:null}function eS(t){const a=t??{};let s;a.origin==="source"||a.origin==="installed"?s=a.origin:(s="source",console.warn(`[api.getSkills] skill ${String(a.plugin)}/${String(a.skill)} has invalid origin=${JSON.stringify(a.origin)}; defaulting to 'source'`));let o;a.scope==="own"||a.scope==="installed"||a.scope==="global"?o=a.scope:o=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=o==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&Xd.has(a.scopeV2)?a.scopeV2:Xj(a.scope),d=Qj(u),h=Zj(u),g=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let m;a.shadowedBy===null?m=null:typeof a.shadowedBy=="string"&&Xd.has(a.shadowedBy)?m=a.shadowedBy:m=void 0;const y={plugin:typeof a.plugin=="string"?a.plugin:"",skill:typeof a.skill=="string"?a.skill:"",dir:typeof a.dir=="string"?a.dir:"",hasEvals:!!a.hasEvals,hasBenchmark:!!a.hasBenchmark,evalCount:typeof a.evalCount=="number"?a.evalCount:0,assertionCount:typeof a.assertionCount=="number"?a.assertionCount:0,benchmarkStatus:a.benchmarkStatus==="pass"||a.benchmarkStatus==="fail"||a.benchmarkStatus==="pending"||a.benchmarkStatus==="stale"||a.benchmarkStatus==="missing"?a.benchmarkStatus:"missing",lastBenchmark:typeof a.lastBenchmark=="string"?a.lastBenchmark:null,origin:s,scope:o,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:tn(a.symlinkTarget),installMethod:c,scopeV2:u,group:d,source:h,pluginName:tn(a.pluginName),pluginNamespace:tn(a.pluginNamespace),pluginMarketplace:tn(a.pluginMarketplace),pluginManifestPath:tn(a.pluginManifestPath),pluginVersion:tn(a.pluginVersion),precedenceRank:g,shadowedBy:m,description:tn(a.description),version:tn(a.version),category:tn(a.category),author:tn(a.author),license:tn(a.license),homepage:tn(a.homepage),repoUrl:tn(a.repoUrl),skillPath:tn(a.skillPath),tags:bd(a.tags),deps:bd(a.deps),mcpDeps:bd(a.mcpDeps),entryPoint:tn(a.entryPoint),lastModified:tn(a.lastModified),sizeBytes:Jj(a.sizeBytes),sourceAgent:tn(a.sourceAgent)};if(a.provenance&&typeof a.provenance=="object"){const b=a.provenance;(b.promotedFrom==="installed"||b.promotedFrom==="global")&&typeof b.sourcePath=="string"&&typeof b.promotedAt=="number"?y.provenance={promotedFrom:b.promotedFrom,sourcePath:b.sourcePath,promotedAt:b.promotedAt,sourceSkillVersion:typeof b.sourceSkillVersion=="string"?b.sourceSkillVersion:void 0}:y.provenance=null}else a.provenance===null&&(y.provenance=null);typeof a.updateAvailable=="boolean"&&(y.updateAvailable=a.updateAvailable),typeof a.currentVersion=="string"&&(y.currentVersion=a.currentVersion),typeof a.latestVersion=="string"&&(y.latestVersion=a.latestVersion),typeof a.pinnedVersion=="string"&&(y.pinnedVersion=a.pinnedVersion);const v=Nv({frontmatterVersion:y.version??null,registryCurrentVersion:y.currentVersion??null,pluginVersion:y.pluginVersion??null});return y.resolvedVersion=v.version,y.versionSource=v.versionSource,y}const Ce={getConfig(){return Ve("/api/config")},setConfig(t,a){return Ve("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:t,model:a})})},async getSkills(t){const a=new URLSearchParams;t!=null&&t.scope&&a.set("scope",t.scope),t!=null&&t.agent&&a.set("agent",t.agent);const s=a.toString(),o=await Ve(`/api/skills${s?"?"+s:""}`);return Array.isArray(o)?o.map(eS):[]},getAgents(){return Ve("/api/agents")},getSkillDetail(t,a){return Ve(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await Ve(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:o,...c}=s;return c}return s},getEvalsEnvelope(t,a){return Ve(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return Ve(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return Ve(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return Ve(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Vn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const o=await s.json().catch(()=>({error:s.statusText}));throw new Us(o.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const o=new URLSearchParams;s!=null&&s.model&&o.set("model",s.model),s!=null&&s.type&&o.set("type",s.type),s!=null&&s.from&&o.set("from",s.from),s!=null&&s.to&&o.set("to",s.to);const c=o.toString();return Ve(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return Ve(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,o){return Ve(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(o)}`)},getCaseHistory(t,a,s,o){const c=new URLSearchParams;o&&c.set("model",o);const u=c.toString();return Ve(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return Ve(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return Ve(`/api/skills/${t}/${a}`,{method:"DELETE"})},improveSkill(t,a,s){return Ve(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return Ve(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return Ve(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return Ve(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return Ve(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return Ve("/api/project-layout")},createSkill(t){return Ve("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return Ve("/api/studio/detect-engines")},saveDraft(t){return Ve("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return Ve("/api/skill-creator-status")},generateSkill(t){return Ve("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return Ve(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return Ve(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,o){return Ve(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:o})})},getLeaderboard(t,a){return Ve(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return Ve(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const o=`${Vn}/api/skills/${t}/${a}/sweep`,c=new EventSource(o);return fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return Ve(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,o){return Ve(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:o})})},getParams(t,a){return Ve(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const o=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return Ve(`/api/credentials/${t}/${a}/params?${o}`)},searchModels(){return Ve("/api/openrouter/models")},async getSkillVersions(t,a){const s=await Ve(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return Ve(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,o){return Ve(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${o}`)},startBatchUpdate(t){const a=`${Vn}/api/skills/batch-update`,s=new EventSource(a);return fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({skills:t})}),s},startSkillUpdate(t,a){const s=`${Vn}/api/skills/${t}/${a}/update`,o=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),o},async postSkillUpdate(t,a,s){let o,c;if(s&&typeof s.aborted=="boolean")o=s;else if(s&&typeof s=="object"){const y=s;o=y.signal,c=y.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${Vn}/api/skills/${t}/${a}/update${u}`,h=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},signal:o});let g,m="";if(h.body){const y=h.body.getReader(),v=new TextDecoder;let b=!1,S="";for(;!b;){const E=await y.read();if(b=E.done,E.value){const C=v.decode(E.value,{stream:!b});S+=C,m.length<200&&(m+=C)}}const k=S.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(k)try{g=JSON.parse(k[1]).version}catch{}m=m.slice(0,200)}else{const y=await h.text();m=y.slice(0,200);const v=y.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(v)try{g=JSON.parse(v[1]).version}catch{}}return{ok:h.ok,status:h.status,body:m,version:g}},async rescanSkill(t,a){const s=`${t}/${a}`,o=await fetch(`${Vn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`rescan failed: HTTP ${o.status}`);return await o.json()},async getSkillUpdates(){try{const t=await fetch(`${Vn}/api/skills/updates`);return t.ok?await t.json():[]}catch{return[]}},async checkSkillUpdates(t){if(t.length===0)return[];try{const a=[...t].sort(),s=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:a.map(c=>({name:c,currentVersion:"0.0.0"}))})});if(!s.ok)return[];const o=await s.json().catch(()=>null);return Array.isArray(o)?o:o&&typeof o=="object"&&Array.isArray(o.results)?o.results.map(c=>({skillId:typeof c.skillId=="string"?c.skillId:typeof c.name=="string"?c.name:"",version:typeof c.version=="string"?c.version:typeof c.latest=="string"?c.latest:"",eventId:typeof c.eventId=="string"?c.eventId:"",publishedAt:typeof c.publishedAt=="string"?c.publishedAt:"",diffSummary:typeof c.diffSummary=="string"?c.diffSummary:void 0,trackedForUpdates:typeof c.trackedForUpdates=="boolean"?c.trackedForUpdates:void 0,updateAvailable:typeof c.updateAvailable=="boolean"?c.updateAvailable:void 0,installed:typeof c.installed=="string"?c.installed:void 0,latest:typeof c.latest=="string"?c.latest:void 0,name:typeof c.name=="string"?c.name:void 0})):[]}catch{return[]}},async resolveInstalledSkillIds(t){if(t.length===0)return[];try{const a=await fetch(`${Vn}/api/v1/skills/check-updates`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({skills:t.map(u=>({name:u.name,currentVersion:u.currentVersion??"0.0.0"}))})});if(!a.ok)return t.map(u=>({plugin:u.plugin,skill:u.skill}));const s=await a.json().catch(()=>null),o=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(o.map(u=>[u.name,u]));return t.map(u=>{const d=c.get(u.name);return{plugin:u.plugin,skill:u.skill,uuid:typeof(d==null?void 0:d.id)=="string"&&d.id.length>0?d.id:void 0,slug:typeof(d==null?void 0:d.slug)=="string"&&d.slug.length>0?d.slug:void 0}})}catch{return t.map(s=>({plugin:s.plugin,skill:s.skill}))}},promoteSkill(t,a,s){const o=s!=null&&s.overwrite?"?overwrite=true":"";return jd(`/api/skills/${t}/${a}/promote${o}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const o=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&o.set("dest","global"),s!=null&&s.overwrite&&o.set("overwrite","true");const c=o.toString();return jd(`/api/skills/${t}/${a}/test-install${c?"?"+c:""}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},revertSkill(t,a,s){return jd(`/api/skills/${t}/${a}/revert`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},listStudioOps(t){const a=new URLSearchParams;(t==null?void 0:t.before)!=null&&a.set("before",String(t.before)),(t==null?void 0:t.limit)!=null&&a.set("limit",String(t.limit));const s=a.toString();return Ve(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return Ve(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Vn}/api/studio/ops/stream`)}};async function jd(t,a,s){const o=await fetch(`${Vn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!o.ok||!o.body){let y=`HTTP ${o.status}`,v;try{const S=await o.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Us(y,o.status);throw v&&(b.code=v),b}const c=o.body.getReader(),u=new TextDecoder;let d="",h="",g=null,m=null;for(;;){const{done:y,value:v}=await c.read();if(y)break;d+=u.decode(v,{stream:!0});const b=d.split(`
62
+ `);d=b.pop()??"";for(const S of b)if(S.startsWith("event: "))h=S.slice(7).trim();else if(S.startsWith("data: ")){let k={};try{k=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const E={type:h,...k};a==null||a(E),E.type==="done"&&(g=E),E.type==="error"&&(m=E)}h=""}}if(m){const y=new Us(m.message,500);throw y.code=m.code,y}if(!g)throw new Us("Transfer stream ended without 'done' event",500);return g}function tS(t,a){if(!a.length)return t;const s=new Map,o=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(o.set(d,c),u.length>=1){const h=u[u.length-1];s.set(`${h}/${d}`,c)}}return t.map(c=>{if(c.origin!=="installed")return c;let u;if(c.pluginName?u=s.get(`${c.pluginName}/${c.skill}`):u=o.get(c.skill),!u)return c;const d={...c,updateAvailable:u.updateAvailable,currentVersion:u.installed,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(d.trackedForUpdates=u.trackedForUpdates);const h=Nv({frontmatterVersion:d.version??null,registryCurrentVersion:d.currentVersion??null,pluginVersion:d.pluginVersion??null});return d.resolvedVersion=h.version,d.versionSource=h.versionSource,d})}function nS(t){const[a,s]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return p.useEffect(()=>{const o=window.matchMedia(t);s(o.matches);const c=u=>s(u.matches);return o.addEventListener("change",c),()=>o.removeEventListener("change",c)},[t]),a}const rS=500,Qd="vskill.updates.seenLastId";function aS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(Qd)}catch{return null}}function Sd(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(Qd):window.localStorage.setItem(Qd,t)}catch{}}function lS(){let t=new Map;const a=new Set,s=new Set,o=[];let c=aS();c&&(s.add(c),o.push(c));function u(){t=new Map(t);for(const h of Array.from(a))h()}function d(h){if(!s.has(h)){if(s.add(h),o.push(h),o.length>rS){const g=o.shift();g&&s.delete(g)}c=h,Sd(h)}}return{getSnapshot(){return t},subscribe(h){return a.add(h),()=>{a.delete(h)}},ingest(h){return s.has(h.eventId)?"duplicate":(d(h.eventId),t.set(h.skillId,{skillId:h.skillId,version:h.version,diffSummary:h.diffSummary,eventId:h.eventId,publishedAt:h.publishedAt,receivedAt:Date.now()}),u(),"stored")},dismiss(h){t.has(h)&&(t.delete(h),u())},clearSeen(){s.clear(),o.length=0,c=null,Sd(null)},mergeBulk(h){if(h.length!==0){for(const g of h)t.set(g.skillId,g);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),o.length=0,c=null,Sd(null),u()}}}const Da=lS(),sS=3e5,iS=500,oS=15e3,cS=6e4,uS=6e4,dS="/api/v1/skills/stream";function Wx(t){const a=new Map;for(const s of t){const o=s.name.split("/").pop()||s.name;a.set(o,s)}return a}function qx(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function fS(t){if(!t||typeof t!="object")return!1;const a=t;return a.type==="skill.updated"&&typeof a.eventId=="string"&&typeof a.skillId=="string"&&typeof a.version=="string"}function pS(t){const a=(t==null?void 0:t.intervalMs)??sS,s=(t==null?void 0:t.debounceMs)??iS,o=(t==null?void 0:t.timeoutMs)??oS,c=(t==null?void 0:t.staleAfterMs)??cS,u=(t==null?void 0:t.disconnectFallbackMs)??uS,d=(t==null?void 0:t.streamUrlBase)??dS,h=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),g=p.useMemo(()=>{const M=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return M.length===0?"":[...M].sort().join(",")},[t==null?void 0:t.trackingSkillIds,t==null?void 0:t.skillIds]),[m,y]=p.useState([]),[v,b]=p.useState(()=>new Map),[S,k]=p.useState(0),[E,C]=p.useState(!1),[N,T]=p.useState(null),[A,B]=p.useState(null),z=p.useRef(null),F=p.useRef(null),w=p.useRef(null),O=p.useRef(null),D=p.useRef(!0),[U,H]=p.useState(()=>h?"connecting":"fallback"),q=p.useRef(U);q.current=U;const X=p.useSyncExternalStore(M=>Da.subscribe(M),()=>Da.getSnapshot(),()=>Da.getSnapshot()),J=X.size,$=p.useCallback(async()=>{C(!0);const M=new AbortController,Y=setTimeout(()=>M.abort(),o);try{const G=await Promise.race([Ce.getSkillUpdates(),new Promise((te,fe)=>{M.signal.addEventListener("abort",()=>{fe(new Error("TIMEOUT"))})})]);if(G==="TIMEOUT")throw new Error("TIMEOUT");if(!D.current)return;y(G),b(Wx(G)),k(qx(G)),F.current=Date.now(),T(F.current),B(null)}catch(G){if(!D.current)return;B(G instanceof Error?G:new Error(String(G)))}finally{clearTimeout(Y),D.current&&C(!1)}},[o]),L=p.useCallback(()=>{if(z.current)return z.current;const M=$().finally(()=>{z.current=null});return z.current=M,M},[$]),_=p.useCallback(()=>{w.current==null&&(w.current=setInterval(()=>{L()},a))},[a,L]),I=p.useCallback(()=>{w.current!=null&&(clearInterval(w.current),w.current=null)},[]);p.useEffect(()=>{D.current=!0,(F.current==null||Date.now()-F.current>c)&&L(),(typeof document>"u"||document.visibilityState!=="hidden")&&_();const G=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){I();return}O.current=setTimeout(()=>{O.current=null,(F.current==null||Date.now()-F.current>c)&&L(),_()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",G),()=>{D.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",G),O.current&&clearTimeout(O.current),I()}},[]);const V=p.useCallback(async M=>{if(M.length!==0)try{const Y=await Ce.checkSkillUpdates(M);if(!D.current||Y.length===0)return;const G=Date.now(),te=Y.filter(oe=>oe.skillId&&oe.eventId&&oe.version).map(oe=>({skillId:oe.skillId,version:oe.version,eventId:oe.eventId,publishedAt:oe.publishedAt,diffSummary:oe.diffSummary,receivedAt:G}));te.length>0&&Da.mergeBulk(te);const fe=Y.filter(oe=>typeof oe.trackedForUpdates=="boolean"||typeof oe.updateAvailable=="boolean").map(oe=>({name:oe.name??oe.skillId,installed:oe.installed??"",latest:oe.latest??null,updateAvailable:oe.updateAvailable??!1,trackedForUpdates:typeof oe.trackedForUpdates=="boolean"?oe.trackedForUpdates:void 0}));fe.length>0&&y(oe=>{const ve=new Map;for(const Re of oe)ve.set(Re.name.split("/").pop()||Re.name,Re);let de=0;for(const Re of fe){const _e=Re.name.split("/").pop()||Re.name,ae=ve.get(_e);if(ae){const he={...ae};ae.trackedForUpdates===void 0&&Re.trackedForUpdates!==void 0&&(he.trackedForUpdates=Re.trackedForUpdates),ve.set(_e,he)}else ve.set(_e,{name:Re.name,installed:Re.installed??"",latest:Re.latest??null,updateAvailable:Re.updateAvailable??!1,trackedForUpdates:Re.trackedForUpdates}),de+=1}if(de===0&&ve.size===oe.length)return oe;const je=[...ve.values()];return b(Wx(je)),k(qx(je)),je})}catch{}},[]);p.useEffect(()=>{const M=h||g;if(!M){H("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){H("fallback");return}H("connecting");const Y=M.split(","),G=`${d}?skills=${encodeURIComponent(M)}`;let te=null,fe=null,oe=null;const ve=()=>{fe==null&&(fe=setTimeout(()=>{fe=null,D.current&&q.current!=="connected"&&H("fallback")},u))},de=()=>{fe!=null&&(clearTimeout(fe),fe=null)};ve();const je=1e3,Re=()=>{D.current&&oe==null&&(oe=setTimeout(()=>{if(oe=null,!!D.current&&!(te&&te.readyState!==EventSource.CLOSED)){if(te)try{te.close()}catch{}he()}},je))},_e=pe=>{if(!D.current)return;let xe;try{xe=JSON.parse(pe.data)}catch{return}if(!fS(xe)||Da.ingest(xe)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const Oe=`${xe.skillId} updated to ${xe.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:Oe,severity:"info",skillId:xe.skillId,version:xe.version,eventId:xe.eventId}}))}},ae=()=>{D.current&&(Da.clearSeen(),V(Y))},he=()=>{D.current&&(te=new EventSource(G),te.onopen=()=>{D.current&&(de(),H("connected"))},te.onerror=()=>{D.current&&(ve(),te&&te.readyState===EventSource.CLOSED&&Re())},te.onmessage=_e,te.addEventListener("gone",ae))};return he(),()=>{if(de(),oe!=null&&(clearTimeout(oe),oe=null),te){try{te.removeEventListener("gone",ae)}catch{}try{te.close()}catch{}}}},[h,g,d,u,V]),p.useEffect(()=>{if(!g)return;const M=g.split(",");V(M)},[g,V]);const ie=p.useCallback(M=>{Da.dismiss(M)},[]);return{updates:m,updatesMap:v,updateCount:S,isRefreshing:E,lastFetchAt:N,error:A,refresh:L,updatesById:X,pushUpdateCount:J,status:U,dismiss:ie}}function mS(t){const a=[];for(const s of t){const o=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!o&&!c)continue;const u={};o&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const hS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function xS(t,a){switch(a.type){case"SELECT_SKILL":return{...t,selectedSkill:a.skill,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_SELECTION":return{...t,selectedSkill:null};case"SET_MODE":return{...t,mode:a.mode,selectedSkill:a.mode==="create"?null:t.selectedSkill};case"SET_SEARCH":return{...t,searchQuery:a.query};case"SET_SKILLS":return{...t,skills:a.skills,skillsLoading:!1,skillsError:null};case"SET_SKILLS_ERROR":return{...t,skillsError:a.error,skillsLoading:!1};case"SET_SKILLS_LOADING":return{...t,skillsLoading:a.loading};case"SET_MOBILE":return{...t,isMobile:a.isMobile};case"SET_MOBILE_VIEW":return{...t,mobileView:a.view};case"DISMISS_UPDATE_NOTIFICATION":return{...t,updateNotificationDismissed:!0};case"REVEAL_SKILL":return{...t,selectedSkill:a.skill,revealSkillId:`${a.skill.plugin}/${a.skill.skill}`,mode:"browse",mobileView:t.isMobile?"detail":t.mobileView};case"CLEAR_REVEAL":return{...t,revealSkillId:null};default:return t}}const Tv=p.createContext(null),Rv=Tv;function er(){const t=p.useContext(Rv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function gS({children:t}){const[a,s]=p.useReducer(xS,hS),o=nS("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:o})},[o]);const[c,u]=p.useState(()=>{try{const I=window.localStorage.getItem("vskill.studio.prefs");if(!I)return null;const V=JSON.parse(I);return typeof V.activeAgent=="string"?V.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function I(V){if(!(V instanceof CustomEvent))return;const ie=V.detail;ie!=null&&ie.agentId&&(u(ie.agentId),h(!0))}return window.addEventListener("studio:agent-changed",I),()=>window.removeEventListener("studio:agent-changed",I)},[]),p.useEffect(()=>{if(d)return;let I=!1;return Ce.getAgents().then(V=>{if(I)return;const ie=(V==null?void 0:V.suggested)??"claude-code";u(M=>M??ie),h(!0)}).catch(()=>{I||(u(V=>V??"claude-code"),h(!0))}),()=>{I=!0}},[d]);const g=p.useCallback(()=>{if(!d||!c)return;s({type:"SET_SKILLS_LOADING",loading:!0});const I={agent:c};Ce.getSkills(I).then(V=>{s({type:"SET_SKILLS",skills:V});const M=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(M){const[,Y,G]=M,te=V.find(fe=>fe.plugin===Y&&fe.skill===G);te&&s({type:"SELECT_SKILL",skill:{plugin:Y,skill:G,origin:te.origin}})}}).catch(V=>s({type:"SET_SKILLS_ERROR",error:V.message}))},[c,d]);p.useEffect(()=>{g()},[g]);const m=p.useCallback(I=>{s({type:"SELECT_SKILL",skill:I}),window.location.hash=`/skills/${I.plugin}/${I.skill}`},[]),y=p.useRef(a.skills);p.useEffect(()=>{y.current=a.skills},[a.skills]);const v=p.useCallback((I,V)=>{const ie=y.current,M=I?ie.find(te=>te.plugin===I&&te.skill===V):ie.find(te=>te.skill===V&&te.source!=="plugin");if(!I&&!M){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${V}" not yet in state — skipping reveal`);return}const Y=(M==null?void 0:M.plugin)??I,G=(M==null?void 0:M.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:Y,skill:V,origin:G}}),window.location.hash=`/skills/${Y}/${V}`},[]),b=p.useCallback(()=>{s({type:"CLEAR_REVEAL"})},[]),S=p.useCallback(()=>{s({type:"CLEAR_SELECTION"}),window.location.hash.startsWith("#/skills/")&&history.replaceState(null,"",window.location.pathname+window.location.search)},[]),k=p.useCallback(I=>{s({type:"SET_MODE",mode:I})},[]),E=p.useCallback(I=>{s({type:"SET_SEARCH",query:I})},[]),C=p.useCallback(I=>{s({type:"SET_MOBILE_VIEW",view:I})},[]),N=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=p.useRef(new Map),A=p.useRef(""),B=p.useRef(!1),[z,F]=p.useState(""),w=p.useMemo(()=>a.skills.map(I=>`${I.plugin}/${I.skill}`),[a.skills]),O=p.useMemo(()=>z?z.split(",").filter(Boolean):[],[z]),D=pS({skillIds:O,trackingSkillIds:w}),U=p.useRef("");p.useEffect(()=>{const I=a.skills.filter(G=>G.origin==="installed");if(I.length===0){F(""),U.current="";return}const V=new Map;for(const G of D.updates)V.set(G.name.split("/").pop()||G.name,G);const ie=I.map(G=>{const te=V.get(G.skill),fe=G.currentVersion??(te==null?void 0:te.installed)??G.version??G.pluginVersion??"0.0.0";return{plugin:G.plugin,skill:G.skill,name:(te==null?void 0:te.name)??G.skill,currentVersion:fe}}),M=ie.map(G=>`${G.plugin}/${G.skill}@${G.currentVersion}#${G.name}`).sort().join("|");if(M===U.current)return;U.current=M;let Y=!1;return Ce.resolveInstalledSkillIds(ie).then(G=>{if(Y)return;const oe=[...mS(G).flatMap(ve=>[ve.uuid,ve.slug].filter(Boolean))].sort().join(",");oe!==A.current&&(A.current=oe,T.current=new Map(G.map(ve=>[`${ve.plugin}/${ve.skill}`,{uuid:ve.uuid,slug:ve.slug}])),F(oe))}).catch(G=>{if(Y||(U.current=""),!B.current){B.current=!0;const te=G instanceof Error?G.message:String(G);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",te)}}),()=>{Y=!0}},[a.skills,D.updates]);const H=p.useMemo(()=>{const I=a.skills.map(V=>{if(!V.updateAvailable&&V.latestVersion===void 0&&V.trackedForUpdates===void 0)return V;const ie={...V};return delete ie.updateAvailable,delete ie.currentVersion,delete ie.latestVersion,delete ie.trackedForUpdates,ie});return tS(I,D.updates)},[a.skills,D.updates]),q=p.useMemo(()=>{const I={source:0,installed:0};for(const V of H)V.updateAvailable&&(I[V.origin]+=1);return I},[H]),X=p.useMemo(()=>({...a,skills:H}),[a,H]),J=D.updateCount,$=D.refresh,L=D.isRefreshing,_=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:k,setSearch:E,setMobileView:C,refreshSkills:g,updateCount:J,dismissUpdateNotification:N,updates:D.updates,outdatedByOrigin:q,isRefreshingUpdates:L,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:D.updatesById,pushUpdateCount:D.pushUpdateCount,updateStreamStatus:D.status,dismissPushUpdate:D.dismiss}),[X,m,S,k,E,C,g,J,N,D.updates,q,L,$,v,b,D.updatesById,D.pushUpdateCount,D.status,D.dismiss]);return r.jsx(Rv.Provider,{value:_,children:t})}const vS={config:null,loading:!0};function yS(t,a){switch(a.type){case"SET_CONFIG":return{config:a.config,loading:!1};case"SET_LOADING":return{...t,loading:!0};default:return t}}const Av=p.createContext(null);function $a(){const t=p.useContext(Av);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function bS({children:t}){const[a,s]=p.useReducer(yS,vS),o=p.useCallback(()=>{Ce.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{o()},[o]);const c=p.useCallback(async(d,h)=>{const g=await Ce.setConfig(d,h);return s({type:"SET_CONFIG",config:g}),g},[]),u=p.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:o}),[a,c,o]);return r.jsx(Av.Provider,{value:u,children:t})}function jS({topRail:t,sidebar:a,main:s,statusBar:o,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:g=!1}){const m={"--top-rail-height":"48px","--status-bar-height":"28px","--sidebar-width":`${h}px`,display:"grid",gridTemplateRows:"var(--top-rail-height) 1fr var(--status-bar-height)",height:"100vh",overflow:"hidden",background:"var(--bg-canvas)",color:"var(--text-primary)"},y={display:"grid",gridTemplateColumns:g?"1fr":"var(--sidebar-width) auto 1fr",minHeight:0,overflow:"hidden"};return r.jsxs("div",{className:"studio-shell",style:m,children:[u,r.jsx("header",{style:{borderBottom:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:t}),r.jsxs("div",{style:y,children:[!g&&r.jsx("aside",{"aria-label":"Skills sidebar",style:{minHeight:0,overflow:"hidden",borderRight:c?"none":"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",flexDirection:"column"},children:a}),!g&&c,r.jsx("main",{style:{minHeight:0,overflow:"auto",background:"var(--bg-canvas)"},children:s})]}),r.jsx("footer",{role:"contentinfo",style:{borderTop:"1px solid var(--border-default)",background:"var(--bg-canvas)",display:"flex",alignItems:"center",minHeight:0},children:o}),r.jsx("div",{"aria-live":"polite",role:"status",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0},children:d??""})]})}const Yx=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],SS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},kS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},wS={"claude-cli":"cli-install",anthropic:"api-key",openai:"api-key",openrouter:"api-key",cursor:"cli-install","codex-cli":"cli-install","gemini-cli":"cli-install",copilot:"cli-install",zed:"cli-install",ollama:"start-service","lm-studio":"start-service"},CS={"claude-cli":"subscription",anthropic:"per-token",openai:"per-token",openrouter:"per-token",cursor:"subscription","codex-cli":"subscription","gemini-cli":"subscription",copilot:"subscription",zed:"subscription",ollama:"free","lm-studio":"free"};function ES(t,a){var h,g;const s=SS[t.id]??null,o=kS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=o?!!((g=a==null?void 0:a.binaries)!=null&&g[o]):!0,d=t.models.map(m=>({id:m.id,displayName:m.label,billingMode:CS[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:NS(t.id,t.label),wrapperFolder:s,wrapperFolderPresent:c,binaryAvailable:u,endpointReachable:t.id==="ollama"||t.id==="lm-studio"?t.available:null,available:t.available,ctaType:t.available?null:wS[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function NS(t,a){return{"claude-cli":"Claude Code",anthropic:"Anthropic API",openai:"OpenAI API",openrouter:"OpenRouter",cursor:"Cursor","codex-cli":"Codex CLI","gemini-cli":"Gemini CLI",copilot:"GitHub Copilot",zed:"Zed",ollama:"Ollama","lm-studio":"LM Studio"}[t]??a}function TS(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of Yx){const c=a.get(o);c&&s.push(c)}for(const o of t)Yx.includes(o.id)||s.push(o);return s}function RS(t){const[a,s]=p.useState(null),[o,c]=p.useState("loading"),[u,d]=p.useState(null),[h,g]=p.useState(null),m=p.useRef(null),y=p.useRef(0),v=p.useRef(t==null?void 0:t.onStaleCatalog),b=p.useRef(t==null?void 0:t.onSetActiveError);p.useEffect(()=>{v.current=t==null?void 0:t.onStaleCatalog,b.current=t==null?void 0:t.onSetActiveError},[t==null?void 0:t.onStaleCatalog,t==null?void 0:t.onSetActiveError]);const S=p.useCallback(async()=>{try{const T=await fetch("/api/config");if(!T.ok)throw new Error(`/api/config returned ${T.status}`);const A=await T.json(),B=TS((A.providers||[]).map(z=>ES(z,A.detection)));s({agents:B,activeAgent:A.provider??null,activeModel:A.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);p.useEffect(()=>{S()},[S]);const k=p.useCallback(async()=>{var A;const T=Date.now();if(!(T-y.current<5*6e4))try{const B=await fetch("/api/openrouter/models");if(!B.ok){B.status!==400&&g(`OpenRouter catalog fetch failed (${B.status})`);return}const z=await B.json();y.current=T,g(null),s(O=>{if(!O)return O;const D=O.agents.map(U=>{if(U.id!=="openrouter")return U;const H=z.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...U,models:H,catalogAgeMs:z.ageSec?z.ageSec*1e3:0,cacheStale:!!z.stale}});return{...O,agents:D}});const F=z.ageSec??0;(z.stale===!0||F>600)&&((A=v.current)==null||A.call(v,"openrouter",F*1e3))}catch(B){g(`OpenRouter catalog unreachable: ${B.message}`)}},[]),E=p.useCallback(T=>{m.current=T,T==="openrouter"&&k()},[k]),C=p.useCallback(()=>{y.current=0,S()},[S]),N=p.useCallback(async(T,A)=>{var F,w;let B;try{B=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:A})})}catch(O){(F=b.current)==null||F.call(b,`Network error while setting ${T}: ${O.message}`);return}if(B.ok){s(O=>O&&{...O,activeAgent:T,activeModel:A});return}let z=`Failed to set ${T} (${B.status})`;try{const O=await B.json();O&&typeof O.error=="string"&&(z=O.error)}catch{}(w=b.current)==null||w.call(b,z)},[]);return{status:o,catalog:a,error:u,openRouterError:h,focusAgent:E,refresh:C,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function kd({variant:t,label:a,onActivate:s,installUrl:o,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&o){window.open(o,"_blank","noopener,noreferrer");return}s()}function d(h){(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),u(h))}return r.jsx("button",{type:"button","data-testid":`locked-cta-${t}`,onClick:u,onKeyDown:d,className:"inline-flex items-center gap-1.5 px-0 py-0 text-[11px] font-medium",style:{color:"var(--accent, var(--text-primary))",background:"transparent",border:"none",cursor:"pointer"},"aria-label":a,...c?{title:c}:{},children:a})}function Zd({unlocked:t=!1,size:a=10}){return t?r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 3.5"})]}):r.jsxs("svg",{width:a,height:a,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"3",y:"7",width:"10",height:"7",rx:"1"}),r.jsx("path",{d:"M5 7V4.5A3 3 0 0 1 11 4.5V7"})]})}const AS={sectionOwn:"Own",sectionInstalled:"Installed",searchPlaceholder:"Search skills",searchShortcutHint:"Press / to search",emptyOwnHeadline:"No skills yet.",emptyOwnBody:"Run vskill new <name> to create one.",emptyInstalledHeadline:"No installed skills.",emptyInstalledBody:"Run vskill install <skill> to add one.",emptyFilteredHeadline:"No matches in this section.",emptyFilteredBody:"Clear the search or try another query.",loadErrorHeadline:"Couldn't load skills.",loadErrorRetry:"Retry",duplicateBadge:"synced from Own",updateAvailableBadge:"Update available",countBadgeFiltered:(t,a)=>`${t} of ${a}`},MS={appTitle:"Skill Studio",commandPaletteButtonLabel:"Open command palette",commandPaletteHint:"⌘K",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},LS={tabOverview:"Overview",tabVersions:"Versions",tabBenchmark:"Benchmark",emptyHeadline:"Select a skill to see details.",emptyBody:"Pick one from the sidebar.",loadErrorHeadline:t=>`Couldn't load SKILL.md for ${t}.`,loadErrorBody:"Check the file path and your workspace permissions.",openInEditor:"Open in editor",copyPath:"Copy path",copyConfigSnippet:"Copy config snippet",depNotInstalledTooltip:"Not installed",missingValue:"—",announceViewingOwn:t=>`Viewing ${t} (Own)`,announceViewingInstalled:t=>`Viewing ${t} (Installed)`,moreFields:"More fields",sourceAgent:"Source agent",noMcpDependencies:"No MCP dependencies.",filesystemGroup:"Filesystem",benchmarkGroup:"Benchmark",metadataGroup:"Frontmatter"},zS={open:"Open",copyPath:"Copy Path",revealInEditor:"Reveal in Editor",edit:"Edit",duplicate:"Duplicate",runBenchmark:"Run Benchmark",update:"Update",uninstall:"Uninstall",retry:"Retry",editPlaceholder:"Edit lands with 0675. Open the file in your editor.",delete:"Delete",deletePluginTooltip:"Plugin skills are managed by their owning plugin — uninstall the plugin to remove.",undo:"Undo"},DS={inputPlaceholder:"Type a command or search",emptyResults:"No matches. Try a different query.",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",actionSelectSkill:"Select skill",actionRunBenchmark:"Run benchmark",actionSwitchTheme:"Switch theme",actionNewSkill:"New skill",closeLabel:"Close palette"},_S={title:"Keyboard shortcuts",closeLabel:"Close shortcuts",groupNavigation:"Navigation",groupActions:"Actions",groupTheme:"Theme",search:"Focus search",moveDown:"Move selection down",moveUp:"Move selection up",openSelected:"Open selected skill",openPalette:"Open command palette",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},OS={pathCopied:"Path copied.",configCopied:"Config copied.",skillDuplicated:"Skill duplicated.",benchmarkQueued:"Benchmark queued.",themeUpdated:"Theme updated.",skillUpdated:"Skill updated.",actionFailed:"Action failed. Retry or check logs.",networkError:"Network error. Check your connection.",permissionDenied:"Permission denied. Check file access.",unknownError:"Something went wrong. Retry or check logs."},BS={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},IS={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},US={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},HS={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",keyboardShortcut:"⌘K",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},$S={claudeCli:{name:"Claude Code",caption:"Delegates to the `claude` CLI — your existing Claude Code session handles quota.",missingBinary:"Claude Code not found. Install it: `npm install -g @anthropic-ai/claude-code`. Or choose a provider with an API key.",installCta:"Install Claude Code →",installUrl:"https://docs.claude.com/en/docs/claude-code"},anthropic:{name:"Anthropic API",caption:"Direct access via your Anthropic API key.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.claude.com/settings/keys",keyPrefix:"sk-ant-"},openai:{name:"OpenAI",caption:"GPT-4, GPT-5, and the o-series reasoning models.",addKeyCta:"Add API key →",keyIssuanceUrl:"https://platform.openai.com/api-keys",keyPrefix:"sk-",pastePlaceholder:"Paste OpenAI API key (sk-proj-...)"},openrouter:{name:"OpenRouter",caption:"300+ models from every major vendor.",addKeyCta:"Add API key →",emptyCardBody:"Add your OpenRouter API key to browse 300+ models",keyIssuanceUrl:"https://openrouter.ai/settings/keys",keyPrefix:"sk-or-"},cursor:{name:"Cursor",caption:"Cursor IDE composer.",installCta:"Install Cursor →"},codexCli:{name:"Codex CLI",caption:"OpenAI Codex CLI.",installCta:"Install Codex CLI →"},geminiCli:{name:"Gemini CLI",caption:"Google Gemini CLI.",installCta:"Install Gemini CLI →"},copilot:{name:"GitHub Copilot",caption:"GitHub Copilot CLI.",installCta:"Install Copilot →"},zed:{name:"Zed",caption:"Zed editor.",installCta:"Install Zed →"},ollama:{name:"Ollama",caption:"Local models, free.",startServiceCta:"Start service →"},lmStudio:{name:"LM Studio",caption:"Local models, free.",startServiceCta:"Start LM Studio server →",startServiceTooltip:"Open LM Studio → Developer tab → Start Server (default port 1234)."}},VS={subscriptionBilling:"· subscription",free:"· free"},PS={title:"Settings",sectionApiKeys:"API Keys",banner:"Keys are stored locally on this device only. Never synced, never committed to git, never transmitted off-device except to the provider's own API.",storagePath:t=>`Keys stored at ${t} · protected by file permissions (0600 on macOS/Linux)`,storagePathFallback:"Keys stored locally on this device.",copyPath:"Copy path",pathCopied:"Path copied.",show:"Show",hide:"Hide",paste:"Paste",save:"Save",remove:"Remove",removeConfirm:t=>`Remove ${t} API key?`,keyStoredAt:t=>`Key stored locally — updated ${t}`,noKey:"No key stored",enterNonEmpty:"Enter a non-empty key",prefixWarn:t=>`This doesn't look like a typical ${t} key. Save anyway?`,keySaved:t=>`${t} API key saved (local only, never synced)`,keyRemoved:t=>`${t} API key removed`},FS={providersLabel:"Providers",providerSummary:(t,a)=>`${t}/${a} providers`,locked:t=>`${t} — locked. Click to add a key.`,lockedCli:t=>`${t} — locked. Click for install instructions.`,unlocked:t=>`${t} — unlocked.`},GS={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsLastSync:"Last sync",statsHealthOk:"Fresh",statsHealthStale:"Updates available",statsHealthMissing:"Not detected",switchCta:"Switch for this studio session",notDetectedSubheading:"Not detected",setUpCta:t=>`Set up ${t}`,sharedFolderBanner:t=>`Shared folder — consumed by ${t}`},WS={ownLabel:"Own",installedLabel:"Installed",globalLabel:"Global",emptyOwn:"No authored skills — run vskill new.",emptyInstalled:t=>`No skills installed for ${t} in this project — run vskill install.`,emptyGlobal:t=>`No global skills for ${t} — run vskill install --global.`},qS={compactLabel:"Uses your Claude Code session · overflow billed at API rates",tooltip:"vSkill delegates to the `claude` CLI — your existing Claude Code session handles quota. If you've enabled extra usage in your account settings, excess runs at standard API rates. Run /usage in Claude Code or visit claude.com Settings → Usage to see remaining quota — vskill can't display it directly.",firstUseBanner:"Claude Code uses your existing session. No API key needed — vskill just runs the official claude binary on your behalf.",learnMore:"Learn more"},YS={title:t=>`Set up ${t}`,close:"Close",copy:"Copy",copied:"Copied",requiredEnv:"Required env vars",getKey:"Get a key",installRun:"Install & run",learnMore:"Learn more",fallbackTitle:"No setup guide available",fallbackBody:"We don't ship a setup guide for this provider yet."},KS={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},XS={anthropic:{name:"Anthropic API",description:"Direct API access to Claude via your Anthropic API key. Pay-per-token billing.",envVars:["ANTHROPIC_API_KEY"],keyUrl:"https://platform.claude.com/settings/keys",learnMoreUrl:"https://docs.claude.com/en/docs/get-started"},openai:{name:"OpenAI",description:"Access to GPT-4, GPT-5 and the o-series reasoning models via your OpenAI API key.",envVars:["OPENAI_API_KEY"],keyUrl:"https://platform.openai.com/api-keys",learnMoreUrl:"https://platform.openai.com/docs"},openrouter:{name:"OpenRouter",description:"One API key, 300+ models from Anthropic, OpenAI, Google, Meta, and more.",envVars:["OPENROUTER_API_KEY"],keyUrl:"https://openrouter.ai/keys",learnMoreUrl:"https://openrouter.ai/docs"},gemini:{name:"Gemini",description:"Google Gemini models (2.5 Pro, Flash) via Google AI Studio. Free tier available.",envVars:["GEMINI_API_KEY"],keyUrl:"https://aistudio.google.com/apikey",learnMoreUrl:"https://ai.google.dev/gemini-api/docs"},ollama:{name:"Ollama",description:"Local models on your own machine. Zero external calls, zero cost after download.",envVars:["OLLAMA_HOST"],installCmd:"curl -fsSL https://ollama.com/install.sh | sh",startCmd:"ollama serve",pullExample:"ollama pull llama3.2",learnMoreUrl:"https://ollama.com/download"},lmStudio:{name:"LM Studio",description:"Desktop app + local server for running open models with a GUI. Compatible with the OpenAI API.",envVars:["LM_STUDIO_BASE_URL"],installCmd:"Download from https://lmstudio.ai and launch the app, then start the local server.",startCmd:"# In LM Studio: Developer → Start Server (default port 1234)",pullExample:"# In LM Studio: Discover → download any GGUF model",learnMoreUrl:"https://lmstudio.ai/docs"},claudeCode:{name:"Claude Code",description:"No API key needed if you're logged into Claude Code. vskill just runs the official claude binary on your behalf — your existing Claude Code session handles quota.",loginHint:"If you're not logged in, run claude in your terminal and authenticate with your Anthropic account.",learnMoreUrl:"https://docs.claude.com/en/docs/claude-code"}},ne={sidebar:AS,shell:MS,detail:LS,actions:zS,palette:DS,shortcuts:_S,toasts:OS,connection:BS,forms:IS,errors:US,picker:HS,providers:$S,models:VS,settings:PS,statusBar:FS,scopePicker:GS,scopeSection:WS,claudeCodeLabel:qS,setupDrawer:YS,setupProviders:XS,scopeLabels:KS},QS=new Set(["claude-cli","claude-code"]);function Kx(t){return QS.has(t)}const Xx=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function ZS({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:o,onSelect:c,onOpenSettings:u}){const d=t.filter(g=>Xx.has(g.id)),h=t.filter(g=>!Xx.has(g.id));return r.jsxs("div",{role:"listbox","aria-label":"Agent","data-testid":"agent-list",style:{width:240,borderRight:"1px solid var(--border-default, var(--border-subtle))",display:"flex",flexDirection:"column",overflowY:"auto"},children:[d.map(g=>r.jsx(Qx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id)),h.length>0&&r.jsx("div",{style:{borderTop:"1px solid var(--border-default, var(--border-subtle))",margin:"4px 0"},"aria-hidden":"true"}),h.map(g=>r.jsx(Qx,{agent:g,isActive:g.id===a,isFocused:g.id===s,onFocus:o,onSelect:c,onOpenSettings:u},g.id))]})}function Qx({agent:t,isActive:a,isFocused:s,onFocus:o,onSelect:c,onOpenSettings:u}){const{providers:d}=ne,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},g={"claude-cli":{label:d.claudeCli.installCta,url:d.claudeCli.installUrl},cursor:{label:d.cursor.installCta},"codex-cli":{label:d.codexCli.installCta},"gemini-cli":{label:d.geminiCli.installCta},copilot:{label:d.copilot.installCta},zed:{label:d.zed.installCta}},m=Kx(t.id),y={minHeight:36,height:m?"auto":36,padding:m?"6px 12px":"0 12px",display:"flex",alignItems:"center",gap:8,cursor:"pointer",position:"relative",background:s?"var(--surface-muted, var(--surface-3))":"transparent",borderLeft:a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",fontSize:13,fontWeight:a?500:400,color:"var(--text-primary)"};return a&&(y.background="color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)"),r.jsxs("div",{role:"option","aria-selected":a,"data-testid":`agent-row-${t.id}`,"data-focused":s||void 0,tabIndex:s?0:-1,onMouseEnter:()=>o(t.id),onFocus:()=>o(t.id),onClick:()=>c(t.id),style:y,children:[t.wrapperFolder&&r.jsx("span",{"data-testid":`wrapper-dot-${t.id}`,"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",flexShrink:0,background:t.wrapperFolderPresent?"var(--accent, var(--color-accent))":"transparent",border:t.wrapperFolderPresent?"none":"1px solid var(--border-default, var(--border-subtle))"}}),!t.wrapperFolder&&r.jsx("span",{style:{width:6,height:6,flexShrink:0},"aria-hidden":"true"}),r.jsxs("span",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.displayName}),Kx(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:ne.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ne.claudeCodeLabel.compactLabel})]}),r.jsx("span",{"aria-label":t.available?"available":"locked",style:{color:t.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0},children:t.available?r.jsx(Zd,{unlocked:!0,size:10}):r.jsx(Zd,{size:10})}),a&&r.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.05em",fontWeight:600,color:"var(--accent-ink, var(--accent))",flexShrink:0},"data-testid":`active-badge-${t.id}`,children:ne.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(kd,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&g[t.id]&&r.jsx(kd,{variant:"cli-install",label:g[t.id].label,installUrl:g[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(kd,{variant:"start-service",label:t.id==="ollama"?d.ollama.startServiceCta:d.lmStudio.startServiceCta,onActivate:()=>u(t.id)}),h[t.id]&&r.jsx("span",{className:"sr-only","data-testid":`caption-${t.id}`,children:h[t.id]})]})}function JS(t,a,s,o){const d=t>=80,h=p.useRef(null),[g,m]=p.useState(0),y=p.useCallback(S=>{m(S.currentTarget.scrollTop)},[]),{visibleStart:v,visibleEnd:b}=p.useMemo(()=>{if(!d)return{visibleStart:0,visibleEnd:t};const S=Math.max(0,Math.floor(g/a)-4),k=Math.ceil(s/a)+8,E=Math.min(t,S+k);return{visibleStart:S,visibleEnd:E}},[d,g,a,s,t,4]);return{visibleStart:v,visibleEnd:b,totalHeight:t*a,offsetTop:v*a,virtualised:d,containerProps:{onScroll:y,ref:h,style:{overflowY:"auto",maxHeight:s,willChange:d?"transform":void 0}}}}const Mv=44,e2=352,t2=60,Zx=480;function n2(t){var u,d;const a=t.contextWindow?t.contextWindow>=1e6?`${Math.round(t.contextWindow/1e6)}M`:t.contextWindow>=1e3?`${Math.round(t.contextWindow/1e3)}k`:String(t.contextWindow):null;if(t.billingMode==="subscription")return a?`${a} ctx ${ne.models.subscriptionBilling}`:ne.models.subscriptionBilling.trim();if(t.billingMode==="free")return a?`local · ${a} ctx · free`:"local · free";const s=((u=t.pricing)==null?void 0:u.prompt)??0,o=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${o.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function r2(t,a){if(!a)return t;const s=a.toLowerCase();return t.filter(c=>c.displayName.toLowerCase().includes(s)).sort((c,u)=>{const d=c.displayName.toLowerCase().indexOf(s),h=u.displayName.toLowerCase().indexOf(s);return d!==h?d-h:c.displayName.length-u.displayName.length})}function a2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:o,onOpenSettings:c}){const[u,d]=p.useState(""),[h,g]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>g(u),t2);return()=>clearTimeout(b)},[u]),p.useEffect(()=>{t.id==="openrouter"&&t.available&&m.current&&m.current.focus()},[t.id,t.available]),t.id==="openrouter"&&!t.available)return r.jsxs("div",{"data-testid":"openrouter-empty-card",style:{width:Zx,padding:20,display:"flex",flexDirection:"column",gap:12},children:[r.jsx("p",{style:{margin:0,color:"var(--text-primary)",fontSize:13,lineHeight:1.5},children:ne.providers.openrouter.emptyCardBody}),r.jsx("button",{type:"button",onClick:()=>c("openrouter"),style:{alignSelf:"flex-start",padding:"6px 10px",borderRadius:6,background:"var(--accent, var(--color-accent))",color:"var(--bg-surface, white)",border:"none",fontSize:12,fontWeight:500,cursor:"pointer"},children:ne.providers.openrouter.addKeyCta})]});const y=p.useMemo(()=>r2(t.models,h),[t.models,h]),v=JS(y.length,Mv,e2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:Zx,display:"flex",flexDirection:"column"},children:[t.id==="openrouter"&&r.jsx("div",{style:{padding:8,borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:r.jsx("input",{ref:m,type:"text",placeholder:ne.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ne.picker.searchPlaceholder,style:{width:"100%",padding:"6px 8px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"}})}),y.length===0&&h?r.jsxs("div",{style:{padding:16},"data-testid":"no-matches",children:[r.jsx("div",{style:{color:"var(--text-muted, var(--text-tertiary))",fontSize:12,marginBottom:8},children:ne.picker.noMatches(h)}),r.jsx("button",{type:"button",onClick:()=>d(""),style:{padding:"4px 8px",background:"transparent",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:ne.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ne.picker.noModelsYet}):r.jsx("div",{...v.containerProps,children:r.jsx("div",{style:{height:v.virtualised?v.totalHeight:"auto",position:"relative"},children:r.jsx("div",{style:{transform:v.virtualised?`translateY(${v.offsetTop}px)`:void 0},children:y.slice(v.visibleStart,v.visibleEnd).map((b,S)=>{const k=v.visibleStart+S;return r.jsx(s2,{model:b,isActive:b.id===a,isFocused:s===k,onSelect:()=>o(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function l2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function s2({model:t,isActive:a,isFocused:s,onSelect:o,resolvedModel:c}){const u=n2(t),d=l2(t.id,c,t.resolvedId),h=d!==null,g=a?"color-mix(in srgb, var(--accent, var(--color-accent)) 10%, transparent)":s?"var(--surface-muted, var(--surface-3))":"transparent",m=a?"1px solid var(--accent, var(--color-accent))":"1px solid transparent";return r.jsxs("button",{type:"button",role:"option","aria-selected":a,"data-testid":`model-row-${t.id}`,"data-focused":s||void 0,onClick:o,title:t.id,style:{width:"100%",minHeight:Mv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:g,borderLeft:m,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",textAlign:"left"},children:[r.jsx("span",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("span",{style:{fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",fontVariantNumeric:"tabular-nums",color:"var(--text-muted, var(--text-tertiary))"},children:u}),h&&r.jsxs("span",{"data-testid":`model-row-${t.id}-resolved`,style:{fontSize:11,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace",color:"var(--text-muted, var(--text-tertiary))"},children:["routing to ",d]})]})}const Jx={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function i2(){const[t,a]=p.useState(null),[s,o]=p.useState(!0),[c,u]=p.useState(null),d=p.useCallback(async()=>{o(!0);try{const m=await fetch("/api/settings/keys");if(!m.ok)throw new Error(`GET /api/settings/keys returned ${m.status}`);const y=await m.json();a({...Jx,...y}),u(null)}catch(m){u(m.message),a(Jx)}finally{o(!1)}},[]);p.useEffect(()=>{d()},[d]);const h=p.useCallback(async(m,y)=>{const v=await fetch("/api/settings/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:m,key:y})});if(!v.ok){const S=await v.json().catch(()=>({error:v.statusText}));throw new Error(S.error||`POST /api/settings/keys returned ${v.status}`)}const b=await v.json();return await d(),b},[d]),g=p.useCallback(async m=>{const y=await fetch(`/api/settings/keys/${m}`,{method:"DELETE"});if(!y.ok)throw new Error(`DELETE /api/settings/keys/${m} returned ${y.status}`);await d()},[d]);return{state:t,loading:s,error:c,save:h,remove:g,refresh:d}}function o2({onMigrated:t,fetchImpl:a}){const[s,o]=p.useState({kind:"loading"}),c=a??globalThis.fetch,u=p.useCallback(async()=>{var m;try{const y=await c("/api/settings/migration-status");if(!y.ok){o({kind:"hidden"});return}const v=await y.json();v.pending&&(((m=v.darwinKeys)==null?void 0:m.length)??0)>0?o({kind:"visible",darwinKeys:v.darwinKeys??[]}):o({kind:"hidden"})}catch{o({kind:"hidden"})}},[c]);p.useEffect(()=>{u()},[u]);const d=p.useCallback(async()=>{o({kind:"working"});try{const m=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!m.ok){o({kind:"error",message:`Migration failed (${m.status})`});return}const y=await m.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(m){o({kind:"error",message:m.message})}},[c,u,t]),h=p.useCallback(async()=>{o({kind:"hidden"});try{await c("/api/settings/migration-acknowledge",{method:"POST",headers:{"Content-Type":"application/json"}})}catch{}},[c]);if(s.kind==="loading"||s.kind==="hidden")return null;if(s.kind==="error")return r.jsxs("div",{role:"status","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--danger, #b33) 15%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{style:{flex:1},children:s.message}),r.jsx("button",{type:"button",onClick:()=>void u(),"data-testid":"migration-retry",style:wd,children:"Retry"})]});const g=s.kind==="working";return r.jsxs("div",{role:"note","data-testid":"migration-banner",style:{padding:"10px 12px",borderRadius:6,background:"color-mix(in srgb, var(--accent, var(--color-accent)) 12%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:12,display:"flex",alignItems:"center",gap:8},children:[r.jsxs("div",{style:{flex:1},children:[r.jsx("strong",{style:{display:"block",marginBottom:2},children:"Migrate from macOS Keychain"}),r.jsx("span",{style:{color:"var(--text-muted, var(--text-tertiary))"},children:"We found stored credentials from a previous vskill version. Import them into the new on-disk store."})]}),r.jsx("button",{type:"button",onClick:()=>void d(),disabled:g,"data-testid":"migration-migrate",style:{...wd,background:"var(--accent, var(--color-accent))",color:"white",opacity:g?.6:1},children:g?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...wd,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const wd={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},c2=[{id:"anthropic",name:ne.providers.anthropic.name,keyIssuanceUrl:ne.providers.anthropic.keyIssuanceUrl,prefix:ne.providers.anthropic.keyPrefix,placeholder:`Paste ${ne.providers.anthropic.name} key`},{id:"openai",name:ne.providers.openai.name,keyIssuanceUrl:ne.providers.openai.keyIssuanceUrl,prefix:ne.providers.openai.keyPrefix,placeholder:ne.providers.openai.pastePlaceholder},{id:"openrouter",name:ne.providers.openrouter.name,keyIssuanceUrl:ne.providers.openrouter.keyIssuanceUrl,prefix:ne.providers.openrouter.keyPrefix,placeholder:`Paste ${ne.providers.openrouter.name} key`}];function u2(t){const a=Date.now()-new Date(t).getTime();return a<6e4?"just now":a<36e5?`${Math.round(a/6e4)}m ago`:a<864e5?`${Math.round(a/36e5)}h ago`:new Date(t).toLocaleString()}function Lv({open:t,onClose:a,initialProvider:s,onToast:o}){const{state:c,save:u,remove:d,refresh:h}=i2(),g=p.useRef(null),m=p.useRef(null),[y,v]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const k=await fetch("/api/settings/storage-path");if(!k.ok)throw new Error(`GET /api/settings/storage-path returned ${k.status}`);const E=await k.json();S||v(E.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,k=setTimeout(()=>{var N;const E=s?`input[data-provider="${s}"]`:"input[data-provider]",C=(N=g.current)==null?void 0:N.querySelector(E);C==null||C.focus()},0);return()=>{var E;clearTimeout(k),(E=S==null?void 0:S.focus)==null||E.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=k=>{if(k.key==="Escape"){k.preventDefault(),a();return}if(k.key==="Tab"&&g.current){const E=g.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(E.length===0)return;const C=E[0],N=E[E.length-1];k.shiftKey&&document.activeElement===C?(k.preventDefault(),N.focus()):!k.shiftKey&&document.activeElement===N&&(k.preventDefault(),C.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=p.useCallback(async()=>{var S,k;if(y)try{await((k=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:k.call(S,y)),o==null||o(ne.settings.pathCopied)}catch{}},[o,y]);return t?r.jsx("div",{role:"dialog","aria-modal":"true","aria-labelledby":"settings-modal-title","data-testid":"settings-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, black 40%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},onClick:S=>{S.target===S.currentTarget&&a()},children:r.jsxs("div",{ref:g,style:{background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,width:560,maxHeight:"80vh",overflowY:"auto",padding:20,fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif",color:"var(--text-primary)"},onClick:S=>S.stopPropagation(),children:[r.jsx("h2",{id:"settings-modal-title",style:{margin:"0 0 16px 0",fontSize:16,fontWeight:600},children:ne.settings.title}),r.jsx(o2,{onMigrated:()=>{h()}}),r.jsx("div",{role:"note","data-testid":"settings-banner",style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--info, var(--accent-muted)) 20%, transparent)",color:"var(--text-primary)",fontSize:12,marginBottom:16},children:ne.settings.banner}),r.jsxs("section",{"aria-labelledby":"settings-api-keys-title",style:{marginBottom:20},children:[r.jsx("h3",{id:"settings-api-keys-title",style:{fontSize:13,fontWeight:600,margin:"0 0 12px 0"},children:ne.settings.sectionApiKeys}),c2.map(S=>r.jsx(d2,{providerId:S.id,providerName:S.name,keyIssuanceUrl:S.keyIssuanceUrl,prefix:S.prefix,placeholder:S.placeholder,metadata:c==null?void 0:c[S.id],onSave:async k=>{const E=await u(S.id,k);return o==null||o(ne.settings.keySaved(S.name)),E},onRemove:async()=>{await d(S.id),o==null||o(ne.settings.keyRemoved(S.name))},inputRef:S.id===(s??"anthropic")?m:void 0},S.id))]}),r.jsxs("div",{"data-testid":"settings-storage-path",style:{fontSize:11,color:"var(--text-muted, var(--text-tertiary))",fontStyle:"italic",display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[r.jsx("span",{style:{flex:1},children:y?ne.settings.storagePath(y):ne.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Oa,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ne.settings.copyPath})]}),r.jsx("div",{style:{marginTop:20,display:"flex",justifyContent:"flex-end"},children:r.jsx("button",{type:"button",onClick:a,style:{padding:"6px 12px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},children:"Close"})})]})}):null}function d2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:o,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:g}){const[m,y]=p.useState(""),[v,b]=p.useState(!1),[S,k]=p.useState(!1),[E,C]=p.useState(!1),[N,T]=p.useState(null),A=m.trim(),B=A.length===0,z=A.length>0&&!A.startsWith(o),F=p.useCallback(async()=>{if(B)return;k(!0);const D=A;y("");try{const U=await d(D);U.warning?T(U.warning):T(null)}finally{k(!1)}},[B,d,A]),w=p.useCallback(async()=>{var D;try{if(!((D=navigator.clipboard)!=null&&D.readText))return;const U=await navigator.clipboard.readText();y(U)}catch{}},[]),O=p.useCallback(async()=>{C(!1),await h()},[h]);return r.jsxs("div",{"data-testid":`provider-row-${t}`,style:{padding:12,border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:8,display:"flex",flexDirection:"column",gap:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[r.jsx("strong",{style:{fontSize:13},children:a}),r.jsx("a",{href:s,target:"_blank",rel:"noopener noreferrer",style:{fontSize:12,color:"var(--accent, var(--color-accent))"},children:"Get a key →"})]}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{ref:g,type:v?"text":"password",value:m,onChange:D=>{y(D.target.value),T(null)},"data-provider":t,placeholder:c,style:{flex:1,padding:"6px 8px",border:"1px solid var(--border-subtle)",borderRadius:4,background:"var(--surface-2, var(--bg-surface))",color:"var(--text-primary)",fontSize:12,fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"}}),r.jsx("button",{type:"button",onClick:()=>b(!v),style:Oa,children:v?ne.settings.hide:ne.settings.show}),r.jsx("button",{type:"button",onClick:w,style:Oa,children:ne.settings.paste})]}),z&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:eg,children:ne.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:eg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:F,disabled:B||S,"data-testid":`save-${t}`,style:{...Oa,background:B?"var(--surface-2)":"var(--accent, var(--color-accent))",color:B?"var(--text-muted)":"white",cursor:B?"not-allowed":"pointer"},children:ne.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:E?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ne.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Oa,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>C(!1),style:Oa,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>C(!0),"data-testid":`remove-${t}`,style:{...Oa,color:"var(--text-muted)"},children:ne.settings.remove})}),r.jsx("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},"data-testid":`status-${t}`,children:u!=null&&u.stored&&u.updatedAt?ne.settings.keyStoredAt(u2(u.updatedAt)):ne.settings.noKey})]})]})}const Oa={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},eg={fontSize:11,color:"var(--warning, var(--text-muted))"};function f2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function p2({onToast:t}){const{status:a,catalog:s,focusAgent:o,setActive:c}=RS({onStaleCatalog:(U,H)=>{const q=Math.round(H/6e4);t==null||t(`Using cached ${U} catalog (${q} min old)`)},onSetActiveError:U=>t==null?void 0:t(U)}),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[m,y]=p.useState(),[v,b]=p.useState(null),[S,k]=p.useState("agents"),[E,C]=p.useState(0),N=p.useRef(null);p.useRef(null),p.useEffect(()=>{var U;s&&!v&&b(s.activeAgent??((U=s.agents[0])==null?void 0:U.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],A=p.useMemo(()=>T.find(U=>U.id===v)??T[0],[T,v]);p.useEffect(()=>{C(0)},[v]);const B=p.useCallback(()=>{var U;d(!0),k("agents"),b((s==null?void 0:s.activeAgent)??((U=T[0])==null?void 0:U.id)??null),C(0)},[s,T]),z=p.useCallback(()=>{var U;d(!1),(U=N.current)==null||U.focus()},[]);p.useEffect(()=>{const U=H=>{var X;if(!(H.metaKey||H.ctrlKey)||H.key.toLowerCase()!=="k")return;const q=(X=document.activeElement)==null?void 0:X.tagName;q==="INPUT"||q==="TEXTAREA"||(H.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[]),p.useEffect(()=>{if(!u)return;const U=q=>{if(q.key==="Escape"){q.preventDefault(),z();return}if(q.key==="ArrowDown"){q.preventDefault(),H(1);return}if(q.key==="ArrowUp"){q.preventDefault(),H(-1);return}if(q.key==="ArrowRight"&&S==="agents"){q.preventDefault(),k("models"),C(X=>{const J=((A==null?void 0:A.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(q.key==="ArrowLeft"&&S==="models"){q.preventDefault(),k("agents");return}if(q.key==="Enter"){if(q.preventDefault(),S==="agents"&&A)k("models"),C(0);else if(S==="models"&&A){const X=Math.max(0,Math.min(A.models.length-1,E)),J=A.models[X];J&&(c(A.id,J.id),z())}return}};function H(q){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+q))];J&&(b(J.id),o(J.id));return}if(S==="models"&&A){const X=A.models.length;if(X===0)return;C(J=>{const $=J+q;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[u,S,T,v,A,E,z,o,c]);const F=p.useCallback(U=>{y(U==="anthropic"||U==="openrouter"?U:void 0),g(!0),d(!1)},[]),w=T.find(U=>U.id===(s==null?void 0:s.activeAgent)),O=w==null?void 0:w.models.find(U=>U.id===(s==null?void 0:s.activeModel)),D=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const U=(w==null?void 0:w.displayName)??"Agent",H=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${U} · ${H}`},[a,s,w,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?z():B(),"aria-haspopup":"listbox","aria-expanded":u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"6px 10px",background:"var(--surface-2, var(--bg-surface))",border:"1px solid var(--border-subtle)",borderRadius:6,color:"var(--text-primary)",fontSize:12,cursor:"pointer",fontFamily:"'Inter Tight Variable', 'Inter Tight', system-ui, sans-serif"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:w!=null&&w.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:D})]}),u&&typeof document<"u"&&Go.createPortal(r.jsxs(m2,{reducedMotion:f2(),onClickOutside:z,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(ZS,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:U=>{b(U),o(U)},onSelect:U=>{b(U),o(U),k("models")},onOpenSettings:F}),A&&r.jsx(a2,{agent:A,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?E:-1,onSelect:U=>{c(A.id,U),z()},onOpenSettings:F})]}),r.jsxs("div",{style:{height:32,borderTop:"1px solid var(--border-default, var(--border-subtle))",padding:"0 12px",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:11,color:"var(--text-muted, var(--text-tertiary))"},children:[r.jsx("button",{type:"button",onClick:()=>F(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ne.picker.footerHint})]})]}),document.body),r.jsx(Lv,{open:h,onClose:()=>g(!1),initialProvider:m,onToast:t})]})}function m2({children:t,reducedMotion:a,onClickOutside:s}){const o=p.useRef(null);return p.useEffect(()=>{const c=u=>{o.current&&!o.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:o,"data-testid":"agent-model-picker-popover",role:"dialog","aria-label":"Select agent and model",style:{position:"fixed",top:56,left:"50%",transform:"translateX(-50%)",width:720,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,overflow:"hidden",zIndex:90,animation:a?void 0:"agentPickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[t,r.jsx("style",{children:`@keyframes agentPickerFadeIn {
63
+ from { opacity: 0; transform: translateX(-50%) translateY(2px); }
64
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
65
+ }`})]})}function tg(){typeof window>"u"||(window.location.hash="#/")}function h2({onHome:t}){const[a,s]=p.useState(!1),[o,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),tg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),tg(),t==null||t())};return r.jsxs("a",{href:"#/",role:"link","data-testid":"studio-logo","aria-label":"Skill Studio — home",onClick:u,onKeyDown:d,onFocus:()=>s(!0),onBlur:()=>s(!1),onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),style:{display:"inline-flex",alignItems:"center",gap:10,flexShrink:0,padding:"4px 6px",margin:"-4px -6px",borderRadius:6,textDecoration:"none",color:"inherit",cursor:"pointer",outline:a?"2px solid var(--border-focus)":"none",outlineOffset:2,background:o?"color-mix(in srgb, var(--text-primary) 4%, transparent)":"transparent",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,background:"color-mix(in srgb, var(--accent-surface) 20%, transparent)"},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent-surface)",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"22 12 18 12 15 21 9 3 6 12 2 12"})})}),r.jsx("span",{style:{fontSize:13,fontWeight:600,letterSpacing:"-0.01em",color:"var(--text-primary)"},children:"Skill Studio"})]})}const ng=p.memo(function({message:a,politeness:s="polite",role:o}){const c=o??(s==="assertive"?"alert":"status");return r.jsx("div",{"aria-live":s,"aria-atomic":"true",role:c,"data-testid":"aria-live","data-politeness":s,style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap",border:0,padding:0,margin:-1},children:a})});function x2({toast:t,onDismiss:a}){const[s,o]=p.useState(!0),c=p.useRef(null);p.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>o(!1))}),()=>{c.current!=null&&cancelAnimationFrame(c.current)}),[]);const u={success:"var(--status-installed)",info:"var(--text-secondary)",error:"var(--color-accent, var(--accent-surface))"};return r.jsxs("div",{role:t.severity==="error"?"alert":"status","data-testid":"toast-item","data-severity":t.severity,style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",minWidth:240,maxWidth:360,background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderLeft:`3px solid ${u[t.severity]}`,borderRadius:6,boxShadow:"0 8px 24px rgba(0,0,0,0.12)",fontFamily:"var(--font-sans)",fontSize:12,transform:s?"translateY(8px)":"translateY(0)",opacity:s?0:1,transition:"transform var(--duration-base, 180ms) var(--ease-standard, ease), opacity var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{style:{flex:1,minWidth:0},children:t.message}),t.action&&r.jsx("button",{type:"button",onClick:()=>{t.action.onInvoke(),a(t.id)},style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"3px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:t.action.label}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:()=>a(t.id),style:{background:"transparent",border:"none",padding:2,color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1},children:"×"})]})}function g2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:o}){return r.jsxs(r.Fragment,{children:[r.jsx(ng,{politeness:"polite",message:s}),r.jsx(ng,{politeness:"assertive",message:o}),t.length>0&&r.jsx("div",{"data-testid":"toast-stack",style:{position:"fixed",right:16,bottom:16,display:"flex",flexDirection:"column-reverse",gap:8,zIndex:50,pointerEvents:"none"},children:t.map(c=>r.jsx("div",{style:{pointerEvents:"auto"},children:r.jsx(x2,{toast:c,onDismiss:a})},c.id))})]})}const zv=p.createContext(null);function Wo(){const t=p.useContext(zv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function v2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[o,c]=p.useState([]),[u,d]=p.useState(""),[h,g]=p.useState(""),m=p.useRef(new Map),y=p.useCallback(C=>{const N=m.current.get(C);N&&(clearTimeout(N),m.current.delete(C)),c(T=>T.filter(A=>A.id!==C))},[]),v=p.useCallback((C,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(C)},N);m.current.set(C,T)},[y]),b=p.useCallback(C=>{const N=C.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:C.message,severity:C.severity??"info",durationMs:C.durationMs??s,action:C.action};return c(A=>[...A,T]),T.severity==="error"?g(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=p.useCallback(()=>{for(const C of m.current.values())clearTimeout(C);m.current.clear(),c([])},[]);p.useEffect(()=>{function C(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const A=T.slice(0,a),B=A[A.length-1],z=m.current.get(B.id);return z&&(clearTimeout(z),m.current.delete(B.id)),T.filter(F=>F.id!==B.id)})}return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[a]),p.useEffect(()=>()=>{for(const C of m.current.values())clearTimeout(C);m.current.clear()},[]);const k=o.slice(0,a),E=p.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(zv.Provider,{value:E,children:[t,r.jsx(g2,{toasts:k,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}const y2="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='1.75'%20stroke-linecap='round'%20stroke-linejoin='round'%20aria-hidden='true'%20focusable='false'%3e%3cpath%20d='M5.5%2017h11l-1.2-1.8a2%202%200%200%201-.3-1.1V10a4%204%200%201%200-8%200v4.1a2%202%200%200%201-.3%201.1L5.5%2017Z'%20/%3e%3cpath%20d='M10%2020a2%202%200%200%200%204%200'%20/%3e%3ccircle%20cx='17'%20cy='7'%20r='2.2'%20fill='currentColor'%20stroke='none'%20/%3e%3c/svg%3e",b2=p.lazy(()=>Ha(()=>import("./UpdateDropdown-O8YGQyMH.js"),__vite__mapDeps([0,1])));function j2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:o,selectSkill:c,revealSkill:u,skills:d,updatesById:h}=er(),{toast:g}=Wo(),m=p.useMemo(()=>{if(!h||h.size===0)return;const N=new Map;for(const[T,A]of h)A.diffSummary&&N.set(T,A.diffSummary);return N.size>0?N:void 0},[h]),[y,v]=p.useState(!1),b=p.useRef(null),S=p.useCallback(()=>v(!1),[]),k=t>0?"var(--text-primary)":"var(--text-secondary)",E=t>9?"9+":String(t),C=t===0?"No updates available":`${t} updates available, open summary`;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:b,type:"button","data-testid":"update-bell","aria-label":C,"aria-haspopup":"dialog","aria-expanded":y,onClick:()=>v(N=>!N),style:{position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",height:26,width:26,padding:0,borderRadius:4,border:"1px solid transparent",background:"transparent",color:k,cursor:"pointer"},children:[r.jsx("img",{src:y2,alt:"",width:18,height:18,style:{display:"block",opacity:t>0?1:.75}}),t>0&&r.jsx("span",{"data-testid":"update-bell-badge","aria-hidden":"true",style:{position:"absolute",top:-2,right:-2,minWidth:14,height:14,padding:"0 3px",borderRadius:999,background:"var(--color-own)",color:"var(--color-paper)",fontSize:9,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",display:"inline-flex",alignItems:"center",justifyContent:"center",fontWeight:600,lineHeight:1},children:E})]}),y&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(b2,{updates:a,isRefreshing:s,diffSummariesById:m,onRefresh:()=>o(),onSelectSkill:N=>{const T=N.localSkill??N.name.split("/").pop()??"",A=N.localPlugin??"";if(u)u(A,T);else{const z=N.name.split("/"),F=z.length>=2?z[z.length-2]:z[0];c({plugin:F,skill:T,origin:"installed"})}if(!(d??[]).some(z=>z.skill===T&&(A===""||z.plugin===A))){const z=N.installLocations&&N.installLocations.length>0?N.installLocations[0].agentLabel:null;z&&g({severity:"info",message:`Skill installed under ${z} — switch to ${z} to view details.`})}S()},onViewAll:()=>{window.location.hash="#/updates",S()},onClose:S,anchorRef:b})})]})}function rg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function S2({projectName:t,selected:a,onOpenPalette:s,onHome:o,projectPickerSlot:c,onRequestCreateSkill:u,findSkillsSlot:d}){const h=a?a.origin==="installed"?"Project":"Skills":null;return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,height:"100%",width:"100%",padding:"0 16px",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexShrink:0},children:[r.jsx(h2,{onHome:o}),c?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:c}):t&&r.jsx("span",{title:t,style:{fontSize:12,color:"var(--text-secondary)",borderLeft:"1px solid var(--border-default)",paddingLeft:10,maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t})]}),r.jsx("nav",{"aria-label":"Breadcrumb",style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:6,fontSize:12,color:"var(--text-secondary)"},children:a&&h&&r.jsxs(r.Fragment,{children:[r.jsx(ag,{segment:"origin",onClick:()=>rg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:h}),r.jsx(lg,{}),r.jsx(ag,{segment:"plugin",onClick:()=>rg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(lg,{}),r.jsx("span",{"data-breadcrumb-segment":"skill","aria-current":"page",style:{color:"var(--text-primary)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a.skill})]})}),r.jsxs("div",{"data-toprail-right":"true",style:{display:"flex",alignItems:"center",gap:8,flexShrink:0},children:[d,u&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:u,"aria-label":"Create a new skill",title:"Create a new skill",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--color-action, #2F5B8E)",background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",fontSize:12,fontWeight:600,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"New Skill"]}),r.jsx("span",{"data-slot":"agent-model-picker",style:{minWidth:200},children:r.jsx(p2,{})}),r.jsx("span",{"data-slot":"update-bell",style:{display:"inline-flex"},children:r.jsx(j2,{})}),r.jsx("button",{type:"button",onClick:s,"aria-label":"Open command palette",title:"Command palette (⌘K)",style:{display:"inline-flex",alignItems:"center",gap:6,height:26,padding:"0 10px",borderRadius:4,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono)",cursor:"pointer"},children:r.jsx("span",{children:"⌘K"})})]})]})}function ag({segment:t,onClick:a,style:s,children:o}){return r.jsx("button",{type:"button","data-breadcrumb-segment":t,onClick:a,style:{background:"transparent",border:"none",padding:0,cursor:"pointer",color:"var(--text-secondary)",fontFamily:"inherit",...s},onMouseEnter:c=>{c.currentTarget.style.color="var(--color-accent-ink)"},onMouseLeave:c=>{const u=(s==null?void 0:s.color)??"var(--text-secondary)";c.currentTarget.style.color=u},children:o})}function lg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const qo="vskill-theme";function Dv(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function k2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function w2(t){try{const a=t.getItem(qo);return Dv(a)}catch{return"auto"}}function C2(t,a){try{t.setItem(qo,a)}catch{}}function E2(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function N2(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const _v=p.createContext(null);function T2({storage:t,matchMedia:a,target:s,children:o}){const c=t??(typeof window<"u"?window.localStorage:void 0),u=a??(typeof window<"u"?window.matchMedia.bind(window):void 0),d=s??(typeof document<"u"?document.documentElement:void 0),[h,g]=p.useState(()=>c?w2(c):"auto"),[m,y]=p.useState(()=>N2(u)),v=p.useMemo(()=>k2(h,m),[h,m]);p.useEffect(()=>{d&&E2(d,h,v)},[d,h,v]),p.useEffect(()=>{if(!u)return;const k=u("(prefers-color-scheme: dark)"),E=N=>y(N.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",E),()=>k.removeEventListener("change",E);const C=k;return C.addListener(E),()=>C.removeListener(E)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const k=E=>{E.key===qo&&g(Dv(E.newValue))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),p.useEffect(()=>{if(!u||!d)return;let k;try{k=u("(prefers-contrast: more)")}catch{return}const E=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};E(k.matches);const C=T=>E(T.matches);if(typeof k.addEventListener=="function")return k.addEventListener("change",C),()=>k.removeEventListener("change",C);const N=k;return N.addListener(C),()=>N.removeListener(C)},[u,d]);const b=p.useCallback(k=>{g(k),c&&C2(c,k)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(_v.Provider,{value:S,children:o})}function Ov(){const t=p.useContext(_v);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const sg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function R2(t){const a=new Map(t.map(o=>[o.id,o])),s=[];for(const o of sg){const c=a.get(o);c&&s.push(c)}for(const o of t)sg.includes(o.id)||s.push(o);return s}function A2(t){const[a,s]=p.useState(()=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(`(max-width: ${t}px)`).matches);return p.useEffect(()=>{var u;if(typeof window>"u"||!window.matchMedia)return;const o=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(o.matches);return(u=o.addEventListener)==null||u.call(o,"change",c),()=>{var d;return(d=o.removeEventListener)==null?void 0:d.call(o,"change",c)}},[t]),a}function M2({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const o=R2(t),c=A2(640),[u,d]=p.useState(!1),h=p.useCallback(g=>{g.available||g.kind==="api-key"?a==null||a(g.id):s==null||s(g.id)},[a,s]);if(c){const g=o.filter(m=>m.available).length;return r.jsxs("div",{"data-testid":"providers-segment",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"providers-summary",onClick:()=>d(!u),"aria-label":ne.statusBar.providerSummary(g,o.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ne.statusBar.providerSummary(g,o.length)}),u&&r.jsx("div",{role:"menu",style:{position:"absolute",bottom:"120%",right:0,background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:6,padding:6,minWidth:180,display:"flex",flexDirection:"column",gap:2,zIndex:80},children:o.map(m=>r.jsx(ig,{p:m,onClick:h},m.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:o.map(g=>r.jsx(ig,{p:g,onClick:h,compact:!0},g.id))})}function ig({p:t,onClick:a,compact:s}){const o=t.available?ne.statusBar.unlocked(t.label):t.kind==="cli-install"?ne.statusBar.lockedCli(t.label):ne.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":o,title:o,onClick:()=>a(t),style:{display:"inline-flex",alignItems:"center",gap:4,background:"transparent",border:"none",color:t.available?"var(--status-installed)":"var(--text-muted, var(--text-tertiary))",cursor:"pointer",padding:s?"2px":"4px 6px",fontSize:11},children:[r.jsx(Zd,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function L2(){try{return typeof localStorage>"u"?null:localStorage.getItem(qo)}catch{return null}}function z2({projectPath:t,modelName:a,health:s="ok",onPathClick:o,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:g,setTheme:m}=Ov(),v=L2()==="auto",b=D2(h,g,v),S=s==="down"||s==="degraded"?"var(--status-own)":"var(--status-installed)";return r.jsxs("div",{role:"contentinfo",style:{display:"flex",alignItems:"center",gap:12,height:"100%",width:"100%",padding:"0 12px",fontSize:11,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[r.jsx("span",{title:a??"",style:{fontFamily:"var(--font-mono)"},children:a??"—"}),r.jsx(og,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(_2,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(og,{}),r.jsx(M2,{providers:c,onOpenSettings:u,onOpenInstallHelp:d})]}),r.jsx("div",{style:{flex:1}}),r.jsxs("button",{type:"button","data-testid":"theme-toggle",onClick:()=>m(b),"aria-label":`Switch to ${b} theme`,title:`Theme: ${h} — click for ${b}`,style:{display:"inline-flex",alignItems:"center",gap:6,background:"transparent",border:"1px solid var(--border-default)",padding:"2px 8px",borderRadius:4,color:"var(--text-secondary)",cursor:"pointer",fontSize:11,height:20},children:[r.jsx(O2,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function D2(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function _2({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function og(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function O2({mode:t}){return t==="dark"?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}):t==="light"?r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"4"}),r.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"M12 3a9 9 0 0 0 0 18z",fill:"currentColor"})]})}const Jd=new Set;function Bv(){for(const t of Jd)t()}const B2=5,I2=1e3,U2=6e4;function H2(){const[t,a]=p.useState(void 0),[s,o]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),g=p.useRef(null),m=p.useRef(!0),y=p.useRef(0),[v,b]=p.useState(0),S=()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},k=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),E=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;k();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!m.current)return;const A=await T.json();if(!m.current)return;d.current=0,a(A.plugins??[]),u(!1),o(!1),g.current=setTimeout(()=>{m.current&&b(B=>B+1)},U2)}catch(T){if(!m.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>B2){o(!0);return}const A=I2*Math.pow(2,d.current-1);g.current=setTimeout(()=>{m.current&&b(B=>B+1)},A)}},[k]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),k()}),[k]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),E())},[v,E]),p.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),k()):(d.current=0,o(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[k]);const C=p.useCallback(()=>{d.current=0,o(!1),S(),y.current+=1,b(N=>N+1)},[]);return p.useEffect(()=>(Jd.add(C),()=>{Jd.delete(C)}),[C]),{plugins:t,paused:s,loading:c,retry:C}}const Yo=0,ca=1,Bl=2,Iv=4;function cg(t){return()=>t}function $2(t){t()}function Uv(t,a){return s=>t(a(s))}function ug(t,a){return()=>t(a)}function V2(t,a){return s=>t(a,s)}function jf(t){return t!==void 0}function P2(...t){return()=>{t.map($2)}}function Il(){}function Ko(t,a){return a(t),t}function F2(t,a){return a(t)}function St(...t){return t}function at(t,a){return t(ca,a)}function Fe(t,a){t(Yo,a)}function Sf(t){t(Bl)}function Ct(t){return t(Iv)}function Te(t,a){return at(t,V2(a,Yo))}function Qn(t,a){const s=t(ca,o=>{s(),a(o)});return s}function dg(t){let a,s;return o=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{o(a)},t)}}function Hv(t,a){return t===a}function jt(t=Hv){let a;return s=>o=>{t(a,o)||(a=o,s(o))}}function De(t){return a=>s=>{t(s)&&a(s)}}function ke(t){return a=>Uv(a,t)}function ir(t){return a=>()=>{a(t)}}function me(t,...a){const s=G2(...a);return((o,c)=>{switch(o){case Bl:Sf(t);return;case ca:return at(t,s(c))}})}function or(t,a){return s=>o=>{s(a=t(a,o))}}function Ua(t){return a=>s=>{t>0?t--:a(s)}}function Ar(t){let a=null,s;return o=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,o(a)},t))}}function Ge(...t){const a=new Array(t.length);let s=0,o=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{const m=s;s|=h,a[d]=g,m!==c&&s===c&&o&&(o(),o=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():o=h}}function G2(...t){return a=>t.reduceRight(F2,a)}function W2(t){let a,s;const o=()=>a==null?void 0:a();return function(c,u){switch(c){case ca:return u?s===u?void 0:(o(),s=u,a=at(t,u),a):(o(),Il);case Bl:o(),s=null;return}}}function ge(t){let a=t;const s=Qe();return((o,c)=>{switch(o){case Yo:a=c;break;case ca:{c(a);break}case Iv:return a}return s(o,c)})}function an(t,a){return Ko(ge(a),s=>Te(t,s))}function Qe(){const t=[];return((a,s)=>{switch(a){case Yo:t.slice().forEach(o=>{o(s)});return;case Bl:t.splice(0,t.length);return;case ca:return t.push(s),()=>{const o=t.indexOf(s);o>-1&&t.splice(o,1)}}})}function Nn(t){return Ko(Qe(),a=>Te(t,a))}function tt(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:q2(),singleton:s}}const q2=()=>Symbol();function Y2(t){const a=new Map,s=({constructor:o,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=o(c.map(g=>s(g)));return d&&a.set(u,h),h};return s(t)}function Ht(...t){const a=Qe(),s=new Array(t.length);let o=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;at(u,g=>{s[d]=g,o|=h,o===c&&Fe(a,s)})}),function(u,d){switch(u){case Bl:{Sf(a);return}case ca:return o===c&&d(s),at(a,d)}}}function ze(t,a=Hv){return me(t,jt(a))}function ef(...t){return function(a,s){switch(a){case Bl:return;case ca:return P2(...t.map(o=>at(o,s)))}}}const Ft={DEBUG:0,INFO:1,WARN:2,ERROR:3},K2={[Ft.DEBUG]:"debug",[Ft.ERROR]:"error",[Ft.INFO]:"log",[Ft.WARN]:"warn"},X2=()=>typeof globalThis>"u"?window:globalThis,ua=tt(()=>{const t=ge(Ft.ERROR);return{log:ge((a,s,o=Ft.INFO)=>{const c=X2().VIRTUOSO_LOG_LEVEL??Ct(t);o>=c&&console[K2[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Va(t,a,s){return kf(t,a,s).callbackRef}function kf(t,a,s){const o=Ne.useRef(null);let c=d=>{};const u=Ne.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const g=d[0].target;g.offsetParent!==null&&t(g)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),o.current=d):(o.current&&(u==null||u.unobserve(o.current)),o.current=null)},{callbackRef:c,ref:o}}function Q2(t,a,s,o,c,u,d,h,g){const m=Ne.useCallback(y=>{const v=Z2(y.children,a,h?"offsetWidth":"offsetHeight",c);let b=y.parentElement;for(;b.dataset.virtuosoScroller===void 0;)b=b.parentElement;const S=b.lastElementChild.dataset.viewportType==="window";let k;S&&(k=b.ownerDocument.defaultView);const E=d?h?d.scrollLeft:d.scrollTop:S?h?k.scrollX||k.document.documentElement.scrollLeft:k.scrollY||k.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,C=d?h?d.scrollWidth:d.scrollHeight:S?h?k.document.documentElement.scrollWidth:k.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?k.innerWidth:k.innerHeight:h?b.offsetWidth:b.offsetHeight;o({scrollHeight:C,scrollTop:Math.max(E,0),viewportHeight:N}),u==null||u(h?fg("column-gap",getComputedStyle(y).columnGap,c):fg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,o,h]);return kf(m,s,g)}function Z2(t,a,s,o){const c=t.length;if(c===0)return null;const u=[];for(let d=0;d<c;d++){const h=t.item(d);if(h.dataset.index===void 0)continue;const g=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&o("Zero-sized element, this should not happen",{child:h},Ft.ERROR),y===m)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==g-1?u.push({endIndex:g,size:y,startIndex:g}):u[u.length-1].endIndex++}return u}function fg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Ft.WARN),a==="normal"?0:parseInt(a??"0",10)}function $v(t,a,s){const o=Ne.useRef(null),c=Ne.useCallback(g=>{if(!(g!=null&&g.offsetParent))return;const m=g.getBoundingClientRect(),y=m.width;let v,b;if(a){const S=a.getBoundingClientRect(),k=m.top-S.top;b=S.height-Math.max(0,k),v=k+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),v=m.top+S.scrollY}o.current={listHeight:m.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(o.current)},[t,a]),{callbackRef:u,ref:d}=kf(c,!0,s),h=Ne.useCallback(()=>{c(d.current)},[c,d]);return Ne.useEffect(()=>{var m;if(a){a.addEventListener("scroll",h);const y=new ResizeObserver(()=>{requestAnimationFrame(h)});return y.observe(a),()=>{a.removeEventListener("scroll",h),y.unobserve(a)}}const g=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return g==null||g.addEventListener("scroll",h),g==null||g.addEventListener("resize",h),()=>{g==null||g.removeEventListener("scroll",h),g==null||g.removeEventListener("resize",h)}},[h,a,d]),u}const dn=tt(()=>{const t=Qe(),a=Qe(),s=ge(0),o=Qe(),c=ge(0),u=Qe(),d=Qe(),h=ge(0),g=ge(0),m=ge(0),y=ge(0),v=Qe(),b=Qe(),S=ge(!1),k=ge(!1),E=ge(!1);return Te(me(t,ke(({scrollTop:C})=>C)),a),Te(me(t,ke(({scrollHeight:C})=>C)),d),Te(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:g,footerHeight:y,headerHeight:h,horizontalDirection:k,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:E,smoothScrollTargetReached:o,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Fs={lvl:0};function Vv(t,a){const s=t.length;if(s===0)return[];let{index:o,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:g}=a(t[d]);u.push({end:h-1,start:o,value:c}),o=h,c=g}return u.push({end:1/0,start:o,value:c}),u}function pt(t){return t===Fs}function Gs(t,a){if(!pt(t))return a===t.k?t.v:a<t.k?Gs(t.l,a):Gs(t.r,a)}function Jn(t,a,s="k"){if(pt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const o=Jn(t.r,a,s);return o[0]===-1/0?[t.k,t.v]:o}return Jn(t.l,a,s)}function En(t,a,s){return pt(t)?Gv(a,s,1):a===t.k?Pt(t,{k:a,v:s}):a<t.k?pg(Pt(t,{l:En(t.l,a,s)})):pg(Pt(t,{r:En(t.r,a,s)}))}function Ml(){return Fs}function Ll(t,a,s){if(pt(t))return[];const o=Jn(t,a)[0];return J2(nf(t,o,s))}function tf(t,a){if(pt(t))return Fs;const{k:s,l:o,r:c}=t;if(a===s){if(pt(o))return c;if(pt(c))return o;const[u,d]=Fv(o);return Mo(Pt(t,{k:u,l:Pv(o),v:d}))}return a<s?Mo(Pt(t,{l:tf(o,a)})):Mo(Pt(t,{r:tf(c,a)}))}function Ia(t){return pt(t)?[]:[...Ia(t.l),{k:t.k,v:t.v},...Ia(t.r)]}function nf(t,a,s){if(pt(t))return[];const{k:o,l:c,r:u,v:d}=t;let h=[];return o>a&&(h=h.concat(nf(c,a,s))),o>=a&&o<=s&&h.push({k:o,v:d}),o<=s&&(h=h.concat(nf(u,a,s))),h}function Mo(t){const{l:a,lvl:s,r:o}=t;if(o.lvl>=s-1&&a.lvl>=s-1)return t;if(s>o.lvl+1){if(Cd(a))return Wv(Pt(t,{lvl:s-1}));if(!pt(a)&&!pt(a.r))return Pt(a.r,{l:Pt(a,{r:a.r.l}),lvl:s,r:Pt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(Cd(t))return rf(Pt(t,{lvl:s-1}));if(!pt(o)&&!pt(o.l)){const c=o.l,u=Cd(c)?o.lvl-1:o.lvl;return Pt(c,{l:Pt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:rf(Pt(o,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Pt(t,a){return Gv(a.k!==void 0?a.k:t.k,a.v!==void 0?a.v:t.v,a.lvl!==void 0?a.lvl:t.lvl,a.l!==void 0?a.l:t.l,a.r!==void 0?a.r:t.r)}function Pv(t){return pt(t.r)?t.l:Mo(Pt(t,{r:Pv(t.r)}))}function Cd(t){return pt(t)||t.lvl>t.r.lvl}function Fv(t){return pt(t.r)?[t.k,t.v]:Fv(t.r)}function Gv(t,a,s,o=Fs,c=Fs){return{k:t,l:o,lvl:s,r:c,v:a}}function pg(t){return rf(Wv(t))}function Wv(t){const{l:a}=t;return!pt(a)&&a.lvl===t.lvl?Pt(a,{r:Pt(t,{l:a.r})}):t}function rf(t){const{lvl:a,r:s}=t;return!pt(s)&&!pt(s.r)&&s.lvl===a&&s.r.lvl===a?Pt(s,{l:Pt(t,{r:s.l}),lvl:a+1}):t}function J2(t){return Vv(t,({k:a,v:s})=>({index:a,value:s}))}function qv(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Ws(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const wf=tt(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function Yv(t,a,s){return t[Bo(t,a,s)]}function Bo(t,a,s,o=0){let c=t.length-1;for(;o<=c;){const u=Math.floor((o+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-o<2)return u-1;c=u-1}else{if(c===o)return u;o=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function ek(t,a,s,o){const c=Bo(t,a,o),u=Bo(t,s,o,c);return t.slice(c,u+1)}function ia(t,a){return Math.round(t.getBoundingClientRect()[a])}function Xo(t){return!pt(t.groupOffsetTree)}function Cf({index:t},a){return a===t?0:a<t?-1:1}function tk(){return{groupIndices:[],groupOffsetTree:Ml(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ml()}}function nk(t,a){let s=pt(t)?0:1/0;for(const o of a){const{endIndex:c,size:u,startIndex:d}=o;if(s=Math.min(s,d),pt(t)){t=En(t,0,u);continue}const h=Ll(t,d-1,c+1);if(h.some(ck(o)))continue;let g=!1,m=!1;for(const{end:y,start:v,value:b}of h)g?(c>=v||u===b)&&(t=tf(t,v)):(m=b!==u,g=!0),y>c&&c>=v&&b!==u&&(t=En(t,c+1,b));m&&(t=En(t,d,u))}return[t,s]}function rk(t){return typeof t.groupIndex<"u"}function ak({offset:t},a){return a===t?0:a<t?-1:1}function qs(t,a,s){if(a.length===0)return 0;const{index:o,offset:c,size:u}=Yv(a,t,Cf),d=t-o,h=u*d+(d-1)*s+c;return h>0?h+s:h}function Kv(t,a){if(!Xo(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function Xv(t,a,s){if(rk(t))return a.groupIndices[t.groupIndex]+1;const o=t.index==="LAST"?s:t.index;let c=Kv(o,a);return c=Math.max(0,c,Math.min(s,c)),c}function lk(t,a,s,o=0){return o>0&&(a=Math.max(a,Yv(t,o,Cf).offset)),Vv(ek(t,a,s,ak),ok)}function sk(t,[a,s,o,c]){a.length>0&&o("received item sizes",a,Ft.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&pt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((k,E)=>En(En(k,E,b),E+1,S),d)}else[d,h]=nk(d,a);if(d===u)return t;const{lastIndex:g,lastOffset:m,lastSize:y,offsetTree:v}=af(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>En(b,S,qs(S,v,c)),Ml()),lastIndex:g,lastOffset:m,lastSize:y,offsetTree:v,sizeTree:d}}function ik(t){return Ia(t).map(({k:a,v:s},o,c)=>{const u=c[o+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function mg(t,a){let s=0,o=0;for(;s<t;)s+=a[o+1]-a[o]-1,o++;return o-(s===t?0:1)}function af(t,a,s,o){let c=t,u=0,d=0,h=0,g=0;if(a!==0){g=Bo(c,a-1,Cf),h=c[g].offset;const m=Jn(s,a-1);u=m[0],d=m[1],c.length&&c[g].size===Jn(s,a)[1]&&(g-=1),c=c.slice(0,g+1)}else c=[];for(const{start:m,value:y}of Ll(s,a,1/0)){const v=m-u,b=v*d+h+v*o;c.push({index:m,offset:b,size:y}),u=m,h=b,d=y}return{lastIndex:u,lastOffset:h,lastSize:d,offsetTree:c}}function ok(t){return{index:t.index,value:t}}function ck(t){const{endIndex:a,size:s,startIndex:o}=t;return c=>c.start===o&&(c.end===a||c.end===1/0)&&c.value===s}const uk={offsetHeight:"height",offsetWidth:"width"},ur=tt(([{log:t},{recalcInProgress:a}])=>{const s=Qe(),o=Qe(),c=an(o,0),u=Qe(),d=Qe(),h=ge(0),g=ge([]),m=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),S=ge((w,O)=>ia(w,uk[O])),k=ge(void 0),E=ge(0),C=tk(),N=an(me(s,Ge(g,t,E),or(sk,C),jt()),C),T=an(me(g,jt(),or((w,O)=>({current:O,prev:w.current}),{current:[],prev:[]}),ke(({prev:w})=>w)),[]);Te(me(g,De(w=>w.length>0),Ge(N,E),ke(([w,O,D])=>{const U=w.reduce((H,q,X)=>En(H,q,qs(q,O.offsetTree,D)||X),Ml());return{...O,groupIndices:w,groupOffsetTree:U}})),N),Te(me(o,Ge(N),De(([w,{lastIndex:O}])=>w<O),ke(([w,{lastIndex:O,lastSize:D}])=>[{endIndex:O,size:D,startIndex:w}])),s),Te(m,y);const A=an(me(m,ke(w=>w===void 0)),!0);Te(me(y,De(w=>w!==void 0&&pt(Ct(N).sizeTree)),ke(w=>{const O=Ct(v),D=Ct(g).length>0;return O!==void 0&&O!==0?D?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:w,startIndex:1}]:[]:[{endIndex:0,size:w,startIndex:0}]})),s),Te(me(b,De(w=>w!==void 0&&w.length>0&&pt(Ct(N).sizeTree)),ke(w=>{const O=[];let D=w[0],U=0;for(let H=1;H<w.length;H++){const q=w[H];q!==D&&(O.push({endIndex:H-1,size:D,startIndex:U}),D=q,U=H)}return O.push({endIndex:w.length-1,size:D,startIndex:U}),O})),s),Te(me(g,Ge(v,y),De(([,w,O])=>w!==void 0&&O!==void 0),ke(([w,O,D])=>{const U=[];for(let H=0;H<w.length;H++){const q=w[H],X=w[H+1];U.push({startIndex:q,endIndex:q,size:O}),X!==void 0&&U.push({startIndex:q+1,endIndex:X-1,size:D})}return U})),s);const B=Nn(me(s,Ge(N),or(({sizes:w},[O,D])=>({changed:D!==w,sizes:D}),{changed:!1,sizes:C}),ke(w=>w.changed)));at(me(h,or((w,O)=>({diff:w.prev-O,prev:O}),{diff:0,prev:0}),ke(w=>w.diff)),w=>{const{groupIndices:O}=Ct(N);if(w>0)Fe(a,!0),Fe(u,w+mg(w,O));else if(w<0){const D=Ct(T);D.length>0&&(w-=mg(-w,D)),Fe(d,w)}}),at(me(h,Ge(t)),([w,O])=>{w<0&&O("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:h},Ft.ERROR)});const z=Nn(u);Te(me(u,Ge(N),ke(([w,O])=>{const D=O.groupIndices.length>0,U=[],H=O.lastSize;if(D){const q=Gs(O.sizeTree,0);let X=0,J=0;for(;X<w;){const L=O.groupIndices[J],_=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-L-1;U.push({endIndex:L,size:q,startIndex:L}),U.push({endIndex:L+1+_-1,size:H,startIndex:L+1}),J++,X+=_+1}const $=Ia(O.sizeTree);return X!==w&&$.shift(),$.reduce((L,{k:_,v:I})=>{let V=L.ranges;return L.prevSize!==0&&(V=[...L.ranges,{endIndex:_+w-1,size:L.prevSize,startIndex:L.prevIndex}]),{prevIndex:_+w,prevSize:I,ranges:V}},{prevIndex:w,prevSize:0,ranges:U}).ranges}return Ia(O.sizeTree).reduce((q,{k:X,v:J})=>({prevIndex:X+w,prevSize:J,ranges:[...q.ranges,{endIndex:X+w-1,size:q.prevSize,startIndex:q.prevIndex}]}),{prevIndex:0,prevSize:H,ranges:[]}).ranges})),s);const F=Nn(me(d,Ge(N,E),ke(([w,{offsetTree:O},D])=>{const U=-w;return qs(U,O,D)})));return Te(me(d,Ge(N,E),ke(([w,O,D])=>{if(O.groupIndices.length>0){if(pt(O.sizeTree))return O;let H=Ml();const q=Ct(T);let X=0,J=0,$=0;for(;X<-w;){$=q[J];const L=q[J+1]-$-1;J++,X+=L+1}if(H=Ia(O.sizeTree).reduce((L,{k:_,v:I})=>En(L,Math.max(0,_+w),I),H),X!==-w){const L=Gs(O.sizeTree,$);H=En(H,0,L);const _=Jn(O.sizeTree,-w+1)[1];H=En(H,1,_)}return{...O,sizeTree:H,...af(O.offsetTree,0,H,D)}}const U=Ia(O.sizeTree).reduce((H,{k:q,v:X})=>En(H,Math.max(0,q+w),X),Ml());return{...O,sizeTree:U,...af(O.offsetTree,0,U,D)}})),N),{beforeUnshiftWith:z,data:k,defaultItemSize:y,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:v,gap:E,groupIndices:g,heightEstimates:b,itemSize:S,listRefresh:B,shiftWith:d,shiftWithOffset:F,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:o,trackItemSizes:A,unshiftWith:u}},St(ua,wf),{singleton:!0});function dk(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const Qv=tt(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:o,scrollTop:c}])=>{const u=Qe(),d=Qe(),h=Nn(me(u,ke(dk)));return Te(me(h,ke(g=>g.totalCount)),s),Te(me(h,ke(g=>g.groupIndices)),t),Te(me(Ht(c,a,o),De(([g,m])=>Xo(m)),ke(([g,m,y])=>Jn(m.groupOffsetTree,Math.max(g-y,0),"v")[0]),jt(),ke(g=>[g])),d),{groupCounts:u,topItemsIndexes:d}},St(ur,dn)),da=tt(([{log:t}])=>{const a=ge(!1),s=Nn(me(a,De(o=>o),jt()));return at(a,o=>{o&&Ct(t)("props updated",{},Ft.DEBUG)}),{didMount:s,propsReady:a}},St(ua),{singleton:!0}),fk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Zv(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!fk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const Js=tt(([{gap:t,listRefresh:a,sizes:s,totalCount:o},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:g,scrollTo:m,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=Qe(),k=Qe(),E=ge(0);let C=null,N=null,T=null;function A(){C!==null&&(C(),C=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),Fe(g,!1)}return Te(me(S,Ge(s,v,o,E,h,d,b),Ge(t,u,c),ke(([[B,z,F,w,O,D,U,H],q,X,J])=>{const $=Zv(B),{align:L,behavior:_,offset:I}=$,V=w-1,ie=Xv($,z,V);let M=qs(ie,z.offsetTree,q)+D;L==="end"?(M+=X+Jn(z.sizeTree,ie)[1]-F+J,ie===V&&(M+=U)):L==="center"?M+=(X+Jn(z.sizeTree,ie)[1]-F+J)/2:M-=O,I!==void 0&&I!==0&&(M+=I);const Y=G=>{A(),G?(H("retrying to scroll to",{location:B},Ft.DEBUG),Fe(S,B)):(Fe(k,!0),H("list did not change, scroll successful",{},Ft.DEBUG))};if(A(),_==="smooth"){let G=!1;T=at(a,te=>{G=G||te}),C=Qn(y,()=>{Y(G)})}else C=Qn(me(a,pk(150)),Y);return N=setTimeout(()=>{A()},1200),Fe(g,!0),H("scrolling from index to",{behavior:_,index:ie,top:M},Ft.DEBUG),{behavior:_,top:M}})),m),{scrollTargetReached:k,scrollToIndex:S,topListHeight:E}},St(ur,dn,ua),{singleton:!0});function pk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return o=>{o&&(a(!0),clearTimeout(s))}}}function Ef(t,a){t===0?a():requestAnimationFrame(()=>{Ef(t-1,a)})}function Nf(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const ei=tt(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:o},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),g=ge(0),m=ge(!0);return Te(me(d,Ge(g),De(([y,v])=>v!==0),ir(!1)),h),Te(me(d,Ge(g),De(([y,v])=>v!==0),ir(!1)),m),at(me(Ht(a,d),Ge(h,s,t,m),De(([[,y],v,{sizeTree:b},S,k])=>y&&(!pt(b)||jf(S))&&!v&&!k),Ge(g)),([,y])=>{Qn(c,()=>{Fe(m,!0)}),Ef(4,()=>{Qn(o,()=>{Fe(h,!0)}),Fe(u,y)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:g,scrolledToInitialItem:h}},St(ur,dn,Js,da),{singleton:!0});function Jv(t,a){return Math.abs(t-a)<1.01}const Ys="up",Hs="down",mk="none",hk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},xk=0,ti=tt(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:o,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),g=Qe(),m=Qe(),y=ge(4),v=ge(xk),b=an(me(ef(me(ze(c),Ua(1),ir(!0)),me(ze(c),Ua(1),ir(!1),dg(100))),jt()),!1),S=an(me(ef(me(s,ir(!0)),me(s,ir(!1),dg(200))),jt()),!1);Te(me(Ht(ze(c),ze(v)),ke(([T,A])=>T<=A),jt()),h),Te(me(h,Ar(50)),m);const k=Nn(me(Ht(o,ze(u),ze(a),ze(t),ze(y)),or((T,[{scrollHeight:A,scrollTop:B},z,F,w,O])=>{const D=B+z-A>-O,U={scrollHeight:A,scrollTop:B,viewportHeight:z};if(D){let q,X;return B>T.state.scrollTop?(q="SCROLLED_DOWN",X=T.state.scrollTop-B):(q="SIZE_DECREASED",X=T.state.scrollTop-B||T.scrollTopDelta),{atBottom:!0,atBottomBecause:q,scrollTopDelta:X,state:U}}let H;return U.scrollHeight>T.state.scrollHeight?H="SIZE_INCREASED":z<T.state.viewportHeight?H="VIEWPORT_HEIGHT_DECREASING":B<T.state.scrollTop?H="SCROLLING_UPWARDS":H="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:H,state:U}},hk),jt((T,A)=>T!==void 0&&T.atBottom===A.atBottom))),E=an(me(o,or((T,{scrollHeight:A,scrollTop:B,viewportHeight:z})=>{if(!Jv(T.scrollHeight,A)){const F=A-(B+z)<1;return T.scrollTop!==B&&F?{changed:!0,jump:T.scrollTop-B,scrollHeight:A,scrollTop:B}:{changed:!0,jump:0,scrollHeight:A,scrollTop:B}}return{changed:!1,jump:0,scrollHeight:A,scrollTop:B}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),De(T=>T.changed),ke(T=>T.jump)),0);Te(me(k,ke(T=>T.atBottom)),d),Te(me(d,Ar(50)),g);const C=ge(Hs);Te(me(o,ke(({scrollTop:T})=>T),jt(),or((T,A)=>Ct(S)?{direction:T.direction,prevScrollTop:A}:{direction:A<T.prevScrollTop?Ys:Hs,prevScrollTop:A},{direction:Hs,prevScrollTop:0}),ke(T=>T.direction)),C),Te(me(o,Ar(50),ir(mk)),C);const N=ge(0);return Te(me(b,De(T=>!T),ir(0)),N),Te(me(c,Ar(100),Ge(b),De(([T,A])=>A),or(([T,A],[B])=>[A,B],[0,0]),ke(([T,A])=>A-T)),N),{atBottomState:k,atBottomStateChange:g,atBottomThreshold:y,atTopStateChange:m,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:E,scrollDirection:C,scrollVelocity:N}},St(dn)),Ks="top",Xs="bottom",hg="none";function xg(t,a,s){return typeof t=="number"?s===Ys&&a===Ks||s===Hs&&a===Xs?t:0:s===Ys?a===Ks?t.main:t.reverse:a===Xs?t.main:t.reverse}function gg(t,a){return typeof t=="number"?t:t[a]??0}const Tf=tt(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:o,viewportHeight:c}])=>{const u=Qe(),d=ge(0),h=ge(0),g=ge(0),m=an(me(Ht(ze(o),ze(c),ze(s),ze(u,Ws),ze(g),ze(d),ze(a),ze(t),ze(h)),ke(([y,v,b,[S,k],E,C,N,T,A])=>{const B=y-T,z=C+N,F=Math.max(b-B,0);let w=hg;const O=gg(A,Ks),D=gg(A,Xs);return S-=T,S+=b+N,k+=b+N,k-=T,S>y+z-O&&(w=Ys),k<y-F+v+D&&(w=Hs),w!==hg?[Math.max(B-b-xg(E,Ks,w)-O,0),B-F-N+v+xg(E,Xs,w)+D]:null}),De(y=>y!==null),jt(Ws)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:g,topListHeight:d,visibleRange:m}},St(dn),{singleton:!0});function gk(t,a,s){if(Xo(a)){const o=Kv(t,a);return[{index:Jn(a.groupOffsetTree,o)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:o,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const Ed={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Lo(t,a,s,o,c,u){const{lastIndex:d,lastOffset:h,lastSize:g}=c;let m=0,y=0;if(t.length>0){m=t[0].offset;const E=t[t.length-1];y=E.offset+E.size}const v=s-d,b=h+v*g+(v-1)*o,S=m,k=b-y;return{bottom:y,firstItemIndex:u,items:vg(t,c,u),offsetBottom:k,offsetTop:m,top:S,topItems:vg(a,c,u),topListHeight:a.reduce((E,C)=>C.size+E,0),totalCount:s}}function ey(t,a,s,o,c,u){let d=0;if(s.groupIndices.length>0)for(const y of s.groupIndices){if(y-d>=t)break;d++}const h=t+d,g=Nf(a,h),m=Array.from({length:h}).map((y,v)=>({data:u[v+g],index:v+g,offset:0,size:0}));return Lo(m,[],h,c,s,o)}function vg(t,a,s){if(t.length===0)return[];if(!Xo(a))return t.map(m=>({...m,index:m.index+s,originalIndex:m.index}));const o=t[0].index,c=t[t.length-1].index,u=[],d=Ll(a.groupOffsetTree,o,c);let h,g=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),g=a.groupIndices.indexOf(h.start));let y;m.index===h.start?y={index:g,type:"group"}:y={groupIndex:g,index:m.index-(g+1)+s},u.push({...y,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function yg(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Pa=tt(([{data:t,firstItemIndex:a,gap:s,sizes:o,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:g},{initialTopMostItemIndex:m,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:k}])=>{const E=ge([]),C=ge(0),N=Qe(),T=ge(0);Te(u.topItemsIndexes,E);const A=an(me(Ht(S,k,ze(g,Ws),ze(c),ze(o),ze(m),y,ze(E),ze(a),ze(s),ze(T),t),De(([w,O,,D,,,,,,,,U])=>{const H=U!==void 0&&U.length!==D;return w&&!O&&!H}),ke(([,,[w,O],D,U,H,q,X,J,$,L,_])=>{var je,Re;const I=U,{offsetTree:V,sizeTree:ie}=I,M=Ct(C);if(D===0)return{...Ed,totalCount:D};if(w===0&&O===0)return M===0?{...Ed,totalCount:D}:ey(M,H,U,J,$,_||[]);if(pt(ie))return M>0?null:Lo(gk(Nf(H,D),I,_),[],D,$,I,J);const Y=[];if(X.length>0){const _e=X[0],ae=X[X.length-1];let he=0;for(const pe of Ll(ie,_e,ae)){const xe=pe.value,be=Math.max(pe.start,_e),Be=Math.min(pe.end,ae);for(let Oe=be;Oe<=Be;Oe++)Y.push({data:_==null?void 0:_[Oe],index:Oe,offset:he,size:xe}),he+=xe}}if(!q)return Lo([],Y,D,$,I,J);const G=X.length>0?X[X.length-1]+1:0,te=lk(V,w,O,G);if(te.length===0)return null;const fe=D-1,oe=Ko([],_e=>{for(const ae of te){const he=ae.value;let pe=he.offset,xe=ae.start;const be=he.size;if(he.offset<w){xe+=Math.floor((w-he.offset+$)/(be+$));const Oe=xe-ae.start;pe+=Oe*be+Oe*$}xe<G&&(pe+=(G-xe)*be,xe=G);const Be=Math.min(ae.end,fe);for(let Oe=xe;Oe<=Be&&!(pe>=O);Oe++)_e.push({data:_==null?void 0:_[Oe],index:Oe,offset:pe,size:be}),pe+=be+$}}),ve=yg(L,Ks),de=yg(L,Xs);if(oe.length>0&&(ve>0||de>0)){const _e=oe[0],ae=oe[oe.length-1];if(ve>0&&_e.index>G){const he=Math.min(ve,_e.index-G),pe=[];let xe=_e.offset;for(let be=_e.index-1;be>=_e.index-he;be--){const Be=((je=Ll(ie,be,be)[0])==null?void 0:je.value)??_e.size;xe-=Be+$,pe.unshift({data:_==null?void 0:_[be],index:be,offset:xe,size:Be})}oe.unshift(...pe)}if(de>0&&ae.index<fe){const he=Math.min(de,fe-ae.index);let pe=ae.offset+ae.size+$;for(let xe=ae.index+1;xe<=ae.index+he;xe++){const be=((Re=Ll(ie,xe,xe)[0])==null?void 0:Re.value)??ae.size;oe.push({data:_==null?void 0:_[xe],index:xe,offset:pe,size:be}),pe+=be+$}}}return Lo(oe,Y,D,$,I,J)}),De(w=>w!==null),jt()),Ed);Te(me(t,De(jf),ke(w=>w==null?void 0:w.length)),c),Te(me(A,ke(w=>w.topListHeight)),v),Te(v,h),Te(me(A,ke(w=>[w.top,w.bottom])),d),Te(me(A,ke(w=>w.items)),N);const B=Nn(me(A,De(({items:w})=>w.length>0),Ge(c,t),De(([{items:w},O])=>w[w.length-1].originalIndex===O-1),ke(([,w,O])=>[w-1,O]),jt(Ws),ke(([w])=>w))),z=Nn(me(A,Ar(200),De(({items:w,topItems:O})=>w.length>0&&w[0].originalIndex===O.length),ke(({items:w})=>w[0].index),jt())),F=Nn(me(A,De(({items:w})=>w.length>0),ke(({items:w})=>{let O=0,D=w.length-1;for(;w[O].type==="group"&&O<D;)O++;for(;w[D].type==="group"&&D>O;)D--;return{endIndex:w[D].index,startIndex:w[O].index}}),jt(qv)));return{endReached:B,initialItemCount:C,itemsRendered:N,listState:A,minOverscanItemCount:T,rangeChanged:F,startReached:z,topItemsIndexes:E,...b}},St(ur,Qv,Tf,ei,Js,ti,da,wf),{singleton:!0}),ty=tt(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:o},{listState:c}])=>{const u=Qe(),d=an(me(Ht(s,t,o,a,c),ke(([h,g,m,y,v])=>h+g+m+y+v.offsetBottom+v.bottom)),0);return Te(ze(d),u),{totalListHeight:d,totalListHeightChanged:u}},St(dn,Pa),{singleton:!0}),vk=tt(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),o=an(me(Ht(s,t,a),De(([c])=>c),ke(([,c,u])=>Math.max(0,c-u)),Ar(0),jt()),0);return{alignToBottom:s,paddingTopAddition:o}},St(dn,ty),{singleton:!0}),ny=tt(()=>({context:ge(null)})),yk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:o,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...o!==void 0?{behavior:o}:{}}:t>u?{...c,align:s??"end",...o!==void 0?{behavior:o}:{}}:null,ry=tt(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:g},{scrollToIndex:m}])=>{const y=Qe();return Te(me(y,Ge(a,g,s,u,c,o,h),Ge(t),ke(([[v,b,S,k,E,C,N,T],A])=>{const{calculateViewLocation:B=yk,done:z,...F}=v,w=Xv(v,b,k-1),O=qs(w,b.offsetTree,A)+E+C,D=O+Jn(b.sizeTree,w)[1],U=T+C,H=T+S-N,q=B({itemBottom:D,itemTop:O,locationParams:F,viewportBottom:H,viewportTop:U});return q!==null?z&&Qn(me(d,De(X=>!X),Ua(Ct(d)?1:2)),z):z==null||z(),q}),De(v=>v!==null)),m),{scrollIntoView:y}},St(ur,dn,Js,Pa,ua),{singleton:!0});function bg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const bk=(t,a)=>typeof t=="function"?bg(t(a)):a&&bg(t),jk=tt(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:o},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:g,propsReady:m},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const k=ge(!1),E=Qe();let C=null;function N(z){Fe(d,{align:"end",behavior:z,index:"LAST"})}at(me(Ht(me(ze(a),Ua(1)),g),Ge(ze(k),u,h,v),ke(([[z,F],w,O,D,U])=>{let H=F&&D,q="auto";return H&&(q=bk(w,O||U),H=H&&q!==!1),{followOutputBehavior:q,shouldFollow:H,totalCount:z}}),De(({shouldFollow:z})=>z)),({followOutputBehavior:z,totalCount:F})=>{C!==null&&(C(),C=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(y)("following output to ",{totalCount:F},Ft.DEBUG),N(z)}):C=Qn(t,()=>{Ct(y)("following output to ",{totalCount:F},Ft.DEBUG),N(z),C=null})});function T(z){const F=Qn(c,w=>{z&&!w.atBottom&&w.notAtBottomBecause==="SIZE_INCREASED"&&C===null&&(Ct(y)("scrolling to bottom due to increased size",{},Ft.DEBUG),N("auto"))});setTimeout(F,100)}at(me(Ht(ze(k),a,m),De(([z,,F])=>z!==!1&&F),or(({value:z},[,F])=>({refreshed:z===F,value:F}),{refreshed:!1,value:0}),De(({refreshed:z})=>z),Ge(k,a)),([,z])=>{Ct(h)&&T(z!==!1)}),at(E,()=>{T(Ct(k)!==!1)}),at(Ht(ze(k),c),([z,F])=>{z!==!1&&!F.atBottom&&F.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const A=ge(null),B=Qe();return Te(ef(me(ze(o),ke(z=>(z==null?void 0:z.length)??0)),me(ze(a))),B),at(me(Ht(me(B,Ua(1)),g),Ge(ze(A),h,v,b),ke(([[z,F],w,O,D,U])=>F&&O&&(w==null?void 0:w({context:U,totalCount:z,scrollingInProgress:D}))),De(z=>!!z),Ar(0)),z=>{C!==null&&(C(),C=null),Ct(s)!==void 0?requestAnimationFrame(()=>{Ct(y)("scrolling into view",{}),Fe(S,z)}):C=Qn(t,()=>{Ct(y)("scrolling into view",{}),Fe(S,z),C=null})}),{autoscrollToBottom:E,followOutput:k,scrollIntoViewOnChange:A}},St(ur,ti,Js,ei,da,ua,dn,ny,ry)),Sk=tt(([{data:t,firstItemIndex:a,gap:s,sizes:o},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Te(me(h,Ge(u),De(([,g])=>g!==0),Ge(c,o,a,s,t),ke(([[,g],m,y,v,b,S=[]])=>ey(g,m,y,v,b,S))),d),{}),St(ur,ei,Pa,da),{singleton:!0}),kk=tt(([{didMount:t},{scrollTo:a},{listState:s}])=>{const o=ge(0);return at(me(t,Ge(o),De(([,c])=>c!==0),ke(([,c])=>({top:c}))),c=>{Qn(me(s,Ua(1),De(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{Fe(a,c)})})}),{initialScrollTop:o}},St(da,dn,Pa),{singleton:!0}),ay=tt(([{scrollVelocity:t}])=>{const a=ge(!1),s=Qe(),o=ge(!1);return Te(me(t,Ge(o,a,s),De(([c,u])=>u!==!1&&u!==void 0),ke(([c,u,d,h])=>{const{enter:g,exit:m}=u;if(d){if(m(c,h))return!1}else if(g(c,h))return!0;return d}),jt()),a),at(me(Ht(a,t,s),Ge(o)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:o,scrollSeekRangeChanged:s,scrollVelocity:t}},St(ti),{singleton:!0}),Rf=tt(([{scrollContainerState:t,scrollTo:a}])=>{const s=Qe(),o=Qe(),c=Qe(),u=ge(!1),d=ge(void 0);return Te(me(Ht(s,o),ke(([{scrollTop:h,viewportHeight:g},{offsetTop:m,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-m),viewportHeight:g}))),t),Te(me(a,Ge(o),ke(([h,{offsetTop:g}])=>({...h,top:h.top+g}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:o}},St(dn)),wk=tt(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:o},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:g}])=>{const m=Qe(),y=ge(void 0),v=ge(null),b=ge(null);return Te(h,v),Te(g,b),at(me(m,Ge(a,o,d,v,b,s)),([S,k,E,C,N,T,A])=>{const B=ik(k.sizeTree);C&&N!==null&&T!==null&&(E=N.scrollTop-T.offsetTop),E-=A,S({ranges:B,scrollTop:E})}),Te(me(y,De(jf),ke(Ck)),c),Te(me(u,Ge(y),De(([,S])=>S!==void 0),jt(),ke(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:y}},St(ur,dn,ei,da,Rf));function Ck(t){return{align:"start",index:0,offset:t.scrollTop}}const Ek=tt(([{topItemsIndexes:t}])=>{const a=ge(0);return Te(me(a,De(s=>s>=0),ke(s=>Array.from({length:s}).map((o,c)=>c))),t),{topItemCount:a}},St(Pa));function ly(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const Nk=ly(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Tk=tt(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:o},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:g},{beforeUnshiftWith:m,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:k}])=>{const E=Nn(me(g,Ge(d),or(([,N,T,A],[{bottom:B,items:z,offsetBottom:F,totalCount:w},O])=>{const D=B+F;let U=0;return T===w&&N.length>0&&z.length>0&&(z[0].originalIndex===0&&N[0].originalIndex===0||(U=D-A,U!==0&&(U+=O))),[U,z,w,D]},[0,[],0,0]),De(([N])=>N!==0),Ge(o,h,s,c,S,k),De(([,N,T,A,,,B])=>!B&&!A&&N!==0&&T===Ys),ke(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},Ft.DEBUG),N))));function C(N){N>0?(Fe(a,{behavior:"auto",top:-N}),Fe(t,0)):(Fe(t,0),Fe(a,{behavior:"auto",top:-N}))}return at(me(E,Ge(t,u)),([N,T,A])=>{A&&Nk()?Fe(t,T-N):C(-N)}),at(me(Ht(an(u,!1),t,k),De(([N,T,A])=>!N&&!A&&T!==0),ke(([N,T])=>T),Ar(1)),C),Te(me(v,ke(N=>({top:-N}))),a),at(me(m,Ge(b,y),ke(([N,{groupIndices:T,lastSize:A,sizeTree:B},z])=>{function F(H){return H*(A+z)}if(T.length===0)return F(N);let w=0;const O=Gs(B,0);let D=0,U=0;for(;D<N;){D++,w+=O;let H=T.length===U+1?1/0:T[U+1]-T[U]-1;D+H>N&&(w-=O,H=N-D+1),D+=H,w+=F(H),U++}return w})),N=>{Fe(t,N),requestAnimationFrame(()=>{Fe(a,{top:N}),requestAnimationFrame(()=>{Fe(t,0),Fe(k,!1)})})}),{deviation:t}},St(dn,ti,Pa,ur,ua,wf)),Rk=tt(([t,a,s,o,c,u,d,h,g,m,y])=>({...t,...a,...s,...o,...c,...u,...d,...h,...g,...m,...y}),St(Tf,Sk,da,ay,ty,kk,vk,Rf,ry,ua,ny)),sy=tt(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:o,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:g,sizeRanges:m,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C},N,T,A,B,{scrollToIndex:z},F,{topItemCount:w},{groupCounts:O},D])=>{const{listState:U,minOverscanItemCount:H,topItemsIndexes:q,rangeChanged:X,...J}=B;return Te(X,D.scrollSeekRangeChanged),Te(me(D.windowViewportRect,ke($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:o,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:k,initialTopMostItemIndex:E,scrolledToInitialItem:C,sizeRanges:m,topItemCount:w,topItemsIndexes:q,totalCount:b,...A,groupIndices:d,itemSize:g,listState:U,minOverscanItemCount:H,scrollToIndex:z,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...D,...N,sizes:y,...T}},St(ur,ei,dn,wk,jk,Pa,Js,Tk,Ek,Qv,Rk));function Ak(t,a){const s={},o={};let c=0;const u=t.length;for(;c<u;)o[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(o,d)||(s[d]=a[d]);return s}const yo=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function iy(t,a,s){const o=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Ne.createContext({});function g(C,N){C.propsReady!==void 0&&Fe(C.propsReady,!1);for(const T of o){const A=C[a.required[T]];Fe(A,N[T])}for(const T of c)if(T in N){const A=C[a.optional[T]];Fe(A,N[T])}C.propsReady!==void 0&&Fe(C.propsReady,!0)}function m(C){return u.reduce((N,T)=>(N[T]=A=>{const B=C[a.methods[T]];Fe(B,A)},N),{})}function y(C){return d.reduce((N,T)=>(N[T]=W2(C[a.events[T]]),N),{})}const v=Ne.forwardRef(function(C,N){const{children:T,...A}=C,[B]=Ne.useState(()=>Ko(Y2(t),w=>{g(w,A)})),[z]=Ne.useState(ug(y,B));yo(()=>{for(const w of d)w in A&&at(z[w],A[w]);return()=>{Object.values(z).map(Sf)}},[A,z,B]),yo(()=>{g(B,A)}),Ne.useImperativeHandle(N,cg(m(B)));const F=s;return r.jsx(h.Provider,{value:B,children:s!==void 0?r.jsx(F,{...Ak([...o,...c,...d],A),children:T}):T})}),b=C=>{const N=Ne.useContext(h);return Ne.useCallback(T=>{Fe(N[C],T)},[N,C])},S=C=>{const N=Ne.useContext(h)[C],T=Ne.useCallback(A=>at(N,A),[N]);return Ne.useSyncExternalStore(T,()=>Ct(N),()=>Ct(N))},k=C=>{const N=Ne.useContext(h)[C],[T,A]=Ne.useState(ug(Ct,N));return yo(()=>at(N,B=>{B!==T&&A(cg(B))}),[N,T]),T},E=parseInt(Ne.version)>=18?S:k;return{Component:v,useEmitter:(C,N)=>{const T=Ne.useContext(h)[C];yo(()=>at(T,N),[N,T])},useEmitterValue:E,usePublisher:b}}const oy=Ne.createContext(void 0),cy=Ne.createContext(void 0),Nd="-webkit-sticky",jg="sticky",Af=ly(()=>{if(typeof document>"u")return jg;const t=document.createElement("div");return t.style.position=Nd,t.style.position===Nd?Nd:jg}),uy=typeof document<"u"?Ne.useLayoutEffect:Ne.useEffect;function Td(t){return"self"in t}function Mk(t){return"body"in t}function dy(t,a,s,o=Il,c,u){const d=Ne.useRef(null),h=Ne.useRef(null),g=Ne.useRef(null),m=Ne.useCallback(b=>{let S,k,E;const C=b.target;if(Mk(C)||Td(C)){const T=Td(C)?C:C.defaultView;E=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,k=u===!0?T.innerWidth:T.innerHeight}else E=u===!0?C.scrollLeft:C.scrollTop,S=u===!0?C.scrollWidth:C.scrollHeight,k=u===!0?C.offsetWidth:C.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(E,0),viewportHeight:k})};b.suppressFlushSync===!0?N():Wj.flushSync(N),h.current!==null&&(E===h.current||E<=0||E===S-k)&&(h.current=null,a(!0),g.current&&(clearTimeout(g.current),g.current=null))},[t,a,u]);Ne.useEffect(()=>{const b=c||d.current;return o(c||d.current),m({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",m,{passive:!0}),()=>{o(null),b.removeEventListener("scroll",m)}},[d,m,s,o,c]);function y(b){const S=d.current;if(!S||(u===!0?"offsetWidth"in S&&S.offsetWidth===0:"offsetHeight"in S&&S.offsetHeight===0))return;const k=b.behavior==="smooth";let E,C,N;Td(S)?(C=Math.max(ia(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),E=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(C=S[u===!0?"scrollWidth":"scrollHeight"],E=ia(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=C-E;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),Jv(E,C)||b.top===N){t({scrollHeight:C,scrollTop:N,viewportHeight:E}),k&&a(!0);return}k?(h.current=b.top,g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,h.current=null,a(!0)},1e3)):h.current=null,u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},left:b.top}),S.scrollTo(b)}function v(b){u===!0&&(b={...b.behavior!==void 0?{behavior:b.behavior}:{},...b.top!==void 0?{left:b.top}:{}}),d.current.scrollBy(b)}return{scrollByCallback:v,scrollerRef:d,scrollToCallback:y}}function Mf(t){return t}const Lk=tt(()=>{const t=ge(h=>`Item ${h}`),a=ge(h=>`Group ${h}`),s=ge({}),o=ge(Mf),c=ge("div"),u=ge(Il),d=(h,g=null)=>an(me(s,ke(m=>m[h]),jt()),g);return{components:s,computeItemKey:o,EmptyPlaceholder:d("EmptyPlaceholder"),FooterComponent:d("Footer"),GroupComponent:d("Group","div"),groupContent:a,HeaderComponent:d("Header"),HeaderFooterTag:c,ItemComponent:d("Item","div"),itemContent:t,ListComponent:d("List","div"),ScrollerComponent:d("Scroller","div"),scrollerRef:u,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TopItemListComponent:d("TopItemList")}}),zk=tt(([t,a])=>({...t,...a}),St(sy,Lk)),Dk=({height:t})=>r.jsx("div",{style:{height:t}}),_k={overflowAnchor:"none",position:Af(),zIndex:1},fy={overflowAnchor:"none"},Ok={...fy,display:"inline-block",height:"100%"},Sg=Ne.memo(function({showTopList:t=!1}){const a=He("listState"),s=Pn("sizeRanges"),o=He("useWindowScroll"),c=He("customScrollParent"),u=Pn("windowScrollContainerState"),d=Pn("scrollContainerState"),h=c||o?u:d,g=He("itemContent"),m=He("context"),y=He("groupContent"),v=He("trackItemSizes"),b=He("itemSize"),S=He("log"),k=Pn("gap"),E=He("horizontalDirection"),{callbackRef:C}=Q2(s,b,v,t?Il:h,S,k,c,E,He("skipAnimationFrameInResizeObserver")),[N,T]=Ne.useState(0);Lf("deviation",J=>{N!==J&&T(J)});const A=He("EmptyPlaceholder"),B=He("ScrollSeekPlaceholder")??Dk,z=He("ListComponent"),F=He("ItemComponent"),w=He("GroupComponent"),O=He("computeItemKey"),D=He("isSeeking"),U=He("groupIndices").length>0,H=He("alignToBottom"),q=He("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...E?{display:"inline-block",height:"100%",marginLeft:N!==0?N:H?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:H?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...q?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&A!==null&&A!==void 0?r.jsx(A,{...rn(A,m)}):r.jsx(z,{...rn(z,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:C,style:X,children:(t?a.topItems:a.items).map(J=>{const $=J.originalIndex,L=O($+a.firstItemIndex,J.data,m);return D?p.createElement(B,{...rn(B,m),height:J.size,index:J.index,key:L,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?p.createElement(w,{...rn(w,m),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:L,style:_k},y(J.index,m)):p.createElement(F,{...rn(F,m),...Hk(F,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:L,style:E?Ok:fy},U?g(J.index,J.groupIndex,J.data,m):g(J.index,J.data,m))})})}),Bk={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Ik={outline:"none",overflowX:"auto",position:"relative"},Qo=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),Uk={position:Af(),top:0,width:"100%",zIndex:1};function rn(t,a){if(typeof t!="string")return{context:a}}function Hk(t,a){return{item:typeof t=="string"?void 0:a}}const $k=Ne.memo(function(){const t=He("HeaderComponent"),a=Pn("headerHeight"),s=He("HeaderFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null}),Vk=Ne.memo(function(){const t=He("FooterComponent"),a=Pn("footerHeight"),s=He("HeaderFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,He("skipAnimationFrameInResizeObserver")),c=He("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null});function py({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("scrollContainerState"),g=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:k}=dy(h,m,g,y,void 0,v);return t("scrollTo",k),t("scrollBy",b),r.jsx(g,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?Ik:Bk,...c},tabIndex:0,...d,...rn(g,u),children:o})})}function my({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Ne.memo(function({children:o,style:c,context:u,...d}){const h=s("windowScrollContainerState"),g=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Ne.useRef(null),k=a("scrollerRef"),{scrollByCallback:E,scrollerRef:C,scrollToCallback:N}=dy(h,m,g,k,b);return uy(()=>{var T;return C.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{C.current=null}},[C,b]),t("windowScrollTo",N),t("scrollBy",E),r.jsx(g,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...rn(g,u),children:o})})}const Pk=({children:t})=>{const a=Ne.useContext(oy),s=Pn("viewportHeight"),o=Pn("fixedItemHeight"),c=He("alignToBottom"),u=He("horizontalDirection"),d=Ne.useMemo(()=>Uv(s,g=>ia(g,u?"width":"height")),[s,u]),h=Va(d,!0,He("skipAnimationFrameInResizeObserver"));return Ne.useEffect(()=>{a&&(s(a.viewportHeight),o(a.itemHeight))},[a,s,o]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:Qo(c),children:t})},Fk=({children:t})=>{const a=Ne.useContext(oy),s=Pn("windowViewportRect"),o=Pn("fixedItemHeight"),c=He("customScrollParent"),u=$v(s,c,He("skipAnimationFrameInResizeObserver")),d=He("alignToBottom");return Ne.useEffect(()=>{a&&(o(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,o]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:Qo(d),children:t})},Gk=({children:t})=>{const a=He("TopItemListComponent")??"div",s=He("headerHeight"),o={...Uk,marginTop:`${s}px`},c=He("context");return r.jsx(a,{style:o,...rn(a,c),children:t})},Wk=Ne.memo(function(t){const a=He("useWindowScroll"),s=He("topItemsIndexes").length>0,o=He("customScrollParent"),c=He("context");return r.jsxs(o||a?Kk:Yk,{...t,context:c,children:[s&&r.jsx(Gk,{children:r.jsx(Sg,{showTopList:!0})}),r.jsxs(o||a?Fk:Pk,{children:[r.jsx($k,{}),r.jsx(Sg,{}),r.jsx(Vk,{})]})]})}),{Component:qk,useEmitter:Lf,useEmitterValue:He,usePublisher:Pn}=iy(zk,{optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Wk),Yk=py({useEmitter:Lf,useEmitterValue:He,usePublisher:Pn}),Kk=my({useEmitter:Lf,useEmitterValue:He,usePublisher:Pn}),Xk=qk,Qk=tt(()=>{const t=ge(m=>r.jsxs("td",{children:["Item $",m]})),a=ge(null),s=ge(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),o=ge(null),c=ge(null),u=ge({}),d=ge(Mf),h=ge(Il),g=(m,y=null)=>an(me(u,ke(v=>v[m]),jt()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:g("EmptyPlaceholder"),FillerRow:g("FillerRow"),fixedFooterContent:c,fixedHeaderContent:o,itemContent:t,groupContent:s,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder"),TableBodyComponent:g("TableBody","tbody"),TableComponent:g("Table","table"),TableFooterComponent:g("TableFoot","tfoot"),TableHeadComponent:g("TableHead","thead"),TableRowComponent:g("TableRow","tr"),GroupComponent:g("Group","tr")}});St(sy,Qk);Af();const kg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Zk={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:wg,floor:Io,max:$s,min:Rd,round:Cg}=Math;function Eg(t,a,s){return Array.from({length:a-t+1}).map((o,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Jk(t){return{...Zk,items:t}}function bo(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function ew(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const tw=tt(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:o},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:g,scrollTop:m,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:k,propsReady:E},{customScrollParent:C,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B},z])=>{const F=ge(0),w=ge(0),O=ge(kg),D=ge({height:0,width:0}),U=ge({height:0,width:0}),H=Qe(),q=Qe(),X=ge(0),J=ge(null),$=ge({column:0,row:0}),L=Qe(),_=Qe(),I=ge(!1),V=ge(0),ie=ge(!0),M=ge(!1),Y=ge(!1);at(me(k,Ge(V),De(([de,je])=>je!==0)),()=>{Fe(ie,!1)}),at(me(Ht(k,ie,U,D,V,M),De(([de,je,Re,_e,,ae])=>de&&!je&&Re.height!==0&&_e.height!==0&&!ae)),([,,,,de])=>{Fe(M,!0),Ef(1,()=>{Fe(H,de)}),Qn(me(m),()=>{Fe(a,[0,0]),Fe(ie,!0)})}),Te(me(_,De(de=>de!=null&&de.scrollTop>0),ir(0)),w),at(me(k,Ge(_),De(([,de])=>de!=null)),([,de])=>{de&&(Fe(D,de.viewport),Fe(U,de.item),Fe($,de.gap),de.scrollTop>0&&(Fe(I,!0),Qn(me(m,Ua(1)),je=>{Fe(I,!1)}),Fe(g,{top:de.scrollTop})))}),Te(me(D,ke(({height:de})=>de)),v),Te(me(Ht(ze(D,bo),ze(U,bo),ze($,(de,je)=>de!==void 0&&de.column===je.column&&de.row===je.row),ze(m)),ke(([de,je,Re,_e])=>({gap:Re,item:je,scrollTop:_e,viewport:de}))),L),Te(me(Ht(ze(F),o,ze($,ew),ze(U,bo),ze(D,bo),ze(J),ze(w),ze(I),ze(ie),ze(V)),De(([,,,,,,,de])=>!de),ke(([de,[je,Re],_e,ae,he,pe,xe,,be,Be])=>{const{column:Oe,row:lt}=_e,{height:Nt,width:xt}=ae,{width:_t}=he;if(xe===0&&(de===0||_t===0))return kg;if(xt===0){const Wt=Nf(Be,de),ln=Wt+Math.max(xe-1,0);return Jk(Eg(Wt,ln,pe))}const Tt=hy(_t,xt,Oe);let Ze,nt;be?je===0&&Re===0&&xe>0?(Ze=0,nt=xe-1):(Ze=Tt*Io((je+lt)/(Nt+lt)),nt=Tt*wg((Re+lt)/(Nt+lt))-1,nt=Rd(de-1,$s(nt,Tt-1)),Ze=Rd(nt,$s(0,Ze))):(Ze=0,nt=-1);const ye=Eg(Ze,nt,pe),{bottom:mt,top:Et}=Ng(he,_e,ae,ye),Xt=wg(de/Tt),fn=Xt*Nt+(Xt-1)*lt-mt;return{bottom:mt,itemHeight:Nt,items:ye,itemWidth:xt,offsetBottom:fn,offsetTop:Et,top:Et}})),O),Te(me(J,De(de=>de!==null),ke(de=>de.length)),F),Te(me(Ht(D,U,O,$),De(([de,je,{items:Re}])=>Re.length>0&&je.height!==0&&de.height!==0),ke(([de,je,{items:Re},_e])=>{const{bottom:ae,top:he}=Ng(de,_e,je,Re);return[he,ae]}),jt(Ws)),a);const G=ge(!1);Te(me(m,Ge(G),ke(([de,je])=>je||de!==0)),G);const te=Nn(me(Ht(O,F),De(([{items:de}])=>de.length>0),Ge(G),De(([[de,je],Re])=>{const _e=de.items[de.items.length-1].index===je-1;return(Re||de.bottom>0&&de.itemHeight>0&&de.offsetBottom===0&&de.items.length===je)&&_e}),ke(([[,de]])=>de-1),jt())),fe=Nn(me(ze(O),De(({items:de})=>de.length>0&&de[0].index===0),ir(0),jt())),oe=Nn(me(ze(O),Ge(I),De(([{items:de},je])=>de.length>0&&!je),ke(([{items:de}])=>({endIndex:de[de.length-1].index,startIndex:de[0].index})),jt(qv),Ar(0)));Te(oe,S.scrollSeekRangeChanged),Te(me(H,Ge(D,U,F,$),ke(([de,je,Re,_e,ae])=>{const he=Zv(de),{align:pe,behavior:xe,offset:be}=he;let Be=he.index;Be==="LAST"&&(Be=_e-1),Be=$s(0,Be,Rd(_e-1,Be));let Oe=lf(je,ae,Re,Be);return pe==="end"?Oe=Cg(Oe-je.height+Re.height):pe==="center"&&(Oe=Cg(Oe-je.height/2+Re.height/2)),be!==void 0&&be!==0&&(Oe+=be),{behavior:xe,top:Oe}})),g);const ve=an(me(O,ke(de=>de.offsetBottom+de.bottom)),0);return Te(me(B,ke(de=>({height:de.visibleHeight,width:de.visibleWidth}))),D),{customScrollParent:C,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:w,itemDimensions:U,overscan:s,restoreStateFrom:_,scrollBy:d,scrollContainerState:h,scrollHeight:q,scrollTo:g,scrollToIndex:H,scrollTop:m,smoothScrollTargetReached:y,totalCount:F,useWindowScroll:N,viewportDimensions:D,windowScrollContainerState:T,windowScrollTo:A,windowViewportRect:B,...S,gridState:O,horizontalDirection:Y,initialTopMostItemIndex:V,totalListHeight:ve,...b,endReached:te,propsReady:E,rangeChanged:oe,startReached:fe,stateChanged:L,stateRestoreInProgress:I,...z}},St(Tf,dn,ti,ay,da,Rf,ua));function hy(t,a,s){return $s(1,Io((t+s)/(Io(a)+s)))}function Ng(t,a,s,o){const{height:c}=s;if(c===void 0||o.length===0)return{bottom:0,top:0};const u=lf(t,a,s,o[0].index);return{bottom:lf(t,a,s,o[o.length-1].index)+c,top:u}}function lf(t,a,s,o){const c=hy(t.width,s.width,a.column),u=Io(o/c),d=u*s.height+$s(0,u-1)*a.row;return d>0?d+a.row:d}const nw=tt(()=>{const t=ge(v=>`Item ${v}`),a=ge({}),s=ge(null),o=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Mf),d=ge("div"),h=ge(Il),g=(v,b=null)=>an(me(a,ke(S=>S[v]),jt()),b),m=ge(!1),y=ge(!1);return Te(ze(y),m),{components:a,computeItemKey:u,context:s,FooterComponent:g("Footer"),HeaderComponent:g("Header"),headerFooterTag:d,itemClassName:o,ItemComponent:g("Item","div"),itemContent:t,listClassName:c,ListComponent:g("List","div"),readyStateChanged:m,reportReadyState:y,ScrollerComponent:g("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:g("ScrollSeekPlaceholder","div")}}),rw=tt(([t,a])=>({...t,...a}),St(tw,nw)),aw=Ne.memo(function(){const t=wt("gridState"),a=wt("listClassName"),s=wt("itemClassName"),o=wt("itemContent"),c=wt("computeItemKey"),u=wt("isSeeking"),d=Fn("scrollHeight"),h=wt("ItemComponent"),g=wt("ListComponent"),m=wt("ScrollSeekPlaceholder"),y=wt("context"),v=Fn("itemDimensions"),b=Fn("gap"),S=wt("log"),k=wt("stateRestoreInProgress"),E=Fn("reportReadyState"),C=Va(Ne.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const A=N.firstChild;if(A!==null){const{height:B,width:z}=A.getBoundingClientRect();v({height:B,width:z})}b({column:Tg("column-gap",getComputedStyle(N).columnGap,S),row:Tg("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return uy(()=>{t.itemHeight>0&&t.itemWidth>0&&E(!0)},[t]),k?null:r.jsx(g,{className:a,ref:C,...rn(g,y),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(N=>{const T=c(N.index,N.data,y);return u?r.jsx(m,{...rn(m,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):p.createElement(h,{...rn(h,y),className:s,"data-index":N.index,key:T},o(N.index,N.data,y))})})}),lw=Ne.memo(function(){const t=wt("HeaderComponent"),a=Fn("headerHeight"),s=wt("headerFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null}),sw=Ne.memo(function(){const t=wt("FooterComponent"),a=Fn("footerHeight"),s=wt("headerFooterTag"),o=Va(Ne.useMemo(()=>u=>{a(ia(u,"height"))},[a]),!0,!1),c=wt("context");return t!=null?r.jsx(s,{ref:o,children:r.jsx(t,{...rn(t,c)})}):null}),iw=({children:t})=>{const a=Ne.useContext(cy),s=Fn("itemDimensions"),o=Fn("viewportDimensions"),c=Va(Ne.useMemo(()=>u=>{o(u.getBoundingClientRect())},[o]),!0,!1);return Ne.useEffect(()=>{a&&(o({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,o,s]),r.jsx("div",{ref:c,style:Qo(!1),children:t})},ow=({children:t})=>{const a=Ne.useContext(cy),s=Fn("windowViewportRect"),o=Fn("itemDimensions"),c=wt("customScrollParent"),u=$v(s,c,!1);return Ne.useEffect(()=>{a&&(o({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,o]),r.jsx("div",{ref:u,style:Qo(!1),children:t})},cw=Ne.memo(function({...t}){const a=wt("useWindowScroll"),s=wt("customScrollParent"),o=s||a?dw:uw,c=s||a?ow:iw,u=wt("context");return r.jsx(o,{...t,...rn(o,u),children:r.jsxs(c,{children:[r.jsx(lw,{}),r.jsx(aw,{}),r.jsx(sw,{})]})})}),{useEmitter:xy,useEmitterValue:wt,usePublisher:Fn}=iy(rw,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},cw),uw=py({useEmitter:xy,useEmitterValue:wt,usePublisher:Fn}),dw=my({useEmitter:xy,useEmitterValue:wt,usePublisher:Fn});function Tg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,Ft.WARN),a==="normal"?0:parseInt(a??"0",10)}const fw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},gy={source:"Own",installed:"Installed"};function pw(t){try{const a=localStorage.getItem(t);if(a!=null)return a==="true"}catch{}try{if(typeof sessionStorage<"u"){const a=sessionStorage.getItem(t);if(a!=null)return a==="true"}}catch{}return!1}function mw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Rg({origin:t,count:a,filteredCount:s,updateCount:o,children:c}){const u=fw[t],[d,h]=p.useState(()=>pw(u)),g=p.useCallback(()=>{h(b=>{const S=!b;return mw(u,S),S})},[u]),m=gy[t],y=`sidebar-section-${t}-header`,v=`sidebar-section-${t}-group`;return r.jsxs("section",{"aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:[r.jsxs("button",{id:y,type:"button","data-testid":"sidebar-section-header","aria-expanded":!d,"aria-controls":v,onClick:g,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 12px 6px 14px",background:"transparent",border:"none",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx(xw,{collapsed:d}),r.jsx("h2",{"aria-level":2,style:{fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)",margin:0},children:m}),r.jsx("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:s!=null&&s!==a?`(${s} of ${a})`:`(${a})`}),o!=null&&o>0&&r.jsx(hw,{origin:t,updateCount:o})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function hw({origin:t,updateCount:a}){const[s,o]=p.useState(!1),c=gy[t].toLowerCase(),u=`${a} updates available in ${c} section, view all`;return r.jsxs("span",{role:"link",tabIndex:0,"data-testid":"sidebar-section-update-chip","aria-label":u,onClick:d=>{d.stopPropagation(),window.location.hash="#/updates"},onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),d.stopPropagation(),window.location.hash="#/updates")},onFocus:()=>o(!0),onBlur:()=>o(!1),style:{display:"inline-flex",alignItems:"center",gap:2,fontSize:10,color:"var(--color-own)",fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",cursor:"pointer",padding:"0 4px",borderRadius:3,outline:s?"2px solid var(--border-focus)":"none",outlineOffset:2},children:[a," updates",r.jsx("span",{"aria-hidden":"true",style:{fontSize:9,marginLeft:2},children:"▾"})]})}function xw({collapsed:t}){return r.jsx("svg",{"aria-hidden":"true",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(0deg)":"rotate(90deg)",transition:"transform var(--duration-fast, 120ms) var(--ease-standard, ease)",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function zf(t,a){const s=a.trim().toLowerCase();return s?t.skill.toLowerCase().includes(s)||t.plugin.toLowerCase().includes(s)||t.dir.toLowerCase().includes(s):!0}function gw({value:t,onChange:a,placeholder:s="Filter skills…",validationPattern:o,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),h=!!o&&t.trim()!==""&&!o.test(t);return p.useEffect(()=>{function g(m){var b;if(m.key!=="/")return;const y=m.target;if(!y)return;const v=y.tagName;v==="INPUT"||v==="TEXTAREA"||y.isContentEditable||(m.preventDefault(),(b=u.current)==null||b.focus())}return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[]),r.jsxs("div",{role:"search",style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("svg",{"aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-secondary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("path",{d:"M21 21l-4.35-4.35"})]}),r.jsx("input",{ref:u,type:"search","aria-label":"Filter skills","aria-invalid":h?!0:void 0,"aria-describedby":h?d:void 0,value:t,placeholder:s,onChange:g=>a(g.currentTarget.value),onKeyDown:g=>{g.key==="Escape"&&(a(""),g.currentTarget.blur())},style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12,padding:"2px 0"}}),h&&r.jsx("span",{id:d,role:"alert","aria-live":"polite",style:{fontFamily:"var(--font-sans)",fontSize:10,color:"var(--text-error, #B42318)",marginLeft:4,whiteSpace:"nowrap"},children:c}),r.jsx("kbd",{"aria-hidden":"true",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",border:"1px solid var(--border-default)",padding:"1px 5px",borderRadius:3,display:t?"none":"inline-block"},children:"/"})]})}function vw({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",o=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":o,title:s,tabIndex:0,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:14,height:14,borderRadius:3,color:"var(--text-secondary)",flexShrink:0},children:r.jsxs("svg",{"data-testid":"symlink-glyph",width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}function yw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,o=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:o,"aria-label":"Update available",style:{color:"var(--color-own)",display:"inline-flex",flexShrink:0},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 19V5"}),r.jsx("path",{d:"M5 12l7-7 7 7"})]})})}function bw({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(Tv)}catch{s=null}const o=s==null?void 0:s.updatesById.get(t);if(o){const c=`Update available → ${o.version}${o.diffSummary?` — ${o.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${o.version}`,title:c,style:{display:"inline-block",width:8,height:8,borderRadius:999,background:"var(--color-accent, #2563eb)",flexShrink:0}})}return a?null:r.jsx("span",{"data-testid":"update-chip-untracked-dot","aria-label":"Not tracked for updates",title:"Not tracked — run `vskill outdated` manually",style:{display:"inline-block",width:6,height:6,borderRadius:999,background:"var(--text-muted, var(--text-secondary))",opacity:.55,flexShrink:0}})}function jw(t,a,s){if(!(!t||t==="frontmatter"))return t==="plugin"?`Inherited from ${s&&s.trim()!==""?s:"plugin"} plugin v${a}`:t==="registry"?"Inherited from registry":"No version declared"}function ni(t){const{version:a,showPrefix:s=!0,size:o="md",source:c,pluginName:u}=t,d=typeof a=="string"&&a.trim()!==""?a.trim():"1.0.0",h=s&&!d.startsWith("v")?`v${d}`:d,g=o==="sm"?10:12,m=o==="sm"?1:2,y=o==="sm"?5:8,v=c!==void 0&&c!=="frontmatter",b=jw(c,d,u),S=t.title??b,k={display:"inline-flex",alignItems:"center",padding:`${m}px ${y}px`,border:"1px solid var(--border, var(--border-default))",borderRadius:4,background:"var(--bg-subtle, var(--surface-1, transparent))",color:"var(--text-secondary)",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:g,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return v&&(k.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":d,"data-version-source":c,title:S,style:k,children:h})}function Sw({skill:t,isSelected:a,onSelect:s,onContextMenu:o}){const c=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:o?u=>{u.preventDefault(),o(u,t)}:void 0,"aria-current":a?"true":void 0,"aria-selected":!!a,"data-testid":"skill-row","data-selected":a,"data-origin":t.origin,"data-skill-id":`${t.plugin}/${t.skill}`,style:{display:"flex",alignItems:"center",gap:8,width:"100%",height:36,padding:"0 12px 0 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",boxShadow:a?"inset 2px 0 0 var(--color-accent, var(--accent-surface))":"none",border:"none",borderRadius:0,color:"var(--text-primary)",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,textAlign:"left",transition:"background-color var(--duration-fast, 120ms) var(--ease-standard, ease), box-shadow var(--duration-base, 180ms) var(--ease-standard, ease)"},children:[r.jsx("span",{"aria-hidden":"true","aria-label":t.updateAvailable?"Update available":void 0,title:t.updateAvailable?`Update available${t.latestVersion?` → ${t.latestVersion}`:""}`:void 0,style:{width:t.updateAvailable?10:6,height:t.updateAvailable?10:6,borderRadius:"50%",background:c,display:"inline-block",flexShrink:0,boxShadow:t.updateAvailable?"0 0 0 2px var(--color-own, #d97706)":"none",transition:"box-shadow 180ms ease, width 180ms ease, height 180ms ease"}}),r.jsx("span",{title:t.skill,style:{minWidth:0,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.skill}),r.jsx(ni,{version:t.resolvedVersion??t.version??"1.0.0",source:t.versionSource??(t.version?"frontmatter":"default"),pluginName:t.pluginName??null,size:"sm",showPrefix:!1,"data-testid":"skill-row-version"}),t.isSymlink&&r.jsx(vw,{target:t.symlinkTarget??null}),r.jsx(yw,{skill:t}),r.jsx(bw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const Uo=p.memo(Sw);function kw({plugin:t,skills:a,selectedKey:s,onSelect:o,onContextMenu:c}){const u=[...a].sort((d,h)=>d.skill.localeCompare(h.skill));return r.jsxs("div",{role:"group","aria-label":`${t} (${a.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t,children:t}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",a.length,")"]})]}),r.jsx("div",{role:"list",children:u.map(d=>{const h=!!s&&s.plugin===d.plugin&&s.skill===d.skill;return r.jsx("div",{role:"listitem",children:r.jsx(Uo,{skill:d,isSelected:h,onSelect:()=>o(d),onContextMenu:c})},`${d.plugin}/${d.skill}`)})})]})}function ww(t,a){if(!t||typeof window>"u")return a;try{const s=window.localStorage.getItem(t);return s===null?a:s==="true"}catch{return a}}function Ag({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:o,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[g,m]=p.useState(()=>ww(o,s)),y=d?!1:g,v=p.useCallback(()=>{m(k=>{const E=!k;if(o&&typeof window<"u")try{window.localStorage.setItem(o,String(E))}catch{}return E})},[o]),b=y?"▸":"▾";return r.jsxs("div",{"data-vskill-plugin-tree":h,role:"group","aria-label":`${h} (${t.length})`,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",paddingRight:6},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:6,flex:1,padding:"4px 4px 4px 18px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",fontSize:12,fontWeight:500},children:[r.jsx("span",{"aria-hidden":!0,className:"vskill-chevron tabular-nums",style:{width:16,display:"inline-block",textAlign:"center",fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))"},children:b}),r.jsx("span",{className:"vskill-plugin-name",style:{fontFamily:"var(--font-mono)"},children:h}),r.jsxs("span",{className:"vskill-plugin-count tabular-nums",style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["(",t.length,")"]})]}),u&&r.jsx("div",{style:{display:"inline-flex",alignItems:"center",flexShrink:0},children:u})]}),!y&&r.jsx("div",{className:"vskill-plugin-tree-children",style:{paddingLeft:36,borderLeft:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",marginLeft:24},children:t.map(k=>r.jsx("div",{"data-vskill-plugin-skill":k.pluginNamespace??k.skill,children:c(k)},`${k.pluginNamespace??k.skill}`))})]})}const zo=new Map,Ba=new Map,Bs=new Map;function Tn(t){zo.delete(t),Ba.delete(t);const a=Bs.get(t);if(a)for(const s of a)s()}function ri(t,a,s={}){const{ttl:o=3e4,enabled:c=!0}=s,[,u]=p.useState(0),d=p.useRef(!0),h=p.useRef(t);h.current=t;const g=()=>Tn(t);p.useEffect(()=>(d.current=!0,()=>{d.current=!1}),[]),p.useEffect(()=>{if(!c)return;const b=()=>{d.current&&u(S=>S+1)};return Bs.has(t)||Bs.set(t,new Set),Bs.get(t).add(b),()=>{var S;(S=Bs.get(t))==null||S.delete(b)}},[t,c]),p.useEffect(()=>{if(!c)return;const b=zo.get(t);if(!(!b||Date.now()-b.fetchedAt>o))return;if(Ba.has(t)){const C=Ba.get(t),N=()=>{d.current&&h.current===t&&u(T=>T+1)};C.subscribers.push(N);return}const k={promise:Promise.resolve(),subscribers:[]},E=a().then(C=>{zo.set(t,{data:C,fetchedAt:Date.now()}),Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N()},C=>{Ba.delete(t),d.current&&h.current===t&&u(N=>N+1);for(const N of k.subscribers)N();throw C});k.promise=E,Ba.set(t,k)},[t,a,o,c]);const m=zo.get(t),y=c&&!m&&Ba.has(t);return{data:m==null?void 0:m.data,loading:y||c&&!m,error:void 0,revalidate:g}}function Cw({pluginName:t,enabled:a,onAfterAction:s}){const[o,c]=p.useState(!1),[u,d]=p.useState(null),[h,g]=p.useState(null),m=p.useRef(null);p.useEffect(()=>{if(!o)return;function v(b){m.current&&!m.current.contains(b.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[o]);async function y(v){d(v),g(null);try{if(v==="uninstall"&&!window.confirm(`Uninstall ${t}? This removes the plugin and its skills.`)){d(null);return}const b=await fetch(`/api/plugins/${encodeURIComponent(t)}/${v}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),S=await b.json().catch(()=>({}));if(!b.ok||!S.ok){g(S.error??`${v} failed (${b.status})`);return}Tn("skills"),Bv(),s==null||s(),c(!1)}catch(b){g(b instanceof Error?b.message:String(b))}finally{d(null)}}return r.jsxs("div",{ref:m,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:v=>{v.stopPropagation(),c(b=>!b)},"data-vskill-plugin-action-trigger":t,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,padding:0,marginLeft:4,border:"none",background:o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:v=>{v.currentTarget.style.color="var(--text-primary)",v.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:v=>{v.currentTarget.style.color="var(--text-tertiary)",v.currentTarget.style.background=o?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),o&&r.jsxs("div",{role:"menu",style:{position:"absolute",top:"calc(100% + 2px)",right:0,minWidth:160,background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 8px 14px -4px rgba(0,0,0,0.12)",padding:4,zIndex:30,fontFamily:"var(--font-sans)"},children:[a?r.jsx(Ad,{onClick:()=>void y("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx(Ad,{onClick:()=>void y("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx(Ad,{onClick:()=>void y("uninstall"),disabled:u!==null,busy:u==="uninstall",label:"Uninstall",hint:"Remove plugin + skills",danger:!0}),h&&r.jsx("div",{style:{padding:"6px 8px",fontSize:11,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4,marginTop:4,lineHeight:1.4,maxWidth:240,wordBreak:"break-word"},children:h})]})]})}function Ad({onClick:t,disabled:a,busy:s,label:o,hint:c,danger:u}){return r.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),t()},disabled:a,role:"menuitem",style:{display:"block",width:"100%",padding:"6px 10px",textAlign:"left",border:"none",background:"transparent",borderRadius:4,cursor:a?"not-allowed":"pointer",color:u?"var(--color-error, #b91c1c)":"var(--text-primary)",opacity:a&&!s?.5:1,fontFamily:"inherit"},onMouseEnter:d=>{a||(d.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.05))")},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:12,fontWeight:500},children:s?`${o}…`:o}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Mg({name:t,count:a,className:s,variant:o,collapsed:c,onToggle:u,action:d}){const h=o==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",g=o==="authoring"?"color-mix(in oklch, var(--color-own, #f59e0b) 10%, var(--color-paper, #fff))":"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))",m=typeof u=="function",y={position:"sticky",top:0,zIndex:4,backdropFilter:"saturate(1.4) blur(10px)",WebkitBackdropFilter:"saturate(1.4) blur(10px)",background:g,borderLeft:`3px solid ${h}`,borderBottom:"1px solid var(--border-subtle, rgba(128,128,128,0.2))",padding:"7px 10px 7px 9px",fontFamily:"var(--font-serif, ui-serif)",fontSize:13,fontWeight:700,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-primary)",display:"flex",alignItems:"center",gap:8,width:"100%",cursor:m?"pointer":"default",border:"none",textAlign:"left"},v=c?"▸":"▾",b=r.jsxs(r.Fragment,{children:[m&&r.jsx("span",{"aria-hidden":!0,style:{fontSize:15,fontWeight:700,color:h,width:16,display:"inline-block",textAlign:"center",letterSpacing:0,textTransform:"none"},children:v}),r.jsx("span",{className:"vskill-group-header-name",children:t}),r.jsxs("span",{className:"vskill-group-header-count tabular-nums",style:{fontFamily:"var(--font-mono)",fontSize:11,fontWeight:500,color:"var(--text-secondary)",letterSpacing:0,textTransform:"none"},children:["(",a,")"]}),d&&r.jsx("span",{style:{marginLeft:"auto"},children:r.jsx(Ew,{label:d.label,title:d.title,icon:d.icon,onClick:d.onClick,accent:h})})]});return m?r.jsx("button",{type:"button","data-vskill-group-header":t,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,onClick:()=>u(!c),"aria-expanded":!c,children:b}):r.jsx("div",{"data-vskill-group-header":t,role:"heading","aria-level":3,className:["vskill-group-header select-none",s??""].join(" ").trim(),style:y,children:b})}function Ew({label:t,title:a,icon:s,onClick:o,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),o()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4,height:22,padding:"0 7px",border:`1px solid ${c}`,background:"transparent",color:c,borderRadius:4,fontSize:10,fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:u=>{u.currentTarget.style.background=`color-mix(in oklch, ${c} 15%, transparent)`},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[s,t]})}function Nw(){return r.jsxs("div",{"aria-hidden":"true",role:"presentation",style:{display:"flex",alignItems:"center",gap:8,height:36,padding:"0 12px 0 14px"},children:[r.jsx("span",{className:"placeholder",style:{width:6,height:6,borderRadius:"50%",flexShrink:0}}),r.jsx("span",{className:"placeholder",style:{height:10,flex:1,borderRadius:3,maxWidth:180}})]})}function Tw(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,o=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const g=h.toLowerCase();g==="cmd"||g==="meta"||g==="⌘"?s=!0:g==="ctrl"||g==="control"?o=!0:g==="shift"?c=!0:(g==="alt"||g==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:o,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function Rw(t){if(!t||!(t instanceof HTMLElement))return!1;const a=t.tagName;if(a==="INPUT"||a==="TEXTAREA"||t.isContentEditable)return!0;const s=t.getAttribute("contenteditable");return s!=null&&s!=="false"||t.getAttribute("role")==="textbox"}function Aw(t,a){const s=!!t.metaKey,o=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||o!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function sf(t,a={}){const{enabled:s=!0,target:o}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(Tw),p.useEffect(()=>{if(!s)return;const d=o??(typeof window<"u"?window:void 0);if(!d)return;function h(g){const m=g,y=Rw(m.target);for(const v of c.current){if(!Aw(m,v))continue;const b=v.meta||v.ctrl||v.alt;if(!(y&&!v.allowInInputs&&!b)){v.handler(m);return}}}return d.addEventListener("keydown",h),()=>{d.removeEventListener("keydown",h)}},[s,o])}const Mw=200;function Lw(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function zw(t,a){const s={availableProject:[],availablePersonal:[],availablePlugin:[],authoringProject:[],authoringPlugin:[]};for(const c of t){const u=c.scopeV2??(c.scope==="installed"?"available-project":c.scope==="global"?"available-personal":"authoring-project");u==="available-project"?s.availableProject.push(c):u==="available-personal"?s.availablePersonal.push(c):u==="available-plugin"?s.availablePlugin.push(c):u==="authoring-plugin"?s.authoringPlugin.push(c):s.authoringProject.push(c)}function o(c){const u=c.filter(g=>zf(g,a)),d={};for(const g of u){const m=g.pluginName??g.plugin;(d[m]||(d[m]=[])).push(g)}const h=Object.entries(d).sort((g,m)=>g[0].localeCompare(m[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:o(s.availableProject),availablePersonal:o(s.availablePersonal),availablePlugin:o(s.availablePlugin),authoringProject:o(s.authoringProject),authoringPlugin:o(s.authoringPlugin)}}function Dw(t,a){const s=[],o=[],c=[];for(const d of t){const h=Lw(d);h==="global"?c.push(d):h==="installed"?o.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>zf(v,a)),g={};for(const v of h)(g[y=v.plugin]||(g[y]=[])).push(v);const m=Object.entries(g).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(o),global:u(c)}}function _w(t,a){const s=[],o=[];for(const u of t)(u.origin==="installed"?o:s).push(u);function c(u){var m;const d=u.filter(y=>zf(y,a)),h={};for(const y of d)(h[m=y.plugin]||(h[m]=[])).push(y);const g=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:g}}return{own:c(s),installed:c(o)}}function Ow({skills:t,selectedKey:a,onSelect:s,isLoading:o,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:g,outdatedByScope:m,topSlot:y,revealSkillId:v,onRevealComplete:b}){const S=!!g||t.some(G=>G.scope!==void 0&&G.scope!==null),k=g??"claude-cli",[E,C]=p.useState(""),N=p.useDeferredValue(E),T=p.useMemo(()=>Dw(t,N),[t,N]),A=p.useMemo(()=>zw(t,N),[t,N]),B=k==="claude-code",{plugins:z}=H2(),F=B?{plugins:z??[]}:void 0,w=p.useMemo(()=>{const G=new Map;for(const te of(F==null?void 0:F.plugins)??[]){const fe=G.get(te.name);G.set(te.name,!!fe||!!te.enabled)}return G},[F==null?void 0:F.plugins]),[O,D]=p.useState(()=>of(`vskill-sidebar-${k}-group-available-collapsed`)),[U,H]=p.useState(()=>of(`vskill-sidebar-${k}-group-authoring-collapsed`)),q=p.useCallback(G=>{D(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-available-collapsed`,String(G))}catch{}},[k]),X=p.useCallback(G=>{H(G);try{window.localStorage.setItem(`vskill-sidebar-${k}-group-authoring-collapsed`,String(G))}catch{}},[k]),{own:J,installed:$}=p.useMemo(()=>_w(t,N),[t,N]),_=T.own.filtered+T.installed.filtered+T.global.filtered>=Mw,I=p.useMemo(()=>{const G=te=>{const fe=[];for(const[,oe]of te){const ve=[...oe].sort((de,je)=>de.skill.localeCompare(je.skill));fe.push(...ve)}return fe};return S?[...G(T.own.byPlugin),...G(T.installed.byPlugin),...G(T.global.byPlugin)]:[...G(J.byPlugin),...G($.byPlugin)]},[S,T.own.byPlugin,T.installed.byPlugin,T.global.byPlugin,J.byPlugin,$.byPlugin]),V=p.useMemo(()=>a?I.findIndex(G=>G.plugin===a.plugin&&G.skill===a.skill):-1,[I,a]),ie=p.useCallback(G=>{if(I.length===0)return;const te=V<0?G>0?0:I.length-1:Math.min(Math.max(V+G,0),I.length-1);s(I[te])},[I,V,s]),M=p.useMemo(()=>{if(!v)return null;const[G,te]=v.split("/");if(!G||!te)return null;const fe=t.find(de=>de.plugin===G&&de.skill===te);if(!fe)return{plugin:G,skill:te,bucket:null,pluginName:null};const oe=fe.source==="plugin"?"plugin":"project",ve=oe==="plugin"?fe.pluginName??G:null;return{plugin:G,skill:te,bucket:oe,pluginName:ve}},[v,t]),Y=p.useRef(null);return p.useEffect(()=>{if(!v){Y.current=null;return}if(Y.current===v)return;const G=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),te=document.querySelector(`[data-skill-id="${G}"]`);te&&(Y.current=v,te.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),sf([{key:"j",handler:()=>ie(1)},{key:"k",handler:()=>ie(-1)},{key:"Enter",handler:()=>{V>=0&&s(I[V])}}],{enabled:!o&&!c}),r.jsxs("div",{"data-testid":"sidebar",style:{display:"flex",flexDirection:"column",minHeight:0,height:"100%",fontFamily:"var(--font-sans)"},children:[y,r.jsx(gw,{value:E,onChange:C}),o&&r.jsx($w,{}),!o&&c&&r.jsx(Vw,{error:c,onRetry:u}),!o&&!c&&S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Mg,{name:ne.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:O,onToggle:q,count:A.availableProject.total+A.availablePersonal.total+A.availablePlugin.total}),!O&&r.jsxs(r.Fragment,{children:[r.jsx(zs,{label:ne.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${k}-available-project-collapsed`,count:A.availableProject.total,filteredCount:E?A.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),children:A.availableProject.filtered===0?r.jsx(zg,{queryActive:!!E,agentId:k}):r.jsx(Ds,{items:A.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(zs,{label:ne.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${k}-available-personal-collapsed`,count:A.availablePersonal.total,filteredCount:E?A.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:A.availablePersonal.filtered===0?r.jsx(Iw,{queryActive:!!E,agentId:k}):r.jsx(Ds,{items:A.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsxs(zs,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-available-plugin-collapsed`,count:A.availablePlugin.total,filteredCount:E?A.availablePlugin.filtered:null,children:[r.jsxs("button",{type:"button",onClick:()=>window.dispatchEvent(new CustomEvent("studio:open-marketplace")),style:{display:"flex",alignItems:"center",gap:6,margin:"4px 14px 6px",padding:"4px 8px",fontSize:11,fontWeight:500,border:"1px dashed var(--color-accent, #2f6f8f)",borderRadius:4,background:"transparent",color:"var(--color-accent, #2f6f8f)",cursor:"pointer"},children:[r.jsx("span",{"aria-hidden":!0,children:"🛒"})," Browse marketplaces…"]}),A.availablePlugin.filtered===0?r.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:"No plugin skills installed yet."}):A.availablePlugin.byPlugin.map(([G,te])=>r.jsx(Ag,{pluginName:G,skills:te,persistKey:`vskill-plugin-available-${G}-collapsed`,headerActionSlot:B?r.jsx(Cw,{pluginName:G,enabled:w.get(G)??!0}):void 0,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`available-${G}`))]})]}),r.jsx(Hw,{}),r.jsx(Mg,{name:ne.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:M?!1:U,onToggle:X,count:A.authoringProject.total+A.authoringPlugin.total,action:{label:"New",title:"Create a new skill (standalone or plugin)",icon:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-create-skill",{detail:{mode:"standalone"}}))}}}),(!U||M)&&r.jsxs(r.Fragment,{children:[r.jsx(zs,{label:ne.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${k}-authoring-project-collapsed`,count:A.authoringProject.total,filteredCount:E?A.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(M==null?void 0:M.bucket)==="project",children:A.authoringProject.filtered===0?r.jsx(Lg,{queryActive:!!E}):r.jsx(Ds,{items:A.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),B&&r.jsx(zs,{label:ne.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${k}-authoring-plugin-collapsed`,count:A.authoringPlugin.total,filteredCount:E?A.authoringPlugin.filtered:null,forceOpen:(M==null?void 0:M.bucket)==="plugin",children:A.authoringPlugin.filtered===0?r.jsxs("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--text-secondary)"},children:["No plugin sources in this project. Add ",r.jsx("code",{children:"<plugin>/.claude-plugin/plugin.json"}),"."]}):A.authoringPlugin.byPlugin.map(([G,te])=>r.jsx(Ag,{pluginName:G,skills:te,persistKey:`vskill-plugin-authoring-${G}-collapsed`,forceOpen:(M==null?void 0:M.bucket)==="plugin"&&M.pluginName===G,renderSkill:fe=>r.jsx(Uo,{skill:fe,isSelected:(a==null?void 0:a.plugin)===fe.plugin&&(a==null?void 0:a.skill)===fe.skill,onSelect:()=>s(fe),onContextMenu:d})},`authoring-${G}`))})]})]}),!o&&!c&&!S&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Rg,{origin:"source",count:J.total,filteredCount:E?J.filtered:null,updateCount:h==null?void 0:h.source,children:J.filtered===0?r.jsx(Lg,{queryActive:!!E}):r.jsx(Ds,{items:J.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})}),r.jsx(Uw,{}),r.jsx(Rg,{origin:"installed",count:$.total,filteredCount:E?$.filtered:null,updateCount:h==null?void 0:h.installed,children:$.filtered===0?r.jsx(zg,{queryActive:!!E}):r.jsx(Ds,{items:$.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:_})})]})]})}function of(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function zs({label:t,storageKey:a,count:s,filteredCount:o,updateCount:c,children:u,forceOpen:d=!1}){const[h,g]=p.useState(()=>of(a)),m=d?!1:h,y=p.useCallback(()=>{g(b=>{const S=!b;if(typeof window<"u")try{window.localStorage.setItem(a,String(S))}catch{}return S})},[a]),v=o!=null&&o!==s?`${o} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("button",{type:"button",onClick:y,"aria-expanded":!m,style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"6px 12px",background:"transparent",border:"none",cursor:"pointer",fontFamily:"var(--font-sans)",textAlign:"left"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:14,fontWeight:700,color:"var(--color-ink, var(--text-primary))",width:16,display:"inline-block",textAlign:"center"},children:m?"▸":"▾"}),r.jsx("span",{style:{fontSize:12,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--text-primary)"},children:t}),r.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",v,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),!m&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function Bw(t){const a=[];for(const[s,o]of t){const c=[...o].sort((u,d)=>u.skill.localeCompare(d.skill));a.push({kind:"header",plugin:s,count:c.length});for(const u of c)a.push({kind:"row",skill:u})}return a}function Ds({items:t,selectedKey:a,onSelect:s,onContextMenu:o,useVirtual:c}){if(c){const u=Bw(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(Xk,{overscan:4,totalCount:u.length,itemContent:d=>{const h=u[d];if(!h)return null;if(h.kind==="header")return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px 4px 14px"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:h.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",h.count,")"]})]});const g=h.skill,m=!!a&&a.plugin===g.plugin&&a.skill===g.skill;return r.jsx(Uo,{skill:g,isSelected:m,onSelect:()=>s(g),onContextMenu:o})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([u,d])=>r.jsx(kw,{plugin:u,skills:d,selectedKey:a,onSelect:s,onContextMenu:o},u))})}function Lg({queryActive:t}){return t?r.jsx(zl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(zl,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(Df,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function zg({queryActive:t,agentId:a}){return t?r.jsx(zl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(zl,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Df,{children:"vskill install <skill>"})," to add one."]})})}function Iw({queryActive:t,agentId:a}){return t?r.jsx(zl,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(zl,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(Df,{children:"vskill install --global <skill>"})," to add one."]})})}function zl({headline:t,body:a}){return r.jsxs("div",{style:{padding:"12px 14px 16px",fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:[r.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:4},children:t}),r.jsx("div",{children:a})]})}function Df({children:t}){return r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",background:"color-mix(in srgb, var(--border-default) 45%, transparent)",padding:"1px 4px",borderRadius:3},children:t})}function Uw(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function Hw(){return r.jsx("div",{"aria-hidden":"true","data-testid":"scope-bold-divider",style:{height:3,background:"var(--color-rule)",boxShadow:"inset 0 1px 0 color-mix(in srgb, var(--color-rule) 50%, transparent)",margin:"12px 0"}})}function $w(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(Nw,{},t))})}function Vw({error:t,onRetry:a}){return r.jsxs("div",{role:"alert",style:{margin:"12px 14px",padding:12,border:"1px solid var(--border-default)",borderRadius:6,background:"var(--bg-canvas)",color:"var(--text-primary)",fontSize:12},children:[r.jsx("div",{style:{fontWeight:600,marginBottom:4},children:"Couldn't load skills."}),r.jsxs("details",{children:[r.jsx("summary",{style:{cursor:"pointer",color:"var(--text-secondary)",fontSize:11,marginBottom:4},children:Pw(t)}),r.jsx("pre",{style:{whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",margin:"6px 0 0"},children:t})]}),a&&r.jsx("button",{type:"button",onClick:a,style:{marginTop:8,background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"4px 10px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry"})]})}function Pw(t){const a=t.split(`
66
+ `)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const vy=240,yy=480,by="vskill-sidebar-width",Vs=320;function _f(t){return Number.isFinite(t)?Math.round(Math.max(vy,Math.min(yy,t))):Vs}function Fw(){try{const t=localStorage.getItem(by);if(!t)return Vs;const a=Number(t);return Number.isFinite(a)?_f(a):Vs}catch{return Vs}}function Gw(t){try{localStorage.setItem(by,String(_f(t)))}catch{}}function Ww({initialWidth:t,onChange:a}){const s=p.useRef({startX:0,startWidth:t,pointerId:null}),o=p.useRef(t);return p.useEffect(()=>{o.current=t},[t]),p.useEffect(()=>{function c(d){if(s.current.pointerId==null||d.pointerId!==s.current.pointerId)return;const h=d.clientX-s.current.startX,g=_f(s.current.startWidth+h);o.current=g,a(g)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,Gw(o.current))}return window.addEventListener("pointermove",c),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[a]),r.jsx("div",{role:"separator","aria-orientation":"vertical","aria-valuemin":vy,"aria-valuemax":yy,"aria-valuenow":t,"aria-label":"Resize sidebar",title:"Drag to resize sidebar",onPointerDown:c=>{const u=c.currentTarget;s.current.startX=c.clientX,s.current.startWidth=o.current,s.current.pointerId=c.pointerId;try{u.setPointerCapture(c.pointerId)}catch{}},style:{width:4,alignSelf:"stretch",cursor:"col-resize",background:"var(--border-default)",userSelect:"none",touchAction:"none"}})}function qw({connected:t,hint:a,onRetry:s}){return t?null:r.jsxs("aside",{"aria-live":"assertive",role:"alert",style:{display:"flex",alignItems:"center",gap:10,padding:"6px 12px",background:"color-mix(in srgb, var(--status-own) 15%, transparent)",borderBottom:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--status-own)",display:"inline-block",flexShrink:0}}),r.jsx("span",{style:{fontWeight:500},children:"Disconnected — reconnecting…"}),a&&r.jsx("span",{style:{color:"var(--text-secondary)",fontSize:11},children:a}),r.jsx("div",{style:{flex:1}}),s&&r.jsx("button",{type:"button",onClick:s,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-primary)",cursor:"pointer",fontSize:11,fontFamily:"var(--font-sans)"},children:"Retry now"})]})}function jy(t,a){if(t!==401||typeof window>"u"||!a||typeof a!="object")return;const s=a;s.error==="invalid_api_key"&&(s.provider!=="anthropic"&&s.provider!=="openai"&&s.provider!=="openrouter"||window.dispatchEvent(new CustomEvent("studio:api-key-error",{detail:{provider:s.provider}})))}function Sy(t){if(t!==void 0)try{return JSON.stringify(t)}catch(a){console.error("Failed to serialize request body:",a);try{const s=new WeakSet;return JSON.stringify(t,(o,c)=>{if(typeof c=="object"&&c!==null){if(s.has(c))return"[Circular]";s.add(c)}return c})}catch{return JSON.stringify({error:"Request body could not be serialized"})}}}function Md(){const[t,a]=p.useState([]),[s,o]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(null),g=p.useRef(null),m=p.useCallback(async(v,b)=>{a([]),o(!0),u(!1),h(null);const S=new AbortController;g.current=S;try{const k=Sy(b),E=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:S.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,z;try{z=await E.json(),z&&typeof z=="object"&&"error"in z&&typeof z.error=="string"&&(B=z.error)}catch{}throw jy(E.status,z),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:z}=await C.read();if(B)break;T+=N.decode(z,{stream:!0});const F=T.split(`
67
+ `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),D={event:A,data:O};A==="done"?(u(!0),a(U=>[...U,D])):a(U=>[...U,D])}catch{}A=""}}}catch(k){k.name!=="AbortError"&&h(k.message)}finally{o(!1),g.current=null}},[]),y=p.useCallback(()=>{var v;(v=g.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:y}}function Yw(t){const a=p.useRef(t);a.current=t;const[s,o]=p.useState(new Set),c=p.useRef(new Map),u=p.useCallback(async(m,y,v)=>{var S;(S=c.current.get(m))==null||S.abort();const b=new AbortController;c.current.set(m,b),o(k=>{const E=new Set(k);return E.add(m),E});try{const k=Sy(v),E=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:k,signal:b.signal});if(!E.ok||!E.body){let B=`HTTP ${E.status}`,z;try{z=await E.json(),z&&typeof z=="object"&&"error"in z&&typeof z.error=="string"&&(B=z.error)}catch{}throw jy(E.status,z),new Error(B)}const C=E.body.getReader(),N=new TextDecoder;let T="",A="";for(;;){const{done:B,value:z}=await C.read();if(B)break;T+=N.decode(z,{stream:!0});const F=T.split(`
68
+ `);T=F.pop()||"";for(const w of F)if(w.startsWith("event: "))A=w.slice(7).trim();else if(w.startsWith("data: ")){try{const O=JSON.parse(w.slice(6)),D={event:A,data:O};a.current.onEvent(m,D)}catch{}A=""}}a.current.onDone(m)}catch(k){k.name!=="AbortError"&&a.current.onError(m,k.message)}finally{o(k=>{const E=new Set(k);return E.delete(m),E}),c.current.delete(m)}},[]),d=p.useCallback(m=>{var y;(y=c.current.get(m))==null||y.abort()},[]),h=p.useCallback(()=>{for(const m of c.current.values())m.abort()},[]),g=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:g}}const Kw={plugin:"",skill:"",skillContent:"",savedContent:"",isDirty:!1,evals:null,evalsError:null,activePanel:"tests",selectedCaseId:null,caseRunStates:new Map,bulkRunActive:!1,runMode:null,latestBenchmark:null,inlineResults:new Map,improveTarget:null,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null,generateEvalsLoading:!1,generateEvalsProgress:[],generateEvalsError:null,regressions:[],iterationCount:0,activationPrompts:"",activationResults:[],activationSummary:null,activationRunning:!1,activationError:null,activationTotalPrompts:0,activationStartedAt:null,activationClassifyingStatus:null,generatingPrompts:!1,generatingPromptsError:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function Xw(t,a){var s,o;switch(a.type){case"SET_LOADING":return{...t,loading:a.loading};case"SET_ERROR":return{...t,error:a.error};case"INIT_DATA":{const c=new Map;if(a.benchmark)for(const d of a.benchmark.cases)c.set(d.eval_id,{status:d.status,passRate:d.pass_rate,errorMessage:d.error_message||void 0,durationMs:d.durationMs,tokens:d.tokens,output:d.output,assertions:d.assertions.map(h=>({assertion_id:h.id,text:h.text,pass:h.pass,reasoning:h.reasoning}))});const u=((o=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:o.id)??null;return{...t,skillContent:a.skillContent,savedContent:a.skillContent,isDirty:!1,evals:a.evals,evalsError:a.evalsError??null,latestBenchmark:a.benchmark,inlineResults:c,selectedCaseId:u,loading:!1,error:null}}case"SET_PANEL":return{...t,activePanel:a.panel};case"SET_CONTENT":return{...t,skillContent:a.content,isDirty:a.content!==t.savedContent};case"CONTENT_SAVED":return{...t,savedContent:t.skillContent,isDirty:!1};case"SET_EVALS":return{...t,evals:a.evals};case"SELECT_CASE":return{...t,selectedCaseId:a.caseId};case"CASE_RUN_START":{const c=new Map(t.caseRunStates);return c.set(a.caseId,{status:"running",startedAt:Date.now(),mode:a.mode}),{...t,caseRunStates:c,runMode:a.mode,activePanel:"run"}}case"CASE_RUN_COMPLETE":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"complete",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,a.result),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_ERROR":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);c.set(a.caseId,{status:"error",mode:u==null?void 0:u.mode});const d=new Map(t.inlineResults);return d.set(a.caseId,{status:"error",errorMessage:a.error,assertions:[]}),{...t,caseRunStates:c,inlineResults:d}}case"CASE_RUN_CANCEL":{const c=new Map(t.caseRunStates),u=c.get(a.caseId);return c.set(a.caseId,{status:"cancelled",mode:u==null?void 0:u.mode}),{...t,caseRunStates:c}}case"BULK_RUN_START":{const c=new Map(t.caseRunStates);for(const u of a.caseIds)c.set(u,{status:"queued",mode:a.mode});return{...t,caseRunStates:c,bulkRunActive:!0,runMode:a.mode,activePanel:"run"}}case"BULK_RUN_COMPLETE":return{...t,bulkRunActive:!1,latestBenchmark:a.benchmark??t.latestBenchmark,iterationCount:t.iterationCount+1};case"CANCEL_ALL":{const c=new Map(t.caseRunStates);for(const[u,d]of c)(d.status==="running"||d.status==="queued")&&c.set(u,{status:"cancelled"});return{...t,caseRunStates:c,bulkRunActive:!1}}case"UPDATE_INLINE_RESULT":{const c=new Map(t.inlineResults);return c.set(a.evalId,a.result),{...t,inlineResults:c}}case"OPEN_IMPROVE":return{...t,improveTarget:a.evalId,activePanel:"editor"};case"CLOSE_IMPROVE":return{...t,improveTarget:null};case"OPEN_AI_EDIT":return{...t,aiEditOpen:!0,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"CLOSE_AI_EDIT":return{...t,aiEditOpen:!1,aiEditLoading:!1,aiEditResult:null,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[],aiEditEvalChanges:[],aiEditEvalSelections:new Map,aiEditEvalsRetry:null};case"AI_EDIT_LOADING":return{...t,aiEditLoading:!0,aiEditError:null,aiEditClassifiedError:null,aiEditProgress:[]};case"AI_EDIT_PROGRESS":return{...t,aiEditProgress:[...t.aiEditProgress,a.entry]};case"AI_EDIT_RESULT":{const c=a.evalChanges??[],u=new Map;for(let d=0;d<c.length;d++)u.set(d,!0);return{...t,aiEditLoading:!1,aiEditResult:{improved:a.improved,reasoning:a.reasoning,evalChanges:c},aiEditEvalChanges:c,aiEditEvalSelections:u}}case"AI_EDIT_ERROR":return{...t,aiEditLoading:!1,aiEditError:a.message,aiEditClassifiedError:a.classified??null};case"GENERATE_EVALS_START":return{...t,generateEvalsLoading:!0,generateEvalsProgress:[],generateEvalsError:null};case"GENERATE_EVALS_PROGRESS":return{...t,generateEvalsProgress:[...t.generateEvalsProgress,a.entry]};case"GENERATE_EVALS_DONE":return{...t,generateEvalsLoading:!1,evals:a.evals};case"GENERATE_EVALS_ERROR":return{...t,generateEvalsLoading:!1,generateEvalsError:a.classified};case"TOGGLE_EVAL_CHANGE":{const c=new Map(t.aiEditEvalSelections);return c.set(a.index,!c.get(a.index)),{...t,aiEditEvalSelections:c}}case"SELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!0);return{...t,aiEditEvalSelections:c}}case"DESELECT_ALL_EVAL_CHANGES":{const c=new Map(t.aiEditEvalSelections);for(const u of c.keys())c.set(u,!1);return{...t,aiEditEvalSelections:c}}case"SET_EVALS_RETRY":return{...t,aiEditEvalsRetry:a.evalsFile};case"SET_REGRESSIONS":return{...t,regressions:a.regressions};case"INCREMENT_ITERATION":return{...t,iterationCount:t.iterationCount+1};case"SET_ACTIVATION_PROMPTS":return{...t,activationPrompts:a.prompts};case"ACTIVATION_START":return{...t,activationRunning:!0,activationResults:[],activationSummary:null,activationError:null,activationClassifyingStatus:null,activationStartedAt:Date.now()};case"ACTIVATION_RESULT":return{...t,activationResults:[...t.activationResults,a.result]};case"ACTIVATION_DONE":return{...t,activationRunning:!1,activationSummary:a.summary,activationClassifyingStatus:null};case"ACTIVATION_CLASSIFYING":return{...t,activationClassifyingStatus:`Classifying prompt ${a.index}/${a.total}...`};case"ACTIVATION_ERROR":return{...t,activationRunning:!1,activationError:a.error,activationClassifyingStatus:null};case"ACTIVATION_RESET":return{...t,activationResults:[],activationSummary:null,activationError:null};case"ACTIVATION_TIMEOUT":return{...t,activationRunning:!1,activationError:"Activation test timed out after 120 seconds"};case"ACTIVATION_CANCEL":return{...t,activationRunning:!1};case"GENERATE_PROMPTS_START":return{...t,generatingPrompts:!0,generatingPromptsError:null};case"GENERATE_PROMPTS_DONE":return{...t,generatingPrompts:!1};case"GENERATE_PROMPTS_ERROR":return{...t,generatingPrompts:!1,generatingPromptsError:a.error};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function Qw(t){if(t==="unit"||t==="integration")return t}function Zw(t,a){const s=a.data;if(a.event==="output_ready"&&(t.output=s.output,s.durationMs!=null&&(t.durationMs=s.durationMs),s.tokens!=null&&(t.tokens=s.tokens)),a.event==="outputs_ready"&&(t.output=s.skillOutput,s.skillDurationMs!=null&&(t.durationMs=s.skillDurationMs),s.skillTokens!=null&&(t.tokens=s.skillTokens)),a.event==="assertion_result"){const o={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===o.assertion_id)||t.assertions.push(o)}a.event==="case_complete"&&(t.status=s.status,t.passRate=s.pass_rate,t.errorMessage=s.error_message||void 0,t.classifiedError=s.classified_error||void 0)}const ky=p.createContext(null);function An(){const t=p.useContext(ky);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function Jw({plugin:t,skill:a,origin:s,children:o}){const c=s==="installed",[u,d]=p.useReducer(Xw,{...Kw,plugin:t,skill:a}),h=p.useRef(new Set),g=p.useRef(new Set),m=p.useRef(new Map),y=p.useCallback((ae,he)=>{let pe=m.current.get(ae);pe||(pe={assertions:[]},m.current.set(ae,pe)),Zw(pe,he),d({type:"UPDATE_INLINE_RESULT",evalId:ae,result:{...pe,assertions:[...pe.assertions]}})},[]),v=p.useCallback(ae=>{if(g.current.has(ae))return;g.current.add(ae);const he=m.current.get(ae)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:ae,result:{...he,assertions:[...he.assertions]}}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=p.useCallback((ae,he)=>{g.current.has(ae)||(g.current.add(ae),d({type:"CASE_RUN_ERROR",caseId:ae,error:he}),h.current.has(ae)&&(h.current.delete(ae),h.current.size===0&&Ce.getLatestBenchmark(t,a).then(pe=>d({type:"BULK_RUN_COMPLETE",benchmark:pe})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:k,stopAll:E}=Yw({onEvent:y,onDone:v,onError:b});p.useEffect(()=>()=>{E()},[E]);const C=p.useCallback(async()=>{try{const ae=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!ae.ok){if(ae.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const he=await ae.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:he.runs||[]})}catch{}},[t,a]);p.useEffect(()=>{let ae=!1;async function he(){try{const[pe,xe,be]=await Promise.allSettled([Ce.getSkillDetail(t,a),Ce.getEvals(t,a),Ce.getLatestBenchmark(t,a)]);if(ae)return;let Be=null,Oe=null;if(xe.status==="fulfilled")Be=xe.value;else{const lt=xe.reason;Oe=(lt==null?void 0:lt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:pe.status==="fulfilled"?pe.value.skillContent:"",evals:Be,evalsError:Oe,benchmark:be.status==="fulfilled"?be.value:null})}catch(pe){ae||d({type:"SET_ERROR",error:pe.message})}}return he(),C(),()=>{ae=!0}},[t,a,C]);const N=p.useCallback(async()=>{if(!c)try{await Ce.applyImprovement(t,a,u.skillContent),d({type:"CONTENT_SAVED"})}catch(ae){d({type:"SET_ERROR",error:ae.message})}},[c,t,a,u.skillContent]),T=p.useCallback(async ae=>{if(!c)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he})}catch(he){d({type:"SET_ERROR",error:he.message})}},[c,t,a]),A=p.useCallback((ae,he="benchmark")=>{if(c)return;const pe=u.caseRunStates.get(ae);if((pe==null?void 0:pe.status)!=="running")if(m.current.delete(ae),g.current.delete(ae),d({type:"CASE_RUN_START",caseId:ae,mode:he}),he==="comparison"){const xe=`/api/skills/${t}/${a}/compare`;S(ae,xe,{eval_ids:[ae]})}else{const xe=`/api/skills/${t}/${a}/benchmark/case/${ae}`;S(ae,xe,he==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),B=p.useCallback((ae="benchmark")=>{var xe;if(c)return;const he=((xe=u.evals)==null?void 0:xe.evals)??[];if(he.length===0)return;const pe=he.map(be=>be.id);for(const be of pe)m.current.delete(be),g.current.delete(be);d({type:"BULK_RUN_START",caseIds:pe,mode:ae}),h.current=new Set(pe);for(const be of pe)if(ae==="comparison")S(be,`/api/skills/${t}/${a}/compare`,{eval_ids:[be]});else{const Be=`/api/skills/${t}/${a}/benchmark/case/${be}`;S(be,Be,ae==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),z=p.useCallback(ae=>{k(ae),d({type:"CASE_RUN_CANCEL",caseId:ae}),h.current.delete(ae),g.current.add(ae)},[k]),F=p.useCallback(()=>{E(),d({type:"CANCEL_ALL"}),h.current.clear()},[E]),w=p.useCallback(async(ae,he)=>{d({type:"OPEN_IMPROVE",evalId:ae})},[]),O=p.useCallback(async(ae,he)=>{try{await Ce.applyImprovement(t,a,he),d({type:"SET_CONTENT",content:he}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),A(ae,"benchmark")}catch(pe){d({type:"SET_ERROR",error:pe.message})}},[t,a,A]),D=Md(),U=p.useRef(null),H=p.useRef(0);p.useEffect(()=>{const ae=D.events;for(let he=H.current;he<ae.length;he++){const pe=ae[he],xe=pe.data;if(pe.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const be=xe.improved,Be=xe.reasoning,Oe=xe.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:be,reasoning:Be,evalChanges:Oe})}if(pe.event==="error"){const be=xe;d({type:"AI_EDIT_ERROR",message:be.description||"Unknown error",classified:be})}}H.current=ae.length},[D.events]),p.useEffect(()=>{D.error&&d({type:"AI_EDIT_ERROR",message:D.error})},[D.error]),p.useEffect(()=>()=>{D.stop()},[D.stop]);const q=p.useCallback(async(ae,he,pe)=>{c||(H.current=0,d({type:"AI_EDIT_LOADING"}),U.current=D.stop,D.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:ae,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:he,model:pe}))},[c,t,a,u.skillContent,u.evals,D]),X=p.useCallback(()=>{D.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[D]),J=p.useCallback(async()=>{const ae=u.aiEditResult;if(ae!=null&&ae.improved)try{if(await Ce.applyImprovement(t,a,ae.improved),d({type:"SET_CONTENT",content:ae.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:pe}=await Ha(async()=>{const{mergeEvalChanges:Be}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Be}},[]),xe=u.evals??{skill_name:a,evals:[]},be=pe(xe,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Be=await Ce.saveEvals(t,a,be);d({type:"SET_EVALS",evals:Be})}catch(Be){d({type:"SET_EVALS_RETRY",evalsFile:be}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Be.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:he.message})}},[t,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),L=p.useCallback(ae=>{d({type:"TOGGLE_EVAL_CHANGE",index:ae})},[]),_=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),I=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),V=p.useCallback(async()=>{const ae=u.aiEditEvalsRetry;if(ae)try{const he=await Ce.saveEvals(t,a,ae);d({type:"SET_EVALS",evals:he}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(he){d({type:"SET_ERROR",error:`Retry failed: ${he.message}`})}},[t,a,u.aiEditEvalsRetry]),ie=p.useCallback(async()=>{try{const ae=await Ce.getSkillDetail(t,a);d({type:"SET_CONTENT",content:ae.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:M}=$a(),Y=Md(),G=p.useRef(0);p.useEffect(()=>{const ae=Y.events;for(let he=G.current;he<ae.length;he++){const pe=ae[he],xe=pe.data;if(pe.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:xe.phase,message:xe.message}}),pe.event==="done"){const be=xe;Ce.saveEvals(t,a,be).then(Be=>d({type:"GENERATE_EVALS_DONE",evals:Be})).catch(Be=>d({type:"SET_ERROR",error:Be.message}))}pe.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:xe})}G.current=ae.length},[Y.events,t,a]),p.useEffect(()=>{Y.error&&d({type:"SET_ERROR",error:Y.error})},[Y.error]),p.useEffect(()=>()=>{Y.stop()},[Y.stop]);const te=p.useCallback(async ae=>{if(c)return;G.current=0,d({type:"GENERATE_EVALS_START"});const he={};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=Qw(ae==null?void 0:ae.testType);pe&&(he.testType=pe),Y.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(he).length>0?he:void 0)},[c,t,a,Y,M]),fe=Md(),oe=p.useRef(0);p.useEffect(()=>()=>{fe.stop()},[fe.stop]),p.useEffect(()=>{const ae=fe.events;for(let he=oe.current;he<ae.length;he++){const pe=ae[he];if(pe.event==="classifying"){const xe=pe.data;d({type:"ACTIVATION_CLASSIFYING",index:xe.index,total:xe.total})}if(pe.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:pe.data}),pe.event==="done"){ve.current&&(clearTimeout(ve.current),ve.current=null);const xe=pe.data;if(xe.error)d({type:"ACTIVATION_ERROR",error:xe.error});else{d({type:"ACTIVATION_DONE",summary:xe});const be={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(M==null?void 0:M.model)||"unknown",provider:(M==null?void 0:M.provider)||"unknown",promptCount:xe.total,summary:{precision:xe.precision,recall:xe.recall,reliability:xe.reliability,tp:xe.tp,tn:xe.tn,fp:xe.fp,fn:xe.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[be,...u.activationHistory??[]]})}}}oe.current=ae.length},[fe.events,M,u.activationHistory]),p.useEffect(()=>{fe.error&&(ve.current&&(clearTimeout(ve.current),ve.current=null),d({type:"ACTIVATION_ERROR",error:fe.error}))},[fe.error]);const ve=p.useRef(null),de=p.useCallback(()=>{ve.current&&(clearTimeout(ve.current),ve.current=null),fe.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[fe]),je=p.useCallback(ae=>{const pe=ae.trim().split(`
69
+ `).filter(Boolean).map(be=>be.startsWith("!")?{prompt:be.slice(1).trim(),expected:"should_not_activate"}:be.startsWith("+")?{prompt:be.slice(1).trim(),expected:"should_activate"}:{prompt:be.trim(),expected:"auto"});oe.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:ae});const xe={prompts:pe};M!=null&&M.provider&&(xe.provider=M.provider),M!=null&&M.model&&(xe.model=M.model),fe.start(`/api/skills/${t}/${a}/activation-test`,xe),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>{fe.stop(),d({type:"ACTIVATION_TIMEOUT"}),ve.current=null},12e4)},[t,a,fe,M]),Re=p.useCallback(async(ae=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const he={count:ae};M!=null&&M.provider&&(he.provider=M.provider),M!=null&&M.model&&(he.model=M.model);const pe=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(he)});if(!pe.ok){let xt=`HTTP ${pe.status}`;try{const _t=await pe.json();_t.error&&(xt=_t.error)}catch{}throw new Error(xt)}const xe=pe.body.getReader(),be=new TextDecoder;let Be="",Oe="",lt=[];for(;;){const{done:xt,value:_t}=await xe.read();if(xt)break;Be+=be.decode(_t,{stream:!0});const Tt=Be.split(`
70
+ `);Be=Tt.pop()||"";for(const Ze of Tt)if(Ze.startsWith("event: "))Oe=Ze.slice(7).trim();else if(Ze.startsWith("data: ")){try{const nt=JSON.parse(Ze.slice(6));if(Oe==="done"){if(nt.error)throw new Error(nt.error);lt=nt.prompts||[]}if(Oe==="error")throw new Error(nt.message||nt.description||"Generation failed")}catch(nt){if(!(nt instanceof SyntaxError))throw nt}Oe=""}}const Nt=lt.map(xt=>`${xt.expected==="should_activate"?"+":"!"}${xt.prompt}`).join(`
71
+ `);d({type:"SET_ACTIVATION_PROMPTS",prompts:Nt}),d({type:"GENERATE_PROMPTS_DONE"})}catch(he){d({type:"GENERATE_PROMPTS_ERROR",error:he.message})}},[t,a,M]),_e=p.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:N,saveEvals:T,runCase:A,runAll:B,cancelCase:z,cancelAll:F,improveForCase:w,applyImproveAndRerun:O,refreshSkillContent:ie,generateEvals:te,runActivationTest:je,cancelActivation:de,generateActivationPrompts:Re,fetchActivationHistory:C,submitAiEdit:q,cancelAiEdit:X,applyAiEdit:J,discardAiEdit:$,toggleEvalChange:L,selectAllEvalChanges:_,deselectAllEvalChanges:I,retryEvalsSave:V}),[u,c,N,T,A,B,z,F,w,O,ie,te,je,de,Re,C,q,X,J,$,L,_,I,V]);return r.jsx(ky.Provider,{value:_e,children:o})}function eC(t){if(!t)return[];const a=t.split(`
72
+ `),s=[];for(const o of a)if(!(o.startsWith("--- ")||o.startsWith("+++ "))){if(o.startsWith("@@")){s.push({type:"header",content:o});continue}if(o.startsWith("+")){s.push({type:"add",content:o.slice(1)});continue}if(o.startsWith("-")){s.push({type:"remove",content:o.slice(1)});continue}(o.startsWith(" ")||o===""&&s.length>0)&&s.push({type:"context",content:o.startsWith(" ")?o.slice(1):""})}return s}function Of({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:o,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[g,m]=p.useState(u),[y,v]=p.useState("unified"),b=p.useRef(null),S=p.useRef(null),k=p.useMemo(()=>eC(t),[t]),E=p.useMemo(()=>{const z=k.filter(w=>w.type==="add").length,F=k.filter(w=>w.type==="remove").length;return{added:z,removed:F}},[k]),C=p.useMemo(()=>{let z=0,F=0;return k.filter(w=>w.type!=="header").map(w=>w.type==="remove"?(z++,{...w,origNum:z,newNum:null}):w.type==="add"?(F++,{...w,origNum:null,newNum:F}):(z++,F++,{...w,origNum:z,newNum:F}))},[k]),N=p.useMemo(()=>{const z=[],F=[];for(const w of C)if(w.type==="remove")z.push(w);else if(w.type==="add")F.push(w);else{for(;z.length<F.length;)z.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<z.length;)F.push({type:"context",content:"",origNum:null,newNum:null});z.push(w),F.push(w)}for(;z.length<F.length;)z.push({type:"context",content:"",origNum:null,newNum:null});for(;F.length<z.length;)F.push({type:"context",content:"",origNum:null,newNum:null});return{left:z,right:F}},[C]),T=p.useCallback(z=>{const F=z==="left"?b.current:S.current,w=z==="left"?S.current:b.current;F&&w&&(w.scrollTop=F.scrollTop)},[]);if(!t||k.length===0)return r.jsxs("div",{className:"rounded-lg p-6 text-center",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"Unable to load diff. Try again."}),h&&r.jsx("button",{onClick:h,className:"btn btn-secondary text-[12px]",children:"Retry"})]});const A=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",B=r.jsxs("div",{className:"rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:[a," → ",s]}),r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",E.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",E.removed]})]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:()=>v(y==="unified"?"side-by-side":"unified"),className:"btn btn-ghost text-[11px]",children:y==="unified"?"Side-by-side":"Unified"}),u&&r.jsx("button",{onClick:()=>m(!g),className:"btn btn-ghost text-[11px]",children:g?"Expand":"Collapse"})]})]}),o&&r.jsx("div",{className:"mx-4 mt-3 px-4 py-2 rounded-lg text-[12px]",style:{background:"var(--accent-muted)",color:"var(--text-secondary)"},children:o}),!g&&(y==="unified"?r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:c,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:C.map((z,F)=>r.jsxs("tr",{style:{background:z.type==="add"?"rgba(34,197,94,0.08)":z.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:z.type==="remove"?"rgba(239,68,68,0.5)":"var(--text-tertiary)",opacity:z.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:z.origNum??""}),r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:z.type==="add"?"rgba(34,197,94,0.5)":"var(--text-tertiary)",opacity:z.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:z.newNum??""}),r.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:z.type==="add"?"var(--green)":z.type==="remove"?"var(--red)":"transparent",borderRight:z.type==="add"?"2px solid var(--green)":z.type==="remove"?"2px solid var(--red)":"2px solid transparent"},children:z.type==="add"?"+":z.type==="remove"?"-":" "}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:z.type==="add"?"var(--green)":z.type==="remove"?"var(--red)":"var(--text-secondary)"},children:z.content||"​"})]},F))})})}):r.jsxs("div",{className:"mx-4 my-4 grid grid-cols-2 gap-0 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{ref:b,style:{maxHeight:c,overflowY:"auto",borderRight:"1px solid var(--border-subtle)"},onScroll:()=>T("left"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.left.map((z,F)=>r.jsxs("tr",{style:{background:z.type==="remove"?"rgba(239,68,68,0.08)":"transparent"},children:[r.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:z.origNum??""}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:z.type==="remove"?"var(--red)":"var(--text-secondary)"},children:z.content||"​"})]},F))})})}),r.jsx("div",{ref:S,style:{maxHeight:c,overflowY:"auto"},onScroll:()=>T("right"),children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:N.right.map((z,F)=>r.jsxs("tr",{style:{background:z.type==="add"?"rgba(34,197,94,0.08)":"transparent"},children:[r.jsx("td",{className:"text-right select-none px-2",style:{width:35,fontSize:10,color:"var(--text-tertiary)",opacity:.6,borderRight:"1px solid var(--border-subtle)"},children:z.newNum??""}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:z.type==="add"?"var(--green)":"var(--text-secondary)"},children:z.content||"​"})]},F))})})})]}))]});return d==="modal"?r.jsx("div",{className:A,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:B})}):B}const Ld="https://verified-skill.com/submit",tC=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function nC(t){if(!t)return Ld;const a=t.trim();return!a||!tC.test(a)?Ld:`${Ld}?repo=${encodeURIComponent(a)}`}const Dg={CERTIFIED:{bg:"var(--yellow-muted)",text:"var(--yellow)"},VERIFIED:{bg:"var(--accent-muted)",text:"var(--accent)"},COMMUNITY:{bg:"var(--surface-3)",text:"var(--text-tertiary)"}};function rC(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function aC(){const{state:t}=An(),{plugin:a,skill:s}=t,o=er(),{refreshSkills:c,updateCount:u}=o,d=p.useMemo(()=>o.state.skills.find(L=>L.plugin===a&&L.skill===s)??null,[o.state.skills,a,s]),h=`versions/${a}/${s}`,g=p.useCallback(()=>Ce.getSkillVersions(a,s),[a,s]),{data:m,loading:y}=ri(h,g),[v,b]=p.useState(null),[S,k]=p.useState(null),[E,C]=p.useState(null),[N,T]=p.useState(!1),[A,B]=p.useState("idle"),[z,F]=p.useState(null),w=p.useRef(null),O=p.useRef(null),D=p.useMemo(()=>(m==null?void 0:m.find(L=>L.isInstalled))??null,[m]),U=p.useMemo(()=>(m==null?void 0:m[0])??null,[m]),H=D&&U&&D.version!==U.version,q=p.useCallback(L=>{v?!S&&L!==v?k(L):(b(L),k(null),C(null)):(b(L),C(null))},[v,S]),X=p.useCallback(async(L,_)=>{T(!0);try{const I=await Ce.getVersionDiff(a,s,L,_);C(I)}catch{C(null)}finally{T(!1)}},[a,s]);p.useEffect(()=>{if(v&&S){const L=m||[],_=L.findIndex(M=>M.version===v),I=L.findIndex(M=>M.version===S),[V,ie]=_>I?[v,S]:[S,v];X(V,ie)}},[v,S,m,X]);const J=p.useCallback(()=>{!D||!U||(b(D.version),k(U.version))},[D,U]),$=p.useCallback(async()=>{B("updating"),F(null);const L=new AbortController;w.current=L;try{const _=await Ce.postSkillUpdate(a,s,L.signal);if(_.ok)B("done"),c(),Tn(h);else{const I=`Update failed (HTTP ${_.status}): ${_.body||"no response body"}`;B("error"),F(I)}}catch(_){if(_ instanceof DOMException&&_.name==="AbortError")return;const I=_ instanceof Error?_.message:"Network error";B("error"),F(I)}finally{w.current===L&&(w.current=null)}},[a,s,h,c]);if(p.useEffect(()=>()=>{var L;(L=w.current)==null||L.abort(),w.current=null},[]),y)return r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-40 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"}),r.jsx("div",{className:"skeleton h-14 rounded-lg"})]})]});if(!m||m.length===0){if((d==null?void 0:d.origin)==="source"){const _=nC((d==null?void 0:d.homepage)??null);return r.jsxs("div",{className:"flex flex-col items-center justify-center h-full py-16 px-8","data-testid":"versions-empty-state-local",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"No published versions yet"}),r.jsx("div",{className:"text-[13px] text-center mb-5 max-w-md",style:{color:"var(--text-tertiary)",lineHeight:1.5},children:"This skill is local-only — the version history shown here is sourced from verified-skill.com. Submit your skill to start tracking versions and share it with others."}),r.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary text-[12px]","data-testid":"versions-empty-state-cta",children:"Submit on verified-skill.com"})]})}return d!=null&&d.version?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"text-[14px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsxs("div",{"data-testid":"version-row-local",className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg",style:{background:"transparent",border:"1px solid transparent"},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:10,height:10,background:"var(--accent)",border:"2px solid var(--accent)"}}),r.jsx("div",{className:"flex items-center justify-between",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:d.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"LOCAL"}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]})}),r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Local-only — this skill is not registered on verified-skill.com, so no upstream history is available."})]})]})]}):r.jsx("div",{className:"flex flex-col items-center justify-center h-full py-16","data-testid":"versions-empty-state-installed",children:r.jsx("div",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No version history available"})})}return r.jsxs("div",{className:"p-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Version History"}),r.jsxs("div",{className:"flex items-center gap-2",children:[H&&r.jsx("button",{onClick:J,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),H&&A!=="done"&&(A==="error"?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--red)"},children:z||"Update failed"}),r.jsx("button",{onClick:$,className:"btn btn-secondary text-[11px]",children:"Retry"})]}):r.jsx("button",{onClick:$,disabled:A!=="idle",className:"btn btn-primary text-[11px]",children:A==="idle"?`Update to ${U==null?void 0:U.version}`:A==="updating"?"Starting update...":A==="scanning"?"Scanning...":"Installing..."})),u>1&&r.jsxs("button",{onClick:()=>{window.location.hash="#/updates"},className:"text-[11px] hover:underline",style:{color:"var(--text-tertiary)",background:"transparent",border:"none",cursor:"pointer"},children:["Manage all updates (",u,")"]})]})]}),v&&!S&&r.jsxs("div",{className:"text-[11px] mb-3 px-3 py-2 rounded-lg",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:["Click another version to compare with ",v]}),r.jsxs("div",{className:"relative",children:[r.jsx("div",{className:"absolute left-3 top-0 bottom-0",style:{width:2,background:"var(--border-subtle)"}}),r.jsx("div",{className:"space-y-1",children:m.map(L=>{const _=Dg[L.certTier]||Dg.COMMUNITY,I=L.version===v||L.version===S,V=L.isInstalled;return r.jsxs("button",{onClick:()=>q(L.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:I?"var(--accent-muted)":"transparent",border:I?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:ie=>{I||(ie.currentTarget.style.background="var(--surface-1)")},onMouseLeave:ie=>{I||(ie.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:V?10:8,height:V?10:8,background:V?"var(--accent)":"var(--surface-3)",border:V?"2px solid var(--accent)":"2px solid var(--border-default)"}}),r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:L.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.bg,color:_.text},children:L.certTier}),V&&r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:"var(--accent-muted)",color:"var(--accent)"},children:"installed"})]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:new Date(L.createdAt).toLocaleDateString()})]}),L.diffSummary&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:rC(L.diffSummary,80)})]},L.version)})}),r.jsx("div",{ref:O,style:{height:1}})]}),N&&r.jsx("div",{className:"mt-4",children:r.jsx("div",{className:"skeleton h-48 rounded-xl"})}),E&&!N&&r.jsx("div",{className:"mt-4",children:r.jsx(Of,{contentDiff:E.contentDiff,fromLabel:E.from,toLabel:E.to,diffSummary:E.diffSummary,renderContext:"inline",onRetry:()=>v&&S&&X(E.from,E.to)})})]})}function lC(t){const a=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!a)return{metadata:{},body:t};const s=a[1],o=a[2].trim(),c={},u=s.split(`
73
+ `);let d="",h=!1;for(const g of u){const m=g.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(m&&d&&h){const b=m[1],S=m[2].trim();let k=c[d];if((typeof k!="object"||Array.isArray(k))&&(k={},c[d]=k),!S)k[b]=[];else{const E=S.match(/^\[(.+)\]$/);E?k[b]=E[1].split(",").map(C=>C.trim().replace(/^["']|["']$/g,"")).filter(Boolean):k[b]=S.replace(/^["']|["']$/g,"")}continue}const y=g.match(/^\s+-\s+(.+)$/);if(y&&d){h=!1;const b=c[d];Array.isArray(b)?b.push(y[1].trim().replace(/^["']|["']$/g,"")):c[d]=[y[1].trim().replace(/^["']|["']$/g,"")];continue}const v=g.match(/^([\w-]+):\s*(.*)$/);if(v){d=v[1];const b=v[2].trim();if(h=!1,!b){c[d]={},h=!0;continue}const S=b.match(/^\[(.+)\]$/);if(S){c[d]=S[1].split(",").map(k=>k.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:o}}function Zo(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=sC(a);return s=s.replace(/```(\w*)\n([\s\S]*?)```/g,'<pre style="background:var(--surface-2);padding:0.75rem;border-radius:6px;overflow-x:auto;font-size:12px;line-height:1.5;margin:0.5rem 0;border:1px solid var(--border-subtle)"><code>$2</code></pre>'),s=s.replace(/^### (.+)$/gm,'<div style="font-weight:600;font-size:14px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^## (.+)$/gm,'<div style="font-weight:700;font-size:15px;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/^# (.+)$/gm,'<div style="font-weight:700;font-size:1rem;margin:0.75rem 0 0.25rem;color:var(--text-primary)">$1</div>'),s=s.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" target="_blank" rel="noopener noreferrer" style="color:var(--accent);text-decoration:underline">$1</a>'),s=s.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),s=s.replace(/\*([^*]+)\*/g,"<em>$1</em>"),s=s.replace(/`([^`]+)`/g,'<code style="background:var(--surface-3);padding:0.1rem 0.3rem;border-radius:3px;font-size:0.85em">$1</code>'),s=s.replace(/^- (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">• $1</div>'),s=s.replace(/^(\d+)\. (.+)$/gm,'<div style="padding-left:1rem;margin:0.15rem 0">$1. $2</div>'),s=s.replace(/\n\n/g,'<div style="height:0.5rem"></div>'),s=s.replace(/\n/g,"<br/>"),s}catch{return`<pre style="white-space:pre-wrap;font-size:12px;line-height:1.5">${t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}</pre>`}}function sC(t){const a=t.split(`
74
+ `),s=[];let o=0;for(;o<a.length;)if(a[o].trim().startsWith("|")&&o+1<a.length&&a[o+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(a[o+1])){const c=_g(a[o]);o+=2;const u=[];for(;o<a.length&&a[o].trim().startsWith("|");)u.push(_g(a[o])),o++;const d='style="text-align:left;padding:0.4rem 0.6rem;font-weight:600;font-size:12px;color:var(--text-primary);border-bottom:1px solid var(--border-default)"',h='style="padding:0.4rem 0.6rem;font-size:12px;color:var(--text-secondary);border-bottom:1px solid var(--border-subtle)"';let g='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';g+="<thead><tr>";for(const m of c)g+=`<th ${d}>${m}</th>`;g+="</tr></thead><tbody>";for(const m of u){g+="<tr>";for(const y of m)g+=`<td ${h}>${y}</td>`;g+="</tr>"}g+="</tbody></table>",s.push(g)}else s.push(a[o]),o++;return s.join(`
75
+ `)}function _g(t){return t.split("|").map(a=>a.trim()).filter(a=>a.length>0)}function Jo(t,a){const s=t.split(`
76
+ `),o=a.split(`
77
+ `);if(s.length>1e3||o.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=o.length,d=Array.from({length:c+1},()=>new Array(u+1).fill(0));for(let y=1;y<=c;y++)for(let v=1;v<=u;v++)s[y-1]===o[v-1]?d[y][v]=d[y-1][v-1]+1:d[y][v]=Math.max(d[y-1][v],d[y][v-1]);const h=[];let g=c,m=u;for(;g>0||m>0;)g>0&&m>0&&s[g-1]===o[m-1]?(h.push({type:"unchanged",content:s[g-1]}),g--,m--):m>0&&(g===0||d[g][m-1]>=d[g-1][m])?(h.push({type:"added",content:o[m-1]}),m--):(h.push({type:"removed",content:s[g-1]}),g--);return h.reverse()}function iC(t,a){if(a&&new Set(["generating","comparing","judging","judging_assertion","preparing","parsing","generating_skill","generating_baseline","scoring","action_items"]).has(t))return r.jsx("div",{className:"spinner",style:{width:10,height:10,flexShrink:0}});const o=new Set(["generating","comparing","preparing","generating_skill","generating_baseline","scoring","action_items"]);return r.jsx("div",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{background:o.has(t)?"var(--accent)":"var(--green)"}})}function ai({entries:t,isRunning:a}){const[s,o]=p.useState(!1),c=p.useRef(null);return p.useEffect(()=>{c.current&&!s&&(c.current.scrollTop=c.current.scrollHeight)},[t,s]),t.length===0&&!a?null:r.jsxs("div",{className:"mt-2 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("button",{onClick:()=>o(!s),className:"w-full flex items-center justify-between px-3 py-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:u=>{u.currentTarget.style.color="var(--text-primary)"},onMouseLeave:u=>{u.currentTarget.style.color="var(--text-tertiary)"},children:[r.jsxs("span",{className:"flex items-center gap-2",children:[a&&r.jsx("div",{className:"spinner",style:{width:10,height:10}}),"Progress Log (",t.length,")"]}),r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{transform:s?"rotate(0)":"rotate(180deg)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),!s&&r.jsx("div",{ref:c,className:"px-3 pb-3 space-y-1 max-h-48 overflow-y-auto",children:t.map((u,d)=>{const h=d===t.length-1&&a,g=d===0?"0s":`+${((u.timestamp-t[0].timestamp)/1e3).toFixed(1)}s`;return r.jsxs("div",{className:"flex items-center gap-2 text-[11px] animate-fade-in",style:{opacity:h?1:.7},children:[iC(u.phase,h),r.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:g}),r.jsx("span",{style:{color:h?"var(--text-primary)":"var(--text-secondary)"},children:u.message}),u.current!=null&&u.total!=null&&r.jsxs("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)"},children:["[",u.current,"/",u.total,"]"]})]},d)})})]})}const Og={rate_limit:{icon:"⏱",color:"var(--amber, #f59e0b)"},context_window:{icon:"⚠",color:"var(--amber, #f59e0b)"},auth:{icon:"🔒",color:"var(--red, #ef4444)"},timeout:{icon:"⌛",color:"var(--amber, #f59e0b)"},model_not_found:{icon:"🔍",color:"var(--red, #ef4444)"},provider_unavailable:{icon:"⚡",color:"var(--red, #ef4444)"},parse_error:{icon:"❓",color:"var(--amber, #f59e0b)"},unknown:{icon:"❌",color:"var(--red, #ef4444)"}};function ec({error:t,onRetry:a,onDismiss:s}){const[o,c]=p.useState(null),u=p.useRef(null);p.useEffect(()=>(t.category==="rate_limit"&&t.retryAfterMs?c(Math.ceil(t.retryAfterMs/1e3)):c(null),()=>{u.current&&clearInterval(u.current)}),[t]),p.useEffect(()=>{if(!(o==null||o<=0))return u.current=setInterval(()=>{c(g=>g==null||g<=1?(u.current&&clearInterval(u.current),0):g-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[o!=null&&o>0]);const d=Og[t.category]||Og.unknown,h=o!=null&&o>0;return r.jsxs("div",{className:"rounded-lg overflow-hidden animate-fade-in",style:{border:`1px solid color-mix(in srgb, ${d.color} 30%, transparent)`,background:`color-mix(in srgb, ${d.color} 6%, var(--surface-1))`},children:[r.jsxs("div",{className:"flex items-center justify-between px-3.5 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{style:{fontSize:14},children:d.icon}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:d.color},children:t.title})]}),s&&r.jsx("button",{onClick:s,className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-3.5 pb-3",children:[r.jsx("p",{className:"text-[11.5px] mb-1.5",style:{color:"var(--text-secondary)"},children:t.description}),r.jsx("p",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.hint}),(a||o!=null)&&r.jsx("div",{className:"flex items-center gap-2 mt-2.5",children:a&&r.jsx("button",{onClick:a,disabled:h,className:"btn btn-secondary text-[11px]",style:{padding:"4px 10px",opacity:h?.5:1},children:h?`Retry in ${o}s`:"Retry"})})]})]})}function oC({plugin:t,skill:a,skillContent:s,onApplied:o}){const[c,u]=p.useState("closed"),{config:d}=$a(),[h,g]=p.useState("claude-cli"),[m,y]=p.useState("opus"),[v,b]=p.useState([]),[S,k]=p.useState(""),[E,C]=p.useState(""),[N,T]=p.useState(null),[A,B]=p.useState(null),[z,F]=p.useState([]),[w,O]=p.useState(!1),D=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(_=>_.id==="claude-cli"&&_.available)&&(g("claude-cli"),y("opus"))},[d]),p.useEffect(()=>()=>{var L;(L=D.current)==null||L.abort()},[]);function U(){return d==null?void 0:d.providers.find(L=>L.id===h&&L.available)}const H=p.useCallback(()=>{var L;(L=D.current)==null||L.abort(),u("open")},[]);async function q(){u("loading"),T(null),B(null),F([]);const L=new AbortController;D.current=L;try{const _=await fetch(`/api/skills/${encodeURIComponent(t)}/${encodeURIComponent(a)}/improve?sse`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:h,model:m}),signal:L.signal});if(!_.ok||!_.body){let Y=`HTTP ${_.status}`;try{const G=await _.json();G.error&&(Y=G.error)}catch{}throw new Error(Y)}const I=_.body.getReader(),V=new TextDecoder;let ie="",M="";for(;;){const{done:Y,value:G}=await I.read();if(Y)break;ie+=V.decode(G,{stream:!0});const te=ie.split(`
78
+ `);ie=te.pop()||"";for(const fe of te)if(fe.startsWith("event: "))M=fe.slice(7).trim();else if(fe.startsWith("data: ")){try{const oe=JSON.parse(fe.slice(6));M==="progress"?F(ve=>[...ve,{phase:oe.phase,message:oe.message,timestamp:Date.now()}]):M==="done"||M==="complete"?(k(oe.improved),C(oe.reasoning||""),b(Jo(oe.original||s,oe.improved)),u("diff_shown")):M==="error"&&(T(oe.message||oe.description||"Unknown error"),oe.category&&B(oe),u("open"))}catch{}M=""}}}catch(_){_.name!=="AbortError"&&(T(_.message),u("open"))}finally{D.current=null}}async function X(){O(!0);try{await Ce.applyImprovement(t,a,S),o(S),u("closed")}catch(L){T(L.message)}finally{O(!1)}}function J(){u("closed"),b([]),k(""),C(""),T(null)}if(c==="closed")return r.jsxs("button",{onClick:()=>u("open"),className:"btn btn-secondary mb-5",disabled:!s,children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]}),"Improve Skill"]});const $=U();return r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden animate-fade-in",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Skill Improvement"})]}),r.jsx("button",{onClick:J,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:L=>{L.currentTarget.style.background="var(--surface-3)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-5 py-4",children:[(c==="open"||c==="loading")&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-end gap-3 mb-4",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:h,onChange:L=>{g(L.target.value);const _=d==null?void 0:d.providers.find(I=>I.id===L.target.value);_!=null&&_.models[0]&&y(_.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(L=>L.available).map(L=>r.jsx("option",{value:L.id,children:L.label},L.id))})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[12px] py-1.5",value:m,onChange:L=>y(L.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(L=>r.jsx("option",{value:L.id,children:L.label},L.id))})]}),c==="loading"?r.jsx("button",{onClick:H,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:q,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&z.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(ai,{entries:z,isRunning:!0})})]}),N&&r.jsx("div",{className:"mb-4",children:A?r.jsx(ec,{error:A,onRetry:q,onDismiss:()=>{T(null),B(null)}}):r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:N})}),c==="diff_shown"&&r.jsxs(r.Fragment,{children:[E&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),E]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((L,_)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:L.type==="added"?"rgba(34,197,94,0.1)":L.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:L.type==="added"?"var(--green)":L.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:L.type==="added"?"3px solid var(--green)":L.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:L.type==="added"?"+":L.type==="removed"?"-":" "}),L.content]},_))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:X,disabled:w,className:"btn btn-primary",children:w?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{width:12,height:12}})," Applying..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Apply"]})}),r.jsx("button",{onClick:J,className:"btn btn-secondary",children:"Discard"})]})]})]})]})}const Bg={remove:{bg:"var(--red-muted)",color:"var(--red)",label:"REMOVE"},modify:{bg:"rgba(251,191,36,0.15)",color:"#fbbf24",label:"MODIFY"},add:{bg:"var(--green-muted)",color:"var(--green)",label:"ADD"}},cC={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function uC({change:t,index:a,selected:s,onToggle:o,originalEval:c}){var v;const[u,d]=p.useState(!1),h=Bg[t.action]??Bg.add,g=cC[t.action]??"var(--border-subtle)",m=t.action==="remove"?(c==null?void 0:c.name)??`Eval #${t.evalId}`:((v=t.eval)==null?void 0:v.name)??"Unnamed",y=p.useCallback(()=>o(a),[o,a]);return r.jsxs("div",{className:"rounded-lg transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderLeft:`3px solid ${g}`,opacity:s?1:.5},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[r.jsx("input",{type:"checkbox",checked:s,onChange:y,className:"flex-shrink-0",style:{accentColor:"var(--accent)"}}),r.jsx("span",{className:"pill text-[9px] font-bold flex-shrink-0",style:{background:h.bg,color:h.color,padding:"1px 6px"},children:h.label}),r.jsx("span",{className:"text-[12px] font-medium truncate",style:{color:"var(--text-primary)"},children:m}),r.jsx("span",{className:"text-[11px] truncate flex-1",style:{color:"var(--text-tertiary)"},children:t.reason}),r.jsx("button",{onClick:()=>d(!u),className:"flex-shrink-0 w-5 h-5 flex items-center justify-center rounded transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-3)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},children:r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:u?"rotate(90deg)":"rotate(0)",transition:"transform 0.15s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})})]}),u&&r.jsxs("div",{className:"px-4 pb-3 animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)"},children:[t.action==="add"&&t.eval&&r.jsx(dC,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(fC,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(pC,{evalCase:c})]})]})}function dC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(cf,{label:"Prompt",value:t.prompt}),r.jsx(cf,{label:"Expected",value:t.expected_output}),r.jsxs("div",{children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((a=t.assertions)==null?void 0:a.length)??0,")"]}),r.jsx("div",{className:"mt-1 space-y-1",children:(t.assertions??[]).map(s=>r.jsxs("div",{className:"text-[11px] flex items-start gap-1.5",style:{color:"var(--text-secondary)"},children:[r.jsx("span",{style:{color:"var(--green)"},children:"+"})," ",s.text]},s.id))})]})]})}function fC({original:t,proposed:a}){const s=[];t.name!==a.name&&s.push({label:"Name",old:t.name,new:a.name}),t.prompt!==a.prompt&&s.push({label:"Prompt",old:t.prompt,new:a.prompt}),t.expected_output!==a.expected_output&&s.push({label:"Expected",old:t.expected_output,new:a.expected_output});const o=t.assertions??[],c=a.assertions??[],u=new Set(o.map(m=>m.text)),d=new Set(c.map(m=>m.text)),h=c.filter(m=>!u.has(m.text)),g=o.filter(m=>!d.has(m.text));return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[s.map(m=>r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:m.label}),r.jsxs("div",{className:"mt-1 text-[11px] font-mono rounded p-2",style:{background:"var(--surface-1)"},children:[r.jsxs("div",{style:{color:"var(--red)",textDecoration:"line-through"},children:["- ",uf(m.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",uf(m.new,120)]})]})]},m.label)),(h.length>0||g.length>0)&&r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Assertions"}),r.jsxs("div",{className:"mt-1 space-y-0.5",children:[g.map(m=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--red)"},children:["- ",m.text]},m.id)),h.map(m=>r.jsxs("div",{className:"text-[11px]",style:{color:"var(--green)"},children:["+ ",m.text]},m.id))]})]}),s.length===0&&h.length===0&&g.length===0&&r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function pC({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(cf,{label:"Prompt",value:t.prompt}),r.jsxs("div",{children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:["Assertions (",((a=t.assertions)==null?void 0:a.length)??0,")"]}),r.jsx("div",{className:"mt-1 space-y-0.5",children:(t.assertions??[]).map(s=>r.jsx("div",{className:"text-[11px]",style:{color:"var(--red)",textDecoration:"line-through"},children:s.text},s.id))})]})]})}function cf({label:t,value:a}){return r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),r.jsx("div",{className:"mt-0.5 text-[11px] p-2 rounded font-mono",style:{background:"var(--surface-1)",color:"var(--text-secondary)",whiteSpace:"pre-wrap"},children:uf(a,300)})]})}function uf(t,a){return t.length>a?t.slice(0,a)+"...":t}const Ig={remove:0,modify:1,add:2};function mC({changes:t,selections:a,currentEvals:s,onToggle:o,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((g,m)=>({change:g,originalIndex:m}));d.sort((g,m)=>(Ig[g.change.action]??2)-(Ig[m.change.action]??2));const h=Array.from(a.values()).filter(Boolean).length;return r.jsxs("div",{className:"mt-3 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"Test Case Changes"}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["(",h,"/",t.length," selected)"]})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("button",{onClick:c,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--accent)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Select All"}),r.jsx("button",{onClick:u,className:"text-[10px] px-2 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:g=>{g.currentTarget.style.background="var(--surface-3)"},onMouseLeave:g=>{g.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),r.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:g,originalIndex:m})=>r.jsx(uC,{change:g,index:m,selected:a.get(m)??!1,onToggle:o,originalEval:g.evalId!=null?s.find(y=>y.id===g.evalId):void 0},m))})]})}function hC(){var L;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:o,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:g,retryEvalsSave:m}=An(),{aiEditLoading:y,aiEditResult:v,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:k,aiEditEvalChanges:E,aiEditEvalSelections:C,aiEditEvalsRetry:N}=t,[T,A]=p.useState(""),{config:B}=$a(),[z,F]=p.useState("claude-cli"),[w,O]=p.useState("opus"),D=p.useRef(null);p.useEffect(()=>{var _;(_=D.current)==null||_.focus()},[]),p.useEffect(()=>{if(!B)return;B.providers.find(I=>I.id==="claude-cli"&&I.available)&&(F("claude-cli"),O("opus"))},[B]);const U=B==null?void 0:B.providers.find(_=>_.id===z&&_.available),H=p.useCallback(()=>{const _=T.trim();!_||y||s(_,z,w)},[T,y,s,z,w]),q=p.useCallback(_=>{_.key==="Enter"&&!_.shiftKey&&(_.preventDefault(),H()),_.key==="Escape"&&(_.preventDefault(),y?u():c())},[H,y,u,c]),X=p.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),J=v?Jo(t.skillContent,v.improved):[],$=((L=t.evals)==null?void 0:L.evals)??[];return r.jsxs("div",{className:"animate-fade-in",style:{background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#a855f7",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M15 4V2"}),r.jsx("path",{d:"M15 16v-2"}),r.jsx("path",{d:"M8 9h2"}),r.jsx("path",{d:"M20 9h2"}),r.jsx("path",{d:"M17.8 11.8L19 13"}),r.jsx("path",{d:"M15 9h.01"}),r.jsx("path",{d:"M17.8 6.2L19 5"}),r.jsx("path",{d:"M11 6.2L9.7 5"}),r.jsx("path",{d:"M3 21l9-9"})]})}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"AI Edit"}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:"Describe what to change — Enter to submit, Esc to dismiss"})]}),r.jsx("button",{onClick:c,className:"w-6 h-6 rounded-md flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:_=>{_.currentTarget.style.background="var(--surface-3)"},onMouseLeave:_=>{_.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),r.jsxs("div",{className:"px-4 py-3",children:[!v&&r.jsxs(r.Fragment,{children:[r.jsx("textarea",{ref:D,value:T,onChange:_=>A(_.target.value),onKeyDown:q,placeholder:"e.g., Add an error handling section...",disabled:y,rows:4,className:"w-full resize-y outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"10px 12px",fontSize:12.5,lineHeight:1.5,fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",minHeight:96,maxHeight:240}}),r.jsxs("div",{className:"flex items-end gap-2.5 mt-2",children:[r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Provider"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:z,onChange:_=>{F(_.target.value);const I=B==null?void 0:B.providers.find(V=>V.id===_.target.value);I!=null&&I.models[0]&&O(I.models[0].id)},disabled:y,style:{width:"100%"},children:B==null?void 0:B.providers.filter(_=>_.available).map(_=>r.jsx("option",{value:_.id,children:_.label},_.id))})]}),r.jsxs("div",{style:{minWidth:200},children:[r.jsx("label",{className:"text-[10px] font-medium mb-0.5 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsx("select",{className:"input-field text-[11px] py-1",value:w,onChange:_=>O(_.target.value),disabled:y,style:{width:"100%"},children:U==null?void 0:U.models.map(_=>r.jsx("option",{value:_.id,children:_.label},_.id))})]}),r.jsx("div",{className:"flex-1"}),y?r.jsx("button",{onClick:u,className:"btn btn-secondary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Cancel"}):r.jsx("button",{onClick:H,disabled:!T.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&k.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(ai,{entries:k,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:S?r.jsx(ec,{error:S,onRetry:X,onDismiss:c}):r.jsx("div",{className:"px-3 py-2.5 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b})}),v&&r.jsxs("div",{className:"animate-fade-in",children:[v.reasoning&&r.jsxs("div",{className:"mb-3 px-3 py-2.5 rounded-lg text-[11.5px]",style:{background:"rgba(168,85,247,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(168,85,247,0.2)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"#a855f7"},children:"AI Reasoning: "}),v.reasoning]}),r.jsx("div",{className:"mb-1",children:r.jsx("span",{className:"text-[11px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"})}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:300,overflowY:"auto"},children:J.map((_,I)=>r.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:_.type==="added"?"rgba(34,197,94,0.1)":_.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:_.type==="added"?"var(--green)":_.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:_.type==="added"?"3px solid var(--green)":_.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:_.type==="added"?"+":_.type==="removed"?"-":" "}),_.content]},I))}),r.jsx(mC,{changes:E,selections:C,currentEvals:$,onToggle:d,onSelectAll:h,onDeselectAll:g}),N&&r.jsxs("div",{className:"mt-3 px-3 py-2.5 rounded-lg text-[12px] flex items-center justify-between",style:{background:"rgba(251,191,36,0.12)",border:"1px solid rgba(251,191,36,0.3)",color:"#fbbf24"},children:[r.jsx("span",{children:"Test case save failed. SKILL.md was saved successfully."}),r.jsx("button",{onClick:m,className:"btn text-[11px]",style:{background:"rgba(251,191,36,0.2)",color:"#fbbf24",padding:"3px 10px"},children:"Retry Save"})]}),r.jsxs("div",{className:"flex gap-2 mt-3",children:[r.jsxs("button",{onClick:o,className:"btn btn-primary text-[11px]",style:{padding:"5px 12px"},children:[r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:c,className:"btn btn-secondary text-[11px]",style:{padding:"5px 12px"},children:"Discard"}),r.jsx("button",{onClick:X,className:"btn btn-ghost text-[11px]",style:{padding:"5px 12px"},children:"Try Again"})]})]})]})]})}function xC(t,a){const[s,o]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,h]=p.useState(null),[g,m]=p.useState(!1),[y,v]=p.useState(null),b=p.useCallback(async()=>{try{const E=await Ce.getSkillFiles(t,a);o(E.files)}catch{o([])}},[t,a]);p.useEffect(()=>{u("SKILL.md"),h(null),v(null),b()},[t,a,b]);const S=p.useCallback(async E=>{if(u(E),E==="SKILL.md"){h(null),v(null);return}m(!0),v(null);try{const C=await Ce.getSkillFile(t,a,E);h(C)}catch(C){v(`Unable to open file: ${C.message}`),h(null)}finally{m(!1)}},[t,a]),k=p.useCallback(()=>{b()},[b]);return{files:s,activeFile:c,secondaryContent:d,loading:g,error:y,selectFile:S,refresh:k,isSkillMd:c==="SKILL.md"}}function gC(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function vC(t){const a=[],s=new Map;for(const o of t){const c=o.path.split("/"),d={name:c[c.length-1],path:o.path,type:o.type,size:o.size,children:[]};s.set(o.path,d)}for(const o of t){const c=o.path.split("/");if(c.length===1){const u=s.get(o.path);u&&a.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),h=s.get(o.path);d&&h&&d.children.push(h)}}return a}function wy({expanded:t}){return r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:t?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Cy(){return r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function yC(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function bC(){return r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"23 4 23 10 17 10"}),r.jsx("polyline",{points:"1 20 1 14 7 14"}),r.jsx("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function Ey({node:t,depth:a,activeFile:s,onSelect:o}){const[c,u]=p.useState(!0),d=t.path===s;return t.type==="dir"?r.jsxs("div",{children:[r.jsxs("button",{onClick:()=>u(!c),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*14}px`,paddingTop:2,paddingBottom:2,background:"none",border:"none",cursor:"pointer",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left"},children:[r.jsx(wy,{expanded:c}),r.jsx(Cy,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>r.jsx(Ey,{node:h,depth:a+1,activeFile:s,onSelect:o},h.path))]}):r.jsxs("button",{onClick:()=>o(t.path),style:{display:"flex",alignItems:"center",gap:4,width:"100%",paddingLeft:`${4+a*14}px`,paddingTop:2,paddingBottom:2,background:d?"var(--accent-muted)":"none",border:"none",cursor:"pointer",color:d?"var(--accent)":"var(--text-tertiary)",fontSize:11,fontFamily:"var(--font-mono, monospace)",textAlign:"left",borderRadius:3},children:[r.jsx("span",{style:{width:10}}),r.jsx(yC,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:gC(t.size)})]})}function jC({files:t,activeFile:a,onSelect:s,onRefresh:o}){const[c,u]=p.useState(!1),d=p.useMemo(()=>vC(t),[t]);return r.jsxs("div",{style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"3px 8px",cursor:"pointer",userSelect:"none"},onClick:()=>u(!c),children:[r.jsx(wy,{expanded:c}),r.jsx(Cy,{}),r.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:a}),r.jsx("button",{onClick:h=>{h.stopPropagation(),o()},style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:"2px 4px",display:"flex",alignItems:"center",borderRadius:3},title:"Refresh file list",children:r.jsx(bC,{})})]}),c&&r.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:d.length===0?r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):d.map(h=>r.jsx(Ey,{node:h,depth:0,activeFile:a,onSelect:s},h.path))})]})}function jo(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function SC(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function kC(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function Ug({content:t}){return r.jsx("textarea",{readOnly:!0,value:t,style:{flex:1,width:"100%",resize:"none",background:"var(--surface-1)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}})}function Hg({content:t,fileType:a}){if(a==="json"){const s=SC(t);return r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s})}return a==="md"?r.jsx("div",{style:{flex:1,overflow:"auto",padding:"16px 20px",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:13,lineHeight:1.6},dangerouslySetInnerHTML:{__html:Zo(t)}}):r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function $g(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"([^"\\]|\\.)*"\s*:/g,s=>`<span style="color:#6383ff">${s}</span>`).replace(/:\s*"([^"\\]|\\.)*"/g,s=>`<span style="color:#22c55e">${s.slice(0,2)}<span style="color:#22c55e">${s.slice(2)}</span></span>`).replace(/:\s*(-?\d+\.?\d*)/g,(s,o)=>`: <span style="color:#fb923c">${o}</span>`).replace(/:\s*(true|false|null)/g,(s,o)=>`: <span style="color:#a855f7">${o}</span>`)}catch{return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}}function wC({file:t,loading:a,error:s,viewMode:o,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[g,m]=p.useState(o),[y,v]=p.useState(!1),[b,S]=p.useState(""),[k,E]=p.useState(!1),[C,N]=p.useState(null),T=o!==g?o:g;p.useEffect(()=>{h==null||h(y)},[y,h]);const A=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),B=p.useCallback(()=>{v(!1)},[]),z=p.useCallback(async()=>{if(!(!c||!u||!t)){E(!0);try{await Ce.saveSkillFile(c,u,t.path,b),N("Saved"),v(!1),d==null||d(),setTimeout(()=>N(null),2e3)}catch(O){N(`Save failed: ${O.message}`),setTimeout(()=>N(null),3e3)}finally{E(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!y)return;const O=D=>{(D.ctrlKey||D.metaKey)&&D.key==="s"&&(D.preventDefault(),z())};return document.addEventListener("keydown",O),()=>document.removeEventListener("keydown",O)},[y,z]),a)return r.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:"Loading…"});if(s)return r.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:r.jsxs("div",{style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"16px 20px",maxWidth:400,textAlign:"center"},children:[r.jsx("div",{style:{fontSize:13,color:"var(--text-primary)",fontWeight:600,marginBottom:6},children:"Unable to open file"}),r.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:s})]})});if(!t)return null;if(t.binary)return r.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-tertiary)",fontSize:13},children:["Binary file (",jo(t.size),") — cannot be displayed"]});const F=t.content??"",w=kC(t.path);return r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[t.truncated&&r.jsxs("div",{style:{padding:"4px 12px",background:"var(--warning-muted, #fef3c7)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:"var(--warning-text, #92400e)"},children:["File truncated at ",jo(512*1024)," — ",jo(t.size)," total"]}),r.jsxs("div",{style:{display:"flex",gap:4,padding:"4px 8px",borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-0)"},children:[(w==="md"||w==="json")&&["raw","split","preview"].map(O=>r.jsx("button",{onClick:()=>m(O),style:{padding:"2px 8px",fontSize:11,background:T===O?"var(--accent-muted)":"none",color:T===O?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer",textTransform:"capitalize"},children:O},O)),r.jsxs("span",{style:{marginLeft:"auto",fontSize:11,color:"var(--text-tertiary)",display:"flex",alignItems:"center",gap:6},children:[jo(t.size),c&&u&&!t.binary&&!y&&r.jsx("button",{onClick:A,style:{padding:"1px 6px",fontSize:10,background:"var(--accent-muted)",color:"var(--accent)",border:"none",borderRadius:3,cursor:"pointer"},children:"Edit"}),y&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:z,disabled:k,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),r.jsx("button",{onClick:B,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),C&&r.jsx("div",{style:{padding:"4px 12px",background:C.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:C.startsWith("Save failed")?"var(--red)":"var(--green)"},children:C}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:y?r.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:[r.jsx("textarea",{value:b,onChange:O=>S(O.target.value),style:{flex:1,width:"100%",resize:"none",background:"var(--surface-0)",color:"var(--text-primary)",border:"none",outline:"none",padding:"12px 16px",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6}}),r.jsxs("div",{style:{position:"sticky",bottom:0,display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--surface-1)",borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("span",{style:{flex:1,fontSize:11,color:"var(--text-tertiary)"},children:"Unsaved changes"}),r.jsx("button",{onClick:z,disabled:k,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:k?.6:1},children:k?"Saving...":"Save"}),r.jsx("button",{onClick:B,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):T==="split"&&w!=="other"?r.jsxs(r.Fragment,{children:[r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",borderRight:"1px solid var(--border-subtle)"},children:r.jsx(Ug,{content:F})}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:w==="json"?r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:$g(F)}}):r.jsx(Hg,{content:F,fileType:w})})]}):T==="preview"&&w!=="other"?w==="json"?r.jsx("pre",{style:{flex:1,margin:0,padding:"12px 16px",overflow:"auto",background:"var(--surface-0)",fontSize:12,fontFamily:"var(--font-mono, monospace)",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:$g(F)}}):r.jsx(Hg,{content:F,fileType:w}):r.jsx(Ug,{content:F})})]})}function CC({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]})}function EC({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"3"}),r.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]})}function NC({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function TC({size:t=15}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M15 4V2"}),r.jsx("path",{d:"M15 16v-2"}),r.jsx("path",{d:"M8 9h2"}),r.jsx("path",{d:"M20 9h2"}),r.jsx("path",{d:"M17.8 11.8L19 13"}),r.jsx("path",{d:"M15 9h.01"}),r.jsx("path",{d:"M17.8 6.2L19 5"}),r.jsx("path",{d:"M11 6.2L9.7 5"}),r.jsx("path",{d:"M3 21l9-9"})]})}function zd({size:t=15}){return r.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 3l1.5 5.5L19 10l-5.5 1.5L12 17l-1.5-5.5L5 10l5.5-1.5L12 3z"})})}function RC(){const{state:t,dispatch:a,saveContent:s,isReadOnly:o}=An(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:g,aiEditOpen:m}=t,[y,v]=p.useState("split"),[b,S]=p.useState(!1),k=p.useRef(null),[E,C]=p.useState(!1),[N,T]=p.useState(""),[A,B]=p.useState(!1),[z,F]=p.useState(null),[w,O]=p.useState([]),[D,U]=p.useState([]),[H,q]=p.useState(null),X=p.useRef(null),{config:J}=$a(),{files:$,activeFile:L,secondaryContent:_,loading:I,error:V,selectFile:ie,refresh:M,isSkillMd:Y}=xC(c??"",u??""),[G,te]=p.useState(!1),fe=p.useCallback(ye=>{G&&!window.confirm("You have unsaved changes. Discard?")||ie(ye)},[G,ie]);p.useEffect(()=>()=>{var ye;(ye=X.current)==null||ye.abort()},[]);const{metadata:oe,body:ve}=lC(d),de=oe["allowed-tools"],je=Array.isArray(de)?de:typeof de=="string"?[de]:[],Re=oe.name,_e=oe.description,ae=oe.metadata,he=typeof ae=="object"&&!Array.isArray(ae)?ae:null,pe=oe.version||(he==null?void 0:he.version),xe=oe.tags||(he==null?void 0:he.tags),be=Array.isArray(xe)?xe:typeof xe=="string"?xe.split(",").map(ye=>ye.trim()).filter(Boolean):[],Be=new Set(["name","description","metadata","allowed-tools","version","tags"]),Oe=Object.entries(oe).filter(([ye])=>!Be.has(ye)),lt=p.useCallback(async()=>{S(!0),await s(),S(!1)},[s]),Nt=p.useCallback(ye=>{(ye.ctrlKey||ye.metaKey)&&ye.key==="s"&&(ye.preventDefault(),ye.stopPropagation(),h&&lt()),(ye.ctrlKey||ye.metaKey)&&ye.key==="k"&&(ye.preventDefault(),ye.stopPropagation(),a({type:m?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,lt,m,a]),xt=p.useCallback(async()=>{var mt,Et;if(!N.trim())return;(mt=X.current)==null||mt.abort();const ye=new AbortController;X.current=ye,B(!0),q(null),U([]),F(null),O([]);try{const Xt=(J==null?void 0:J.provider)||"claude-cli",fn=(J==null?void 0:J.model)||"sonnet",Wt=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:Xt,model:fn}),signal:ye.signal});if(!Wt.ok||!Wt.body){let gt=`HTTP ${Wt.status}`;try{const Wn=await Wt.json();Wn.error&&(gt=Wn.error)}catch{}throw new Error(gt)}const ln=Wt.body.getReader(),Mn=new TextDecoder;let Lt="",vt="";for(;;){const{done:gt,value:Wn}=await ln.read();if(gt)break;Lt+=Mn.decode(Wn,{stream:!0});const zr=Lt.split(`
79
+ `);Lt=zr.pop()||"";for(const dr of zr)if(dr.startsWith("event: "))vt=dr.slice(7).trim();else if(dr.startsWith("data: ")){try{const Rt=JSON.parse(dr.slice(6));if(vt==="progress")U(qt=>[...qt,{phase:Rt.phase,message:Rt.message,timestamp:Date.now()}]);else if(vt==="done"||vt==="complete"){const qt=["---"];Rt.name&&qt.push(`name: ${Rt.name}`),Rt.description&&qt.push(`description: "${Rt.description.replace(/"/g,'\\"')}"`),Rt.model&&qt.push(`model: ${Rt.model}`),(Et=Rt.allowedTools)!=null&&Et.trim()&&qt.push(`allowed-tools: ${Rt.allowedTools.trim()}`),qt.push("---","",Rt.body||"");const Ie=qt.join(`
80
+ `);F(Ie),O(Jo(d,Ie)),B(!1)}else vt==="error"&&(q(Rt.message||Rt.description||"Generation failed"),B(!1))}catch{}vt=""}}}catch(Xt){Xt.name!=="AbortError"&&q(Xt.message)}finally{B(!1),X.current=null}},[N,J,d]),_t=p.useCallback(()=>{z&&a({type:"SET_CONTENT",content:z}),C(!1),F(null),O([]),T(""),U([])},[z,a]),Tt=p.useCallback(()=>{C(!1),F(null),O([]),T(""),U([]),q(null)},[]),Ze=p.useCallback(()=>{var ye;E?((ye=X.current)==null||ye.abort(),Tt()):(m&&a({type:"CLOSE_AI_EDIT"}),C(!0))},[E,m,a,Tt]),nt=[{mode:"raw",icon:r.jsx(CC,{}),label:"Editor"},{mode:"split",icon:r.jsx(EC,{}),label:"Split"},{mode:"preview",icon:r.jsx(NC,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col h-full",onKeyDown:Nt,tabIndex:-1,children:[r.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:nt.map(({mode:ye,icon:mt,label:Et})=>r.jsxs("button",{onClick:()=>v(ye),title:Et,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===ye?"var(--surface-4)":"transparent",color:y===ye?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===ye?600:400,border:"none",cursor:"pointer"},children:[mt,r.jsx("span",{style:{letterSpacing:"0.01em"},children:Et})]},ye))}),Y?o?r.jsx("div",{className:"flex items-center gap-2",children:r.jsxs("span",{className:"flex items-center gap-1.5 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Read-only"]})}):r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("button",{onClick:()=>{m?a({type:"CLOSE_AI_EDIT"}):(E&&Tt(),a({type:"OPEN_AI_EDIT"}))},title:"Edit with AI (Ctrl+K)",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:m?600:400,border:"none",cursor:"pointer",color:m?"var(--purple)":"var(--text-tertiary)",background:m?"var(--purple-muted)":"transparent"},children:[r.jsx(TC,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:Ze,title:"Regenerate skill from prompt",className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"4px 10px",fontSize:11,fontWeight:E?600:400,border:"none",cursor:"pointer",color:E?"var(--purple)":"var(--text-tertiary)",background:E?"var(--purple-muted)":"transparent"},children:[r.jsx(zd,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),h&&r.jsx("button",{onClick:()=>a({type:"SET_CONTENT",content:t.savedContent}),className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Discard"}),r.jsx("button",{onClick:lt,disabled:!h||b,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},children:b?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Saving..."]}):"Save"})]}):null]}),c&&u&&r.jsx(jC,{files:$,activeFile:L,onSelect:fe,onRefresh:M}),!Y&&r.jsx(wC,{file:_,loading:I,error:V,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{ie(L),M()},onDirtyChange:te}),Y&&r.jsxs("div",{className:"flex-1 overflow-hidden",style:{display:"grid",gridTemplateColumns:y==="raw"||y==="preview"?"1fr":"1fr 1fr"},children:[y!=="preview"&&r.jsx("div",{className:"flex flex-col overflow-hidden",style:{borderRight:y==="split"?"1px solid var(--border-subtle)":"none"},children:r.jsx("textarea",{ref:k,value:d,onChange:ye=>{o||a({type:"SET_CONTENT",content:ye.target.value})},onKeyDown:Nt,spellCheck:!1,readOnly:o,className:"flex-1 w-full resize-none outline-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",fontFamily:"var(--font-mono, 'JetBrains Mono', ui-monospace, monospace)",fontSize:12.5,lineHeight:1.7,tabSize:2,border:"none",padding:"16px 20px",opacity:o?.7:1}})}),y!=="raw"&&r.jsx("div",{className:"overflow-auto",style:{background:"var(--surface-0)"},children:r.jsxs("div",{className:"animate-fade-in",style:{padding:"20px 24px",maxWidth:720},children:[(Re||pe||_e)&&r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Re&&r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Re}),pe&&r.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4,letterSpacing:"0.03em",fontFamily:"var(--font-mono, ui-monospace, monospace)"},children:["v",pe]})]}),_e&&r.jsx("p",{style:{fontSize:12.5,lineHeight:1.65,color:"var(--text-secondary)",margin:0,paddingLeft:12,borderLeft:"2px solid var(--accent)",maxWidth:600},children:_e})]}),be.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:be.map(ye=>r.jsx("span",{style:{fontSize:10,fontWeight:500,color:"var(--text-tertiary)",background:"var(--surface-2)",padding:"3px 8px",borderRadius:4,letterSpacing:"0.02em"},children:ye},ye))}),je.length>0&&r.jsx("div",{style:{marginBottom:16},children:r.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",marginRight:4},children:"Tools"}),je.map(ye=>r.jsx("span",{style:{fontSize:10.5,fontFamily:"var(--font-mono, ui-monospace, monospace)",color:"var(--accent)",background:"var(--accent-muted)",padding:"2px 7px",borderRadius:4},children:ye},ye))]})}),Oe.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:Oe.map(([ye,mt],Et)=>{const Xt=Array.isArray(mt)?mt.join(", "):typeof mt=="object"?Object.entries(mt).map(([fn,Wt])=>`${fn}: ${Array.isArray(Wt)?Wt.join(", "):Wt}`).join(" | "):mt;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:Et>0?"1px solid var(--border-subtle)":"none"},children:[r.jsx("span",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"var(--text-tertiary)",minWidth:80,flexShrink:0},children:ye}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Xt})]},ye)})}),(Re||_e||be.length>0||je.length>0||Oe.length>0)&&ve&&r.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),ve&&r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:Zo(ve)}})]})})]}),Y&&m&&r.jsx(hC,{}),Y&&E&&r.jsx("div",{className:"animate-fade-in",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:r.jsxs("div",{className:"px-4 py-3",children:[!z&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(zd,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerate Skill"})]}),r.jsx("div",{className:"flex gap-2 mb-2",children:r.jsx("textarea",{value:N,onChange:ye=>T(ye.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:A,className:"flex-1 px-3 py-2 rounded-lg text-[12px] resize-none",style:{background:"var(--surface-0)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",outline:"none",opacity:A?.5:1},onKeyDown:ye=>{ye.key==="Enter"&&(ye.ctrlKey||ye.metaKey)&&N.trim()&&!A&&(ye.preventDefault(),xt())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[A?r.jsx("button",{onClick:()=>{var ye;(ye=X.current)==null||ye.abort(),B(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:xt,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:Tt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),A&&D.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(ai,{entries:D,isRunning:!0})}),H&&r.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[H,r.jsx("button",{onClick:xt,className:"ml-2 underline",style:{color:"var(--red)"},children:"Retry"})]})]}),z&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsx(zd,{size:14}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:"Regenerated — Review Changes"})]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-3",style:{border:"1px solid var(--border-subtle)",maxHeight:"300px",overflowY:"auto"},children:w.map((ye,mt)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:ye.type==="added"?"var(--green-muted)":ye.type==="removed"?"var(--red-muted)":"transparent",color:ye.type==="added"?"var(--green)":ye.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:ye.type==="added"?"3px solid var(--green)":ye.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:ye.type==="added"?"+":ye.type==="removed"?"-":" "}),ye.content]},mt))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:_t,className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Apply"]}),r.jsx("button",{onClick:Tt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),Y&&g!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(oC,{plugin:c,skill:u,skillContent:d,onApplied:ye=>{a({type:"SET_CONTENT",content:ye}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})})]})}function Rl(t){return t.testType==="integration"?"integration":"unit"}function Dl(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function Ny(t){const a=new Date(t);return a.toLocaleDateString(void 0,{month:"short",day:"numeric"})+", "+a.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function Ty(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const AC=new Set(["benchmark","comparison","baseline"]);function Vg(t,a,s,o){return t.map(({rate:c,idx:u,total:d})=>{const h=o+u/(d-1)*(a-o*2),g=o+(s-o*2)-c*(s-o*2);return`${h},${g}`})}function Ry({entries:t}){const a=t.filter(v=>AC.has(v.type)).slice().reverse(),s=a.map((v,b,S)=>({rate:v.pass_rate,idx:b,total:S.length})).filter((v,b)=>{const S=a[b].type;return S==="benchmark"||S==="comparison"}),o=a.flatMap((v,b)=>v.type==="baseline"?[{rate:v.pass_rate,idx:b,total:a.length}]:v.type==="comparison"&&v.baselinePassRate!=null?[{rate:v.baselinePassRate,idx:b,total:a.length}]:[]);if(s.length<2&&o.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?Vg(s,c,u,d):[],g=o.length>=2?Vg(o,c,u,d):[],m=h[h.length-1],y=g[g.length-1];return r.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[g.length>0&&r.jsx("polyline",{points:g.join(" "),fill:"none",stroke:"var(--text-tertiary)",strokeWidth:1.5,strokeLinejoin:"round",strokeDasharray:"3 2"}),h.length>0&&r.jsx("polyline",{points:h.join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),y&&r.jsx("circle",{cx:parseFloat(y.split(",")[0]),cy:parseFloat(y.split(",")[1]),r:2.5,fill:"var(--text-tertiary)"}),m&&r.jsx("circle",{cx:parseFloat(m.split(",")[0]),cy:parseFloat(m.split(",")[1]),r:2.5,fill:"var(--accent)"})]})}function Ay(t,a,s){const o=isNaN(a)?0:a,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&o>=.7){const m=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): evaluation met expectations.${m}`}}if(t==="FAIL"||t==="DEGRADING"){const m=u.length>0?` Failed criteria: ${u.map(v=>v.criterion).join(", ")}.`:"",y=[...u.map(v=>`Improve "${v.criterion}" (score: ${v.score.toFixed(2)})`),...d.map(v=>`Strengthen "${v.criterion}" (score: ${v.score.toFixed(2)})`)];return y.length===0&&y.push("Review prompt instructions and add more specific guidance"),{explanation:`${t} (score ${o.toFixed(2)}): evaluation did not meet expectations.${m}`,recommendations:y}}if(t==="INEFFECTIVE"){if(o<.2){const y=[...u.map(v=>`Rework "${v.criterion}" — currently at ${v.score.toFixed(2)}`),"Consider adding examples to your system prompt","Review the rubric criteria for achievability"];return{explanation:`${t} (score ${o.toFixed(2)}): evaluation is significantly below expectations.`,recommendations:y}}const m=[...u.map(y=>`Rework "${y.criterion}" — currently at ${y.score.toFixed(2)}`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push("Consider restructuring your prompt approach"),{explanation:`${t} (score ${o.toFixed(2)}): below expectations but showing some capability.`,recommendations:m}}if(t==="MARGINAL"){const m=[...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`),...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Review prompt instructions for areas of improvement"),{explanation:`${t} (score ${o.toFixed(2)}): moderate improvement detected.`,recommendations:m}}if(t==="EMERGING"){const m=[...u.map(y=>`Improve "${y.criterion}" (score: ${y.score.toFixed(2)})`),...d.map(y=>`Strengthen "${y.criterion}" (score: ${y.score.toFixed(2)})`)];return m.length===0&&m.push(c.length>0?"Assertion pass rate is below target despite strong rubric scores — review test case alignment":"Add more specific guidance to your prompt instructions"),{explanation:`${t} (score ${o.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:m}}const h=c.length>0?` Passing: ${c.map(m=>m.criterion).join(", ")}.`:"",g=d.length>0?` Needs improvement: ${d.map(m=>m.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${o.toFixed(2)}): mixed results.${h}${g}`}}const My={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function MC(t){return Object.hasOwn(My,t)}function LC(t){return MC(t)?My[t]:t}function zC(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=p.useState([]),[u,d]=p.useState([]),[h,g]=p.useState(!0),[m,y]=p.useState(null),[v,b]=p.useState(new Set),[S,k]=p.useState({}),[E,C]=p.useState(null),[N,T]=p.useState(""),[A,B]=p.useState(!1),[z,F]=p.useState(""),[w,O]=p.useState(""),D=p.useCallback(async()=>{g(!0),y(null);try{const[$,L]=await Promise.all([Ce.getCredentials(a,s),Ce.getParams(a,s)]);c($.credentials),d(L.params)}catch($){y($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{g(!1)}},[a,s]);p.useEffect(()=>{D()},[D]);const U=p.useCallback(async($,L)=>{B(!0),y(null);try{await Ce.setCredential(a,s,$,L),C(null),T(""),await D()}catch(_){y(_ instanceof Error?_.message:`Failed to save ${$}`)}finally{B(!1)}},[a,s,D]),H=p.useCallback(async()=>{const $=z.trim().toUpperCase(),L=w.trim();if(!(!$||!L)){B(!0),y(null);try{await Ce.setCredential(a,s,$,L),F(""),O(""),await D()}catch(_){y(_ instanceof Error?_.message:`Failed to add ${$}`)}finally{B(!1)}}},[a,s,z,w,D]),q=p.useCallback(async $=>{if(v.has($)){b(L=>{const _=new Set(L);return _.delete($),_}),k(L=>{const _={...L};return delete _[$],_});return}try{const _=(await Ce.getParamsRevealed(a,s,$)).params.find(I=>I.name===$);_!=null&&_.value&&(k(I=>({...I,[$]:_.value})),b(I=>new Set(I).add($)))}catch{}},[a,s,v]),X=new Set(o.map($=>$.name)),J=[...o.map($=>{const L=u.find(_=>_.name===$.name);return{name:$.name,status:$.status,maskedValue:(L==null?void 0:L.maskedValue)??""}}),...u.filter($=>!X.has($.name)).map($=>({name:$.name,status:$.status,maskedValue:$.maskedValue}))];return r.jsxs("div",{className:"py-2 px-3",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters"}),m&&r.jsx("div",{className:"text-[10px] px-2 py-1.5 rounded mb-2",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},role:"alert",children:m}),h&&J.length===0&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"Loading..."}),!h&&J.length===0&&!m&&r.jsx("div",{className:"text-[11px] py-2",style:{color:"var(--text-tertiary)"},children:"No parameters configured"}),J.map($=>r.jsxs("div",{className:"flex items-center gap-2 py-1.5",style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("span",{className:"text-[10px] font-mono flex-1 truncate",style:{color:"var(--text-primary)"},children:$.name}),r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:$.status==="ready"?"var(--green-muted)":"var(--red-muted)",color:$.status==="ready"?"var(--green)":"var(--red)"},children:$.status}),($.maskedValue||$.status==="ready")&&r.jsxs("span",{className:"text-[10px] font-mono",style:{color:"var(--text-secondary)"},children:[v.has($.name)?S[$.name]??$.maskedValue:$.maskedValue||"***",r.jsx("button",{onClick:()=>q($.name),className:"text-[9px] ml-1",style:{color:"var(--accent)",cursor:"pointer",background:"none",border:"none"},"aria-label":`${v.has($.name)?"Hide":"Reveal"} value for ${$.name}`,children:v.has($.name)?"hide":"show"})]}),E===$.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:N,onChange:L=>T(L.target.value),onKeyDown:L=>{L.key==="Enter"&&N.trim()&&U($.name,N)},className:"input-field text-[10px] font-mono",style:{width:120},placeholder:"New value...","aria-label":`New value for ${$.name}`,autoFocus:!0}),r.jsx("button",{onClick:()=>U($.name,N),disabled:A||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{C(null),T("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{C($.name),T("")},className:"text-[10px]",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"Edit"})]},$.name)),r.jsxs("div",{className:"mt-3 pt-2",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-medium mb-1.5",style:{color:"var(--text-secondary)"},children:"Add New Parameter"}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:z,onChange:$=>F($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),r.jsx("input",{value:w,onChange:$=>O($.target.value),onKeyDown:$=>{$.key==="Enter"&&z.trim()&&w.trim()&&H()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),r.jsx("button",{onClick:H,disabled:A||!z.trim()||!w.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:A?"not-allowed":"pointer"},children:"Add"})]})]})]})}const _s="This is an installed copy (read-only). Open the source skill to edit.";function DC(t,a,s){const[o,c]=p.useState(null),[u,d]=p.useState(!1),h=p.useRef("");p.useEffect(()=>{const m=`${t}/${a}/${s}`;h.current!==m&&(h.current=m,d(!0),Ce.getCaseHistory(t,a,s).then(y=>c(y)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const g=p.useCallback(()=>{d(!0),h.current="",Ce.getCaseHistory(t,a,s).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:o,loading:u,refetch:g}}function _C(t,a,s){const o={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return o;const u=s.slice(0,10).map(g=>g.assertions.find(m=>m.id===t)).filter(Boolean);if(u.length>=2){const m=u.filter(y=>y.pass).length/u.length;m>=.3&&m<=.7&&(o.flaky=!0)}const d=s.find(g=>g.type==="benchmark"),h=s.find(g=>g.type==="baseline");if(d&&h){const g=d.assertions.find(y=>y.id===t),m=h.assertions.find(y=>y.id===t);g!=null&&g.pass&&(m!=null&&m.pass)&&(o.nonDiscriminating=!0)}if(a&&!a.pass&&s.length>=1){const m=s[0].assertions.find(y=>y.id===t);m!=null&&m.pass&&(o.regression=!0)}return o}function OC(){var I;const{state:t,dispatch:a,saveEvals:s,runCase:o,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:g}=An(),{evals:m,evalsError:y,selectedCaseId:v,inlineResults:b,caseRunStates:S,generateEvalsLoading:k,generateEvalsProgress:E,generateEvalsError:C}=t,N=p.useMemo(()=>{for(const V of S.values())if(V.status==="running"||V.status==="queued")return!0;return!1},[S]),[T,A]=p.useState(!1),[B,z]=p.useState("all"),F={skill_name:t.skill,evals:[]},w=m??F,O=w.evals,D=p.useMemo(()=>B==="all"?O:O.filter(V=>Rl(V)===B),[B,O]),U=D.find(V=>V.id===v)??null;p.useEffect(()=>{v!==null&&!D.find(V=>V.id===v)&&a({type:"SELECT_CASE",caseId:D.length>0?D[0].id:null})},[D,v,a]);const[H,q]=p.useState([]),X=p.useMemo(()=>O.some(V=>Rl(V)==="integration"),[O]);p.useEffect(()=>{X&&Ce.getCredentials(t.plugin,t.skill).then(V=>q(V.credentials)).catch(()=>q([]))},[t.plugin,t.skill,X]);const J=p.useMemo(()=>new Set(H.filter(V=>V.status==="missing").map(V=>V.name)),[H]),[$,L]=p.useState(!1),_=p.useCallback(V=>{L(!1),h(V?{testType:V}:void 0)},[h]);return!m||O.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:y?"var(--red-muted)":"var(--accent-muted)"},children:y?r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}):r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M9 11l3 3L22 4"}),r.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}),r.jsx("div",{className:"text-center",children:y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Invalid evals.json"}),r.jsx("div",{className:"text-[11px] font-mono px-3 py-2 rounded mt-1 max-w-sm text-left break-words",style:{color:"var(--text-secondary)",background:"var(--surface-2)"},children:y}),r.jsx("div",{className:"text-[12px] mt-2",style:{color:"var(--text-tertiary)"},children:"Fix the evals.json file and reload, or regenerate test cases with AI"})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No test cases yet"}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Create test cases to start evaluating your skill"})]})}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:()=>A(!0),disabled:g,title:g?_s:void 0,className:"btn btn-primary text-[12px]",children:"Create Test Case"}),r.jsxs("div",{style:{position:"relative"},children:[r.jsxs("div",{className:"flex",children:[r.jsx("button",{onClick:()=>_("unit"),disabled:k||g,title:g?_s:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}})," Generating..."]}):"Generate Unit Tests"}),r.jsx("button",{onClick:()=>L(!$),disabled:k||g,title:g?_s:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeft:"1px solid var(--border-default)",padding:"4px 6px"},children:r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),$&&r.jsx("div",{className:"absolute right-0 mt-1 rounded-lg py-1 z-50",style:{background:"var(--surface-1)",border:"1px solid var(--border-default)",minWidth:180,boxShadow:"0 4px 12px rgba(0,0,0,0.3)"},children:r.jsx("button",{onClick:()=>_("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.background="var(--surface-2)"},onMouseLeave:V=>{V.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),k&&E.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ai,{entries:E,isRunning:!0})}),C&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ec,{error:C,onRetry:()=>_()})}),T&&r.jsx(Pg,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]}):r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"280px 1fr",height:"100%",overflow:"hidden"},children:[r.jsxs("div",{className:"overflow-auto",style:{borderRight:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"px-3 py-2",style:{borderBottom:"1px solid var(--border-subtle)",display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:6,columnGap:8},children:[r.jsxs("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",flex:"1 1 auto",minWidth:0},children:["Test Cases (",D.length,")"]}),r.jsx("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,marginLeft:"auto",flexShrink:0},children:N?r.jsx("button",{onClick:d,className:"btn text-[10px] px-2 py-0.5",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:"Cancel All"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>c("benchmark"),disabled:D.length===0||g,title:g?_s:void 0,className:"btn btn-primary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Run All"}),r.jsx("button",{onClick:()=>c("comparison"),disabled:D.length===0||g,title:g?_s:void 0,className:"btn btn-secondary text-[10px] px-2 py-0.5",style:{whiteSpace:"nowrap"},children:"Compare All"})]})})]}),r.jsx("div",{className:"flex px-3 py-1.5 gap-1",style:{borderBottom:"1px solid var(--border-subtle)"},children:["all","unit","integration"].map(V=>r.jsx("button",{onClick:()=>z(V),style:{padding:"2px 8px",fontSize:10,fontWeight:B===V?600:400,background:B===V?"var(--accent-muted)":"transparent",color:B===V?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:V==="all"?`All (${O.length})`:V==="unit"?`Unit (${O.filter(ie=>Rl(ie)==="unit").length})`:`Integration (${O.filter(ie=>Rl(ie)==="integration").length})`},V))}),r.jsxs("div",{className:"py-1",children:[D.length===0&&O.length>0&&r.jsxs("div",{className:"flex items-center justify-center py-8 px-3 text-[12px]",style:{color:"var(--text-tertiary)"},children:["No ",B==="all"?"":B+" ","tests yet"]}),D.map(V=>{var G;const ie=b.get(V.id),M=v===V.id,Y=Rl(V);return r.jsxs("button",{onClick:()=>a({type:"SELECT_CASE",caseId:V.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:M?"var(--accent-muted)":"transparent",borderLeft:M?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:te=>{M||(te.currentTarget.style.background="var(--surface-2)")},onMouseLeave:te=>{M||(te.currentTarget.style.background="transparent")},children:[r.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[r.jsxs("span",{className:"text-[12px] font-medium truncate flex items-center gap-1.5",style:{color:M?"var(--text-primary)":"var(--text-secondary)"},children:["#",V.id," ",V.name,r.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:Y==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:Y==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:Y==="unit"?"U":"I"}),Y==="integration"&&((G=V.requiredCredentials)==null?void 0:G.some(te=>J.has(te)))&&r.jsx("span",{title:"Configure credentials to run",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})})]}),r.jsx(Ly,{result:ie})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[V.assertions.length," assertion",V.assertions.length!==1?"s":"",(ie==null?void 0:ie.passRate)!=null&&r.jsx(UC,{passRate:ie.passRate})]})]},V.id)})]}),r.jsx("div",{className:"px-3 py-2",children:!g&&r.jsx("button",{onClick:()=>A(!0),className:"w-full py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{border:"1px dashed var(--border-default)",color:"var(--text-tertiary)",background:"transparent"},onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--accent)",V.currentTarget.style.color="var(--accent)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-default)",V.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(zC,{})})]}),r.jsx("div",{className:"overflow-auto",children:U?r.jsx(BC,{evalCase:U,result:b.get(U.id),evals:m,caseStatus:((I=S.get(U.id))==null?void 0:I.status)??"idle",onSaveEvals:s,onRun:V=>o(V,"benchmark"),onCompare:V=>o(V,"comparison"),onCancel:V=>u(V),onImprove:V=>a({type:"OPEN_IMPROVE",evalId:V})}):r.jsx("div",{className:"flex items-center justify-center h-full text-[13px]",style:{color:"var(--text-tertiary)"},children:"Select a test case"})}),T&&r.jsx(Pg,{evals:w,onSave:V=>{s(V),A(!1)},onCancel:()=>A(!1)})]})}function BC({evalCase:t,result:a,evals:s,caseStatus:o,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:g}){const{state:m,isReadOnly:y}=An(),{plugin:v,skill:b}=m,{entries:S,loading:k}=DC(v,b,t.id),[E,C]=p.useState(!1),[N,T]=p.useState(t.prompt),[A,B]=p.useState(!1),[z,F]=p.useState(t.expected_output);p.useState(()=>{T(t.prompt),F(t.expected_output)});const w=p.useCallback(V=>{c({...s,evals:s.evals.map(ie=>ie.id===V.id?V:ie)})},[s,c]),O=p.useCallback(()=>{w({...t,prompt:N}),C(!1)},[t,N,w]),D=p.useCallback(()=>{w({...t,expected_output:z}),B(!1)},[t,z,w]),U=p.useCallback(()=>{w({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,w]),H=p.useCallback((V,ie)=>{w({...t,assertions:t.assertions.map(M=>M.id===V?{...M,text:ie}:M)})},[t,w]),q=p.useCallback(V=>{w({...t,assertions:t.assertions.filter(ie=>ie.id!==V)})},[t,w]),X=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(V=>V.id!==t.id)})},[s,t.id,c]),J=a&&a.assertions.length>0&&a.assertions.every(V=>V.pass),$=a&&a.assertions.some(V=>!V.pass),L=Rl(t),_=t.requiredCredentials??[],I=L==="integration"&&_.length>0;return r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"mb-4",style:{display:"flex",flexWrap:"wrap",alignItems:"center",rowGap:8,columnGap:12},children:[r.jsxs("div",{className:"flex items-center gap-2",style:{flex:"1 1 240px",minWidth:0},children:[r.jsxs("span",{className:"text-[16px] font-semibold",title:`#${t.id} ${t.name}`,style:{color:"var(--text-primary)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["#",t.id," ",t.name]}),y?r.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)"},children:L==="unit"?"Unit":"Integration"}):r.jsx("button",{onClick:()=>{if((L==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:ie,requirements:M,cleanup:Y,...G}=t;w({...G,testType:"unit"})}else w({...t,testType:"integration"})},title:`Click to switch to ${L==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:L==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:L==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:L==="unit"?"Unit":"Integration"}),r.jsx(Ly,{result:a})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[o==="running"||o==="queued"?r.jsxs("button",{onClick:()=>h(t.id),className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)",whiteSpace:"nowrap"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel"]}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>u(t.id),disabled:y,className:"btn btn-primary text-[12px]",style:{whiteSpace:"nowrap"},children:"Run"}),r.jsx("button",{onClick:()=>d(t.id),disabled:y,className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"A/B Compare"})]}),$&&!y&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:()=>g(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&o!=="running"&&o!=="queued"&&r.jsx("button",{onClick:X,className:"btn btn-ghost text-[12px]","aria-label":"Delete test case",title:"Delete test case",style:{color:"var(--red)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})})]})]}),y&&L==="integration"&&r.jsxs("div",{"data-testid":"platform-integration-note",className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--accent-muted)",border:"1px solid var(--accent-muted)"},children:[r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),r.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),r.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--accent)"},children:"Run locally in vSkill Studio"})]}),J&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl flex items-center gap-3",style:{background:"var(--green-muted)",border:"1px solid var(--green-muted)"},children:[r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--green)"},children:"All assertions passing"})]}),I&&r.jsxs("div",{className:"mb-4 px-4 py-3 rounded-xl",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"Required Credentials"})]}),r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:"This integration test requires the following environment variables:"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:_.map(V=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:V},V))})]}),!y&&L==="integration"&&r.jsx(VC,{evalCase:t,onUpdate:w}),r.jsx(So,{title:"Prompt",children:E?r.jsxs("div",{children:[r.jsx("textarea",{value:N,onChange:V=>T(V.target.value),className:"input-field w-full",rows:4,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:O,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{T(t.prompt),C(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-secondary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||C(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.prompt||r.jsx("span",{style:{color:"var(--text-tertiary)",fontStyle:"italic"},children:y?"No prompt":"Click to edit prompt..."})})}),r.jsx(So,{title:"Expected Output",children:A?r.jsxs("div",{children:[r.jsx("textarea",{value:z,onChange:V=>F(V.target.value),className:"input-field w-full",rows:3,style:{fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12},autoFocus:!0}),r.jsxs("div",{className:"flex gap-2 mt-2",children:[r.jsx("button",{onClick:D,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{F(t.expected_output),B(!1)},className:"btn btn-ghost text-[12px]",children:"Cancel"})]})]}):r.jsx("div",{className:"p-3 rounded-lg text-[12px] transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",border:"1px solid var(--border-subtle)",maxHeight:200,overflowY:"auto",cursor:y?"default":"pointer"},onClick:()=>{y||B(!0)},onMouseEnter:V=>{y||(V.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--border-subtle)"},children:t.expected_output||r.jsx("span",{style:{fontStyle:"italic"},children:y?"No expected output":"Click to edit expected output..."})})}),r.jsx(So,{title:`Assertions (${t.assertions.length})`,action:y?void 0:r.jsx("button",{onClick:U,className:"btn btn-ghost text-[11px]",children:"+ Add"}),children:t.assertions.length===0?r.jsx("div",{className:"text-[12px] text-center py-4",style:{color:"var(--text-tertiary)"},children:'No assertions. Click "+ Add" to create one.'}):r.jsx("div",{className:"space-y-2",children:t.assertions.map(V=>{const ie=a==null?void 0:a.assertions.find(Y=>Y.assertion_id===V.id),M=_C(V.id,ie,S);return r.jsx(IC,{assertion:V,result:ie,badges:M,isReadOnly:y,onUpdate:Y=>H(V.id,Y),onDelete:()=>q(V.id)},V.id)})})}),(a==null?void 0:a.output)&&r.jsx(HC,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const V=Ay("INEFFECTIVE",a.passRate);return V.recommendations&&V.recommendations.length>0?r.jsx(So,{title:"Recommendations",children:r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--orange)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),r.jsx("span",{className:"text-[12px] font-semibold",style:{color:"var(--orange)"},children:"This eval is significantly below expectations"})]}),r.jsx("ul",{className:"space-y-1.5 ml-1",children:V.recommendations.map((ie,M)=>r.jsxs("li",{className:"flex items-start gap-2 text-[12px]",style:{color:"var(--text-secondary)"},children:[r.jsx("span",{style:{color:"var(--orange)",fontWeight:600,flexShrink:0},children:"•"}),ie]},M))})]})}):null})(),r.jsx($C,{evalId:t.id,sharedEntries:S,sharedLoading:k})]},t.id)}function IC({assertion:t,result:a,badges:s,isReadOnly:o,onUpdate:c,onDelete:u}){const[d,h]=p.useState(!1),[g,m]=p.useState(t.text),[y,v]=p.useState(!1),b=()=>{c(g),h(!1)};return r.jsx("div",{className:"rounded-lg px-3 py-2.5 transition-all duration-150",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsxs("div",{className:"flex items-start gap-2",children:[a?r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}):r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:18,height:18,border:"1.5px dashed var(--text-tertiary)",background:"transparent"},title:"Not run yet"}),(s==null?void 0:s.regression)&&r.jsx("span",{className:"mt-0.5 flex-shrink-0",title:"Regression: was passing, now failing",style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:18,color:"var(--red)",fontSize:14,fontWeight:700,lineHeight:1},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("polyline",{points:"19 12 12 19 5 12"})]})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[10px] font-mono font-semibold",style:{color:"var(--text-tertiary)"},children:t.id}),(s==null?void 0:s.flaky)&&r.jsx("span",{title:"Flaky: 30-70% pass rate across recent runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--yellow-muted)",color:"var(--yellow)",whiteSpace:"nowrap"},children:"Flaky"}),(s==null?void 0:s.nonDiscriminating)&&r.jsx("span",{title:"Non-discriminating: passes on both skill and baseline runs",style:{display:"inline-block",fontSize:9,fontWeight:600,lineHeight:1,padding:"2px 6px",borderRadius:9999,background:"var(--surface-3)",color:"var(--text-tertiary)",whiteSpace:"nowrap"},children:"Non-Discrim."})]}),d?r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{value:g,onChange:S=>m(S.target.value),onKeyDown:S=>{S.key==="Enter"&&b(),S.key==="Escape"&&h(!1)},className:"input-field flex-1 text-[12px]",autoFocus:!0}),r.jsx("button",{onClick:b,className:"btn btn-primary text-[11px]",children:"Save"})]}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-secondary)",cursor:o?"default":"pointer"},onClick:()=>{o||(m(t.text),h(!0))},children:t.text}),(a==null?void 0:a.reasoning)&&r.jsx("button",{onClick:()=>v(!y),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:y?"Hide reasoning":"Show reasoning"}),y&&(a==null?void 0:a.reasoning)&&r.jsx("div",{className:"mt-1 text-[11px] p-2 rounded",style:{background:"var(--surface-1)",color:"var(--text-tertiary)"},children:a.reasoning})]}),!o&&r.jsx("button",{onClick:u,className:"btn btn-ghost p-1 opacity-0 group-hover:opacity-100",style:{color:"var(--text-tertiary)"},onMouseEnter:S=>{S.currentTarget.style.color="var(--red)",S.currentTarget.style.opacity="1"},onMouseLeave:S=>{S.currentTarget.style.color="var(--text-tertiary)",S.currentTarget.style.opacity=""},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})}function So({title:t,action:a,children:s}){return r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:t}),a]}),s]})}function Ly({result:t}){const[a,s]=p.useState(!1);if(!t||t.status==null)return r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"--"});const o=t.status==="pass",c=t.passRate??0,d=Ay(o?"PASS":"FAIL",c);return r.jsxs("span",{className:"pill text-[10px]",style:{background:o?"var(--green-muted)":"var(--red-muted)",color:o?"var(--green)":"var(--red)",position:"relative",cursor:"default"},onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),"aria-describedby":a?"verdict-tooltip":void 0,children:[t.passRate!=null?`${Math.round(t.passRate*100)}%`:t.status,a&&r.jsx("div",{id:"verdict-tooltip",role:"tooltip",style:{position:"absolute",bottom:"calc(100% + 6px)",right:0,padding:"6px 10px",background:"var(--surface-4)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:11,color:"var(--text-secondary)",whiteSpace:"nowrap",zIndex:50,maxWidth:300,width:"max-content",boxShadow:"0 4px 12px rgba(0,0,0,0.15)"},children:d.explanation})]})}function UC({passRate:t}){const a=Math.round(t*100);return r.jsx("div",{className:"flex items-center gap-1",children:r.jsx("div",{className:"rounded-full overflow-hidden",style:{width:32,height:4,background:"var(--surface-4)"},children:r.jsx("div",{className:"h-full rounded-full",style:{width:`${a}%`,background:a>=80?"var(--green)":a>=50?"var(--yellow)":"var(--red)"}})})})}function HC({output:t,durationMs:a,tokens:s}){const[o,c]=p.useState(!1);return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:()=>c(!o),className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:o?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"LLM Output",a!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",(a/1e3).toFixed(1),"s)"]}),s!=null&&r.jsxs("span",{style:{fontWeight:400},children:["(",s," tokens)"]})]}),o&&r.jsx("pre",{className:"text-[12px] p-4 rounded-lg overflow-auto animate-fade-in",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:400,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function Dd(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function _d({entry:t}){return r.jsxs("div",{className:"rounded-lg px-3 py-2.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:Ny(t.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:t.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:t.type==="benchmark"?"var(--accent-muted)":t.type==="comparison"?"var(--purple-muted)":"var(--orange-muted)",color:t.type==="benchmark"?"var(--accent)":t.type==="comparison"?"var(--purple)":"var(--orange)"},children:t.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Dl(t.pass_rate)},children:[Math.round(t.pass_rate*100),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-1.5 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[t.durationMs!=null&&r.jsx("span",{children:Ty(t.durationMs)}),t.tokens!=null&&r.jsxs("span",{children:[t.tokens>=1e3?`${(t.tokens/1e3).toFixed(1)}k`:t.tokens," tok"]})]}),t.type==="comparison"&&t.baselinePassRate!=null&&(()=>{const a=t.pass_rate-t.baselinePassRate,s=a>.001?"skill":a<-.001?"baseline":"tie",o=a>0?"+":"",c=s==="skill"?"var(--green)":s==="baseline"?"var(--red)":"var(--text-tertiary)";return r.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"vs baseline:"}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:a>=0?"var(--green)":"var(--red)"},children:[o,(a*100).toFixed(1),"%"]}),r.jsx("span",{className:"pill text-[9px]",style:{padding:"1px 5px",background:"var(--surface-3)",color:c},children:s})]})})(),r.jsx("div",{className:"space-y-0.5",children:t.assertions.map(a=>r.jsxs("div",{className:"flex items-start gap-1.5",children:[r.jsx("span",{className:"mt-0.5 rounded-full flex-shrink-0",style:{width:14,height:14,display:"flex",alignItems:"center",justifyContent:"center",background:a.pass?"var(--green-muted)":"var(--red-muted)"},children:a.pass?r.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:a.text})]},a.id))})]})}function $C({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:o,dispatch:c}=An(),{plugin:u,skill:d}=o,[h,g]=p.useState(!0),m=a??null,y=s??!1,v=p.useCallback(()=>{g(E=>!E)},[]),b=m?m.slice(0,10):[],S=b.some(E=>{const C=Dd(E.type);return C==="left"||C==="full"}),k=b.some(E=>{const C=Dd(E.type);return C==="right"||C==="full"});return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:v,className:"flex items-center gap-2 text-[11px] font-semibold uppercase tracking-wider mb-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:h?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease"},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Execution History",m&&m.length>0&&r.jsxs("span",{style:{fontWeight:400},children:["(",m.length," run",m.length!==1?"s":"",")"]})]}),h&&r.jsx("div",{className:"animate-fade-in",children:y?r.jsxs("div",{className:"flex items-center gap-2 py-3",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):!m||m.length===0?r.jsx("div",{className:"text-[12px] py-3",style:{color:"var(--text-tertiary)"},children:"No history for this case"}):r.jsxs("div",{children:[b.length>=2&&r.jsx("div",{className:"mb-2",children:r.jsx(Ry,{entries:b})}),r.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:8},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"1"},children:"Skill"}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)",gridColumn:"2"},children:"Baseline"}),!S&&r.jsx("div",{style:{gridColumn:"1",fontSize:12,color:"var(--text-tertiary)"},children:"No skill runs"}),!k&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((E,C)=>{const N=Dd(E.type);return N==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(_d,{entry:E})},C):N==="left"?r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(_d,{entry:E})}),r.jsx("div",{style:{gridColumn:"2"}})]},C):r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(_d,{entry:E})})]},C)})]}),r.jsx("button",{onClick:()=>c({type:"SET_PANEL",panel:"history"}),className:"mt-2 text-[11px] font-medium transition-colors duration-150",style:{color:"var(--accent)"},onMouseEnter:E=>{E.currentTarget.style.textDecoration="underline"},onMouseLeave:E=>{E.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function Pg({evals:t,onSave:a,onCancel:s}){const[o,c]=p.useState(""),[u,d]=p.useState(""),[h,g]=p.useState(""),[m,y]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,b]=p.useState("unit"),[S,k]=p.useState(""),[E,C]=p.useState([]),[N,T]=p.useState(""),[A,B]=p.useState(""),z=Math.max(0,...t.evals.map(D=>D.id))+1,F=D=>{b(D),D==="unit"&&(C([]),k(""),T(""),B(""))},w=()=>{const D=S.trim().toUpperCase();D&&!E.includes(D)&&C([...E,D]),k("")},O=()=>{if(!o.trim()||!u.trim())return;const D={id:z,name:o.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:m.filter(U=>U.text.trim()),...v==="integration"?{testType:"integration",...E.length>0?{requiredCredentials:E}:{},...N||A?{requirements:{...N?{platform:N}:{},...A?{chromeProfile:A}:{}}}:{}}:{}};a({...t,evals:[...t.evals,D]})};return r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center animate-overlay-in",style:{background:"rgba(0,0,0,0.6)"},children:r.jsxs("div",{className:"w-full max-w-lg rounded-xl p-6 animate-modal-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",maxHeight:"85vh",overflowY:"auto"},children:[r.jsx("div",{className:"text-[15px] font-semibold mb-4",style:{color:"var(--text-primary)"},children:"New Test Case"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1.5 block",style:{color:"var(--text-tertiary)"},children:"Type"}),r.jsx("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)",display:"inline-flex"},children:["unit","integration"].map(D=>r.jsx("button",{onClick:()=>F(D),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===D?D==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===D?D==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:D},D))})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Name"}),r.jsx("input",{value:o,onChange:D=>c(D.target.value),className:"input-field",placeholder:"e.g., auth-check",autoFocus:!0})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Prompt"}),r.jsx("textarea",{value:u,onChange:D=>d(D.target.value),className:"input-field",rows:3,placeholder:"User prompt to test..."})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Expected Output"}),r.jsx("textarea",{value:h,onChange:D=>g(D.target.value),className:"input-field",rows:2,placeholder:"Description of expected behavior..."})]}),r.jsxs("div",{className:"mb-4",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Assertions"}),m.map((D,U)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:D.text,onChange:H=>y(m.map((q,X)=>X===U?{...q,text:H.target.value}:q)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),m.length>1&&r.jsx("button",{onClick:()=>y(m.filter((H,q)=>q!==U)),className:"btn btn-ghost p-1",style:{color:"var(--text-tertiary)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},D.id)),r.jsx("button",{onClick:()=>y([...m,{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),className:"text-[11px] mt-1 transition-colors duration-150",style:{color:"var(--accent)"},children:"+ Add Assertion"})]}),v==="integration"&&r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:E.map(D=>r.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[D,r.jsx("button",{onClick:()=>C(E.filter(U=>U!==D)),style:{color:"var(--orange)",lineHeight:1},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},D))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:S,onChange:D=>k(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),w())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),r.jsx("button",{onClick:w,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("label",{className:"block mb-3",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:N,onChange:D=>T(D.target.value),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("label",{className:"block",children:[r.jsx("span",{className:"text-[11px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:A,onChange:D=>B(D.target.value),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]}),r.jsxs("div",{className:"flex justify-end gap-2",children:[r.jsx("button",{onClick:s,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsx("button",{onClick:O,disabled:!o.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function VC({evalCase:t,onUpdate:a}){var d,h;const[s,o]=p.useState(""),c=()=>{const g=s.trim().toUpperCase();g&&!(t.requiredCredentials??[]).includes(g)&&a({...t,requiredCredentials:[...t.requiredCredentials??[],g]}),o("")},u=g=>{const m=(t.requiredCredentials??[]).filter(y=>y!==g);a({...t,requiredCredentials:m.length>0?m:void 0})};return r.jsxs("div",{className:"mb-4 p-3 rounded-lg",style:{background:"var(--orange-muted)",border:"1px solid var(--orange-muted)"},children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 block",style:{color:"var(--orange)"},children:"Integration Settings"}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Required Credentials"}),r.jsx("div",{className:"flex flex-wrap gap-1.5 mb-1.5",children:(t.requiredCredentials??[]).map(g=>r.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-mono",style:{background:"var(--orange-muted)",color:"var(--orange)"},children:[g,r.jsx("button",{onClick:()=>u(g),style:{color:"var(--orange)",lineHeight:1},children:r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},g))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:g=>o(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),c())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., GITHUB_TOKEN"}),r.jsx("button",{onClick:c,className:"btn btn-ghost text-[11px]",style:{color:"var(--orange)"},children:"Add"})]})]}),r.jsxs("div",{className:"mb-2.5",children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Platform"}),r.jsx("input",{value:((d=t.requirements)==null?void 0:d.platform)??"",onChange:g=>a({...t,requirements:{...t.requirements,platform:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., linkedin, twitter"})]}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[10px] mb-1 block",style:{color:"var(--text-secondary)"},children:"Chrome Profile"}),r.jsx("input",{value:((h=t.requirements)==null?void 0:h.chromeProfile)??"",onChange:g=>a({...t,requirements:{...t.requirements,chromeProfile:g.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function Rn(t,a){return a==="free"?"Free":a==="subscription"&&t==null?"Included":t==null?"N/A":t>=1?`$${t.toFixed(2)}`:t===0?"$0.00":t>=.001?`$${t.toFixed(4)}`:`$${t.toPrecision(3).replace(/0+$/,"").replace(/\.$/,"")}`}function zy(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function PC(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function FC(t,a){let s="";if(a){const c=new Date(a);isNaN(c.getTime())||(s=c.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}))}return[t,s].filter(Boolean).join(" · ")}function GC(t,a,s){const o=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const c=Math.round(Math.abs(t)*a);if(c===0)return`Your skill performs the same as the baseline across ${s} ${o}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${o}`}function Fg(t,a){const s=o=>{const c=o/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(a)}}function WC(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function qC(t,a){const s=t+a,o=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(o)}–${u(c)}`}const YC={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function KC(t,a){if(!t)return null;const s=YC[t];if(s==null||s===0)return null;const o=s*a*.5,c=s*a*2;return`${Rn(o)}–${Rn(c)}`}function XC(){const{state:t,runCase:a,runAll:s,cancelCase:o,cancelAll:c,isReadOnly:u}=An(),{evals:d,caseRunStates:h,bulkRunActive:g,latestBenchmark:m,inlineResults:y}=t,{config:v}=$a(),b=(d==null?void 0:d.evals)??[],S=p.useMemo(()=>{for(const w of h.values())if(w.status==="running"||w.status==="queued")return!0;return!1},[h]),k=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,E=b.filter(w=>{const O=h.get(w.id);return O&&(O.status==="running"||O.status==="queued")}).length,C=p.useRef(null),[N,T]=p.useState(0);p.useEffect(()=>{if(S&&!C.current&&(C.current=Date.now()),!S){C.current=null,T(0);return}const w=setInterval(()=>{C.current&&T(Math.round((Date.now()-C.current)/1e3))},1e3);return()=>clearInterval(w)},[S]);const A=b.reduce((w,O)=>w+O.assertions.length,0),B=b.length+A,z=p.useMemo(()=>qC(b.length,A),[b.length,A]),F=p.useMemo(()=>KC((v==null?void 0:v.provider)??null,B),[v==null?void 0:v.provider,B]);return r.jsxs("div",{className:"p-5",children:[u&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-4 text-[11px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"Installed skill — benchmarking is disabled. Edit the source skill to run benchmarks."]}),r.jsxs("div",{className:"rounded-xl p-4 mb-5",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Benchmark"}),S&&r.jsxs("span",{className:"text-[11px] font-medium",style:{color:"var(--accent)"},children:[E," running"]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsxs("button",{onClick:c,className:"btn text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",style:{marginRight:4},children:r.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1"})}),"Cancel All"]}),r.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||S||u,className:"btn btn-primary text-[12px]",title:"Runs both your skill and the baseline, then compares results side by side",children:"Run A/B Test"}),r.jsx("button",{onClick:()=>s("benchmark"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using your skill only",children:"Test Skill"}),r.jsx("button",{onClick:()=>s("baseline"),disabled:b.length===0||S||u,className:"btn btn-secondary text-[12px]",title:"Runs benchmark using the baseline (no skill) for reference",children:"Test Baseline"})]}),!S&&b.length>0&&r.jsxs("div",{className:"flex items-center gap-3 mt-2 text-[10px]",style:{color:"var(--text-tertiary)"},children:[r.jsxs("span",{children:["Est. duration: ",z]}),F&&r.jsxs("span",{children:["Est. cost: ",F]}),!F&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!F&&(v==null?void 0:v.provider)&&(v.provider==="ollama"||v.provider==="lm-studio"||v.provider==="gemini-cli")&&r.jsx("span",{children:"Cost: Free"})]})]}),S&&b.length>0&&r.jsxs("div",{className:"mb-5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("span",{className:"text-[12px] font-medium",style:{color:"var(--text-secondary)"},children:["Progress: ",k,"/",b.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(k/b.length*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${k/b.length*100}%`,background:"var(--accent)"}})}),r.jsxs("div",{className:"flex items-center justify-between mt-1.5",children:[r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Elapsed: ",N>=60?`${Math.floor(N/60)}m ${N%60}s`:`${N}s`]}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:["Est. total: ",z]})]})]}),r.jsx("div",{className:"space-y-3 stagger-children",children:b.map(w=>{const O=y.get(w.id),D=h.get(w.id),U=(D==null?void 0:D.status)??"idle",H=m==null?void 0:m.cases.find(q=>q.eval_id===w.id);return r.jsx(ZC,{name:w.name,evalId:w.id,result:O,caseCost:H==null?void 0:H.cost,caseBillingMode:H==null?void 0:H.billingMode,caseInputTokens:H==null?void 0:H.inputTokens,caseOutputTokens:H==null?void 0:H.outputTokens,caseStatus:U,runMode:(D==null?void 0:D.mode)??null,comparisonDetail:H==null?void 0:H.comparisonDetail,isReadOnly:u,onRun:q=>a(q,"benchmark"),onBaseline:q=>a(q,"baseline"),onCompare:q=>a(q,"comparison"),onCancel:q=>o(q)},w.id)})}),!S&&m&&m.cases.length>0&&r.jsxs("div",{className:"mt-5",children:[r.jsxs("div",{className:"rounded-xl p-4 mb-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:PC(m.type)}),r.jsx("span",{className:"text-[20px] font-bold",style:{color:(m.overall_pass_rate??0)>=.8?"var(--green)":(m.overall_pass_rate??0)>=.5?"var(--yellow)":"var(--red)"},children:m.overall_pass_rate!=null?`${Math.round(m.overall_pass_rate*100)}%`:"--"})]}),m.totalDurationMs!=null&&r.jsxs("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:["Total: ",(m.totalDurationMs/1e3).toFixed(1),"s",m.model&&` | Model: ${m.model}`,m.totalInputTokens!=null&&m.totalOutputTokens!=null&&` | Tokens: ${zy(m.totalInputTokens,m.totalOutputTokens)}`,m.totalCost!=null&&` | Cost: ${Rn(m.totalCost)}`]}),m.overall_pass_rate>=.9999&&!m.comparison&&r.jsx("button",{onClick:()=>s("comparison"),disabled:b.length===0||u,className:"text-[13px] font-semibold mt-3 w-full rounded-lg transition-opacity duration-150",style:{padding:"10px 0",background:"var(--green)",color:"var(--color-paper)",border:"none",cursor:"pointer",opacity:b.length===0?.5:1},children:"Run Final A/B Comparison"})]}),m.comparison&&r.jsxs("div",{className:"rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Skill vs Baseline"}),(()=>{const w=FC(m.model,m.timestamp);return w?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:w}):r.jsx("div",{className:"mb-3"})})(),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(Gg,{label:"Skill",value:m.comparison.skillPassRate,color:"var(--accent)"}),r.jsx(Gg,{label:"Baseline",value:m.comparison.baselinePassRate,color:"var(--text-tertiary)"})]}),r.jsxs("div",{className:"mt-3 text-[12px] font-medium",style:{color:m.comparison.delta>0?"var(--green)":m.comparison.delta<0?"var(--red)":"var(--text-tertiary)"},children:["Delta: ",m.comparison.delta>0?"+":"",(m.comparison.delta*100).toFixed(1),"%",m.verdict&&` | ${LC(m.verdict)}`]}),(()=>{const w=m.cases.reduce((D,U)=>D+U.assertions.length,0),O=GC(m.comparison.delta,w,m.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const QC={benchmark:{label:"Skill",bg:"var(--accent-muted)",color:"var(--accent)"},baseline:{label:"Baseline",bg:"var(--surface-3)",color:"var(--text-tertiary)"},comparison:{label:"Compare",bg:"var(--purple-muted)",color:"var(--purple)"}};function ZC({name:t,evalId:a,result:s,caseCost:o,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:g,comparisonDetail:m,isReadOnly:y,onRun:v,onBaseline:b,onCompare:S,onCancel:k}){const[E,C]=p.useState(!1),N=h==="running"||h==="queued",T=h==="complete"||h==="error";return r.jsxs("div",{className:"rounded-xl overflow-hidden transition-all duration-200",style:{background:"var(--surface-1)",border:N?"1px solid var(--accent)":"1px solid var(--border-subtle)",boxShadow:N?"0 0 12px rgba(99, 131, 255, 0.15)":"none"},children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[h==="running"&&r.jsx("span",{className:"spinner",style:{width:14,height:14,borderWidth:1.5}}),h==="queued"&&r.jsx("span",{className:"text-[10px] font-medium",style:{color:"var(--text-tertiary)"},children:"queued"}),r.jsxs("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:["#",a," ",t]}),g&&(N||T)&&(()=>{const A=QC[g];return A?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:A.bg,color:A.color,padding:"1px 6px"},children:A.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[N?r.jsx("button",{onClick:()=>k(a),className:"btn text-[10px] px-2 py-1",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:"Cancel"}):r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:()=>S(a),disabled:y,className:"btn btn-primary text-[10px] px-2 py-1",children:"Compare"}),r.jsx("button",{onClick:()=>v(a),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Skill"}),r.jsx("button",{onClick:()=>b(a),disabled:y,className:"btn btn-secondary text-[10px] px-2 py-1",children:"Base"})]}),s&&s.status!=null&&r.jsx("span",{className:"pill text-[10px]",style:{background:s.status==="pass"?"var(--green-muted)":"var(--red-muted)",color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.passRate!=null?`${Math.round(s.passRate*100)}%`:s.status}),u!=null&&d!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:zy(u,d)}),o!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:Rn(o,c)}),h==="cancelled"&&r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:"cancelled"})]})]}),s&&s.assertions.length>0&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"space-y-1",children:s.assertions.map(A=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:A.pass?"var(--green)":"var(--red)"},children:A.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:A.text})]},A.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>C(!E),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:E?"Hide output":"Show output"}),E&&s.output&&r.jsx("pre",{className:"text-[11px] mt-2 p-3 rounded-lg overflow-auto",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",maxHeight:200,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap"},children:s.output})]}),m&&r.jsx("div",{className:"px-4 pb-3",children:r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:r.jsx("div",{className:"flex items-center gap-4 text-[11px] flex-wrap",children:(()=>{const A=Fg(m.skillContentScore,m.baselineContentScore),B=Fg(m.skillStructureScore,m.baselineStructureScore),z=WC(m.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",A.skill,"% / Baseline ",A.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",B.skill,"% / Baseline ",B.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsx("span",{style:{color:z.isSkill?"var(--accent)":"var(--text-tertiary)",fontWeight:500},children:z.text})]})})()})})}),s&&s.errorMessage&&r.jsx(JC,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Od={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function JC({errorMessage:t,classifiedError:a}){const[s,o]=p.useState(!1),c=(a==null?void 0:a.title)??"Error",u=a==null?void 0:a.hint,d=a?Od[a.category]??Od.unknown:Od.unknown;return r.jsx("div",{className:"px-4 pb-3",children:r.jsxs("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--red-muted)",border:"1px solid var(--red-muted)"},children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsx("span",{style:{fontSize:12},children:d}),r.jsx("span",{className:"text-[11.5px] font-semibold flex-1",style:{color:"var(--red)"},children:c}),r.jsx("button",{onClick:()=>o(!s),className:"text-[10px] px-1.5 py-0.5 rounded transition-colors duration-150",style:{color:"var(--text-tertiary)",background:"transparent"},children:s?"Hide details":"Details"})]}),u&&r.jsx("div",{className:"px-3 pb-2 text-[10.5px]",style:{color:"var(--text-secondary)"},children:u}),s&&r.jsx("pre",{className:"text-[10px] px-3 pb-2.5 overflow-auto",style:{color:"var(--text-tertiary)",maxHeight:120,fontFamily:"var(--font-mono, ui-monospace, monospace)",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0},children:t})]})})}function Gg({label:t,value:a,color:s}){return r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:t}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:s},children:[Math.round(a*100),"%"]})]}),r.jsx("div",{className:"rounded-full overflow-hidden",style:{height:6,background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${a*100}%`,background:s}})})]})}const Wg={TP:{bg:"var(--green-muted)",text:"var(--green)"},TN:{bg:"var(--green-muted)",text:"var(--green)"},FP:{bg:"var(--red-muted)",text:"var(--red)"},FN:{bg:"var(--red-muted)",text:"var(--red)"}};function eE(){var _;const{state:t,dispatch:a,runActivationTest:s,cancelActivation:o,generateActivationPrompts:c}=An(),{plugin:u,skill:d,activationPrompts:h,activationResults:g,activationSummary:m,activationRunning:y,activationError:v,activationStartedAt:b,activationClassifyingStatus:S,generatingPrompts:k,generatingPromptsError:E,activationHistory:C}=t,{state:N}=er(),T=((_=N.skills.find(I=>I.plugin===u&&I.skill===d))==null?void 0:_.version)??null,[A,B]=p.useState(h),[z,F]=p.useState(null),[w,O]=p.useState(!1);p.useEffect(()=>{h&&h!==A&&B(h)},[h]),p.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:A})},[A,a]),p.useEffect(()=>{fetch(`/api/skills/${u}/${d}/description`).then(I=>I.json()).then(I=>F(I.rawContent||I.description||null)).catch(()=>F(null))},[u,d]);function D(){s(A)}function U(){c(8)}const H=A.trim().split(`
81
+ `).filter(Boolean).length,q=g.filter(I=>I.classification==="TP"||I.classification==="TN"),X=g.filter(I=>I.classification==="FP"||I.classification==="FN"),J=(z==null?void 0:z.replace(/^---[\s\S]*?---\s*/,"").trim())??null,$=A.trim().length>0,L=J?Zo(J):"";return r.jsxs("div",{className:"p-5 space-y-5",children:[r.jsxs("div",{children:[r.jsx("div",{className:"text-[14px] font-semibold",style:{color:"var(--text-primary)"},children:"Activation Test"}),r.jsx("div",{className:"text-[12px] mt-0.5",style:{color:"var(--text-tertiary)"},children:"Test whether this skill's description activates for relevant prompts and stays silent for irrelevant ones."})]}),r.jsxs("div",{className:"grid grid-cols-[3fr_2fr] gap-4 items-stretch",children:[r.jsxs("div",{className:"glass-card p-4 flex flex-col gap-3",children:[r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),r.jsx("div",{className:"flex gap-1.5",children:r.jsx("button",{onClick:U,disabled:k||!J||y,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:k?"var(--surface-3)":"var(--surface-2)",color:J?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:J?1:.5,cursor:J?"pointer":"not-allowed"},title:J?void 0:"No skill description available",onMouseEnter:I=>{J&&!k&&(I.currentTarget.style.background="var(--surface-3)")},onMouseLeave:I=>{k||(I.currentTarget.style.background="var(--surface-2)")},children:k?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--accent)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Generating..."]}):r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 3v3m6.36.64l-2.12 2.12M21 12h-3m-.64 6.36l-2.12-2.12M12 21v-3m-4.24.64l2.12-2.12M3 12h3m.64-6.36l2.12 2.12"})}),$?"Regenerate":"Generate"," Test Prompts"]})})})]}),!J&&!y&&r.jsx("div",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},"aria-live":"polite",children:"Add a description to your skill's frontmatter to enable prompt generation."}),E&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:E}),r.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:A,onChange:I=>B(I.target.value),placeholder:`How do I write a unit test?
82
+ What edge cases should I test?
83
+ +Deploy this to production
84
+ !What's the weather like today?
85
+ !Write me a poem about flowers`}),r.jsxs("div",{className:"flex items-center flex-wrap gap-x-3 gap-y-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:[r.jsx("span",{children:"One prompt per line"}),r.jsx(ko,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"+"}),"= must activate"]}),r.jsx(ko,{}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("code",{className:"px-1 rounded",style:{background:"var(--surface-2)"},children:"!"}),"= must NOT activate"]}),r.jsx(ko,{}),r.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[H," prompt",H!==1?"s":""]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:D,disabled:y||!A.trim(),className:"btn btn-primary",children:y?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--color-paper)",borderColor:"var(--border-default)",width:14,height:14}}),"Testing..."]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("circle",{cx:"12",cy:"12",r:"6"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),"Run Activation Test"]})}),y&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:o,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[S||`${g.length} / ${H} prompts tested`,b&&r.jsx(aE,{startedAt:b})]})]})]})]}),r.jsxs("div",{className:"glass-card flex flex-col overflow-hidden",children:[r.jsx("div",{className:"px-4 pt-3.5 pb-2.5 flex-shrink-0",style:{borderBottom:"1px solid var(--border-subtle)"},children:r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Skill Description"})}),r.jsx("div",{className:"flex-1 overflow-auto px-4 py-3",style:{minHeight:0},children:J?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:L}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),v&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid var(--red-muted)"},children:v}),y&&g.length===0&&r.jsxs("div",{className:"text-center py-12 animate-fade-in",children:[r.jsx("div",{className:"spinner-lg mx-auto mb-4"}),r.jsx("p",{className:"text-[14px]",style:{color:"var(--text-secondary)"},children:"Testing activation against skill description..."})]}),g.length>0&&r.jsxs("div",{className:"space-y-5",children:[X.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--red)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),r.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--red)"},children:["Incorrect (",X.length,")"]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"— These need attention"})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:X.map((I,V)=>r.jsx(qg,{result:I},`incorrect-${V}`))})]}),q.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("polyline",{points:"16 10 11 15 8 12"})]}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--green)"},children:["Correct (",q.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:q.map((I,V)=>r.jsx(qg,{result:I},`correct-${V}`))})]})]}),m&&r.jsxs("div",{className:"glass-card p-6 animate-fade-in-scale",style:{borderColor:"var(--border-active)",borderWidth:2},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-2",style:{color:"var(--text-tertiary)"},children:"Summary"}),m.autoClassifiedCount!=null&&m.autoClassifiedCount>0&&r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[m.autoClassifiedCount," of ",m.total," prompts auto-classified from skill name and tags"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(Bd,{label:"Precision",value:m.precision,description:"Of all activations, how many were correct?",detail:`${m.tp} true / ${m.tp+m.fp} total activations`}),r.jsx(Bd,{label:"Recall",value:m.recall,description:"Of expected activations, how many fired?",detail:`${m.tp} activated / ${m.tp+m.fn} expected`}),r.jsx(Bd,{label:"Reliability",value:m.reliability,description:"Overall correct classification rate",detail:`${m.tp+m.tn} correct / ${m.total} total`})]}),r.jsxs("div",{className:"pt-4",style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-widest mb-3 text-center",style:{color:"var(--text-tertiary)"},children:"Confusion Matrix"}),r.jsxs("div",{className:"grid grid-cols-2 gap-2 max-w-xs mx-auto",children:[r.jsx(wo,{label:"True Positive",abbr:"TP",count:m.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(wo,{label:"False Positive",abbr:"FP",count:m.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(wo,{label:"False Negative",abbr:"FN",count:m.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(wo,{label:"True Negative",abbr:"TN",count:m.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]})]})]}),r.jsx(tE,{history:C,expanded:w,onToggle:()=>O(!w),skillVersion:T})]})}function tE({history:t,expanded:a,onToggle:s,skillVersion:o}){return t===null?null:r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{className:"w-full px-4 py-3 flex items-center justify-between text-left",style:{borderBottom:a?"1px solid var(--border-subtle)":"none"},onClick:s,children:[r.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:["Test History",t.length>0&&r.jsxs("span",{className:"ml-2 font-normal",style:{color:"var(--text-tertiary)"},children:["(",t.length," run",t.length!==1?"s":"",")"]})]}),r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{transform:a?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:r.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),a&&r.jsx("div",{className:"px-4 py-3",children:t.length===0?r.jsx("div",{className:"text-[12px] py-4 text-center",style:{color:"var(--text-tertiary)"},children:"No test runs yet"}):r.jsx("div",{className:"space-y-2",children:t.map(c=>r.jsx(nE,{run:c,skillVersion:o},c.id))})})]})}function nE({run:t,skillVersion:a}){const s=Math.round(t.summary.reliability*100),o=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=o;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded-lg",style:{background:"var(--surface-1)"},children:[r.jsx("div",{className:"flex-1 min-w-0",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:rE(t.timestamp)}),r.jsx(ni,{version:a??null,size:"sm","data-testid":"activation-row-version"}),r.jsx("span",{className:"pill text-[9px] px-1.5",style:{background:"var(--surface-2)",color:"var(--text-tertiary)"},children:t.model||t.provider}),r.jsxs("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[t.promptCount," prompts"]})]})}),r.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:o,fontVariantNumeric:"tabular-nums"},children:[s,"%"]}),r.jsx("span",{className:"text-[10px] font-medium px-2 py-0.5 rounded",style:{color:u,background:`color-mix(in srgb, ${u} 10%, transparent)`},children:c})]})]})}function rE(t){const a=Date.now(),s=new Date(t).getTime(),o=Math.floor((a-s)/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c}m ago`;const u=Math.floor(c/60);if(u<24)return`${u}h ago`;const d=Math.floor(u/24);return d<7?`${d}d ago`:new Date(t).toLocaleDateString()}function ko(){return r.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function qg({result:t}){const a=Wg[t.classification]||Wg.FN,s=t.classification==="TP"||t.classification==="TN";return r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:a.bg,border:"1px solid transparent"},children:[r.jsx("div",{className:"flex-shrink-0 mt-0.5",children:r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`color-mix(in srgb, ${a.text} 20%, transparent)`},children:s?r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:a.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"flex items-center gap-2 mb-1",children:r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:t.prompt})}),r.jsxs("div",{className:"flex items-center gap-3 text-[12px]",children:[r.jsx("span",{className:"pill",style:{background:"var(--surface-3)",color:a.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},children:t.classification}),r.jsx("span",{style:{color:t.activate?"var(--green)":"var(--text-tertiary)"},children:t.activate?"Activated":"Silent"}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:["Expected: ",t.expected==="should_activate"?"activate":"stay silent"]}),r.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[t.confidence," confidence"]}),t.autoClassified&&r.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},children:"auto"})]}),t.reasoning&&r.jsx("div",{className:"text-[11px] mt-1.5",style:{color:"var(--text-tertiary)"},children:t.reasoning})]})]})}function Bd({label:t,value:a,description:s,detail:o}){const c=Math.round(a*100),u=c>=80?"var(--green)":c>=60?"var(--yellow)":"var(--red)";return r.jsxs("div",{className:"text-center",children:[r.jsxs("div",{className:"text-[28px] font-bold tracking-tight",style:{color:u},children:[c,"%"]}),r.jsx("div",{className:"text-[12px] font-medium mt-0.5",style:{color:"var(--text-secondary)"},children:t}),r.jsx("div",{className:"text-[10px] mt-1",style:{color:"var(--text-tertiary)"},children:s}),r.jsx("div",{className:"text-[10px] mt-0.5 font-mono",style:{color:"var(--text-tertiary)"},children:o})]})}function wo({abbr:t,count:a,bg:s,color:o,description:c}){return r.jsxs("div",{className:"text-center p-3 rounded-lg",style:{background:s},children:[r.jsx("div",{className:"text-[20px] font-bold",style:{color:o},children:a}),r.jsx("div",{className:"text-[11px] font-semibold",style:{color:o},children:t}),r.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function aE({startedAt:t}){const[a,s]=p.useState(0);return p.useEffect(()=>{const o=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(o)},[t]),r.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}const Id={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},Yg={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},df=600,ff=180,cn=40,Ud=df-cn*2,aa=ff-cn*2,lE=[25,50,75,100];function Kg(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function sE(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function iE({entries:t,onPointClick:a}){const[s,o]=p.useState(null),c=p.useMemo(()=>[...t].reverse(),[t]);if(c.length<2)return null;const u=c.length,d=c.map((m,y)=>{const v=cn+y/(u-1)*Ud,b=m.passRate*100,S=cn+aa-b/100*aa;return{x:v,y:S,pct:b,entry:m}}),h=d.map(m=>`${m.x},${m.y}`).join(" "),g=Array.from(new Set(c.map(m=>m.type)));return r.jsxs("div",{className:"glass-card p-5 animate-fade-in",style:{position:"relative",overflowX:u>=20?"auto":void 0},children:[r.jsx("div",{className:"text-[13px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"Pass Rate Trend"}),r.jsx("div",{className:"flex items-center gap-5 mb-3",children:g.map(m=>r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("div",{className:"w-3 h-3 rounded-full",style:{background:Id[m]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:Yg[m]??m})]},m))}),r.jsxs("svg",{width:df,height:ff,viewBox:`0 0 ${df} ${ff}`,style:{display:"block",overflow:"visible"},children:[lE.map(m=>{const y=cn+aa-m/100*aa;return r.jsxs("g",{children:[r.jsx("line",{x1:cn,y1:y,x2:cn+Ud,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:cn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[m,"%"]})]},m)}),r.jsx("line",{x1:cn,y1:cn+aa,x2:cn+Ud,y2:cn+aa,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:cn-8,y:cn+aa+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:"0%"}),r.jsx("polyline",{points:h,fill:"none",stroke:"var(--border-subtle)",strokeWidth:1.5,strokeLinejoin:"round"}),d.map((m,y)=>r.jsx("circle",{cx:m.x,cy:m.y,r:5,fill:Id[m.entry.type]??"var(--text-tertiary)",stroke:"var(--surface-2)",strokeWidth:2,style:{cursor:"pointer",transition:"r 0.15s ease"},onMouseEnter:v=>{v.currentTarget.setAttribute("r","7"),o({x:m.x,y:m.y,entry:m.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),o(null)},onClick:()=>a==null?void 0:a(m.entry)},y)),oE(u).map(m=>r.jsx("text",{x:d[m].x,y:cn+aa+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:Kg(c[m].timestamp)},m))]}),s&&r.jsxs("div",{style:{position:"absolute",left:s.x,top:s.y-12,transform:"translate(-50%, -100%)",background:"var(--surface-3)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:"8px 12px",pointerEvents:"none",zIndex:10,whiteSpace:"nowrap"},children:[r.jsx("div",{className:"text-[11px] font-medium",style:{color:"var(--text-primary)"},children:Kg(s.entry.timestamp)}),r.jsx("div",{className:"text-[11px] mt-0.5",style:{color:"var(--text-tertiary)"},children:s.entry.model}),r.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[r.jsx("span",{className:"text-[9px] font-semibold px-1.5 py-0.5 rounded-full",style:{background:Id[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:Yg[s.entry.type]??s.entry.type}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:"var(--text-primary)"},children:[Math.round(s.entry.passRate*100),"%"]})]}),r.jsxs("div",{className:"text-[10px] mt-1.5 flex items-center gap-3",style:{color:"var(--text-tertiary)"},children:[r.jsx("span",{children:sE(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function oE(t){if(t<=3)return Array.from({length:t},(o,c)=>c);if(t<=6)return[0,Math.floor(t/2),t-1];if(t<20)return[0,Math.floor(t/3),Math.floor(2*t/3),t-1];const a=Math.ceil(t/10),s=[0];for(let o=a;o<t-1;o+=a)s.push(o);return s.push(t-1),s}const Is=new Map;let un=null,Do=null,Co=1e3,Al=0;function Dy(){if(un)return;un=new EventSource("/api/events");const t=a=>s=>{let o={};try{o=s.data?JSON.parse(s.data):{}}catch{}const c=Is.get(a);if(c)for(const u of c)u(o)};un.addEventListener("benchmark:complete",t("benchmark:complete")),un.addEventListener("history:written",t("history:written")),un.addEventListener("leaderboard:updated",t("leaderboard:updated")),un.onerror=()=>{un==null||un.close(),un=null,Al>0&&(Do=setTimeout(()=>{Co=Math.min(Co*2,3e4),Dy()},Co))},un.onopen=()=>{Co=1e3}}function cE(){Do!=null&&(clearTimeout(Do),Do=null),un==null||un.close(),un=null}function uE(t,a){return Is.has(t)||Is.set(t,new Set),Is.get(t).add(a),Al++,Dy(),()=>{var s;(s=Is.get(t))==null||s.delete(a),Al--,Al<=0&&(Al=0,queueMicrotask(()=>{Al<=0&&cE()}))}}function Ho(t,a){const s=p.useRef(a);s.current=a,p.useEffect(()=>uE(t,c=>s.current(c)),[t])}function $o(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function dE(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function fE({rate:t,label:a}){const s=Math.round(t*100);return r.jsx("div",{className:"flex items-center gap-3",children:r.jsxs("div",{className:"flex-1",children:[r.jsxs("div",{className:"flex items-center justify-between mb-1",children:[r.jsx("span",{className:"text-[11px] truncate",style:{color:"var(--text-primary)",maxWidth:"70%"},children:a}),r.jsxs("span",{className:"text-[11px] font-semibold",style:{color:$o(t)},children:[s,"%"]})]}),r.jsx("div",{className:"h-1.5 rounded-full overflow-hidden",style:{background:"var(--surface-3)"},children:r.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${s}%`,background:$o(t)}})})]})})}function pE({points:t}){if(t.length<2)return null;const a=200,s=48,o=4,c=t.length,u=t.map((g,m)=>{const y=o+m/(c-1)*(a-o*2),v=o+(s-o*2)-g.passRate*(s-o*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-o} `+u.map(g=>`L ${g.x},${g.y}`).join(" ")+` L ${u[u.length-1].x},${s-o} Z`,h=u.map((g,m)=>`${m===0?"M":"L"} ${g.x},${g.y}`).join(" ");return r.jsxs("svg",{width:a,height:s,style:{display:"block"},children:[r.jsx("path",{d,fill:"var(--accent-muted)"}),r.jsx("path",{d:h,fill:"none",stroke:"var(--accent)",strokeWidth:1.5,strokeLinejoin:"round"}),r.jsx("circle",{cx:u[u.length-1].x,cy:u[u.length-1].y,r:3,fill:"var(--accent)"})]})}function mE({plugin:t,skill:a}){const s=`stats/${t}/${a}`,o=p.useCallback(()=>Ce.getStats(t,a),[t,a]),{data:c,loading:u}=ri(s,o),d=p.useCallback(()=>Tn(s),[s]);if(Ho("benchmark:complete",d),Ho("history:written",d),u)return r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"skeleton h-24 rounded-xl"}),r.jsx("div",{className:"skeleton h-48 rounded-xl"}),r.jsx("div",{className:"skeleton h-36 rounded-xl"})]});if(!c||c.totalRuns===0)return r.jsxs("div",{className:"text-center py-12",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center mx-auto mb-3",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark data yet"}),r.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:"Run some benchmarks to see statistics"})]});const h=c.trendPoints.length>0?c.trendPoints[c.trendPoints.length-1].passRate:0,g=c.trendPoints.length>0?c.trendPoints[0].passRate:0,m=h-g,y=c.assertionStats.slice(0,10);return r.jsxs("div",{className:"space-y-4 stagger-children",children:[r.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Runs"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.totalRuns})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Latest Pass Rate"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:$o(h)},children:[Math.round(h*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Trend"}),r.jsxs("div",{className:"text-[24px] font-bold",style:{color:m>=0?"var(--green)":"var(--red)"},children:[m>=0?"+":"",Math.round(m*100),"%"]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Models Tested"}),r.jsx("div",{className:"text-[24px] font-bold",style:{color:"var(--text-primary)"},children:c.modelStats.length})]}),c.totalCost!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Total Cost"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.totalCost)})]}),c.costPerRun!=null&&r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("div",{className:"text-[10px] uppercase tracking-widest font-semibold mb-1",style:{color:"var(--text-tertiary)"},children:"Avg Cost/Run"}),r.jsx("div",{className:"text-[20px] font-bold",style:{color:"var(--text-primary)"},children:Rn(c.costPerRun)})]})]}),c.trendPoints.length>=2&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Pass Rate Over Time"}),r.jsx(pE,{points:c.trendPoints})]}),c.modelStats.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Model Performance"}),r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[r.jsx("thead",{children:r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("th",{style:{textAlign:"left",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Model"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Runs"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Pass Rate"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Duration"}),r.jsx("th",{style:{textAlign:"center",padding:"6px 8px",color:"var(--text-tertiary)",fontWeight:600,fontSize:11},children:"Avg Cost"})]})}),r.jsx("tbody",{children:c.modelStats.map(v=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("td",{style:{padding:"8px",color:"var(--text-primary)",fontWeight:500},children:v.model}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.runs}),r.jsx("td",{style:{padding:"8px",textAlign:"center"},children:r.jsxs("span",{className:"font-semibold",style:{color:$o(v.avgPassRate)},children:[Math.round(v.avgPassRate*100),"%"]})}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:dE(v.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?Rn(v.avgCost):"N/A"})]},v.model))})]})]}),y.length>0&&r.jsxs("div",{className:"glass-card p-5",children:[r.jsx("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Weakest Assertions"}),r.jsx("div",{className:"space-y-3",children:y.map(v=>r.jsxs("button",{className:"block w-full text-left rounded-lg p-2 -mx-2 transition-colors duration-150",style:{background:"transparent"},onMouseEnter:b=>{b.currentTarget.style.background="var(--surface-2)"},onMouseLeave:b=>{b.currentTarget.style.background="transparent"},onClick:()=>{},children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsxs("span",{className:"text-[10px] font-mono px-1 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.evalId]}),r.jsx("span",{className:"text-[10px] truncate",style:{color:"var(--text-tertiary)"},children:v.evalName}),r.jsxs("span",{className:"text-[10px] ml-auto flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[v.totalRuns," runs"]})]}),r.jsx(fE,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function hE({plugin:t,skill:a}){const[s,o]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState({}),[g,m]=p.useState({});p.useEffect(()=>{Ce.getEvals(t,a).then(o).catch(()=>o(null))},[t,a]);async function y(v){if(c===v){u(null);return}if(u(v),!d[v]){m(b=>({...b,[v]:!0}));try{const b=await Ce.getCaseHistory(t,a,v);h(S=>({...S,[v]:b}))}catch{h(b=>({...b,[v]:[]}))}finally{m(b=>({...b,[v]:!1}))}}}return s?r.jsx("div",{className:"space-y-2 stagger-children",children:s.evals.map(v=>{const b=d[v.id]||[],S=c===v.id,k=g[v.id],E=b.length>0?b[0].pass_rate:null;return r.jsxs("div",{className:"glass-card overflow-hidden",children:[r.jsxs("button",{onClick:()=>y(v.id),className:"w-full text-left p-4 flex items-center gap-3 transition-colors duration-150",style:{background:S?"var(--surface-2)":"transparent"},onMouseEnter:C=>{S||(C.currentTarget.style.background="var(--surface-2)")},onMouseLeave:C=>{S||(C.currentTarget.style.background="transparent")},children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2.5",strokeLinecap:"round",style:{transform:S?"rotate(90deg)":"rotate(0)",transition:"transform 0.2s ease",flexShrink:0},children:r.jsx("polyline",{points:"9 18 15 12 9 6"})}),r.jsxs("span",{className:"text-[11px] font-mono px-1.5 py-0.5 rounded flex-shrink-0",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:["#",v.id]}),r.jsx("span",{className:"text-[13px] font-medium flex-1 truncate",style:{color:"var(--text-primary)"},children:v.name}),b.length>=2&&r.jsx(Ry,{entries:b}),E!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:Dl(E)},children:[Math.round(E*100),"%"]}),b.length>0&&r.jsxs("span",{className:"text-[10px] flex-shrink-0",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:[b.length," runs"]})]}),S&&r.jsx("div",{className:"border-t animate-fade-in",style:{borderColor:"var(--border-subtle)"},children:k?r.jsxs("div",{className:"p-4 flex items-center gap-2",children:[r.jsx("div",{className:"spinner",style:{width:14,height:14}}),r.jsx("span",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Loading history..."})]}):b.length===0?r.jsx("div",{className:"p-4",children:r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No history for this eval case"})}):r.jsx("div",{className:"divide-y",style:{borderColor:"var(--border-subtle)"},children:b.map((C,N)=>r.jsxs("div",{className:"p-4",style:{background:N===0?"var(--surface-2)":"transparent"},children:[r.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:Ny(C.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:C.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:C.type==="benchmark"?"rgba(99,131,255,0.15)":C.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:C.type==="benchmark"?"#6383ff":C.type==="comparison"?"var(--purple)":"#fb923c"},children:C.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:Dl(C.pass_rate)},children:[Math.round(C.pass_rate*100),"%"]})]}),r.jsxs("div",{className:"flex items-center gap-4 mb-2 text-[10px]",style:{fontFamily:"var(--font-mono, monospace)",color:"var(--text-tertiary)"},children:[C.durationMs!=null&&r.jsx("span",{children:Ty(C.durationMs)}),C.tokens!=null&&r.jsxs("span",{children:[C.tokens>=1e3?`${(C.tokens/1e3).toFixed(1)}k`:C.tokens," tok"]})]}),r.jsx("div",{className:"space-y-1",children:C.assertions.map(T=>r.jsxs("div",{className:"flex items-start gap-2 py-0.5",children:[r.jsx("div",{className:"w-3.5 h-3.5 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5",style:{background:T.pass?"var(--green)":"var(--red)"},children:r.jsx("svg",{width:"7",height:"7",viewBox:"0 0 24 24",fill:"none",stroke:"#fff",strokeWidth:"3.5",strokeLinecap:"round",strokeLinejoin:"round",children:T.pass?r.jsx("polyline",{points:"20 6 9 17 4 12"}):r.jsxs(r.Fragment,{children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-primary)"},children:T.text}),T.reasoning&&r.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"var(--text-tertiary)"},children:T.reasoning})]})]},T.id))})]},N))})})]},v.id)})}):r.jsx("div",{className:"text-center py-12",children:r.jsx("p",{className:"text-[13px]",style:{color:"var(--text-tertiary)"},children:"No eval cases found"})})}function xE(){const{state:t,dispatch:a}=An(),{plugin:s,skill:o}=t,{state:c}=er(),u=c.skills.find(I=>I.plugin===s&&I.skill===o),d=(u==null?void 0:u.version)??null,[h,g]=p.useState("timeline"),[m,y]=p.useState(""),[v,b]=p.useState(""),[S,k]=p.useState(!1),[E,C]=p.useState([]),[N,T]=p.useState(null),[A,B]=p.useState(!1),[z,F]=p.useState(null),[w,O]=p.useState(!1),D=`history/${s}/${o}?model=${m}&type=${v}`,U=p.useCallback(()=>Ce.getHistory(s,o,{model:m||void 0,type:v||void 0}),[s,o,m,v]),{data:H,loading:q}=ri(D,U),X=H??[];p.useEffect(()=>{!H||H.length<2||Ce.compareRuns(s,o,H[0].timestamp,H[1].timestamp).then(I=>{const V=I.regressions.filter(ie=>ie.change==="regression");a({type:"SET_REGRESSIONS",regressions:V})}).catch(()=>{})},[H,s,o,a]);const J=p.useCallback(()=>Tn(D),[D]);Ho("history:written",J);const $=p.useCallback(async I=>{if(S){C(V=>V.includes(I)?V.filter(ie=>ie!==I):V.length>=2?[V[1],I]:[...V,I]);return}O(!0);try{const V=await Ce.getHistoryEntry(s,o,I);F(V)}catch{}finally{O(!1)}},[s,o,S]),L=p.useCallback(async()=>{if(E.length===2){B(!0);try{const I=await Ce.compareRuns(s,o,E[0],E[1]);T(I)}catch{}finally{B(!1)}}},[s,o,E]),_=[...new Set(X.map(I=>I.model))];return q?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-48 rounded-xl mb-4"}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("div",{className:"skeleton h-12 rounded-lg"}),r.jsx("div",{className:"skeleton h-12 rounded-lg"})]})]}):r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"flex items-center gap-1 mb-4",children:["timeline","per-eval","statistics"].map(I=>r.jsx("button",{onClick:()=>g(I),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===I?"var(--accent-muted)":"transparent",color:h===I?"var(--accent)":"var(--text-tertiary)"},children:I==="timeline"?"Timeline":I==="per-eval"?"Per Eval":"Statistics"},I))}),h==="timeline"&&r.jsxs("div",{children:[X.length>0&&r.jsx("div",{className:"mb-5 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:r.jsx(iE,{entries:X,onPointClick:I=>$(I.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:m,onChange:I=>y(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),_.map(I=>r.jsx("option",{value:I,children:I},I))]}),r.jsxs("select",{value:v,onChange:I=>b(I.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Types"}),r.jsx("option",{value:"benchmark",children:"Benchmark"}),r.jsx("option",{value:"comparison",children:"Comparison"}),r.jsx("option",{value:"baseline",children:"Baseline"}),r.jsx("option",{value:"model-compare",children:"Model Compare"}),r.jsx("option",{value:"improve",children:"AI Improve"}),r.jsx("option",{value:"instruct",children:"AI Edit"}),r.jsx("option",{value:"ai-generate",children:"AI Generate"}),r.jsx("option",{value:"eval-generate",children:"Eval Generate"})]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:()=>{k(!S),C([]),T(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&E.length===2&&r.jsx("button",{onClick:L,disabled:A,className:"btn btn-primary text-[12px]",children:A?"Comparing...":"Compare"})]}),r.jsx("div",{className:"space-y-2",children:X.length===0?r.jsx("div",{className:"text-center py-8 text-[13px]",style:{color:"var(--text-tertiary)"},children:"No benchmark runs yet"}):X.map(I=>{const V=E.includes(I.timestamp);return r.jsx("button",{onClick:()=>$(I.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:V?"var(--accent-muted)":"var(--surface-1)",border:V?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:ie=>{V||(ie.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:ie=>{V||(ie.currentTarget.style.borderColor="var(--border-subtle)")},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[S&&r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:V?"var(--accent)":"var(--border-default)",background:V?"var(--accent)":"transparent"},children:V&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:new Date(I.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:I.type==="comparison"?"var(--purple-muted)":I.type==="baseline"?"var(--surface-3)":I.type==="model-compare"?"var(--accent-muted)":I.type==="improve"||I.type==="instruct"?"var(--purple-muted)":I.type==="ai-generate"?"var(--green-muted)":I.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:I.type==="comparison"?"var(--purple)":I.type==="baseline"?"var(--text-tertiary)":I.type==="model-compare"?"var(--accent)":I.type==="improve"||I.type==="instruct"?"var(--purple)":I.type==="ai-generate"?"var(--green)":I.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:I.type==="model-compare"?"model compare":I.type==="improve"?"ai improve":I.type==="instruct"?"ai edit":I.type==="ai-generate"?"ai generate":I.type==="eval-generate"?"eval generate":I.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(ni,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:I.model}),I.totalCost!=null&&I.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(I.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:I.passRate>=.8?"var(--green)":I.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(I.passRate*100),"%"]})]})]})},I.timestamp)})}),N&&r.jsx(gE,{result:N}),z&&!S&&r.jsx(vE,{run:z,onClose:()=>F(null)})]}),h==="per-eval"&&r.jsx(hE,{plugin:s,skill:o}),h==="statistics"&&r.jsx(mE,{plugin:s,skill:o})]})}function gE({result:t}){const a=t.regressions.filter(o=>o.change==="regression"),s=t.regressions.filter(o=>o.change==="improvement");return r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:["Comparison: ",new Date(t.runA.timestamp).toLocaleDateString()," vs ",new Date(t.runB.timestamp).toLocaleDateString()]}),(t.runA.totalCost!=null||t.runB.totalCost!=null)&&r.jsxs("div",{className:"flex items-center gap-4 mb-3 text-[11px]",style:{color:"var(--text-secondary)"},children:[r.jsxs("span",{children:["Run A cost: ",Rn(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",Rn(t.runB.totalCost??null)]}),t.runA.totalCost!=null&&t.runB.totalCost!=null&&r.jsxs("span",{style:{color:t.runB.totalCost<=t.runA.totalCost?"var(--green)":"var(--red)"},children:["Delta: ",Rn(t.runB.totalCost-t.runA.totalCost)]})]}),a.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--red)"},children:["Regressions (",a.length,")"]}),a.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--red)"},children:o.assertionId})," (was passing, now failing)"]},`${o.evalId}-${o.assertionId}`))]}),s.length>0&&r.jsxs("div",{className:"mb-3",children:[r.jsxs("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--green)"},children:["Improvements (",s.length,")"]}),s.map(o=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",o.evalId," ",o.evalName,": ",r.jsx("span",{style:{color:"var(--green)"},children:o.assertionId})," (was failing, now passing)"]},`${o.evalId}-${o.assertionId}`))]}),r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2 mt-3",style:{color:"var(--text-tertiary)"},children:"Case Diffs"}),r.jsx("div",{className:"rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:r.jsxs("table",{className:"w-full text-[12px]",children:[r.jsx("thead",{children:r.jsxs("tr",{style:{background:"var(--surface-2)"},children:[r.jsx("th",{className:"text-left px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Case"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run A"}),r.jsx("th",{className:"text-right px-3 py-2 font-medium",style:{color:"var(--text-tertiary)"},children:"Run B"})]})}),r.jsx("tbody",{children:t.caseDiffs.map(o=>r.jsxs("tr",{style:{borderTop:"1px solid var(--border-subtle)"},children:[r.jsxs("td",{className:"px-3 py-2",style:{color:"var(--text-secondary)"},children:["#",o.eval_id," ",o.eval_name]}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateA!=null?o.passRateA>=.8?"var(--green)":o.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateA!=null?`${Math.round(o.passRateA*100)}%`:o.statusA}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:o.passRateB!=null?o.passRateB>=.8?"var(--green)":o.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:o.passRateB!=null?`${Math.round(o.passRateB*100)}%`:o.statusB})]},o.eval_id))})]})})]})}function vE({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(yE,{run:t,onClose:a}):r.jsxs("div",{className:"mt-4 rounded-xl p-4",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:["Run: ",new Date(t.timestamp).toLocaleString()]}),r.jsx("button",{onClick:a,className:"btn btn-ghost text-[11px]",children:"Close"})]}),r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:["Model: ",t.model," | Cases: ",t.cases.length," | Pass Rate: ",t.overall_pass_rate!=null?`${Math.round(t.overall_pass_rate*100)}%`:"--",t.totalCost!=null&&t.totalCost>0&&` | Cost: ${Rn(t.totalCost)}`]}),r.jsx("div",{className:"space-y-2",children:t.cases.map(s=>r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-2)"},children:r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("span",{className:"text-[12px]",style:{color:"var(--text-secondary)"},children:["#",s.eval_id," ",s.eval_name]}),r.jsxs("div",{className:"flex items-center gap-2",children:[s.cost!=null&&s.cost>0&&r.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-tertiary)"},children:Rn(s.cost)}),r.jsx("span",{className:"text-[11px] font-semibold",style:{color:s.status==="pass"?"var(--green)":"var(--red)"},children:s.pass_rate!=null?`${Math.round(s.pass_rate*100)}%`:s.status})]})]})},s.eval_id))})]})}function yE({run:t,onClose:a}){var u;const s=p.useMemo(()=>t.improve?Jo(t.improve.original,t.improve.improved):[],[t.improve]),o=p.useMemo(()=>{const d=s.filter(g=>g.type==="added").length,h=s.filter(g=>g.type==="removed").length;return{added:d,removed:h}},[s]),c=p.useMemo(()=>{let d=0,h=0;return s.map(g=>g.type==="removed"?(d++,{...g,origNum:d,newNum:null}):g.type==="added"?(h++,{...g,origNum:null,newNum:h}):(d++,h++,{...g,origNum:d,newNum:h}))},[s]);return r.jsxs("div",{className:"mt-4 rounded-xl overflow-hidden animate-fade-in",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center",style:{background:"var(--purple-muted)"},children:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--purple)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),r.jsx("path",{d:"M2 17l10 5 10-5"}),r.jsx("path",{d:"M2 12l10 5 10-5"})]})}),r.jsxs("div",{children:[r.jsx("div",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md Changes"}),r.jsxs("div",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:[new Date(t.timestamp).toLocaleString()," · ",t.model]})]})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsxs("span",{style:{color:"var(--green)"},children:["+",o.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",o.removed]})]}),r.jsx("button",{onClick:a,className:"w-7 h-7 rounded-lg flex items-center justify-center transition-colors duration-150",style:{color:"var(--text-tertiary)"},onMouseEnter:d=>{d.currentTarget.style.background="var(--surface-3)"},onMouseLeave:d=>{d.currentTarget.style.background="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),((u=t.improve)==null?void 0:u.reasoning)&&r.jsxs("div",{className:"mx-4 mt-4 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--purple-muted)",border:"1px solid var(--purple-muted)",color:"var(--text-secondary)"},children:[r.jsx("span",{className:"font-semibold",style:{color:"var(--purple)"},children:"AI Reasoning: "}),t.improve.reasoning]}),r.jsx("div",{className:"mx-4 my-4 rounded-lg overflow-hidden",style:{border:"1px solid var(--border-subtle)",maxHeight:480,overflowY:"auto"},children:r.jsx("table",{className:"w-full",style:{borderCollapse:"collapse",fontFamily:"var(--font-mono, monospace)"},children:r.jsx("tbody",{children:c.map((d,h)=>r.jsxs("tr",{style:{background:d.type==="added"?"var(--green-muted)":d.type==="removed"?"var(--red-muted)":"transparent"},children:[r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="removed"?"var(--red)":"var(--text-tertiary)",opacity:d.origNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.origNum??""}),r.jsx("td",{className:"text-right select-none px-2",style:{width:40,fontSize:10,color:d.type==="added"?"var(--green)":"var(--text-tertiary)",opacity:d.newNum?.6:.2,borderRight:"1px solid var(--border-subtle)"},children:d.newNum??""}),r.jsx("td",{className:"select-none text-center",style:{width:20,fontSize:11,fontWeight:700,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"transparent",borderRight:d.type==="added"?"2px solid var(--green)":d.type==="removed"?"2px solid var(--red)":"2px solid transparent"},children:d.type==="added"?"+":d.type==="removed"?"-":" "}),r.jsx("td",{className:"px-3 py-px whitespace-pre-wrap",style:{fontSize:11,lineHeight:1.6,color:d.type==="added"?"var(--green)":d.type==="removed"?"var(--red)":"var(--text-secondary)"},children:d.content||"​"})]},h))})})})]})}function _y({data:t}){if(t.length<2)return r.jsx("span",{style:{color:"var(--text-tertiary)",fontSize:10},children:"--"});const a=t.slice(-10),s=80,o=24,c=2,u=s-c*2,d=o-c*2,h=a.length,g=Math.min(...a),y=Math.max(...a)-g||1,v=a.map((k,E)=>{const C=c+E/(h-1)*u,N=c+d-(k-g)/y*d;return`${C.toFixed(1)},${N.toFixed(1)}`}),b=a[a.length-1],S=Dl(b);return r.jsxs("svg",{width:s,height:o,viewBox:`0 0 ${s} ${o}`,style:{display:"block"},children:[r.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[k,E]=v[v.length-1].split(",");return r.jsx("circle",{cx:k,cy:E,r:2.5,fill:S})})()]})}function bE(){return r.jsxs("span",{className:"pill",style:{background:"var(--yellow-muted)",color:"var(--yellow)",fontSize:9,fontWeight:700,gap:3},children:[r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"var(--yellow)",stroke:"none",children:r.jsx("polygon",{points:"12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"})}),"Best Model"]})}function jE({pct:t}){const a=t>=10?"var(--green)":t>=0?"var(--yellow)":"var(--red)",s=t>=10?"var(--green-muted)":t>=0?"var(--yellow-muted)":"var(--red-muted)",o=t>=0?"+":"";return r.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[o,t.toFixed(1),"%"]})}function SE({score:t,rating:a}){const s={excellent:{bg:"var(--green-muted)",fg:"var(--green)"},good:{bg:"var(--green-muted)",fg:"var(--green)"},marginal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},minimal:{bg:"var(--yellow-muted)",fg:"var(--yellow)"},harmful:{bg:"var(--red-muted)",fg:"var(--red)"}},o=s[a]??s.minimal,c=t>=0?"+":"";return r.jsxs("div",{className:"flex items-center gap-2 mt-3",children:[r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"Skill Quality:"}),r.jsxs("span",{className:"pill",style:{background:o.bg,color:o.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function kE({warning:t}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg mb-3",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow-muted)"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--yellow)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--yellow)"},children:t})]})}function wE({active:t,onChange:a,hasBaseline:s}){return r.jsxs("div",{className:"flex gap-1 p-0.5 rounded-lg",style:{background:"var(--surface-2)"},children:[r.jsx("button",{onClick:()=>a("rankings"),className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="rankings"?"var(--surface-3)":"transparent",color:t==="rankings"?"var(--text-primary)":"var(--text-tertiary)"},children:"Rankings"}),r.jsx("button",{onClick:()=>a("amplification"),disabled:!s,className:"px-3 py-1 rounded-md text-[11px] font-medium transition-all",style:{background:t==="amplification"?"var(--surface-3)":"transparent",color:s&&t==="amplification"?"var(--text-primary)":"var(--text-tertiary)",opacity:s?1:.5,cursor:s?"pointer":"not-allowed"},title:s?"View skill amplification data":"Run sweep with --baseline to see amplification data",children:"Skill Amplification"})]})}function CE(t){var o,c,u;if(t.length===0)return[];const a=new Map;for(const d of t)for(const h of d.models){if(h.status==="error")continue;const g=`${h.provider}/${h.model}`;a.has(g)||a.set(g,{provider:h.provider,passRates:[],lastRubric:null,lastDuration:0,lastCost:null,lastBaselinePassRate:void 0,lastSkillDelta:void 0,lastAmplificationPct:void 0,lastCompositeScore:void 0,hasBaseline:!1});const m=a.get(g);m.passRates.push(h.passRate.mean),m.lastRubric=((o=h.rubricScore)==null?void 0:o.mean)??null,m.lastDuration=h.duration.mean,m.lastCost=((c=h.cost)==null?void 0:c.total)??null,m.lastCompositeScore=h.compositeScore,h.baselinePassRate!=null&&(m.lastBaselinePassRate=h.baselinePassRate.mean,m.lastSkillDelta=(u=h.skillDelta)==null?void 0:u.mean,m.lastAmplificationPct=h.amplificationPct,m.hasBaseline=!0)}const s=[];for(const[d,h]of a){const[g,...m]=d.split("/");s.push({rank:0,model:m.join("/"),provider:g,passRate:h.passRates[h.passRates.length-1],rubricScore:h.lastRubric,duration:h.lastDuration,cost:h.lastCost,sparklineData:h.passRates,isBest:!1,baselinePassRate:h.lastBaselinePassRate,skillDelta:h.lastSkillDelta,amplificationPct:h.lastAmplificationPct,compositeScore:h.lastCompositeScore,hasBaseline:h.hasBaseline})}return s.sort((d,h)=>{const g=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-g}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const Oy=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function EE({entries:t}){return r.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","Pass Rate","Rubric","Duration","Cost","Trend"].map(a=>r.jsx("th",{style:Oy(a==="#"?"center":"left"),children:a},a))})}),r.jsx("tbody",{children:t.map(a=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:s=>{s.currentTarget.style.background="var(--surface-2)"},onMouseLeave:s=>{s.currentTarget.style.background="transparent"},children:[r.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:a.rank}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:a.model}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:a.provider}),a.isBest&&r.jsx(bE,{})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:a.passRate>=.7?"var(--green-muted)":a.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Dl(a.passRate),fontSize:11,fontWeight:600},children:[Math.round(a.passRate*100),"%"]})}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.rubricScore!=null?a.rubricScore.toFixed(1):"--"}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.duration<1e3?`${Math.round(a.duration)}ms`:`${(a.duration/1e3).toFixed(1)}s`}),r.jsx("td",{style:{padding:"10px 12px",fontSize:12,color:"var(--text-secondary)"},children:a.cost!=null?`$${a.cost.toFixed(4)}`:"N/A"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(_y,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function NE({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,o)=>(o.amplificationPct??0)-(s.amplificationPct??0));return a.length===0?r.jsx("div",{className:"flex items-center justify-center py-8",children:r.jsx("div",{className:"text-center",children:r.jsxs("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:["No baseline data available. Run sweep with ",r.jsx("code",{children:"--baseline"})," flag."]})})}):r.jsx("div",{className:"glass-card",style:{overflow:"hidden"},children:r.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[r.jsx("thead",{children:r.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Model","With Skill","Without Skill","Delta","Amplification","Trend"].map(s=>r.jsx("th",{style:Oy(s==="#"?"center":"left"),children:s},s))})}),r.jsx("tbody",{children:a.map((s,o)=>r.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},onMouseEnter:c=>{c.currentTarget.style.background="var(--surface-2)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},children:[r.jsx("td",{style:{padding:"10px 12px",textAlign:"center",fontSize:12,fontWeight:600,color:"var(--text-tertiary)",width:40},children:o+1}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:s.model}),r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)"},children:s.provider})]})}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsxs("span",{className:"pill",style:{background:s.passRate>=.7?"var(--green-muted)":s.passRate>=.4?"var(--yellow-muted)":"var(--red-muted)",color:Dl(s.passRate),fontSize:11,fontWeight:600},children:[Math.round(s.passRate*100),"%"]})}),r.jsx("td",{style:{padding:"10px 12px"},children:s.baselinePassRate!=null?r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:[Math.round(s.baselinePassRate*100),"%"]}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:s.skillDelta!=null?r.jsxs("span",{className:"text-[11px] font-medium",style:{color:s.skillDelta>=0?"var(--green)":"var(--red)"},children:[s.skillDelta>=0?"+":"",(s.skillDelta*100).toFixed(1),"pp"]}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:s.amplificationPct!=null&&isFinite(s.amplificationPct)?r.jsx(jE,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(_y,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function TE(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=p.useState("rankings"),u=`leaderboard/${a}/${s}`,d=p.useCallback(()=>Ce.getLeaderboard(a,s),[a,s]),{data:h,loading:g}=ri(u,d),m=(h==null?void 0:h.entries)??[];p.useEffect(()=>{c("rankings")},[a,s]);const y=p.useCallback(()=>Tn(u),[u]);Ho("leaderboard:updated",y);const v=p.useMemo(()=>CE(m),[m]),b=v.some(E=>E.hasBaseline),S=m[0],k=S==null?void 0:S.judgeBiasWarning;return g?r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx("div",{className:"spinner spinner-lg"})}):v.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-4 px-8",children:[r.jsx("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M18 20V10"}),r.jsx("path",{d:"M12 20V4"}),r.jsx("path",{d:"M6 20v-6"})]})}),r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No sweep results yet"}),r.jsx("div",{className:"text-[12px] mb-3",style:{color:"var(--text-tertiary)"},children:"Run your first model sweep to compare performance across models:"}),r.jsx("div",{className:"text-[11px] font-mono px-4 py-3 rounded-lg text-left",style:{background:"var(--surface-2)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)"},children:'vskill eval sweep --models "anthropic/claude-sonnet-4,openrouter/meta-llama/llama-3.1-70b" --judge "anthropic/claude-sonnet-4"'}),r.jsxs("div",{className:"text-[11px] mt-2",style:{color:"var(--text-tertiary)"},children:["Add ",r.jsx("code",{children:"--baseline"})," to measure skill amplification per model."]})]})]}):r.jsxs("div",{className:"p-5 animate-fade-in",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"text-[15px] font-semibold",style:{color:"var(--text-primary)"},children:"Model Leaderboard"}),r.jsx(wE,{active:o,onChange:c,hasBaseline:b})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[m.length," sweep",m.length!==1?"s":""," · ",v.length," model",v.length!==1?"s":""]})]}),k&&r.jsx(kE,{warning:k}),o==="rankings"?r.jsx(EE,{entries:v}):r.jsx(NE,{entries:v}),o==="amplification"&&(S==null?void 0:S.skillQualityScore)!=null&&(S==null?void 0:S.skillQualityRating)&&r.jsx(SE,{score:S.skillQualityScore,rating:S.skillQualityRating})]})}function RE({plugin:t,skill:a}){const[s,o]=p.useState([]),[c,u]=p.useState([]),[d,h]=p.useState(!0),[g,m]=p.useState(null);p.useEffect(()=>{Ce.getDependencies(t,a).then(v=>{o(v.mcpDependencies),u(v.skillDependencies)}).catch(()=>{}).finally(()=>h(!1))},[t,a]);async function y(v,b){try{await navigator.clipboard.writeText(b),m(v),setTimeout(()=>m(null),2e3)}catch{}}return d?null:s.length===0&&c.length===0?r.jsx("div",{className:"mb-5 px-4 py-3 rounded-lg text-[12px]",style:{background:"var(--surface-2)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:"No dependencies detected"}):r.jsxs("div",{className:"mb-5 rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsxs("div",{className:"flex items-center gap-2.5 px-5 py-3.5",style:{background:"var(--surface-2)",borderBottom:"1px solid var(--border-subtle)"},children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"rgba(234,179,8,0.15)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#eab308",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),r.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"Dependencies"}),r.jsx("span",{className:"pill text-[10px]",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:s.length+c.length})]}),r.jsxs("div",{className:"px-5 py-4",children:[s.length>0&&r.jsxs("div",{className:"space-y-3 mb-4",children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"MCP Servers"}),s.map(v=>r.jsxs("div",{className:"p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:v.server}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.transport})]}),r.jsx("button",{onClick:()=>y(v.server,v.configSnippet),className:"btn btn-ghost text-[11px] py-1 px-2",style:{color:g===v.server?"var(--green)":"var(--accent)"},children:g===v.server?r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})," Copied!"]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})," Copy Config"]})})]}),r.jsx("div",{className:"text-[11px] mb-2 font-mono",style:{color:"var(--text-tertiary)"},children:v.url}),r.jsx("div",{className:"flex flex-wrap gap-1.5",children:v.matchedTools.map(b=>r.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono",style:{background:"var(--surface-3)",color:"var(--text-secondary)"},children:b},b))})]},v.server))]}),c.length>0&&r.jsxs("div",{children:[r.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Skill Dependencies"}),r.jsx("div",{className:"space-y-1.5",children:c.map(v=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})}),r.jsx("span",{className:"text-[12px] font-medium",style:{color:"var(--text-primary)"},children:v.name}),r.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:v.source==="frontmatter"?"frontmatter":"referenced"})]},v.name))})]})]})]})}function Xg({plugin:t,skill:a}){const[s,o]=p.useState([]),[c,u]=p.useState(!0),[d,h]=p.useState(null),[g,m]=p.useState(""),[y,v]=p.useState(!1),[b,S]=p.useState(null),[k,E]=p.useState(""),[C,N]=p.useState(""),[T,A]=p.useState(!1),[B,z]=p.useState(new Set),F=p.useCallback(async()=>{u(!0);try{const[U,H]=await Promise.all([Ce.getCredentials(t,a).catch(()=>({credentials:[]})),Ce.getParams(t,a).catch(()=>({params:[]}))]),q=new Map(H.params.map($=>[$.name,$])),X=new Set,J=[];for(const $ of U.credentials){X.add($.name);const L=q.get($.name);J.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:L==null?void 0:L.maskedValue})}for(const $ of H.params)X.has($.name)||J.push({name:$.name,status:$.status,maskedValue:$.maskedValue});o(J)}finally{u(!1)}},[t,a]);p.useEffect(()=>{F()},[F]);const w=p.useCallback(async U=>{if(B.has(U)){z(H=>{const q=new Set(H);return q.delete(U),q}),o(H=>H.map(q=>q.name===U?{...q,revealedValue:void 0}:q));return}try{const q=(await Ce.getParamsRevealed(t,a,U)).params.find(X=>X.name===U);q&&(o(X=>X.map(J=>J.name===U?{...J,revealedValue:q.value}:J)),z(X=>new Set(X).add(U)))}catch{}},[t,a,B]),O=async(U,H)=>{if(!(!U.trim()||!H.trim())){v(!0),S(null);try{await Ce.setCredential(t,a,U,H),h(null),m(""),z(new Set),F()}catch(q){S(q.message)}finally{v(!1)}}},D=async()=>{if(!(!k.trim()||!C.trim())){v(!0),S(null);try{await Ce.setCredential(t,a,k.trim().toUpperCase(),C),E(""),N(""),A(!1),F()}catch(U){S(U.message)}finally{v(!1)}}};return c?r.jsxs("div",{className:"mt-6",children:[r.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("div",{className:"skeleton h-20 rounded-xl"})]}):r.jsxs("div",{className:"mt-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wider",style:{color:"var(--text-tertiary)"},children:"Parameters & Secrets"}),r.jsx("button",{onClick:()=>A(!T),className:"text-[11px] transition-colors duration-150",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"+ Add Parameter"})]}),b&&r.jsx("div",{className:"mb-2 px-3 py-2 rounded-lg text-[11px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:b}),s.length===0&&!T?r.jsx("div",{className:"text-[12px] text-center py-6 rounded-xl",style:{color:"var(--text-tertiary)",background:"var(--surface-2)"},children:"No credentials configured for this skill"}):r.jsx("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid var(--border-subtle)"},children:s.map(U=>r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)"},children:[r.jsx("span",{className:"text-[11px] font-mono font-medium truncate",style:{color:"var(--text-primary)",minWidth:80},children:U.name}),U.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:B.has(U.name)&&U.revealedValue!=null?U.revealedValue:U.maskedValue}),U.maskedValue&&r.jsx("button",{onClick:()=>w(U.name),className:"btn btn-ghost px-1",title:B.has(U.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:B.has(U.name)?r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94"}),r.jsx("path",{d:"M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19"}),r.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]}):r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),r.jsx("span",{className:"text-[10px] font-semibold px-2 py-0.5 rounded-full",style:{background:U.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:U.status==="ready"?"var(--green)":"var(--orange)"},children:U.status==="ready"?"ready":"missing"}),U.source&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:U.source}),d===U.name?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("input",{value:g,onChange:H=>m(H.target.value),onKeyDown:H=>{H.key==="Enter"&&O(U.name,g)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>O(U.name,g),disabled:y||!g.trim(),className:"btn btn-primary text-[10px] px-2 py-0.5",children:y?"...":"Save"}),r.jsx("button",{onClick:()=>{h(null),m("")},className:"btn btn-ghost text-[10px] px-1",children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):r.jsx("button",{onClick:()=>{h(U.name),m("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},U.name))}),T&&r.jsxs("div",{className:"mt-2 p-3 rounded-lg",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:k,onChange:U=>E(U.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:C,onChange:U=>N(U.target.value),onKeyDown:U=>{U.key==="Enter"&&D()},className:"input-field flex-1 text-[11px] font-mono",placeholder:"Value",type:"password"})]}),r.jsxs("div",{className:"flex justify-end gap-1.5",children:[r.jsx("button",{onClick:()=>{A(!1),E(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:D,disabled:y||!k.trim()||!C.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function AE(){const{state:t}=An(),{plugin:a,skill:s}=t,[o,c]=p.useState(null),[u,d]=p.useState(!0);return p.useEffect(()=>{Ce.getDependencies(a,s).then(c).catch(()=>{}).finally(()=>d(!1))},[a,s]),u?r.jsxs("div",{className:"p-5",children:[r.jsx("div",{className:"skeleton h-5 w-32 mb-4"}),r.jsx("div",{className:"skeleton h-32 rounded-xl"})]}):o?r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx(RE,{plugin:a,skill:s}),r.jsx(Xg,{plugin:a,skill:s})]}):r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx("div",{className:"text-[13px] mb-4",style:{color:"var(--text-tertiary)"},children:"No MCP dependency information available"}),r.jsx(Xg,{plugin:a,skill:s})]})}function ME(t){const a={prompt:t.prompt,provider:t.provider,model:t.model};return t.targetAgents&&t.targetAgents.length>0&&(a.targetAgents=t.targetAgents),a}function LE(t){var c;const a=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,o=t.forceLayout===3;return{applyName:a?null:t.aiName??null,applySuggestedPlugin:!o&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:o||s?null:t.aiSuggestedPlugin??null}}function pf(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function zE(t,a,s,o){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(a){case 1:return`${u}/${s}/skills/${o}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${o}/SKILL.md`;case 3:return`${u}/skills/${o}/SKILL.md`}}function DE({onCreated:t,resolveAiConfigOverride:a,forceLayout:s}){const[o,c]=p.useState("ai"),[u,d]=p.useState(null),[h,g]=p.useState(!0),{config:m}=$a(),[y,v]=p.useState(""),[b,S]=p.useState(s??3),[k,E]=p.useState(""),[C,N]=p.useState(""),[T,A]=p.useState(""),[B,z]=p.useState(""),[F,w]=p.useState(""),[O,D]=p.useState(""),[U,H]=p.useState("write"),[q,X]=p.useState([]),[J,$]=p.useState(!1),[L,_]=p.useState(null),[I,V]=p.useState(null),[ie,M]=p.useState("vskill"),[Y,G]=p.useState("1.0.0"),[te,fe]=p.useState(!0),oe=p.useCallback(async()=>{try{const Ie=await Ce.detectEngines();V(Ie),M(le=>le!=="vskill"?le:Ie.vskillSkillBuilder?"vskill":Ie.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{V({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{oe()},[oe]);const[ve,de]=p.useState(""),[je,Re]=p.useState(!1),[_e,ae]=p.useState(!1),[he,pe]=p.useState(null),[xe,be]=p.useState(null),[Be,Oe]=p.useState([]),lt=p.useRef(null),Nt=p.useRef(null),xt=p.useRef(null),_t=p.useRef(null),Tt=p.useRef(null),[Ze,nt]=p.useState(!1),[ye,mt]=p.useState(!1),Et=p.useRef(y),Xt=p.useRef(k),fn=p.useRef(C);p.useEffect(()=>{Et.current=y},[y]),p.useEffect(()=>{Xt.current=k},[k]),p.useEffect(()=>{fn.current=C},[C]),p.useEffect(()=>{Ce.getProjectLayout().then(Ie=>{if(d(Ie),s)return;S(Ie.suggestedLayout);const le=Ie.detectedLayouts.find(Se=>Se.layout===Ie.suggestedLayout);le!=null&&le.existingPlugins.length&&E(le.existingPlugins[0])}).catch(()=>{}).finally(()=>g(!1))},[s]),p.useEffect(()=>{var Ie;o==="ai"&&((Ie=lt.current)==null||Ie.focus())},[o]),p.useEffect(()=>()=>{var Ie;(Ie=Nt.current)==null||Ie.abort()},[]);const Wt=p.useMemo(()=>{var Ie;return u?((Ie=u.detectedLayouts.find(le=>le.layout===b))==null?void 0:Ie.existingPlugins)||[]:[]},[u,b]),ln=k==="__new__"?C:k,Mn=u?zE(u.root,b,ln||"{plugin}",y||"{skill}"):"",Lt=p.useMemo(()=>u?u.detectedLayouts.filter(Ie=>Ie.layout!==4):[],[u]),vt=p.useMemo(()=>{if(!u)return null;const Ie=u.detectedLayouts.find(Me=>Me.layout===2&&Me.existingPlugins.length>0),le=u.detectedLayouts.find(Me=>Me.layout===1&&Me.existingPlugins.length>0),Se=Ie||le;return Se?{layout:Se.layout,plugins:Se.existingPlugins}:null},[u]),gt=p.useCallback(()=>{if(a)return a();if(!m)return{provider:"claude-cli",model:"sonnet"};const Ie=m.provider||"claude-cli",le=m.model||"sonnet";return{provider:Ie,model:le}},[m,a]),Wn=p.useCallback(()=>{var Ie;(Ie=Nt.current)==null||Ie.abort(),Re(!1)},[]),zr=p.useCallback(()=>{pe(null),be(null)},[]),dr=p.useCallback(async()=>{var Me,Fa;if(pe(null),be(null),Oe([]),xt.current=null,_t.current=null,!ve.trim()){pe("Describe what your skill should do");return}Re(!0);const Ie=new AbortController;Nt.current=Ie;const{provider:le,model:Se}=gt();try{const qn=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ME({prompt:ve.trim(),provider:le,model:Se,targetAgents:q})),signal:Ie.signal});if(!qn.ok||!qn.body){let pa=`HTTP ${qn.status}`;try{const ma=await qn.json();ma.error&&(pa=ma.error)}catch{}throw new Error(pa)}const Ul=qn.body.getReader(),fa=new TextDecoder;let Hl="",tr="";for(;;){const{done:pa,value:ma}=await Ul.read();if(pa)break;Hl+=fa.decode(ma,{stream:!0});const Ga=Hl.split(`
86
+ `);Hl=Ga.pop()||"";for(const Dr of Ga)if(Dr.startsWith("event: "))tr=Dr.slice(7).trim();else if(Dr.startsWith("data: ")){try{const ot=JSON.parse(Dr.slice(6));if(tr==="progress")Oe(ha=>[...ha,{phase:ot.phase,message:ot.message,timestamp:Date.now()}]);else if(tr==="provenance")_t.current={resolvedModelId:typeof ot.resolvedModelId=="string"?ot.resolvedModelId:null,snapshotDate:typeof ot.snapshotDate=="string"?ot.snapshotDate:null};else if(tr==="done"||tr==="complete"){const ha={prompt:ve.trim(),provider:gt().provider,model:gt().model,resolvedModelId:((Me=_t.current)==null?void 0:Me.resolvedModelId)??null,snapshotDate:((Fa=_t.current)==null?void 0:Fa.snapshotDate)??null,reasoning:ot.reasoning||""},sn=LE({userName:Et.current,userPlugin:Xt.current,userNewPlugin:fn.current,aiName:ot.name,aiSuggestedPlugin:ot.suggestedPlugin&&ot.suggestedPlugin.plugin?{plugin:ot.suggestedPlugin.plugin,layout:ot.suggestedPlugin.layout}:null,forceLayout:s});if(sn.applyName!==null&&v(sn.applyName),A(ot.description),z(ot.model||""),w(ot.allowedTools||""),D(ot.body),ae(!0),xt.current=ha,c("manual"),s===3)S(3),E(""),N("");else if(sn.applySuggestedPlugin&&sn.suggestedPluginValue){const ct=sn.suggestedPluginValue;if(((u==null?void 0:u.detectedLayouts.flatMap(nr=>nr.existingPlugins))??[]).includes(ct.plugin))if(E(ct.plugin),ct.layout&&(ct.layout===1||ct.layout===2))S(ct.layout);else{const nr=u==null?void 0:u.detectedLayouts.find(tc=>tc.existingPlugins.includes(ct.plugin));nr&&(nr.layout===1||nr.layout===2)&&S(nr.layout)}else E("__new__"),N(ct.plugin)}else!sn.applySuggestedPlugin&&Xt.current.trim().length===0&&fn.current.trim().length===0&&b===3&&vt&&mt(!0);const $t={name:ot.name,plugin:ln||"",layout:b,description:ot.description,model:ot.model||void 0,allowedTools:ot.allowedTools||void 0,body:ot.body,aiMeta:ha};Ce.saveDraft($t).then(ct=>{nt(!0),ct!=null&&ct.dir&&(Tt.current=ct.dir)}).catch(()=>{})}else tr==="error"&&(pe(ot.message||ot.description||"Unknown error"),ot.category&&be(ot))}catch{}tr=""}}}catch(qn){qn.name!=="AbortError"&&pe(qn.message)}finally{Re(!1),Nt.current=null}},[ve,gt,b,vt,ln,u,q,s]),Rt=p.useCallback(async()=>{if(_(null),!y.trim()){_("Skill name is required");return}if(!T.trim()){_("Description is required");return}if(b!==3&&!ln.trim()){_("Plugin name is required");return}if(!te){_("Version is not valid semver");return}$(!0);try{const Ie=await Ce.createSkill({name:pf(y),plugin:ln||"",layout:b,description:T,model:B||void 0,allowedTools:F||void 0,body:O,aiMeta:xt.current||void 0,draftDir:Tt.current||void 0,version:Y.trim()||void 0,engine:ie});Tt.current=null,t(Ie.plugin,Ie.skill)}catch(Ie){_(Ie.message)}finally{$(!1)}},[y,T,b,ln,B,F,O,Y,te,ie,t]),qt=p.useCallback(()=>{vt&&(S(vt.layout),E(vt.plugins[0]),mt(!1))},[vt]);return{mode:o,setMode:c,layout:u,layoutLoading:h,selectedLayout:b,setSelectedLayout:S,creatableLayouts:Lt,availablePlugins:Wt,pathPreview:Mn,plugin:k,setPlugin:E,newPlugin:C,setNewPlugin:N,effectivePlugin:ln,name:y,setName:v,description:T,setDescription:A,model:B,setModel:z,allowedTools:F,setAllowedTools:w,body:O,setBody:D,bodyViewMode:U,setBodyViewMode:H,aiPrompt:ve,setAiPrompt:de,generating:je,aiGenerated:_e,aiError:he,aiClassifiedError:xe,aiProgress:Be,promptRef:lt,handleGenerate:dr,handleCancelGenerate:Wn,clearAiError:zr,targetAgents:q,setTargetAgents:X,draftSaved:Ze,showPluginRecommendation:ye,setShowPluginRecommendation:mt,pluginLayoutInfo:vt,applyPluginRecommendation:qt,creating:J,error:L,handleCreate:Rt,engineDetection:I,refreshEngineDetection:oe,engine:ie,setEngine:M,version:Y,setVersion:G,versionValid:te,setVersionValid:fe,standaloneLocked:s===3}}function By(){return r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function _E(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Iy({node:t,depth:a=0}){var s;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex items-center gap-1.5 py-0.5",style:{paddingLeft:`${a*16}px`,color:t.type==="dir"?"var(--text-secondary)":"var(--text-tertiary)",fontSize:12,fontFamily:"var(--font-mono, monospace)"},children:[t.type==="dir"?r.jsx(By,{}):r.jsx(_E,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(o=>r.jsx(Iy,{node:o,depth:a+1},o.name))]})}function OE(t,a,s){const o=[];a&&o.push({name:"evals.json",type:"file"}),o.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:o}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function BE({skillName:t,hasEvals:a,isDraft:s}){const o=OE(t,a,s);return r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[r.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsx(By,{})}),"Skill Structure"]}),r.jsx("div",{className:"rounded-lg px-3 py-2",style:{background:"var(--surface-0)",border:"1px solid var(--border-subtle)"},children:r.jsx(Iy,{node:o})})]})}const la={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Hd({size:t=14,color:a="currentColor"}){return r.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:a,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M12 3l1.912 5.813a2 2 0 001.275 1.275L21 12l-5.813 1.912a2 2 0 00-1.275 1.275L12 21l-1.912-5.813a2 2 0 00-1.275-1.275L3 12l5.813-1.912a2 2 0 001.275-1.275L12 3z"})})}function IE({onCreated:t,onCancel:a}){const s=DE({onCreated:t});return r.jsxs("div",{className:"px-8 py-6 max-w-4xl animate-fade-in overflow-auto h-full",children:[r.jsxs("div",{className:"mb-5",children:[r.jsx("h2",{className:"text-[20px] font-semibold tracking-tight",style:{color:"var(--text-primary)"},children:"Create a New Skill"}),r.jsx("div",{className:"flex items-center justify-between mt-2",children:r.jsxs("div",{className:"inline-flex rounded-lg p-0.5",style:{background:"var(--surface-2)",border:"1px solid var(--border-subtle)"},children:[r.jsx("button",{onClick:()=>s.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:s.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:s.mode==="ai"?"0 1px 3px rgba(168,85,247,0.15)":"none",cursor:"pointer",border:"none"},children:r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(Hd,{size:12}),"AI-Assisted"]})}),r.jsx("button",{onClick:()=>s.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:s.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:s.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:s.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),s.layoutLoading&&r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-10 w-full rounded-lg"}),r.jsx("div",{className:"skeleton h-10 w-full rounded-lg"})]}),!s.layoutLoading&&s.layout&&s.mode==="ai"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("h3",{className:"text-[13px] font-semibold mb-3 flex items-center gap-2",style:{color:"var(--text-primary)"},children:[r.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center",style:{background:"rgba(168,85,247,0.15)"},children:r.jsx(Hd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.jsx("textarea",{ref:s.promptRef,value:s.aiPrompt,onChange:o=>s.setAiPrompt(o.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
87
+
88
+ Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:s.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...la,minHeight:"120px"},onKeyDown:o=>{o.key==="Enter"&&(o.metaKey||o.ctrlKey)&&(o.preventDefault(),s.handleGenerate())}}),r.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),s.generating&&s.aiProgress.length>0&&r.jsx(ai,{entries:s.aiProgress,isRunning:!0}),s.aiError&&r.jsx("div",{children:s.aiClassifiedError?r.jsx(ec,{error:s.aiClassifiedError,onRetry:s.handleGenerate,onDismiss:s.clearAiError}):r.jsxs("div",{children:[r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.aiError}),r.jsx("button",{onClick:s.handleGenerate,className:"mt-2 text-[12px] font-medium",style:{color:"#a855f7",background:"none",border:"none",cursor:"pointer"},children:"Retry"})]})}),r.jsxs("div",{className:"flex items-center gap-3",children:[s.generating?r.jsx("button",{onClick:s.handleCancelGenerate,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:"var(--surface-3)",color:"var(--text-secondary)",border:"none",cursor:"pointer"},children:"Cancel Generation"}):r.jsxs("button",{onClick:s.handleGenerate,disabled:!s.aiPrompt.trim(),className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150 flex items-center gap-2",style:{background:s.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:s.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:s.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[r.jsx(Hd,{size:14}),"Generate"]}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"}),!s.generating&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.jsx("button",{onClick:()=>s.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!s.layoutLoading&&s.layout&&s.mode==="manual"&&r.jsxs("div",{className:"space-y-4 animate-fade-in",children:[r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Location"}),s.creatableLayouts.length>1&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Layout"}),r.jsx("div",{className:"flex gap-2",children:s.creatableLayouts.map(o=>r.jsx("button",{onClick:()=>{s.setSelectedLayout(o.layout),s.setPlugin(o.existingPlugins[0]||""),s.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:s.selectedLayout===o.layout?"var(--accent)":"var(--surface-3)",color:s.selectedLayout===o.layout?"#fff":"var(--text-secondary)",border:`1px solid ${s.selectedLayout===o.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:o.label},o.layout))})]}),s.selectedLayout!==3&&r.jsxs("div",{className:"mb-3",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-2 block",style:{color:"var(--text-tertiary)"},children:"Plugin"}),r.jsxs("select",{value:s.plugin,onChange:o=>{s.setPlugin(o.target.value),s.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la,children:[s.availablePlugins.map(o=>r.jsx("option",{value:o,children:o},o)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),s.plugin==="__new__"&&r.jsx("input",{type:"text",value:s.newPlugin,onChange:o=>s.setNewPlugin(pf(o.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:la})]}),r.jsx("div",{className:"px-3 py-2 rounded-lg text-[11px] font-mono",style:{background:"var(--surface-0)",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)"},children:s.pathPreview})]}),s.showPluginRecommendation&&s.pluginLayoutInfo&&s.selectedLayout===3&&r.jsxs("div",{className:"px-4 py-3 rounded-lg text-[12px] animate-fade-in flex items-center justify-between gap-3",style:{background:"rgba(59,130,246,0.08)",color:"var(--text-secondary)",border:"1px solid rgba(59,130,246,0.2)"},children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3b82f6",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"12",cy:"12",r:"10"}),r.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),r.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),r.jsxs("span",{children:["Plugins detected (",r.jsx("strong",{children:s.pluginLayoutInfo.plugins.slice(0,3).join(", ")}),"). Add this skill to a plugin for better organization."]})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:s.applyPluginRecommendation,className:"px-3 py-1 rounded-md text-[11px] font-medium",style:{background:"#3b82f6",color:"#fff",border:"none",cursor:"pointer"},children:"Use plugin"}),r.jsx("button",{onClick:()=>s.setShowPluginRecommendation(!1),className:"w-5 h-5 rounded flex items-center justify-center",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[r.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),r.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsx("h3",{className:"text-[13px] font-semibold mb-3",style:{color:"var(--text-primary)"},children:"Skill Details"}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Name ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("input",{type:"text",value:s.name,onChange:o=>s.setName(pf(o.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la})]}),r.jsxs("div",{className:"mb-3",children:[r.jsxs("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:["Description ",r.jsx("span",{style:{color:"var(--red)"},children:"*"})]}),r.jsx("textarea",{value:s.description,onChange:o=>s.setDescription(o.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...la,minHeight:"72px"}})]}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Model"}),r.jsxs("select",{value:s.model,onChange:o=>s.setModel(o.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la,children:[r.jsx("option",{value:"",children:"Any"}),r.jsx("option",{value:"opus",children:"Opus"}),r.jsx("option",{value:"sonnet",children:"Sonnet"}),r.jsx("option",{value:"haiku",children:"Haiku"})]})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"text-[11px] font-medium uppercase tracking-wider mb-1 block",style:{color:"var(--text-tertiary)"},children:"Allowed Tools"}),r.jsx("input",{type:"text",value:s.allowedTools,onChange:o=>s.setAllowedTools(o.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:la})]})]})]}),r.jsxs("div",{className:"glass-card p-4",children:[r.jsxs("div",{className:"flex items-center justify-between mb-3",children:[r.jsxs("div",{className:"flex items-center gap-2.5",children:[r.jsx("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:"var(--accent-muted)"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--accent)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),r.jsx("polyline",{points:"14 2 14 8 20 8"}),r.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),r.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]})}),r.jsxs("div",{children:[r.jsx("span",{className:"text-[13px] font-semibold",style:{color:"var(--text-primary)"},children:"SKILL.md"}),r.jsx("span",{className:"text-[11px] ml-2",style:{color:"var(--text-tertiary)"},children:"Skill Definition"})]})]}),r.jsx("div",{className:"flex items-center",style:{background:"var(--surface-2)",borderRadius:8,padding:2,gap:1},children:["write","preview"].map(o=>r.jsxs("button",{onClick:()=>s.setBodyViewMode(o),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:s.bodyViewMode===o?"var(--surface-4)":"transparent",color:s.bodyViewMode===o?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:s.bodyViewMode===o?600:400,border:"none",cursor:"pointer"},children:[o==="write"?r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"16 18 22 12 16 6"}),r.jsx("polyline",{points:"8 6 2 12 8 18"})]}):r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"}),r.jsx("circle",{cx:"12",cy:"12",r:"3"})]}),r.jsx("span",{children:o==="write"?"Write":"Preview"})]},o))})]}),s.bodyViewMode==="write"?r.jsx("textarea",{value:s.body,onChange:o=>s.setBody(o.target.value),placeholder:`# /my-skill
89
+
90
+ You are an expert at...
91
+ `,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...la,minHeight:"150px"}}):s.body.trim()?r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:Zo(s.body)}}):r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto rounded-lg px-4 py-3",style:{background:"var(--surface-0)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",minHeight:"150px",maxHeight:"400px",overflowY:"auto"},children:r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Start writing to see preview"})})]}),r.jsx(BE,{skillName:s.name||"{skill}",hasEvals:!1,isDraft:s.draftSaved}),s.error&&r.jsx("div",{className:"px-4 py-3 rounded-lg text-[13px]",style:{background:"var(--red-muted)",color:"var(--red)",border:"1px solid rgba(248,113,113,0.2)"},children:s.error}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:s.handleCreate,disabled:s.creating||!s.name||!s.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:s.creating||!s.name||!s.description?"var(--surface-3)":"var(--accent)",color:s.creating||!s.name||!s.description?"var(--text-tertiary)":"#fff",cursor:s.creating||!s.name||!s.description?"not-allowed":"pointer",border:"none"},children:s.creating?"Creating...":"Create Skill"}),r.jsx("button",{onClick:a,className:"px-4 py-2.5 rounded-lg text-[13px] font-medium",style:{color:"var(--text-secondary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]})]})]})}function UE(){return r.jsx("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center",style:{background:"var(--surface-2)"},children:r.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"}),r.jsx("polyline",{points:"3.27 6.96 12 12.01 20.73 6.96"}),r.jsx("line",{x1:"12",y1:"22.08",x2:"12",y2:"12"})]})})}function _o({variant:t,message:a,onRetry:s}){const{setMode:o,setSearch:c}=er(),[u,d]=p.useState(!1);return t==="no-selection"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(UE,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[14px] font-medium mb-1",style:{color:"var(--text-secondary)"},children:"Select a skill to view details"}),r.jsx("p",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"Choose a skill from the list to edit, test, and evaluate"})]}):t==="no-skills"?r.jsxs("div",{className:"text-center py-12 px-4 animate-fade-in-scale",children:[r.jsx("div",{className:"w-14 h-14 rounded-2xl flex items-center justify-center mx-auto mb-4",style:{background:"var(--surface-2)"},children:r.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("path",{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"})})}),r.jsx("p",{className:"text-[14px] font-medium",style:{color:"var(--text-secondary)"},children:"No skills found"}),r.jsxs("p",{className:"text-[12px] mt-1 mb-4",style:{color:"var(--text-tertiary)"},children:["Check your ",r.jsx("code",{className:"px-1.5 py-0.5 rounded text-[11px]",style:{background:"var(--surface-2)"},children:"--root"})," directory, or create your first skill"]}),r.jsxs("button",{onClick:()=>o("create"),className:"inline-flex items-center gap-2 px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},onMouseEnter:h=>{h.currentTarget.style.opacity="0.9"},onMouseLeave:h=>{h.currentTarget.style.opacity="1"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Create Your First Skill"]})]}):t==="error"?r.jsx("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in",children:r.jsxs("div",{className:"px-5 py-4 rounded-lg text-center max-w-sm",style:{background:"var(--red-muted)",border:"1px solid rgba(248,113,113,0.2)"},children:[r.jsx("p",{className:"text-[13px] mb-3",style:{color:"var(--red)"},children:a||"Failed to load skill data"}),s&&r.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] font-medium",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"none",cursor:"pointer"},children:"Retry"})]})}):r.jsxs("div",{className:"px-4 py-8 text-center animate-fade-in",children:[r.jsx("p",{className:"text-[13px] mb-2",style:{color:"var(--text-tertiary)"},children:"No skills match your search"}),r.jsx("button",{onClick:()=>c(""),className:"text-[12px] font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer",textDecoration:"underline"},children:"Clear search"})]})}function HE(t,a){const[s,o]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>o?"minor":"patch"}const $E={major:{bg:"var(--red-muted)",text:"var(--red)"},minor:{bg:"var(--yellow-muted)",text:"var(--yellow)"},patch:{bg:"var(--green-muted)",text:"var(--green)"}};function Uy(){const[t,a]=p.useState([]),[s,o]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[g,m]=p.useState(!1),[y,v]=p.useState(new Set),[b,S]=p.useState(new Map),[k,E]=p.useState(null),[C,N]=p.useState(null),[T,A]=p.useState(!1),B=p.useCallback(async()=>{o(!0);try{const H=await Ce.getSkillUpdates();a(H.filter(q=>q.updateAvailable))}catch{a([])}finally{o(!1)}},[]);p.useEffect(()=>{B()},[B]);const z=p.useMemo(()=>t.filter(H=>!H.pinned),[t]),F=p.useCallback(H=>{u(q=>{const X=new Set(q);return X.has(H)?X.delete(H):X.add(H),X})},[]),w=p.useCallback(()=>{c.size===z.length?u(new Set):u(new Set(z.map(H=>H.name)))},[c,z]),O=p.useCallback(()=>{const H=[...c];if(!H.length)return;m(!0),h(new Map(H.map(X=>[X,{skill:X,status:"pending"}])));const q=Ce.startBatchUpdate(H);q.addEventListener("progress",X=>{try{const J=JSON.parse(X.data);h($=>new Map($).set(J.skill,J))}catch{}}),q.addEventListener("done",X=>{q.close(),m(!1);try{const J=JSON.parse(X.data);E(`Updated ${J.updated??0} skills, ${J.failed??0} failed`),setTimeout(()=>E(null),5e3)}catch{}B()}),q.addEventListener("error",()=>{q.close(),m(!1),E("Batch update failed"),setTimeout(()=>E(null),5e3)})},[c,B]),D=p.useCallback(async H=>{const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];v($=>new Set($).add(H.name)),S($=>{const L=new Map($);return L.delete(H.name),L});try{const $=await Ce.postSkillUpdate(X,J);if($.ok)B();else{const L=`Update failed (HTTP ${$.status}): ${$.body}`;S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — HTTP ${$.status}`),setTimeout(()=>E(null),5e3)}}catch($){const L=$ instanceof Error?$.message:"Network error";S(_=>new Map(_).set(H.name,L)),E(`Couldn't update ${J} — ${L}`),setTimeout(()=>E(null),5e3)}finally{v($=>{const L=new Set($);return L.delete(H.name),L})}},[B]),U=p.useCallback(async H=>{if(!H.latest)return;const q=H.name.split("/"),X=q.length>=3?q[q.length-2]:q[0],J=q[q.length-1];A(!0);try{const $=await Ce.getVersionDiff(X,J,H.installed,H.latest);N({skill:H,diff:$})}catch{N(null)}finally{A(!1)}},[]);return s?r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[r.jsx("div",{className:"skeleton h-6 w-48 mb-4"}),r.jsxs("div",{className:"space-y-3",children:[r.jsx("div",{className:"skeleton h-16 rounded-lg"}),r.jsx("div",{className:"skeleton h-16 rounded-lg"})]})]}):t.length===0?r.jsxs("div",{"data-testid":"updates-panel",className:"flex flex-col items-center justify-center h-full py-16",children:[r.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"var(--green)",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",className:"mb-4",children:[r.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),r.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),r.jsx("div",{className:"text-[15px] font-semibold mb-2",style:{color:"var(--text-primary)"},children:"All skills are up to date"}),r.jsx("div",{className:"text-[12px] mb-4",style:{color:"var(--text-tertiary)"},children:"No updates available for installed skills."}),r.jsx("button",{onClick:B,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[k&&r.jsx("div",{className:"fixed top-4 right-4 z-50 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"},children:k}),r.jsxs("div",{className:"flex items-center justify-between mb-5",children:[r.jsxs("div",{className:"text-[16px] font-semibold",style:{color:"var(--text-primary)"},children:["Available Updates (",z.length,")"]}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:B,className:"btn btn-ghost text-[12px]",disabled:g,children:"Refresh"}),r.jsx("button",{onClick:O,disabled:c.size===0||g,className:"btn btn-primary text-[12px]",children:g?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs("button",{onClick:w,className:"flex items-center gap-2 text-[12px] font-medium",style:{color:"var(--text-secondary)",background:"transparent",border:"none",cursor:"pointer"},children:[r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:c.size===z.length&&z.length>0?"var(--accent)":"var(--border-default)",background:c.size===z.length&&z.length>0?"var(--accent)":"transparent"},children:c.size===z.length&&z.length>0&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})}),"Select All"]})}),r.jsx("div",{className:"space-y-2",children:t.map(H=>{const q=H.name.split("/").pop()||H.name,X=H.latest?HE(H.installed,H.latest):"patch",J=$E[X],$=!!H.pinned,L=y.has(H.name),_=d.get(H.name),I=c.has(H.name);return r.jsx("div",{className:"rounded-lg px-4 py-3 transition-all duration-150",style:{background:"var(--surface-1)",border:"1px solid var(--border-subtle)",opacity:$?.7:1},children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:()=>!$&&F(H.name),disabled:$,className:"flex-shrink-0",style:{background:"transparent",border:"none",cursor:$?"not-allowed":"pointer"},children:r.jsx("span",{className:"w-4 h-4 rounded border flex items-center justify-center",style:{borderColor:I?"var(--accent)":"var(--border-default)",background:I?"var(--accent)":"transparent",opacity:$?.4:1},children:I&&r.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-paper)",strokeWidth:"3",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})})})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[r.jsx("span",{className:"text-[13px] font-medium",style:{color:"var(--text-primary)"},children:q}),$&&r.jsx("span",{className:"text-[10px]",title:"Pinned — unpin from CLI to update",children:"📌"}),r.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:J.bg,color:J.text},children:X})]}),r.jsxs("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[H.installed," → ",H.latest||"?",$&&` (pinned at ${H.pinnedVersion||H.installed})`]})]}),_&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:_.status==="done"?"var(--green-muted)":_.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:_.status==="done"?"var(--green)":_.status==="error"?"var(--red)":"var(--yellow)"},children:[_.status,_.error&&`: ${_.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>U(H),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>D(H),disabled:$||L||g,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:L?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(_==null?void 0:_.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},H.name)})}),C&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0,0,0,0.5)"},onClick:()=>N(null),children:r.jsxs("div",{style:{width:"80%",maxWidth:900},onClick:H=>H.stopPropagation(),children:[r.jsx("div",{className:"mb-2 flex justify-end",children:r.jsx("button",{onClick:()=>N(null),className:"btn btn-ghost text-[12px]",children:"Close"})}),r.jsx(Of,{contentDiff:C.diff.contentDiff,fromLabel:C.diff.from,toLabel:C.diff.to,diffSummary:C.diff.diffSummary,renderContext:"inline"})]})})]})}const VE=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:Uy},Symbol.toStringTag,{value:"Module"}));function PE(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function FE(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function GE(t){if(!t||typeof t!="string")return null;const a=t.trim();if(!a)return null;if(!a.includes("://")){const[s]=a.split("/");return s&&/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(s)?s:null}try{const s=new URL(a),o=s.hostname.toLowerCase();if(o!=="github.com"&&o!=="www.github.com"&&o!=="raw.githubusercontent.com")return null;const u=s.pathname.split("/").filter(Boolean)[0];return!u||!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(u)?null:u}catch{return null}}function Hy(t){const{author:a,repoUrl:s}=t,o=GE(s??null),c=a&&a.trim()!==""?a:o??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var g;try{await((g=navigator.clipboard)==null?void 0:g.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return o?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${o}`,target:"_blank",rel:"noopener noreferrer",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",borderBottom:"1px dotted var(--border-default, var(--border))",whiteSpace:"nowrap"},children:c}):!a||a.trim()===""?r.jsx("span",{"data-testid":t["data-testid"]??"author-link-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"}):r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"author-copy",title:`Copy "${c}"`,onClick:h,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:[c,r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:u?"✓":"⧉"})]})}function WE(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function qE(t,a){const s=WE(t),o=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return o?`${s}/blob/HEAD/${o}`:`${s}/blob/HEAD/`}function Qg(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function $y(t){const{repoUrl:a,skillPath:s,absolutePath:o}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?Qg(s):o?Qg(o):"source",g=p.useCallback(async()=>{var v;const y=o??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[o,s]);if(d){const y=qE(a,s);return r.jsxs("a",{"data-testid":t["data-testid"]??"source-file-link",href:y,target:"_blank",rel:"noopener noreferrer",title:y,style:{display:"inline-flex",alignItems:"center",gap:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-accent, var(--text-primary))",textDecoration:"none",whiteSpace:"nowrap",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",children:"↗"})]})}if(!o&&!s)return r.jsx("span",{"data-testid":t["data-testid"]??"source-file-empty",style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:"—"});const m=o??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:g,style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:12,color:"var(--text-secondary)",cursor:"pointer",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[r.jsx("span",{children:h}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,opacity:.7},children:c?"✓":"⧉"})]})}function Zg(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Vy(t){return t.skill?KE({skill:t.skill}):QE({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function YE(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),o=t.slice(t.length-(a-12-1));return`${s}…${o}`}function KE({skill:t}){const[a,s]=p.useState(!1),o=p.useCallback(async()=>{var d;try{await((d=navigator.clipboard)==null?void 0:d.writeText(t.dir)),s(!0),setTimeout(()=>s(!1),1500),Zg(ne.toasts.pathCopied,"info")}catch{Zg(ne.toasts.permissionDenied,"error")}},[t.dir]),c=t.origin==="installed"?"Project":"Skills",u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("div",{"data-testid":"detail-header",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px",boxShadow:"none"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",marginBottom:4},children:[r.jsx("span",{"data-testid":"detail-header-plugin",children:t.plugin}),r.jsx("span",{"aria-hidden":"true",style:{color:"var(--text-secondary)"},children:"›"}),r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:"var(--text-secondary)",fontSize:11,letterSpacing:.3,textTransform:"uppercase"},children:[r.jsx("span",{"data-origin-dot":t.origin,"aria-label":`Origin: ${c}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:u}}),c]})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,marginBottom:8},children:[r.jsx("h2",{"data-testid":"detail-header-name",style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,lineHeight:1.25,color:"var(--text-primary)",margin:0},children:t.skill}),r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(ni,{version:t.version??null})})]}),r.jsxs("div",{"data-testid":"detail-header-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,margin:"0 0 8px",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(Hy,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx($y,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(XE,{skill:t}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("button",{type:"button","data-testid":"detail-header-path-chip",title:t.dir,"aria-label":`Copy path ${t.dir} to clipboard`,onClick:o,style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",border:"1px solid var(--border-default)",borderRadius:4,background:"transparent",fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",cursor:"pointer"},children:YE(t.dir||"—")}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:o,"aria-label":"Copy skill path to clipboard",style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 8px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:11,cursor:"pointer"},children:[r.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),r.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),a?"Copied":"Copy"]})]})]})}function XE({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let o="";switch(a){case"symlinked":o=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":o="Copied (independent)";break;case"authored":o="Authored";break;default:return null}return r.jsxs("div",{"data-testid":"detail-header-install-method",style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",margin:"6px 0 8px"},children:[r.jsx("span",{style:{fontWeight:600,letterSpacing:"0.04em",textTransform:"uppercase",fontSize:10,color:"var(--text-tertiary)"},children:"Install method"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)"},children:o})]})}function QE({state:t,isReadOnly:a,onDelete:s}){const{plugin:o,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:g,regressions:m,iterationCount:y}=t,v=Array.from(g.values()).some(N=>N.status==="running"||N.status==="queued"),b=d==null?void 0:d.overall_pass_rate,S=(u==null?void 0:u.evals.reduce((N,T)=>N+T.assertions.length,0))??0,k=(u==null?void 0:u.evals.length)??0,E=PE(b),C=FE(b);return r.jsxs("div",{className:"flex items-center justify-between px-4 py-2.5",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-1)",flexShrink:0},children:[r.jsxs("div",{className:"flex items-center gap-2 text-[13px]",children:[r.jsx("span",{style:{color:"var(--text-tertiary)"},children:o}),r.jsx(ZE,{}),r.jsx("span",{className:"font-medium",style:{color:"var(--text-primary)"},children:c}),a&&r.jsxs("span",{className:"ml-2 flex items-center gap-1 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--surface-3)",color:"var(--text-tertiary)"},children:[r.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),"installed"]}),h&&r.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"var(--yellow-muted)",color:"var(--yellow)"},children:"unsaved"}),v&&r.jsxs("span",{className:"ml-2 flex items-center gap-1.5 text-[11px]",style:{color:"var(--accent)"},children:[r.jsx("span",{className:"spinner",style:{width:12,height:12,borderWidth:1.5}}),"Running..."]})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[!a&&s&&r.jsx("button",{disabled:v,onClick:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:{plugin:o,skill:c,dir:"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"source"}}}))},title:"Delete skill",className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:v?"not-allowed":"pointer",color:"var(--text-tertiary)",padding:4,opacity:v?.4:1,borderRadius:4},onMouseEnter:N=>{v||(N.currentTarget.style.color="var(--red)")},onMouseLeave:N=>{N.currentTarget.style.color="var(--text-tertiary)"},children:r.jsx(JE,{})}),m.length>0&&r.jsxs("span",{className:"pill",style:{background:"var(--red-muted)",color:"var(--red)"},children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[r.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),r.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),r.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),m.length," regression",m.length>1?"s":""]}),y>0&&r.jsxs("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)"},children:["Iter ",y]}),r.jsx("span",{className:"pill",style:{background:C,color:E},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[k," case",k!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function ZE(){return r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"var(--text-tertiary)",strokeWidth:"2",children:r.jsx("polyline",{points:"9 18 15 12 9 6"})})}function JE(){return r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),r.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),r.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function sa(t){const{title:a,label:s,value:o,subtitle:c,description:u,linkLabel:d,children:h,onClick:g}=t,m=a??s??"",y=typeof g=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),g==null||g())};return r.jsxs("div",{className:y?"metric-card metric-card-link":"metric-card","data-testid":t["data-testid"],role:y?"button":void 0,tabIndex:y?0:void 0,onClick:y?()=>g==null?void 0:g():void 0,onKeyDown:y?v:void 0,style:{background:"var(--card-bg, var(--bg-surface))",border:"1px solid var(--border, var(--border-default))",borderRadius:6,padding:"1rem",display:"flex",flexDirection:"column",gap:"0.375rem",minWidth:0,height:"100%",cursor:y?"pointer":void 0,wordBreak:"break-word",overflowWrap:"anywhere"},children:[m?r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-title`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--card-text-muted, var(--text-secondary))"},children:m}):null,r.jsx("div",{"data-testid":t["data-testid"]?`${t["data-testid"]}-value`:void 0,style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"1.375rem",fontWeight:700,color:"var(--card-text, var(--text-primary))",lineHeight:1,fontVariantNumeric:"tabular-nums"},children:String(o)}),c?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:c}):null,u?r.jsx("div",{style:{fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.5625rem",color:"var(--card-text-muted, var(--text-secondary))",lineHeight:1.4,opacity:.7},children:u}):null,h?r.jsx("div",{style:{flex:1,marginTop:"0.25rem"},children:h}):null,d?r.jsx("div",{style:{marginTop:"auto",paddingTop:"0.375rem",borderTop:"1px solid var(--border, var(--border-default))",fontFamily:"var(--font-geist-mono, var(--font-mono))",fontSize:"0.625rem",color:"var(--card-text-muted, var(--text-secondary))"},children:d}):null]})}const eN="Benchmarks are the aggregated score of this skill's evals (evals.yaml) run against its tests (tests/). Each test case produces a verdict; the benchmark is the mean pass rate.";function tN(t){const{onNavigate:a}=t,[s,o]=p.useState(t.open??!1),c=p.useCallback(()=>o(!1),[]);p.useEffect(()=>{if(!s)return;const d=h=>{h.key==="Escape"&&c()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,c]);const u=p.useCallback(d=>{a==null||a(d),o(!1)},[a]);return r.jsxs("span",{"data-testid":t["data-testid"]??"benchmark-info",style:{position:"relative",display:"inline-flex",alignItems:"center"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-trigger","aria-label":"About benchmarks","aria-expanded":!!s,onClick:()=>o(d=>!d),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:18,height:18,padding:0,border:"1px solid var(--border-default, var(--border))",borderRadius:999,background:"transparent",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer",lineHeight:1},children:"ℹ"}),s&&r.jsxs("div",{role:"dialog","data-testid":"benchmark-info-popover",style:{position:"absolute",top:"100%",right:0,marginTop:6,zIndex:20,width:280,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:6,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",boxShadow:"0 4px 16px rgba(0,0,0,0.08)"},children:[r.jsx("p",{style:{margin:"0 0 8px",lineHeight:1.45},children:eN}),r.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[r.jsx("button",{type:"button","data-testid":"benchmark-info-link-tests",onClick:()=>u("tests"),style:$d,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:$d,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...$d,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const $d={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function nN(t){if(t==null||!Number.isFinite(t))return"—";if(t<1024)return`${t} B`;const a=t/1024;if(a<1024)return a>=10?`${Math.round(a)} KB`:`${a.toFixed(1).replace(/\.0$/,"")} KB`;const s=a/1024;return s>=10?`${Math.round(s)} MB`:`${s.toFixed(1).replace(/\.0$/,"")} MB`}function Os(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),o=Math.floor(s/1e3);if(o<60)return"just now";const c=Math.floor(o/60);if(c<60)return`${c} min ago`;const u=Math.floor(c/60);if(u<24)return`${u} hr ago`;const d=Math.floor(u/24);if(d<30)return`${d} day${d===1?"":"s"} ago`;const h=Math.floor(d/30);if(h<12)return`${h} month${h===1?"":"s"} ago`;const g=Math.floor(h/12);return`${g} year${g===1?"":"s"} ago`}function rN(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function aN(t){const a=t.installMethod;if(!a)return null;const s=a==="authored"?"Authored":a==="copied"?"Copied":"Symlinked";return r.jsx("span",{"data-testid":"overview-install-method",style:{display:"inline-flex",alignItems:"center",padding:"1px 6px",border:"1px solid var(--border-default, var(--border))",borderRadius:4,fontFamily:"var(--font-mono, var(--font-geist-mono))",fontSize:10,color:"var(--text-secondary)",textTransform:"uppercase",letterSpacing:.4},children:s})}function lN(t){var y,v;const{skill:a,onNavigate:s,activationsCount:o=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(sN(a.homepage)?a.homepage??null:null),g=((y=a.mcpDeps)==null?void 0:y.length)??0,m=((v=a.deps)==null?void 0:v.length)??0;return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"flex",flexDirection:"column",gap:12,padding:16},children:[r.jsxs("header",{"data-testid":"skill-overview-header",style:{position:"sticky",top:0,zIndex:5,display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border))",borderRadius:8},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx("h2",{"data-testid":"skill-overview-name",style:{fontFamily:"var(--font-serif, var(--font-sans))",fontSize:18,fontWeight:500,color:"var(--text-primary)",margin:0,lineHeight:1.2},children:a.skill}),r.jsx(ni,{version:a.version??null}),aN(a)]}),r.jsxs("div",{"data-testid":"skill-overview-byline",style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:10,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)"},children:[r.jsx(Hy,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx($y,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Os(a.lastModified)]}):null]})]}),r.jsxs("div",{"data-testid":"skill-overview-grid",className:"skill-overview-grid",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"0.75rem",alignItems:"stretch"},children:[r.jsx(sa,{title:"Benchmark",value:rN(a),subtitle:a.lastBenchmark?Os(a.lastBenchmark):"Never run","data-testid":"metric-benchmark",onClick:s?()=>s("run"):void 0,children:r.jsx("div",{style:{marginTop:4,display:"inline-flex",alignItems:"center"},children:r.jsx(tN,{onNavigate:s})})}),r.jsx(sa,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(sa,{title:"Activations",value:o,subtitle:c?`Last: ${Os(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(sa,{title:"Last run",value:Os(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(sa,{title:"MCP deps",value:g,subtitle:g>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(sa,{title:"Skill deps",value:m,subtitle:m>0&&a.deps?a.deps.slice(0,3).join(", "):"None","data-testid":"metric-skill-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(sa,{title:"Size",value:nN(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(sa,{title:"Last modified",value:Os(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]})}function sN(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function iN({skill:t}){const{refreshUpdates:a,dismissPushUpdate:s}=er(),{toast:o}=Wo(),[c,u]=p.useState("idle"),[d,h]=p.useState(null),[g,m]=p.useState(!1),[y,v]=p.useState(null),[b,S]=p.useState(!1),k=p.useRef(null),E=p.useCallback(async()=>{if(!t||c==="updating")return;const A=new AbortController;k.current=A,u("updating"),h(null);try{const B=await Ce.postSkillUpdate(t.plugin,t.skill,A.signal);if(B.ok)u("done"),a(),s(`${t.plugin}/${t.skill}`),o({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const z=`Update failed (HTTP ${B.status}): ${B.body}`;u("idle"),h(z),o({message:`Couldn't update ${t.skill} — HTTP ${B.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(B){if(B instanceof DOMException&&B.name==="AbortError")return;const z=B instanceof Error?B.message:"Network error";u("idle"),h(z),o({message:`Couldn't update ${t.skill} — ${z}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{k.current===A&&(k.current=null)}},[t,c,a,s,o]);if(p.useEffect(()=>{if(!g||y!=null||!t||!t.latestVersion)return;let A=!1;return S(!0),Ce.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(B=>{A||v(B)}).catch(()=>{A||v(null)}).finally(()=>{A||S(!1)}),()=>{A=!0}},[g,y,t==null?void 0:t.plugin,t==null?void 0:t.skill,t==null?void 0:t.latestVersion,t==null?void 0:t.currentVersion,t]),p.useEffect(()=>()=>{var A;(A=k.current)==null||A.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,N=c==="updating"?"Updating…":C?`Update to ${C}`:"Update",T=c==="updating";return r.jsxs("div",{"data-testid":"update-action",style:{display:"flex",flexDirection:"column",gap:6,padding:"12px 16px",borderTop:"1px solid var(--border-default)",borderBottom:"1px solid var(--border-default)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[r.jsx("button",{type:"button","data-testid":"update-action-button",onClick:()=>{E()},disabled:T,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:T?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:N}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>m(A=>!A),disabled:T||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:g?"Hide changelog":"Preview changelog"})]}),c==="updating"&&r.jsx("div",{"data-testid":"update-action-progress",role:"status",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-muted, var(--text-secondary))"},children:"Updating…"}),d&&c!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:d}),g&&C&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[b&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!b&&y&&r.jsx(Of,{contentDiff:y.contentDiff,fromLabel:y.from,toLabel:y.to,diffSummary:y.diffSummary??void 0,renderContext:"inline"}),!b&&!y&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const oN=3e4;function cN({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:o=!1}){const c=er(),[u,d]=p.useState(!1),[h,g]=p.useState(!1),[,m]=p.useState(0),y=p.useRef(null),v=p.useRef(null),b=`${t}/${a}`,S=c.updatesById.get(b);if(p.useEffect(()=>{if(!u)return;const E=setInterval(()=>m(C=>(C+1)%1e6),250);return()=>clearInterval(E)},[u]),p.useEffect(()=>{if(!u||!S)return;const E=v.current??0;S.receivedAt<E||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),g(!1),v.current=null)},[u,S]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||o)return null;const k=async()=>{if(!u){g(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),g(!0),y.current=null,v.current=null},oN);try{await Ce.rescanSkill(t,a)}catch{y.current&&(clearTimeout(y.current),y.current=null),d(!1),v.current=null}}};return r.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx("button",{type:"button","data-testid":"check-now-button",onClick:k,disabled:u,style:{height:26,padding:"0 10px",background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12,cursor:u?"not-allowed":"pointer"},children:"Check now"}),u&&r.jsx("span",{"data-testid":"check-now-spinner","aria-label":"Checking for updates",role:"status",style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--text-secondary)",borderTopColor:"transparent",animation:"check-now-spin 800ms linear infinite"}}),h&&r.jsx("span",{"data-testid":"check-now-no-changes",style:{fontSize:11,color:"var(--text-secondary)",fontFamily:"var(--font-sans)"},children:"No changes detected"})]})}const Py=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"],uN={overview:"Overview",editor:"Editor",tests:"Tests",run:"Run",activation:"Activation",history:"History",leaderboard:"Leaderboard",deps:"Deps",versions:"Versions"};function dN(t){return typeof t=="string"&&Py.includes(t)}function fN(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return dN(a)?a:"overview"}function Vd(){const{state:t,setMobileView:a}=er();return t.isMobile?r.jsxs("button",{onClick:()=>a("list"),className:"flex items-center gap-1.5 px-3 py-2 text-[12px] font-medium",style:{background:"var(--surface-1)",color:"var(--text-secondary)",border:"none",borderBottom:"1px solid var(--border-subtle)",cursor:"pointer",width:"100%"},children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"15 18 9 12 15 6"})}),"Back to skills"]}):null}function pN(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return mN(t);const{state:a,selectSkill:s,setMode:o,refreshSkills:c}=er(),[u,d]=p.useState(typeof window<"u"?window.location.hash:"");if(p.useEffect(()=>{const m=()=>d(window.location.hash);return window.addEventListener("hashchange",m),()=>window.removeEventListener("hashchange",m)},[]),u==="#/updates")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Vd,{}),r.jsx(Uy,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Vd,{}),r.jsx(IE,{onCreated:(m,y)=>{o("browse"),c(),s({plugin:m,skill:y,origin:"source"})},onCancel:()=>o("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(_o,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(_o,{variant:"no-skills"}):r.jsx(_o,{variant:"no-selection"});const h=a.selectedSkill,g=a.skills.find(m=>m.plugin===h.plugin&&m.skill===h.skill)??null;return r.jsxs("div",{className:"flex flex-col h-full",children:[r.jsx(Vd,{}),r.jsx(hN,{skillInfo:g,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function mN(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return gN();if(t.loadError)return vN(a,t.loadError);const o=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return Fy(a,s,t.onDetailTabChange,o)}function hN({skillInfo:t,allSkills:a,onSelectSkill:s}){const[o,c]=p.useState(fN());p.useEffect(()=>{if(typeof window>"u")return;const d=new URLSearchParams(window.location.search);o==="overview"?d.delete("panel"):d.set("panel",o);const h=d.toString(),g=`${window.location.pathname}${h?"?"+h:""}${window.location.hash}`;window.history.replaceState(null,"",g)},[o]);const u=p.useMemo(()=>t?Fy(t,o,c,{}):r.jsx(_o,{variant:"no-selection"}),[t,o,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:u})}function xN(t,a){return r.jsx("div",{role:"tablist","aria-label":"Detail sections","data-testid":"detail-tab-bar",style:{display:"flex",alignItems:"stretch",gap:4,borderBottom:"1px solid var(--border-default)",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:Py.map(s=>{const o=s===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":o,tabIndex:o?0:-1,id:`detail-tab-${s}`,"aria-controls":`detail-panel-${s}`,"data-testid":`detail-tab-${s}`,onClick:()=>a==null?void 0:a(s),style:{background:"transparent",border:"none",borderBottom:o?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:o?500:400,color:o?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:uN[s]},s)})})}function gN(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:32,background:"var(--bg-canvas)"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:20,fontWeight:500,color:"var(--text-primary)",margin:0,marginBottom:8},children:"Select a skill to view details"}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-secondary)",margin:0,maxWidth:420,textAlign:"center"},children:"Choose a skill from the sidebar — its frontmatter, filesystem info, and benchmark status will appear here."})]})}function vN(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[Vy({skill:t}),r.jsxs("section",{role:"alert",style:{background:"var(--bg-surface)",border:"1px solid var(--border-default)",borderRadius:8,padding:"14px 16px"},children:[r.jsxs("h3",{style:{fontFamily:"var(--font-serif)",fontSize:15,fontWeight:500,color:"var(--text-primary)",margin:"0 0 8px"},children:["Couldn't load SKILL.md for ",t.skill]}),r.jsx("p",{style:{fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-secondary)",margin:"0 0 12px",wordBreak:"break-word"},children:a})]})]})}function yN({active:t}){return t==="editor"?r.jsx(RC,{}):t==="tests"?r.jsx(OC,{}):t==="run"?r.jsx(XC,{}):t==="activation"?r.jsx(eE,{}):t==="history"?r.jsx(xE,{}):t==="leaderboard"?r.jsx(TE,{}):t==="deps"?r.jsx(AE,{}):t==="versions"?r.jsx(aC,{}):null}function bN({active:t}){const{state:a,dispatch:s}=An();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function Fy(t,a,s,o){const c=h=>{s==null||s(h)},u=r.jsx(lN,{skill:t,onNavigate:c,repoUrl:t.homepage??null}),d=o!=null?r.jsxs(Jw,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(bN,{active:a}),r.jsx(yN,{active:a})]},`${t.plugin}/${t.skill}`):r.jsxs("div",{style:{padding:16,fontFamily:"var(--font-sans)",color:"var(--text-secondary)",fontSize:13},children:["Select a skill from the sidebar to load its ",a," view."]});return r.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",background:"var(--bg-canvas)"},children:[r.jsx("div",{style:{padding:16,paddingBottom:12},children:Vy({skill:t})}),r.jsx(iN,{skill:t}),t.origin==="installed"&&r.jsxs("div",{"data-testid":"read-only-banner",style:{display:"flex",alignItems:"center",gap:8,padding:"8px 16px",background:"var(--surface-2)",color:"var(--text-secondary)",borderBottom:"1px solid var(--border-subtle)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,color:"var(--text-tertiary)"},children:[r.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),r.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r.jsx("span",{children:"This is an installed copy of the skill. Editing, generating tests, and running evals are disabled. Open the source skill to make changes."})]}),t.origin==="installed"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(cN,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),xN(a,s),r.jsx("div",{role:"tabpanel",id:`detail-panel-${a}`,"aria-labelledby":`detail-tab-${a}`,"data-testid":`detail-panel-${a}`,style:{flex:1,minHeight:0,overflow:"auto"},children:a==="overview"?u:d})]})}function jN(){const{updateCount:t,state:a,dismissUpdateNotification:s}=er(),o=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!o)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[o,s]),o?r.jsxs("div",{className:"fixed bottom-4 right-4 z-50 flex items-center gap-3 px-4 py-3 rounded-lg text-[13px] font-medium animate-fade-in",style:{background:"var(--yellow-muted)",border:"1px solid var(--yellow)",color:"var(--text-primary)"},children:[r.jsxs("span",{children:[t," update",t===1?"":"s"," available"]}),r.jsx("button",{onClick:()=>{window.location.hash="#/updates"},className:"px-2 py-0.5 rounded text-[12px] font-semibold",style:{background:"var(--yellow)",color:"var(--surface-0)",border:"none",cursor:"pointer"},children:"View Updates"}),r.jsx("button",{onClick:s,className:"text-[14px] leading-none",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"0 2px"},"aria-label":"Dismiss",children:"✕"})]}):null}const SN=[{name:ne.shortcuts.groupNavigation,items:[{keys:"/",label:ne.shortcuts.search},{keys:"j",label:ne.shortcuts.moveDown},{keys:"k",label:ne.shortcuts.moveUp},{keys:"Enter",label:ne.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ne.shortcuts.groupActions,items:[{keys:"⌘K",label:ne.shortcuts.openPalette},{keys:"?",label:ne.shortcuts.openShortcuts},{keys:"⌘B",label:ne.shortcuts.toggleSidebar},{keys:"E",label:ne.actions.edit}]},{name:ne.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ne.shortcuts.toggleTheme}]}];function kN({open:t,onClose:a,groups:s=SN,title:o=ne.shortcuts.title}){const c=p.useRef(null),u=p.useRef(null);return p.useEffect(()=>{var d;if(t)return c.current=document.activeElement??null,(d=u.current)==null||d.focus(),()=>{var h,g;(g=(h=c.current)==null?void 0:h.focus)==null||g.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var g;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(g=u.current)==null||g.focus())}return window.addEventListener("keydown",d,!0),()=>window.removeEventListener("keydown",d,!0)},[t,a]),t?r.jsx("div",{role:"presentation","data-testid":"shortcut-modal",style:{position:"fixed",inset:0,background:"color-mix(in srgb, var(--bg-canvas) 70%, transparent)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:d=>{d.target===d.currentTarget&&a()},children:r.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":"shortcut-modal-title",style:{width:"min(480px, 92vw)",maxHeight:"80vh",overflow:"auto",background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:8,boxShadow:"0 16px 48px rgba(0,0,0,0.18)",padding:"16px 20px",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[r.jsx("h2",{id:"shortcut-modal-title",style:{margin:0,fontFamily:"var(--font-serif)",fontWeight:500,fontSize:18},children:o}),r.jsx("button",{ref:u,type:"button","aria-label":"Close",onClick:a,style:{background:"transparent",border:"1px solid var(--border-default)",borderRadius:4,padding:"2px 8px",color:"var(--text-secondary)",cursor:"pointer",fontSize:13},children:"Esc"})]}),s.map(d=>r.jsxs("section",{style:{marginBottom:12},children:[r.jsx("h3",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"var(--text-secondary)",margin:"0 0 6px"},children:d.name}),r.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:d.items.map(h=>r.jsxs("li",{style:{display:"flex",justifyContent:"space-between",padding:"4px 0",borderTop:"1px solid var(--border-default)",fontSize:13},children:[r.jsx("span",{children:h.label}),r.jsx("kbd",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-secondary)",border:"1px solid var(--border-default)",borderRadius:3,padding:"1px 6px"},children:h.keys})]},`${d.name}:${h.keys}`))})]},d.name))]})}):null}function wN(t){const a=ne.actions,s=[{action:"open",label:a.open},{action:"copy-path",label:a.copyPath},{action:"reveal",label:a.revealInEditor},{action:"run-benchmark",label:a.runBenchmark}];if(t.origin==="source")return[...s,{action:"edit",label:a.edit},{action:"duplicate",label:a.duplicate},{action:"delete",label:a.delete}];const o=[...s];return t.updateAvailable&&o.push({action:"update",label:a.update}),o.push({action:"uninstall",label:a.uninstall}),o.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),o}function CN({state:t,onClose:a,onAction:s,itemsOverride:o}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),g=p.useMemo(()=>t.skill?o??wN(t.skill):[],[t.skill,o]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+g.length*28;let k=t.x,E=t.y;return k+b+v>window.innerWidth&&(k=Math.max(v,t.x-b)),E+S+v>window.innerHeight&&(E=Math.max(v,t.y-S)),{left:k,top:E}},[t.x,t.y,g.length]);p.useEffect(()=>{if(t.open)return u.current=document.activeElement??null,h(0),requestAnimationFrame(()=>{var v;(v=c.current)==null||v.focus()}),()=>{var v,b;(b=(v=u.current)==null?void 0:v.focus)==null||b.call(v),u.current=null}},[t.open]);const y=p.useCallback(()=>{if(!t.skill)return;const v=g[d];!v||v.disabled||(s(v.action,t.skill),a())},[g,d,t.skill,s,a]);return p.useEffect(()=>{if(!t.open)return;function v(S){if(S.key==="Escape"){S.preventDefault(),a();return}if(S.key==="ArrowDown"){S.preventDefault(),h(k=>Math.min(k+1,Math.max(g.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(k=>Math.max(k-1,0));return}if(S.key==="Enter"||S.key===" "){S.preventDefault(),y();return}}function b(S){c.current&&S.target instanceof Node&&(c.current.contains(S.target)||a())}return window.addEventListener("keydown",v,!0),window.addEventListener("mousedown",b,!0),()=>{window.removeEventListener("keydown",v,!0),window.removeEventListener("mousedown",b,!0)}},[t.open,a,g.length,y]),!t.open||!t.skill?null:r.jsx("div",{ref:c,role:"menu",tabIndex:-1,"data-testid":"context-menu",style:{position:"fixed",left:m.left,top:m.top,zIndex:70,minWidth:200,padding:4,background:"var(--bg-canvas)",border:"1px solid var(--border-default)",borderRadius:6,boxShadow:"0 12px 32px rgba(0,0,0,0.16)",fontFamily:"var(--font-sans)",fontSize:13,color:"var(--text-primary)",outline:"none"},children:g.map((v,b)=>r.jsx("div",{role:"menuitem","aria-disabled":v.disabled||void 0,title:v.title||void 0,"data-action":v.action,"data-selected":b===d||void 0,onMouseEnter:()=>h(b),onClick:()=>{v.disabled||(s(v.action,t.skill),a())},style:{padding:"5px 10px",borderRadius:4,cursor:v.disabled?"default":"pointer",opacity:v.disabled?.5:1,background:b===d?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent"},children:v.label},v.action))})}function EN({open:t,title:a,body:s,confirmLabel:o="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const g=p.useRef(null),m=p.useRef(null),y=p.useRef(null);if(p.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var k;(k=m.current)==null||k.focus()}),()=>{var k,E;(E=(k=y.current)==null?void 0:k.focus)==null||E.call(k),y.current=null}},[t]),p.useEffect(()=>{if(!t)return;function k(E){if(E.key==="Escape"){E.preventDefault(),h();return}if(E.key==="Tab"&&g.current){const C=g.current.querySelectorAll("button:not([disabled])");if(C.length===0)return;const N=C[0],T=C[C.length-1];E.shiftKey&&document.activeElement===N?(E.preventDefault(),T.focus()):!E.shiftKey&&document.activeElement===T&&(E.preventDefault(),N.focus())}}return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[t,h]),!t)return null;const v="confirm-dialog-title",b="confirm-dialog-body",S=u==="destructive"?{background:"var(--red, #d92d20)",color:"#fff",border:"1px solid var(--red, #d92d20)"}:{background:"var(--accent-surface)",color:"var(--text-primary)",border:"1px solid var(--border-default)"};return r.jsx("div",{"data-testid":"confirm-dialog-overlay",onMouseDown:k=>{k.target===k.currentTarget&&h()},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:100},children:r.jsxs("div",{ref:g,role:"alertdialog","aria-modal":"true","aria-labelledby":v,"aria-describedby":b,"data-testid":"confirm-dialog",style:{background:"var(--bg-canvas)",color:"var(--text-primary)",border:"1px solid var(--border-default)",borderRadius:8,padding:20,width:"min(440px, 92vw)",boxShadow:"0 20px 48px rgba(0,0,0,0.32)",fontFamily:"var(--font-sans)"},children:[r.jsx("h2",{id:v,style:{margin:0,fontSize:16,fontWeight:600,marginBottom:8},children:a}),r.jsx("p",{id:b,style:{margin:0,fontSize:13,color:"var(--text-secondary)",marginBottom:16,lineHeight:1.5},children:s}),r.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[r.jsx("button",{ref:m,type:"button","data-testid":"confirm-dialog-cancel",onClick:h,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",background:"transparent",color:"var(--text-primary)",border:"1px solid var(--border-default)",fontSize:13},children:c}),r.jsx("button",{type:"button","data-testid":"confirm-dialog-confirm",onClick:d,style:{padding:"6px 14px",borderRadius:6,cursor:"pointer",fontSize:13,...S},children:o})]})]})})}function NN(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}const Jg=t=>`${t.plugin}/${t.skill}`;function TN(t){const a=t==null?void 0:t.delayMs,s=t==null?void 0:t.onCommit,o=t==null?void 0:t.onFailure,c=p.useRef(s),u=p.useRef(o);c.current=s,u.current=o;const d=p.useRef(new Map),[,h]=p.useState(0),g=p.useCallback(()=>h(k=>k+1),[]),m=p.useCallback(async k=>{var E,C;try{await Ce.deleteSkill(k.skill.plugin,k.skill.skill),(E=c.current)==null||E.call(c,k.skill)}catch(N){(C=u.current)==null||C.call(u,k.skill,N)}finally{d.current.delete(Jg(k.skill)),g()}},[g]),y=p.useCallback(k=>{const E=Jg(k),C=d.current.get(E);C!=null&&C.timeoutId&&clearTimeout(C.timeoutId);const N={skill:k,timeoutId:null};N.timeoutId=setTimeout(()=>{N.timeoutId=null,m(N)},a),d.current.set(E,N),g()},[a,m,g]),v=p.useCallback(k=>{const E=d.current.get(k);E&&(E.timeoutId&&clearTimeout(E.timeoutId),d.current.delete(k),g())},[g]),b=p.useCallback(async()=>{const k=Array.from(d.current.values());for(const E of k)E.timeoutId&&(clearTimeout(E.timeoutId),E.timeoutId=null);await Promise.all(k.map(E=>m(E)))},[m]),S=p.useCallback(k=>d.current.has(k),[]);return p.useEffect(()=>{const k=()=>{b()};return window.addEventListener("beforeunload",k),()=>{window.removeEventListener("beforeunload",k)}},[b]),p.useEffect(()=>{const k=d.current;return()=>{for(const E of k.values())E.timeoutId&&clearTimeout(E.timeoutId);k.clear()}},[]),{enqueueDelete:y,cancelDelete:v,flushPending:b,isPending:S}}const RN={"anthropic-api":{name:ne.setupProviders.anthropic.name,description:ne.setupProviders.anthropic.description,envVars:ne.setupProviders.anthropic.envVars,keyUrl:ne.setupProviders.anthropic.keyUrl,learnMoreUrl:ne.setupProviders.anthropic.learnMoreUrl},openai:{name:ne.setupProviders.openai.name,description:ne.setupProviders.openai.description,envVars:ne.setupProviders.openai.envVars,keyUrl:ne.setupProviders.openai.keyUrl,learnMoreUrl:ne.setupProviders.openai.learnMoreUrl},openrouter:{name:ne.setupProviders.openrouter.name,description:ne.setupProviders.openrouter.description,envVars:ne.setupProviders.openrouter.envVars,keyUrl:ne.setupProviders.openrouter.keyUrl,learnMoreUrl:ne.setupProviders.openrouter.learnMoreUrl},gemini:{name:ne.setupProviders.gemini.name,description:ne.setupProviders.gemini.description,envVars:ne.setupProviders.gemini.envVars,keyUrl:ne.setupProviders.gemini.keyUrl,learnMoreUrl:ne.setupProviders.gemini.learnMoreUrl},ollama:{name:ne.setupProviders.ollama.name,description:ne.setupProviders.ollama.description,envVars:ne.setupProviders.ollama.envVars,install:[ne.setupProviders.ollama.installCmd],start:[ne.setupProviders.ollama.startCmd],pullExample:ne.setupProviders.ollama.pullExample,learnMoreUrl:ne.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ne.setupProviders.lmStudio.name,description:ne.setupProviders.lmStudio.description,envVars:ne.setupProviders.lmStudio.envVars,install:[ne.setupProviders.lmStudio.installCmd],start:[ne.setupProviders.lmStudio.startCmd],pullExample:ne.setupProviders.lmStudio.pullExample,learnMoreUrl:ne.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ne.setupProviders.claudeCode.name,description:ne.setupProviders.claudeCode.description,envVars:[],notes:[ne.setupProviders.claudeCode.loginHint,ne.claudeCodeLabel.compactLabel],learnMoreUrl:ne.setupProviders.claudeCode.learnMoreUrl}};function AN(t){return t?RN[t]??null:null}function MN({open:t,providerKey:a,onClose:s}){const o=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=h=>{h.key==="Escape"&&(h.preventDefault(),s())};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,s]),p.useEffect(()=>{if(!t)return;const d=o.current;if(!d)return;const h=d.querySelector("button, a[href], [tabindex]:not([tabindex='-1']), input, textarea, select");h==null||h.focus()},[t]),!t||typeof document>"u")return null;const c=AN(a),u=(c==null?void 0:c.name)??ne.setupDrawer.fallbackTitle;return Go.createPortal(r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"setup-drawer-backdrop","aria-hidden":"true",onClick:s,style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",zIndex:99,animation:"vskillDrawerBackdropIn 120ms ease"}}),r.jsxs("div",{"data-testid":"setup-drawer",ref:o,role:"dialog","aria-modal":"true","aria-label":ne.setupDrawer.title(u),style:{position:"fixed",top:0,right:0,bottom:0,width:"480px",maxWidth:"100vw",background:"var(--bg-surface, var(--surface-1))",borderLeft:"1px solid var(--border-default, var(--border-subtle))",boxShadow:"-8px 0 32px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",zIndex:100,fontFamily:"var(--font-sans)",animation:"vskillDrawerIn 200ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsx(LN,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx(zN,{content:c}):r.jsx(DN,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
92
+ from { transform: translateX(100%); }
93
+ to { transform: translateX(0); }
94
+ }
95
+ @keyframes vskillDrawerBackdropIn {
96
+ from { opacity: 0; }
97
+ to { opacity: 1; }
98
+ }`})]})]}),document.body)}function LN({title:t,onClose:a}){return r.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 20px",borderBottom:"1px solid var(--border-default, var(--border-subtle))"},children:[r.jsx("h2",{style:{fontFamily:"var(--font-serif)",fontSize:18,fontWeight:500,margin:0,color:"var(--text-primary)"},children:ne.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":ne.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function zN({content:t}){var a,s;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsx("p",{style:{fontSize:14,lineHeight:1.5,color:"var(--text-primary)",margin:0},children:t.description}),t.notes&&t.notes.length>0&&r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.notes.map(o=>r.jsx("li",{style:{fontSize:13,color:"var(--text-secondary)",padding:"8px 10px",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",borderRadius:4},children:o},o))}),t.envVars.length>0&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(o=>r.jsx("li",{children:r.jsx(_N,{name:o})},o))})]}),t.keyUrl&&r.jsx(ON,{href:t.keyUrl,label:ne.setupDrawer.getKey,testId:"setup-drawer-get-key"}),(t.install||t.start||t.pullExample)&&r.jsxs("section",{children:[r.jsx("h3",{style:{fontSize:11,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-secondary)",margin:"0 0 8px"},children:ne.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((o,c)=>r.jsx(Pd,{code:o},`install-${c}`)),(s=t.start)==null?void 0:s.map((o,c)=>r.jsx(Pd,{code:o},`start-${c}`)),t.pullExample&&r.jsx(Pd,{code:t.pullExample})]})]}),r.jsx("footer",{style:{marginTop:8},children:r.jsxs("a",{href:t.learnMoreUrl,target:"_blank",rel:"noopener noreferrer","data-testid":"setup-drawer-learn-more",style:{fontSize:12,color:"var(--color-accent, var(--accent-surface))",textDecoration:"none"},children:[ne.setupDrawer.learnMore," →"]})})]})}function DN(){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[r.jsx("h3",{style:{margin:0,fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:ne.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ne.setupDrawer.fallbackBody})]})}function _N({name:t}){const a=async()=>{var s;try{await((s=navigator.clipboard)==null?void 0:s.writeText(t))}catch{}};return r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 8px",background:"color-mix(in srgb, var(--border-default) 30%, transparent)",borderRadius:4},children:[r.jsx("code",{style:{fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)",flex:1},children:t}),r.jsx("button",{type:"button",onClick:a,"aria-label":`Copy ${t} to clipboard`,style:{background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:3,padding:"2px 8px",color:"var(--text-secondary)",fontSize:11,fontFamily:"var(--font-sans)",cursor:"pointer"},children:ne.setupDrawer.copy})]})}function Pd({code:t}){return r.jsx("pre",{style:{margin:0,padding:"8px 10px",background:"var(--bg-canvas, #111)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:11.5,lineHeight:1.5,borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",overflowX:"auto",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})}function ON({href:t,label:a,testId:s}){return r.jsxs("a",{href:t,target:"_blank",rel:"noopener noreferrer","data-testid":s,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 12%, transparent)",color:"var(--text-primary)",textDecoration:"none",fontSize:13,fontWeight:500,fontFamily:"var(--font-sans)",width:"fit-content"},children:[a," →"]})}function BN(){const[t,a]=p.useState(!1),[s,o]=p.useState(null),c=p.useRef(null),u=p.useCallback((h,g)=>{var m;c.current=typeof document<"u"?document.activeElement:null,(m=g==null?void 0:g.beforeOpen)==null||m.call(g),o(h),a(!0)},[]),d=p.useCallback(()=>{a(!1);const h=c.current;h&&"focus"in h&&typeof h.focus=="function"&&queueMicrotask(()=>h.focus())},[]);return p.useMemo(()=>({open:u,close:d,isOpen:t,providerKey:s}),[u,d,t,s])}function IN(t){const a=[],s=[],o=new Set;for(const c of t){if(c.presence==="absent"||c.health==="missing"){s.push({kind:"individual",key:c.id,agent:c});continue}if(c.sharedFolderGroup&&c.sharedFolderGroup.length>1){const u=[...c.sharedFolderGroup].sort().join("+");if(o.has(u))continue;o.add(u);const d=t.filter(h=>c.sharedFolderGroup.includes(h.id));a.push({kind:"aggregate",key:`shared:${u}`,consumers:d,sharedFolderPath:c.sharedFolderPath??"~/.config/agents/skills",combinedCount:d.reduce((h,g)=>h+g.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function UN({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:o,onSwitch:c,onOpenSetup:u,onClose:d}){const h=p.useRef(null);p.useEffect(()=>{const y=v=>{v.key==="Escape"&&(v.preventDefault(),d())};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[d]),p.useEffect(()=>{const y=b=>{h.current&&!h.current.contains(b.target)&&d()},v=setTimeout(()=>{document.addEventListener("mousedown",y)},0);return()=>{clearTimeout(v),document.removeEventListener("mousedown",y)}},[d]);const g=p.useMemo(()=>IN(t),[t]),m=t.find(y=>y.id===s)??t.find(y=>y.id===a)??t[0];return typeof document>"u"?null:Go.createPortal(r.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ne.scopePicker.popoverTitle,style:{position:"fixed",top:96,left:"50%",transform:"translateX(-50%)",width:600,maxWidth:"calc(100vw - 32px)",background:"var(--bg-surface, var(--surface-1))",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,boxShadow:"0 18px 40px rgba(0,0,0,0.25)",overflow:"hidden",zIndex:90,animation:"scopePickerFadeIn 120ms cubic-bezier(0.2, 0, 0, 1)"},children:[r.jsxs("div",{style:{display:"flex",height:360,maxHeight:"60vh"},children:[r.jsxs("section",{"data-testid":"agent-scope-picker-agents",style:{width:260,borderRight:"1px solid var(--border-default, var(--border-subtle))",overflowY:"auto",padding:"6px 0"},children:[g.detected.length===0&&g.notDetected.length===0&&r.jsx(ev,{}),g.detected.map(y=>y.kind==="aggregate"?r.jsx($N,{row:y,onFocus:()=>{var v;return o(((v=y.consumers[0])==null?void 0:v.id)??a??"")}},y.key):r.jsx(HN,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===a,onClick:()=>o(y.agent.id)},y.key)),g.notDetected.length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{"data-testid":"agent-scope-not-detected-subheading",title:"These agents were not found on this machine. Hover a row to see which folder detection looked for.",style:{padding:"10px 14px 4px",fontSize:10,fontWeight:600,letterSpacing:"0.08em",textTransform:"uppercase",color:"var(--text-tertiary)"},children:ne.scopePicker.notDetectedSubheading}),g.notDetected.map(y=>r.jsx(VN,{agent:y.agent},y.key))]})]}),r.jsx("section",{"data-testid":"agent-scope-picker-stats",style:{flex:1,overflowY:"auto",padding:"14px 16px"},children:m?r.jsx(PN,{agent:m,activeAgentId:a,onSwitch:()=>c(m.id)}):r.jsx(ev,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
99
+ from { opacity: 0; transform: translateX(-50%) translateY(2px); }
100
+ to { opacity: 1; transform: translateX(-50%) translateY(0); }
101
+ }`})]}),document.body)}function HN({agent:t,focused:a,active:s,onClick:o}){const c=t.health==="ok"?"var(--color-ok, #22c55e)":t.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)";return r.jsxs("button",{type:"button","data-testid":"agent-scope-row","data-agent-id":t.id,"data-active":s?"true":"false",onClick:o,style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"8px 14px",background:a?"color-mix(in srgb, var(--accent-surface) 10%, transparent)":"transparent",border:"none",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:c,flexShrink:0}}),r.jsx("span",{style:{flex:1,fontSize:13},children:t.displayName}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount]})]})}function $N({row:t,onFocus:a}){return r.jsxs("button",{type:"button","data-testid":"agent-scope-shared-folder-row",onClick:a,style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:4,width:"100%",padding:"8px 14px",background:"transparent",border:"none",borderTop:"1px dashed var(--border-subtle)",borderBottom:"1px dashed var(--border-subtle)",cursor:"pointer",textAlign:"left",fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)"},children:t.sharedFolderPath}),r.jsxs("span",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[t.consumers.map(s=>r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"color-mix(in srgb, var(--color-global) 20%, transparent)",color:"var(--text-primary)"},children:s.id},s.id)),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:["· ",t.combinedCount," skills"]})]})]})}function VN({agent:t}){const a=t.isRemoteOnly?`${t.displayName} is a web-only product — no local CLI or folder to detect.`:t.resolvedGlobalDir?`Looked for ${t.resolvedGlobalDir} — not found.`:`${t.displayName} was not found on this machine.`;return r.jsxs("div",{"data-testid":`agent-scope-not-detected-row-${t.id}`,title:a,style:{display:"flex",alignItems:"center",gap:10,padding:"6px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",fontSize:12},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--text-tertiary)",flexShrink:0}}),r.jsx("span",{style:{flex:1},children:t.displayName}),t.isRemoteOnly&&r.jsx("span",{"data-testid":`agent-scope-remote-badge-${t.id}`,"aria-label":"Remote-only agent",title:"Web-only agent — no local CLI to install skills into. Use the agent's web UI to load skills.",style:{background:"color-mix(in srgb, var(--text-tertiary) 18%, transparent)",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:10,padding:"1px 8px",color:"var(--text-secondary)",fontSize:10,letterSpacing:"0.04em",textTransform:"uppercase"},children:"Remote"})]})}function PN({agent:t,activeAgentId:a,onSwitch:s}){const o=t.id===a,c=t.isRemoteOnly===!0,u=o||c,d=o?"Active":c?"Remote-only":ne.scopePicker.switchCta;return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[r.jsxs("div",{children:[r.jsx("div",{style:{fontFamily:"var(--font-serif)",fontSize:16,fontWeight:500,color:"var(--text-primary)"},children:t.displayName}),r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:2},children:c?"Remote service — no local install":GN(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(Fd,{label:ne.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(Fd,{label:ne.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(Fd,{label:ne.scopePicker.statsLastSync,value:t.lastSync?FN(t.lastSync):"—"})]}),r.jsx("button",{type:"button","data-testid":"agent-scope-switch",onClick:s,disabled:u,title:c?"This agent has no local CLI to switch to":void 0,style:{alignSelf:"flex-start",padding:"8px 14px",borderRadius:6,border:"1px solid var(--border-default, var(--border-subtle))",background:u?"transparent":"color-mix(in srgb, var(--accent-surface) 20%, transparent)",color:"var(--text-primary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:u?"default":"pointer",opacity:u?.5:1},children:d})]})}function Fd({label:t,value:a}){return r.jsxs(r.Fragment,{children:[r.jsx("dt",{style:{color:"var(--text-secondary)",margin:0},children:t}),r.jsx("dd",{style:{color:"var(--text-primary)",margin:0,fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums"},children:a})]})}function ev(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function FN(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const o=Math.round(s/6e4);if(o<1)return"just now";if(o<60)return`${o}m ago`;const c=Math.round(o/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function GN(t){switch(t){case"ok":return ne.scopePicker.statsHealthOk;case"stale":return ne.scopePicker.statsHealthStale;case"missing":return ne.scopePicker.statsHealthMissing}}function WN(t){const a=new Map;for(const s of t.sharedFolders??[])for(const o of s.consumers)a.set(o,s);return t.agents.map(s=>{const o=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,lastSync:s.lastSync,health:s.health,sharedFolderGroup:o?o.consumers:void 0,sharedFolderPath:o?o.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function qN({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:o}){const[c,u]=p.useState(!1),[d,h]=p.useState(null),g=p.useRef(null),m=p.useMemo(()=>t.find(S=>S.id===a)??t[0]??null,[t,a]),y=p.useMemo(()=>m?m.health==="ok"?"var(--color-ok, #22c55e)":m.health==="stale"?"var(--color-own, #f59e0b)":"var(--text-tertiary)":"var(--text-tertiary)",[m]),v=p.useCallback(()=>{var S;u(!1),(S=g.current)==null||S.focus()},[]),b=p.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:g,type:"button","data-testid":"agent-scope-picker-trigger","aria-haspopup":"dialog","aria-expanded":c,onClick:()=>u(S=>!S),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),u(!0))},style:{display:"flex",alignItems:"center",gap:10,height:"40px",width:"100%",padding:"0 14px",background:"var(--bg-surface, var(--surface-1))",border:"none",borderBottom:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer",color:"var(--text-primary)",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,textAlign:"left",position:"sticky",top:0,zIndex:2},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:y,flexShrink:0}}),r.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(m==null?void 0:m.displayName)??"Select agent"}),r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["(",(m==null?void 0:m.installedCount)??0," · ",(m==null?void 0:m.globalCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(UN,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{o(S),v()},onClose:v})]})}const Gy="vskill-ccode-banner-dismissed",YN=new Set(["claude-cli","claude-code"]);function KN(){try{return sessionStorage.getItem(Gy)==="true"}catch{return!1}}function XN(){try{sessionStorage.setItem(Gy,"true")}catch{}}function QN({activeAgentId:t}){const[a,s]=p.useState(()=>KN()),o=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{XN(),s(!0)},[]);return!t||!YN.has(t)||a?null:r.jsxs("div",{"data-testid":"claude-code-first-use-banner",role:"note","aria-label":"Claude Code session info",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"8px 12px",borderBottom:"1px solid var(--border-default, var(--border-subtle))",background:"color-mix(in srgb, var(--accent-surface) 8%, transparent)",fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-primary)",lineHeight:1.45},children:[r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:"var(--color-ok, #22c55e)",marginTop:6,flexShrink:0}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{children:[ne.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:o,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ne.claudeCodeLabel.learnMore})]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-dismiss",onClick:c,"aria-label":"Dismiss Claude Code info banner",style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,lineHeight:1,padding:2,flexShrink:0},children:"×"})]})}function ZN(){const[t,a]=p.useState(null),[s,o]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await Ce.getAgents();a(h),o("ready"),u(null)}catch(h){o("error"),u(h.message)}},[]);return p.useEffect(()=>{d()},[d]),p.useEffect(()=>{const h=()=>void d();return window.addEventListener("studio:agent-changed",h),()=>window.removeEventListener("studio:agent-changed",h)},[d]),{status:s,response:t,error:c,refresh:()=>void d()}}const Eo="workspace",JN=["skills","agents"];async function eT(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function tT(t){const a=await fetch("/api/workspace/active",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t})});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/active failed: ${a.status}`)}return await a.json()}async function nT(t){const a=await fetch("/api/workspace/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`POST /api/workspace/projects failed: ${a.status}`)}return await a.json()}async function rT(t){const a=await fetch(`/api/workspace/projects/${encodeURIComponent(t)}`,{method:"DELETE"});if(!a.ok){const s=await a.json().catch(()=>({}));throw new Error(s.error??`DELETE /api/workspace/projects/${t} failed: ${a.status}`)}return await a.json()}function Gd(){for(const t of JN)Tn(t)}function aT(){const{data:t,loading:a,error:s,revalidate:o}=ri(Eo,eT),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await tT(m),Tn(Eo),Gd()},[]),h=p.useCallback(async m=>{await nT(m),Tn(Eo),Gd()},[]),g=p.useCallback(async m=>{await rT(m),Tn(Eo),Gd()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:g,revalidate:o}}function lT({workspace:t,onSwitch:a,onAdd:s,onRemove:o,isPathStale:c}){const[u,d]=p.useState(!1),[h,g]=p.useState(!1),[m,y]=p.useState(""),[v,b]=p.useState(null),[S,k]=p.useState(null),[E,C]=p.useState(null),[N,T]=p.useState(!1),A=p.useRef(null),B=(t==null?void 0:t.projects)??[],z=B.find(D=>D.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function D(U){A.current&&!A.current.contains(U.target)&&(d(!1),g(!1),b(null))}return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[u]);async function F(){b(null);const D=m.trim();if(!D){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!D.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(D)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:D}),y(""),g(!1)}catch(U){const H=U instanceof Error?U.message:String(U);/does not exist/i.test(H)?b(`Path not found on disk: ${D}`):/Duplicate/i.test(H)?b("That project is already registered."):b(H)}}async function w(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const D=await window.showDirectoryPicker();y(D.name),g(!0)}catch{}else g(!0)}function O(D){if(D.length<=50)return D;const U=D.split("/");return U.length<=4?D:`${U.slice(0,3).join("/")}/…/${U.slice(-2).join("/")}`}return r.jsxs("div",{ref:A,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(D=>!D),"aria-expanded":u,"aria-haspopup":"menu",title:(z==null?void 0:z.path)??"No project selected",style:{display:"flex",alignItems:"center",gap:8,padding:"4px 10px",border:"1px solid transparent",borderRadius:6,background:u?"var(--surface-2, rgba(0,0,0,0.05))":"transparent",cursor:"pointer",fontFamily:"var(--font-mono)",fontSize:13,color:"var(--text-primary)",transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:8,height:8,borderRadius:"50%",flexShrink:0,backgroundColor:(z==null?void 0:z.colorDot)??"var(--text-tertiary, #999)"}}),r.jsx("span",{style:{maxWidth:180,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z?z.name:"No project"}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary, #999)",marginLeft:2},children:u?"▴":"▾"})]}),u&&r.jsxs("div",{role:"menu","aria-label":"Switch project",style:{position:"absolute",top:"calc(100% + 4px)",left:0,minWidth:280,maxWidth:420,width:"max-content",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:8,boxShadow:"0 4px 6px -1px rgba(0,0,0,0.08), 0 10px 20px -5px rgba(0,0,0,0.12)",overflow:"hidden",zIndex:50,fontFamily:"var(--font-sans)"},children:[B.length===0&&r.jsx("div",{style:{padding:"16px 16px 12px",fontSize:12,color:"var(--text-tertiary)",lineHeight:1.5},children:"No projects registered. Add one to get started."}),B.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:B.map(D=>{const U=c?c(D.path):!1,H=D.id===(t==null?void 0:t.activeProjectId),q=S===D.id;return r.jsxs("li",{role:"menuitem","data-stale":U?"true":"false",onMouseEnter:()=>k(D.id),onMouseLeave:()=>k(X=>X===D.id?null:X),onClick:()=>{if(!U){if(H){d(!1);return}C(D)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:U?"not-allowed":"pointer",background:q&&!U?"var(--surface-2, rgba(0,0,0,0.04))":H?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:U?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:D.colorDot,boxShadow:H?"0 0 0 2px color-mix(in oklch, currentColor 20%, transparent)":"none"}}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:13,fontWeight:H?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.name}),H&&r.jsx("span",{"aria-label":"Active",style:{fontSize:10,color:"var(--color-action, #2F5B8E)",letterSpacing:"0.05em",textTransform:"uppercase",fontWeight:600},children:"Active"})]}),r.jsx("div",{title:D.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(D.path)}),U&&r.jsx("div",{style:{fontSize:10,color:"var(--color-own, #b45309)",marginTop:2},children:"Path no longer exists"})]}),r.jsx("button",{type:"button","aria-label":`Remove ${D.name}`,onClick:X=>{X.stopPropagation(),o(D.id)},style:{width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",border:"none",background:"transparent",borderRadius:4,cursor:"pointer",color:"var(--text-tertiary)",opacity:q?1:0,transition:"opacity 120ms ease, color 120ms ease, background-color 120ms ease",flexShrink:0},onMouseEnter:X=>{X.currentTarget.style.color="var(--color-error, #b91c1c)",X.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-error, #b91c1c) 10%, transparent)"},onMouseLeave:X=>{X.currentTarget.style.color="var(--text-tertiary)",X.currentTarget.style.backgroundColor="transparent"},children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("polyline",{points:"3 6 5 6 21 6"}),r.jsx("path",{d:"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"}),r.jsx("path",{d:"M10 11v6"}),r.jsx("path",{d:"M14 11v6"}),r.jsx("path",{d:"M9 6V4a2 2 0 0 1 2-2h2a2 2 0 0 1 2 2v2"})]})})]},D.id)})}),r.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:h?8:6},children:[!h&&r.jsxs("button",{type:"button",onClick:()=>void w(),className:"vskill-project-add",style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500,color:"var(--color-action, #2F5B8E)",transition:"background-color 120ms ease"},onMouseEnter:D=>{D.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:D=>{D.currentTarget.style.backgroundColor="transparent"},children:[r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),r.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),"Add project"]}),h&&r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("input",{type:"text",value:m,onChange:D=>y(D.target.value),onKeyDown:D=>{D.key==="Enter"&&F(),D.key==="Escape"&&(g(!1),b(null))},placeholder:"/absolute/path/to/project",autoFocus:!0,style:{width:"100%",padding:"6px 8px",fontFamily:"var(--font-mono)",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsxs("div",{style:{display:"flex",gap:6,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:()=>{g(!1),b(null),y("")},style:{padding:"4px 10px",fontSize:12,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Cancel"}),r.jsx("button",{type:"button",onClick:()=>void F(),style:{padding:"4px 10px",fontSize:12,border:"none",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-paper, #fff)",cursor:"pointer",fontWeight:500},children:"Add"})]}),v&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:v})]})]})]}),E&&r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Switch project instructions",style:{position:"fixed",inset:0,zIndex:80,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>C(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:D=>D.stopPropagation(),style:{position:"relative",width:"min(520px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",padding:18,fontFamily:"var(--font-sans)",color:"var(--text-primary)"},children:[r.jsxs("h2",{style:{margin:0,fontSize:16,fontWeight:600,fontFamily:"var(--font-serif, ui-serif)",marginBottom:8},children:["Switch to ",E.name]}),r.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",lineHeight:1.5,margin:0,marginBottom:12},children:"Skill Studio's skill scanner reads from the folder it was launched in, so switching projects from the browser isn't possible. Quit this server and relaunch from the target folder:"}),r.jsx("div",{style:{background:"var(--surface-1, #0f0f10)",color:"var(--text-primary)",padding:"10px 12px",borderRadius:6,fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.55,whiteSpace:"pre-wrap",wordBreak:"break-all",border:"1px solid var(--border-subtle, rgba(255,255,255,0.08))"},children:`cd "${E.path}" && npx vskill@latest studio`}),r.jsxs("div",{style:{display:"flex",gap:8,marginTop:14,justifyContent:"flex-end"},children:[r.jsx("button",{type:"button",onClick:async()=>{try{await navigator.clipboard.writeText(`cd "${E.path}" && npx vskill@latest studio`),T(!0),setTimeout(()=>T(!1),1600)}catch{}},style:{padding:"7px 14px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"#ffffff",cursor:"pointer",boxShadow:"0 1px 2px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.12)"},children:N?"Copied!":"Copy command"}),r.jsx("button",{type:"button",onClick:()=>C(null),style:{padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer"},children:"Close"})]})]})]})]})}function sT(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(o=>{const c=`${o.name} ${o.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function iT({open:t,projects:a,onSwitch:s,onClose:o}){const[c,u]=p.useState(""),[d,h]=p.useState(0),g=p.useMemo(()=>sT(a,c),[a,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=g.length&&h(0)},[g.length,d]);const m=y=>{if(y.key==="Escape"){y.preventDefault(),o();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(g.length-1,0)));return}if(y.key==="ArrowUp"){y.preventDefault(),h(v=>Math.max(v-1,0));return}if(y.key==="Enter"){y.preventDefault();const v=g[d];v&&(s(v.id),o())}};return t?r.jsxs("div",{role:"dialog","aria-modal":"true","data-vskill-project-palette":!0,className:"vskill-project-palette fixed inset-0 z-50 flex items-start justify-center pt-24",children:[r.jsx("div",{className:"absolute inset-0 bg-black/30",onClick:o}),r.jsxs("div",{className:"relative w-[520px] max-w-[92vw] bg-background border rounded shadow-lg",children:[r.jsx("input",{type:"text",autoFocus:!0,value:c,onChange:y=>u(y.target.value),onKeyDown:m,placeholder:"Switch project…",className:"w-full px-3 py-2 text-sm border-b outline-none"}),r.jsxs("ul",{role:"listbox",className:"max-h-80 overflow-auto",children:[g.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),g.map((y,v)=>r.jsxs("li",{role:"option","aria-selected":v===d,"data-highlighted":v===d,className:["flex items-center gap-2 px-3 py-2 text-sm cursor-pointer",v===d?"bg-muted":""].join(" "),onMouseEnter:()=>h(v),onClick:()=>{s(y.id),o()},children:[r.jsx("span",{"aria-hidden":!0,className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:y.colorDot}}),r.jsxs("span",{className:"flex-1",children:[r.jsx("span",{className:"vskill-palette-name",children:y.name}),r.jsx("span",{className:"ml-2 vskill-palette-path text-xs font-mono text-muted-foreground",children:y.path})]})]},y.id))]})]})]}):null}const tv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function oT({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:o,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[g,m]=p.useState(s),[y,v]=p.useState(""),[b,S]=p.useState(""),[k,E]=p.useState(""),[C,N]=p.useState([]),[T,A]=p.useState(!1),[B,z]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),v(""),S(""),E(""),z(null))},[t,s]),p.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(L=>L.json()).then(L=>{$&&N(L.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),p.useEffect(()=>{if(!t)return;function $(L){L.key==="Escape"&&(L.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const F=C.length>0,w=o&&F,O=o,D=tv.test(y),U=g==="existing-plugin"?b.length>0:tv.test(b),H=!T&&D&&(g==="standalone"||U),q=cT(c,g,b,y);async function X(){z(null),A(!0);try{const _=new URLSearchParams;_.set("mode",g),_.set("skillName",y),b&&_.set("pluginName",b);const I=await fetch(`/api/authoring/skill-exists?${_.toString()}`),V=await I.json();if(!I.ok){z(V.error??`Check failed: ${I.status}`);return}if(V.exists){z(`Skill '${y}' already exists${V.path?` at ${V.path}`:""}`);return}}catch(_){z(_ instanceof Error?_.message:String(_));return}finally{A(!1)}const $=new URLSearchParams;$.set("mode",g),$.set("skillName",y),k.trim()&&$.set("description",k.trim()),b&&$.set("pluginName",b);const L=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=L),a()}async function J(){z(null),A(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:g,skillName:y,description:k.trim()||void 0,pluginName:g==="standalone"?void 0:b})}),L=await $.json();if(!$.ok||!L.ok){z(L.error??`Create failed: ${$.status}`);return}Tn("skills"),u==null||u({mode:g,skillName:y,pluginName:L.pluginName??null,skillMdPath:L.skillMdPath}),a()}catch($){z($ instanceof Error?$.message:String($))}finally{A(!1)}}return r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Create skill","data-vskill-create-skill-modal":!0,style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)"}}),r.jsxs("div",{style:{position:"relative",width:"min(560px, 92vw)",maxHeight:"86vh",overflow:"auto",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:10,boxShadow:"0 10px 15px -3px rgba(0,0,0,0.12), 0 20px 40px -8px rgba(0,0,0,0.18)",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[r.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",letterSpacing:"0.01em"},children:d==="destination"?"Create a skill":"Name and describe"}),r.jsxs("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginLeft:"auto",fontVariantNumeric:"tabular-nums"},children:["Step ",d==="destination"?"1":"2"," of 2"]})]}),d==="destination"&&r.jsxs("div",{style:{padding:14,display:"flex",flexDirection:"column",gap:10},children:[r.jsx(Wd,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:g==="standalone",onClick:()=>m("standalone")}),r.jsx(Wd,{title:"Add to existing plugin",subtitle:w?`${C.length} plugin source${C.length===1?"":"s"} in this project`:o?"No plugin sources in this project yet":"Claude Code only",description:"Appends a skill to an existing <plugin>/.claude-plugin/plugin.json source.",icon:"🧩",disabled:!w,selected:g==="existing-plugin",onClick:()=>w&&m("existing-plugin")}),r.jsx(Wd,{title:"New plugin",subtitle:O?"Bundles one or more skills for distribution":"Claude Code only",description:"Scaffolds <plugin>/.claude-plugin/plugin.json and its first skill.",icon:"📦",disabled:!O,selected:g==="new-plugin",onClick:()=>O&&m("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[g==="new-plugin"&&r.jsx(No,{label:"Plugin name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:b,onChange:$=>S($.target.value.trim()),placeholder:"my-first-plugin",autoFocus:!0,style:To(!b||U)})}),g==="existing-plugin"&&r.jsx(No,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...To(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),C.map($=>r.jsx("option",{value:$.name,children:$.name},$.path))]})}),r.jsx(No,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:g!=="new-plugin",style:To(!y||D)})}),r.jsx(No,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:k,onChange:$=>E($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...To(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),q&&r.jsxs("div",{style:{padding:"8px 10px",fontSize:11,fontFamily:"var(--font-mono)",color:"var(--text-secondary)",background:"var(--surface-1, rgba(0,0,0,0.03))",border:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",borderRadius:4,wordBreak:"break-all"},children:[r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)",marginBottom:2,fontFamily:"var(--font-sans)"},children:"Will create:"}),q.map(($,L)=>r.jsx("div",{children:$},L))]}),B&&r.jsx("div",{style:{fontSize:12,color:"var(--color-error, #b91c1c)",padding:"6px 10px",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:B})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-end",gap:8,padding:"12px 16px",borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",background:"var(--surface-1, rgba(0,0,0,0.02))"},children:[r.jsx("button",{type:"button",onClick:a,style:qd,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:nv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:qd,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!H,style:{...qd,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Opens the AI generation flow with this destination pre-selected (choose Claude Code, Anthropic API, OpenRouter, or local models)",children:"Generate with AI"}),r.jsx("button",{type:"button",onClick:()=>void J(),disabled:!H,style:{...nv,opacity:H?1:.5,cursor:H?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function Wd({title:t,subtitle:a,description:s,icon:o,selected:c,disabled:u,onClick:d}){return r.jsxs("button",{type:"button",onClick:d,disabled:u,"aria-pressed":c,style:{display:"flex",gap:12,padding:"12px 14px",textAlign:"left",borderRadius:8,border:c?"2px solid var(--color-accent, #2f6f8f)":"1px solid var(--border-default, rgba(0,0,0,0.12))",background:c?"color-mix(in oklch, var(--color-accent, #2f6f8f) 8%, var(--color-paper, #fff))":u?"var(--surface-1, rgba(0,0,0,0.02))":"var(--color-paper, #fff)",color:u?"var(--text-tertiary)":"var(--text-primary)",cursor:u?"not-allowed":"pointer",opacity:u?.6:1,fontFamily:"inherit",width:"100%",transition:"border-color 120ms ease, background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:22,lineHeight:1,marginTop:2},children:o}),r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsx("div",{style:{fontSize:14,fontWeight:600,lineHeight:1.3},children:t}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",marginTop:2,textTransform:"uppercase",letterSpacing:"0.04em"},children:a}),r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",marginTop:6,lineHeight:1.5},children:s})]})]})}function No({label:t,hint:a,children:s}){return r.jsxs("label",{style:{display:"flex",flexDirection:"column",gap:4},children:[r.jsxs("span",{style:{display:"flex",alignItems:"baseline",gap:8},children:[r.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:t}),a&&r.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)"},children:a})]}),s]})}function To(t){return{width:"100%",padding:"7px 10px",fontSize:13,fontFamily:"var(--font-mono)",border:`1px solid ${t?"var(--border-default, rgba(0,0,0,0.12))":"var(--color-error, #b91c1c)"}`,borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}}const nv={padding:"8px 16px",fontSize:13,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:6,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:"pointer",fontFamily:"inherit",boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",letterSpacing:"0.01em"},qd={padding:"7px 12px",fontSize:13,fontWeight:500,border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:6,background:"transparent",color:"var(--text-primary)",cursor:"pointer",fontFamily:"inherit"};function cT(t,a,s,o){const c=o||"<skill-name>",u=s||"<plugin-name>",d=t||"<project>";return a==="standalone"?[`${d}/skills/${c}/SKILL.md`]:a==="existing-plugin"?[`${d}/${u}/skills/${c}/SKILL.md`]:a==="new-plugin"?[`${d}/${u}/.claude-plugin/plugin.json`,`${d}/${u}/skills/${c}/SKILL.md`]:null}function Wy(t){return t.trim().toLowerCase()}function uT(t,a){const s=Wy(a);return s?t.filter(o=>o.name.toLowerCase().includes(s)||o.source.toLowerCase().includes(s)):t}function dT(t,a){const s=Wy(a);return s?t.filter(o=>[o.name,o.description??"",o.category??"",o.author??""].join(" ").toLowerCase().includes(s)):t}function fT({open:t,onClose:a,onInstall:s,onUninstall:o,installedNames:c}){const[u,d]=p.useState(null),[h,g]=p.useState([]),[m,y]=p.useState(null),[v,b]=p.useState(null),[S,k]=p.useState(!1),[E,C]=p.useState(null),[N,T]=p.useState(""),[A,B]=p.useState("");p.useEffect(()=>{m?T(""):B("")},[m]);const z=p.useMemo(()=>uT(h,N),[h,N]),F=p.useMemo(()=>dT((v==null?void 0:v.plugins)??[],A),[v,A]);return p.useEffect(()=>{t&&(k(!0),C(null),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);g(w.marketplaces??[])}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1)))},[t]),p.useEffect(()=>{if(!m){b(null);return}k(!0),C(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(m)}`).then(w=>w.json()).then(w=>{if(w.error)throw new Error(w.error);b(w)}).catch(w=>C(w instanceof Error?w.message:String(w))).finally(()=>k(!1))},[m]),p.useEffect(()=>{if(!t)return;function w(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[t,a]),t?r.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Plugin marketplace","data-vskill-marketplace-drawer":!0,style:{position:"fixed",inset:0,zIndex:80},children:[r.jsx("div",{onClick:a,style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.38)"}}),r.jsxs("aside",{style:{position:"absolute",top:0,right:0,bottom:0,width:"min(480px, 94vw)",background:"var(--color-paper, #fff)",borderLeft:"1px solid var(--border-default, rgba(0,0,0,0.12))",boxShadow:"-10px 0 30px -8px rgba(0,0,0,0.18)",display:"flex",flexDirection:"column",fontFamily:"var(--font-sans)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"14px 18px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.08))"},children:[m&&r.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":"Back to marketplaces",style:{border:"none",background:"transparent",fontSize:14,color:"var(--text-secondary)",cursor:"pointer",padding:0},children:"← Back"}),r.jsx("h2",{style:{margin:0,fontSize:15,fontWeight:600,color:"var(--text-primary)",fontFamily:"var(--font-serif, ui-serif)",flex:1},children:m?(v==null?void 0:v.name)??m:"Browse plugins"}),r.jsx("button",{type:"button",onClick:a,"aria-label":"Close",style:{border:"none",background:"transparent",fontSize:16,color:"var(--text-secondary)",cursor:"pointer",padding:"4px 6px"},children:"✕"})]}),r.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12},children:[S&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"Loading…"}),E&&r.jsx("div",{style:{padding:10,fontSize:12,color:"var(--color-error, #b91c1c)",background:"color-mix(in oklch, var(--color-error, #b91c1c) 8%, transparent)",borderRadius:4},children:E}),!m&&!S&&h.length===0&&!E&&r.jsx(pT,{}),!m&&h.length>0&&r.jsx(rv,{value:N,onChange:T,placeholder:"Search marketplaces…",ariaLabel:"Search marketplaces",testId:"marketplace-search"}),!m&&h.length>0&&z.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No marketplaces match “",N,"”."]}),!m&&z.map(w=>r.jsxs("button",{type:"button",onClick:()=>y(w.name),style:hT,onMouseEnter:O=>{O.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.04))"},onMouseLeave:O=>{O.currentTarget.style.background="transparent"},children:[r.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:w.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:w.source})]},w.name)),m&&v&&r.jsxs(r.Fragment,{children:[v.description&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",padding:"0 6px 12px",lineHeight:1.5},children:v.description}),v.plugins.length===0&&r.jsx("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:"This marketplace has no plugins catalogued yet."}),v.plugins.length>0&&r.jsx(rv,{value:A,onChange:B,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&F.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",A,"”."]}),F.map(w=>{const O=c.has(w.name);return r.jsx("div",{style:{padding:"10px 8px",borderBottom:"1px solid var(--border-subtle, rgba(0,0,0,0.05))"},children:r.jsxs("div",{style:{display:"flex",alignItems:"start",gap:8},children:[r.jsxs("div",{style:{flex:1,minWidth:0},children:[r.jsxs("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"baseline",gap:8},children:[w.name,w.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:w.version}),w.category&&r.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"var(--surface-2, rgba(0,0,0,0.05))",color:"var(--text-secondary)"},children:w.category})]}),w.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:w.description})]}),O&&o?r.jsx("button",{type:"button",disabled:u===w.name,onClick:async()=>{d(w.name);try{await o(w.name)}finally{d(null)}},"aria-label":`Uninstall ${w.name}`,style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:"1px solid var(--color-error, #b91c1c)",borderRadius:4,background:"transparent",color:"var(--color-error, #b91c1c)",cursor:u===w.name?"wait":"pointer",opacity:u===w.name?.6:1,fontFamily:"inherit"},children:u===w.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(w.name,m),style:{flexShrink:0,padding:"5px 12px",fontSize:12,fontWeight:600,border:O?"none":"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:O?"var(--surface-2, rgba(0,0,0,0.05))":"var(--color-action, #2F5B8E)",color:O?"var(--text-tertiary)":"var(--color-action-ink, #FFFFFF)",cursor:O?"default":"pointer",fontFamily:"inherit",boxShadow:O?"none":"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)"},children:O?"Installed":"Install"})]})},w.name)})]})]}),!m&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(mT,{onAdded:()=>{Tn("marketplaces"),fetch("/api/plugins/marketplaces").then(w=>w.json()).then(w=>g(w.marketplaces??[]))}})})]})]}):null}function rv({value:t,onChange:a,placeholder:s,ariaLabel:o,testId:c}){return r.jsx("div",{style:{padding:"0 4px 10px"},children:r.jsx("input",{type:"search",value:t,onChange:u=>a(u.target.value),placeholder:s,"aria-label":o,"data-testid":c,style:{width:"100%",padding:"6px 10px",fontSize:12,fontFamily:"var(--font-sans)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none",boxSizing:"border-box"}})})}function pT(){return r.jsxs("div",{style:{padding:20,fontSize:12,color:"var(--text-tertiary)",lineHeight:1.6},children:["No marketplaces configured yet. Add one below — examples:",r.jsxs("ul",{style:{marginTop:8,paddingLeft:16},children:[r.jsx("li",{children:r.jsx("code",{children:"anthropics/claude-plugins-official"})}),r.jsx("li",{children:r.jsx("code",{children:"openai/codex-plugin-cc"})})]})]})}function mT({onAdded:t}){const[a,s]=p.useState(""),[o,c]=p.useState(!1),[u,d]=p.useState(null);async function h(){const g=a.trim();if(g){c(!0),d(null);try{const m=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:g})}),y=await m.json().catch(()=>({}));if(!m.ok||!y.ok){d(y.error??`Add failed (${m.status})`);return}s(""),t()}catch(m){d(m instanceof Error?m.message:String(m))}finally{c(!1)}}}return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[r.jsx("label",{style:{fontSize:11,color:"var(--text-tertiary)",fontWeight:500},children:"Add marketplace (GitHub owner/repo, URL, or path)"}),r.jsxs("div",{style:{display:"flex",gap:6},children:[r.jsx("input",{type:"text",value:a,onChange:g=>s(g.target.value),onKeyDown:g=>{g.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:o,style:{flex:1,padding:"6px 8px",fontSize:12,fontFamily:"var(--font-mono)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderRadius:4,background:"var(--surface-0, #fff)",color:"var(--text-primary)",outline:"none"}}),r.jsx("button",{type:"button",onClick:()=>void h(),disabled:o||!a.trim(),style:{padding:"6px 14px",fontSize:12,fontWeight:600,border:"1px solid var(--color-action, #2F5B8E)",borderRadius:4,background:"var(--color-action, #2F5B8E)",color:"var(--color-action-ink, #FFFFFF)",cursor:o||!a.trim()?"not-allowed":"pointer",opacity:o||!a.trim()?.5:1,boxShadow:"0 1px 2px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.12)",fontFamily:"inherit"},children:o?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const hT={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},Yd=12;function xT({job:t,onDone:a}){const[s,o]=p.useState([]),[c,u]=p.useState("running"),[d,h]=p.useState(!1);if(p.useEffect(()=>{if(!t)return;o([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const k=await fetch("/api/plugins/install/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({plugin:t.ref}),signal:v.signal});if(!k.ok||!k.body){u("failed"),a({ok:!1,code:k.status,lines:[`HTTP ${k.status}`]});return}const E=k.body.getReader(),C=new TextDecoder;let N="";for(;;){const{value:T,done:A}=await E.read();if(A)break;N+=C.decode(T,{stream:!0});const B=N.split(/\n\n/);N=B.pop()??"";for(const z of B){const F=z.match(/^data:\s*(.*)$/m);if(F)try{const w=JSON.parse(F[1]);w.type==="stdout"&&w.line?(b=[...b,w.line].slice(-Yd),o(b)):w.type==="stderr"&&w.line?(b=[...b,`⚠ ${w.line}`].slice(-Yd),o(b)):w.type==="done"?(S=w.ok?"ok":"failed",u(S),Bv(),Tn("skills"),a({ok:w.ok??!1,code:w.code??null,lines:b})):w.type==="error"&&w.error&&(b=[...b,`✘ ${w.error}`].slice(-Yd),o(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(k){if(k.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,k instanceof Error?k.message:String(k)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const g=c==="ok"?"var(--color-installed, #2F6A4A)":c==="failed"?"var(--color-error, #b91c1c)":"var(--color-accent, #2f6f8f)",m=c==="ok"?"✔":c==="failed"?"✘":"…",y=c==="ok"?"Installed":c==="failed"?"Install failed":"Installing";return r.jsxs("div",{role:"status","aria-live":"polite","data-vskill-install-toast":!0,style:{position:"fixed",bottom:16,right:16,width:"min(420px, 92vw)",background:"var(--color-paper, #fff)",border:"1px solid var(--border-default, rgba(0,0,0,0.12))",borderLeft:`3px solid ${g}`,borderRadius:6,boxShadow:"0 10px 20px -6px rgba(0,0,0,0.18)",zIndex:90,fontFamily:"var(--font-sans)",overflow:"hidden"},children:[r.jsxs("button",{type:"button",onClick:()=>h(v=>!v),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"10px 12px",border:"none",background:"transparent",cursor:"pointer",textAlign:"left",fontFamily:"inherit"},children:[r.jsx("span",{"aria-hidden":!0,style:{fontSize:16,color:g,width:16,textAlign:"center"},children:c==="running"?r.jsx(gT,{}):m}),r.jsxs("span",{style:{flex:1,minWidth:0},children:[r.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:[y,": ",t.plugin,r.jsxs("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s[s.length-1]})]}),r.jsx("span",{"aria-hidden":!0,style:{fontSize:10,color:"var(--text-tertiary)"},children:d?"▾":"▸"})]}),d&&r.jsx("pre",{style:{margin:0,padding:"0 12px 12px",maxHeight:180,overflowY:"auto",fontFamily:"var(--font-mono)",fontSize:10,lineHeight:1.5,color:"var(--text-secondary)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:s.length===0?"Waiting for output…":s.join(`
102
+ `)})]})}function gT(){return r.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:10,height:10,borderRadius:"50%",border:"2px solid var(--color-accent, #2f6f8f)",borderTopColor:"transparent",animation:"vskill-spin 800ms linear infinite"},children:r.jsx("style",{children:"@keyframes vskill-spin { to { transform: rotate(360deg); } }"})})}const vT=3e3,yT={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function av(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function bT(){const{toast:t}=Wo(),a=p.useRef(new Map),s=p.useCallback(o=>{if(!av(o.provider))return;const c=Date.now(),u=a.current.get(o.provider)??0;if(c-u<vT)return;a.current.set(o.provider,c);const d=yT[o.provider];t({message:`${d} API key invalid or missing. Open Settings →`,severity:"error",action:{label:"Open Settings",onInvoke:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-settings",{detail:{provider:o.provider}}))}}})},[t]);return p.useEffect(()=>{function o(c){const u=c.detail;!u||!av(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",o),()=>window.removeEventListener("studio:api-key-error",o)},[s]),{report:s}}const qy="vskill.studio.prefs";function Yy(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Ky(){const t=Yy();if(!t)return{};try{const a=t.getItem(qy);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function jT(t,a){const s=Yy();if(s)try{const c={...Ky(),[t]:a};s.setItem(qy,JSON.stringify(c))}catch{}}function ST(t,a){const o=Ky()[t];return o===void 0?a:o}const lv={open:!1,x:0,y:0,skill:null};function kT(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function _a(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function wT(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function CT(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{_a(ne.toasts.permissionDenied,"error");return}_a(ne.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":_a(ne.actions.editPlaceholder,"info");return;case"run-benchmark":_a(ne.toasts.benchmarkQueued,"info");return;case"duplicate":_a(ne.toasts.skillDuplicated,"info");return;case"update":_a(ne.toasts.skillUpdated,"info");return;case"uninstall":_a(ne.actions.editPlaceholder,"info");return;case"delete":wT(a);return;default:return}}function ET(t){return t.startsWith("#/create")}function NT(t){return t.startsWith("#/updates")}function Xy(t){const[a,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function o(){s(t(window.location.hash))}return window.addEventListener("hashchange",o),o(),()=>window.removeEventListener("hashchange",o)},[]),a}function TT(){return Xy(ET)}function RT(){return Xy(NT)}function AT(){var o,c;if(typeof navigator>"u")return"⌘⇧K";const t=((o=navigator.platform)==null?void 0:o.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘⇧K":"Ctrl+Shift+K"}function MT(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function LT(){const[t,a]=p.useState("⌘⇧K");p.useEffect(()=>{a(AT())},[]);const s=MT();function o(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:o,"aria-label":`Find verified skills — opens search (${t})`,title:`Find verified skills (${t})`,"data-testid":"find-skills-nav-button",style:{display:"inline-flex",alignItems:"center",gap:6,height:28,padding:"0 12px",borderRadius:6,border:"1px solid var(--border-default)",background:"transparent",color:"var(--text-secondary)",fontSize:12,fontWeight:500,fontFamily:"var(--font-sans)",cursor:"pointer",letterSpacing:"0.01em"},children:[r.jsxs("svg",{"data-icon":"search","aria-hidden":"true",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("span",{children:"Find skills"}),r.jsx("kbd",{"data-animated":s?"false":"true",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-faint)",border:"1px solid var(--border-default)",borderRadius:4,padding:"1px 5px",marginLeft:2,lineHeight:1},children:t})]})}const zT=p.lazy(()=>Ha(()=>import("./CommandPalette-LtejhB76.js"),__vite__mapDeps([2,1]))),DT=p.lazy(()=>Ha(()=>import("./FindSkillsPalette-Dbl2_IC4.js"),__vite__mapDeps([3,1])).then(t=>({default:t.FindSkillsPalette}))),_T=p.lazy(()=>Ha(()=>import("./SkillDetailPanel-RQc5u4nm.js"),__vite__mapDeps([4,5,1])).then(t=>({default:t.SkillDetailPanel}))),OT=p.lazy(()=>Ha(()=>import("./CreateSkillPage-3RuqLQnm.js"),__vite__mapDeps([6,1])).then(t=>({default:t.CreateSkillPage}))),BT=p.lazy(()=>Ha(()=>Promise.resolve().then(()=>VE),void 0).then(t=>({default:t.UpdatesPanel})));function IT(){return r.jsx(bS,{children:r.jsx(gS,{children:r.jsxs(v2,{children:[r.jsx(UT,{}),r.jsx(jN,{})]})})})}function UT(){var qt,Ie;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:o,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=er(),{config:h}=$a(),{mode:g,resolvedTheme:m,setTheme:y}=Ov(),{toast:v}=Wo(),[b,S]=p.useState(()=>Fw()),[k]=p.useState(!0),[E,C]=p.useState(!1),[N,T]=p.useState(!1),[A,B]=p.useState(!1),[z,F]=p.useState("overview"),[w,O]=p.useState(lv),D=p.useCallback((le,Se)=>{O(kT(le,Se))},[]),U=ZN(),[H,q]=p.useState(()=>ST("activeAgent",null)),X=p.useCallback(le=>{q(le),jT("activeAgent",le),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:le}}))},[]);p.useEffect(()=>{var le;!H&&((le=U.response)!=null&&le.suggested)&&X(U.response.suggested)},[H,(qt=U.response)==null?void 0:qt.suggested,X]);const J=p.useMemo(()=>U.response?WN(U.response):[],[U.response]),{workspace:$,switchProject:L,addProject:_,removeProject:I,activeProject:V}=aT(),[ie,M]=p.useState(!1),[Y,G]=p.useState(!1),[te,fe]=p.useState("standalone"),oe=p.useCallback((le="standalone")=>{fe(le),G(!0)},[]);p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;oe((Me==null?void 0:Me.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",le),()=>window.removeEventListener("studio:request-create-skill",le)},[oe]);const[ve,de]=p.useState(!1),[je,Re]=p.useState(null);p.useEffect(()=>{function le(){de(!0)}return window.addEventListener("studio:open-marketplace",le),()=>window.removeEventListener("studio:open-marketplace",le)},[]);const _e=p.useMemo(()=>{const le=new Set;for(const Se of t.skills)Se.source==="plugin"&&Se.pluginName&&le.add(Se.pluginName);return le},[t.skills]);sf([{key:"p",meta:!0,handler:le=>{var Me;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Me=le==null?void 0:le.preventDefault)==null||Me.call(le),M(Fa=>!Fa))}}],{enabled:!0});const ae=BN(),he=ae.open;p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Me!=null&&Me.provider&&he(Me.provider)}return window.addEventListener("studio:open-setup-drawer",le),()=>window.removeEventListener("studio:open-setup-drawer",le)},[he]);const pe=p.useCallback(()=>{O(lv)},[]);p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Me!=null&&Me.message&&v({message:Me.message,severity:Me.severity??"info"})}return window.addEventListener("studio:toast",le),()=>window.removeEventListener("studio:toast",le)},[v]),bT();const[xe,be]=p.useState(!1),[Be,Oe]=p.useState(void 0);p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Oe(Me==null?void 0:Me.provider),be(!0)}return window.addEventListener("studio:open-settings",le),()=>window.removeEventListener("studio:open-settings",le)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${b}px`)},[b]);const[lt,Nt]=p.useState(null),[xt,_t]=p.useState(()=>new Set),Tt=p.useRef(!1),Ze=p.useMemo(()=>NN(),[]),nt=p.useCallback(le=>`${le.plugin}/${le.skill}`,[]),ye=p.useCallback(le=>{_t(Se=>{const Me=new Set(Se);return Me.add(nt(le)),Me})},[nt]),mt=p.useCallback(le=>{_t(Se=>{const Me=new Set(Se);return Me.delete(nt(le)),Me})},[nt]),Et=TN({delayMs:1e4,onCommit:le=>{o(),mt(le)},onFailure:(le,Se)=>{mt(le),v({message:`Couldn't delete ${le.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:ne.actions.retry,onInvoke:()=>{ye(le),Et.enqueueDelete(le)}}})}});p.useEffect(()=>{function le(Se){if(!(Se instanceof CustomEvent))return;const Me=Se.detail;Me!=null&&Me.skill&&Nt(Me.skill)}return window.addEventListener("studio:request-delete",le),()=>window.removeEventListener("studio:request-delete",le)},[]);const Xt=p.useCallback(()=>{const le=lt;if(Nt(null),!le)return;const Se={plugin:le.plugin,skill:le.skill};ye(Se),Et.enqueueDelete(Se);const Me=Tt.current?"":`Sent to your ${Ze}. Open Trash to restore. `;Tt.current=!0,v({message:`${Me}Deleted ${le.skill}`,severity:"info",durationMs:1e4,action:{label:ne.actions.undo,onInvoke:()=>{Et.cancelDelete(nt(Se)),mt(Se)}}})},[lt,ye,mt,Et,v,Ze,nt]),fn=p.useCallback(()=>{Nt(null)},[]),Wt=p.useMemo(()=>t.skills.filter(le=>!xt.has(nt(le))),[t.skills,xt,nt]),ln=p.useMemo(()=>t.selectedSkill?t.skills.find(le=>le.plugin===t.selectedSkill.plugin&&le.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),Mn=p.useCallback(le=>{a({plugin:le.plugin,skill:le.skill,origin:le.origin})},[a]),Lt=p.useMemo(()=>{if(!t.selectedSkill)return"";const le=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${le})`},[t.selectedSkill]),vt=p.useMemo(()=>[{id:"switch-theme",label:ne.palette.actionSwitchTheme,description:"Cycle light / dark / auto",keywords:["theme","dark","light","mode"],onInvoke:()=>y(g==="light"?"dark":g==="dark"?"auto":"light")},{id:"toggle-sidebar",label:"Toggle sidebar",description:"Show or hide the skills sidebar",keywords:["sidebar","panel","hide","show","cmd+b"],onInvoke:()=>B(le=>!le)},{id:"show-shortcuts",label:"Show keyboard shortcuts",description:"Open the cheatsheet",keywords:["help","keys"],onInvoke:()=>T(!0)},{id:"refresh-skills",label:"Refresh skills",description:"Re-scan local + installed",keywords:["reload","scan"],onInvoke:()=>o()}],[g,y,o]),[gt,Wn]=p.useState(null);sf([{key:"cmd+k",handler:()=>C(le=>!le)},{key:"ctrl+k",handler:()=>C(le=>!le)},{key:"cmd+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+shift+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>T(le=>!le)},{key:"cmd+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>y(m==="light"?"dark":"light")},{key:"cmd+b",handler:()=>B(le=>!le)},{key:"ctrl+b",handler:()=>B(le=>!le)},{key:"e",handler:()=>v({message:ne.actions.editPlaceholder,severity:"info"})}]);const zr=TT(),Rt=RT()?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(BT,{})}):zr?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(OT,{})}):r.jsx(pN,{selectedSkillInfo:ln,activeDetailTab:z,onDetailTabChange:F,allSkills:t.skills,onSelectSkill:Mn});return r.jsxs(r.Fragment,{children:[r.jsx(jS,{sidebarWidth:b,sidebarHidden:A||t.isMobile&&t.mobileView==="detail",banner:r.jsx(qw,{connected:k}),liveMessage:Lt,topRail:r.jsx(S2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onOpenPalette:()=>C(!0),onHome:s,onRequestCreateSkill:()=>oe("standalone"),projectPickerSlot:$&&$.projects.length>0?r.jsx(lT,{workspace:$,onSwitch:L,onAdd:_,onRemove:I}):void 0,findSkillsSlot:r.jsx(LT,{})}),sidebar:r.jsx(Ow,{skills:Wt,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:Mn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:o,onContextMenu:D,outdatedByOrigin:c,activeAgentId:H,revealSkillId:t.revealSkillId,onRevealComplete:d,topSlot:U.status==="ready"&&J.length>0?r.jsxs(r.Fragment,{children:[r.jsx(qN,{agents:J,activeAgentId:H,onActiveAgentChange:X,onOpenSetup:le=>ae.open(le)}),r.jsx(QN,{activeAgentId:H})]}):null}),resizeHandle:r.jsx(Ww,{initialWidth:b??Vs,onChange:S}),main:Rt,statusBar:r.jsx(z2,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(Ie=h==null?void 0:h.providers)==null?void 0:Ie.map(le=>{const Se=le.id;return{id:Se,label:le.label,available:le.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(kN,{open:N,onClose:()=>T(!1)}),r.jsx(MN,{open:ae.isOpen,providerKey:ae.providerKey,onClose:ae.close}),r.jsx(CN,{state:w,onClose:pe,onAction:(le,Se)=>CT(le,Se)}),E&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(zT,{open:E,onClose:()=>C(!1),commands:vt})}),r.jsx(p.Suspense,{fallback:null,children:r.jsx(DT,{onSelect:le=>{const Se=le.name.split("/");Se.length===3&&Wn({owner:Se[0],repo:Se[1],slug:Se[2],displayName:le.displayName??le.name})}})}),gt&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(_T,{selectedSkill:gt,onClose:()=>Wn(null)})}),r.jsx(iT,{open:ie,projects:($==null?void 0:$.projects)??[],onSwitch:le=>{L(le)},onClose:()=>M(!1)}),r.jsx(oT,{open:Y,onClose:()=>G(!1),initialMode:te,isClaudeCode:H==="claude-code",projectRoot:(V==null?void 0:V.path)??(h==null?void 0:h.projectName)??"",onCreated:le=>{o(),setTimeout(()=>{u(le.pluginName??"",le.skillName)},500)}}),r.jsx(fT,{open:ve,onClose:()=>de(!1),installedNames:_e,onInstall:(le,Se)=>{Re({plugin:le,marketplace:Se,ref:`${le}@${Se}`}),de(!1)},onUninstall:async le=>{if(window.confirm(`Uninstall ${le}? This removes the plugin and its skills.`))try{const Se=await fetch(`/api/plugins/${encodeURIComponent(le)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),Me=await Se.json().catch(()=>({}));if(!Se.ok||!Me.ok){v({message:Me.error??`Uninstall failed (${Se.status})`,severity:"error"});return}v({message:`Uninstalled ${le}.`,severity:"info"}),o()}catch(Se){v({message:Se instanceof Error?Se.message:String(Se),severity:"error"})}}}),r.jsx(Lv,{open:xe,onClose:()=>be(!1),initialProvider:Be,onToast:le=>v({message:le,severity:"info"})}),r.jsx(xT,{job:je,onDone:le=>{le.ok&&(o(),setTimeout(()=>Re(null),3e3))}}),r.jsx(EN,{open:lt!==null,title:lt?`Delete "${lt.skill}"?`:"",body:`It will be sent to your ${Ze}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:Xt,onCancel:fn})]})}const sv="vskill.migrations.scope-rename.v1",HT={own:"authoring-project",installed:"available-project",global:"available-personal"},$T=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function VT(t){if(t.getItem(sv)==="done")return;const a=[];for(let s=0;s<t.length;s++){const o=t.key(s);if(!o)continue;const c=o.match($T);if(!c)continue;const[,u,d]=c,h=HT[d];if(!h)continue;const g=t.getItem(o);g!==null&&a.push({oldKey:o,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:g})}for(const{oldKey:s,newKey:o,value:c}of a)t.getItem(o)===null&&t.setItem(o,c),t.removeItem(s);t.setItem(sv,"done")}if(typeof PerformanceObserver<"u")try{const t=new PerformanceObserver(a=>{for(const s of a.getEntries())if(s.name==="first-contentful-paint"){window.__vskillPaint=s.startTime,t.disconnect();return}});t.observe({type:"paint",buffered:!0})}catch{}if(typeof window<"u"&&window.localStorage)try{VT(window.localStorage)}catch{}h0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(Oj,{children:r.jsx(T2,{children:r.jsx(IT,{})})})}));export{ec as E,Cv as L,ai as P,Ne as R,BE as S,Ha as _,$a as a,Ky as b,DE as c,Zo as d,Wo as e,Ce as f,ST as g,r as j,p as r,ne as s,pf as t,Q0 as u,jT as w};