vskill 0.5.159 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents.json +1 -1
- package/dist/agents/agents-registry.d.ts +4 -14
- package/dist/agents/agents-registry.js.map +1 -1
- package/dist/eval-server/api-routes.js +14 -47
- package/dist/eval-server/api-routes.js.map +1 -1
- package/dist/eval-ui/assets/{CreateSkillPage-DOJWF3-Z.js → CreateSkillPage-8zJnqwjr.js} +5 -5
- package/dist/eval-ui/assets/{FindSkillsPalette-CEckFgA2.js → FindSkillsPalette-C_GiEl_q.js} +2 -2
- package/dist/eval-ui/assets/{SearchPaletteCore-CybKVEgq.js → SearchPaletteCore-D1atnd7R.js} +2 -2
- package/dist/eval-ui/assets/{SkillDetailPanel-CYmWPegc.js → SkillDetailPanel-Cg8-E-fm.js} +1 -1
- package/dist/eval-ui/assets/{UpdateDropdown-B53G4Agp.js → UpdateDropdown-DvdC8JlL.js} +1 -1
- package/dist/eval-ui/assets/index-Dr23ls2i.js +122 -0
- package/dist/eval-ui/index.html +1 -1
- package/dist/utils/skill-builder-detection.d.ts +1 -7
- package/dist/utils/skill-builder-detection.js +8 -11
- package/dist/utils/skill-builder-detection.js.map +1 -1
- package/dist/utils/skill-creator-detection.js +41 -9
- package/dist/utils/skill-creator-detection.js.map +1 -1
- package/package.json +1 -1
- package/dist/eval-ui/assets/index-DAH5iFYQ.js +0 -122
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/UpdateDropdown-B53G4Agp.js","assets/fonts-i7Lkz2zN.css","assets/FindSkillsPalette-CEckFgA2.js","assets/SkillDetailPanel-CYmWPegc.js","assets/skill-url-C4ekwoGs.js","assets/CreateSkillPage-DOJWF3-Z.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"]'))i(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"&&i(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 i(c){if(c.ep)return;c.ep=!0;const u=s(c);fetch(c.href,u)}})();function Nv(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var yd={exports:{}},_s={};/**
|
|
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 Bx;function O0(){if(Bx)return _s;Bx=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.fragment");function s(i,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:i,key:d,ref:c!==void 0?c:null,props:u}}return _s.Fragment=a,_s.jsx=s,_s.jsxs=s,_s}var Ix;function B0(){return Ix||(Ix=1,yd.exports=O0()),yd.exports}var r=B0(),bd={exports:{}},Ie={};/**
|
|
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 $x;function I0(){if($x)return Ie;$x=1;var t=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=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"),x=Symbol.for("react.suspense"),m=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),b=Symbol.iterator;function S(D){return D===null||typeof D!="object"?null:(D=b&&D[b]||D["@@iterator"],typeof D=="function"?D:null)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,w={};function N(D,W,te){this.props=D,this.context=W,this.refs=w,this.updater=te||E}N.prototype.isReactComponent={},N.prototype.setState=function(D,W){if(typeof D!="object"&&typeof D!="function"&&D!=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,D,W,"setState")},N.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function T(){}T.prototype=N.prototype;function R(D,W,te){this.props=D,this.context=W,this.refs=w,this.updater=te||E}var _=R.prototype=new T;_.constructor=R,C(_,N.prototype),_.isPureReactComponent=!0;var z=Array.isArray;function P(){}var k={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function L(D,W,te){var q=te.ref;return{$$typeof:t,type:D,key:W,ref:q!==void 0?q:null,props:te}}function B(D,W){return L(D.type,W,D.props)}function U(D){return typeof D=="object"&&D!==null&&D.$$typeof===t}function Y(D){var W={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(te){return W[te]})}var X=/\/+/g;function J(D,W){return typeof D=="object"&&D!==null&&D.key!=null?Y(""+D.key):W.toString(36)}function $(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(P,P):(D.status="pending",D.then(function(W){D.status==="pending"&&(D.status="fulfilled",D.value=W)},function(W){D.status==="pending"&&(D.status="rejected",D.reason=W)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function M(D,W,te,q,ce){var Q=typeof D;(Q==="undefined"||Q==="boolean")&&(D=null);var ye=!1;if(D===null)ye=!0;else switch(Q){case"bigint":case"string":case"number":ye=!0;break;case"object":switch(D.$$typeof){case t:case a:ye=!0;break;case y:return ye=D._init,M(ye(D._payload),W,te,q,ce)}}if(ye)return ce=ce(D),ye=q===""?"."+J(D,0):q,z(ce)?(te="",ye!=null&&(te=ye.replace(X,"$&/")+"/"),M(ce,W,te,"",function(Ne){return Ne})):ce!=null&&(U(ce)&&(ce=B(ce,te+(ce.key==null||D&&D.key===ce.key?"":(""+ce.key).replace(X,"$&/")+"/")+ye)),W.push(ce)),1;ye=0;var oe=q===""?".":q+":";if(z(D))for(var be=0;be<D.length;be++)q=D[be],Q=oe+J(q,be),ye+=M(q,W,te,Q,ce);else if(be=S(D),typeof be=="function")for(D=be.call(D),be=0;!(q=D.next()).done;)q=q.value,Q=oe+J(q,be++),ye+=M(q,W,te,Q,ce);else if(Q==="object"){if(typeof D.then=="function")return M($(D),W,te,q,ce);throw W=String(D),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return ye}function I(D,W,te){if(D==null)return D;var q=[],ce=0;return M(D,q,"","",function(Q){return W.call(te,Q,ce++)}),q}function F(D){if(D._status===-1){var W=D._result;W=W(),W.then(function(te){(D._status===0||D._status===-1)&&(D._status=1,D._result=te)},function(te){(D._status===0||D._status===-1)&&(D._status=2,D._result=te)}),D._status===-1&&(D._status=0,D._result=W)}if(D._status===1)return D._result.default;throw D._result}var H=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},re={map:I,forEach:function(D,W,te){I(D,function(){W.apply(this,arguments)},te)},count:function(D){var W=0;return I(D,function(){W++}),W},toArray:function(D){return I(D,function(W){return W})||[]},only:function(D){if(!U(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return Ie.Activity=v,Ie.Children=re,Ie.Component=N,Ie.Fragment=s,Ie.Profiler=c,Ie.PureComponent=R,Ie.StrictMode=i,Ie.Suspense=x,Ie.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=k,Ie.__COMPILER_RUNTIME={__proto__:null,c:function(D){return k.H.useMemoCache(D)}},Ie.cache=function(D){return function(){return D.apply(null,arguments)}},Ie.cacheSignal=function(){return null},Ie.cloneElement=function(D,W,te){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var q=C({},D.props),ce=D.key;if(W!=null)for(Q in W.key!==void 0&&(ce=""+W.key),W)!O.call(W,Q)||Q==="key"||Q==="__self"||Q==="__source"||Q==="ref"&&W.ref===void 0||(q[Q]=W[Q]);var Q=arguments.length-2;if(Q===1)q.children=te;else if(1<Q){for(var ye=Array(Q),oe=0;oe<Q;oe++)ye[oe]=arguments[oe+2];q.children=ye}return L(D.type,ce,q)},Ie.createContext=function(D){return D={$$typeof:d,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:u,_context:D},D},Ie.createElement=function(D,W,te){var q,ce={},Q=null;if(W!=null)for(q in W.key!==void 0&&(Q=""+W.key),W)O.call(W,q)&&q!=="key"&&q!=="__self"&&q!=="__source"&&(ce[q]=W[q]);var ye=arguments.length-2;if(ye===1)ce.children=te;else if(1<ye){for(var oe=Array(ye),be=0;be<ye;be++)oe[be]=arguments[be+2];ce.children=oe}if(D&&D.defaultProps)for(q in ye=D.defaultProps,ye)ce[q]===void 0&&(ce[q]=ye[q]);return L(D,Q,ce)},Ie.createRef=function(){return{current:null}},Ie.forwardRef=function(D){return{$$typeof:h,render:D}},Ie.isValidElement=U,Ie.lazy=function(D){return{$$typeof:y,_payload:{_status:-1,_result:D},_init:F}},Ie.memo=function(D,W){return{$$typeof:m,type:D,compare:W===void 0?null:W}},Ie.startTransition=function(D){var W=k.T,te={};k.T=te;try{var q=D(),ce=k.S;ce!==null&&ce(te,q),typeof q=="object"&&q!==null&&typeof q.then=="function"&&q.then(P,H)}catch(Q){H(Q)}finally{W!==null&&te.types!==null&&(W.types=te.types),k.T=W}},Ie.unstable_useCacheRefresh=function(){return k.H.useCacheRefresh()},Ie.use=function(D){return k.H.use(D)},Ie.useActionState=function(D,W,te){return k.H.useActionState(D,W,te)},Ie.useCallback=function(D,W){return k.H.useCallback(D,W)},Ie.useContext=function(D){return k.H.useContext(D)},Ie.useDebugValue=function(){},Ie.useDeferredValue=function(D,W){return k.H.useDeferredValue(D,W)},Ie.useEffect=function(D,W){return k.H.useEffect(D,W)},Ie.useEffectEvent=function(D){return k.H.useEffectEvent(D)},Ie.useId=function(){return k.H.useId()},Ie.useImperativeHandle=function(D,W,te){return k.H.useImperativeHandle(D,W,te)},Ie.useInsertionEffect=function(D,W){return k.H.useInsertionEffect(D,W)},Ie.useLayoutEffect=function(D,W){return k.H.useLayoutEffect(D,W)},Ie.useMemo=function(D,W){return k.H.useMemo(D,W)},Ie.useOptimistic=function(D,W){return k.H.useOptimistic(D,W)},Ie.useReducer=function(D,W,te){return k.H.useReducer(D,W,te)},Ie.useRef=function(D){return k.H.useRef(D)},Ie.useState=function(D){return k.H.useState(D)},Ie.useSyncExternalStore=function(D,W,te){return k.H.useSyncExternalStore(D,W,te)},Ie.useTransition=function(){return k.H.useTransition()},Ie.version="19.2.4",Ie}var Ux;function Cf(){return Ux||(Ux=1,bd.exports=I0()),bd.exports}var p=Cf();const Te=Nv(p);var jd={exports:{}},Os={},Sd={exports:{}},kd={};/**
|
|
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 Hx;function $0(){return Hx||(Hx=1,(function(t){function a(M,I){var F=M.length;M.push(I);e:for(;0<F;){var H=F-1>>>1,re=M[H];if(0<c(re,I))M[H]=I,M[F]=re,F=H;else break e}}function s(M){return M.length===0?null:M[0]}function i(M){if(M.length===0)return null;var I=M[0],F=M.pop();if(F!==I){M[0]=F;e:for(var H=0,re=M.length,D=re>>>1;H<D;){var W=2*(H+1)-1,te=M[W],q=W+1,ce=M[q];if(0>c(te,F))q<re&&0>c(ce,te)?(M[H]=ce,M[q]=F,H=q):(M[H]=te,M[W]=F,H=W);else if(q<re&&0>c(ce,F))M[H]=ce,M[q]=F,H=q;else break e}}return I}function c(M,I){var F=M.sortIndex-I.sortIndex;return F!==0?F:M.id-I.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 x=[],m=[],y=1,v=null,b=3,S=!1,E=!1,C=!1,w=!1,N=typeof setTimeout=="function"?setTimeout:null,T=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function _(M){for(var I=s(m);I!==null;){if(I.callback===null)i(m);else if(I.startTime<=M)i(m),I.sortIndex=I.expirationTime,a(x,I);else break;I=s(m)}}function z(M){if(C=!1,_(M),!E)if(s(x)!==null)E=!0,P||(P=!0,Y());else{var I=s(m);I!==null&&$(z,I.startTime-M)}}var P=!1,k=-1,O=5,L=-1;function B(){return w?!0:!(t.unstable_now()-L<O)}function U(){if(w=!1,P){var M=t.unstable_now();L=M;var I=!0;try{e:{E=!1,C&&(C=!1,T(k),k=-1),S=!0;var F=b;try{t:{for(_(M),v=s(x);v!==null&&!(v.expirationTime>M&&B());){var H=v.callback;if(typeof H=="function"){v.callback=null,b=v.priorityLevel;var re=H(v.expirationTime<=M);if(M=t.unstable_now(),typeof re=="function"){v.callback=re,_(M),I=!0;break t}v===s(x)&&i(x),_(M)}else i(x);v=s(x)}if(v!==null)I=!0;else{var D=s(m);D!==null&&$(z,D.startTime-M),I=!1}}break e}finally{v=null,b=F,S=!1}I=void 0}}finally{I?Y():P=!1}}}var Y;if(typeof R=="function")Y=function(){R(U)};else if(typeof MessageChannel<"u"){var X=new MessageChannel,J=X.port2;X.port1.onmessage=U,Y=function(){J.postMessage(null)}}else Y=function(){N(U,0)};function $(M,I){k=N(function(){M(t.unstable_now())},I)}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(M){M.callback=null},t.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<M?Math.floor(1e3/M):5},t.unstable_getCurrentPriorityLevel=function(){return b},t.unstable_next=function(M){switch(b){case 1:case 2:case 3:var I=3;break;default:I=b}var F=b;b=I;try{return M()}finally{b=F}},t.unstable_requestPaint=function(){w=!0},t.unstable_runWithPriority=function(M,I){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var F=b;b=M;try{return I()}finally{b=F}},t.unstable_scheduleCallback=function(M,I,F){var H=t.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?H+F:H):F=H,M){case 1:var re=-1;break;case 2:re=250;break;case 5:re=1073741823;break;case 4:re=1e4;break;default:re=5e3}return re=F+re,M={id:y++,callback:I,priorityLevel:M,startTime:F,expirationTime:re,sortIndex:-1},F>H?(M.sortIndex=F,a(m,M),s(x)===null&&M===s(m)&&(C?(T(k),k=-1):C=!0,$(z,F-H))):(M.sortIndex=re,a(x,M),E||S||(E=!0,P||(P=!0,Y()))),M},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(M){var I=b;return function(){var F=b;b=I;try{return M.apply(this,arguments)}finally{b=F}}}})(kd)),kd}var Px;function U0(){return Px||(Px=1,Sd.exports=$0()),Sd.exports}var wd={exports:{}},cn={};/**
|
|
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 Vx;function H0(){if(Vx)return cn;Vx=1;var t=Cf();function a(x){var m="https://react.dev/errors/"+x;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 #"+x+"; visit "+m+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function s(){}var i={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(x,m,y){var v=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:c,key:v==null?null:""+v,children:x,containerInfo:m,implementation:y}}var d=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function h(x,m){if(x==="font")return"";if(typeof m=="string")return m==="use-credentials"?m:""}return cn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,cn.createPortal=function(x,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(x,m,null,y)},cn.flushSync=function(x){var m=d.T,y=i.p;try{if(d.T=null,i.p=2,x)return x()}finally{d.T=m,i.p=y,i.d.f()}},cn.preconnect=function(x,m){typeof x=="string"&&(m?(m=m.crossOrigin,m=typeof m=="string"?m==="use-credentials"?m:"":void 0):m=null,i.d.C(x,m))},cn.prefetchDNS=function(x){typeof x=="string"&&i.d.D(x)},cn.preinit=function(x,m){if(typeof x=="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"?i.d.S(x,typeof m.precedence=="string"?m.precedence:void 0,{crossOrigin:v,integrity:b,fetchPriority:S}):y==="script"&&i.d.X(x,{crossOrigin:v,integrity:b,fetchPriority:S,nonce:typeof m.nonce=="string"?m.nonce:void 0})}},cn.preinitModule=function(x,m){if(typeof x=="string")if(typeof m=="object"&&m!==null){if(m.as==null||m.as==="script"){var y=h(m.as,m.crossOrigin);i.d.M(x,{crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0,nonce:typeof m.nonce=="string"?m.nonce:void 0})}}else m==null&&i.d.M(x)},cn.preload=function(x,m){if(typeof x=="string"&&typeof m=="object"&&m!==null&&typeof m.as=="string"){var y=m.as,v=h(y,m.crossOrigin);i.d.L(x,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})}},cn.preloadModule=function(x,m){if(typeof x=="string")if(m){var y=h(m.as,m.crossOrigin);i.d.m(x,{as:typeof m.as=="string"&&m.as!=="script"?m.as:void 0,crossOrigin:y,integrity:typeof m.integrity=="string"?m.integrity:void 0})}else i.d.m(x)},cn.requestFormReset=function(x){i.d.r(x)},cn.unstable_batchedUpdates=function(x,m){return x(m)},cn.useFormState=function(x,m,y){return d.H.useFormState(x,m,y)},cn.useFormStatus=function(){return d.H.useHostTransitionStatus()},cn.version="19.2.4",cn}var Fx;function Tv(){if(Fx)return wd.exports;Fx=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(),wd.exports=H0(),wd.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 Gx;function P0(){if(Gx)return Os;Gx=1;var t=U0(),a=Cf(),s=Tv();function i(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 x(e){if(u(e)!==e)throw Error(i(188))}function m(e){var n=e.alternate;if(!n){if(n=u(e),n===null)throw Error(i(188));return n!==e?null:e}for(var l=e,o=n;;){var f=l.return;if(f===null)break;var g=f.alternate;if(g===null){if(o=f.return,o!==null){l=o;continue}break}if(f.child===g.child){for(g=f.child;g;){if(g===l)return x(f),e;if(g===o)return x(f),n;g=g.sibling}throw Error(i(188))}if(l.return!==o.return)l=f,o=g;else{for(var j=!1,A=f.child;A;){if(A===l){j=!0,l=f,o=g;break}if(A===o){j=!0,o=f,l=g;break}A=A.sibling}if(!j){for(A=g.child;A;){if(A===l){j=!0,l=g,o=f;break}if(A===o){j=!0,o=g,l=f;break}A=A.sibling}if(!j)throw Error(i(189))}}if(l.alternate!==o)throw Error(i(190))}if(l.tag!==3)throw Error(i(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"),E=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),R=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),P=Symbol.for("react.suspense_list"),k=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),L=Symbol.for("react.activity"),B=Symbol.for("react.memo_cache_sentinel"),U=Symbol.iterator;function Y(e){return e===null||typeof e!="object"?null:(e=U&&e[U]||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 C:return"Fragment";case N:return"Profiler";case w:return"StrictMode";case z:return"Suspense";case P:return"SuspenseList";case L:return"Activity"}if(typeof e=="object")switch(e.$$typeof){case E:return"Portal";case R:return e.displayName||"Context";case T:return(e._context.displayName||"Context")+".Consumer";case _:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case k: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,M=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=s.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F={pending:!1,data:null,method:null,action:null},H=[],re=-1;function D(e){return{current:e}}function W(e){0>re||(e.current=H[re],H[re]=null,re--)}function te(e,n){re++,H[re]=e.current,e.current=n}var q=D(null),ce=D(null),Q=D(null),ye=D(null);function oe(e,n){switch(te(Q,n),te(ce,e),te(q,null),n.nodeType){case 9:case 11:e=(e=n.documentElement)&&(e=e.namespaceURI)?sx(e):0;break;default:if(e=n.tagName,n=n.namespaceURI)n=sx(n),e=ix(n,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}W(q),te(q,e)}function be(){W(q),W(ce),W(Q)}function Ne(e){e.memoizedState!==null&&te(ye,e);var n=q.current,l=ix(n,e.type);n!==l&&(te(ce,e),te(q,l))}function Be(e){ce.current===e&&(W(q),W(ce)),ye.current===e&&(W(ye),Ms._currentValue=F)}var Le,Pe;function se(e){if(Le===void 0)try{throw Error()}catch(l){var n=l.stack.trim().match(/\n( *(at )?)/);Le=n&&n[1]||"",Pe=-1<l.stack.indexOf(`
|
|
43
|
-
at`)?" (<anonymous>)":-1<l.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
-
`+Le+e+Pe}var de=!1;function me(e,n){if(!e||de)return"";de=!0;var l=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var o={DetermineComponentFrameRoot:function(){try{if(n){var pe=function(){throw Error()};if(Object.defineProperty(pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(pe,[])}catch(le){var ne=le}Reflect.construct(e,[],pe)}else{try{pe.call()}catch(le){ne=le}e.call(pe.prototype)}}else{try{throw Error()}catch(le){ne=le}(pe=e())&&typeof pe.catch=="function"&&pe.catch(function(){})}}catch(le){if(le&&ne&&typeof le.stack=="string")return[le.stack,ne.stack]}return[null,null]}};o.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var f=Object.getOwnPropertyDescriptor(o.DetermineComponentFrameRoot,"name");f&&f.configurable&&Object.defineProperty(o.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var g=o.DetermineComponentFrameRoot(),j=g[0],A=g[1];if(j&&A){var V=j.split(`
|
|
45
|
-
`),ee=A.split(`
|
|
46
|
-
`);for(f=o=0;o<V.length&&!V[o].includes("DetermineComponentFrameRoot");)o++;for(;f<ee.length&&!ee[f].includes("DetermineComponentFrameRoot");)f++;if(o===V.length||f===ee.length)for(o=V.length-1,f=ee.length-1;1<=o&&0<=f&&V[o]!==ee[f];)f--;for(;1<=o&&0<=f;o--,f--)if(V[o]!==ee[f]){if(o!==1||f!==1)do if(o--,f--,0>f||V[o]!==ee[f]){var ue=`
|
|
47
|
-
`+V[o].replace(" at new "," at ");return e.displayName&&ue.includes("<anonymous>")&&(ue=ue.replace("<anonymous>",e.displayName)),ue}while(1<=o&&0<=f);break}}}finally{de=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?se(l):""}function ve(e,n){switch(e.tag){case 26:case 27:case 5:return se(e.type);case 16:return se("Lazy");case 13:return e.child!==n&&n!==null?se("Suspense Fallback"):se("Suspense");case 19:return se("SuspenseList");case 0:case 15:return me(e.type,!1);case 11:return me(e.type.render,!1);case 1:return me(e.type,!0);case 31:return se("Activity");default:return""}}function je(e){try{var n="",l=null;do n+=ve(e,l),l=e,e=e.return;while(e);return n}catch(o){return`
|
|
48
|
-
Error generating stack: `+o.message+`
|
|
49
|
-
`+o.stack}}var Ve=Object.prototype.hasOwnProperty,ct=t.unstable_scheduleCallback,Nt=t.unstable_cancelCallback,tn=t.unstable_shouldYield,bt=t.unstable_requestPaint,Ge=t.unstable_now,pt=t.unstable_getCurrentPriorityLevel,mt=t.unstable_ImmediatePriority,jt=t.unstable_UserBlockingPriority,Kt=t.unstable_NormalPriority,xe=t.unstable_LowPriority,tt=t.unstable_IdlePriority,it=t.log,Tt=t.unstable_setDisableYieldValue,Lt=null,ut=null;function Bt(e){if(typeof it=="function"&&Tt(e),ut&&typeof ut.setStrictMode=="function")try{ut.setStrictMode(Lt,e)}catch{}}var It=Math.clz32?Math.clz32:gn,yr=Math.log,Xt=Math.LN2;function gn(e){return e>>>=0,e===0?32:31-(yr(e)/Xt|0)|0}var Cn=256,Hn=262144,vn=4194304;function St(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 nn(e,n,l){var o=e.pendingLanes;if(o===0)return 0;var f=0,g=e.suspendedLanes,j=e.pingedLanes;e=e.warmLanes;var A=o&134217727;return A!==0?(o=A&~g,o!==0?f=St(o):(j&=A,j!==0?f=St(j):l||(l=A&~e,l!==0&&(f=St(l))))):(A=o&~g,A!==0?f=St(A):j!==0?f=St(j):l||(l=o&~e,l!==0&&(f=St(l)))),f===0?0:n!==0&&n!==f&&(n&g)===0&&(g=f&-f,l=n&-n,g>=l||g===32&&(l&4194048)!==0)?n:f}function Ue(e,n){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&n)===0}function lt(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 Qt(){var e=vn;return vn<<=1,(vn&62914560)===0&&(vn=4194304),e}function rn(e){for(var n=[],l=0;31>l;l++)n.push(e);return n}function ie(e,n){e.pendingLanes|=n,n!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Se(e,n,l,o,f,g){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 A=e.entanglements,V=e.expirationTimes,ee=e.hiddenUpdates;for(l=j&~l;0<l;){var ue=31-It(l),pe=1<<ue;A[ue]=0,V[ue]=-1;var ne=ee[ue];if(ne!==null)for(ee[ue]=null,ue=0;ue<ne.length;ue++){var le=ne[ue];le!==null&&(le.lane&=-536870913)}l&=~pe}o!==0&&Ae(e,o,0),g!==0&&f===0&&e.tag!==0&&(e.suspendedLanes|=g&~(j&~n))}function Ae(e,n,l){e.pendingLanes|=n,e.suspendedLanes&=~n;var o=31-It(n);e.entangledLanes|=n,e.entanglements[o]=e.entanglements[o]|1073741824|l&261930}function En(e,n){var l=e.entangledLanes|=n;for(e=e.entanglements;l;){var o=31-It(l),f=1<<o;f&n|e[o]&n&&(e[o]|=n),l&=~f}}function Pr(e,n){var l=n&-n;return l=(l&42)!==0?1:nr(l),(l&(e.suspendedLanes|n))!==0?0:l}function nr(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 Vr(e){return e&=-e,2<e?8<e?(e&134217727)!==0?32:268435456:8:2}function ja(){var e=I.p;return e!==0?e:(e=window.event,e===void 0?32:Ax(e.type))}function Gl(e,n){var l=I.p;try{return I.p=e,n()}finally{I.p=l}}var Nn=Math.random().toString(36).slice(2),He="__reactFiber$"+Nn,Ft="__reactProps$"+Nn,Tn="__reactContainer$"+Nn,Wl="__reactEvents$"+Nn,fn="__reactListeners$"+Nn,qf="__reactHandles$"+Nn,br="__reactResources$"+Nn,Sa="__reactMarker$"+Nn;function dc(e){delete e[He],delete e[Ft],delete e[Wl],delete e[fn],delete e[qf]}function Qa(e){var n=e[He];if(n)return n;for(var l=e.parentNode;l;){if(n=l[Tn]||l[He]){if(l=n.alternate,n.child!==null||l!==null&&l.child!==null)for(e=mx(e);e!==null;){if(l=e[He])return l;e=mx(e)}return n}e=l,l=e.parentNode}return null}function Za(e){if(e=e[He]||e[Tn]){var n=e.tag;if(n===5||n===6||n===13||n===31||n===26||n===27||n===3)return e}return null}function ql(e){var n=e.tag;if(n===5||n===26||n===27||n===6)return e.stateNode;throw Error(i(33))}function Ja(e){var n=e[br];return n||(n=e[br]={hoistableStyles:new Map,hoistableScripts:new Map}),n}function Zt(e){e[Sa]=!0}var Yf=new Set,Kf={};function ka(e,n){el(e,n),el(e+"Capture",n)}function el(e,n){for(Kf[e]=n,e=0;e<n.length;e++)Yf.add(n[e])}var Nb=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]*$"),Xf={},Qf={};function Tb(e){return Ve.call(Qf,e)?!0:Ve.call(Xf,e)?!1:Nb.test(e)?Qf[e]=!0:(Xf[e]=!0,!1)}function di(e,n,l){if(Tb(n))if(l===null)e.removeAttribute(n);else{switch(typeof l){case"undefined":case"function":case"symbol":e.removeAttribute(n);return;case"boolean":var o=n.toLowerCase().slice(0,5);if(o!=="data-"&&o!=="aria-"){e.removeAttribute(n);return}}e.setAttribute(n,""+l)}}function fi(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 jr(e,n,l,o){if(o===null)e.removeAttribute(l);else{switch(typeof o){case"undefined":case"function":case"symbol":case"boolean":e.removeAttribute(l);return}e.setAttributeNS(n,l,""+o)}}function Pn(e){switch(typeof e){case"bigint":case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Zf(e){var n=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(n==="checkbox"||n==="radio")}function Rb(e,n,l){var o=Object.getOwnPropertyDescriptor(e.constructor.prototype,n);if(!e.hasOwnProperty(n)&&typeof o<"u"&&typeof o.get=="function"&&typeof o.set=="function"){var f=o.get,g=o.set;return Object.defineProperty(e,n,{configurable:!0,get:function(){return f.call(this)},set:function(j){l=""+j,g.call(this,j)}}),Object.defineProperty(e,n,{enumerable:o.enumerable}),{getValue:function(){return l},setValue:function(j){l=""+j},stopTracking:function(){e._valueTracker=null,delete e[n]}}}}function fc(e){if(!e._valueTracker){var n=Zf(e)?"checked":"value";e._valueTracker=Rb(e,n,""+e[n])}}function Jf(e){if(!e)return!1;var n=e._valueTracker;if(!n)return!0;var l=n.getValue(),o="";return e&&(o=Zf(e)?e.checked?"true":"false":e.value),e=o,e!==l?(n.setValue(e),!0):!1}function pi(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 Ab=/[\n"\\]/g;function Vn(e){return e.replace(Ab,function(n){return"\\"+n.charCodeAt(0).toString(16)+" "})}function pc(e,n,l,o,f,g,j,A){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=""+Pn(n)):e.value!==""+Pn(n)&&(e.value=""+Pn(n)):j!=="submit"&&j!=="reset"||e.removeAttribute("value"),n!=null?mc(e,j,Pn(n)):l!=null?mc(e,j,Pn(l)):o!=null&&e.removeAttribute("value"),f==null&&g!=null&&(e.defaultChecked=!!g),f!=null&&(e.checked=f&&typeof f!="function"&&typeof f!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?e.name=""+Pn(A):e.removeAttribute("name")}function ep(e,n,l,o,f,g,j,A){if(g!=null&&typeof g!="function"&&typeof g!="symbol"&&typeof g!="boolean"&&(e.type=g),n!=null||l!=null){if(!(g!=="submit"&&g!=="reset"||n!=null)){fc(e);return}l=l!=null?""+Pn(l):"",n=n!=null?""+Pn(n):l,A||n===e.value||(e.value=n),e.defaultValue=n}o=o??f,o=typeof o!="function"&&typeof o!="symbol"&&!!o,e.checked=A?e.checked:!!o,e.defaultChecked=!!o,j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(e.name=j),fc(e)}function mc(e,n,l){n==="number"&&pi(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function tl(e,n,l,o){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&&o&&(e[l].defaultSelected=!0)}else{for(l=""+Pn(l),n=null,f=0;f<e.length;f++){if(e[f].value===l){e[f].selected=!0,o&&(e[f].defaultSelected=!0);return}n!==null||e[f].disabled||(n=e[f])}n!==null&&(n.selected=!0)}}function tp(e,n,l){if(n!=null&&(n=""+Pn(n),n!==e.value&&(e.value=n),l==null)){e.defaultValue!==n&&(e.defaultValue=n);return}e.defaultValue=l!=null?""+Pn(l):""}function np(e,n,l,o){if(n==null){if(o!=null){if(l!=null)throw Error(i(92));if($(o)){if(1<o.length)throw Error(i(93));o=o[0]}l=o}l==null&&(l=""),n=l}l=Pn(n),e.defaultValue=l,o=e.textContent,o===l&&o!==""&&o!==null&&(e.value=o),fc(e)}function nl(e,n){if(n){var l=e.firstChild;if(l&&l===e.lastChild&&l.nodeType===3){l.nodeValue=n;return}}e.textContent=n}var Mb=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 rp(e,n,l){var o=n.indexOf("--")===0;l==null||typeof l=="boolean"||l===""?o?e.setProperty(n,""):n==="float"?e.cssFloat="":e[n]="":o?e.setProperty(n,l):typeof l!="number"||l===0||Mb.has(n)?n==="float"?e.cssFloat=l:e[n]=(""+l).trim():e[n]=l+"px"}function ap(e,n,l){if(n!=null&&typeof n!="object")throw Error(i(62));if(e=e.style,l!=null){for(var o in l)!l.hasOwnProperty(o)||n!=null&&n.hasOwnProperty(o)||(o.indexOf("--")===0?e.setProperty(o,""):o==="float"?e.cssFloat="":e[o]="");for(var f in n)o=n[f],n.hasOwnProperty(f)&&l[f]!==o&&rp(e,f,o)}else for(var g in n)n.hasOwnProperty(g)&&rp(e,g,n[g])}function hc(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 Lb=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"]]),zb=/^[\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 mi(e){return zb.test(""+e)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":e}function Sr(){}var xc=null;function gc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var rl=null,al=null;function lp(e){var n=Za(e);if(n&&(e=n.stateNode)){var l=e[Ft]||null;e:switch(e=n.stateNode,n.type){case"input":if(pc(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="'+Vn(""+n)+'"][type="radio"]'),n=0;n<l.length;n++){var o=l[n];if(o!==e&&o.form===e.form){var f=o[Ft]||null;if(!f)throw Error(i(90));pc(o,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name)}}for(n=0;n<l.length;n++)o=l[n],o.form===e.form&&Jf(o)}break e;case"textarea":tp(e,l.value,l.defaultValue);break e;case"select":n=l.value,n!=null&&tl(e,!!l.multiple,n,!1)}}}var vc=!1;function sp(e,n,l){if(vc)return e(n,l);vc=!0;try{var o=e(n);return o}finally{if(vc=!1,(rl!==null||al!==null)&&(to(),rl&&(n=rl,e=al,al=rl=null,lp(n),e)))for(n=0;n<e.length;n++)lp(e[n])}}function Yl(e,n){var l=e.stateNode;if(l===null)return null;var o=l[Ft]||null;if(o===null)return null;l=o[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":(o=!o.disabled)||(e=e.type,o=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!o;break e;default:e=!1}if(e)return null;if(l&&typeof l!="function")throw Error(i(231,n,typeof l));return l}var kr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),yc=!1;if(kr)try{var Kl={};Object.defineProperty(Kl,"passive",{get:function(){yc=!0}}),window.addEventListener("test",Kl,Kl),window.removeEventListener("test",Kl,Kl)}catch{yc=!1}var Fr=null,bc=null,hi=null;function ip(){if(hi)return hi;var e,n=bc,l=n.length,o,f="value"in Fr?Fr.value:Fr.textContent,g=f.length;for(e=0;e<l&&n[e]===f[e];e++);var j=l-e;for(o=1;o<=j&&n[l-o]===f[g-o];o++);return hi=f.slice(e,1<o?1-o:void 0)}function xi(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 gi(){return!0}function op(){return!1}function yn(e){function n(l,o,f,g,j){this._reactName=l,this._targetInst=f,this.type=o,this.nativeEvent=g,this.target=j,this.currentTarget=null;for(var A in e)e.hasOwnProperty(A)&&(l=e[A],this[A]=l?l(g):g[A]);return this.isDefaultPrevented=(g.defaultPrevented!=null?g.defaultPrevented:g.returnValue===!1)?gi:op,this.isPropagationStopped=op,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=gi)},stopPropagation:function(){var l=this.nativeEvent;l&&(l.stopPropagation?l.stopPropagation():typeof l.cancelBubble!="unknown"&&(l.cancelBubble=!0),this.isPropagationStopped=gi)},persist:function(){},isPersistent:gi}),n}var wa={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vi=yn(wa),Xl=v({},wa,{view:0,detail:0}),Db=yn(Xl),jc,Sc,Ql,yi=v({},Xl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:wc,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!==Ql&&(Ql&&e.type==="mousemove"?(jc=e.screenX-Ql.screenX,Sc=e.screenY-Ql.screenY):Sc=jc=0,Ql=e),jc)},movementY:function(e){return"movementY"in e?e.movementY:Sc}}),cp=yn(yi),_b=v({},yi,{dataTransfer:0}),Ob=yn(_b),Bb=v({},Xl,{relatedTarget:0}),kc=yn(Bb),Ib=v({},wa,{animationName:0,elapsedTime:0,pseudoElement:0}),$b=yn(Ib),Ub=v({},wa,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Hb=yn(Ub),Pb=v({},wa,{data:0}),up=yn(Pb),Vb={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Fb={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"},Gb={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Wb(e){var n=this.nativeEvent;return n.getModifierState?n.getModifierState(e):(e=Gb[e])?!!n[e]:!1}function wc(){return Wb}var qb=v({},Xl,{key:function(e){if(e.key){var n=Vb[e.key]||e.key;if(n!=="Unidentified")return n}return e.type==="keypress"?(e=xi(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?Fb[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:wc,charCode:function(e){return e.type==="keypress"?xi(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?xi(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),Yb=yn(qb),Kb=v({},yi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),dp=yn(Kb),Xb=v({},Xl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:wc}),Qb=yn(Xb),Zb=v({},wa,{propertyName:0,elapsedTime:0,pseudoElement:0}),Jb=yn(Zb),e1=v({},yi,{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}),t1=yn(e1),n1=v({},wa,{newState:0,oldState:0}),r1=yn(n1),a1=[9,13,27,32],Cc=kr&&"CompositionEvent"in window,Zl=null;kr&&"documentMode"in document&&(Zl=document.documentMode);var l1=kr&&"TextEvent"in window&&!Zl,fp=kr&&(!Cc||Zl&&8<Zl&&11>=Zl),pp=" ",mp=!1;function hp(e,n){switch(e){case"keyup":return a1.indexOf(n.keyCode)!==-1;case"keydown":return n.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function xp(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ll=!1;function s1(e,n){switch(e){case"compositionend":return xp(n);case"keypress":return n.which!==32?null:(mp=!0,pp);case"textInput":return e=n.data,e===pp&&mp?null:e;default:return null}}function i1(e,n){if(ll)return e==="compositionend"||!Cc&&hp(e,n)?(e=ip(),hi=bc=Fr=null,ll=!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 fp&&n.locale!=="ko"?null:n.data;default:return null}}var o1={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 gp(e){var n=e&&e.nodeName&&e.nodeName.toLowerCase();return n==="input"?!!o1[e.type]:n==="textarea"}function vp(e,n,l,o){rl?al?al.push(o):al=[o]:rl=o,n=oo(n,"onChange"),0<n.length&&(l=new vi("onChange","change",null,l,o),e.push({event:l,listeners:n}))}var Jl=null,es=null;function c1(e){ex(e,0)}function bi(e){var n=ql(e);if(Jf(n))return e}function yp(e,n){if(e==="change")return n}var bp=!1;if(kr){var Ec;if(kr){var Nc="oninput"in document;if(!Nc){var jp=document.createElement("div");jp.setAttribute("oninput","return;"),Nc=typeof jp.oninput=="function"}Ec=Nc}else Ec=!1;bp=Ec&&(!document.documentMode||9<document.documentMode)}function Sp(){Jl&&(Jl.detachEvent("onpropertychange",kp),es=Jl=null)}function kp(e){if(e.propertyName==="value"&&bi(es)){var n=[];vp(n,es,e,gc(e)),sp(c1,n)}}function u1(e,n,l){e==="focusin"?(Sp(),Jl=n,es=l,Jl.attachEvent("onpropertychange",kp)):e==="focusout"&&Sp()}function d1(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return bi(es)}function f1(e,n){if(e==="click")return bi(n)}function p1(e,n){if(e==="input"||e==="change")return bi(n)}function m1(e,n){return e===n&&(e!==0||1/e===1/n)||e!==e&&n!==n}var Rn=typeof Object.is=="function"?Object.is:m1;function ts(e,n){if(Rn(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;var l=Object.keys(e),o=Object.keys(n);if(l.length!==o.length)return!1;for(o=0;o<l.length;o++){var f=l[o];if(!Ve.call(n,f)||!Rn(e[f],n[f]))return!1}return!0}function wp(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Cp(e,n){var l=wp(e);e=0;for(var o;l;){if(l.nodeType===3){if(o=e+l.textContent.length,e<=n&&o>=n)return{node:l,offset:n-e};e=o}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=wp(l)}}function Ep(e,n){return e&&n?e===n?!0:e&&e.nodeType===3?!1:n&&n.nodeType===3?Ep(e,n.parentNode):"contains"in e?e.contains(n):e.compareDocumentPosition?!!(e.compareDocumentPosition(n)&16):!1:!1}function Np(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var n=pi(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=pi(e.document)}return n}function Tc(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 h1=kr&&"documentMode"in document&&11>=document.documentMode,sl=null,Rc=null,ns=null,Ac=!1;function Tp(e,n,l){var o=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Ac||sl==null||sl!==pi(o)||(o=sl,"selectionStart"in o&&Tc(o)?o={start:o.selectionStart,end:o.selectionEnd}:(o=(o.ownerDocument&&o.ownerDocument.defaultView||window).getSelection(),o={anchorNode:o.anchorNode,anchorOffset:o.anchorOffset,focusNode:o.focusNode,focusOffset:o.focusOffset}),ns&&ts(ns,o)||(ns=o,o=oo(Rc,"onSelect"),0<o.length&&(n=new vi("onSelect","select",null,n,l),e.push({event:n,listeners:o}),n.target=sl)))}function Ca(e,n){var l={};return l[e.toLowerCase()]=n.toLowerCase(),l["Webkit"+e]="webkit"+n,l["Moz"+e]="moz"+n,l}var il={animationend:Ca("Animation","AnimationEnd"),animationiteration:Ca("Animation","AnimationIteration"),animationstart:Ca("Animation","AnimationStart"),transitionrun:Ca("Transition","TransitionRun"),transitionstart:Ca("Transition","TransitionStart"),transitioncancel:Ca("Transition","TransitionCancel"),transitionend:Ca("Transition","TransitionEnd")},Mc={},Rp={};kr&&(Rp=document.createElement("div").style,"AnimationEvent"in window||(delete il.animationend.animation,delete il.animationiteration.animation,delete il.animationstart.animation),"TransitionEvent"in window||delete il.transitionend.transition);function Ea(e){if(Mc[e])return Mc[e];if(!il[e])return e;var n=il[e],l;for(l in n)if(n.hasOwnProperty(l)&&l in Rp)return Mc[e]=n[l];return e}var Ap=Ea("animationend"),Mp=Ea("animationiteration"),Lp=Ea("animationstart"),x1=Ea("transitionrun"),g1=Ea("transitionstart"),v1=Ea("transitioncancel"),zp=Ea("transitionend"),Dp=new Map,Lc="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(" ");Lc.push("scrollEnd");function rr(e,n){Dp.set(e,n),ka(n,[e])}var ji=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)},Fn=[],ol=0,zc=0;function Si(){for(var e=ol,n=zc=ol=0;n<e;){var l=Fn[n];Fn[n++]=null;var o=Fn[n];Fn[n++]=null;var f=Fn[n];Fn[n++]=null;var g=Fn[n];if(Fn[n++]=null,o!==null&&f!==null){var j=o.pending;j===null?f.next=f:(f.next=j.next,j.next=f),o.pending=f}g!==0&&_p(l,f,g)}}function ki(e,n,l,o){Fn[ol++]=e,Fn[ol++]=n,Fn[ol++]=l,Fn[ol++]=o,zc|=o,e.lanes|=o,e=e.alternate,e!==null&&(e.lanes|=o)}function Dc(e,n,l,o){return ki(e,n,l,o),wi(e)}function Na(e,n){return ki(e,null,null,n),wi(e)}function _p(e,n,l){e.lanes|=l;var o=e.alternate;o!==null&&(o.lanes|=l);for(var f=!1,g=e.return;g!==null;)g.childLanes|=l,o=g.alternate,o!==null&&(o.childLanes|=l),g.tag===22&&(e=g.stateNode,e===null||e._visibility&1||(f=!0)),e=g,g=g.return;return e.tag===3?(g=e.stateNode,f&&n!==null&&(f=31-It(l),e=g.hiddenUpdates,o=e[f],o===null?e[f]=[n]:o.push(n),n.lane=l|536870912),g):null}function wi(e){if(50<ws)throw ws=0,Vu=null,Error(i(185));for(var n=e.return;n!==null;)e=n,n=e.return;return e.tag===3?e.stateNode:null}var cl={};function y1(e,n,l,o){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=o,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function An(e,n,l,o){return new y1(e,n,l,o)}function _c(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wr(e,n){var l=e.alternate;return l===null?(l=An(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 Op(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 Ci(e,n,l,o,f,g){var j=0;if(o=e,typeof e=="function")_c(e)&&(j=1);else if(typeof e=="string")j=w0(e,l,q.current)?26:e==="html"||e==="head"||e==="body"?27:5;else e:switch(e){case L:return e=An(31,l,n,f),e.elementType=L,e.lanes=g,e;case C:return Ta(l.children,f,g,n);case w:j=8,f|=24;break;case N:return e=An(12,l,n,f|2),e.elementType=N,e.lanes=g,e;case z:return e=An(13,l,n,f),e.elementType=z,e.lanes=g,e;case P:return e=An(19,l,n,f),e.elementType=P,e.lanes=g,e;default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case R:j=10;break e;case T:j=9;break e;case _:j=11;break e;case k:j=14;break e;case O:j=16,o=null;break e}j=29,l=Error(i(130,e===null?"null":typeof e,"")),o=null}return n=An(j,l,n,f),n.elementType=e,n.type=o,n.lanes=g,n}function Ta(e,n,l,o){return e=An(7,e,o,n),e.lanes=l,e}function Oc(e,n,l){return e=An(6,e,null,n),e.lanes=l,e}function Bp(e){var n=An(18,null,null,0);return n.stateNode=e,n}function Bc(e,n,l){return n=An(4,e.children!==null?e.children:[],e.key,n),n.lanes=l,n.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},n}var Ip=new WeakMap;function Gn(e,n){if(typeof e=="object"&&e!==null){var l=Ip.get(e);return l!==void 0?l:(n={value:e,source:n,stack:je(n)},Ip.set(e,n),n)}return{value:e,source:n,stack:je(n)}}var ul=[],dl=0,Ei=null,rs=0,Wn=[],qn=0,Gr=null,ur=1,dr="";function Cr(e,n){ul[dl++]=rs,ul[dl++]=Ei,Ei=e,rs=n}function $p(e,n,l){Wn[qn++]=ur,Wn[qn++]=dr,Wn[qn++]=Gr,Gr=e;var o=ur;e=dr;var f=32-It(o)-1;o&=~(1<<f),l+=1;var g=32-It(n)+f;if(30<g){var j=f-f%5;g=(o&(1<<j)-1).toString(32),o>>=j,f-=j,ur=1<<32-It(n)+f|l<<f|o,dr=g+e}else ur=1<<g|l<<f|o,dr=e}function Ic(e){e.return!==null&&(Cr(e,1),$p(e,1,0))}function $c(e){for(;e===Ei;)Ei=ul[--dl],ul[dl]=null,rs=ul[--dl],ul[dl]=null;for(;e===Gr;)Gr=Wn[--qn],Wn[qn]=null,dr=Wn[--qn],Wn[qn]=null,ur=Wn[--qn],Wn[qn]=null}function Up(e,n){Wn[qn++]=ur,Wn[qn++]=dr,Wn[qn++]=Gr,ur=n.id,dr=n.overflow,Gr=e}var an=null,kt=null,Je=!1,Wr=null,Yn=!1,Uc=Error(i(519));function qr(e){var n=Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw as(Gn(n,e)),Uc}function Hp(e){var n=e.stateNode,l=e.type,o=e.memoizedProps;switch(n[He]=e,n[Ft]=o,l){case"dialog":Xe("cancel",n),Xe("close",n);break;case"iframe":case"object":case"embed":Xe("load",n);break;case"video":case"audio":for(l=0;l<Es.length;l++)Xe(Es[l],n);break;case"source":Xe("error",n);break;case"img":case"image":case"link":Xe("error",n),Xe("load",n);break;case"details":Xe("toggle",n);break;case"input":Xe("invalid",n),ep(n,o.value,o.defaultValue,o.checked,o.defaultChecked,o.type,o.name,!0);break;case"select":Xe("invalid",n);break;case"textarea":Xe("invalid",n),np(n,o.value,o.defaultValue,o.children)}l=o.children,typeof l!="string"&&typeof l!="number"&&typeof l!="bigint"||n.textContent===""+l||o.suppressHydrationWarning===!0||ax(n.textContent,l)?(o.popover!=null&&(Xe("beforetoggle",n),Xe("toggle",n)),o.onScroll!=null&&Xe("scroll",n),o.onScrollEnd!=null&&Xe("scrollend",n),o.onClick!=null&&(n.onclick=Sr),n=!0):n=!1,n||qr(e,!0)}function Pp(e){for(an=e.return;an;)switch(an.tag){case 5:case 31:case 13:Yn=!1;return;case 27:case 3:Yn=!0;return;default:an=an.return}}function fl(e){if(e!==an)return!1;if(!Je)return Pp(e),Je=!0,!1;var n=e.tag,l;if((l=n!==3&&n!==27)&&((l=n===5)&&(l=e.type,l=!(l!=="form"&&l!=="button")||ad(e.type,e.memoizedProps)),l=!l),l&&kt&&qr(e),Pp(e),n===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));kt=px(e)}else if(n===31){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(317));kt=px(e)}else n===27?(n=kt,ia(e.type)?(e=cd,cd=null,kt=e):kt=n):kt=an?Xn(e.stateNode.nextSibling):null;return!0}function Ra(){kt=an=null,Je=!1}function Hc(){var e=Wr;return e!==null&&(kn===null?kn=e:kn.push.apply(kn,e),Wr=null),e}function as(e){Wr===null?Wr=[e]:Wr.push(e)}var Pc=D(null),Aa=null,Er=null;function Yr(e,n,l){te(Pc,n._currentValue),n._currentValue=l}function Nr(e){e._currentValue=Pc.current,W(Pc)}function Vc(e,n,l){for(;e!==null;){var o=e.alternate;if((e.childLanes&n)!==n?(e.childLanes|=n,o!==null&&(o.childLanes|=n)):o!==null&&(o.childLanes&n)!==n&&(o.childLanes|=n),e===l)break;e=e.return}}function Fc(e,n,l,o){var f=e.child;for(f!==null&&(f.return=e);f!==null;){var g=f.dependencies;if(g!==null){var j=f.child;g=g.firstContext;e:for(;g!==null;){var A=g;g=f;for(var V=0;V<n.length;V++)if(A.context===n[V]){g.lanes|=l,A=g.alternate,A!==null&&(A.lanes|=l),Vc(g.return,l,e),o||(j=null);break e}g=A.next}}else if(f.tag===18){if(j=f.return,j===null)throw Error(i(341));j.lanes|=l,g=j.alternate,g!==null&&(g.lanes|=l),Vc(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 pl(e,n,l,o){e=null;for(var f=n,g=!1;f!==null;){if(!g){if((f.flags&524288)!==0)g=!0;else if((f.flags&262144)!==0)break}if(f.tag===10){var j=f.alternate;if(j===null)throw Error(i(387));if(j=j.memoizedProps,j!==null){var A=f.type;Rn(f.pendingProps.value,j.value)||(e!==null?e.push(A):e=[A])}}else if(f===ye.current){if(j=f.alternate,j===null)throw Error(i(387));j.memoizedState.memoizedState!==f.memoizedState.memoizedState&&(e!==null?e.push(Ms):e=[Ms])}f=f.return}e!==null&&Fc(n,e,l,o),n.flags|=262144}function Ni(e){for(e=e.firstContext;e!==null;){if(!Rn(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ma(e){Aa=e,Er=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function ln(e){return Vp(Aa,e)}function Ti(e,n){return Aa===null&&Ma(e),Vp(e,n)}function Vp(e,n){var l=n._currentValue;if(n={context:n,memoizedValue:l,next:null},Er===null){if(e===null)throw Error(i(308));Er=n,e.dependencies={lanes:0,firstContext:n},e.flags|=524288}else Er=Er.next=n;return l}var b1=typeof AbortController<"u"?AbortController:function(){var e=[],n=this.signal={aborted:!1,addEventListener:function(l,o){e.push(o)}};this.abort=function(){n.aborted=!0,e.forEach(function(l){return l()})}},j1=t.unstable_scheduleCallback,S1=t.unstable_NormalPriority,$t={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Gc(){return{controller:new b1,data:new Map,refCount:0}}function ls(e){e.refCount--,e.refCount===0&&j1(S1,function(){e.controller.abort()})}var ss=null,Wc=0,ml=0,hl=null;function k1(e,n){if(ss===null){var l=ss=[];Wc=0,ml=Ku(),hl={status:"pending",value:void 0,then:function(o){l.push(o)}}}return Wc++,n.then(Fp,Fp),n}function Fp(){if(--Wc===0&&ss!==null){hl!==null&&(hl.status="fulfilled");var e=ss;ss=null,ml=0,hl=null;for(var n=0;n<e.length;n++)(0,e[n])()}}function w1(e,n){var l=[],o={status:"pending",value:null,reason:null,then:function(f){l.push(f)}};return e.then(function(){o.status="fulfilled",o.value=n;for(var f=0;f<l.length;f++)(0,l[f])(n)},function(f){for(o.status="rejected",o.reason=f,f=0;f<l.length;f++)(0,l[f])(void 0)}),o}var Gp=M.S;M.S=function(e,n){Th=Ge(),typeof n=="object"&&n!==null&&typeof n.then=="function"&&k1(e,n),Gp!==null&&Gp(e,n)};var La=D(null);function qc(){var e=La.current;return e!==null?e:yt.pooledCache}function Ri(e,n){n===null?te(La,La.current):te(La,n.pool)}function Wp(){var e=qc();return e===null?null:{parent:$t._currentValue,pool:e}}var xl=Error(i(460)),Yc=Error(i(474)),Ai=Error(i(542)),Mi={then:function(){}};function qp(e){return e=e.status,e==="fulfilled"||e==="rejected"}function Yp(e,n,l){switch(l=e[l],l===void 0?e.push(n):l!==n&&(n.then(Sr,Sr),n=l),n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Xp(e),e;default:if(typeof n.status=="string")n.then(Sr,Sr);else{if(e=yt,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=n,e.status="pending",e.then(function(o){if(n.status==="pending"){var f=n;f.status="fulfilled",f.value=o}},function(o){if(n.status==="pending"){var f=n;f.status="rejected",f.reason=o}})}switch(n.status){case"fulfilled":return n.value;case"rejected":throw e=n.reason,Xp(e),e}throw Da=n,xl}}function za(e){try{var n=e._init;return n(e._payload)}catch(l){throw l!==null&&typeof l=="object"&&typeof l.then=="function"?(Da=l,xl):l}}var Da=null;function Kp(){if(Da===null)throw Error(i(459));var e=Da;return Da=null,e}function Xp(e){if(e===xl||e===Ai)throw Error(i(483))}var gl=null,is=0;function Li(e){var n=is;return is+=1,gl===null&&(gl=[]),Yp(gl,e,n)}function os(e,n){n=n.props.ref,e.ref=n!==void 0?n:null}function zi(e,n){throw n.$$typeof===b?Error(i(525)):(e=Object.prototype.toString.call(n),Error(i(31,e==="[object Object]"?"object with keys {"+Object.keys(n).join(", ")+"}":e)))}function Qp(e){function n(K,G){if(e){var Z=K.deletions;Z===null?(K.deletions=[G],K.flags|=16):Z.push(G)}}function l(K,G){if(!e)return null;for(;G!==null;)n(K,G),G=G.sibling;return null}function o(K){for(var G=new Map;K!==null;)K.key!==null?G.set(K.key,K):G.set(K.index,K),K=K.sibling;return G}function f(K,G){return K=wr(K,G),K.index=0,K.sibling=null,K}function g(K,G,Z){return K.index=Z,e?(Z=K.alternate,Z!==null?(Z=Z.index,Z<G?(K.flags|=67108866,G):Z):(K.flags|=67108866,G)):(K.flags|=1048576,G)}function j(K){return e&&K.alternate===null&&(K.flags|=67108866),K}function A(K,G,Z,fe){return G===null||G.tag!==6?(G=Oc(Z,K.mode,fe),G.return=K,G):(G=f(G,Z),G.return=K,G)}function V(K,G,Z,fe){var Me=Z.type;return Me===C?ue(K,G,Z.props.children,fe,Z.key):G!==null&&(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&za(Me)===G.type)?(G=f(G,Z.props),os(G,Z),G.return=K,G):(G=Ci(Z.type,Z.key,Z.props,null,K.mode,fe),os(G,Z),G.return=K,G)}function ee(K,G,Z,fe){return G===null||G.tag!==4||G.stateNode.containerInfo!==Z.containerInfo||G.stateNode.implementation!==Z.implementation?(G=Bc(Z,K.mode,fe),G.return=K,G):(G=f(G,Z.children||[]),G.return=K,G)}function ue(K,G,Z,fe,Me){return G===null||G.tag!==7?(G=Ta(Z,K.mode,fe,Me),G.return=K,G):(G=f(G,Z),G.return=K,G)}function pe(K,G,Z){if(typeof G=="string"&&G!==""||typeof G=="number"||typeof G=="bigint")return G=Oc(""+G,K.mode,Z),G.return=K,G;if(typeof G=="object"&&G!==null){switch(G.$$typeof){case S:return Z=Ci(G.type,G.key,G.props,null,K.mode,Z),os(Z,G),Z.return=K,Z;case E:return G=Bc(G,K.mode,Z),G.return=K,G;case O:return G=za(G),pe(K,G,Z)}if($(G)||Y(G))return G=Ta(G,K.mode,Z,null),G.return=K,G;if(typeof G.then=="function")return pe(K,Li(G),Z);if(G.$$typeof===R)return pe(K,Ti(K,G),Z);zi(K,G)}return null}function ne(K,G,Z,fe){var Me=G!==null?G.key:null;if(typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint")return Me!==null?null:A(K,G,""+Z,fe);if(typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case S:return Z.key===Me?V(K,G,Z,fe):null;case E:return Z.key===Me?ee(K,G,Z,fe):null;case O:return Z=za(Z),ne(K,G,Z,fe)}if($(Z)||Y(Z))return Me!==null?null:ue(K,G,Z,fe,null);if(typeof Z.then=="function")return ne(K,G,Li(Z),fe);if(Z.$$typeof===R)return ne(K,G,Ti(K,Z),fe);zi(K,Z)}return null}function le(K,G,Z,fe,Me){if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return K=K.get(Z)||null,A(G,K,""+fe,Me);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case S:return K=K.get(fe.key===null?Z:fe.key)||null,V(G,K,fe,Me);case E:return K=K.get(fe.key===null?Z:fe.key)||null,ee(G,K,fe,Me);case O:return fe=za(fe),le(K,G,Z,fe,Me)}if($(fe)||Y(fe))return K=K.get(Z)||null,ue(G,K,fe,Me,null);if(typeof fe.then=="function")return le(K,G,Z,Li(fe),Me);if(fe.$$typeof===R)return le(K,G,Z,Ti(G,fe),Me);zi(G,fe)}return null}function Ce(K,G,Z,fe){for(var Me=null,nt=null,Ee=G,We=G=0,Ze=null;Ee!==null&&We<Z.length;We++){Ee.index>We?(Ze=Ee,Ee=null):Ze=Ee.sibling;var rt=ne(K,Ee,Z[We],fe);if(rt===null){Ee===null&&(Ee=Ze);break}e&&Ee&&rt.alternate===null&&n(K,Ee),G=g(rt,G,We),nt===null?Me=rt:nt.sibling=rt,nt=rt,Ee=Ze}if(We===Z.length)return l(K,Ee),Je&&Cr(K,We),Me;if(Ee===null){for(;We<Z.length;We++)Ee=pe(K,Z[We],fe),Ee!==null&&(G=g(Ee,G,We),nt===null?Me=Ee:nt.sibling=Ee,nt=Ee);return Je&&Cr(K,We),Me}for(Ee=o(Ee);We<Z.length;We++)Ze=le(Ee,K,We,Z[We],fe),Ze!==null&&(e&&Ze.alternate!==null&&Ee.delete(Ze.key===null?We:Ze.key),G=g(Ze,G,We),nt===null?Me=Ze:nt.sibling=Ze,nt=Ze);return e&&Ee.forEach(function(fa){return n(K,fa)}),Je&&Cr(K,We),Me}function ze(K,G,Z,fe){if(Z==null)throw Error(i(151));for(var Me=null,nt=null,Ee=G,We=G=0,Ze=null,rt=Z.next();Ee!==null&&!rt.done;We++,rt=Z.next()){Ee.index>We?(Ze=Ee,Ee=null):Ze=Ee.sibling;var fa=ne(K,Ee,rt.value,fe);if(fa===null){Ee===null&&(Ee=Ze);break}e&&Ee&&fa.alternate===null&&n(K,Ee),G=g(fa,G,We),nt===null?Me=fa:nt.sibling=fa,nt=fa,Ee=Ze}if(rt.done)return l(K,Ee),Je&&Cr(K,We),Me;if(Ee===null){for(;!rt.done;We++,rt=Z.next())rt=pe(K,rt.value,fe),rt!==null&&(G=g(rt,G,We),nt===null?Me=rt:nt.sibling=rt,nt=rt);return Je&&Cr(K,We),Me}for(Ee=o(Ee);!rt.done;We++,rt=Z.next())rt=le(Ee,K,We,rt.value,fe),rt!==null&&(e&&rt.alternate!==null&&Ee.delete(rt.key===null?We:rt.key),G=g(rt,G,We),nt===null?Me=rt:nt.sibling=rt,nt=rt);return e&&Ee.forEach(function(_0){return n(K,_0)}),Je&&Cr(K,We),Me}function gt(K,G,Z,fe){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case S:e:{for(var Me=Z.key;G!==null;){if(G.key===Me){if(Me=Z.type,Me===C){if(G.tag===7){l(K,G.sibling),fe=f(G,Z.props.children),fe.return=K,K=fe;break e}}else if(G.elementType===Me||typeof Me=="object"&&Me!==null&&Me.$$typeof===O&&za(Me)===G.type){l(K,G.sibling),fe=f(G,Z.props),os(fe,Z),fe.return=K,K=fe;break e}l(K,G);break}else n(K,G);G=G.sibling}Z.type===C?(fe=Ta(Z.props.children,K.mode,fe,Z.key),fe.return=K,K=fe):(fe=Ci(Z.type,Z.key,Z.props,null,K.mode,fe),os(fe,Z),fe.return=K,K=fe)}return j(K);case E:e:{for(Me=Z.key;G!==null;){if(G.key===Me)if(G.tag===4&&G.stateNode.containerInfo===Z.containerInfo&&G.stateNode.implementation===Z.implementation){l(K,G.sibling),fe=f(G,Z.children||[]),fe.return=K,K=fe;break e}else{l(K,G);break}else n(K,G);G=G.sibling}fe=Bc(Z,K.mode,fe),fe.return=K,K=fe}return j(K);case O:return Z=za(Z),gt(K,G,Z,fe)}if($(Z))return Ce(K,G,Z,fe);if(Y(Z)){if(Me=Y(Z),typeof Me!="function")throw Error(i(150));return Z=Me.call(Z),ze(K,G,Z,fe)}if(typeof Z.then=="function")return gt(K,G,Li(Z),fe);if(Z.$$typeof===R)return gt(K,G,Ti(K,Z),fe);zi(K,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,G!==null&&G.tag===6?(l(K,G.sibling),fe=f(G,Z),fe.return=K,K=fe):(l(K,G),fe=Oc(Z,K.mode,fe),fe.return=K,K=fe),j(K)):l(K,G)}return function(K,G,Z,fe){try{is=0;var Me=gt(K,G,Z,fe);return gl=null,Me}catch(Ee){if(Ee===xl||Ee===Ai)throw Ee;var nt=An(29,Ee,null,K.mode);return nt.lanes=fe,nt.return=K,nt}finally{}}}var _a=Qp(!0),Zp=Qp(!1),Kr=!1;function Kc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Xc(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 Xr(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Qr(e,n,l){var o=e.updateQueue;if(o===null)return null;if(o=o.shared,(st&2)!==0){var f=o.pending;return f===null?n.next=n:(n.next=f.next,f.next=n),o.pending=n,n=wi(e),_p(e,null,l),n}return ki(e,o,n,l),wi(e)}function cs(e,n,l){if(n=n.updateQueue,n!==null&&(n=n.shared,(l&4194048)!==0)){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,En(e,l)}}function Qc(e,n){var l=e.updateQueue,o=e.alternate;if(o!==null&&(o=o.updateQueue,l===o)){var f=null,g=null;if(l=l.firstBaseUpdate,l!==null){do{var j={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};g===null?f=g=j:g=g.next=j,l=l.next}while(l!==null);g===null?f=g=n:g=g.next=n}else f=g=n;l={baseState:o.baseState,firstBaseUpdate:f,lastBaseUpdate:g,shared:o.shared,callbacks:o.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=n:e.next=n,l.lastBaseUpdate=n}var Zc=!1;function us(){if(Zc){var e=hl;if(e!==null)throw e}}function ds(e,n,l,o){Zc=!1;var f=e.updateQueue;Kr=!1;var g=f.firstBaseUpdate,j=f.lastBaseUpdate,A=f.shared.pending;if(A!==null){f.shared.pending=null;var V=A,ee=V.next;V.next=null,j===null?g=ee:j.next=ee,j=V;var ue=e.alternate;ue!==null&&(ue=ue.updateQueue,A=ue.lastBaseUpdate,A!==j&&(A===null?ue.firstBaseUpdate=ee:A.next=ee,ue.lastBaseUpdate=V))}if(g!==null){var pe=f.baseState;j=0,ue=ee=V=null,A=g;do{var ne=A.lane&-536870913,le=ne!==A.lane;if(le?(Qe&ne)===ne:(o&ne)===ne){ne!==0&&ne===ml&&(Zc=!0),ue!==null&&(ue=ue.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var Ce=e,ze=A;ne=n;var gt=l;switch(ze.tag){case 1:if(Ce=ze.payload,typeof Ce=="function"){pe=Ce.call(gt,pe,ne);break e}pe=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=ze.payload,ne=typeof Ce=="function"?Ce.call(gt,pe,ne):Ce,ne==null)break e;pe=v({},pe,ne);break e;case 2:Kr=!0}}ne=A.callback,ne!==null&&(e.flags|=64,le&&(e.flags|=8192),le=f.callbacks,le===null?f.callbacks=[ne]:le.push(ne))}else le={lane:ne,tag:A.tag,payload:A.payload,callback:A.callback,next:null},ue===null?(ee=ue=le,V=pe):ue=ue.next=le,j|=ne;if(A=A.next,A===null){if(A=f.shared.pending,A===null)break;le=A,A=le.next,le.next=null,f.lastBaseUpdate=le,f.shared.pending=null}}while(!0);ue===null&&(V=pe),f.baseState=V,f.firstBaseUpdate=ee,f.lastBaseUpdate=ue,g===null&&(f.shared.lanes=0),na|=j,e.lanes=j,e.memoizedState=pe}}function Jp(e,n){if(typeof e!="function")throw Error(i(191,e));e.call(n)}function em(e,n){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;e<l.length;e++)Jp(l[e],n)}var vl=D(null),Di=D(0);function tm(e,n){e=Or,te(Di,e),te(vl,n),Or=e|n.baseLanes}function Jc(){te(Di,Or),te(vl,vl.current)}function eu(){Or=Di.current,W(vl),W(Di)}var Mn=D(null),Kn=null;function Zr(e){var n=e.alternate;te(_t,_t.current&1),te(Mn,e),Kn===null&&(n===null||vl.current!==null||n.memoizedState!==null)&&(Kn=e)}function tu(e){te(_t,_t.current),te(Mn,e),Kn===null&&(Kn=e)}function nm(e){e.tag===22?(te(_t,_t.current),te(Mn,e),Kn===null&&(Kn=e)):Jr()}function Jr(){te(_t,_t.current),te(Mn,Mn.current)}function Ln(e){W(Mn),Kn===e&&(Kn=null),W(_t)}var _t=D(0);function _i(e){for(var n=e;n!==null;){if(n.tag===13){var l=n.memoizedState;if(l!==null&&(l=l.dehydrated,l===null||id(l)||od(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 Tr=0,Fe=null,ht=null,Ut=null,Oi=!1,yl=!1,Oa=!1,Bi=0,fs=0,bl=null,C1=0;function zt(){throw Error(i(321))}function nu(e,n){if(n===null)return!1;for(var l=0;l<n.length&&l<e.length;l++)if(!Rn(e[l],n[l]))return!1;return!0}function ru(e,n,l,o,f,g){return Tr=g,Fe=n,n.memoizedState=null,n.updateQueue=null,n.lanes=0,M.H=e===null||e.memoizedState===null?$m:vu,Oa=!1,g=l(o,f),Oa=!1,yl&&(g=am(n,l,o,f)),rm(e),g}function rm(e){M.H=hs;var n=ht!==null&&ht.next!==null;if(Tr=0,Ut=ht=Fe=null,Oi=!1,fs=0,bl=null,n)throw Error(i(300));e===null||Ht||(e=e.dependencies,e!==null&&Ni(e)&&(Ht=!0))}function am(e,n,l,o){Fe=e;var f=0;do{if(yl&&(bl=null),fs=0,yl=!1,25<=f)throw Error(i(301));if(f+=1,Ut=ht=null,e.updateQueue!=null){var g=e.updateQueue;g.lastEffect=null,g.events=null,g.stores=null,g.memoCache!=null&&(g.memoCache.index=0)}M.H=Um,g=n(l,o)}while(yl);return g}function E1(){var e=M.H,n=e.useState()[0];return n=typeof n.then=="function"?ps(n):n,e=e.useState()[0],(ht!==null?ht.memoizedState:null)!==e&&(Fe.flags|=1024),n}function au(){var e=Bi!==0;return Bi=0,e}function lu(e,n,l){n.updateQueue=e.updateQueue,n.flags&=-2053,e.lanes&=~l}function su(e){if(Oi){for(e=e.memoizedState;e!==null;){var n=e.queue;n!==null&&(n.pending=null),e=e.next}Oi=!1}Tr=0,Ut=ht=Fe=null,yl=!1,fs=Bi=0,bl=null}function pn(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Ut===null?Fe.memoizedState=Ut=e:Ut=Ut.next=e,Ut}function Ot(){if(ht===null){var e=Fe.alternate;e=e!==null?e.memoizedState:null}else e=ht.next;var n=Ut===null?Fe.memoizedState:Ut.next;if(n!==null)Ut=n,ht=e;else{if(e===null)throw Fe.alternate===null?Error(i(467)):Error(i(310));ht=e,e={memoizedState:ht.memoizedState,baseState:ht.baseState,baseQueue:ht.baseQueue,queue:ht.queue,next:null},Ut===null?Fe.memoizedState=Ut=e:Ut=Ut.next=e}return Ut}function Ii(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function ps(e){var n=fs;return fs+=1,bl===null&&(bl=[]),e=Yp(bl,e,n),n=Fe,(Ut===null?n.memoizedState:Ut.next)===null&&(n=n.alternate,M.H=n===null||n.memoizedState===null?$m:vu),e}function $i(e){if(e!==null&&typeof e=="object"){if(typeof e.then=="function")return ps(e);if(e.$$typeof===R)return ln(e)}throw Error(i(438,String(e)))}function iu(e){var n=null,l=Fe.updateQueue;if(l!==null&&(n=l.memoCache),n==null){var o=Fe.alternate;o!==null&&(o=o.updateQueue,o!==null&&(o=o.memoCache,o!=null&&(n={data:o.data.map(function(f){return f.slice()}),index:0})))}if(n==null&&(n={data:[],index:0}),l===null&&(l=Ii(),Fe.updateQueue=l),l.memoCache=n,l=n.data[n.index],l===void 0)for(l=n.data[n.index]=Array(e),o=0;o<e;o++)l[o]=B;return n.index++,l}function Rr(e,n){return typeof n=="function"?n(e):n}function Ui(e){var n=Ot();return ou(n,ht,e)}function ou(e,n,l){var o=e.queue;if(o===null)throw Error(i(311));o.lastRenderedReducer=l;var f=e.baseQueue,g=o.pending;if(g!==null){if(f!==null){var j=f.next;f.next=g.next,g.next=j}n.baseQueue=f=g,o.pending=null}if(g=e.baseState,f===null)e.memoizedState=g;else{n=f.next;var A=j=null,V=null,ee=n,ue=!1;do{var pe=ee.lane&-536870913;if(pe!==ee.lane?(Qe&pe)===pe:(Tr&pe)===pe){var ne=ee.revertLane;if(ne===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null}),pe===ml&&(ue=!0);else if((Tr&ne)===ne){ee=ee.next,ne===ml&&(ue=!0);continue}else pe={lane:0,revertLane:ee.revertLane,gesture:null,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null},V===null?(A=V=pe,j=g):V=V.next=pe,Fe.lanes|=ne,na|=ne;pe=ee.action,Oa&&l(g,pe),g=ee.hasEagerState?ee.eagerState:l(g,pe)}else ne={lane:pe,revertLane:ee.revertLane,gesture:ee.gesture,action:ee.action,hasEagerState:ee.hasEagerState,eagerState:ee.eagerState,next:null},V===null?(A=V=ne,j=g):V=V.next=ne,Fe.lanes|=pe,na|=pe;ee=ee.next}while(ee!==null&&ee!==n);if(V===null?j=g:V.next=A,!Rn(g,e.memoizedState)&&(Ht=!0,ue&&(l=hl,l!==null)))throw l;e.memoizedState=g,e.baseState=j,e.baseQueue=V,o.lastRenderedState=g}return f===null&&(o.lanes=0),[e.memoizedState,o.dispatch]}function cu(e){var n=Ot(),l=n.queue;if(l===null)throw Error(i(311));l.lastRenderedReducer=e;var o=l.dispatch,f=l.pending,g=n.memoizedState;if(f!==null){l.pending=null;var j=f=f.next;do g=e(g,j.action),j=j.next;while(j!==f);Rn(g,n.memoizedState)||(Ht=!0),n.memoizedState=g,n.baseQueue===null&&(n.baseState=g),l.lastRenderedState=g}return[g,o]}function lm(e,n,l){var o=Fe,f=Ot(),g=Je;if(g){if(l===void 0)throw Error(i(407));l=l()}else l=n();var j=!Rn((ht||f).memoizedState,l);if(j&&(f.memoizedState=l,Ht=!0),f=f.queue,fu(om.bind(null,o,f,e),[e]),f.getSnapshot!==n||j||Ut!==null&&Ut.memoizedState.tag&1){if(o.flags|=2048,jl(9,{destroy:void 0},im.bind(null,o,f,l,n),null),yt===null)throw Error(i(349));g||(Tr&127)!==0||sm(o,n,l)}return l}function sm(e,n,l){e.flags|=16384,e={getSnapshot:n,value:l},n=Fe.updateQueue,n===null?(n=Ii(),Fe.updateQueue=n,n.stores=[e]):(l=n.stores,l===null?n.stores=[e]:l.push(e))}function im(e,n,l,o){n.value=l,n.getSnapshot=o,cm(n)&&um(e)}function om(e,n,l){return l(function(){cm(n)&&um(e)})}function cm(e){var n=e.getSnapshot;e=e.value;try{var l=n();return!Rn(e,l)}catch{return!0}}function um(e){var n=Na(e,2);n!==null&&wn(n,e,2)}function uu(e){var n=pn();if(typeof e=="function"){var l=e;if(e=l(),Oa){Bt(!0);try{l()}finally{Bt(!1)}}}return n.memoizedState=n.baseState=e,n.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rr,lastRenderedState:e},n}function dm(e,n,l,o){return e.baseState=l,ou(e,ht,typeof o=="function"?o:Rr)}function N1(e,n,l,o,f){if(Vi(e))throw Error(i(485));if(e=n.action,e!==null){var g={payload:f,action:e,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(j){g.listeners.push(j)}};M.T!==null?l(!0):g.isTransition=!1,o(g),l=n.pending,l===null?(g.next=n.pending=g,fm(n,g)):(g.next=l.next,n.pending=l.next=g)}}function fm(e,n){var l=n.action,o=n.payload,f=e.state;if(n.isTransition){var g=M.T,j={};M.T=j;try{var A=l(f,o),V=M.S;V!==null&&V(j,A),pm(e,n,A)}catch(ee){du(e,n,ee)}finally{g!==null&&j.types!==null&&(g.types=j.types),M.T=g}}else try{g=l(f,o),pm(e,n,g)}catch(ee){du(e,n,ee)}}function pm(e,n,l){l!==null&&typeof l=="object"&&typeof l.then=="function"?l.then(function(o){mm(e,n,o)},function(o){return du(e,n,o)}):mm(e,n,l)}function mm(e,n,l){n.status="fulfilled",n.value=l,hm(n),e.state=l,n=e.pending,n!==null&&(l=n.next,l===n?e.pending=null:(l=l.next,n.next=l,fm(e,l)))}function du(e,n,l){var o=e.pending;if(e.pending=null,o!==null){o=o.next;do n.status="rejected",n.reason=l,hm(n),n=n.next;while(n!==o)}e.action=null}function hm(e){e=e.listeners;for(var n=0;n<e.length;n++)(0,e[n])()}function xm(e,n){return n}function gm(e,n){if(Je){var l=yt.formState;if(l!==null){e:{var o=Fe;if(Je){if(kt){t:{for(var f=kt,g=Yn;f.nodeType!==8;){if(!g){f=null;break t}if(f=Xn(f.nextSibling),f===null){f=null;break t}}g=f.data,f=g==="F!"||g==="F"?f:null}if(f){kt=Xn(f.nextSibling),o=f.data==="F!";break e}}qr(o)}o=!1}o&&(n=l[0])}}return l=pn(),l.memoizedState=l.baseState=n,o={pending:null,lanes:0,dispatch:null,lastRenderedReducer:xm,lastRenderedState:n},l.queue=o,l=Om.bind(null,Fe,o),o.dispatch=l,o=uu(!1),g=gu.bind(null,Fe,!1,o.queue),o=pn(),f={state:n,dispatch:null,action:e,pending:null},o.queue=f,l=N1.bind(null,Fe,f,g,l),f.dispatch=l,o.memoizedState=e,[n,l,!1]}function vm(e){var n=Ot();return ym(n,ht,e)}function ym(e,n,l){if(n=ou(e,n,xm)[0],e=Ui(Rr)[0],typeof n=="object"&&n!==null&&typeof n.then=="function")try{var o=ps(n)}catch(j){throw j===xl?Ai:j}else o=n;n=Ot();var f=n.queue,g=f.dispatch;return l!==n.memoizedState&&(Fe.flags|=2048,jl(9,{destroy:void 0},T1.bind(null,f,l),null)),[o,g,e]}function T1(e,n){e.action=n}function bm(e){var n=Ot(),l=ht;if(l!==null)return ym(n,l,e);Ot(),n=n.memoizedState,l=Ot();var o=l.queue.dispatch;return l.memoizedState=e,[n,o,!1]}function jl(e,n,l,o){return e={tag:e,create:l,deps:o,inst:n,next:null},n=Fe.updateQueue,n===null&&(n=Ii(),Fe.updateQueue=n),l=n.lastEffect,l===null?n.lastEffect=e.next=e:(o=l.next,l.next=e,e.next=o,n.lastEffect=e),e}function jm(){return Ot().memoizedState}function Hi(e,n,l,o){var f=pn();Fe.flags|=e,f.memoizedState=jl(1|n,{destroy:void 0},l,o===void 0?null:o)}function Pi(e,n,l,o){var f=Ot();o=o===void 0?null:o;var g=f.memoizedState.inst;ht!==null&&o!==null&&nu(o,ht.memoizedState.deps)?f.memoizedState=jl(n,g,l,o):(Fe.flags|=e,f.memoizedState=jl(1|n,g,l,o))}function Sm(e,n){Hi(8390656,8,e,n)}function fu(e,n){Pi(2048,8,e,n)}function R1(e){Fe.flags|=4;var n=Fe.updateQueue;if(n===null)n=Ii(),Fe.updateQueue=n,n.events=[e];else{var l=n.events;l===null?n.events=[e]:l.push(e)}}function km(e){var n=Ot().memoizedState;return R1({ref:n,nextImpl:e}),function(){if((st&2)!==0)throw Error(i(440));return n.impl.apply(void 0,arguments)}}function wm(e,n){return Pi(4,2,e,n)}function Cm(e,n){return Pi(4,4,e,n)}function Em(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 Nm(e,n,l){l=l!=null?l.concat([e]):null,Pi(4,4,Em.bind(null,n,e),l)}function pu(){}function Tm(e,n){var l=Ot();n=n===void 0?null:n;var o=l.memoizedState;return n!==null&&nu(n,o[1])?o[0]:(l.memoizedState=[e,n],e)}function Rm(e,n){var l=Ot();n=n===void 0?null:n;var o=l.memoizedState;if(n!==null&&nu(n,o[1]))return o[0];if(o=e(),Oa){Bt(!0);try{e()}finally{Bt(!1)}}return l.memoizedState=[o,n],o}function mu(e,n,l){return l===void 0||(Tr&1073741824)!==0&&(Qe&261930)===0?e.memoizedState=n:(e.memoizedState=l,e=Ah(),Fe.lanes|=e,na|=e,l)}function Am(e,n,l,o){return Rn(l,n)?l:vl.current!==null?(e=mu(e,l,o),Rn(e,n)||(Ht=!0),e):(Tr&42)===0||(Tr&1073741824)!==0&&(Qe&261930)===0?(Ht=!0,e.memoizedState=l):(e=Ah(),Fe.lanes|=e,na|=e,n)}function Mm(e,n,l,o,f){var g=I.p;I.p=g!==0&&8>g?g:8;var j=M.T,A={};M.T=A,gu(e,!1,n,l);try{var V=f(),ee=M.S;if(ee!==null&&ee(A,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var ue=w1(V,o);ms(e,n,ue,_n(e))}else ms(e,n,o,_n(e))}catch(pe){ms(e,n,{then:function(){},status:"rejected",reason:pe},_n())}finally{I.p=g,j!==null&&A.types!==null&&(j.types=A.types),M.T=j}}function A1(){}function hu(e,n,l,o){if(e.tag!==5)throw Error(i(476));var f=Lm(e).queue;Mm(e,f,n,F,l===null?A1:function(){return zm(e),l(o)})}function Lm(e){var n=e.memoizedState;if(n!==null)return n;n={memoizedState:F,baseState:F,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rr,lastRenderedState:F},next:null};var l={};return n.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Rr,lastRenderedState:l},next:null},e.memoizedState=n,e=e.alternate,e!==null&&(e.memoizedState=n),n}function zm(e){var n=Lm(e);n.next===null&&(n=e.alternate.memoizedState),ms(e,n.next.queue,{},_n())}function xu(){return ln(Ms)}function Dm(){return Ot().memoizedState}function _m(){return Ot().memoizedState}function M1(e){for(var n=e.return;n!==null;){switch(n.tag){case 24:case 3:var l=_n();e=Xr(l);var o=Qr(n,e,l);o!==null&&(wn(o,n,l),cs(o,n,l)),n={cache:Gc()},e.payload=n;return}n=n.return}}function L1(e,n,l){var o=_n();l={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Vi(e)?Bm(n,l):(l=Dc(e,n,l,o),l!==null&&(wn(l,e,o),Im(l,n,o)))}function Om(e,n,l){var o=_n();ms(e,n,l,o)}function ms(e,n,l,o){var f={lane:o,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Vi(e))Bm(n,f);else{var g=e.alternate;if(e.lanes===0&&(g===null||g.lanes===0)&&(g=n.lastRenderedReducer,g!==null))try{var j=n.lastRenderedState,A=g(j,l);if(f.hasEagerState=!0,f.eagerState=A,Rn(A,j))return ki(e,n,f,0),yt===null&&Si(),!1}catch{}finally{}if(l=Dc(e,n,f,o),l!==null)return wn(l,e,o),Im(l,n,o),!0}return!1}function gu(e,n,l,o){if(o={lane:2,revertLane:Ku(),gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Vi(e)){if(n)throw Error(i(479))}else n=Dc(e,l,o,2),n!==null&&wn(n,e,2)}function Vi(e){var n=e.alternate;return e===Fe||n!==null&&n===Fe}function Bm(e,n){yl=Oi=!0;var l=e.pending;l===null?n.next=n:(n.next=l.next,l.next=n),e.pending=n}function Im(e,n,l){if((l&4194048)!==0){var o=n.lanes;o&=e.pendingLanes,l|=o,n.lanes=l,En(e,l)}}var hs={readContext:ln,use:$i,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};hs.useEffectEvent=zt;var $m={readContext:ln,use:$i,useCallback:function(e,n){return pn().memoizedState=[e,n===void 0?null:n],e},useContext:ln,useEffect:Sm,useImperativeHandle:function(e,n,l){l=l!=null?l.concat([e]):null,Hi(4194308,4,Em.bind(null,n,e),l)},useLayoutEffect:function(e,n){return Hi(4194308,4,e,n)},useInsertionEffect:function(e,n){Hi(4,2,e,n)},useMemo:function(e,n){var l=pn();n=n===void 0?null:n;var o=e();if(Oa){Bt(!0);try{e()}finally{Bt(!1)}}return l.memoizedState=[o,n],o},useReducer:function(e,n,l){var o=pn();if(l!==void 0){var f=l(n);if(Oa){Bt(!0);try{l(n)}finally{Bt(!1)}}}else f=n;return o.memoizedState=o.baseState=f,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:f},o.queue=e,e=e.dispatch=L1.bind(null,Fe,e),[o.memoizedState,e]},useRef:function(e){var n=pn();return e={current:e},n.memoizedState=e},useState:function(e){e=uu(e);var n=e.queue,l=Om.bind(null,Fe,n);return n.dispatch=l,[e.memoizedState,l]},useDebugValue:pu,useDeferredValue:function(e,n){var l=pn();return mu(l,e,n)},useTransition:function(){var e=uu(!1);return e=Mm.bind(null,Fe,e.queue,!0,!1),pn().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,n,l){var o=Fe,f=pn();if(Je){if(l===void 0)throw Error(i(407));l=l()}else{if(l=n(),yt===null)throw Error(i(349));(Qe&127)!==0||sm(o,n,l)}f.memoizedState=l;var g={value:l,getSnapshot:n};return f.queue=g,Sm(om.bind(null,o,g,e),[e]),o.flags|=2048,jl(9,{destroy:void 0},im.bind(null,o,g,l,n),null),l},useId:function(){var e=pn(),n=yt.identifierPrefix;if(Je){var l=dr,o=ur;l=(o&~(1<<32-It(o)-1)).toString(32)+l,n="_"+n+"R_"+l,l=Bi++,0<l&&(n+="H"+l.toString(32)),n+="_"}else l=C1++,n="_"+n+"r_"+l.toString(32)+"_";return e.memoizedState=n},useHostTransitionStatus:xu,useFormState:gm,useActionState:gm,useOptimistic:function(e){var n=pn();n.memoizedState=n.baseState=e;var l={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return n.queue=l,n=gu.bind(null,Fe,!0,l),l.dispatch=n,[e,n]},useMemoCache:iu,useCacheRefresh:function(){return pn().memoizedState=M1.bind(null,Fe)},useEffectEvent:function(e){var n=pn(),l={impl:e};return n.memoizedState=l,function(){if((st&2)!==0)throw Error(i(440));return l.impl.apply(void 0,arguments)}}},vu={readContext:ln,use:$i,useCallback:Tm,useContext:ln,useEffect:fu,useImperativeHandle:Nm,useInsertionEffect:wm,useLayoutEffect:Cm,useMemo:Rm,useReducer:Ui,useRef:jm,useState:function(){return Ui(Rr)},useDebugValue:pu,useDeferredValue:function(e,n){var l=Ot();return Am(l,ht.memoizedState,e,n)},useTransition:function(){var e=Ui(Rr)[0],n=Ot().memoizedState;return[typeof e=="boolean"?e:ps(e),n]},useSyncExternalStore:lm,useId:Dm,useHostTransitionStatus:xu,useFormState:vm,useActionState:vm,useOptimistic:function(e,n){var l=Ot();return dm(l,ht,e,n)},useMemoCache:iu,useCacheRefresh:_m};vu.useEffectEvent=km;var Um={readContext:ln,use:$i,useCallback:Tm,useContext:ln,useEffect:fu,useImperativeHandle:Nm,useInsertionEffect:wm,useLayoutEffect:Cm,useMemo:Rm,useReducer:cu,useRef:jm,useState:function(){return cu(Rr)},useDebugValue:pu,useDeferredValue:function(e,n){var l=Ot();return ht===null?mu(l,e,n):Am(l,ht.memoizedState,e,n)},useTransition:function(){var e=cu(Rr)[0],n=Ot().memoizedState;return[typeof e=="boolean"?e:ps(e),n]},useSyncExternalStore:lm,useId:Dm,useHostTransitionStatus:xu,useFormState:bm,useActionState:bm,useOptimistic:function(e,n){var l=Ot();return ht!==null?dm(l,ht,e,n):(l.baseState=e,[e,l.queue.dispatch])},useMemoCache:iu,useCacheRefresh:_m};Um.useEffectEvent=km;function yu(e,n,l,o){n=e.memoizedState,l=l(o,n),l=l==null?n:v({},n,l),e.memoizedState=l,e.lanes===0&&(e.updateQueue.baseState=l)}var bu={enqueueSetState:function(e,n,l){e=e._reactInternals;var o=_n(),f=Xr(o);f.payload=n,l!=null&&(f.callback=l),n=Qr(e,f,o),n!==null&&(wn(n,e,o),cs(n,e,o))},enqueueReplaceState:function(e,n,l){e=e._reactInternals;var o=_n(),f=Xr(o);f.tag=1,f.payload=n,l!=null&&(f.callback=l),n=Qr(e,f,o),n!==null&&(wn(n,e,o),cs(n,e,o))},enqueueForceUpdate:function(e,n){e=e._reactInternals;var l=_n(),o=Xr(l);o.tag=2,n!=null&&(o.callback=n),n=Qr(e,o,l),n!==null&&(wn(n,e,l),cs(n,e,l))}};function Hm(e,n,l,o,f,g,j){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(o,g,j):n.prototype&&n.prototype.isPureReactComponent?!ts(l,o)||!ts(f,g):!0}function Pm(e,n,l,o){e=n.state,typeof n.componentWillReceiveProps=="function"&&n.componentWillReceiveProps(l,o),typeof n.UNSAFE_componentWillReceiveProps=="function"&&n.UNSAFE_componentWillReceiveProps(l,o),n.state!==e&&bu.enqueueReplaceState(n,n.state,null)}function Ba(e,n){var l=n;if("ref"in n){l={};for(var o in n)o!=="ref"&&(l[o]=n[o])}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 Vm(e){ji(e)}function Fm(e){console.error(e)}function Gm(e){ji(e)}function Fi(e,n){try{var l=e.onUncaughtError;l(n.value,{componentStack:n.stack})}catch(o){setTimeout(function(){throw o})}}function Wm(e,n,l){try{var o=e.onCaughtError;o(l.value,{componentStack:l.stack,errorBoundary:n.tag===1?n.stateNode:null})}catch(f){setTimeout(function(){throw f})}}function ju(e,n,l){return l=Xr(l),l.tag=3,l.payload={element:null},l.callback=function(){Fi(e,n)},l}function qm(e){return e=Xr(e),e.tag=3,e}function Ym(e,n,l,o){var f=l.type.getDerivedStateFromError;if(typeof f=="function"){var g=o.value;e.payload=function(){return f(g)},e.callback=function(){Wm(n,l,o)}}var j=l.stateNode;j!==null&&typeof j.componentDidCatch=="function"&&(e.callback=function(){Wm(n,l,o),typeof f!="function"&&(ra===null?ra=new Set([this]):ra.add(this));var A=o.stack;this.componentDidCatch(o.value,{componentStack:A!==null?A:""})})}function z1(e,n,l,o,f){if(l.flags|=32768,o!==null&&typeof o=="object"&&typeof o.then=="function"){if(n=l.alternate,n!==null&&pl(n,l,f,!0),l=Mn.current,l!==null){switch(l.tag){case 31:case 13:return Kn===null?no():l.alternate===null&&Dt===0&&(Dt=3),l.flags&=-257,l.flags|=65536,l.lanes=f,o===Mi?l.flags|=16384:(n=l.updateQueue,n===null?l.updateQueue=new Set([o]):n.add(o),Wu(e,o,f)),!1;case 22:return l.flags|=65536,o===Mi?l.flags|=16384:(n=l.updateQueue,n===null?(n={transitions:null,markerInstances:null,retryQueue:new Set([o])},l.updateQueue=n):(l=n.retryQueue,l===null?n.retryQueue=new Set([o]):l.add(o)),Wu(e,o,f)),!1}throw Error(i(435,l.tag))}return Wu(e,o,f),no(),!1}if(Je)return n=Mn.current,n!==null?((n.flags&65536)===0&&(n.flags|=256),n.flags|=65536,n.lanes=f,o!==Uc&&(e=Error(i(422),{cause:o}),as(Gn(e,l)))):(o!==Uc&&(n=Error(i(423),{cause:o}),as(Gn(n,l))),e=e.current.alternate,e.flags|=65536,f&=-f,e.lanes|=f,o=Gn(o,l),f=ju(e.stateNode,o,f),Qc(e,f),Dt!==4&&(Dt=2)),!1;var g=Error(i(520),{cause:o});if(g=Gn(g,l),ks===null?ks=[g]:ks.push(g),Dt!==4&&(Dt=2),n===null)return!0;o=Gn(o,l),l=n;do{switch(l.tag){case 3:return l.flags|=65536,e=f&-f,l.lanes|=e,e=ju(l.stateNode,o,e),Qc(l,e),!1;case 1:if(n=l.type,g=l.stateNode,(l.flags&128)===0&&(typeof n.getDerivedStateFromError=="function"||g!==null&&typeof g.componentDidCatch=="function"&&(ra===null||!ra.has(g))))return l.flags|=65536,f&=-f,l.lanes|=f,f=qm(f),Ym(f,e,l,o),Qc(l,f),!1}l=l.return}while(l!==null);return!1}var Su=Error(i(461)),Ht=!1;function sn(e,n,l,o){n.child=e===null?Zp(n,null,l,o):_a(n,e.child,l,o)}function Km(e,n,l,o,f){l=l.render;var g=n.ref;if("ref"in o){var j={};for(var A in o)A!=="ref"&&(j[A]=o[A])}else j=o;return Ma(n),o=ru(e,n,l,j,g,f),A=au(),e!==null&&!Ht?(lu(e,n,f),Ar(e,n,f)):(Je&&A&&Ic(n),n.flags|=1,sn(e,n,o,f),n.child)}function Xm(e,n,l,o,f){if(e===null){var g=l.type;return typeof g=="function"&&!_c(g)&&g.defaultProps===void 0&&l.compare===null?(n.tag=15,n.type=g,Qm(e,n,g,o,f)):(e=Ci(l.type,null,o,n,n.mode,f),e.ref=n.ref,e.return=n,n.child=e)}if(g=e.child,!Au(e,f)){var j=g.memoizedProps;if(l=l.compare,l=l!==null?l:ts,l(j,o)&&e.ref===n.ref)return Ar(e,n,f)}return n.flags|=1,e=wr(g,o),e.ref=n.ref,e.return=n,n.child=e}function Qm(e,n,l,o,f){if(e!==null){var g=e.memoizedProps;if(ts(g,o)&&e.ref===n.ref)if(Ht=!1,n.pendingProps=o=g,Au(e,f))(e.flags&131072)!==0&&(Ht=!0);else return n.lanes=e.lanes,Ar(e,n,f)}return ku(e,n,l,o,f)}function Zm(e,n,l,o){var f=o.children,g=e!==null?e.memoizedState:null;if(e===null&&n.stateNode===null&&(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.mode==="hidden"){if((n.flags&128)!==0){if(g=g!==null?g.baseLanes|l:l,e!==null){for(o=n.child=e.child,f=0;o!==null;)f=f|o.lanes|o.childLanes,o=o.sibling;o=f&~g}else o=0,n.child=null;return Jm(e,n,g,l,o)}if((l&536870912)!==0)n.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ri(n,g!==null?g.cachePool:null),g!==null?tm(n,g):Jc(),nm(n);else return o=n.lanes=536870912,Jm(e,n,g!==null?g.baseLanes|l:l,l,o)}else g!==null?(Ri(n,g.cachePool),tm(n,g),Jr(),n.memoizedState=null):(e!==null&&Ri(n,null),Jc(),Jr());return sn(e,n,f,l),n.child}function xs(e,n){return e!==null&&e.tag===22||n.stateNode!==null||(n.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),n.sibling}function Jm(e,n,l,o,f){var g=qc();return g=g===null?null:{parent:$t._currentValue,pool:g},n.memoizedState={baseLanes:l,cachePool:g},e!==null&&Ri(n,null),Jc(),nm(n),e!==null&&pl(e,n,o,!0),n.childLanes=f,null}function Gi(e,n){return n=qi({mode:n.mode,children:n.children},e.mode),n.ref=e.ref,e.child=n,n.return=e,n}function eh(e,n,l){return _a(n,e.child,null,l),e=Gi(n,n.pendingProps),e.flags|=2,Ln(n),n.memoizedState=null,e}function D1(e,n,l){var o=n.pendingProps,f=(n.flags&128)!==0;if(n.flags&=-129,e===null){if(Je){if(o.mode==="hidden")return e=Gi(n,o),n.lanes=536870912,xs(null,e);if(tu(n),(e=kt)?(e=fx(e,Yn),e=e!==null&&e.data==="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Gr!==null?{id:ur,overflow:dr}:null,retryLane:536870912,hydrationErrors:null},l=Bp(e),l.return=n,n.child=l,an=n,kt=null)):e=null,e===null)throw qr(n);return n.lanes=536870912,null}return Gi(n,o)}var g=e.memoizedState;if(g!==null){var j=g.dehydrated;if(tu(n),f)if(n.flags&256)n.flags&=-257,n=eh(e,n,l);else if(n.memoizedState!==null)n.child=e.child,n.flags|=128,n=null;else throw Error(i(558));else if(Ht||pl(e,n,l,!1),f=(l&e.childLanes)!==0,Ht||f){if(o=yt,o!==null&&(j=Pr(o,l),j!==0&&j!==g.retryLane))throw g.retryLane=j,Na(e,j),wn(o,e,j),Su;no(),n=eh(e,n,l)}else e=g.treeContext,kt=Xn(j.nextSibling),an=n,Je=!0,Wr=null,Yn=!1,e!==null&&Up(n,e),n=Gi(n,o),n.flags|=4096;return n}return e=wr(e.child,{mode:o.mode,children:o.children}),e.ref=n.ref,n.child=e,e.return=n,e}function Wi(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(i(284));(e===null||e.ref!==l)&&(n.flags|=4194816)}}function ku(e,n,l,o,f){return Ma(n),l=ru(e,n,l,o,void 0,f),o=au(),e!==null&&!Ht?(lu(e,n,f),Ar(e,n,f)):(Je&&o&&Ic(n),n.flags|=1,sn(e,n,l,f),n.child)}function th(e,n,l,o,f,g){return Ma(n),n.updateQueue=null,l=am(n,o,l,f),rm(e),o=au(),e!==null&&!Ht?(lu(e,n,g),Ar(e,n,g)):(Je&&o&&Ic(n),n.flags|=1,sn(e,n,l,g),n.child)}function nh(e,n,l,o,f){if(Ma(n),n.stateNode===null){var g=cl,j=l.contextType;typeof j=="object"&&j!==null&&(g=ln(j)),g=new l(o,g),n.memoizedState=g.state!==null&&g.state!==void 0?g.state:null,g.updater=bu,n.stateNode=g,g._reactInternals=n,g=n.stateNode,g.props=o,g.state=n.memoizedState,g.refs={},Kc(n),j=l.contextType,g.context=typeof j=="object"&&j!==null?ln(j):cl,g.state=n.memoizedState,j=l.getDerivedStateFromProps,typeof j=="function"&&(yu(n,l,j,o),g.state=n.memoizedState),typeof l.getDerivedStateFromProps=="function"||typeof g.getSnapshotBeforeUpdate=="function"||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(j=g.state,typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount(),j!==g.state&&bu.enqueueReplaceState(g,g.state,null),ds(n,o,g,f),us(),g.state=n.memoizedState),typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!0}else if(e===null){g=n.stateNode;var A=n.memoizedProps,V=Ba(l,A);g.props=V;var ee=g.context,ue=l.contextType;j=cl,typeof ue=="object"&&ue!==null&&(j=ln(ue));var pe=l.getDerivedStateFromProps;ue=typeof pe=="function"||typeof g.getSnapshotBeforeUpdate=="function",A=n.pendingProps!==A,ue||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(A||ee!==j)&&Pm(n,g,o,j),Kr=!1;var ne=n.memoizedState;g.state=ne,ds(n,o,g,f),us(),ee=n.memoizedState,A||ne!==ee||Kr?(typeof pe=="function"&&(yu(n,l,pe,o),ee=n.memoizedState),(V=Kr||Hm(n,l,V,o,ne,ee,j))?(ue||typeof g.UNSAFE_componentWillMount!="function"&&typeof g.componentWillMount!="function"||(typeof g.componentWillMount=="function"&&g.componentWillMount(),typeof g.UNSAFE_componentWillMount=="function"&&g.UNSAFE_componentWillMount()),typeof g.componentDidMount=="function"&&(n.flags|=4194308)):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),n.memoizedProps=o,n.memoizedState=ee),g.props=o,g.state=ee,g.context=j,o=V):(typeof g.componentDidMount=="function"&&(n.flags|=4194308),o=!1)}else{g=n.stateNode,Xc(e,n),j=n.memoizedProps,ue=Ba(l,j),g.props=ue,pe=n.pendingProps,ne=g.context,ee=l.contextType,V=cl,typeof ee=="object"&&ee!==null&&(V=ln(ee)),A=l.getDerivedStateFromProps,(ee=typeof A=="function"||typeof g.getSnapshotBeforeUpdate=="function")||typeof g.UNSAFE_componentWillReceiveProps!="function"&&typeof g.componentWillReceiveProps!="function"||(j!==pe||ne!==V)&&Pm(n,g,o,V),Kr=!1,ne=n.memoizedState,g.state=ne,ds(n,o,g,f),us();var le=n.memoizedState;j!==pe||ne!==le||Kr||e!==null&&e.dependencies!==null&&Ni(e.dependencies)?(typeof A=="function"&&(yu(n,l,A,o),le=n.memoizedState),(ue=Kr||Hm(n,l,ue,o,ne,le,V)||e!==null&&e.dependencies!==null&&Ni(e.dependencies))?(ee||typeof g.UNSAFE_componentWillUpdate!="function"&&typeof g.componentWillUpdate!="function"||(typeof g.componentWillUpdate=="function"&&g.componentWillUpdate(o,le,V),typeof g.UNSAFE_componentWillUpdate=="function"&&g.UNSAFE_componentWillUpdate(o,le,V)),typeof g.componentDidUpdate=="function"&&(n.flags|=4),typeof g.getSnapshotBeforeUpdate=="function"&&(n.flags|=1024)):(typeof g.componentDidUpdate!="function"||j===e.memoizedProps&&ne===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ne===e.memoizedState||(n.flags|=1024),n.memoizedProps=o,n.memoizedState=le),g.props=o,g.state=le,g.context=V,o=ue):(typeof g.componentDidUpdate!="function"||j===e.memoizedProps&&ne===e.memoizedState||(n.flags|=4),typeof g.getSnapshotBeforeUpdate!="function"||j===e.memoizedProps&&ne===e.memoizedState||(n.flags|=1024),o=!1)}return g=o,Wi(e,n),o=(n.flags&128)!==0,g||o?(g=n.stateNode,l=o&&typeof l.getDerivedStateFromError!="function"?null:g.render(),n.flags|=1,e!==null&&o?(n.child=_a(n,e.child,null,f),n.child=_a(n,null,l,f)):sn(e,n,l,f),n.memoizedState=g.state,e=n.child):e=Ar(e,n,f),e}function rh(e,n,l,o){return Ra(),n.flags|=256,sn(e,n,l,o),n.child}var wu={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Cu(e){return{baseLanes:e,cachePool:Wp()}}function Eu(e,n,l){return e=e!==null?e.childLanes&~l:0,n&&(e|=Dn),e}function ah(e,n,l){var o=n.pendingProps,f=!1,g=(n.flags&128)!==0,j;if((j=g)||(j=e!==null&&e.memoizedState===null?!1:(_t.current&2)!==0),j&&(f=!0,n.flags&=-129),j=(n.flags&32)!==0,n.flags&=-33,e===null){if(Je){if(f?Zr(n):Jr(),(e=kt)?(e=fx(e,Yn),e=e!==null&&e.data!=="&"?e:null,e!==null&&(n.memoizedState={dehydrated:e,treeContext:Gr!==null?{id:ur,overflow:dr}:null,retryLane:536870912,hydrationErrors:null},l=Bp(e),l.return=n,n.child=l,an=n,kt=null)):e=null,e===null)throw qr(n);return od(e)?n.lanes=32:n.lanes=536870912,null}var A=o.children;return o=o.fallback,f?(Jr(),f=n.mode,A=qi({mode:"hidden",children:A},f),o=Ta(o,f,l,null),A.return=n,o.return=n,A.sibling=o,n.child=A,o=n.child,o.memoizedState=Cu(l),o.childLanes=Eu(e,j,l),n.memoizedState=wu,xs(null,o)):(Zr(n),Nu(n,A))}var V=e.memoizedState;if(V!==null&&(A=V.dehydrated,A!==null)){if(g)n.flags&256?(Zr(n),n.flags&=-257,n=Tu(e,n,l)):n.memoizedState!==null?(Jr(),n.child=e.child,n.flags|=128,n=null):(Jr(),A=o.fallback,f=n.mode,o=qi({mode:"visible",children:o.children},f),A=Ta(A,f,l,null),A.flags|=2,o.return=n,A.return=n,o.sibling=A,n.child=o,_a(n,e.child,null,l),o=n.child,o.memoizedState=Cu(l),o.childLanes=Eu(e,j,l),n.memoizedState=wu,n=xs(null,o));else if(Zr(n),od(A)){if(j=A.nextSibling&&A.nextSibling.dataset,j)var ee=j.dgst;j=ee,o=Error(i(419)),o.stack="",o.digest=j,as({value:o,source:null,stack:null}),n=Tu(e,n,l)}else if(Ht||pl(e,n,l,!1),j=(l&e.childLanes)!==0,Ht||j){if(j=yt,j!==null&&(o=Pr(j,l),o!==0&&o!==V.retryLane))throw V.retryLane=o,Na(e,o),wn(j,e,o),Su;id(A)||no(),n=Tu(e,n,l)}else id(A)?(n.flags|=192,n.child=e.child,n=null):(e=V.treeContext,kt=Xn(A.nextSibling),an=n,Je=!0,Wr=null,Yn=!1,e!==null&&Up(n,e),n=Nu(n,o.children),n.flags|=4096);return n}return f?(Jr(),A=o.fallback,f=n.mode,V=e.child,ee=V.sibling,o=wr(V,{mode:"hidden",children:o.children}),o.subtreeFlags=V.subtreeFlags&65011712,ee!==null?A=wr(ee,A):(A=Ta(A,f,l,null),A.flags|=2),A.return=n,o.return=n,o.sibling=A,n.child=o,xs(null,o),o=n.child,A=e.child.memoizedState,A===null?A=Cu(l):(f=A.cachePool,f!==null?(V=$t._currentValue,f=f.parent!==V?{parent:V,pool:V}:f):f=Wp(),A={baseLanes:A.baseLanes|l,cachePool:f}),o.memoizedState=A,o.childLanes=Eu(e,j,l),n.memoizedState=wu,xs(e.child,o)):(Zr(n),l=e.child,e=l.sibling,l=wr(l,{mode:"visible",children:o.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 Nu(e,n){return n=qi({mode:"visible",children:n},e.mode),n.return=e,e.child=n}function qi(e,n){return e=An(22,e,null,n),e.lanes=0,e}function Tu(e,n,l){return _a(n,e.child,null,l),e=Nu(n,n.pendingProps.children),e.flags|=2,n.memoizedState=null,e}function lh(e,n,l){e.lanes|=n;var o=e.alternate;o!==null&&(o.lanes|=n),Vc(e.return,n,l)}function Ru(e,n,l,o,f,g){var j=e.memoizedState;j===null?e.memoizedState={isBackwards:n,rendering:null,renderingStartTime:0,last:o,tail:l,tailMode:f,treeForkCount:g}:(j.isBackwards=n,j.rendering=null,j.renderingStartTime=0,j.last=o,j.tail=l,j.tailMode=f,j.treeForkCount=g)}function sh(e,n,l){var o=n.pendingProps,f=o.revealOrder,g=o.tail;o=o.children;var j=_t.current,A=(j&2)!==0;if(A?(j=j&1|2,n.flags|=128):j&=1,te(_t,j),sn(e,n,o,l),o=Je?rs:0,!A&&e!==null&&(e.flags&128)!==0)e:for(e=n.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&lh(e,l,n);else if(e.tag===19)lh(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&&_i(e)===null&&(f=l),l=l.sibling;l=f,l===null?(f=n.child,n.child=null):(f=l.sibling,l.sibling=null),Ru(n,!1,f,l,g,o);break;case"backwards":case"unstable_legacy-backwards":for(l=null,f=n.child,n.child=null;f!==null;){if(e=f.alternate,e!==null&&_i(e)===null){n.child=f;break}e=f.sibling,f.sibling=l,l=f,f=e}Ru(n,!0,l,null,g,o);break;case"together":Ru(n,!1,null,null,void 0,o);break;default:n.memoizedState=null}return n.child}function Ar(e,n,l){if(e!==null&&(n.dependencies=e.dependencies),na|=n.lanes,(l&n.childLanes)===0)if(e!==null){if(pl(e,n,l,!1),(l&n.childLanes)===0)return null}else return null;if(e!==null&&n.child!==e.child)throw Error(i(153));if(n.child!==null){for(e=n.child,l=wr(e,e.pendingProps),n.child=l,l.return=n;e.sibling!==null;)e=e.sibling,l=l.sibling=wr(e,e.pendingProps),l.return=n;l.sibling=null}return n.child}function Au(e,n){return(e.lanes&n)!==0?!0:(e=e.dependencies,!!(e!==null&&Ni(e)))}function _1(e,n,l){switch(n.tag){case 3:oe(n,n.stateNode.containerInfo),Yr(n,$t,e.memoizedState.cache),Ra();break;case 27:case 5:Ne(n);break;case 4:oe(n,n.stateNode.containerInfo);break;case 10:Yr(n,n.type,n.memoizedProps.value);break;case 31:if(n.memoizedState!==null)return n.flags|=128,tu(n),null;break;case 13:var o=n.memoizedState;if(o!==null)return o.dehydrated!==null?(Zr(n),n.flags|=128,null):(l&n.child.childLanes)!==0?ah(e,n,l):(Zr(n),e=Ar(e,n,l),e!==null?e.sibling:null);Zr(n);break;case 19:var f=(e.flags&128)!==0;if(o=(l&n.childLanes)!==0,o||(pl(e,n,l,!1),o=(l&n.childLanes)!==0),f){if(o)return sh(e,n,l);n.flags|=128}if(f=n.memoizedState,f!==null&&(f.rendering=null,f.tail=null,f.lastEffect=null),te(_t,_t.current),o)break;return null;case 22:return n.lanes=0,Zm(e,n,l,n.pendingProps);case 24:Yr(n,$t,e.memoizedState.cache)}return Ar(e,n,l)}function ih(e,n,l){if(e!==null)if(e.memoizedProps!==n.pendingProps)Ht=!0;else{if(!Au(e,l)&&(n.flags&128)===0)return Ht=!1,_1(e,n,l);Ht=(e.flags&131072)!==0}else Ht=!1,Je&&(n.flags&1048576)!==0&&$p(n,rs,n.index);switch(n.lanes=0,n.tag){case 16:e:{var o=n.pendingProps;if(e=za(n.elementType),n.type=e,typeof e=="function")_c(e)?(o=Ba(e,o),n.tag=1,n=nh(null,n,e,o,l)):(n.tag=0,n=ku(null,n,e,o,l));else{if(e!=null){var f=e.$$typeof;if(f===_){n.tag=11,n=Km(null,n,e,o,l);break e}else if(f===k){n.tag=14,n=Xm(null,n,e,o,l);break e}}throw n=J(e)||e,Error(i(306,n,""))}}return n;case 0:return ku(e,n,n.type,n.pendingProps,l);case 1:return o=n.type,f=Ba(o,n.pendingProps),nh(e,n,o,f,l);case 3:e:{if(oe(n,n.stateNode.containerInfo),e===null)throw Error(i(387));o=n.pendingProps;var g=n.memoizedState;f=g.element,Xc(e,n),ds(n,o,null,l);var j=n.memoizedState;if(o=j.cache,Yr(n,$t,o),o!==g.cache&&Fc(n,[$t],l,!0),us(),o=j.element,g.isDehydrated)if(g={element:o,isDehydrated:!1,cache:j.cache},n.updateQueue.baseState=g,n.memoizedState=g,n.flags&256){n=rh(e,n,o,l);break e}else if(o!==f){f=Gn(Error(i(424)),n),as(f),n=rh(e,n,o,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(kt=Xn(e.firstChild),an=n,Je=!0,Wr=null,Yn=!0,l=Zp(n,null,o,l),n.child=l;l;)l.flags=l.flags&-3|4096,l=l.sibling}else{if(Ra(),o===f){n=Ar(e,n,l);break e}sn(e,n,o,l)}n=n.child}return n;case 26:return Wi(e,n),e===null?(l=vx(n.type,null,n.pendingProps,null))?n.memoizedState=l:Je||(l=n.type,e=n.pendingProps,o=co(Q.current).createElement(l),o[He]=n,o[Ft]=e,on(o,l,e),Zt(o),n.stateNode=o):n.memoizedState=vx(n.type,e.memoizedProps,n.pendingProps,e.memoizedState),null;case 27:return Ne(n),e===null&&Je&&(o=n.stateNode=hx(n.type,n.pendingProps,Q.current),an=n,Yn=!0,f=kt,ia(n.type)?(cd=f,kt=Xn(o.firstChild)):kt=f),sn(e,n,n.pendingProps.children,l),Wi(e,n),e===null&&(n.flags|=4194304),n.child;case 5:return e===null&&Je&&((f=o=kt)&&(o=d0(o,n.type,n.pendingProps,Yn),o!==null?(n.stateNode=o,an=n,kt=Xn(o.firstChild),Yn=!1,f=!0):f=!1),f||qr(n)),Ne(n),f=n.type,g=n.pendingProps,j=e!==null?e.memoizedProps:null,o=g.children,ad(f,g)?o=null:j!==null&&ad(f,j)&&(n.flags|=32),n.memoizedState!==null&&(f=ru(e,n,E1,null,null,l),Ms._currentValue=f),Wi(e,n),sn(e,n,o,l),n.child;case 6:return e===null&&Je&&((e=l=kt)&&(l=f0(l,n.pendingProps,Yn),l!==null?(n.stateNode=l,an=n,kt=null,e=!0):e=!1),e||qr(n)),null;case 13:return ah(e,n,l);case 4:return oe(n,n.stateNode.containerInfo),o=n.pendingProps,e===null?n.child=_a(n,null,o,l):sn(e,n,o,l),n.child;case 11:return Km(e,n,n.type,n.pendingProps,l);case 7:return sn(e,n,n.pendingProps,l),n.child;case 8:return sn(e,n,n.pendingProps.children,l),n.child;case 12:return sn(e,n,n.pendingProps.children,l),n.child;case 10:return o=n.pendingProps,Yr(n,n.type,o.value),sn(e,n,o.children,l),n.child;case 9:return f=n.type._context,o=n.pendingProps.children,Ma(n),f=ln(f),o=o(f),n.flags|=1,sn(e,n,o,l),n.child;case 14:return Xm(e,n,n.type,n.pendingProps,l);case 15:return Qm(e,n,n.type,n.pendingProps,l);case 19:return sh(e,n,l);case 31:return D1(e,n,l);case 22:return Zm(e,n,l,n.pendingProps);case 24:return Ma(n),o=ln($t),e===null?(f=qc(),f===null&&(f=yt,g=Gc(),f.pooledCache=g,g.refCount++,g!==null&&(f.pooledCacheLanes|=l),f=g),n.memoizedState={parent:o,cache:f},Kc(n),Yr(n,$t,f)):((e.lanes&l)!==0&&(Xc(e,n),ds(n,null,null,l),us()),f=e.memoizedState,g=n.memoizedState,f.parent!==o?(f={parent:o,cache:o},n.memoizedState=f,n.lanes===0&&(n.memoizedState=n.updateQueue.baseState=f),Yr(n,$t,o)):(o=g.cache,Yr(n,$t,o),o!==f.cache&&Fc(n,[$t],l,!0))),sn(e,n,n.pendingProps.children,l),n.child;case 29:throw n.pendingProps}throw Error(i(156,n.tag))}function Mr(e){e.flags|=4}function Mu(e,n,l,o,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(Dh())e.flags|=8192;else throw Da=Mi,Yc}else e.flags&=-16777217}function oh(e,n){if(n.type!=="stylesheet"||(n.state.loading&4)!==0)e.flags&=-16777217;else if(e.flags|=16777216,!kx(n))if(Dh())e.flags|=8192;else throw Da=Mi,Yc}function Yi(e,n){n!==null&&(e.flags|=4),e.flags&16384&&(n=e.tag!==22?Qt():536870912,e.lanes|=n,Cl|=n)}function gs(e,n){if(!Je)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 o=null;l!==null;)l.alternate!==null&&(o=l),l=l.sibling;o===null?n||e.tail===null?e.tail=null:e.tail.sibling=null:o.sibling=null}}function wt(e){var n=e.alternate!==null&&e.alternate.child===e.child,l=0,o=0;if(n)for(var f=e.child;f!==null;)l|=f.lanes|f.childLanes,o|=f.subtreeFlags&65011712,o|=f.flags&65011712,f.return=e,f=f.sibling;else for(f=e.child;f!==null;)l|=f.lanes|f.childLanes,o|=f.subtreeFlags,o|=f.flags,f.return=e,f=f.sibling;return e.subtreeFlags|=o,e.childLanes=l,n}function O1(e,n,l){var o=n.pendingProps;switch($c(n),n.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return wt(n),null;case 1:return wt(n),null;case 3:return l=n.stateNode,o=null,e!==null&&(o=e.memoizedState.cache),n.memoizedState.cache!==o&&(n.flags|=2048),Nr($t),be(),l.pendingContext&&(l.context=l.pendingContext,l.pendingContext=null),(e===null||e.child===null)&&(fl(n)?Mr(n):e===null||e.memoizedState.isDehydrated&&(n.flags&256)===0||(n.flags|=1024,Hc())),wt(n),null;case 26:var f=n.type,g=n.memoizedState;return e===null?(Mr(n),g!==null?(wt(n),oh(n,g)):(wt(n),Mu(n,f,null,o,l))):g?g!==e.memoizedState?(Mr(n),wt(n),oh(n,g)):(wt(n),n.flags&=-16777217):(e=e.memoizedProps,e!==o&&Mr(n),wt(n),Mu(n,f,e,o,l)),null;case 27:if(Be(n),l=Q.current,f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&Mr(n);else{if(!o){if(n.stateNode===null)throw Error(i(166));return wt(n),null}e=q.current,fl(n)?Hp(n):(e=hx(f,o,l),n.stateNode=e,Mr(n))}return wt(n),null;case 5:if(Be(n),f=n.type,e!==null&&n.stateNode!=null)e.memoizedProps!==o&&Mr(n);else{if(!o){if(n.stateNode===null)throw Error(i(166));return wt(n),null}if(g=q.current,fl(n))Hp(n);else{var j=co(Q.current);switch(g){case 1:g=j.createElementNS("http://www.w3.org/2000/svg",f);break;case 2:g=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;default:switch(f){case"svg":g=j.createElementNS("http://www.w3.org/2000/svg",f);break;case"math":g=j.createElementNS("http://www.w3.org/1998/Math/MathML",f);break;case"script":g=j.createElement("div"),g.innerHTML="<script><\/script>",g=g.removeChild(g.firstChild);break;case"select":g=typeof o.is=="string"?j.createElement("select",{is:o.is}):j.createElement("select"),o.multiple?g.multiple=!0:o.size&&(g.size=o.size);break;default:g=typeof o.is=="string"?j.createElement(f,{is:o.is}):j.createElement(f)}}g[He]=n,g[Ft]=o;e:for(j=n.child;j!==null;){if(j.tag===5||j.tag===6)g.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=g;e:switch(on(g,f,o),f){case"button":case"input":case"select":case"textarea":o=!!o.autoFocus;break e;case"img":o=!0;break e;default:o=!1}o&&Mr(n)}}return wt(n),Mu(n,n.type,e===null?null:e.memoizedProps,n.pendingProps,l),null;case 6:if(e&&n.stateNode!=null)e.memoizedProps!==o&&Mr(n);else{if(typeof o!="string"&&n.stateNode===null)throw Error(i(166));if(e=Q.current,fl(n)){if(e=n.stateNode,l=n.memoizedProps,o=null,f=an,f!==null)switch(f.tag){case 27:case 5:o=f.memoizedProps}e[He]=n,e=!!(e.nodeValue===l||o!==null&&o.suppressHydrationWarning===!0||ax(e.nodeValue,l)),e||qr(n,!0)}else e=co(e).createTextNode(o),e[He]=n,n.stateNode=e}return wt(n),null;case 31:if(l=n.memoizedState,e===null||e.memoizedState!==null){if(o=fl(n),l!==null){if(e===null){if(!o)throw Error(i(318));if(e=n.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(i(557));e[He]=n}else Ra(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;wt(n),e=!1}else l=Hc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return n.flags&256?(Ln(n),n):(Ln(n),null);if((n.flags&128)!==0)throw Error(i(558))}return wt(n),null;case 13:if(o=n.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(f=fl(n),o!==null&&o.dehydrated!==null){if(e===null){if(!f)throw Error(i(318));if(f=n.memoizedState,f=f!==null?f.dehydrated:null,!f)throw Error(i(317));f[He]=n}else Ra(),(n.flags&128)===0&&(n.memoizedState=null),n.flags|=4;wt(n),f=!1}else f=Hc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=f),f=!0;if(!f)return n.flags&256?(Ln(n),n):(Ln(n),null)}return Ln(n),(n.flags&128)!==0?(n.lanes=l,n):(l=o!==null,e=e!==null&&e.memoizedState!==null,l&&(o=n.child,f=null,o.alternate!==null&&o.alternate.memoizedState!==null&&o.alternate.memoizedState.cachePool!==null&&(f=o.alternate.memoizedState.cachePool.pool),g=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(g=o.memoizedState.cachePool.pool),g!==f&&(o.flags|=2048)),l!==e&&l&&(n.child.flags|=8192),Yi(n,n.updateQueue),wt(n),null);case 4:return be(),e===null&&Ju(n.stateNode.containerInfo),wt(n),null;case 10:return Nr(n.type),wt(n),null;case 19:if(W(_t),o=n.memoizedState,o===null)return wt(n),null;if(f=(n.flags&128)!==0,g=o.rendering,g===null)if(f)gs(o,!1);else{if(Dt!==0||e!==null&&(e.flags&128)!==0)for(e=n.child;e!==null;){if(g=_i(e),g!==null){for(n.flags|=128,gs(o,!1),e=g.updateQueue,n.updateQueue=e,Yi(n,e),n.subtreeFlags=0,e=l,l=n.child;l!==null;)Op(l,e),l=l.sibling;return te(_t,_t.current&1|2),Je&&Cr(n,o.treeForkCount),n.child}e=e.sibling}o.tail!==null&&Ge()>Ji&&(n.flags|=128,f=!0,gs(o,!1),n.lanes=4194304)}else{if(!f)if(e=_i(g),e!==null){if(n.flags|=128,f=!0,e=e.updateQueue,n.updateQueue=e,Yi(n,e),gs(o,!0),o.tail===null&&o.tailMode==="hidden"&&!g.alternate&&!Je)return wt(n),null}else 2*Ge()-o.renderingStartTime>Ji&&l!==536870912&&(n.flags|=128,f=!0,gs(o,!1),n.lanes=4194304);o.isBackwards?(g.sibling=n.child,n.child=g):(e=o.last,e!==null?e.sibling=g:n.child=g,o.last=g)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=Ge(),e.sibling=null,l=_t.current,te(_t,f?l&1|2:l&1),Je&&Cr(n,o.treeForkCount),e):(wt(n),null);case 22:case 23:return Ln(n),eu(),o=n.memoizedState!==null,e!==null?e.memoizedState!==null!==o&&(n.flags|=8192):o&&(n.flags|=8192),o?(l&536870912)!==0&&(n.flags&128)===0&&(wt(n),n.subtreeFlags&6&&(n.flags|=8192)):wt(n),l=n.updateQueue,l!==null&&Yi(n,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),o=null,n.memoizedState!==null&&n.memoizedState.cachePool!==null&&(o=n.memoizedState.cachePool.pool),o!==l&&(n.flags|=2048),e!==null&&W(La),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),n.memoizedState.cache!==l&&(n.flags|=2048),Nr($t),wt(n),null;case 25:return null;case 30:return null}throw Error(i(156,n.tag))}function B1(e,n){switch($c(n),n.tag){case 1:return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 3:return Nr($t),be(),e=n.flags,(e&65536)!==0&&(e&128)===0?(n.flags=e&-65537|128,n):null;case 26:case 27:case 5:return Be(n),null;case 31:if(n.memoizedState!==null){if(Ln(n),n.alternate===null)throw Error(i(340));Ra()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 13:if(Ln(n),e=n.memoizedState,e!==null&&e.dehydrated!==null){if(n.alternate===null)throw Error(i(340));Ra()}return e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 19:return W(_t),null;case 4:return be(),null;case 10:return Nr(n.type),null;case 22:case 23:return Ln(n),eu(),e!==null&&W(La),e=n.flags,e&65536?(n.flags=e&-65537|128,n):null;case 24:return Nr($t),null;case 25:return null;default:return null}}function ch(e,n){switch($c(n),n.tag){case 3:Nr($t),be();break;case 26:case 27:case 5:Be(n);break;case 4:be();break;case 31:n.memoizedState!==null&&Ln(n);break;case 13:Ln(n);break;case 19:W(_t);break;case 10:Nr(n.type);break;case 22:case 23:Ln(n),eu(),e!==null&&W(La);break;case 24:Nr($t)}}function vs(e,n){try{var l=n.updateQueue,o=l!==null?l.lastEffect:null;if(o!==null){var f=o.next;l=f;do{if((l.tag&e)===e){o=void 0;var g=l.create,j=l.inst;o=g(),j.destroy=o}l=l.next}while(l!==f)}}catch(A){ft(n,n.return,A)}}function ea(e,n,l){try{var o=n.updateQueue,f=o!==null?o.lastEffect:null;if(f!==null){var g=f.next;o=g;do{if((o.tag&e)===e){var j=o.inst,A=j.destroy;if(A!==void 0){j.destroy=void 0,f=n;var V=l,ee=A;try{ee()}catch(ue){ft(f,V,ue)}}}o=o.next}while(o!==g)}}catch(ue){ft(n,n.return,ue)}}function uh(e){var n=e.updateQueue;if(n!==null){var l=e.stateNode;try{em(n,l)}catch(o){ft(e,e.return,o)}}}function dh(e,n,l){l.props=Ba(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(o){ft(e,n,o)}}function ys(e,n){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var o=e.stateNode;break;case 30:o=e.stateNode;break;default:o=e.stateNode}typeof l=="function"?e.refCleanup=l(o):l.current=o}}catch(f){ft(e,n,f)}}function fr(e,n){var l=e.ref,o=e.refCleanup;if(l!==null)if(typeof o=="function")try{o()}catch(f){ft(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){ft(e,n,f)}else l.current=null}function fh(e){var n=e.type,l=e.memoizedProps,o=e.stateNode;try{e:switch(n){case"button":case"input":case"select":case"textarea":l.autoFocus&&o.focus();break e;case"img":l.src?o.src=l.src:l.srcSet&&(o.srcset=l.srcSet)}}catch(f){ft(e,e.return,f)}}function Lu(e,n,l){try{var o=e.stateNode;l0(o,e.type,l,n),o[Ft]=n}catch(f){ft(e,e.return,f)}}function ph(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&ia(e.type)||e.tag===4}function zu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||ph(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&&ia(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 Du(e,n,l){var o=e.tag;if(o===5||o===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=Sr));else if(o!==4&&(o===27&&ia(e.type)&&(l=e.stateNode,n=null),e=e.child,e!==null))for(Du(e,n,l),e=e.sibling;e!==null;)Du(e,n,l),e=e.sibling}function Ki(e,n,l){var o=e.tag;if(o===5||o===6)e=e.stateNode,n?l.insertBefore(e,n):l.appendChild(e);else if(o!==4&&(o===27&&ia(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Ki(e,n,l),e=e.sibling;e!==null;)Ki(e,n,l),e=e.sibling}function mh(e){var n=e.stateNode,l=e.memoizedProps;try{for(var o=e.type,f=n.attributes;f.length;)n.removeAttributeNode(f[0]);on(n,o,l),n[He]=e,n[Ft]=l}catch(g){ft(e,e.return,g)}}var Lr=!1,Pt=!1,_u=!1,hh=typeof WeakSet=="function"?WeakSet:Set,Jt=null;function I1(e,n){if(e=e.containerInfo,nd=go,e=Np(e),Tc(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var o=l.getSelection&&l.getSelection();if(o&&o.rangeCount!==0){l=o.anchorNode;var f=o.anchorOffset,g=o.focusNode;o=o.focusOffset;try{l.nodeType,g.nodeType}catch{l=null;break e}var j=0,A=-1,V=-1,ee=0,ue=0,pe=e,ne=null;t:for(;;){for(var le;pe!==l||f!==0&&pe.nodeType!==3||(A=j+f),pe!==g||o!==0&&pe.nodeType!==3||(V=j+o),pe.nodeType===3&&(j+=pe.nodeValue.length),(le=pe.firstChild)!==null;)ne=pe,pe=le;for(;;){if(pe===e)break t;if(ne===l&&++ee===f&&(A=j),ne===g&&++ue===o&&(V=j),(le=pe.nextSibling)!==null)break;pe=ne,ne=pe.parentNode}pe=le}l=A===-1||V===-1?null:{start:A,end:V}}else l=null}l=l||{start:0,end:0}}else l=null;for(rd={focusedElem:e,selectionRange:l},go=!1,Jt=n;Jt!==null;)if(n=Jt,e=n.child,(n.subtreeFlags&1028)!==0&&e!==null)e.return=n,Jt=e;else for(;Jt!==null;){switch(n=Jt,g=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&&g!==null){e=void 0,l=n,f=g.memoizedProps,g=g.memoizedState,o=l.stateNode;try{var Ce=Ba(l.type,f);e=o.getSnapshotBeforeUpdate(Ce,g),o.__reactInternalSnapshotBeforeUpdate=e}catch(ze){ft(l,l.return,ze)}}break;case 3:if((e&1024)!==0){if(e=n.stateNode.containerInfo,l=e.nodeType,l===9)sd(e);else if(l===1)switch(e.nodeName){case"HEAD":case"HTML":case"BODY":sd(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(i(163))}if(e=n.sibling,e!==null){e.return=n.return,Jt=e;break}Jt=n.return}}function xh(e,n,l){var o=l.flags;switch(l.tag){case 0:case 11:case 15:Dr(e,l),o&4&&vs(5,l);break;case 1:if(Dr(e,l),o&4)if(e=l.stateNode,n===null)try{e.componentDidMount()}catch(j){ft(l,l.return,j)}else{var f=Ba(l.type,n.memoizedProps);n=n.memoizedState;try{e.componentDidUpdate(f,n,e.__reactInternalSnapshotBeforeUpdate)}catch(j){ft(l,l.return,j)}}o&64&&uh(l),o&512&&ys(l,l.return);break;case 3:if(Dr(e,l),o&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{em(e,n)}catch(j){ft(l,l.return,j)}}break;case 27:n===null&&o&4&&mh(l);case 26:case 5:Dr(e,l),n===null&&o&4&&fh(l),o&512&&ys(l,l.return);break;case 12:Dr(e,l);break;case 31:Dr(e,l),o&4&&yh(e,l);break;case 13:Dr(e,l),o&4&&bh(e,l),o&64&&(e=l.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(l=q1.bind(null,l),p0(e,l))));break;case 22:if(o=l.memoizedState!==null||Lr,!o){n=n!==null&&n.memoizedState!==null||Pt,f=Lr;var g=Pt;Lr=o,(Pt=n)&&!g?_r(e,l,(l.subtreeFlags&8772)!==0):Dr(e,l),Lr=f,Pt=g}break;case 30:break;default:Dr(e,l)}}function gh(e){var n=e.alternate;n!==null&&(e.alternate=null,gh(n)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(n=e.stateNode,n!==null&&dc(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 Rt=null,bn=!1;function zr(e,n,l){for(l=l.child;l!==null;)vh(e,n,l),l=l.sibling}function vh(e,n,l){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(Lt,l)}catch{}switch(l.tag){case 26:Pt||fr(l,n),zr(e,n,l),l.memoizedState?l.memoizedState.count--:l.stateNode&&(l=l.stateNode,l.parentNode.removeChild(l));break;case 27:Pt||fr(l,n);var o=Rt,f=bn;ia(l.type)&&(Rt=l.stateNode,bn=!1),zr(e,n,l),Ts(l.stateNode),Rt=o,bn=f;break;case 5:Pt||fr(l,n);case 6:if(o=Rt,f=bn,Rt=null,zr(e,n,l),Rt=o,bn=f,Rt!==null)if(bn)try{(Rt.nodeType===9?Rt.body:Rt.nodeName==="HTML"?Rt.ownerDocument.body:Rt).removeChild(l.stateNode)}catch(g){ft(l,n,g)}else try{Rt.removeChild(l.stateNode)}catch(g){ft(l,n,g)}break;case 18:Rt!==null&&(bn?(e=Rt,ux(e.nodeType===9?e.body:e.nodeName==="HTML"?e.ownerDocument.body:e,l.stateNode),zl(e)):ux(Rt,l.stateNode));break;case 4:o=Rt,f=bn,Rt=l.stateNode.containerInfo,bn=!0,zr(e,n,l),Rt=o,bn=f;break;case 0:case 11:case 14:case 15:ea(2,l,n),Pt||ea(4,l,n),zr(e,n,l);break;case 1:Pt||(fr(l,n),o=l.stateNode,typeof o.componentWillUnmount=="function"&&dh(l,n,o)),zr(e,n,l);break;case 21:zr(e,n,l);break;case 22:Pt=(o=Pt)||l.memoizedState!==null,zr(e,n,l),Pt=o;break;default:zr(e,n,l)}}function yh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{zl(e)}catch(l){ft(n,n.return,l)}}}function bh(e,n){if(n.memoizedState===null&&(e=n.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{zl(e)}catch(l){ft(n,n.return,l)}}function $1(e){switch(e.tag){case 31:case 13:case 19:var n=e.stateNode;return n===null&&(n=e.stateNode=new hh),n;case 22:return e=e.stateNode,n=e._retryCache,n===null&&(n=e._retryCache=new hh),n;default:throw Error(i(435,e.tag))}}function Xi(e,n){var l=$1(e);n.forEach(function(o){if(!l.has(o)){l.add(o);var f=Y1.bind(null,e,o);o.then(f,f)}})}function jn(e,n){var l=n.deletions;if(l!==null)for(var o=0;o<l.length;o++){var f=l[o],g=e,j=n,A=j;e:for(;A!==null;){switch(A.tag){case 27:if(ia(A.type)){Rt=A.stateNode,bn=!1;break e}break;case 5:Rt=A.stateNode,bn=!1;break e;case 3:case 4:Rt=A.stateNode.containerInfo,bn=!0;break e}A=A.return}if(Rt===null)throw Error(i(160));vh(g,j,f),Rt=null,bn=!1,g=f.alternate,g!==null&&(g.return=null),f.return=null}if(n.subtreeFlags&13886)for(n=n.child;n!==null;)jh(n,e),n=n.sibling}var ar=null;function jh(e,n){var l=e.alternate,o=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:jn(n,e),Sn(e),o&4&&(ea(3,e,e.return),vs(3,e),ea(5,e,e.return));break;case 1:jn(n,e),Sn(e),o&512&&(Pt||l===null||fr(l,l.return)),o&64&&Lr&&(e=e.updateQueue,e!==null&&(o=e.callbacks,o!==null&&(l=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=l===null?o:l.concat(o))));break;case 26:var f=ar;if(jn(n,e),Sn(e),o&512&&(Pt||l===null||fr(l,l.return)),o&4){var g=l!==null?l.memoizedState:null;if(o=e.memoizedState,l===null)if(o===null)if(e.stateNode===null){e:{o=e.type,l=e.memoizedProps,f=f.ownerDocument||f;t:switch(o){case"title":g=f.getElementsByTagName("title")[0],(!g||g[Sa]||g[He]||g.namespaceURI==="http://www.w3.org/2000/svg"||g.hasAttribute("itemprop"))&&(g=f.createElement(o),f.head.insertBefore(g,f.querySelector("head > title"))),on(g,o,l),g[He]=e,Zt(g),o=g;break e;case"link":var j=jx("link","href",f).get(o+(l.href||""));if(j){for(var A=0;A<j.length;A++)if(g=j[A],g.getAttribute("href")===(l.href==null||l.href===""?null:l.href)&&g.getAttribute("rel")===(l.rel==null?null:l.rel)&&g.getAttribute("title")===(l.title==null?null:l.title)&&g.getAttribute("crossorigin")===(l.crossOrigin==null?null:l.crossOrigin)){j.splice(A,1);break t}}g=f.createElement(o),on(g,o,l),f.head.appendChild(g);break;case"meta":if(j=jx("meta","content",f).get(o+(l.content||""))){for(A=0;A<j.length;A++)if(g=j[A],g.getAttribute("content")===(l.content==null?null:""+l.content)&&g.getAttribute("name")===(l.name==null?null:l.name)&&g.getAttribute("property")===(l.property==null?null:l.property)&&g.getAttribute("http-equiv")===(l.httpEquiv==null?null:l.httpEquiv)&&g.getAttribute("charset")===(l.charSet==null?null:l.charSet)){j.splice(A,1);break t}}g=f.createElement(o),on(g,o,l),f.head.appendChild(g);break;default:throw Error(i(468,o))}g[He]=e,Zt(g),o=g}e.stateNode=o}else Sx(f,e.type,e.stateNode);else e.stateNode=bx(f,o,e.memoizedProps);else g!==o?(g===null?l.stateNode!==null&&(l=l.stateNode,l.parentNode.removeChild(l)):g.count--,o===null?Sx(f,e.type,e.stateNode):bx(f,o,e.memoizedProps)):o===null&&e.stateNode!==null&&Lu(e,e.memoizedProps,l.memoizedProps)}break;case 27:jn(n,e),Sn(e),o&512&&(Pt||l===null||fr(l,l.return)),l!==null&&o&4&&Lu(e,e.memoizedProps,l.memoizedProps);break;case 5:if(jn(n,e),Sn(e),o&512&&(Pt||l===null||fr(l,l.return)),e.flags&32){f=e.stateNode;try{nl(f,"")}catch(Ce){ft(e,e.return,Ce)}}o&4&&e.stateNode!=null&&(f=e.memoizedProps,Lu(e,f,l!==null?l.memoizedProps:f)),o&1024&&(_u=!0);break;case 6:if(jn(n,e),Sn(e),o&4){if(e.stateNode===null)throw Error(i(162));o=e.memoizedProps,l=e.stateNode;try{l.nodeValue=o}catch(Ce){ft(e,e.return,Ce)}}break;case 3:if(po=null,f=ar,ar=uo(n.containerInfo),jn(n,e),ar=f,Sn(e),o&4&&l!==null&&l.memoizedState.isDehydrated)try{zl(n.containerInfo)}catch(Ce){ft(e,e.return,Ce)}_u&&(_u=!1,Sh(e));break;case 4:o=ar,ar=uo(e.stateNode.containerInfo),jn(n,e),Sn(e),ar=o;break;case 12:jn(n,e),Sn(e);break;case 31:jn(n,e),Sn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Xi(e,o)));break;case 13:jn(n,e),Sn(e),e.child.flags&8192&&e.memoizedState!==null!=(l!==null&&l.memoizedState!==null)&&(Zi=Ge()),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Xi(e,o)));break;case 22:f=e.memoizedState!==null;var V=l!==null&&l.memoizedState!==null,ee=Lr,ue=Pt;if(Lr=ee||f,Pt=ue||V,jn(n,e),Pt=ue,Lr=ee,Sn(e),o&8192)e:for(n=e.stateNode,n._visibility=f?n._visibility&-2:n._visibility|1,f&&(l===null||V||Lr||Pt||Ia(e)),l=null,n=e;;){if(n.tag===5||n.tag===26){if(l===null){V=l=n;try{if(g=V.stateNode,f)j=g.style,typeof j.setProperty=="function"?j.setProperty("display","none","important"):j.display="none";else{A=V.stateNode;var pe=V.memoizedProps.style,ne=pe!=null&&pe.hasOwnProperty("display")?pe.display:null;A.style.display=ne==null||typeof ne=="boolean"?"":(""+ne).trim()}}catch(Ce){ft(V,V.return,Ce)}}}else if(n.tag===6){if(l===null){V=n;try{V.stateNode.nodeValue=f?"":V.memoizedProps}catch(Ce){ft(V,V.return,Ce)}}}else if(n.tag===18){if(l===null){V=n;try{var le=V.stateNode;f?dx(le,!0):dx(V.stateNode,!1)}catch(Ce){ft(V,V.return,Ce)}}}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}o&4&&(o=e.updateQueue,o!==null&&(l=o.retryQueue,l!==null&&(o.retryQueue=null,Xi(e,l))));break;case 19:jn(n,e),Sn(e),o&4&&(o=e.updateQueue,o!==null&&(e.updateQueue=null,Xi(e,o)));break;case 30:break;case 21:break;default:jn(n,e),Sn(e)}}function Sn(e){var n=e.flags;if(n&2){try{for(var l,o=e.return;o!==null;){if(ph(o)){l=o;break}o=o.return}if(l==null)throw Error(i(160));switch(l.tag){case 27:var f=l.stateNode,g=zu(e);Ki(e,g,f);break;case 5:var j=l.stateNode;l.flags&32&&(nl(j,""),l.flags&=-33);var A=zu(e);Ki(e,A,j);break;case 3:case 4:var V=l.stateNode.containerInfo,ee=zu(e);Du(e,ee,V);break;default:throw Error(i(161))}}catch(ue){ft(e,e.return,ue)}e.flags&=-3}n&4096&&(e.flags&=-4097)}function Sh(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var n=e;Sh(n),n.tag===5&&n.flags&1024&&n.stateNode.reset(),e=e.sibling}}function Dr(e,n){if(n.subtreeFlags&8772)for(n=n.child;n!==null;)xh(e,n.alternate,n),n=n.sibling}function Ia(e){for(e=e.child;e!==null;){var n=e;switch(n.tag){case 0:case 11:case 14:case 15:ea(4,n,n.return),Ia(n);break;case 1:fr(n,n.return);var l=n.stateNode;typeof l.componentWillUnmount=="function"&&dh(n,n.return,l),Ia(n);break;case 27:Ts(n.stateNode);case 26:case 5:fr(n,n.return),Ia(n);break;case 22:n.memoizedState===null&&Ia(n);break;case 30:Ia(n);break;default:Ia(n)}e=e.sibling}}function _r(e,n,l){for(l=l&&(n.subtreeFlags&8772)!==0,n=n.child;n!==null;){var o=n.alternate,f=e,g=n,j=g.flags;switch(g.tag){case 0:case 11:case 15:_r(f,g,l),vs(4,g);break;case 1:if(_r(f,g,l),o=g,f=o.stateNode,typeof f.componentDidMount=="function")try{f.componentDidMount()}catch(ee){ft(o,o.return,ee)}if(o=g,f=o.updateQueue,f!==null){var A=o.stateNode;try{var V=f.shared.hiddenCallbacks;if(V!==null)for(f.shared.hiddenCallbacks=null,f=0;f<V.length;f++)Jp(V[f],A)}catch(ee){ft(o,o.return,ee)}}l&&j&64&&uh(g),ys(g,g.return);break;case 27:mh(g);case 26:case 5:_r(f,g,l),l&&o===null&&j&4&&fh(g),ys(g,g.return);break;case 12:_r(f,g,l);break;case 31:_r(f,g,l),l&&j&4&&yh(f,g);break;case 13:_r(f,g,l),l&&j&4&&bh(f,g);break;case 22:g.memoizedState===null&&_r(f,g,l),ys(g,g.return);break;case 30:break;default:_r(f,g,l)}n=n.sibling}}function Ou(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&&ls(l))}function Bu(e,n){e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ls(e))}function lr(e,n,l,o){if(n.subtreeFlags&10256)for(n=n.child;n!==null;)kh(e,n,l,o),n=n.sibling}function kh(e,n,l,o){var f=n.flags;switch(n.tag){case 0:case 11:case 15:lr(e,n,l,o),f&2048&&vs(9,n);break;case 1:lr(e,n,l,o);break;case 3:lr(e,n,l,o),f&2048&&(e=null,n.alternate!==null&&(e=n.alternate.memoizedState.cache),n=n.memoizedState.cache,n!==e&&(n.refCount++,e!=null&&ls(e)));break;case 12:if(f&2048){lr(e,n,l,o),e=n.stateNode;try{var g=n.memoizedProps,j=g.id,A=g.onPostCommit;typeof A=="function"&&A(j,n.alternate===null?"mount":"update",e.passiveEffectDuration,-0)}catch(V){ft(n,n.return,V)}}else lr(e,n,l,o);break;case 31:lr(e,n,l,o);break;case 13:lr(e,n,l,o);break;case 23:break;case 22:g=n.stateNode,j=n.alternate,n.memoizedState!==null?g._visibility&2?lr(e,n,l,o):bs(e,n):g._visibility&2?lr(e,n,l,o):(g._visibility|=2,Sl(e,n,l,o,(n.subtreeFlags&10256)!==0||!1)),f&2048&&Ou(j,n);break;case 24:lr(e,n,l,o),f&2048&&Bu(n.alternate,n);break;default:lr(e,n,l,o)}}function Sl(e,n,l,o,f){for(f=f&&((n.subtreeFlags&10256)!==0||!1),n=n.child;n!==null;){var g=e,j=n,A=l,V=o,ee=j.flags;switch(j.tag){case 0:case 11:case 15:Sl(g,j,A,V,f),vs(8,j);break;case 23:break;case 22:var ue=j.stateNode;j.memoizedState!==null?ue._visibility&2?Sl(g,j,A,V,f):bs(g,j):(ue._visibility|=2,Sl(g,j,A,V,f)),f&&ee&2048&&Ou(j.alternate,j);break;case 24:Sl(g,j,A,V,f),f&&ee&2048&&Bu(j.alternate,j);break;default:Sl(g,j,A,V,f)}n=n.sibling}}function bs(e,n){if(n.subtreeFlags&10256)for(n=n.child;n!==null;){var l=e,o=n,f=o.flags;switch(o.tag){case 22:bs(l,o),f&2048&&Ou(o.alternate,o);break;case 24:bs(l,o),f&2048&&Bu(o.alternate,o);break;default:bs(l,o)}n=n.sibling}}var js=8192;function kl(e,n,l){if(e.subtreeFlags&js)for(e=e.child;e!==null;)wh(e,n,l),e=e.sibling}function wh(e,n,l){switch(e.tag){case 26:kl(e,n,l),e.flags&js&&e.memoizedState!==null&&C0(l,ar,e.memoizedState,e.memoizedProps);break;case 5:kl(e,n,l);break;case 3:case 4:var o=ar;ar=uo(e.stateNode.containerInfo),kl(e,n,l),ar=o;break;case 22:e.memoizedState===null&&(o=e.alternate,o!==null&&o.memoizedState!==null?(o=js,js=16777216,kl(e,n,l),js=o):kl(e,n,l));break;default:kl(e,n,l)}}function Ch(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 Ss(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];Jt=o,Nh(o,e)}Ch(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Eh(e),e=e.sibling}function Eh(e){switch(e.tag){case 0:case 11:case 15:Ss(e),e.flags&2048&&ea(9,e,e.return);break;case 3:Ss(e);break;case 12:Ss(e);break;case 22:var n=e.stateNode;e.memoizedState!==null&&n._visibility&2&&(e.return===null||e.return.tag!==13)?(n._visibility&=-3,Qi(e)):Ss(e);break;default:Ss(e)}}function Qi(e){var n=e.deletions;if((e.flags&16)!==0){if(n!==null)for(var l=0;l<n.length;l++){var o=n[l];Jt=o,Nh(o,e)}Ch(e)}for(e=e.child;e!==null;){switch(n=e,n.tag){case 0:case 11:case 15:ea(8,n,n.return),Qi(n);break;case 22:l=n.stateNode,l._visibility&2&&(l._visibility&=-3,Qi(n));break;default:Qi(n)}e=e.sibling}}function Nh(e,n){for(;Jt!==null;){var l=Jt;switch(l.tag){case 0:case 11:case 15:ea(8,l,n);break;case 23:case 22:if(l.memoizedState!==null&&l.memoizedState.cachePool!==null){var o=l.memoizedState.cachePool.pool;o!=null&&o.refCount++}break;case 24:ls(l.memoizedState.cache)}if(o=l.child,o!==null)o.return=l,Jt=o;else e:for(l=e;Jt!==null;){o=Jt;var f=o.sibling,g=o.return;if(gh(o),o===l){Jt=null;break e}if(f!==null){f.return=g,Jt=f;break e}Jt=g}}}var U1={getCacheForType:function(e){var n=ln($t),l=n.data.get(e);return l===void 0&&(l=e(),n.data.set(e,l)),l},cacheSignal:function(){return ln($t).controller.signal}},H1=typeof WeakMap=="function"?WeakMap:Map,st=0,yt=null,Ke=null,Qe=0,dt=0,zn=null,ta=!1,wl=!1,Iu=!1,Or=0,Dt=0,na=0,$a=0,$u=0,Dn=0,Cl=0,ks=null,kn=null,Uu=!1,Zi=0,Th=0,Ji=1/0,eo=null,ra=null,Gt=0,aa=null,El=null,Br=0,Hu=0,Pu=null,Rh=null,ws=0,Vu=null;function _n(){return(st&2)!==0&&Qe!==0?Qe&-Qe:M.T!==null?Ku():ja()}function Ah(){if(Dn===0)if((Qe&536870912)===0||Je){var e=Hn;Hn<<=1,(Hn&3932160)===0&&(Hn=262144),Dn=e}else Dn=536870912;return e=Mn.current,e!==null&&(e.flags|=32),Dn}function wn(e,n,l){(e===yt&&(dt===2||dt===9)||e.cancelPendingCommit!==null)&&(Nl(e,0),la(e,Qe,Dn,!1)),ie(e,l),((st&2)===0||e!==yt)&&(e===yt&&((st&2)===0&&($a|=l),Dt===4&&la(e,Qe,Dn,!1)),pr(e))}function Mh(e,n,l){if((st&6)!==0)throw Error(i(327));var o=!l&&(n&127)===0&&(n&e.expiredLanes)===0||Ue(e,n),f=o?F1(e,n):Gu(e,n,!0),g=o;do{if(f===0){wl&&!o&&la(e,n,0,!1);break}else{if(l=e.current.alternate,g&&!P1(l)){f=Gu(e,n,!1),g=!1;continue}if(f===2){if(g=n,e.errorRecoveryDisabledLanes&g)var j=0;else j=e.pendingLanes&-536870913,j=j!==0?j:j&536870912?536870912:0;if(j!==0){n=j;e:{var A=e;f=ks;var V=A.current.memoizedState.isDehydrated;if(V&&(Nl(A,j).flags|=256),j=Gu(A,j,!1),j!==2){if(Iu&&!V){A.errorRecoveryDisabledLanes|=g,$a|=g,f=4;break e}g=kn,kn=f,g!==null&&(kn===null?kn=g:kn.push.apply(kn,g))}f=j}if(g=!1,f!==2)continue}}if(f===1){Nl(e,0),la(e,n,0,!0);break}e:{switch(o=e,g=f,g){case 0:case 1:throw Error(i(345));case 4:if((n&4194048)!==n)break;case 6:la(o,n,Dn,!ta);break e;case 2:kn=null;break;case 3:case 5:break;default:throw Error(i(329))}if((n&62914560)===n&&(f=Zi+300-Ge(),10<f)){if(la(o,n,Dn,!ta),nn(o,0,!0)!==0)break e;Br=n,o.timeoutHandle=ox(Lh.bind(null,o,l,kn,eo,Uu,n,Dn,$a,Cl,ta,g,"Throttled",-0,0),f);break e}Lh(o,l,kn,eo,Uu,n,Dn,$a,Cl,ta,g,null,-0,0)}}break}while(!0);pr(e)}function Lh(e,n,l,o,f,g,j,A,V,ee,ue,pe,ne,le){if(e.timeoutHandle=-1,pe=n.subtreeFlags,pe&8192||(pe&16785408)===16785408){pe={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Sr},wh(n,g,pe);var Ce=(g&62914560)===g?Zi-Ge():(g&4194048)===g?Th-Ge():0;if(Ce=E0(pe,Ce),Ce!==null){Br=g,e.cancelPendingCommit=Ce(Uh.bind(null,e,n,g,l,o,f,j,A,V,ue,pe,null,ne,le)),la(e,g,j,!ee);return}}Uh(e,n,g,l,o,f,j,A,V)}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 o=0;o<l.length;o++){var f=l[o],g=f.getSnapshot;f=f.value;try{if(!Rn(g(),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 la(e,n,l,o){n&=~$u,n&=~$a,e.suspendedLanes|=n,e.pingedLanes&=~n,o&&(e.warmLanes|=n),o=e.expirationTimes;for(var f=n;0<f;){var g=31-It(f),j=1<<g;o[g]=-1,f&=~j}l!==0&&Ae(e,l,n)}function to(){return(st&6)===0?(Cs(0),!1):!0}function Fu(){if(Ke!==null){if(dt===0)var e=Ke.return;else e=Ke,Er=Aa=null,su(e),gl=null,is=0,e=Ke;for(;e!==null;)ch(e.alternate,e),e=e.return;Ke=null}}function Nl(e,n){var l=e.timeoutHandle;l!==-1&&(e.timeoutHandle=-1,o0(l)),l=e.cancelPendingCommit,l!==null&&(e.cancelPendingCommit=null,l()),Br=0,Fu(),yt=e,Ke=l=wr(e.current,null),Qe=n,dt=0,zn=null,ta=!1,wl=Ue(e,n),Iu=!1,Cl=Dn=$u=$a=na=Dt=0,kn=ks=null,Uu=!1,(n&8)!==0&&(n|=n&32);var o=e.entangledLanes;if(o!==0)for(e=e.entanglements,o&=n;0<o;){var f=31-It(o),g=1<<f;n|=e[f],o&=~g}return Or=n,Si(),l}function zh(e,n){Fe=null,M.H=hs,n===xl||n===Ai?(n=Kp(),dt=3):n===Yc?(n=Kp(),dt=4):dt=n===Su?8:n!==null&&typeof n=="object"&&typeof n.then=="function"?6:1,zn=n,Ke===null&&(Dt=1,Fi(e,Gn(n,e.current)))}function Dh(){var e=Mn.current;return e===null?!0:(Qe&4194048)===Qe?Kn===null:(Qe&62914560)===Qe||(Qe&536870912)!==0?e===Kn:!1}function _h(){var e=M.H;return M.H=hs,e===null?hs:e}function Oh(){var e=M.A;return M.A=U1,e}function no(){Dt=4,ta||(Qe&4194048)!==Qe&&Mn.current!==null||(wl=!0),(na&134217727)===0&&($a&134217727)===0||yt===null||la(yt,Qe,Dn,!1)}function Gu(e,n,l){var o=st;st|=2;var f=_h(),g=Oh();(yt!==e||Qe!==n)&&(eo=null,Nl(e,n)),n=!1;var j=Dt;e:do try{if(dt!==0&&Ke!==null){var A=Ke,V=zn;switch(dt){case 8:Fu(),j=6;break e;case 3:case 2:case 9:case 6:Mn.current===null&&(n=!0);var ee=dt;if(dt=0,zn=null,Tl(e,A,V,ee),l&&wl){j=0;break e}break;default:ee=dt,dt=0,zn=null,Tl(e,A,V,ee)}}V1(),j=Dt;break}catch(ue){zh(e,ue)}while(!0);return n&&e.shellSuspendCounter++,Er=Aa=null,st=o,M.H=f,M.A=g,Ke===null&&(yt=null,Qe=0,Si()),j}function V1(){for(;Ke!==null;)Bh(Ke)}function F1(e,n){var l=st;st|=2;var o=_h(),f=Oh();yt!==e||Qe!==n?(eo=null,Ji=Ge()+500,Nl(e,n)):wl=Ue(e,n);e:do try{if(dt!==0&&Ke!==null){n=Ke;var g=zn;t:switch(dt){case 1:dt=0,zn=null,Tl(e,n,g,1);break;case 2:case 9:if(qp(g)){dt=0,zn=null,Ih(n);break}n=function(){dt!==2&&dt!==9||yt!==e||(dt=7),pr(e)},g.then(n,n);break e;case 3:dt=7;break e;case 4:dt=5;break e;case 7:qp(g)?(dt=0,zn=null,Ih(n)):(dt=0,zn=null,Tl(e,n,g,7));break;case 5:var j=null;switch(Ke.tag){case 26:j=Ke.memoizedState;case 5:case 27:var A=Ke;if(j?kx(j):A.stateNode.complete){dt=0,zn=null;var V=A.sibling;if(V!==null)Ke=V;else{var ee=A.return;ee!==null?(Ke=ee,ro(ee)):Ke=null}break t}}dt=0,zn=null,Tl(e,n,g,5);break;case 6:dt=0,zn=null,Tl(e,n,g,6);break;case 8:Fu(),Dt=6;break e;default:throw Error(i(462))}}G1();break}catch(ue){zh(e,ue)}while(!0);return Er=Aa=null,M.H=o,M.A=f,st=l,Ke!==null?0:(yt=null,Qe=0,Si(),Dt)}function G1(){for(;Ke!==null&&!tn();)Bh(Ke)}function Bh(e){var n=ih(e.alternate,e,Or);e.memoizedProps=e.pendingProps,n===null?ro(e):Ke=n}function Ih(e){var n=e,l=n.alternate;switch(n.tag){case 15:case 0:n=th(l,n,n.pendingProps,n.type,void 0,Qe);break;case 11:n=th(l,n,n.pendingProps,n.type.render,n.ref,Qe);break;case 5:su(n);default:ch(l,n),n=Ke=Op(n,Or),n=ih(l,n,Or)}e.memoizedProps=e.pendingProps,n===null?ro(e):Ke=n}function Tl(e,n,l,o){Er=Aa=null,su(n),gl=null,is=0;var f=n.return;try{if(z1(e,f,n,l,Qe)){Dt=1,Fi(e,Gn(l,e.current)),Ke=null;return}}catch(g){if(f!==null)throw Ke=f,g;Dt=1,Fi(e,Gn(l,e.current)),Ke=null;return}n.flags&32768?(Je||o===1?e=!0:wl||(Qe&536870912)!==0?e=!1:(ta=e=!0,(o===2||o===9||o===3||o===6)&&(o=Mn.current,o!==null&&o.tag===13&&(o.flags|=16384))),$h(n,e)):ro(n)}function ro(e){var n=e;do{if((n.flags&32768)!==0){$h(n,ta);return}e=n.return;var l=O1(n.alternate,n,Or);if(l!==null){Ke=l;return}if(n=n.sibling,n!==null){Ke=n;return}Ke=n=e}while(n!==null);Dt===0&&(Dt=5)}function $h(e,n){do{var l=B1(e.alternate,e);if(l!==null){l.flags&=32767,Ke=l;return}if(l=e.return,l!==null&&(l.flags|=32768,l.subtreeFlags=0,l.deletions=null),!n&&(e=e.sibling,e!==null)){Ke=e;return}Ke=e=l}while(e!==null);Dt=6,Ke=null}function Uh(e,n,l,o,f,g,j,A,V){e.cancelPendingCommit=null;do ao();while(Gt!==0);if((st&6)!==0)throw Error(i(327));if(n!==null){if(n===e.current)throw Error(i(177));if(g=n.lanes|n.childLanes,g|=zc,Se(e,l,g,j,A,V),e===yt&&(Ke=yt=null,Qe=0),El=n,aa=e,Br=l,Hu=g,Pu=f,Rh=o,(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?(e.callbackNode=null,e.callbackPriority=0,K1(Kt,function(){return Gh(),null})):(e.callbackNode=null,e.callbackPriority=0),o=(n.flags&13878)!==0,(n.subtreeFlags&13878)!==0||o){o=M.T,M.T=null,f=I.p,I.p=2,j=st,st|=4;try{I1(e,n,l)}finally{st=j,I.p=f,M.T=o}}Gt=1,Hh(),Ph(),Vh()}}function Hh(){if(Gt===1){Gt=0;var e=aa,n=El,l=(n.flags&13878)!==0;if((n.subtreeFlags&13878)!==0||l){l=M.T,M.T=null;var o=I.p;I.p=2;var f=st;st|=4;try{jh(n,e);var g=rd,j=Np(e.containerInfo),A=g.focusedElem,V=g.selectionRange;if(j!==A&&A&&A.ownerDocument&&Ep(A.ownerDocument.documentElement,A)){if(V!==null&&Tc(A)){var ee=V.start,ue=V.end;if(ue===void 0&&(ue=ee),"selectionStart"in A)A.selectionStart=ee,A.selectionEnd=Math.min(ue,A.value.length);else{var pe=A.ownerDocument||document,ne=pe&&pe.defaultView||window;if(ne.getSelection){var le=ne.getSelection(),Ce=A.textContent.length,ze=Math.min(V.start,Ce),gt=V.end===void 0?ze:Math.min(V.end,Ce);!le.extend&&ze>gt&&(j=gt,gt=ze,ze=j);var K=Cp(A,ze),G=Cp(A,gt);if(K&&G&&(le.rangeCount!==1||le.anchorNode!==K.node||le.anchorOffset!==K.offset||le.focusNode!==G.node||le.focusOffset!==G.offset)){var Z=pe.createRange();Z.setStart(K.node,K.offset),le.removeAllRanges(),ze>gt?(le.addRange(Z),le.extend(G.node,G.offset)):(Z.setEnd(G.node,G.offset),le.addRange(Z))}}}}for(pe=[],le=A;le=le.parentNode;)le.nodeType===1&&pe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;A<pe.length;A++){var fe=pe[A];fe.element.scrollLeft=fe.left,fe.element.scrollTop=fe.top}}go=!!nd,rd=nd=null}finally{st=f,I.p=o,M.T=l}}e.current=n,Gt=2}}function Ph(){if(Gt===2){Gt=0;var e=aa,n=El,l=(n.flags&8772)!==0;if((n.subtreeFlags&8772)!==0||l){l=M.T,M.T=null;var o=I.p;I.p=2;var f=st;st|=4;try{xh(e,n.alternate,n)}finally{st=f,I.p=o,M.T=l}}Gt=3}}function Vh(){if(Gt===4||Gt===3){Gt=0,bt();var e=aa,n=El,l=Br,o=Rh;(n.subtreeFlags&10256)!==0||(n.flags&10256)!==0?Gt=5:(Gt=0,El=aa=null,Fh(e,e.pendingLanes));var f=e.pendingLanes;if(f===0&&(ra=null),Vr(l),n=n.stateNode,ut&&typeof ut.onCommitFiberRoot=="function")try{ut.onCommitFiberRoot(Lt,n,void 0,(n.current.flags&128)===128)}catch{}if(o!==null){n=M.T,f=I.p,I.p=2,M.T=null;try{for(var g=e.onRecoverableError,j=0;j<o.length;j++){var A=o[j];g(A.value,{componentStack:A.stack})}}finally{M.T=n,I.p=f}}(Br&3)!==0&&ao(),pr(e),f=e.pendingLanes,(l&261930)!==0&&(f&42)!==0?e===Vu?ws++:(ws=0,Vu=e):ws=0,Cs(0)}}function Fh(e,n){(e.pooledCacheLanes&=n)===0&&(n=e.pooledCache,n!=null&&(e.pooledCache=null,ls(n)))}function ao(){return Hh(),Ph(),Vh(),Gh()}function Gh(){if(Gt!==5)return!1;var e=aa,n=Hu;Hu=0;var l=Vr(Br),o=M.T,f=I.p;try{I.p=32>l?32:l,M.T=null,l=Pu,Pu=null;var g=aa,j=Br;if(Gt=0,El=aa=null,Br=0,(st&6)!==0)throw Error(i(331));var A=st;if(st|=4,Eh(g.current),kh(g,g.current,j,l),st=A,Cs(0,!1),ut&&typeof ut.onPostCommitFiberRoot=="function")try{ut.onPostCommitFiberRoot(Lt,g)}catch{}return!0}finally{I.p=f,M.T=o,Fh(e,n)}}function Wh(e,n,l){n=Gn(l,n),n=ju(e.stateNode,n,2),e=Qr(e,n,2),e!==null&&(ie(e,2),pr(e))}function ft(e,n,l){if(e.tag===3)Wh(e,e,l);else for(;n!==null;){if(n.tag===3){Wh(n,e,l);break}else if(n.tag===1){var o=n.stateNode;if(typeof n.type.getDerivedStateFromError=="function"||typeof o.componentDidCatch=="function"&&(ra===null||!ra.has(o))){e=Gn(l,e),l=qm(2),o=Qr(n,l,2),o!==null&&(Ym(l,o,n,e),ie(o,2),pr(o));break}}n=n.return}}function Wu(e,n,l){var o=e.pingCache;if(o===null){o=e.pingCache=new H1;var f=new Set;o.set(n,f)}else f=o.get(n),f===void 0&&(f=new Set,o.set(n,f));f.has(l)||(Iu=!0,f.add(l),e=W1.bind(null,e,n,l),n.then(e,e))}function W1(e,n,l){var o=e.pingCache;o!==null&&o.delete(n),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,yt===e&&(Qe&l)===l&&(Dt===4||Dt===3&&(Qe&62914560)===Qe&&300>Ge()-Zi?(st&2)===0&&Nl(e,0):$u|=l,Cl===Qe&&(Cl=0)),pr(e)}function qh(e,n){n===0&&(n=Qt()),e=Na(e,n),e!==null&&(ie(e,n),pr(e))}function q1(e){var n=e.memoizedState,l=0;n!==null&&(l=n.retryLane),qh(e,l)}function Y1(e,n){var l=0;switch(e.tag){case 31:case 13:var o=e.stateNode,f=e.memoizedState;f!==null&&(l=f.retryLane);break;case 19:o=e.stateNode;break;case 22:o=e.stateNode._retryCache;break;default:throw Error(i(314))}o!==null&&o.delete(n),qh(e,l)}function K1(e,n){return ct(e,n)}var lo=null,Rl=null,qu=!1,so=!1,Yu=!1,sa=0;function pr(e){e!==Rl&&e.next===null&&(Rl===null?lo=Rl=e:Rl=Rl.next=e),so=!0,qu||(qu=!0,Q1())}function Cs(e,n){if(!Yu&&so){Yu=!0;do for(var l=!1,o=lo;o!==null;){if(e!==0){var f=o.pendingLanes;if(f===0)var g=0;else{var j=o.suspendedLanes,A=o.pingedLanes;g=(1<<31-It(42|e)+1)-1,g&=f&~(j&~A),g=g&201326741?g&201326741|1:g?g|2:0}g!==0&&(l=!0,Qh(o,g))}else g=Qe,g=nn(o,o===yt?g:0,o.cancelPendingCommit!==null||o.timeoutHandle!==-1),(g&3)===0||Ue(o,g)||(l=!0,Qh(o,g));o=o.next}while(l);Yu=!1}}function X1(){Yh()}function Yh(){so=qu=!1;var e=0;sa!==0&&i0()&&(e=sa);for(var n=Ge(),l=null,o=lo;o!==null;){var f=o.next,g=Kh(o,n);g===0?(o.next=null,l===null?lo=f:l.next=f,f===null&&(Rl=l)):(l=o,(e!==0||(g&3)!==0)&&(so=!0)),o=f}Gt!==0&&Gt!==5||Cs(e),sa!==0&&(sa=0)}function Kh(e,n){for(var l=e.suspendedLanes,o=e.pingedLanes,f=e.expirationTimes,g=e.pendingLanes&-62914561;0<g;){var j=31-It(g),A=1<<j,V=f[j];V===-1?((A&l)===0||(A&o)!==0)&&(f[j]=lt(A,n)):V<=n&&(e.expiredLanes|=A),g&=~A}if(n=yt,l=Qe,l=nn(e,e===n?l:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o=e.callbackNode,l===0||e===n&&(dt===2||dt===9)||e.cancelPendingCommit!==null)return o!==null&&o!==null&&Nt(o),e.callbackNode=null,e.callbackPriority=0;if((l&3)===0||Ue(e,l)){if(n=l&-l,n===e.callbackPriority)return n;switch(o!==null&&Nt(o),Vr(l)){case 2:case 8:l=jt;break;case 32:l=Kt;break;case 268435456:l=tt;break;default:l=Kt}return o=Xh.bind(null,e),l=ct(l,o),e.callbackPriority=n,e.callbackNode=l,n}return o!==null&&o!==null&&Nt(o),e.callbackPriority=2,e.callbackNode=null,2}function Xh(e,n){if(Gt!==0&&Gt!==5)return e.callbackNode=null,e.callbackPriority=0,null;var l=e.callbackNode;if(ao()&&e.callbackNode!==l)return null;var o=Qe;return o=nn(e,e===yt?o:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),o===0?null:(Mh(e,o,n),Kh(e,Ge()),e.callbackNode!=null&&e.callbackNode===l?Xh.bind(null,e):null)}function Qh(e,n){if(ao())return null;Mh(e,n,!0)}function Q1(){c0(function(){(st&6)!==0?ct(mt,X1):Yh()})}function Ku(){if(sa===0){var e=ml;e===0&&(e=Cn,Cn<<=1,(Cn&261888)===0&&(Cn=256)),sa=e}return sa}function Zh(e){return e==null||typeof e=="symbol"||typeof e=="boolean"?null:typeof e=="function"?e:mi(""+e)}function Jh(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 Z1(e,n,l,o,f){if(n==="submit"&&l&&l.stateNode===f){var g=Zh((f[Ft]||null).action),j=o.submitter;j&&(n=(n=j[Ft]||null)?Zh(n.formAction):j.getAttribute("formAction"),n!==null&&(g=n,j=null));var A=new vi("action","action",null,o,f);e.push({event:A,listeners:[{instance:null,listener:function(){if(o.defaultPrevented){if(sa!==0){var V=j?Jh(f,j):new FormData(f);hu(l,{pending:!0,data:V,method:f.method,action:g},null,V)}}else typeof g=="function"&&(A.preventDefault(),V=j?Jh(f,j):new FormData(f),hu(l,{pending:!0,data:V,method:f.method,action:g},g,V))},currentTarget:f}]})}}for(var Xu=0;Xu<Lc.length;Xu++){var Qu=Lc[Xu],J1=Qu.toLowerCase(),e0=Qu[0].toUpperCase()+Qu.slice(1);rr(J1,"on"+e0)}rr(Ap,"onAnimationEnd"),rr(Mp,"onAnimationIteration"),rr(Lp,"onAnimationStart"),rr("dblclick","onDoubleClick"),rr("focusin","onFocus"),rr("focusout","onBlur"),rr(x1,"onTransitionRun"),rr(g1,"onTransitionStart"),rr(v1,"onTransitionCancel"),rr(zp,"onTransitionEnd"),el("onMouseEnter",["mouseout","mouseover"]),el("onMouseLeave",["mouseout","mouseover"]),el("onPointerEnter",["pointerout","pointerover"]),el("onPointerLeave",["pointerout","pointerover"]),ka("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),ka("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),ka("onBeforeInput",["compositionend","keypress","textInput","paste"]),ka("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),ka("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),ka("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Es="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(" "),t0=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Es));function ex(e,n){n=(n&4)!==0;for(var l=0;l<e.length;l++){var o=e[l],f=o.event;o=o.listeners;e:{var g=void 0;if(n)for(var j=o.length-1;0<=j;j--){var A=o[j],V=A.instance,ee=A.currentTarget;if(A=A.listener,V!==g&&f.isPropagationStopped())break e;g=A,f.currentTarget=ee;try{g(f)}catch(ue){ji(ue)}f.currentTarget=null,g=V}else for(j=0;j<o.length;j++){if(A=o[j],V=A.instance,ee=A.currentTarget,A=A.listener,V!==g&&f.isPropagationStopped())break e;g=A,f.currentTarget=ee;try{g(f)}catch(ue){ji(ue)}f.currentTarget=null,g=V}}}}function Xe(e,n){var l=n[Wl];l===void 0&&(l=n[Wl]=new Set);var o=e+"__bubble";l.has(o)||(tx(n,e,2,!1),l.add(o))}function Zu(e,n,l){var o=0;n&&(o|=4),tx(l,e,o,n)}var io="_reactListening"+Math.random().toString(36).slice(2);function Ju(e){if(!e[io]){e[io]=!0,Yf.forEach(function(l){l!=="selectionchange"&&(t0.has(l)||Zu(l,!1,e),Zu(l,!0,e))});var n=e.nodeType===9?e:e.ownerDocument;n===null||n[io]||(n[io]=!0,Zu("selectionchange",!1,n))}}function tx(e,n,l,o){switch(Ax(n)){case 2:var f=R0;break;case 8:f=A0;break;default:f=md}l=f.bind(null,n,l,e),f=void 0,!yc||n!=="touchstart"&&n!=="touchmove"&&n!=="wheel"||(f=!0),o?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 ed(e,n,l,o,f){var g=o;if((n&1)===0&&(n&2)===0&&o!==null)e:for(;;){if(o===null)return;var j=o.tag;if(j===3||j===4){var A=o.stateNode.containerInfo;if(A===f)break;if(j===4)for(j=o.return;j!==null;){var V=j.tag;if((V===3||V===4)&&j.stateNode.containerInfo===f)return;j=j.return}for(;A!==null;){if(j=Qa(A),j===null)return;if(V=j.tag,V===5||V===6||V===26||V===27){o=g=j;continue e}A=A.parentNode}}o=o.return}sp(function(){var ee=g,ue=gc(l),pe=[];e:{var ne=Dp.get(e);if(ne!==void 0){var le=vi,Ce=e;switch(e){case"keypress":if(xi(l)===0)break e;case"keydown":case"keyup":le=Yb;break;case"focusin":Ce="focus",le=kc;break;case"focusout":Ce="blur",le=kc;break;case"beforeblur":case"afterblur":le=kc;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":le=cp;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":le=Ob;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":le=Qb;break;case Ap:case Mp:case Lp:le=$b;break;case zp:le=Jb;break;case"scroll":case"scrollend":le=Db;break;case"wheel":le=t1;break;case"copy":case"cut":case"paste":le=Hb;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":le=dp;break;case"toggle":case"beforetoggle":le=r1}var ze=(n&4)!==0,gt=!ze&&(e==="scroll"||e==="scrollend"),K=ze?ne!==null?ne+"Capture":null:ne;ze=[];for(var G=ee,Z;G!==null;){var fe=G;if(Z=fe.stateNode,fe=fe.tag,fe!==5&&fe!==26&&fe!==27||Z===null||K===null||(fe=Yl(G,K),fe!=null&&ze.push(Ns(G,fe,Z))),gt)break;G=G.return}0<ze.length&&(ne=new le(ne,Ce,null,l,ue),pe.push({event:ne,listeners:ze}))}}if((n&7)===0){e:{if(ne=e==="mouseover"||e==="pointerover",le=e==="mouseout"||e==="pointerout",ne&&l!==xc&&(Ce=l.relatedTarget||l.fromElement)&&(Qa(Ce)||Ce[Tn]))break e;if((le||ne)&&(ne=ue.window===ue?ue:(ne=ue.ownerDocument)?ne.defaultView||ne.parentWindow:window,le?(Ce=l.relatedTarget||l.toElement,le=ee,Ce=Ce?Qa(Ce):null,Ce!==null&&(gt=u(Ce),ze=Ce.tag,Ce!==gt||ze!==5&&ze!==27&&ze!==6)&&(Ce=null)):(le=null,Ce=ee),le!==Ce)){if(ze=cp,fe="onMouseLeave",K="onMouseEnter",G="mouse",(e==="pointerout"||e==="pointerover")&&(ze=dp,fe="onPointerLeave",K="onPointerEnter",G="pointer"),gt=le==null?ne:ql(le),Z=Ce==null?ne:ql(Ce),ne=new ze(fe,G+"leave",le,l,ue),ne.target=gt,ne.relatedTarget=Z,fe=null,Qa(ue)===ee&&(ze=new ze(K,G+"enter",Ce,l,ue),ze.target=Z,ze.relatedTarget=gt,fe=ze),gt=fe,le&&Ce)t:{for(ze=n0,K=le,G=Ce,Z=0,fe=K;fe;fe=ze(fe))Z++;fe=0;for(var Me=G;Me;Me=ze(Me))fe++;for(;0<Z-fe;)K=ze(K),Z--;for(;0<fe-Z;)G=ze(G),fe--;for(;Z--;){if(K===G||G!==null&&K===G.alternate){ze=K;break t}K=ze(K),G=ze(G)}ze=null}else ze=null;le!==null&&nx(pe,ne,le,ze,!1),Ce!==null&>!==null&&nx(pe,gt,Ce,ze,!0)}}e:{if(ne=ee?ql(ee):window,le=ne.nodeName&&ne.nodeName.toLowerCase(),le==="select"||le==="input"&&ne.type==="file")var nt=yp;else if(gp(ne))if(bp)nt=p1;else{nt=d1;var Ee=u1}else le=ne.nodeName,!le||le.toLowerCase()!=="input"||ne.type!=="checkbox"&&ne.type!=="radio"?ee&&hc(ee.elementType)&&(nt=yp):nt=f1;if(nt&&(nt=nt(e,ee))){vp(pe,nt,l,ue);break e}Ee&&Ee(e,ne,ee),e==="focusout"&&ee&&ne.type==="number"&&ee.memoizedProps.value!=null&&mc(ne,"number",ne.value)}switch(Ee=ee?ql(ee):window,e){case"focusin":(gp(Ee)||Ee.contentEditable==="true")&&(sl=Ee,Rc=ee,ns=null);break;case"focusout":ns=Rc=sl=null;break;case"mousedown":Ac=!0;break;case"contextmenu":case"mouseup":case"dragend":Ac=!1,Tp(pe,l,ue);break;case"selectionchange":if(h1)break;case"keydown":case"keyup":Tp(pe,l,ue)}var We;if(Cc)e:{switch(e){case"compositionstart":var Ze="onCompositionStart";break e;case"compositionend":Ze="onCompositionEnd";break e;case"compositionupdate":Ze="onCompositionUpdate";break e}Ze=void 0}else ll?hp(e,l)&&(Ze="onCompositionEnd"):e==="keydown"&&l.keyCode===229&&(Ze="onCompositionStart");Ze&&(fp&&l.locale!=="ko"&&(ll||Ze!=="onCompositionStart"?Ze==="onCompositionEnd"&&ll&&(We=ip()):(Fr=ue,bc="value"in Fr?Fr.value:Fr.textContent,ll=!0)),Ee=oo(ee,Ze),0<Ee.length&&(Ze=new up(Ze,e,null,l,ue),pe.push({event:Ze,listeners:Ee}),We?Ze.data=We:(We=xp(l),We!==null&&(Ze.data=We)))),(We=l1?s1(e,l):i1(e,l))&&(Ze=oo(ee,"onBeforeInput"),0<Ze.length&&(Ee=new up("onBeforeInput","beforeinput",null,l,ue),pe.push({event:Ee,listeners:Ze}),Ee.data=We)),Z1(pe,e,ee,l,ue)}ex(pe,n)})}function Ns(e,n,l){return{instance:e,listener:n,currentTarget:l}}function oo(e,n){for(var l=n+"Capture",o=[];e!==null;){var f=e,g=f.stateNode;if(f=f.tag,f!==5&&f!==26&&f!==27||g===null||(f=Yl(e,l),f!=null&&o.unshift(Ns(e,f,g)),f=Yl(e,n),f!=null&&o.push(Ns(e,f,g))),e.tag===3)return o;e=e.return}return[]}function n0(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function nx(e,n,l,o,f){for(var g=n._reactName,j=[];l!==null&&l!==o;){var A=l,V=A.alternate,ee=A.stateNode;if(A=A.tag,V!==null&&V===o)break;A!==5&&A!==26&&A!==27||ee===null||(V=ee,f?(ee=Yl(l,g),ee!=null&&j.unshift(Ns(l,ee,V))):f||(ee=Yl(l,g),ee!=null&&j.push(Ns(l,ee,V)))),l=l.return}j.length!==0&&e.push({event:n,listeners:j})}var r0=/\r\n?/g,a0=/\u0000|\uFFFD/g;function rx(e){return(typeof e=="string"?e:""+e).replace(r0,`
|
|
50
|
-
`).replace(a0,"")}function ax(e,n){return n=rx(n),rx(e)===n}function xt(e,n,l,o,f,g){switch(l){case"children":typeof o=="string"?n==="body"||n==="textarea"&&o===""||nl(e,o):(typeof o=="number"||typeof o=="bigint")&&n!=="body"&&nl(e,""+o);break;case"className":fi(e,"class",o);break;case"tabIndex":fi(e,"tabindex",o);break;case"dir":case"role":case"viewBox":case"width":case"height":fi(e,l,o);break;case"style":ap(e,o,g);break;case"data":if(n!=="object"){fi(e,"data",o);break}case"src":case"href":if(o===""&&(n!=="a"||l!=="href")){e.removeAttribute(l);break}if(o==null||typeof o=="function"||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=mi(""+o),e.setAttribute(l,o);break;case"action":case"formAction":if(typeof o=="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 g=="function"&&(l==="formAction"?(n!=="input"&&xt(e,n,"name",f.name,f,null),xt(e,n,"formEncType",f.formEncType,f,null),xt(e,n,"formMethod",f.formMethod,f,null),xt(e,n,"formTarget",f.formTarget,f,null)):(xt(e,n,"encType",f.encType,f,null),xt(e,n,"method",f.method,f,null),xt(e,n,"target",f.target,f,null)));if(o==null||typeof o=="symbol"||typeof o=="boolean"){e.removeAttribute(l);break}o=mi(""+o),e.setAttribute(l,o);break;case"onClick":o!=null&&(e.onclick=Sr);break;case"onScroll":o!=null&&Xe("scroll",e);break;case"onScrollEnd":o!=null&&Xe("scrollend",e);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(i(61));if(l=o.__html,l!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"multiple":e.multiple=o&&typeof o!="function"&&typeof o!="symbol";break;case"muted":e.muted=o&&typeof o!="function"&&typeof o!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(o==null||typeof o=="function"||typeof o=="boolean"||typeof o=="symbol"){e.removeAttribute("xlink:href");break}l=mi(""+o),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":o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""+o):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":o&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,""):e.removeAttribute(l);break;case"capture":case"download":o===!0?e.setAttribute(l,""):o!==!1&&o!=null&&typeof o!="function"&&typeof o!="symbol"?e.setAttribute(l,o):e.removeAttribute(l);break;case"cols":case"rows":case"size":case"span":o!=null&&typeof o!="function"&&typeof o!="symbol"&&!isNaN(o)&&1<=o?e.setAttribute(l,o):e.removeAttribute(l);break;case"rowSpan":case"start":o==null||typeof o=="function"||typeof o=="symbol"||isNaN(o)?e.removeAttribute(l):e.setAttribute(l,o);break;case"popover":Xe("beforetoggle",e),Xe("toggle",e),di(e,"popover",o);break;case"xlinkActuate":jr(e,"http://www.w3.org/1999/xlink","xlink:actuate",o);break;case"xlinkArcrole":jr(e,"http://www.w3.org/1999/xlink","xlink:arcrole",o);break;case"xlinkRole":jr(e,"http://www.w3.org/1999/xlink","xlink:role",o);break;case"xlinkShow":jr(e,"http://www.w3.org/1999/xlink","xlink:show",o);break;case"xlinkTitle":jr(e,"http://www.w3.org/1999/xlink","xlink:title",o);break;case"xlinkType":jr(e,"http://www.w3.org/1999/xlink","xlink:type",o);break;case"xmlBase":jr(e,"http://www.w3.org/XML/1998/namespace","xml:base",o);break;case"xmlLang":jr(e,"http://www.w3.org/XML/1998/namespace","xml:lang",o);break;case"xmlSpace":jr(e,"http://www.w3.org/XML/1998/namespace","xml:space",o);break;case"is":di(e,"is",o);break;case"innerText":case"textContent":break;default:(!(2<l.length)||l[0]!=="o"&&l[0]!=="O"||l[1]!=="n"&&l[1]!=="N")&&(l=Lb.get(l)||l,di(e,l,o))}}function td(e,n,l,o,f,g){switch(l){case"style":ap(e,o,g);break;case"dangerouslySetInnerHTML":if(o!=null){if(typeof o!="object"||!("__html"in o))throw Error(i(61));if(l=o.__html,l!=null){if(f.children!=null)throw Error(i(60));e.innerHTML=l}}break;case"children":typeof o=="string"?nl(e,o):(typeof o=="number"||typeof o=="bigint")&&nl(e,""+o);break;case"onScroll":o!=null&&Xe("scroll",e);break;case"onScrollEnd":o!=null&&Xe("scrollend",e);break;case"onClick":o!=null&&(e.onclick=Sr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Kf.hasOwnProperty(l))e:{if(l[0]==="o"&&l[1]==="n"&&(f=l.endsWith("Capture"),n=l.slice(2,f?l.length-7:void 0),g=e[Ft]||null,g=g!=null?g[l]:null,typeof g=="function"&&e.removeEventListener(n,g,f),typeof o=="function")){typeof g!="function"&&g!==null&&(l in e?e[l]=null:e.hasAttribute(l)&&e.removeAttribute(l)),e.addEventListener(n,o,f);break e}l in e?e[l]=o:o===!0?e.setAttribute(l,""):di(e,l,o)}}}function on(e,n,l){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":Xe("error",e),Xe("load",e);var o=!1,f=!1,g;for(g in l)if(l.hasOwnProperty(g)){var j=l[g];if(j!=null)switch(g){case"src":o=!0;break;case"srcSet":f=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(i(137,n));default:xt(e,n,g,j,l,null)}}f&&xt(e,n,"srcSet",l.srcSet,l,null),o&&xt(e,n,"src",l.src,l,null);return;case"input":Xe("invalid",e);var A=g=j=f=null,V=null,ee=null;for(o in l)if(l.hasOwnProperty(o)){var ue=l[o];if(ue!=null)switch(o){case"name":f=ue;break;case"type":j=ue;break;case"checked":V=ue;break;case"defaultChecked":ee=ue;break;case"value":g=ue;break;case"defaultValue":A=ue;break;case"children":case"dangerouslySetInnerHTML":if(ue!=null)throw Error(i(137,n));break;default:xt(e,n,o,ue,l,null)}}ep(e,g,A,V,ee,j,f,!1);return;case"select":Xe("invalid",e),o=j=g=null;for(f in l)if(l.hasOwnProperty(f)&&(A=l[f],A!=null))switch(f){case"value":g=A;break;case"defaultValue":j=A;break;case"multiple":o=A;default:xt(e,n,f,A,l,null)}n=g,l=j,e.multiple=!!o,n!=null?tl(e,!!o,n,!1):l!=null&&tl(e,!!o,l,!0);return;case"textarea":Xe("invalid",e),g=f=o=null;for(j in l)if(l.hasOwnProperty(j)&&(A=l[j],A!=null))switch(j){case"value":o=A;break;case"defaultValue":f=A;break;case"children":g=A;break;case"dangerouslySetInnerHTML":if(A!=null)throw Error(i(91));break;default:xt(e,n,j,A,l,null)}np(e,o,f,g);return;case"option":for(V in l)if(l.hasOwnProperty(V)&&(o=l[V],o!=null))switch(V){case"selected":e.selected=o&&typeof o!="function"&&typeof o!="symbol";break;default:xt(e,n,V,o,l,null)}return;case"dialog":Xe("beforetoggle",e),Xe("toggle",e),Xe("cancel",e),Xe("close",e);break;case"iframe":case"object":Xe("load",e);break;case"video":case"audio":for(o=0;o<Es.length;o++)Xe(Es[o],e);break;case"image":Xe("error",e),Xe("load",e);break;case"details":Xe("toggle",e);break;case"embed":case"source":case"link":Xe("error",e),Xe("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(ee in l)if(l.hasOwnProperty(ee)&&(o=l[ee],o!=null))switch(ee){case"children":case"dangerouslySetInnerHTML":throw Error(i(137,n));default:xt(e,n,ee,o,l,null)}return;default:if(hc(n)){for(ue in l)l.hasOwnProperty(ue)&&(o=l[ue],o!==void 0&&td(e,n,ue,o,l,void 0));return}}for(A in l)l.hasOwnProperty(A)&&(o=l[A],o!=null&&xt(e,n,A,o,l,null))}function l0(e,n,l,o){switch(n){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var f=null,g=null,j=null,A=null,V=null,ee=null,ue=null;for(le in l){var pe=l[le];if(l.hasOwnProperty(le)&&pe!=null)switch(le){case"checked":break;case"value":break;case"defaultValue":V=pe;default:o.hasOwnProperty(le)||xt(e,n,le,null,o,pe)}}for(var ne in o){var le=o[ne];if(pe=l[ne],o.hasOwnProperty(ne)&&(le!=null||pe!=null))switch(ne){case"type":g=le;break;case"name":f=le;break;case"checked":ee=le;break;case"defaultChecked":ue=le;break;case"value":j=le;break;case"defaultValue":A=le;break;case"children":case"dangerouslySetInnerHTML":if(le!=null)throw Error(i(137,n));break;default:le!==pe&&xt(e,n,ne,le,o,pe)}}pc(e,j,A,V,ee,ue,g,f);return;case"select":le=j=A=ne=null;for(g in l)if(V=l[g],l.hasOwnProperty(g)&&V!=null)switch(g){case"value":break;case"multiple":le=V;default:o.hasOwnProperty(g)||xt(e,n,g,null,o,V)}for(f in o)if(g=o[f],V=l[f],o.hasOwnProperty(f)&&(g!=null||V!=null))switch(f){case"value":ne=g;break;case"defaultValue":A=g;break;case"multiple":j=g;default:g!==V&&xt(e,n,f,g,o,V)}n=A,l=j,o=le,ne!=null?tl(e,!!l,ne,!1):!!o!=!!l&&(n!=null?tl(e,!!l,n,!0):tl(e,!!l,l?[]:"",!1));return;case"textarea":le=ne=null;for(A in l)if(f=l[A],l.hasOwnProperty(A)&&f!=null&&!o.hasOwnProperty(A))switch(A){case"value":break;case"children":break;default:xt(e,n,A,null,o,f)}for(j in o)if(f=o[j],g=l[j],o.hasOwnProperty(j)&&(f!=null||g!=null))switch(j){case"value":ne=f;break;case"defaultValue":le=f;break;case"children":break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(i(91));break;default:f!==g&&xt(e,n,j,f,o,g)}tp(e,ne,le);return;case"option":for(var Ce in l)if(ne=l[Ce],l.hasOwnProperty(Ce)&&ne!=null&&!o.hasOwnProperty(Ce))switch(Ce){case"selected":e.selected=!1;break;default:xt(e,n,Ce,null,o,ne)}for(V in o)if(ne=o[V],le=l[V],o.hasOwnProperty(V)&&ne!==le&&(ne!=null||le!=null))switch(V){case"selected":e.selected=ne&&typeof ne!="function"&&typeof ne!="symbol";break;default:xt(e,n,V,ne,o,le)}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 ze in l)ne=l[ze],l.hasOwnProperty(ze)&&ne!=null&&!o.hasOwnProperty(ze)&&xt(e,n,ze,null,o,ne);for(ee in o)if(ne=o[ee],le=l[ee],o.hasOwnProperty(ee)&&ne!==le&&(ne!=null||le!=null))switch(ee){case"children":case"dangerouslySetInnerHTML":if(ne!=null)throw Error(i(137,n));break;default:xt(e,n,ee,ne,o,le)}return;default:if(hc(n)){for(var gt in l)ne=l[gt],l.hasOwnProperty(gt)&&ne!==void 0&&!o.hasOwnProperty(gt)&&td(e,n,gt,void 0,o,ne);for(ue in o)ne=o[ue],le=l[ue],!o.hasOwnProperty(ue)||ne===le||ne===void 0&&le===void 0||td(e,n,ue,ne,o,le);return}}for(var K in l)ne=l[K],l.hasOwnProperty(K)&&ne!=null&&!o.hasOwnProperty(K)&&xt(e,n,K,null,o,ne);for(pe in o)ne=o[pe],le=l[pe],!o.hasOwnProperty(pe)||ne===le||ne==null&&le==null||xt(e,n,pe,ne,o,le)}function lx(e){switch(e){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function s0(){if(typeof performance.getEntriesByType=="function"){for(var e=0,n=0,l=performance.getEntriesByType("resource"),o=0;o<l.length;o++){var f=l[o],g=f.transferSize,j=f.initiatorType,A=f.duration;if(g&&A&&lx(j)){for(j=0,A=f.responseEnd,o+=1;o<l.length;o++){var V=l[o],ee=V.startTime;if(ee>A)break;var ue=V.transferSize,pe=V.initiatorType;ue&&lx(pe)&&(V=V.responseEnd,j+=ue*(V<A?1:(A-ee)/(V-ee)))}if(--o,n+=8*(g+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 nd=null,rd=null;function co(e){return e.nodeType===9?e:e.ownerDocument}function sx(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 ix(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 ad(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 ld=null;function i0(){var e=window.event;return e&&e.type==="popstate"?e===ld?!1:(ld=e,!0):(ld=null,!1)}var ox=typeof setTimeout=="function"?setTimeout:void 0,o0=typeof clearTimeout=="function"?clearTimeout:void 0,cx=typeof Promise=="function"?Promise:void 0,c0=typeof queueMicrotask=="function"?queueMicrotask:typeof cx<"u"?function(e){return cx.resolve(null).then(e).catch(u0)}:ox;function u0(e){setTimeout(function(){throw e})}function ia(e){return e==="head"}function ux(e,n){var l=n,o=0;do{var f=l.nextSibling;if(e.removeChild(l),f&&f.nodeType===8)if(l=f.data,l==="/$"||l==="/&"){if(o===0){e.removeChild(f),zl(n);return}o--}else if(l==="$"||l==="$?"||l==="$~"||l==="$!"||l==="&")o++;else if(l==="html")Ts(e.ownerDocument.documentElement);else if(l==="head"){l=e.ownerDocument.head,Ts(l);for(var g=l.firstChild;g;){var j=g.nextSibling,A=g.nodeName;g[Sa]||A==="SCRIPT"||A==="STYLE"||A==="LINK"&&g.rel.toLowerCase()==="stylesheet"||l.removeChild(g),g=j}}else l==="body"&&Ts(e.ownerDocument.body);l=f}while(l);zl(n)}function dx(e,n){var l=e;e=0;do{var o=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||""),o&&o.nodeType===8)if(l=o.data,l==="/$"){if(e===0)break;e--}else l!=="$"&&l!=="$?"&&l!=="$~"&&l!=="$!"||e++;l=o}while(l)}function sd(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":sd(l),dc(l);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(l.rel.toLowerCase()==="stylesheet")continue}e.removeChild(l)}}function d0(e,n,l,o){for(;e.nodeType===1;){var f=l;if(e.nodeName.toLowerCase()!==n.toLowerCase()){if(!o&&(e.nodeName!=="INPUT"||e.type!=="hidden"))break}else if(o){if(!e[Sa])switch(n){case"meta":if(!e.hasAttribute("itemprop"))break;return e;case"link":if(g=e.getAttribute("rel"),g==="stylesheet"&&e.hasAttribute("data-precedence"))break;if(g!==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(g=e.getAttribute("src"),(g!==(f.src==null?null:f.src)||e.getAttribute("type")!==(f.type==null?null:f.type)||e.getAttribute("crossorigin")!==(f.crossOrigin==null?null:f.crossOrigin))&&g&&e.hasAttribute("async")&&!e.hasAttribute("itemprop"))break;return e;default:return e}}else if(n==="input"&&e.type==="hidden"){var g=f.name==null?null:""+f.name;if(f.type==="hidden"&&e.getAttribute("name")===g)return e}else return e;if(e=Xn(e.nextSibling),e===null)break}return null}function f0(e,n,l){if(n==="")return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!l||(e=Xn(e.nextSibling),e===null))return null;return e}function fx(e,n){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!=="INPUT"||e.type!=="hidden")&&!n||(e=Xn(e.nextSibling),e===null))return null;return e}function id(e){return e.data==="$?"||e.data==="$~"}function od(e){return e.data==="$!"||e.data==="$?"&&e.ownerDocument.readyState!=="loading"}function p0(e,n){var l=e.ownerDocument;if(e.data==="$~")e._reactRetry=n;else if(e.data!=="$?"||l.readyState!=="loading")n();else{var o=function(){n(),l.removeEventListener("DOMContentLoaded",o)};l.addEventListener("DOMContentLoaded",o),e._reactRetry=o}}function Xn(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 cd=null;function px(e){e=e.nextSibling;for(var n=0;e;){if(e.nodeType===8){var l=e.data;if(l==="/$"||l==="/&"){if(n===0)return Xn(e.nextSibling);n--}else l!=="$"&&l!=="$!"&&l!=="$?"&&l!=="$~"&&l!=="&"||n++}e=e.nextSibling}return null}function mx(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 hx(e,n,l){switch(n=co(l),e){case"html":if(e=n.documentElement,!e)throw Error(i(452));return e;case"head":if(e=n.head,!e)throw Error(i(453));return e;case"body":if(e=n.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Ts(e){for(var n=e.attributes;n.length;)e.removeAttributeNode(n[0]);dc(e)}var Qn=new Map,xx=new Set;function uo(e){return typeof e.getRootNode=="function"?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Ir=I.d;I.d={f:m0,r:h0,D:x0,C:g0,L:v0,m:y0,X:j0,S:b0,M:S0};function m0(){var e=Ir.f(),n=to();return e||n}function h0(e){var n=Za(e);n!==null&&n.tag===5&&n.type==="form"?zm(n):Ir.r(e)}var Al=typeof document>"u"?null:document;function gx(e,n,l){var o=Al;if(o&&typeof n=="string"&&n){var f=Vn(n);f='link[rel="'+e+'"][href="'+f+'"]',typeof l=="string"&&(f+='[crossorigin="'+l+'"]'),xx.has(f)||(xx.add(f),e={rel:e,crossOrigin:l,href:n},o.querySelector(f)===null&&(n=o.createElement("link"),on(n,"link",e),Zt(n),o.head.appendChild(n)))}}function x0(e){Ir.D(e),gx("dns-prefetch",e,null)}function g0(e,n){Ir.C(e,n),gx("preconnect",e,n)}function v0(e,n,l){Ir.L(e,n,l);var o=Al;if(o&&e&&n){var f='link[rel="preload"][as="'+Vn(n)+'"]';n==="image"&&l&&l.imageSrcSet?(f+='[imagesrcset="'+Vn(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(f+='[imagesizes="'+Vn(l.imageSizes)+'"]')):f+='[href="'+Vn(e)+'"]';var g=f;switch(n){case"style":g=Ml(e);break;case"script":g=Ll(e)}Qn.has(g)||(e=v({rel:"preload",href:n==="image"&&l&&l.imageSrcSet?void 0:e,as:n},l),Qn.set(g,e),o.querySelector(f)!==null||n==="style"&&o.querySelector(Rs(g))||n==="script"&&o.querySelector(As(g))||(n=o.createElement("link"),on(n,"link",e),Zt(n),o.head.appendChild(n)))}}function y0(e,n){Ir.m(e,n);var l=Al;if(l&&e){var o=n&&typeof n.as=="string"?n.as:"script",f='link[rel="modulepreload"][as="'+Vn(o)+'"][href="'+Vn(e)+'"]',g=f;switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":g=Ll(e)}if(!Qn.has(g)&&(e=v({rel:"modulepreload",href:e},n),Qn.set(g,e),l.querySelector(f)===null)){switch(o){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(As(g)))return}o=l.createElement("link"),on(o,"link",e),Zt(o),l.head.appendChild(o)}}}function b0(e,n,l){Ir.S(e,n,l);var o=Al;if(o&&e){var f=Ja(o).hoistableStyles,g=Ml(e);n=n||"default";var j=f.get(g);if(!j){var A={loading:0,preload:null};if(j=o.querySelector(Rs(g)))A.loading=5;else{e=v({rel:"stylesheet",href:e,"data-precedence":n},l),(l=Qn.get(g))&&ud(e,l);var V=j=o.createElement("link");Zt(V),on(V,"link",e),V._p=new Promise(function(ee,ue){V.onload=ee,V.onerror=ue}),V.addEventListener("load",function(){A.loading|=1}),V.addEventListener("error",function(){A.loading|=2}),A.loading|=4,fo(j,n,o)}j={type:"stylesheet",instance:j,count:1,state:A},f.set(g,j)}}}function j0(e,n){Ir.X(e,n);var l=Al;if(l&&e){var o=Ja(l).hoistableScripts,f=Ll(e),g=o.get(f);g||(g=l.querySelector(As(f)),g||(e=v({src:e,async:!0},n),(n=Qn.get(f))&&dd(e,n),g=l.createElement("script"),Zt(g),on(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function S0(e,n){Ir.M(e,n);var l=Al;if(l&&e){var o=Ja(l).hoistableScripts,f=Ll(e),g=o.get(f);g||(g=l.querySelector(As(f)),g||(e=v({src:e,async:!0,type:"module"},n),(n=Qn.get(f))&&dd(e,n),g=l.createElement("script"),Zt(g),on(g,"link",e),l.head.appendChild(g)),g={type:"script",instance:g,count:1,state:null},o.set(f,g))}}function vx(e,n,l,o){var f=(f=Q.current)?uo(f):null;if(!f)throw Error(i(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(n=Ml(l.href),l=Ja(f).hoistableStyles,o=l.get(n),o||(o={type:"style",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=Ml(l.href);var g=Ja(f).hoistableStyles,j=g.get(e);if(j||(f=f.ownerDocument||f,j={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},g.set(e,j),(g=f.querySelector(Rs(e)))&&!g._p&&(j.instance=g,j.state.loading=5),Qn.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},Qn.set(e,l),g||k0(f,e,l,j.state))),n&&o===null)throw Error(i(528,""));return j}if(n&&o!==null)throw Error(i(529,""));return null;case"script":return n=l.async,l=l.src,typeof l=="string"&&n&&typeof n!="function"&&typeof n!="symbol"?(n=Ll(l),l=Ja(f).hoistableScripts,o=l.get(n),o||(o={type:"script",instance:null,count:0,state:null},l.set(n,o)),o):{type:"void",instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Ml(e){return'href="'+Vn(e)+'"'}function Rs(e){return'link[rel="stylesheet"]['+e+"]"}function yx(e){return v({},e,{"data-precedence":e.precedence,precedence:null})}function k0(e,n,l,o){e.querySelector('link[rel="preload"][as="style"]['+n+"]")?o.loading=1:(n=e.createElement("link"),o.preload=n,n.addEventListener("load",function(){return o.loading|=1}),n.addEventListener("error",function(){return o.loading|=2}),on(n,"link",l),Zt(n),e.head.appendChild(n))}function Ll(e){return'[src="'+Vn(e)+'"]'}function As(e){return"script[async]"+e}function bx(e,n,l){if(n.count++,n.instance===null)switch(n.type){case"style":var o=e.querySelector('style[data-href~="'+Vn(l.href)+'"]');if(o)return n.instance=o,Zt(o),o;var f=v({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return o=(e.ownerDocument||e).createElement("style"),Zt(o),on(o,"style",f),fo(o,l.precedence,e),n.instance=o;case"stylesheet":f=Ml(l.href);var g=e.querySelector(Rs(f));if(g)return n.state.loading|=4,n.instance=g,Zt(g),g;o=yx(l),(f=Qn.get(f))&&ud(o,f),g=(e.ownerDocument||e).createElement("link"),Zt(g);var j=g;return j._p=new Promise(function(A,V){j.onload=A,j.onerror=V}),on(g,"link",o),n.state.loading|=4,fo(g,l.precedence,e),n.instance=g;case"script":return g=Ll(l.src),(f=e.querySelector(As(g)))?(n.instance=f,Zt(f),f):(o=l,(f=Qn.get(g))&&(o=v({},l),dd(o,f)),e=e.ownerDocument||e,f=e.createElement("script"),Zt(f),on(f,"link",o),e.head.appendChild(f),n.instance=f);case"void":return null;default:throw Error(i(443,n.type))}else n.type==="stylesheet"&&(n.state.loading&4)===0&&(o=n.instance,n.state.loading|=4,fo(o,l.precedence,e));return n.instance}function fo(e,n,l){for(var o=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),f=o.length?o[o.length-1]:null,g=f,j=0;j<o.length;j++){var A=o[j];if(A.dataset.precedence===n)g=A;else if(g!==f)break}g?g.parentNode.insertBefore(e,g.nextSibling):(n=l.nodeType===9?l.head:l,n.insertBefore(e,n.firstChild))}function ud(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.title==null&&(e.title=n.title)}function dd(e,n){e.crossOrigin==null&&(e.crossOrigin=n.crossOrigin),e.referrerPolicy==null&&(e.referrerPolicy=n.referrerPolicy),e.integrity==null&&(e.integrity=n.integrity)}var po=null;function jx(e,n,l){if(po===null){var o=new Map,f=po=new Map;f.set(l,o)}else f=po,o=f.get(l),o||(o=new Map,f.set(l,o));if(o.has(e))return o;for(o.set(e,null),l=l.getElementsByTagName(e),f=0;f<l.length;f++){var g=l[f];if(!(g[Sa]||g[He]||e==="link"&&g.getAttribute("rel")==="stylesheet")&&g.namespaceURI!=="http://www.w3.org/2000/svg"){var j=g.getAttribute(n)||"";j=e+j;var A=o.get(j);A?A.push(g):o.set(j,[g])}}return o}function Sx(e,n,l){e=e.ownerDocument||e,e.head.insertBefore(l,n==="title"?e.querySelector("head > title"):null)}function w0(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 kx(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function C0(e,n,l,o){if(l.type==="stylesheet"&&(typeof o.media!="string"||matchMedia(o.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var f=Ml(o.href),g=n.querySelector(Rs(f));if(g){n=g._p,n!==null&&typeof n=="object"&&typeof n.then=="function"&&(e.count++,e=mo.bind(e),n.then(e,e)),l.state.loading|=4,l.instance=g,Zt(g);return}g=n.ownerDocument||n,o=yx(o),(f=Qn.get(f))&&ud(o,f),g=g.createElement("link"),Zt(g);var j=g;j._p=new Promise(function(A,V){j.onload=A,j.onerror=V}),on(g,"link",o),l.instance=g}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,n),(n=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=mo.bind(e),n.addEventListener("load",l),n.addEventListener("error",l))}}var fd=0;function E0(e,n){return e.stylesheets&&e.count===0&&xo(e,e.stylesheets),0<e.count||0<e.imgCount?function(l){var o=setTimeout(function(){if(e.stylesheets&&xo(e,e.stylesheets),e.unsuspend){var g=e.unsuspend;e.unsuspend=null,g()}},6e4+n);0<e.imgBytes&&fd===0&&(fd=62500*s0());var f=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&xo(e,e.stylesheets),e.unsuspend)){var g=e.unsuspend;e.unsuspend=null,g()}},(e.imgBytes>fd?50:800)+n);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(o),clearTimeout(f)}}:null}function mo(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)xo(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ho=null;function xo(e,n){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ho=new Map,n.forEach(N0,e),ho=null,mo.call(e))}function N0(e,n){if(!(n.state.loading&4)){var l=ho.get(e);if(l)var o=l.get(null);else{l=new Map,ho.set(e,l);for(var f=e.querySelectorAll("link[data-precedence],style[data-precedence]"),g=0;g<f.length;g++){var j=f[g];(j.nodeName==="LINK"||j.getAttribute("media")!=="not all")&&(l.set(j.dataset.precedence,j),o=j)}o&&l.set(null,o)}f=n.instance,j=f.getAttribute("data-precedence"),g=l.get(j)||o,g===o&&l.set(null,f),l.set(j,f),this.count++,o=mo.bind(this),f.addEventListener("load",o),f.addEventListener("error",o),g?g.parentNode.insertBefore(f,g.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(f,e.firstChild)),n.state.loading|=4}}var Ms={$$typeof:R,Provider:null,Consumer:null,_currentValue:F,_currentValue2:F,_threadCount:0};function T0(e,n,l,o,f,g,j,A,V){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=rn(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rn(0),this.hiddenUpdates=rn(null),this.identifierPrefix=o,this.onUncaughtError=f,this.onCaughtError=g,this.onRecoverableError=j,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=V,this.incompleteTransitions=new Map}function wx(e,n,l,o,f,g,j,A,V,ee,ue,pe){return e=new T0(e,n,l,j,V,ee,ue,pe,A),n=1,g===!0&&(n|=24),g=An(3,null,null,n),e.current=g,g.stateNode=e,n=Gc(),n.refCount++,e.pooledCache=n,n.refCount++,g.memoizedState={element:o,isDehydrated:l,cache:n},Kc(g),e}function Cx(e){return e?(e=cl,e):cl}function Ex(e,n,l,o,f,g){f=Cx(f),o.context===null?o.context=f:o.pendingContext=f,o=Xr(n),o.payload={element:l},g=g===void 0?null:g,g!==null&&(o.callback=g),l=Qr(e,o,n),l!==null&&(wn(l,e,n),cs(l,e,n))}function Nx(e,n){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var l=e.retryLane;e.retryLane=l!==0&&l<n?l:n}}function pd(e,n){Nx(e,n),(e=e.alternate)&&Nx(e,n)}function Tx(e){if(e.tag===13||e.tag===31){var n=Na(e,67108864);n!==null&&wn(n,e,67108864),pd(e,67108864)}}function Rx(e){if(e.tag===13||e.tag===31){var n=_n();n=nr(n);var l=Na(e,n);l!==null&&wn(l,e,n),pd(e,n)}}var go=!0;function R0(e,n,l,o){var f=M.T;M.T=null;var g=I.p;try{I.p=2,md(e,n,l,o)}finally{I.p=g,M.T=f}}function A0(e,n,l,o){var f=M.T;M.T=null;var g=I.p;try{I.p=8,md(e,n,l,o)}finally{I.p=g,M.T=f}}function md(e,n,l,o){if(go){var f=hd(o);if(f===null)ed(e,n,o,vo,l),Mx(e,o);else if(L0(f,e,n,l,o))o.stopPropagation();else if(Mx(e,o),n&4&&-1<M0.indexOf(e)){for(;f!==null;){var g=Za(f);if(g!==null)switch(g.tag){case 3:if(g=g.stateNode,g.current.memoizedState.isDehydrated){var j=St(g.pendingLanes);if(j!==0){var A=g;for(A.pendingLanes|=2,A.entangledLanes|=2;j;){var V=1<<31-It(j);A.entanglements[1]|=V,j&=~V}pr(g),(st&6)===0&&(Ji=Ge()+500,Cs(0))}}break;case 31:case 13:A=Na(g,2),A!==null&&wn(A,g,2),to(),pd(g,2)}if(g=hd(o),g===null&&ed(e,n,o,vo,l),g===f)break;f=g}f!==null&&o.stopPropagation()}else ed(e,n,o,null,l)}}function hd(e){return e=gc(e),xd(e)}var vo=null;function xd(e){if(vo=null,e=Qa(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 vo=e,null}function Ax(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(pt()){case mt:return 2;case jt:return 8;case Kt:case xe:return 32;case tt:return 268435456;default:return 32}default:return 32}}var gd=!1,oa=null,ca=null,ua=null,Ls=new Map,zs=new Map,da=[],M0="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 Mx(e,n){switch(e){case"focusin":case"focusout":oa=null;break;case"dragenter":case"dragleave":ca=null;break;case"mouseover":case"mouseout":ua=null;break;case"pointerover":case"pointerout":Ls.delete(n.pointerId);break;case"gotpointercapture":case"lostpointercapture":zs.delete(n.pointerId)}}function Ds(e,n,l,o,f,g){return e===null||e.nativeEvent!==g?(e={blockedOn:n,domEventName:l,eventSystemFlags:o,nativeEvent:g,targetContainers:[f]},n!==null&&(n=Za(n),n!==null&&Tx(n)),e):(e.eventSystemFlags|=o,n=e.targetContainers,f!==null&&n.indexOf(f)===-1&&n.push(f),e)}function L0(e,n,l,o,f){switch(n){case"focusin":return oa=Ds(oa,e,n,l,o,f),!0;case"dragenter":return ca=Ds(ca,e,n,l,o,f),!0;case"mouseover":return ua=Ds(ua,e,n,l,o,f),!0;case"pointerover":var g=f.pointerId;return Ls.set(g,Ds(Ls.get(g)||null,e,n,l,o,f)),!0;case"gotpointercapture":return g=f.pointerId,zs.set(g,Ds(zs.get(g)||null,e,n,l,o,f)),!0}return!1}function Lx(e){var n=Qa(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,Gl(e.priority,function(){Rx(l)});return}}else if(n===31){if(n=h(l),n!==null){e.blockedOn=n,Gl(e.priority,function(){Rx(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 yo(e){if(e.blockedOn!==null)return!1;for(var n=e.targetContainers;0<n.length;){var l=hd(e.nativeEvent);if(l===null){l=e.nativeEvent;var o=new l.constructor(l.type,l);xc=o,l.target.dispatchEvent(o),xc=null}else return n=Za(l),n!==null&&Tx(n),e.blockedOn=l,!1;n.shift()}return!0}function zx(e,n,l){yo(e)&&l.delete(n)}function z0(){gd=!1,oa!==null&&yo(oa)&&(oa=null),ca!==null&&yo(ca)&&(ca=null),ua!==null&&yo(ua)&&(ua=null),Ls.forEach(zx),zs.forEach(zx)}function bo(e,n){e.blockedOn===n&&(e.blockedOn=null,gd||(gd=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,z0)))}var jo=null;function Dx(e){jo!==e&&(jo=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jo===e&&(jo=null);for(var n=0;n<e.length;n+=3){var l=e[n],o=e[n+1],f=e[n+2];if(typeof o!="function"){if(xd(o||l)===null)continue;break}var g=Za(l);g!==null&&(e.splice(n,3),n-=3,hu(g,{pending:!0,data:f,method:l.method,action:o},o,f))}}))}function zl(e){function n(V){return bo(V,e)}oa!==null&&bo(oa,e),ca!==null&&bo(ca,e),ua!==null&&bo(ua,e),Ls.forEach(n),zs.forEach(n);for(var l=0;l<da.length;l++){var o=da[l];o.blockedOn===e&&(o.blockedOn=null)}for(;0<da.length&&(l=da[0],l.blockedOn===null);)Lx(l),l.blockedOn===null&&da.shift();if(l=(e.ownerDocument||e).$$reactFormReplay,l!=null)for(o=0;o<l.length;o+=3){var f=l[o],g=l[o+1],j=f[Ft]||null;if(typeof g=="function")j||Dx(l);else if(j){var A=null;if(g&&g.hasAttribute("formAction")){if(f=g,j=g[Ft]||null)A=j.formAction;else if(xd(f)!==null)continue}else A=j.action;typeof A=="function"?l[o+1]=A:(l.splice(o,3),o-=3),Dx(l)}}}function _x(){function e(g){g.canIntercept&&g.info==="react-transition"&&g.intercept({handler:function(){return new Promise(function(j){return f=j})},focusReset:"manual",scroll:"manual"})}function n(){f!==null&&(f(),f=null),o||setTimeout(l,20)}function l(){if(!o&&!navigation.transition){var g=navigation.currentEntry;g&&g.url!=null&&navigation.navigate(g.url,{state:g.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var o=!1,f=null;return navigation.addEventListener("navigate",e),navigation.addEventListener("navigatesuccess",n),navigation.addEventListener("navigateerror",n),setTimeout(l,100),function(){o=!0,navigation.removeEventListener("navigate",e),navigation.removeEventListener("navigatesuccess",n),navigation.removeEventListener("navigateerror",n),f!==null&&(f(),f=null)}}}function vd(e){this._internalRoot=e}So.prototype.render=vd.prototype.render=function(e){var n=this._internalRoot;if(n===null)throw Error(i(409));var l=n.current,o=_n();Ex(l,o,e,n,null,null)},So.prototype.unmount=vd.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var n=e.containerInfo;Ex(e.current,2,null,e,null,null),to(),n[Tn]=null}};function So(e){this._internalRoot=e}So.prototype.unstable_scheduleHydration=function(e){if(e){var n=ja();e={blockedOn:null,target:e,priority:n};for(var l=0;l<da.length&&n!==0&&n<da[l].priority;l++);da.splice(l,0,e),l===0&&Lx(e)}};var Ox=a.version;if(Ox!=="19.2.4")throw Error(i(527,Ox,"19.2.4"));I.findDOMNode=function(e){var n=e._reactInternals;if(n===void 0)throw typeof e.render=="function"?Error(i(188)):(e=Object.keys(e).join(","),Error(i(268,e)));return e=m(n),e=e!==null?y(e):null,e=e===null?null:e.stateNode,e};var D0={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:M,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var ko=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ko.isDisabled&&ko.supportsFiber)try{Lt=ko.inject(D0),ut=ko}catch{}}return Os.createRoot=function(e,n){if(!c(e))throw Error(i(299));var l=!1,o="",f=Vm,g=Fm,j=Gm;return n!=null&&(n.unstable_strictMode===!0&&(l=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onUncaughtError!==void 0&&(f=n.onUncaughtError),n.onCaughtError!==void 0&&(g=n.onCaughtError),n.onRecoverableError!==void 0&&(j=n.onRecoverableError)),n=wx(e,1,!1,null,null,l,o,null,f,g,j,_x),e[Tn]=n.current,Ju(e),new vd(n)},Os.hydrateRoot=function(e,n,l){if(!c(e))throw Error(i(299));var o=!1,f="",g=Vm,j=Fm,A=Gm,V=null;return l!=null&&(l.unstable_strictMode===!0&&(o=!0),l.identifierPrefix!==void 0&&(f=l.identifierPrefix),l.onUncaughtError!==void 0&&(g=l.onUncaughtError),l.onCaughtError!==void 0&&(j=l.onCaughtError),l.onRecoverableError!==void 0&&(A=l.onRecoverableError),l.formState!==void 0&&(V=l.formState)),n=wx(e,1,!0,n,l??null,o,f,V,g,j,A,_x),n.context=Cx(null),l=n.current,o=_n(),o=nr(o),f=Xr(o),f.callback=null,Qr(l,f,o),l=o,n.current.lanes=l,ie(n,l),pr(n),e[Tn]=n.current,Ju(e),new So(n)},Os.version="19.2.4",Os}var Wx;function V0(){if(Wx)return jd.exports;Wx=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(),jd.exports=P0(),jd.exports}var F0=V0();/**
|
|
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 qx="popstate";function Yx(t){return typeof t=="object"&&t!=null&&"pathname"in t&&"search"in t&&"hash"in t&&"state"in t&&"key"in t}function G0(t={}){function a(c,u){let{pathname:d="/",search:h="",hash:x=""}=Ul(c.location.hash.substring(1));return!d.startsWith("/")&&!d.startsWith(".")&&(d="/"+d),af("",{pathname:d,search:h,hash:x},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 x=c.location.href,m=x.indexOf("#");h=m===-1?x:x.slice(0,m)}return h+"#"+(typeof u=="string"?u:Ks(u))}function i(c,u){ir(c.pathname.charAt(0)==="/",`relative pathnames are not supported in hash history.push(${JSON.stringify(u)})`)}return q0(a,s,i,t)}function Yt(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function ir(t,a){if(!t){typeof console<"u"&&console.warn(a);try{throw new Error(a)}catch{}}}function W0(){return Math.random().toString(36).substring(2,10)}function Kx(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 af(t,a,s=null,i,c){return{pathname:typeof t=="string"?t:t.pathname,search:"",hash:"",...typeof a=="string"?Ul(a):a,state:s,key:a&&a.key||i||W0(),unstable_mask:c}}function Ks({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 Ul(t){let a={};if(t){let s=t.indexOf("#");s>=0&&(a.hash=t.substring(s),t=t.substring(0,s));let i=t.indexOf("?");i>=0&&(a.search=t.substring(i),t=t.substring(0,i)),t&&(a.pathname=t)}return a}function q0(t,a,s,i={}){let{window:c=document.defaultView,v5Compat:u=!1}=i,d=c.history,h="POP",x=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 w=y(),N=w==null?null:w-m;m=w,x&&x({action:h,location:C.location,delta:N})}function b(w,N){h="PUSH";let T=Yx(w)?w:af(C.location,w,N);s&&s(T,w),m=y()+1;let R=Kx(T,m),_=C.createHref(T.unstable_mask||T);try{d.pushState(R,"",_)}catch(z){if(z instanceof DOMException&&z.name==="DataCloneError")throw z;c.location.assign(_)}u&&x&&x({action:h,location:C.location,delta:1})}function S(w,N){h="REPLACE";let T=Yx(w)?w:af(C.location,w,N);s&&s(T,w),m=y();let R=Kx(T,m),_=C.createHref(T.unstable_mask||T);d.replaceState(R,"",_),u&&x&&x({action:h,location:C.location,delta:0})}function E(w){return Y0(w)}let C={get action(){return h},get location(){return t(c,d)},listen(w){if(x)throw new Error("A history only accepts one active listener");return c.addEventListener(qx,v),x=w,()=>{c.removeEventListener(qx,v),x=null}},createHref(w){return a(c,w)},createURL:E,encodeLocation(w){let N=E(w);return{pathname:N.pathname,search:N.search,hash:N.hash}},push:b,replace:S,go(w){return d.go(w)}};return C}function Y0(t,a=!1){let s="http://localhost";typeof window<"u"&&(s=window.location.origin!=="null"?window.location.origin:window.location.href),Yt(s,"No window.location.(origin|href) available to create URL");let i=typeof t=="string"?t:Ks(t);return i=i.replace(/ $/,"%20"),!a&&i.startsWith("//")&&(i=s+i),new URL(i,s)}function Rv(t,a,s="/"){return K0(t,a,s,!1)}function K0(t,a,s,i){let c=typeof a=="string"?Ul(a):a,u=Ur(c.pathname||"/",s);if(u==null)return null;let d=Av(t);X0(d);let h=null;for(let x=0;h==null&&x<d.length;++x){let m=ij(u);h=lj(d[x],m,i)}return h}function Av(t,a=[],s=[],i="",c=!1){let u=(d,h,x=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(i)&&x)return;Yt(y.relativePath.startsWith(i),`Absolute route path "${y.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(i.length)}let v=xr([i,y.relativePath]),b=s.concat(y);d.children&&d.children.length>0&&(Yt(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),Av(d.children,a,b,v,x)),!(d.path==null&&!d.index)&&a.push({path:v,score:rj(v,d.index),routesMeta:b})};return t.forEach((d,h)=>{var x;if(d.path===""||!((x=d.path)!=null&&x.includes("?")))u(d,h);else for(let m of Mv(d.path))u(d,h,!0,m)}),a}function Mv(t){let a=t.split("/");if(a.length===0)return[];let[s,...i]=a,c=s.endsWith("?"),u=s.replace(/\?$/,"");if(i.length===0)return c?[u,""]:[u];let d=Mv(i.join("/")),h=[];return h.push(...d.map(x=>x===""?u:[u,x].join("/"))),c&&h.push(...d),h.map(x=>t.startsWith("/")&&x===""?"/":x)}function X0(t){t.sort((a,s)=>a.score!==s.score?s.score-a.score:aj(a.routesMeta.map(i=>i.childrenIndex),s.routesMeta.map(i=>i.childrenIndex)))}var Q0=/^:[\w-]+$/,Z0=3,J0=2,ej=1,tj=10,nj=-2,Xx=t=>t==="*";function rj(t,a){let s=t.split("/"),i=s.length;return s.some(Xx)&&(i+=nj),a&&(i+=J0),s.filter(c=>!Xx(c)).reduce((c,u)=>c+(Q0.test(u)?Z0:u===""?ej:tj),i)}function aj(t,a){return t.length===a.length&&t.slice(0,-1).every((i,c)=>i===a[c])?t[t.length-1]-a[a.length-1]:0}function lj(t,a,s=!1){let{routesMeta:i}=t,c={},u="/",d=[];for(let h=0;h<i.length;++h){let x=i[h],m=h===i.length-1,y=u==="/"?a:a.slice(u.length)||"/",v=Fo({path:x.relativePath,caseSensitive:x.caseSensitive,end:m},y),b=x.route;if(!v&&m&&s&&!i[i.length-1].route.index&&(v=Fo({path:x.relativePath,caseSensitive:x.caseSensitive,end:!1},y)),!v)return null;Object.assign(c,v.params),d.push({params:c,pathname:xr([u,v.pathname]),pathnameBase:dj(xr([u,v.pathnameBase])),route:b}),v.pathnameBase!=="/"&&(u=xr([u,v.pathnameBase]))}return d}function Fo(t,a){typeof t=="string"&&(t={path:t,caseSensitive:!1,end:!0});let[s,i]=sj(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:i.reduce((m,{paramName:y,isOptional:v},b)=>{if(y==="*"){let E=h[b]||"";d=u.slice(0,u.length-E.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 sj(t,a=!1,s=!0){ir(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 i=[],c="^"+t.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,h,x,m,y)=>{if(i.push({paramName:h,isOptional:x!=null}),x){let v=y.charAt(m+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return t.endsWith("*")?(i.push({paramName:"*"}),c+=t==="*"||t==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):s?c+="\\/*$":t!==""&&t!=="/"&&(c+="(?:(?=\\/|$))"),[new RegExp(c,a?void 0:"i"),i]}function ij(t){try{return t.split("/").map(a=>decodeURIComponent(a).replace(/\//g,"%2F")).join("/")}catch(a){return ir(!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 Ur(t,a){if(a==="/")return t;if(!t.toLowerCase().startsWith(a.toLowerCase()))return null;let s=a.endsWith("/")?a.length-1:a.length,i=t.charAt(s);return i&&i!=="/"?null:t.slice(s)||"/"}var oj=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function cj(t,a="/"){let{pathname:s,search:i="",hash:c=""}=typeof t=="string"?Ul(t):t,u;return s?(s=s.replace(/\/\/+/g,"/"),s.startsWith("/")?u=Qx(s.substring(1),"/"):u=Qx(s,a)):u=a,{pathname:u,search:fj(i),hash:pj(c)}}function Qx(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 Cd(t,a,s,i){return`Cannot include a '${t}' character in a manually specified \`to.${a}\` field [${JSON.stringify(i)}]. 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 uj(t){return t.filter((a,s)=>s===0||a.route.path&&a.route.path.length>0)}function Lv(t){let a=uj(t);return a.map((s,i)=>i===a.length-1?s.pathname:s.pathnameBase)}function Ef(t,a,s,i=!1){let c;typeof t=="string"?c=Ul(t):(c={...t},Yt(!c.pathname||!c.pathname.includes("?"),Cd("?","pathname","search",c)),Yt(!c.pathname||!c.pathname.includes("#"),Cd("#","pathname","hash",c)),Yt(!c.search||!c.search.includes("#"),Cd("#","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(!i&&d.startsWith("..")){let b=d.split("/");for(;b[0]==="..";)b.shift(),v-=1;c.pathname=b.join("/")}h=v>=0?a[v]:"/"}let x=cj(c,h),m=d&&d!=="/"&&d.endsWith("/"),y=(u||d===".")&&s.endsWith("/");return!x.pathname.endsWith("/")&&(m||y)&&(x.pathname+="/"),x}var xr=t=>t.join("/").replace(/\/\/+/g,"/"),dj=t=>t.replace(/\/+$/,"").replace(/^\/*/,"/"),fj=t=>!t||t==="?"?"":t.startsWith("?")?t:"?"+t,pj=t=>!t||t==="#"?"":t.startsWith("#")?t:"#"+t,mj=class{constructor(t,a,s,i=!1){this.status=t,this.statusText=a||"",this.internal=i,s instanceof Error?(this.data=s.toString(),this.error=s):this.data=s}};function hj(t){return t!=null&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.internal=="boolean"&&"data"in t}function xj(t){return t.map(a=>a.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var zv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Dv(t,a){let s=t;if(typeof s!="string"||!oj.test(s))return{absoluteURL:void 0,isExternal:!1,to:s};let i=s,c=!1;if(zv)try{let u=new URL(window.location.href),d=s.startsWith("//")?new URL(u.protocol+s):new URL(s),h=Ur(d.pathname,a);d.origin===u.origin&&h!=null?s=h+d.search+d.hash:c=!0}catch{ir(!1,`<Link to="${s}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:c,to:s}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var _v=["POST","PUT","PATCH","DELETE"];new Set(_v);var gj=["GET",..._v];new Set(gj);var Hl=p.createContext(null);Hl.displayName="DataRouter";var Zo=p.createContext(null);Zo.displayName="DataRouterState";var vj=p.createContext(!1),Ov=p.createContext({isTransitioning:!1});Ov.displayName="ViewTransition";var yj=p.createContext(new Map);yj.displayName="Fetchers";var bj=p.createContext(null);bj.displayName="Await";var tr=p.createContext(null);tr.displayName="Navigation";var Jo=p.createContext(null);Jo.displayName="Location";var Hr=p.createContext({outlet:null,matches:[],isDataRoute:!1});Hr.displayName="Route";var Nf=p.createContext(null);Nf.displayName="RouteError";var Bv="REACT_ROUTER_ERROR",jj="REDIRECT",Sj="ROUTE_ERROR_RESPONSE";function kj(t){if(t.startsWith(`${Bv}:${jj}:{`))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 wj(t){if(t.startsWith(`${Bv}:${Sj}:{`))try{let a=JSON.parse(t.slice(40));if(typeof a=="object"&&a&&typeof a.status=="number"&&typeof a.statusText=="string")return new mj(a.status,a.statusText,a.data)}catch{}}function Cj(t,{relative:a}={}){Yt(ri(),"useHref() may be used only in the context of a <Router> component.");let{basename:s,navigator:i}=p.useContext(tr),{hash:c,pathname:u,search:d}=ai(t,{relative:a}),h=u;return s!=="/"&&(h=u==="/"?s:xr([s,u])),i.createHref({pathname:h,search:d,hash:c})}function ri(){return p.useContext(Jo)!=null}function ga(){return Yt(ri(),"useLocation() may be used only in the context of a <Router> component."),p.useContext(Jo).location}var Iv="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function $v(t){p.useContext(tr).static||p.useLayoutEffect(t)}function Ej(){let{isDataRoute:t}=p.useContext(Hr);return t?$j():Nj()}function Nj(){Yt(ri(),"useNavigate() may be used only in the context of a <Router> component.");let t=p.useContext(Hl),{basename:a,navigator:s}=p.useContext(tr),{matches:i}=p.useContext(Hr),{pathname:c}=ga(),u=JSON.stringify(Lv(i)),d=p.useRef(!1);return $v(()=>{d.current=!0}),p.useCallback((x,m={})=>{if(ir(d.current,Iv),!d.current)return;if(typeof x=="number"){s.go(x);return}let y=Ef(x,JSON.parse(u),c,m.relative==="path");t==null&&a!=="/"&&(y.pathname=y.pathname==="/"?a:xr([a,y.pathname])),(m.replace?s.replace:s.push)(y,m.state,m)},[a,s,u,c,t])}p.createContext(null);function ai(t,{relative:a}={}){let{matches:s}=p.useContext(Hr),{pathname:i}=ga(),c=JSON.stringify(Lv(s));return p.useMemo(()=>Ef(t,JSON.parse(c),i,a==="path"),[t,c,i,a])}function Tj(t,a,s){Yt(ri(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:i}=p.useContext(tr),{matches:c}=p.useContext(Hr),u=c[c.length-1],d=u?u.params:{},h=u?u.pathname:"/",x=u?u.pathnameBase:"/",m=u&&u.route;{let w=m&&m.path||"";Hv(h,!m||w.endsWith("*")||w.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${h}" (under <Route path="${w}">) 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="${w}"> to <Route path="${w==="/"?"*":`${w}/*`}">.`)}let y=ga(),v;v=y;let b=v.pathname||"/",S=b;if(x!=="/"){let w=x.replace(/^\//,"").split("/");S="/"+b.replace(/^\//,"").split("/").slice(w.length).join("/")}let E=Rv(t,{pathname:S});return ir(m||E!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),ir(E==null||E[E.length-1].route.element!==void 0||E[E.length-1].route.Component!==void 0||E[E.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.`),zj(E&&E.map(w=>Object.assign({},w,{params:Object.assign({},d,w.params),pathname:xr([x,i.encodeLocation?i.encodeLocation(w.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathname]),pathnameBase:w.pathnameBase==="/"?x:xr([x,i.encodeLocation?i.encodeLocation(w.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:w.pathnameBase])})),c,s)}function Rj(){let t=Ij(),a=hj(t)?`${t.status} ${t.statusText}`:t instanceof Error?t.message:JSON.stringify(t),s=t instanceof Error?t.stack:null,i="rgba(200,200,200, 0.5)",c={padding:"0.5rem",backgroundColor:i},u={padding:"2px 4px",backgroundColor:i},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 Aj=p.createElement(Rj,null),Uv=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=wj(t.digest);s&&(t=s)}let a=t!==void 0?p.createElement(Hr.Provider,{value:this.props.routeContext},p.createElement(Nf.Provider,{value:t,children:this.props.component})):this.props.children;return this.context?p.createElement(Mj,{error:t},a):a}};Uv.contextType=vj;var Ed=new WeakMap;function Mj({children:t,error:a}){let{basename:s}=p.useContext(tr);if(typeof a=="object"&&a&&"digest"in a&&typeof a.digest=="string"){let i=kj(a.digest);if(i){let c=Ed.get(a);if(c)throw c;let u=Dv(i.location,s);if(zv&&!Ed.get(a))if(u.isExternal||i.reloadDocument)window.location.href=u.absoluteURL||u.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(u.to,{replace:i.replace}));throw Ed.set(a,d),d}return p.createElement("meta",{httpEquiv:"refresh",content:`0;url=${u.absoluteURL||u.to}`})}}return t}function Lj({routeContext:t,match:a,children:s}){let i=p.useContext(Hl);return i&&i.static&&i.staticContext&&(a.route.errorElement||a.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=a.route.id),p.createElement(Hr.Provider,{value:t},s)}function zj(t,a=[],s){let i=s==null?void 0:s.state;if(t==null){if(!i)return null;if(i.errors)t=i.matches;else if(a.length===0&&!i.initialized&&i.matches.length>0)t=i.matches;else return null}let c=t,u=i==null?void 0:i.errors;if(u!=null){let y=c.findIndex(v=>v.route.id&&(u==null?void 0:u[v.route.id])!==void 0);Yt(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&&i){d=i.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}=i,E=v.route.loader&&!b.hasOwnProperty(v.route.id)&&(!S||S[v.route.id]===void 0);if(v.route.lazy||E){s.isStatic&&(d=!0),h>=0?c=c.slice(0,h+1):c=[c[0]];break}}}}let x=s==null?void 0:s.onError,m=i&&x?(y,v)=>{var b,S;x(y,{location:i.location,params:((S=(b=i.matches)==null?void 0:b[0])==null?void 0:S.params)??{},unstable_pattern:xj(i.matches),errorInfo:v})}:void 0;return c.reduceRight((y,v,b)=>{let S,E=!1,C=null,w=null;i&&(S=u&&v.route.id?u[v.route.id]:void 0,C=v.route.errorElement||Aj,d&&(h<0&&b===0?(Hv("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),E=!0,w=null):h===b&&(E=!0,w=v.route.hydrateFallbackElement||null)));let N=a.concat(c.slice(0,b+1)),T=()=>{let R;return S?R=C:E?R=w:v.route.Component?R=p.createElement(v.route.Component,null):v.route.element?R=v.route.element:R=y,p.createElement(Lj,{match:v,routeContext:{outlet:y,matches:N,isDataRoute:i!=null},children:R})};return i&&(v.route.ErrorBoundary||v.route.errorElement||b===0)?p.createElement(Uv,{location:i.location,revalidation:i.revalidation,component:C,error:S,children:T(),routeContext:{outlet:null,matches:N,isDataRoute:!0},onError:m}):T()},null)}function Tf(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Dj(t){let a=p.useContext(Hl);return Yt(a,Tf(t)),a}function _j(t){let a=p.useContext(Zo);return Yt(a,Tf(t)),a}function Oj(t){let a=p.useContext(Hr);return Yt(a,Tf(t)),a}function Rf(t){let a=Oj(t),s=a.matches[a.matches.length-1];return Yt(s.route.id,`${t} can only be used on routes that contain a unique "id"`),s.route.id}function Bj(){return Rf("useRouteId")}function Ij(){var i;let t=p.useContext(Nf),a=_j("useRouteError"),s=Rf("useRouteError");return t!==void 0?t:(i=a.errors)==null?void 0:i[s]}function $j(){let{router:t}=Dj("useNavigate"),a=Rf("useNavigate"),s=p.useRef(!1);return $v(()=>{s.current=!0}),p.useCallback(async(c,u={})=>{ir(s.current,Iv),s.current&&(typeof c=="number"?await t.navigate(c):await t.navigate(c,{fromRouteId:a,...u}))},[t,a])}var Zx={};function Hv(t,a,s){!a&&!Zx[t]&&(Zx[t]=!0,ir(!1,s))}p.memo(Uj);function Uj({routes:t,future:a,state:s,isStatic:i,onError:c}){return Tj(t,void 0,{state:s,isStatic:i,onError:c})}function Hj({basename:t="/",children:a=null,location:s,navigationType:i="POP",navigator:c,static:u=!1,unstable_useTransitions:d}){Yt(!ri(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let h=t.replace(/^\/*/,"/"),x=p.useMemo(()=>({basename:h,navigator:c,static:u,unstable_useTransitions:d,future:{}}),[h,c,u,d]);typeof s=="string"&&(s=Ul(s));let{pathname:m="/",search:y="",hash:v="",state:b=null,key:S="default",unstable_mask:E}=s,C=p.useMemo(()=>{let w=Ur(m,h);return w==null?null:{location:{pathname:w,search:y,hash:v,state:b,key:S,unstable_mask:E},navigationType:i}},[h,m,y,v,b,S,i,E]);return ir(C!=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.`),C==null?null:p.createElement(tr.Provider,{value:x},p.createElement(Jo.Provider,{children:a,value:C}))}var Bo="get",Io="application/x-www-form-urlencoded";function ec(t){return typeof HTMLElement<"u"&&t instanceof HTMLElement}function Pj(t){return ec(t)&&t.tagName.toLowerCase()==="button"}function Vj(t){return ec(t)&&t.tagName.toLowerCase()==="form"}function Fj(t){return ec(t)&&t.tagName.toLowerCase()==="input"}function Gj(t){return!!(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}function Wj(t,a){return t.button===0&&(!a||a==="_self")&&!Gj(t)}var wo=null;function qj(){if(wo===null)try{new FormData(document.createElement("form"),0),wo=!1}catch{wo=!0}return wo}var Yj=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Nd(t){return t!=null&&!Yj.has(t)?(ir(!1,`"${t}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Io}"`),null):t}function Kj(t,a){let s,i,c,u,d;if(Vj(t)){let h=t.getAttribute("action");i=h?Ur(h,a):null,s=t.getAttribute("method")||Bo,c=Nd(t.getAttribute("enctype"))||Io,u=new FormData(t)}else if(Pj(t)||Fj(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 x=t.getAttribute("formaction")||h.getAttribute("action");if(i=x?Ur(x,a):null,s=t.getAttribute("formmethod")||h.getAttribute("method")||Bo,c=Nd(t.getAttribute("formenctype"))||Nd(h.getAttribute("enctype"))||Io,u=new FormData(h,t),!qj()){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(ec(t))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');s=Bo,i=null,c=Io,d=t}return u&&c==="text/plain"&&(d=u,u=void 0),{action:i,method:s.toLowerCase(),encType:c,formData:u,body:d}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function Af(t,a){if(t===!1||t===null||typeof t>"u")throw new Error(a)}function Xj(t,a,s,i){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}_.${i}`:c.pathname=`${c.pathname}.${i}`:c.pathname==="/"?c.pathname=`_root.${i}`:a&&Ur(c.pathname,a)==="/"?c.pathname=`${a.replace(/\/$/,"")}/_root.${i}`:c.pathname=`${c.pathname.replace(/\/$/,"")}.${i}`,c}async function Qj(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 Zj(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 Jj(t,a,s){let i=await Promise.all(t.map(async c=>{let u=a.routes[c.route.id];if(u){let d=await Qj(u,s);return d.links?d.links():[]}return[]}));return rS(i.flat(1).filter(Zj).filter(c=>c.rel==="stylesheet"||c.rel==="preload").map(c=>c.rel==="stylesheet"?{...c,rel:"prefetch",as:"style"}:{...c,rel:"prefetch"}))}function Jx(t,a,s,i,c,u){let d=(x,m)=>s[m]?x.route.id!==s[m].route.id:!0,h=(x,m)=>{var y;return s[m].pathname!==x.pathname||((y=s[m].route.path)==null?void 0:y.endsWith("*"))&&s[m].params["*"]!==x.params["*"]};return u==="assets"?a.filter((x,m)=>d(x,m)||h(x,m)):u==="data"?a.filter((x,m)=>{var v;let y=i.routes[x.route.id];if(!y||!y.hasLoader)return!1;if(d(x,m)||h(x,m))return!0;if(x.route.shouldRevalidate){let b=x.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:x.params,defaultShouldRevalidate:!0});if(typeof b=="boolean")return b}return!0}):[]}function eS(t,a,{includeHydrateFallback:s}={}){return tS(t.map(i=>{let c=a.routes[i.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 tS(t){return[...new Set(t)]}function nS(t){let a={},s=Object.keys(t).sort();for(let i of s)a[i]=t[i];return a}function rS(t,a){let s=new Set;return new Set(a),t.reduce((i,c)=>{let u=JSON.stringify(nS(c));return s.has(u)||(s.add(u),i.push({key:u,link:c})),i},[])}function Pv(){let t=p.useContext(Hl);return Af(t,"You must render this element inside a <DataRouterContext.Provider> element"),t}function aS(){let t=p.useContext(Zo);return Af(t,"You must render this element inside a <DataRouterStateContext.Provider> element"),t}var Mf=p.createContext(void 0);Mf.displayName="FrameworkContext";function Vv(){let t=p.useContext(Mf);return Af(t,"You must render this element inside a <HydratedRouter> element"),t}function lS(t,a){let s=p.useContext(Mf),[i,c]=p.useState(!1),[u,d]=p.useState(!1),{onFocus:h,onBlur:x,onMouseEnter:m,onMouseLeave:y,onTouchStart:v}=a,b=p.useRef(null);p.useEffect(()=>{if(t==="render"&&d(!0),t==="viewport"){let C=N=>{N.forEach(T=>{d(T.isIntersecting)})},w=new IntersectionObserver(C,{threshold:.5});return b.current&&w.observe(b.current),()=>{w.disconnect()}}},[t]),p.useEffect(()=>{if(i){let C=setTimeout(()=>{d(!0)},100);return()=>{clearTimeout(C)}}},[i]);let S=()=>{c(!0)},E=()=>{c(!1),d(!1)};return s?t!=="intent"?[u,b,{}]:[u,b,{onFocus:Bs(h,S),onBlur:Bs(x,E),onMouseEnter:Bs(m,S),onMouseLeave:Bs(y,E),onTouchStart:Bs(v,S)}]:[!1,b,{}]}function Bs(t,a){return s=>{t&&t(s),s.defaultPrevented||a(s)}}function sS({page:t,...a}){let{router:s}=Pv(),i=p.useMemo(()=>Rv(s.routes,t,s.basename),[s.routes,t,s.basename]);return i?p.createElement(oS,{page:t,matches:i,...a}):null}function iS(t){let{manifest:a,routeModules:s}=Vv(),[i,c]=p.useState([]);return p.useEffect(()=>{let u=!1;return Jj(t,a,s).then(d=>{u||c(d)}),()=>{u=!0}},[t,a,s]),i}function oS({page:t,matches:a,...s}){let i=ga(),{future:c,manifest:u,routeModules:d}=Vv(),{basename:h}=Pv(),{loaderData:x,matches:m}=aS(),y=p.useMemo(()=>Jx(t,a,m,u,i,"data"),[t,a,m,u,i]),v=p.useMemo(()=>Jx(t,a,m,u,i,"assets"),[t,a,m,u,i]),b=p.useMemo(()=>{if(t===i.pathname+i.search+i.hash)return[];let C=new Set,w=!1;if(a.forEach(T=>{var _;let R=u.routes[T.route.id];!R||!R.hasLoader||(!y.some(z=>z.route.id===T.route.id)&&T.route.id in x&&((_=d[T.route.id])!=null&&_.shouldRevalidate)||R.hasClientLoader?w=!0:C.add(T.route.id))}),C.size===0)return[];let N=Xj(t,h,c.unstable_trailingSlashAwareDataRequests,"data");return w&&C.size>0&&N.searchParams.set("_routes",a.filter(T=>C.has(T.route.id)).map(T=>T.route.id).join(",")),[N.pathname+N.search]},[h,c.unstable_trailingSlashAwareDataRequests,x,i,u,y,a,t,d]),S=p.useMemo(()=>eS(v,u),[v,u]),E=iS(v);return p.createElement(p.Fragment,null,b.map(C=>p.createElement("link",{key:C,rel:"prefetch",as:"fetch",href:C,...s})),S.map(C=>p.createElement("link",{key:C,rel:"modulepreload",href:C,...s})),E.map(({key:C,link:w})=>p.createElement("link",{key:C,nonce:s.nonce,...w,crossOrigin:w.crossOrigin??s.crossOrigin})))}function cS(...t){return a=>{t.forEach(s=>{typeof s=="function"?s(a):s!=null&&(s.current=a)})}}var uS=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{uS&&(window.__reactRouterVersion="7.13.1")}catch{}function dS({basename:t,children:a,unstable_useTransitions:s,window:i}){let c=p.useRef();c.current==null&&(c.current=G0({window:i,v5Compat:!0}));let u=c.current,[d,h]=p.useState({action:u.action,location:u.location}),x=p.useCallback(m=>{s===!1?h(m):p.startTransition(()=>h(m))},[s]);return p.useLayoutEffect(()=>u.listen(x),[u,x]),p.createElement(Hj,{basename:t,children:a,location:d.location,navigationType:d.action,navigator:u,unstable_useTransitions:s})}var Fv=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Gv=p.forwardRef(function({onClick:a,discover:s="render",prefetch:i="none",relative:c,reloadDocument:u,replace:d,unstable_mask:h,state:x,target:m,to:y,preventScrollReset:v,viewTransition:b,unstable_defaultShouldRevalidate:S,...E},C){let{basename:w,navigator:N,unstable_useTransitions:T}=p.useContext(tr),R=typeof y=="string"&&Fv.test(y),_=Dv(y,w);y=_.to;let z=Cj(y,{relative:c}),P=ga(),k=null;if(h){let $=Ef(h,[],P.unstable_mask?P.unstable_mask.pathname:"/",!0);w!=="/"&&($.pathname=$.pathname==="/"?w:xr([w,$.pathname])),k=N.createHref($)}let[O,L,B]=lS(i,E),U=hS(y,{replace:d,unstable_mask:h,state:x,target:m,preventScrollReset:v,relative:c,viewTransition:b,unstable_defaultShouldRevalidate:S,unstable_useTransitions:T});function Y($){a&&a($),$.defaultPrevented||U($)}let X=!(_.isExternal||u),J=p.createElement("a",{...E,...B,href:(X?k:void 0)||_.absoluteURL||z,onClick:X?Y:a,ref:cS(C,L),target:m,"data-discover":!R&&s==="render"?"true":void 0});return O&&!R?p.createElement(p.Fragment,null,J,p.createElement(sS,{page:z})):J});Gv.displayName="Link";var fS=p.forwardRef(function({"aria-current":a="page",caseSensitive:s=!1,className:i="",end:c=!1,style:u,to:d,viewTransition:h,children:x,...m},y){let v=ai(d,{relative:m.relative}),b=ga(),S=p.useContext(Zo),{navigator:E,basename:C}=p.useContext(tr),w=S!=null&&bS(v)&&h===!0,N=E.encodeLocation?E.encodeLocation(v).pathname:v.pathname,T=b.pathname,R=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(T=T.toLowerCase(),R=R?R.toLowerCase():null,N=N.toLowerCase()),R&&C&&(R=Ur(R,C)||R);const _=N!=="/"&&N.endsWith("/")?N.length-1:N.length;let z=T===N||!c&&T.startsWith(N)&&T.charAt(_)==="/",P=R!=null&&(R===N||!c&&R.startsWith(N)&&R.charAt(N.length)==="/"),k={isActive:z,isPending:P,isTransitioning:w},O=z?a:void 0,L;typeof i=="function"?L=i(k):L=[i,z?"active":null,P?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let B=typeof u=="function"?u(k):u;return p.createElement(Gv,{...m,"aria-current":O,className:L,ref:y,style:B,to:d,viewTransition:h},typeof x=="function"?x(k):x)});fS.displayName="NavLink";var pS=p.forwardRef(({discover:t="render",fetcherKey:a,navigate:s,reloadDocument:i,replace:c,state:u,method:d=Bo,action:h,onSubmit:x,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b,...S},E)=>{let{unstable_useTransitions:C}=p.useContext(tr),w=vS(),N=yS(h,{relative:m}),T=d.toLowerCase()==="get"?"get":"post",R=typeof h=="string"&&Fv.test(h),_=z=>{if(x&&x(z),z.defaultPrevented)return;z.preventDefault();let P=z.nativeEvent.submitter,k=(P==null?void 0:P.getAttribute("formmethod"))||d,O=()=>w(P||z.currentTarget,{fetcherKey:a,method:k,navigate:s,replace:c,state:u,relative:m,preventScrollReset:y,viewTransition:v,unstable_defaultShouldRevalidate:b});C&&s!==!1?p.startTransition(()=>O()):O()};return p.createElement("form",{ref:E,method:T,action:N,onSubmit:i?x:_,...S,"data-discover":!R&&t==="render"?"true":void 0})});pS.displayName="Form";function mS(t){return`${t} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Wv(t){let a=p.useContext(Hl);return Yt(a,mS(t)),a}function hS(t,{target:a,replace:s,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:x,unstable_useTransitions:m}={}){let y=Ej(),v=ga(),b=ai(t,{relative:d});return p.useCallback(S=>{if(Wj(S,a)){S.preventDefault();let E=s!==void 0?s:Ks(v)===Ks(b),C=()=>y(t,{replace:E,unstable_mask:i,state:c,preventScrollReset:u,relative:d,viewTransition:h,unstable_defaultShouldRevalidate:x});m?p.startTransition(()=>C()):C()}},[v,y,b,s,i,c,a,t,u,d,h,x,m])}var xS=0,gS=()=>`__${String(++xS)}__`;function vS(){let{router:t}=Wv("useSubmit"),{basename:a}=p.useContext(tr),s=Bj(),i=t.fetch,c=t.navigate;return p.useCallback(async(u,d={})=>{let{action:h,method:x,encType:m,formData:y,body:v}=Kj(u,a);if(d.navigate===!1){let b=d.fetcherKey||gS();await i(b,s,d.action||h,{unstable_defaultShouldRevalidate:d.unstable_defaultShouldRevalidate,preventScrollReset:d.preventScrollReset,formData:y,body:v,formMethod:d.method||x,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||x,formEncType:d.encType||m,replace:d.replace,state:d.state,fromRouteId:s,flushSync:d.flushSync,viewTransition:d.viewTransition})},[i,c,a,s])}function yS(t,{relative:a}={}){let{basename:s}=p.useContext(tr),i=p.useContext(Hr);Yt(i,"useFormAction must be used inside a RouteContext");let[c]=i.matches.slice(-1),u={...ai(t||".",{relative:a})},d=ga();if(t==null){u.search=d.search;let h=new URLSearchParams(u.search),x=h.getAll("index");if(x.some(y=>y==="")){h.delete("index"),x.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:xr([s,u.pathname])),Ks(u)}function bS(t,{relative:a}={}){let s=p.useContext(Ov);Yt(s!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=Wv("useViewTransitionState"),c=ai(t,{relative:a});if(!s.isTransitioning)return!1;let u=Ur(s.currentLocation.pathname,i)||s.currentLocation.pathname,d=Ur(s.nextLocation.pathname,i)||s.nextLocation.pathname;return Fo(c.pathname,d)!=null||Fo(c.pathname,u)!=null}var tc=Tv();const jS=Nv(tc),SS="modulepreload",kS=function(t){return"/"+t},eg={},Pl=function(a,s,i){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]"),x=(h==null?void 0:h.nonce)||(h==null?void 0:h.getAttribute("nonce"));c=d(s.map(m=>{if(m=kS(m),m in eg)return;eg[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":SS,y||(b.as="script"),b.crossOrigin="",b.href=m,x&&b.setAttribute("nonce",x),document.head.appendChild(b),y)return new Promise((S,E)=>{b.addEventListener("load",S),b.addEventListener("error",()=>E(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)})},wS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function Co(t){if(typeof t!="string")return null;const a=t.trim();return a===""||!wS.test(a)||a==="0.0.0"?null:a}function qv(t){if(t.preferInstalled){const c=Co(t.installedCurrentVersion);if(c)return{version:c,versionSource:"registry"}}const a=Co(t.frontmatterVersion);if(a)return{version:a,versionSource:"frontmatter"};const s=Co(t.registryCurrentVersion);if(s)return{version:s,versionSource:"registry"};const i=Co(t.pluginVersion);return i?{version:i,versionSource:"plugin"}:{version:"1.0.0",versionSource:"default"}}const tg={own:"authoring-project",installed:"available-project",global:"available-personal"},lf=new Set(["available-project","available-personal","available-plugin","authoring-project","authoring-plugin"]);function CS(t){if(typeof t=="string"){if(lf.has(t))return t;if(Object.prototype.hasOwnProperty.call(tg,t))return tg[t]}return"authoring-project"}function ES(t){return t.startsWith("available-")?"available":"authoring"}function NS(t){const a=t.indexOf("-");return t.slice(a+1)}const Zn="";class Ga extends Error{constructor(a,s,i){super(a),this.name="ApiError",this.status=s,this.details=i}}async function De(t,a){const s=await fetch(`${Zn}${t}`,a);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText})),c=i&&typeof i=="object"?i:void 0;throw new Ga((i==null?void 0:i.error)||`HTTP ${s.status}`,s.status,c)}return s.json()}async function ng(t,a){const s=await fetch(t,a);return s.status>=502&&s.status<=504?(await new Promise(i=>setTimeout(i,250)),fetch(t,a)):s}function en(t){return typeof t=="string"&&t.length>0?t:null}function TS(t){return typeof t=="number"&&Number.isFinite(t)?t:null}function Td(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 RS(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 i;a.scope==="own"||a.scope==="installed"||a.scope==="global"?i=a.scope:i=s==="installed"?"installed":"own";let c;a.installMethod==="authored"||a.installMethod==="copied"||a.installMethod==="symlinked"?c=a.installMethod:c=i==="own"?"authored":"copied";const u=typeof a.scopeV2=="string"&&lf.has(a.scopeV2)?a.scopeV2:CS(a.scope),d=ES(u),h=NS(u),x=typeof a.precedenceRank=="number"?a.precedenceRank:void 0;let m;a.shadowedBy===null?m=null:typeof a.shadowedBy=="string"&&lf.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:i,isSymlink:typeof a.isSymlink=="boolean"?a.isSymlink:!1,symlinkTarget:en(a.symlinkTarget),installMethod:c,sourcePath:en(a.sourcePath),scopeV2:u,group:d,source:h,pluginName:en(a.pluginName),pluginNamespace:en(a.pluginNamespace),pluginMarketplace:en(a.pluginMarketplace),pluginManifestPath:en(a.pluginManifestPath),pluginVersion:en(a.pluginVersion),precedenceRank:x,shadowedBy:m,description:en(a.description),version:en(a.version),category:en(a.category),author:en(a.author),license:en(a.license),homepage:en(a.homepage),repoUrl:en(a.repoUrl),skillPath:en(a.skillPath),tags:Td(a.tags),deps:Td(a.deps),mcpDeps:Td(a.mcpDeps),entryPoint:en(a.entryPoint),lastModified:en(a.lastModified),sizeBytes:TS(a.sizeBytes),sourceAgent:en(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=qv({frontmatterVersion:y.version??null,registryCurrentVersion:y.currentVersion??null,pluginVersion:y.pluginVersion??null,installedCurrentVersion:y.currentVersion??null,preferInstalled:y.origin==="installed"});return y.resolvedVersion=v.version,y.versionSource=v.versionSource,y}const ke={getConfig(){return De("/api/config")},setConfig(t,a){return De("/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(),i=await De(`/api/skills${s?"?"+s:""}`);return Array.isArray(i)?i.map(RS):[]},getAgents(){return De("/api/agents")},getSkillDetail(t,a){return De(`/api/skills/${t}/${a}`)},async getEvals(t,a){const s=await De(`/api/skills/${t}/${a}/evals`);if(s&&typeof s=="object"&&"exists"in s){if(s.exists===!1)return{skill_name:a,evals:[]};const{exists:i,...c}=s;return c}return s},getEvalsEnvelope(t,a){return De(`/api/skills/${t}/${a}/evals`)},getActivationHistoryEnvelope(t,a){return De(`/api/skills/${t}/${a}/activation-history`)},saveEvals(t,a,s){return De(`/api/skills/${t}/${a}/evals`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},generateEvals(t,a){return De(`/api/skills/${t}/${a}/generate-evals`,{method:"POST"})},async getLatestBenchmark(t,a){const s=await fetch(`${Zn}/api/skills/${t}/${a}/benchmark/latest`);if(!s.ok){const i=await s.json().catch(()=>({error:s.statusText}));throw new Ga(i.error||`HTTP ${s.status}`,s.status)}return s.json()},getHistory(t,a,s){const i=new URLSearchParams;s!=null&&s.model&&i.set("model",s.model),s!=null&&s.type&&i.set("type",s.type),s!=null&&s.from&&i.set("from",s.from),s!=null&&s.to&&i.set("to",s.to);const c=i.toString();return De(`/api/skills/${t}/${a}/history${c?"?"+c:""}`)},getHistoryEntry(t,a,s){return De(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`)},compareRuns(t,a,s,i){return De(`/api/skills/${t}/${a}/history-compare?a=${encodeURIComponent(s)}&b=${encodeURIComponent(i)}`)},getCaseHistory(t,a,s,i){const c=new URLSearchParams;i&&c.set("model",i);const u=c.toString();return De(`/api/skills/${t}/${a}/history/case/${s}${u?"?"+u:""}`)},deleteHistoryEntry(t,a,s){return De(`/api/skills/${t}/${a}/history/${encodeURIComponent(s)}`,{method:"DELETE"})},deleteSkill(t,a){return De(`/api/skills/${t}/${a}`,{method:"DELETE"})},uninstallSkill(t,a){return De(`/api/skills/${t}/${a}/uninstall`,{method:"POST"})},improveSkill(t,a,s){return De(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)})},instructEdit(t,a,s){return De(`/api/skills/${t}/${a}/improve`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"instruct",...s})})},applyImprovement(t,a,s){return De(`/api/skills/${t}/${a}/apply-improvement`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:s})})},getStats(t,a){return De(`/api/skills/${t}/${a}/stats`)},getDependencies(t,a){return De(`/api/skills/${t}/${a}/dependencies`)},getProjectLayout(){return De("/api/project-layout")},getProjectGitHubStatus(){return De("/api/project/github-status")},createSkill(t){return De("/api/skills/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},detectEngines(){return De("/api/studio/detect-engines")},saveDraft(t){return De("/api/skills/save-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillCreatorStatus(){return De("/api/skill-creator-status")},generateSkill(t){return De("/api/skills/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})},getSkillFiles(t,a){return De(`/api/skills/${t}/${a}/files`)},getSkillFile(t,a,s){return De(`/api/skills/${t}/${a}/file?path=${encodeURIComponent(s)}`)},saveSkillFile(t,a,s,i){return De(`/api/skills/${t}/${a}/file`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s,content:i})})},getLeaderboard(t,a){return De(`/api/skills/${t}/${a}/leaderboard`)},getLeaderboardEntry(t,a,s){return De(`/api/skills/${t}/${a}/leaderboard/${encodeURIComponent(s)}`)},startSweep(t,a,s){const i=`${Zn}/api/skills/${t}/${a}/sweep`,c=new EventSource(i);return fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify(s)}),c},getCredentials(t,a){return De(`/api/credentials/${t}/${a}`)},setCredential(t,a,s,i){return De(`/api/credentials/${t}/${a}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s,value:i})})},getParams(t,a){return De(`/api/credentials/${t}/${a}/params`)},getParamsRevealed(t,a,s){const i=s?`reveal=true&key=${encodeURIComponent(s)}`:"reveal=true";return De(`/api/credentials/${t}/${a}/params?${i}`)},searchModels(){return De("/api/openrouter/models")},async getSkillVersions(t,a){const s=await De(`/api/skills/${t}/${a}/versions`);return Array.isArray(s)?s:Array.isArray(s.versions)?s.versions:[]},getSkillVersionsEnvelope(t,a){return De(`/api/skills/${t}/${a}/versions`)},getVersionDiff(t,a,s,i){return De(`/api/skills/${t}/${a}/versions/diff?from=${s}&to=${i}`)},startBatchUpdate(t){const a=`${Zn}/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=`${Zn}/api/skills/${t}/${a}/update`,i=new EventSource(s);return fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"}}),i},async postSkillUpdate(t,a,s){let i,c;if(s&&typeof s.aborted=="boolean")i=s;else if(s&&typeof s=="object"){const y=s;i=y.signal,c=y.agentId}const u=c?`?agent=${encodeURIComponent(c)}`:"",d=`${Zn}/api/skills/${t}/${a}/update${u}`,h=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json"},signal:i});let x,m="";if(h.body){const y=h.body.getReader(),v=new TextDecoder;let b=!1,S="";for(;!b;){const C=await y.read();if(b=C.done,C.value){const w=v.decode(C.value,{stream:!b});S+=w,m.length<200&&(m+=w)}}const E=S.match(/event:\s*done[\s\S]*?data:\s*(\{[^\n]+\})/);if(E)try{x=JSON.parse(E[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{x=JSON.parse(v[1]).version}catch{}}return{ok:h.ok,status:h.status,body:m,version:x}},async rescanSkill(t,a){const s=`${t}/${a}`,i=await fetch(`${Zn}/api/v1/skills/${encodeURIComponent(s)}/rescan`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(`rescan failed: HTTP ${i.status}`);return await i.json()},async getSkillUpdates(){try{const t=await fetch(`${Zn}/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 ng(`${Zn}/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 i=await s.json().catch(()=>null);return Array.isArray(i)?i:i&&typeof i=="object"&&Array.isArray(i.results)?i.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 ng(`${Zn}/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),i=Array.isArray(s)?s:Array.isArray(s==null?void 0:s.results)?s.results:[],c=new Map(i.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 i=s!=null&&s.overwrite?"?overwrite=true":"";return Rd(`/api/skills/${t}/${a}/promote${i}`,s==null?void 0:s.onEvent,s==null?void 0:s.signal)},testInstallSkill(t,a,s){const i=new URLSearchParams;(s==null?void 0:s.dest)==="global"&&i.set("dest","global"),s!=null&&s.overwrite&&i.set("overwrite","true");const c=i.toString();return Rd(`/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 Rd(`/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 De(`/api/studio/ops${s?"?"+s:""}`)},deleteStudioOp(t){return De(`/api/studio/ops/${encodeURIComponent(t)}`,{method:"DELETE"})},studioOpsStream(){return new EventSource(`${Zn}/api/studio/ops/stream`)},gitRemote(){return De("/api/git/remote")},gitDiff(){return De("/api/git/diff",{method:"POST"})},gitStatus(){return De("/api/git/status")},gitCommitMessage(t){return De("/api/git/commit-message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})},gitPublish(t){return De("/api/git/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t??{})})}};async function Rd(t,a,s){const i=await fetch(`${Zn}${t}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},signal:s});if(!i.ok||!i.body){let y=`HTTP ${i.status}`,v;try{const S=await i.json();S.error&&(y=S.error),typeof S.code=="string"&&(v=S.code)}catch{}const b=new Ga(y,i.status);throw v&&(b.code=v),b}const c=i.body.getReader(),u=new TextDecoder;let d="",h="",x=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 E={};try{E=JSON.parse(S.slice(6))}catch{h="";continue}if(h==="started"||h==="copied"||h==="deleted"||h==="indexed"||h==="done"||h==="error"){const C={type:h,...E};a==null||a(C),C.type==="done"&&(x=C),C.type==="error"&&(m=C)}h=""}}if(m){const y=new Ga(m.message,500);throw y.code=m.code,y}if(!x)throw new Ga("Transfer stream ended without 'done' event",500);return x}function AS(t,a){if(!t||!a)return!1;const s=/^(\d+)\.(\d+)\.(\d+)/,i=t.match(s),c=a.match(s);if(!i||!c)return!1;const[,u,d,h]=i.map(Number),[,x,m,y]=c.map(Number);return u!==x?u>x:d!==m?d>m:h>=y}function MS(t,a){if(!a.length)return t;const s=new Map,i=new Map;for(const c of a){const u=c.name.split("/"),d=u.pop()||c.name;if(i.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=i.get(c.skill),!u)return c;const d=u.updateAvailable&&!AS(c.version,u.latest),h={...c,updateAvailable:d,currentVersion:u.installed,latestVersion:u.latest??void 0};typeof u.trackedForUpdates=="boolean"&&(h.trackedForUpdates=u.trackedForUpdates);const x=qv({frontmatterVersion:h.version??null,registryCurrentVersion:h.currentVersion??null,pluginVersion:h.pluginVersion??null,installedCurrentVersion:h.currentVersion??null,preferInstalled:!0});return h.resolvedVersion=x.version,h.versionSource=x.versionSource,h})}const $o=new Map,Pa=new Map,Ps=new Map;function Bn(t){$o.delete(t),Pa.delete(t);const a=Ps.get(t);if(a)for(const s of a)s()}function qa(t,a,s={}){const{ttl:i=3e4,enabled:c=!0}=s,[,u]=p.useState(0),[d,h]=p.useState(void 0),[x,m]=p.useState(0),y=p.useRef(!0),v=p.useRef(t);v.current=t;const b=()=>{h(void 0),Bn(t),m(C=>C+1)};p.useEffect(()=>(y.current=!0,()=>{y.current=!1}),[]),p.useEffect(()=>{if(!c)return;const C=()=>{y.current&&m(w=>w+1)};return Ps.has(t)||Ps.set(t,new Set),Ps.get(t).add(C),()=>{var w;(w=Ps.get(t))==null||w.delete(C)}},[t,c]),p.useEffect(()=>{if(!c)return;const C=$o.get(t);if(!(!C||Date.now()-C.fetchedAt>i))return;if(Pa.has(t)){const R=Pa.get(t),_=()=>{y.current&&v.current===t&&u(z=>z+1)};R.subscribers.push(_);return}const N={promise:Promise.resolve(),subscribers:[]},T=a().then(R=>{$o.set(t,{data:R,fetchedAt:Date.now()}),Pa.delete(t),y.current&&v.current===t&&(h(void 0),u(_=>_+1));for(const _ of N.subscribers)_()},R=>{Pa.delete(t);const _=R instanceof Error?R:new Error(String(R));y.current&&v.current===t&&(h(_),u(z=>z+1));for(const z of N.subscribers)z()});N.promise=T,Pa.set(t,N)},[t,a,i,c,x]);const S=$o.get(t),E=c&&!S&&!d&&Pa.has(t);return{data:S==null?void 0:S.data,loading:E,error:d,revalidate:b}}function LS(t){const[a,s]=p.useState(()=>typeof window>"u"?!1:window.matchMedia(t).matches);return p.useEffect(()=>{const i=window.matchMedia(t);s(i.matches);const c=u=>s(u.matches);return i.addEventListener("change",c),()=>i.removeEventListener("change",c)},[t]),a}const zS=500,sf="vskill.updates.seenLastId";function DS(){if(typeof window>"u")return null;try{return window.localStorage.getItem(sf)}catch{return null}}function Ad(t){if(!(typeof window>"u"))try{t==null?window.localStorage.removeItem(sf):window.localStorage.setItem(sf,t)}catch{}}function _S(){let t=new Map;const a=new Set,s=new Set,i=[];let c=DS();c&&(s.add(c),i.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),i.push(h),i.length>zS){const x=i.shift();x&&s.delete(x)}c=h,Ad(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(),i.length=0,c=null,Ad(null)},mergeBulk(h){if(h.length!==0){for(const x of h)t.set(x.skillId,x);u()}},getSeenLastId(){return c},reset(){t=new Map,s.clear(),i.length=0,c=null,Ad(null),u()}}}const Ua=_S(),OS=3e5,BS=500,IS=15e3,$S=6e4,US=6e4,HS="/api/v1/skills/stream";function rg(t){const a=new Map;for(const s of t){const i=s.name.split("/").pop()||s.name;a.set(i,s)}return a}function ag(t){let a=0;for(const s of t)s.updateAvailable&&a++;return a}function PS(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 VS(t){const a=(t==null?void 0:t.intervalMs)??OS,s=(t==null?void 0:t.debounceMs)??BS,i=(t==null?void 0:t.timeoutMs)??IS,c=(t==null?void 0:t.staleAfterMs)??$S,u=(t==null?void 0:t.disconnectFallbackMs)??US,d=(t==null?void 0:t.streamUrlBase)??HS,h=p.useMemo(()=>!(t!=null&&t.skillIds)||t.skillIds.length===0?"":[...t.skillIds].sort().join(","),[t==null?void 0:t.skillIds]),x=p.useMemo(()=>{const D=(t==null?void 0:t.trackingSkillIds)??(t==null?void 0:t.skillIds)??[];return D.length===0?"":[...D].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,E]=p.useState(0),[C,w]=p.useState(!1),[N,T]=p.useState(null),[R,_]=p.useState(null),z=p.useRef(null),P=p.useRef(null),k=p.useRef(null),O=p.useRef(null),L=p.useRef(!0),[B,U]=p.useState(()=>h?"connecting":"fallback"),Y=p.useRef(B);Y.current=B;const X=p.useSyncExternalStore(D=>Ua.subscribe(D),()=>Ua.getSnapshot(),()=>Ua.getSnapshot()),J=X.size,$=p.useCallback(async()=>{w(!0);const D=new AbortController,W=setTimeout(()=>D.abort(),i);try{const te=await Promise.race([ke.getSkillUpdates(),new Promise((q,ce)=>{D.signal.addEventListener("abort",()=>{ce(new Error("TIMEOUT"))})})]);if(te==="TIMEOUT")throw new Error("TIMEOUT");if(!L.current)return;y(te),b(rg(te)),E(ag(te)),P.current=Date.now(),T(P.current),_(null)}catch(te){if(!L.current)return;_(te instanceof Error?te:new Error(String(te)))}finally{clearTimeout(W),L.current&&w(!1)}},[i]),M=p.useCallback(()=>{if(z.current)return z.current;const D=$().finally(()=>{z.current=null});return z.current=D,D},[$]),I=p.useCallback(()=>{k.current==null&&(k.current=setInterval(()=>{M()},a))},[a,M]),F=p.useCallback(()=>{k.current!=null&&(clearInterval(k.current),k.current=null)},[]);p.useEffect(()=>{L.current=!0,(P.current==null||Date.now()-P.current>c)&&M(),(typeof document>"u"||document.visibilityState!=="hidden")&&I();const te=()=>{if(O.current&&(clearTimeout(O.current),O.current=null),document.visibilityState==="hidden"){F();return}O.current=setTimeout(()=>{O.current=null,(P.current==null||Date.now()-P.current>c)&&M(),I()},s)};return typeof document<"u"&&document.addEventListener("visibilitychange",te),()=>{L.current=!1,typeof document<"u"&&document.removeEventListener("visibilitychange",te),O.current&&clearTimeout(O.current),F()}},[]);const H=p.useCallback(async D=>{if(D.length!==0)try{const W=await ke.checkSkillUpdates(D);if(!L.current||W.length===0)return;const te=Date.now(),q=W.filter(Q=>Q.skillId&&Q.eventId&&Q.version).map(Q=>({skillId:Q.skillId,version:Q.version,eventId:Q.eventId,publishedAt:Q.publishedAt,diffSummary:Q.diffSummary,receivedAt:te}));q.length>0&&Ua.mergeBulk(q);const ce=W.filter(Q=>typeof Q.trackedForUpdates=="boolean"||typeof Q.updateAvailable=="boolean").map(Q=>({name:Q.name??Q.skillId,installed:Q.installed??"",latest:Q.latest??null,updateAvailable:Q.updateAvailable??!1,trackedForUpdates:typeof Q.trackedForUpdates=="boolean"?Q.trackedForUpdates:void 0}));ce.length>0&&y(Q=>{const ye=new Map;for(const Ne of Q)ye.set(Ne.name.split("/").pop()||Ne.name,Ne);let oe=0;for(const Ne of ce){const Be=Ne.name.split("/").pop()||Ne.name,Le=ye.get(Be);if(Le){const Pe={...Le};Le.trackedForUpdates===void 0&&Ne.trackedForUpdates!==void 0&&(Pe.trackedForUpdates=Ne.trackedForUpdates),ye.set(Be,Pe)}else ye.set(Be,{name:Ne.name,installed:Ne.installed??"",latest:Ne.latest??null,updateAvailable:Ne.updateAvailable??!1,trackedForUpdates:Ne.trackedForUpdates}),oe+=1}if(oe===0&&ye.size===Q.length)return Q;const be=[...ye.values()];return b(rg(be)),E(ag(be)),be})}catch{}},[]);p.useEffect(()=>{const D=h||x;if(!D){U("fallback");return}if(typeof window>"u"||typeof EventSource>"u"){U("fallback");return}U("connecting");const W=D.split(","),te=`${d}?skills=${encodeURIComponent(D)}`;let q=null,ce=null,Q=null;const ye=()=>{ce==null&&(ce=setTimeout(()=>{ce=null,L.current&&Y.current!=="connected"&&U("fallback")},u))},oe=()=>{ce!=null&&(clearTimeout(ce),ce=null)};ye();const be=1e3,Ne=()=>{L.current&&Q==null&&(Q=setTimeout(()=>{if(Q=null,!!L.current&&!(q&&q.readyState!==EventSource.CLOSED)){if(q)try{q.close()}catch{}Pe()}},be))},Be=se=>{if(!L.current)return;let de;try{de=JSON.parse(se.data)}catch{return}if(!PS(de)||Ua.ingest(de)==="duplicate")return;if(typeof document>"u"||document.visibilityState!=="hidden"){const je=`${de.skillId} updated to ${de.version}`;window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:je,severity:"info",skillId:de.skillId,version:de.version,eventId:de.eventId}}))}},Le=()=>{L.current&&(Ua.clearSeen(),H(W))},Pe=()=>{L.current&&(q=new EventSource(te),q.onopen=()=>{L.current&&(oe(),U("connected"))},q.onerror=()=>{L.current&&(ye(),q&&q.readyState===EventSource.CLOSED&&Ne())},q.onmessage=Be,q.addEventListener("gone",Le))};return Pe(),()=>{if(oe(),Q!=null&&(clearTimeout(Q),Q=null),q){try{q.removeEventListener("gone",Le)}catch{}try{q.close()}catch{}}}},[h,x,d,u,H]),p.useEffect(()=>{if(!x)return;const D=x.split(",");H(D)},[x,H]);const re=p.useCallback(D=>{Ua.dismiss(D)},[]);return{updates:m,updatesMap:v,updateCount:S,isRefreshing:C,lastFetchAt:N,error:R,refresh:M,updatesById:X,pushUpdateCount:J,status:B,dismiss:re}}function FS(t){const a=[];for(const s of t){const i=typeof s.uuid=="string"&&s.uuid.length>0,c=typeof s.slug=="string"&&s.slug.length>0;if(!i&&!c)continue;const u={};i&&(u.uuid=s.uuid),c&&(u.slug=s.slug),a.push(u)}return a}const GS={selectedSkill:null,mode:"browse",searchQuery:"",skills:[],skillsLoading:!0,skillsError:null,isMobile:!1,mobileView:"list",updateNotificationDismissed:!1,revealSkillId:null};function WS(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 Yv=p.createContext(null),Kv=Yv;function cr(){const t=p.useContext(Kv);if(!t)throw new Error("useStudio must be used within StudioProvider");return t}function qS({children:t}){const[a,s]=p.useReducer(WS,GS),i=LS("(max-width: 767px)");p.useEffect(()=>{s({type:"SET_MOBILE",isMobile:i})},[i]);const[c,u]=p.useState(()=>{try{const H=window.localStorage.getItem("vskill.studio.prefs");if(!H)return null;const re=JSON.parse(H);return typeof re.activeAgent=="string"?re.activeAgent:null}catch{return null}}),[d,h]=p.useState(c!==null);p.useEffect(()=>{function H(re){if(!(re instanceof CustomEvent))return;const D=re.detail;D!=null&&D.agentId&&(u(D.agentId),h(!0))}return window.addEventListener("studio:agent-changed",H),()=>window.removeEventListener("studio:agent-changed",H)},[]),p.useEffect(()=>{if(d)return;let H=!1;return ke.getAgents().then(re=>{if(H)return;const D=(re==null?void 0:re.suggested)??"claude-code";u(W=>W??D),h(!0)}).catch(()=>{H||(u(re=>re??"claude-code"),h(!0))}),()=>{H=!0}},[d]);const x=p.useCallback(()=>{if(!d||!c)return Promise.resolve();s({type:"SET_SKILLS_LOADING",loading:!0});const H={agent:c};return ke.getSkills(H).then(re=>{s({type:"SET_SKILLS",skills:re});const W=window.location.hash.match(/^#\/skills\/([^/]+)\/([^/?]+)/);if(W){const[,te,q]=W,ce=re.find(Q=>Q.plugin===te&&Q.skill===q);ce&&s({type:"SELECT_SKILL",skill:{plugin:te,skill:q,origin:ce.origin}})}}).catch(re=>s({type:"SET_SKILLS_ERROR",error:re.message}))},[c,d]);p.useEffect(()=>{x()},[x]);const m=p.useCallback(H=>{s({type:"SELECT_SKILL",skill:H}),window.location.hash=`/skills/${H.plugin}/${H.skill}`},[]),y=p.useRef(a.skills);p.useEffect(()=>{y.current=a.skills},[a.skills]);const v=p.useCallback((H,re)=>{const D=y.current,W=H?D.find(ce=>ce.plugin===H&&ce.skill===re):D.find(ce=>ce.skill===re&&ce.source!=="plugin");if(!H&&!W){typeof console<"u"&&console.warn(`[StudioContext] revealSkill: no plugin provided and skill "${re}" not yet in state — skipping reveal`);return}const te=(W==null?void 0:W.plugin)??H,q=(W==null?void 0:W.origin)??"source";s({type:"REVEAL_SKILL",skill:{plugin:te,skill:re,origin:q}}),window.location.hash=`/skills/${te}/${re}`},[]),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)},[]),E=p.useCallback(H=>{s({type:"SET_MODE",mode:H})},[]),C=p.useCallback(H=>{s({type:"SET_SEARCH",query:H})},[]),w=p.useCallback(H=>{s({type:"SET_MOBILE_VIEW",view:H})},[]),N=p.useCallback(()=>{s({type:"DISMISS_UPDATE_NOTIFICATION"})},[]),T=p.useRef(new Map),R=p.useRef(""),_=p.useRef(!1),[z,P]=p.useState(""),k=p.useMemo(()=>a.skills.map(H=>`${H.plugin}/${H.skill}`),[a.skills]),O=p.useMemo(()=>z?z.split(",").filter(Boolean):[],[z]),L=VS({skillIds:O,trackingSkillIds:k}),B=p.useRef("");p.useEffect(()=>{const H=a.skills.filter(q=>q.origin==="installed");if(H.length===0){P(""),B.current="";return}const re=new Map;for(const q of L.updates)re.set(q.name.split("/").pop()||q.name,q);const D=H.map(q=>{const ce=re.get(q.skill),Q=q.currentVersion??(ce==null?void 0:ce.installed)??q.version??q.pluginVersion??"1.0.0";return{plugin:q.plugin,skill:q.skill,name:(ce==null?void 0:ce.name)??q.skill,currentVersion:Q}}),W=D.map(q=>`${q.plugin}/${q.skill}@${q.currentVersion}#${q.name}`).sort().join("|");if(W===B.current)return;B.current=W;let te=!1;return ke.resolveInstalledSkillIds(D).then(q=>{if(te)return;const ye=[...FS(q).flatMap(oe=>[oe.uuid,oe.slug].filter(Boolean))].sort().join(",");ye!==R.current&&(R.current=ye,T.current=new Map(q.map(oe=>[`${oe.plugin}/${oe.skill}`,{uuid:oe.uuid,slug:oe.slug}])),P(ye))}).catch(q=>{if(te||(B.current=""),!_.current){_.current=!0;const ce=q instanceof Error?q.message:String(q);console.warn("[studio] resolveInstalledSkillIds failed (using polling fallback):",ce)}}),()=>{te=!0}},[a.skills,L.updates]);const U=p.useMemo(()=>{const H=a.skills.map(re=>{if(!re.updateAvailable&&re.latestVersion===void 0&&re.trackedForUpdates===void 0)return re;const D={...re};return delete D.updateAvailable,delete D.currentVersion,delete D.latestVersion,delete D.trackedForUpdates,D});return MS(H,L.updates)},[a.skills,L.updates]),Y=p.useMemo(()=>{const H={source:0,installed:0};for(const re of U)re.updateAvailable&&(H[re.origin]+=1);return H},[U]),X=p.useMemo(()=>({...a,skills:U}),[a,U]),J=L.updateCount,$=L.refresh,M=L.isRefreshing,I=p.useCallback((H,re)=>{$(),x(),Bn(`versions/${H}/${re}`),L.dismiss(`${H}/${re}`)},[$,x,L]),F=p.useMemo(()=>({state:X,selectSkill:m,clearSelection:S,setMode:E,setSearch:C,setMobileView:w,refreshSkills:x,updateCount:J,dismissUpdateNotification:N,updates:L.updates,outdatedByOrigin:Y,isRefreshingUpdates:M,refreshUpdates:$,revealSkill:v,clearReveal:b,updatesById:L.updatesById,pushUpdateCount:L.pushUpdateCount,updateStreamStatus:L.status,dismissPushUpdate:L.dismiss,activeAgent:c,onSkillUpdated:I}),[X,m,S,E,C,w,x,J,N,L.updates,Y,M,$,v,b,L.updatesById,L.pushUpdateCount,L.status,L.dismiss,c,I]);return r.jsx(Kv.Provider,{value:F,children:t})}const YS={config:null,loading:!0};function KS(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 Xv=p.createContext(null);function Ya(){const t=p.useContext(Xv);if(!t)throw new Error("useConfig must be used within ConfigProvider");return t}function XS({children:t}){const[a,s]=p.useReducer(KS,YS),i=p.useCallback(()=>{ke.getConfig().then(d=>s({type:"SET_CONFIG",config:d})).catch(()=>{})},[]);p.useEffect(()=>{i()},[i]);const c=p.useCallback(async(d,h)=>{const x=await ke.setConfig(d,h);return s({type:"SET_CONFIG",config:x}),x},[]),u=p.useMemo(()=>({config:a.config,loading:a.loading,updateConfig:c,refreshConfig:i}),[a,c,i]);return r.jsx(Xv.Provider,{value:u,children:t})}function QS({topRail:t,sidebar:a,main:s,statusBar:i,resizeHandle:c,banner:u,liveMessage:d,sidebarWidth:h=320,sidebarHidden:x=!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:x?"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:[!x&&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}),!x&&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:i}),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 lg=["claude-cli","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed","ollama","lm-studio"],ZS={"claude-cli":".claude",cursor:".cursor","codex-cli":".codex","gemini-cli":".gemini",copilot:".github",zed:".zed"},JS={"claude-cli":"claude",cursor:"cursor","codex-cli":"codex","gemini-cli":"gemini"},e2={"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"},t2={"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 n2(t,a){var h,x;const s=ZS[t.id]??null,i=JS[t.id]??null,c=s?!!((h=a==null?void 0:a.wrapperFolders)!=null&&h[s]):!1,u=i?!!((x=a==null?void 0:a.binaries)!=null&&x[i]):!0,d=t.models.map(m=>({id:m.id,displayName:m.label,billingMode:t2[t.id]??"per-token",...m.pricing?{pricing:m.pricing}:{},...m.resolvedId?{resolvedId:m.resolvedId}:{}}));return{id:t.id,displayName:r2(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:e2[t.id]??null,models:d,resolvedModel:t.resolvedModel??null}}function r2(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 a2(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of lg){const c=a.get(i);c&&s.push(c)}for(const i of t)lg.includes(i.id)||s.push(i);return s}function l2(t){const[a,s]=p.useState(null),[i,c]=p.useState("loading"),[u,d]=p.useState(null),[h,x]=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 R=await T.json(),_=a2((R.providers||[]).map(z=>n2(z,R.detection)));s({agents:_,activeAgent:R.provider??null,activeModel:R.model??null}),c("ready"),d(null)}catch(T){c("error"),d(T.message)}},[]);p.useEffect(()=>{S()},[S]);const E=p.useCallback(async()=>{var R;const T=Date.now();if(!(T-y.current<5*6e4))try{const _=await fetch("/api/openrouter/models");if(!_.ok){_.status!==400&&x(`OpenRouter catalog fetch failed (${_.status})`);return}const z=await _.json();y.current=T,x(null),s(O=>{if(!O)return O;const L=O.agents.map(B=>{if(B.id!=="openrouter")return B;const U=z.models.map(X=>({id:X.id,displayName:X.name,contextWindow:X.contextWindow,pricing:X.pricing,billingMode:"per-token"}));return{...B,models:U,catalogAgeMs:z.ageSec?z.ageSec*1e3:0,cacheStale:!!z.stale}});return{...O,agents:L}});const P=z.ageSec??0;(z.stale===!0||P>600)&&((R=v.current)==null||R.call(v,"openrouter",P*1e3))}catch(_){x(`OpenRouter catalog unreachable: ${_.message}`)}},[]),C=p.useCallback(T=>{m.current=T,T==="openrouter"&&E()},[E]),w=p.useCallback(()=>{y.current=0,S()},[S]),N=p.useCallback(async(T,R)=>{var P,k;let _;try{_=await fetch("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:T,model:R})})}catch(O){(P=b.current)==null||P.call(b,`Network error while setting ${T}: ${O.message}`);return}if(_.ok){s(O=>O&&{...O,activeAgent:T,activeModel:R});return}let z=`Failed to set ${T} (${_.status})`;try{const O=await _.json();O&&typeof O.error=="string"&&(z=O.error)}catch{}(k=b.current)==null||k.call(b,z)},[]);return{status:i,catalog:a,error:u,openRouterError:h,focusAgent:C,refresh:w,activeAgentId:(a==null?void 0:a.activeAgent)??null,activeModelId:(a==null?void 0:a.activeModel)??null,setActive:N}}function Md({variant:t,label:a,onActivate:s,installUrl:i,tooltip:c}){function u(h){if(h.stopPropagation(),t==="cli-install"&&i){window.open(i,"_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 of({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 s2={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}`},i2={appTitle:"Skill Studio",themeToggleLight:"Switch to light theme",themeToggleDark:"Switch to dark theme",themeToggleAuto:"Switch to auto theme",projectPathLabel:"Project",modelLabel:"Model",healthLabel:"Health"},o2={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"},c2={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"},u2={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:"Find skills",openShortcuts:"Open this cheatsheet",toggleSidebar:"Toggle sidebar",toggleTheme:"Toggle theme"},d2={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."},f2={disconnected:"Disconnected — reconnecting…",reconnected:"Reconnected.",loading:"Loading skills…",loadingPlaceholderCount:"—"},p2={fieldRequired:"This field is required.",nameInvalid:"Use letters, numbers, and hyphens.",descriptionRequired:"Description is required.",saveFailed:"Save failed. Check the form for errors."},m2={boundaryHeadline:"Something broke in this view.",boundaryBody:"Reload the page to recover.",boundaryAction:"Reload"},h2={triggerLabel:"Agent and model",popoverTitle:"Select agent and model",footerHint:"↑↓ navigate · Enter select · Esc close",settingsButton:"Settings",noModelsYet:"No models yet.",searchPlaceholder:"Search 300+ models…",noMatches:t=>`No models match "${t}"`,clearSearch:"Clear",currentlyActive:"Currently active"},x2={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)."}},g2={subscriptionBilling:"· subscription",free:"· free"},v2={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`},y2={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.`},b2={triggerAriaLabel:"Choose active agent for the sidebar",popoverTitle:"Choose active agent",statsInstalled:"Installed",statsGlobal:"Global",statsPlugins:"Plugins",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}`},j2={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.`},S2={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"},k2={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."},w2={groupAvailable:"Available",groupAuthoring:"Authoring",sourceProject:"Project",sourcePersonal:"Personal",sourcePlugin:"Plugins",authoringSkills:"Skills"},C2={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"}},ae={sidebar:s2,shell:i2,detail:o2,actions:c2,shortcuts:u2,toasts:d2,connection:f2,forms:p2,errors:m2,picker:h2,providers:x2,models:g2,settings:v2,statusBar:y2,scopePicker:b2,scopeSection:j2,claudeCodeLabel:S2,setupDrawer:k2,setupProviders:C2,scopeLabels:w2},E2=new Set(["claude-cli","claude-code"]);function sg(t){return E2.has(t)}const ig=new Set(["claude-cli","claude-code","anthropic","openai","openrouter","cursor","codex-cli","gemini-cli","copilot","zed"]);function N2({agents:t,activeAgentId:a,focusedAgentId:s,onFocus:i,onSelect:c,onOpenSettings:u}){const d=t.filter(x=>ig.has(x.id)),h=t.filter(x=>!ig.has(x.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(x=>r.jsx(og,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.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(x=>r.jsx(og,{agent:x,isActive:x.id===a,isFocused:x.id===s,onFocus:i,onSelect:c,onOpenSettings:u},x.id))]})}function og({agent:t,isActive:a,isFocused:s,onFocus:i,onSelect:c,onOpenSettings:u}){const{providers:d}=ae,h={"claude-cli":d.claudeCli.caption,anthropic:d.anthropic.caption,openrouter:d.openrouter.caption},x={"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=sg(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:()=>i(t.id),onFocus:()=>i(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}),sg(t.id)&&r.jsx("span",{"data-testid":"claude-code-billing-label",title:ae.claudeCodeLabel.tooltip,style:{fontSize:10,color:"var(--text-secondary, var(--text-tertiary))",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginTop:1},children:ae.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(of,{unlocked:!0,size:10}):r.jsx(of,{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:ae.picker.currentlyActive}),!t.available&&t.ctaType==="api-key"&&r.jsx(Md,{variant:"api-key",label:t.id==="anthropic"?d.anthropic.addKeyCta:d.openrouter.addKeyCta,onActivate:()=>u(t.id)}),!t.available&&t.ctaType==="cli-install"&&x[t.id]&&r.jsx(Md,{variant:"cli-install",label:x[t.id].label,installUrl:x[t.id].url,onActivate:()=>{}}),!t.available&&t.ctaType==="start-service"&&r.jsx(Md,{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 T2(t,a,s,i){const d=t>=80,h=p.useRef(null),[x,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(x/a)-4),E=Math.ceil(s/a)+8,C=Math.min(t,S+E);return{visibleStart:S,visibleEnd:C}},[d,x,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 Qv=44,R2=352,A2=60,cg=480;function M2(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 ${ae.models.subscriptionBilling}`:ae.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,i=((d=t.pricing)==null?void 0:d.completion)??0,c=`$${s.toFixed(2)} / $${i.toFixed(2)} per 1M tokens`;return a?`${a} ctx · ${c}`:c}function L2(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 z2({agent:t,activeModelId:a,focusedIndex:s=-1,onSelect:i,onOpenSettings:c}){const[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(null);if(p.useEffect(()=>{const b=setTimeout(()=>x(u),A2);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:cg,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:ae.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:ae.providers.openrouter.addKeyCta})]});const y=p.useMemo(()=>L2(t.models,h),[t.models,h]),v=T2(y.length,Qv,R2);return r.jsxs("div",{role:"listbox","aria-label":"Model","data-testid":"model-list",style:{width:cg,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:ae.picker.searchPlaceholder,value:u,onChange:b=>d(b.target.value),"data-testid":"model-search-input","aria-label":ae.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:ae.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:ae.picker.clearSearch})]}):y.length===0?r.jsx("div",{style:{padding:16,color:"var(--text-muted, var(--text-tertiary))",fontSize:12},children:ae.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 E=v.visibleStart+S;return r.jsx(_2,{model:b,isActive:b.id===a,isFocused:s===E,onSelect:()=>i(b.id),resolvedModel:t.id==="claude-cli"?t.resolvedModel??null:null},b.id)})})})})]})}function D2(t,a,s){return a&&a.toLowerCase().includes(t.toLowerCase())?a:s??null}function _2({model:t,isActive:a,isFocused:s,onSelect:i,resolvedModel:c}){const u=M2(t),d=D2(t.id,c,t.resolvedId),h=d!==null,x=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:i,title:t.id,style:{width:"100%",minHeight:Qv,padding:"4px 12px",display:"flex",flexDirection:"column",alignItems:"flex-start",justifyContent:"center",gap:2,background:x,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 ug={anthropic:{stored:!1,updatedAt:null},openai:{stored:!1,updatedAt:null},openrouter:{stored:!1,updatedAt:null}};function O2(){const[t,a]=p.useState(null),[s,i]=p.useState(!0),[c,u]=p.useState(null),d=p.useCallback(async()=>{i(!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({...ug,...y}),u(null)}catch(m){u(m.message),a(ug)}finally{i(!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]),x=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:x,refresh:d}}function B2({onMigrated:t,fetchImpl:a}){const[s,i]=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){i({kind:"hidden"});return}const v=await y.json();v.pending&&(((m=v.darwinKeys)==null?void 0:m.length)??0)>0?i({kind:"visible",darwinKeys:v.darwinKeys??[]}):i({kind:"hidden"})}catch{i({kind:"hidden"})}},[c]);p.useEffect(()=>{u()},[u]);const d=p.useCallback(async()=>{i({kind:"working"});try{const m=await c("/api/settings/migration-perform",{method:"POST",headers:{"Content-Type":"application/json"}});if(!m.ok){i({kind:"error",message:`Migration failed (${m.status})`});return}const y=await m.json().catch(()=>({migrated:[]}));t==null||t(y.migrated??[]),await u()}catch(m){i({kind:"error",message:m.message})}},[c,u,t]),h=p.useCallback(async()=>{i({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:Ld,children:"Retry"})]});const x=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:x,"data-testid":"migration-migrate",style:{...Ld,background:"var(--accent, var(--color-accent))",color:"white",opacity:x?.6:1},children:x?"Importing…":"Migrate"}),r.jsx("button",{type:"button",onClick:()=>void h(),"data-testid":"migration-dismiss",style:{...Ld,background:"transparent",border:"none",color:"var(--text-muted, var(--text-tertiary))",textDecoration:"underline",padding:"4px 6px"},children:"Dismiss for 30 days"})]})}const Ld={padding:"4px 10px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},I2=[{id:"anthropic",name:ae.providers.anthropic.name,keyIssuanceUrl:ae.providers.anthropic.keyIssuanceUrl,prefix:ae.providers.anthropic.keyPrefix,placeholder:`Paste ${ae.providers.anthropic.name} key`},{id:"openai",name:ae.providers.openai.name,keyIssuanceUrl:ae.providers.openai.keyIssuanceUrl,prefix:ae.providers.openai.keyPrefix,placeholder:ae.providers.openai.pastePlaceholder},{id:"openrouter",name:ae.providers.openrouter.name,keyIssuanceUrl:ae.providers.openrouter.keyIssuanceUrl,prefix:ae.providers.openrouter.keyPrefix,placeholder:`Paste ${ae.providers.openrouter.name} key`}];function $2(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 Zv({open:t,onClose:a,initialProvider:s,onToast:i}){const{state:c,save:u,remove:d,refresh:h}=O2(),x=p.useRef(null),m=p.useRef(null),[y,v]=p.useState(null);p.useEffect(()=>{if(!t)return;let S=!1;return(async()=>{try{const E=await fetch("/api/settings/storage-path");if(!E.ok)throw new Error(`GET /api/settings/storage-path returned ${E.status}`);const C=await E.json();S||v(C.path??null)}catch{S||v(null)}})(),()=>{S=!0}},[t]),p.useEffect(()=>{if(!t)return;const S=document.activeElement,E=setTimeout(()=>{var N;const C=s?`input[data-provider="${s}"]`:"input[data-provider]",w=(N=x.current)==null?void 0:N.querySelector(C);w==null||w.focus()},0);return()=>{var C;clearTimeout(E),(C=S==null?void 0:S.focus)==null||C.call(S)}},[t,s]),p.useEffect(()=>{if(!t)return;const S=E=>{if(E.key==="Escape"){E.preventDefault(),a();return}if(E.key==="Tab"&&x.current){const C=x.current.querySelectorAll("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");if(C.length===0)return;const w=C[0],N=C[C.length-1];E.shiftKey&&document.activeElement===w?(E.preventDefault(),N.focus()):!E.shiftKey&&document.activeElement===N&&(E.preventDefault(),w.focus())}};return document.addEventListener("keydown",S),()=>document.removeEventListener("keydown",S)},[t,a]);const b=p.useCallback(async()=>{var S,E;if(y)try{await((E=(S=navigator.clipboard)==null?void 0:S.writeText)==null?void 0:E.call(S,y)),i==null||i(ae.settings.pathCopied)}catch{}},[i,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:x,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:ae.settings.title}),r.jsx(B2,{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:ae.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:ae.settings.sectionApiKeys}),I2.map(S=>r.jsx(U2,{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 E=>{const C=await u(S.id,E);return i==null||i(ae.settings.keySaved(S.name)),C},onRemove:async()=>{await d(S.id),i==null||i(ae.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?ae.settings.storagePath(y):ae.settings.storagePathFallback}),r.jsx("button",{type:"button",onClick:b,disabled:!y,"data-testid":"settings-copy-path",style:{...Va,opacity:y?1:.5,cursor:y?"pointer":"not-allowed"},children:ae.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 U2({providerId:t,providerName:a,keyIssuanceUrl:s,prefix:i,placeholder:c,metadata:u,onSave:d,onRemove:h,inputRef:x}){const[m,y]=p.useState(""),[v,b]=p.useState(!1),[S,E]=p.useState(!1),[C,w]=p.useState(!1),[N,T]=p.useState(null),R=m.trim(),_=R.length===0,z=R.length>0&&!R.startsWith(i),P=p.useCallback(async()=>{if(_)return;E(!0);const L=R;y("");try{const B=await d(L);B.warning?T(B.warning):T(null)}finally{E(!1)}},[_,d,R]),k=p.useCallback(async()=>{var L;try{if(!((L=navigator.clipboard)!=null&&L.readText))return;const B=await navigator.clipboard.readText();y(B)}catch{}},[]),O=p.useCallback(async()=>{w(!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:x,type:v?"text":"password",value:m,onChange:L=>{y(L.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:Va,children:v?ae.settings.hide:ae.settings.show}),r.jsx("button",{type:"button",onClick:k,style:Va,children:ae.settings.paste})]}),z&&r.jsx("div",{role:"status","data-testid":`prefix-warn-${t}`,style:dg,children:ae.settings.prefixWarn(a)}),N&&r.jsx("div",{role:"status",style:dg,children:N}),r.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center"},children:[r.jsx("button",{type:"button",onClick:P,disabled:_||S,"data-testid":`save-${t}`,style:{...Va,background:_?"var(--surface-2)":"var(--accent, var(--color-accent))",color:_?"var(--text-muted)":"white",cursor:_?"not-allowed":"pointer"},children:ae.settings.save}),(u==null?void 0:u.stored)&&r.jsx(r.Fragment,{children:C?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:{fontSize:12},children:ae.settings.removeConfirm(a)}),r.jsx("button",{type:"button",onClick:O,"data-testid":`remove-confirm-${t}`,style:{...Va,background:"var(--danger, #b33)",color:"white"},children:"Confirm"}),r.jsx("button",{type:"button",onClick:()=>w(!1),style:Va,children:"Cancel"})]}):r.jsx("button",{type:"button",onClick:()=>w(!0),"data-testid":`remove-${t}`,style:{...Va,color:"var(--text-muted)"},children:ae.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?ae.settings.keyStoredAt($2(u.updatedAt)):ae.settings.noKey})]})]})}const Va={padding:"4px 8px",background:"var(--surface-2, transparent)",border:"1px solid var(--border-subtle)",borderRadius:4,color:"var(--text-primary)",fontSize:12,cursor:"pointer"},dg={fontSize:11,color:"var(--warning, var(--text-muted))"};function H2(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia("(prefers-reduced-motion: reduce)").matches}function P2({onToast:t}){const{status:a,catalog:s,focusAgent:i,setActive:c}=l2({onStaleCatalog:(B,U)=>{const Y=Math.round(U/6e4);t==null||t(`Using cached ${B} catalog (${Y} min old)`)},onSetActiveError:B=>t==null?void 0:t(B)}),[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,y]=p.useState(),[v,b]=p.useState(null),[S,E]=p.useState("agents"),[C,w]=p.useState(0),N=p.useRef(null);p.useRef(null),p.useEffect(()=>{var B;s&&!v&&b(s.activeAgent??((B=s.agents[0])==null?void 0:B.id)??null)},[s,v]);const T=(s==null?void 0:s.agents)??[],R=p.useMemo(()=>T.find(B=>B.id===v)??T[0],[T,v]);p.useEffect(()=>{w(0)},[v]);const _=p.useCallback(()=>{var B;d(!0),E("agents"),b((s==null?void 0:s.activeAgent)??((B=T[0])==null?void 0:B.id)??null),w(0)},[s,T]),z=p.useCallback(()=>{var B;d(!1),(B=N.current)==null||B.focus()},[]);p.useEffect(()=>{const B=U=>{var X;if(!(U.metaKey||U.ctrlKey)||U.key.toLowerCase()!=="k")return;const Y=(X=document.activeElement)==null?void 0:X.tagName;Y==="INPUT"||Y==="TEXTAREA"||(U.preventDefault(),d(J=>!J))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[]),p.useEffect(()=>{if(!u)return;const B=Y=>{if(Y.key==="Escape"){Y.preventDefault(),z();return}if(Y.key==="ArrowDown"){Y.preventDefault(),U(1);return}if(Y.key==="ArrowUp"){Y.preventDefault(),U(-1);return}if(Y.key==="ArrowRight"&&S==="agents"){Y.preventDefault(),E("models"),w(X=>{const J=((R==null?void 0:R.models.length)??1)-1;return Math.max(0,Math.min(X,Math.max(0,J)))});return}if(Y.key==="ArrowLeft"&&S==="models"){Y.preventDefault(),E("agents");return}if(Y.key==="Enter"){if(Y.preventDefault(),S==="agents"&&R)E("models"),w(0);else if(S==="models"&&R){const X=Math.max(0,Math.min(R.models.length-1,C)),J=R.models[X];J&&(c(R.id,J.id),z())}return}};function U(Y){if(S==="agents"){const X=T.findIndex($=>$.id===v),J=T[Math.max(0,Math.min(T.length-1,X+Y))];J&&(b(J.id),i(J.id));return}if(S==="models"&&R){const X=R.models.length;if(X===0)return;w(J=>{const $=J+Y;return Math.max(0,Math.min(X-1,$))})}}return document.addEventListener("keydown",B),()=>document.removeEventListener("keydown",B)},[u,S,T,v,R,C,z,i,c]);const P=p.useCallback(B=>{y(B==="anthropic"||B==="openrouter"?B:void 0),x(!0),d(!1)},[]),k=T.find(B=>B.id===(s==null?void 0:s.activeAgent)),O=k==null?void 0:k.models.find(B=>B.id===(s==null?void 0:s.activeModel)),L=p.useMemo(()=>{if(a!=="ready"||!s)return"Loading…";const B=(k==null?void 0:k.displayName)??"Agent",U=(O==null?void 0:O.displayName)??s.activeModel??"Model";return`${B} · ${U}`},[a,s,k,O]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:N,type:"button","data-testid":"agent-model-picker-trigger",onClick:()=>u?z():_(),"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:k!=null&&k.available?"var(--accent, var(--color-accent))":"var(--text-muted, var(--text-tertiary))",flexShrink:0}}),r.jsx("span",{children:L})]}),u&&typeof document<"u"&&tc.createPortal(r.jsxs(V2,{reducedMotion:H2(),onClickOutside:z,children:[r.jsxs("div",{style:{display:"flex",height:440,maxHeight:"60vh"},children:[r.jsx(N2,{agents:T,activeAgentId:(s==null?void 0:s.activeAgent)??null,focusedAgentId:v,onFocus:B=>{b(B),i(B)},onSelect:B=>{b(B),i(B),E("models")},onOpenSettings:P}),R&&r.jsx(z2,{agent:R,activeModelId:(s==null?void 0:s.activeModel)??null,focusedIndex:S==="models"?C:-1,onSelect:B=>{c(R.id,B),z()},onOpenSettings:P})]}),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:()=>P(),"data-testid":"picker-footer-settings",style:{background:"transparent",border:"none",color:"var(--text-primary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ae.picker.settingsButton}),r.jsx("span",{style:{fontFamily:"'JetBrains Mono Variable', 'JetBrains Mono', monospace"},children:ae.picker.footerHint})]})]}),document.body),r.jsx(Zv,{open:h,onClose:()=>x(!1),initialProvider:m,onToast:t})]})}function V2({children:t,reducedMotion:a,onClickOutside:s}){const i=p.useRef(null);return p.useEffect(()=>{const c=u=>{i.current&&!i.current.contains(u.target)&&s()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),r.jsxs("div",{ref:i,"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 fg(){typeof window>"u"||(window.location.hash="#/")}function F2({onHome:t}){const[a,s]=p.useState(!1),[i,c]=p.useState(!1),u=h=>{h.metaKey||h.ctrlKey||h.shiftKey||h.button!==0||(h.preventDefault(),fg(),t==null||t())},d=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),fg(),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:i?"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 pg=p.memo(function({message:a,politeness:s="polite",role:i}){const c=i??(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 G2({toast:t,onDismiss:a}){const[s,i]=p.useState(!0),c=p.useRef(null);p.useEffect(()=>(c.current=requestAnimationFrame(()=>{c.current=requestAnimationFrame(()=>i(!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 W2({toasts:t,onDismiss:a,liveMessage:s,liveAssertiveMessage:i}){return r.jsxs(r.Fragment,{children:[r.jsx(pg,{politeness:"polite",message:s}),r.jsx(pg,{politeness:"assertive",message:i}),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(G2,{toast:c,onDismiss:a})},c.id))})]})}const Jv=p.createContext(null);function nc(){const t=p.useContext(Jv);if(!t)throw new Error("useToast must be used inside <ToastProvider>.");return t}function q2({children:t,maxVisible:a=4,defaultDurationMs:s=4e3}){const[i,c]=p.useState([]),[u,d]=p.useState(""),[h,x]=p.useState(""),m=p.useRef(new Map),y=p.useCallback(w=>{const N=m.current.get(w);N&&(clearTimeout(N),m.current.delete(w)),c(T=>T.filter(R=>R.id!==w))},[]),v=p.useCallback((w,N)=>{if(N<=0)return;const T=setTimeout(()=>{y(w)},N);m.current.set(w,T)},[y]),b=p.useCallback(w=>{const N=w.id??`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,T={id:N,message:w.message,severity:w.severity??"info",durationMs:w.durationMs??s,action:w.action};return c(R=>[...R,T]),T.severity==="error"?x(T.message):d(T.message),v(N,T.durationMs),N},[s,v]),S=p.useCallback(()=>{for(const w of m.current.values())clearTimeout(w);m.current.clear(),c([])},[]);p.useEffect(()=>{function w(N){N.key==="Escape"&&c(T=>{if(T.length===0)return T;const R=T.slice(0,a),_=R[R.length-1],z=m.current.get(_.id);return z&&(clearTimeout(z),m.current.delete(_.id)),T.filter(P=>P.id!==_.id)})}return window.addEventListener("keydown",w),()=>window.removeEventListener("keydown",w)},[a]),p.useEffect(()=>()=>{for(const w of m.current.values())clearTimeout(w);m.current.clear()},[]);const E=i.slice(0,a),C=p.useMemo(()=>({toast:b,dismiss:y,clear:S}),[b,y,S]);return r.jsxs(Jv.Provider,{value:C,children:[t,r.jsx(W2,{toasts:E,onDismiss:y,liveMessage:u,liveAssertiveMessage:h})]})}function Y2(){const{data:t,loading:a}=qa("platform-health",async()=>{const s=await fetch("/api/platform/health");return s.ok?await s.json():{degraded:!1,reason:"platform-unreachable",statsAgeMs:0,oldestActiveAgeMs:0}},{ttl:6e4});return{data:t,loading:a}}const K2=p.lazy(()=>Pl(()=>import("./UpdateDropdown-B53G4Agp.js"),__vite__mapDeps([0,1])));function X2(){const{updateCount:t,updates:a,isRefreshingUpdates:s,refreshUpdates:i,selectSkill:c,revealSkill:u,skills:d,updatesById:h,activeAgent:x}=cr(),{toast:m}=nc(),{data:y}=Y2(),v=(y==null?void 0:y.degraded)===!0,b=p.useMemo(()=>{if(!h||h.size===0)return;const P=new Map;for(const[k,O]of h)O.diffSummary&&P.set(k,O.diffSummary);return P.size>0?P:void 0},[h]),[S,E]=p.useState(!1),C=p.useRef(null),w=p.useCallback(()=>E(!1),[]),N=v?"var(--color-own)":t>0?"var(--text-primary)":"var(--text-secondary)",T=t>9?"9+":String(t),R=t===0?"No updates available":`${t} updates available, open summary`,_=v?`${R} — platform crawler degraded`:R,z=v?"Update checks paused — verified-skill.com crawler is degraded. Your submissions are queued.":void 0;return r.jsxs("span",{"data-testid":"update-bell-anchor",style:{position:"relative",display:"inline-flex"},children:[r.jsxs("button",{ref:C,type:"button","data-testid":"update-bell","aria-label":_,"aria-haspopup":"dialog","aria-expanded":S,title:z,onClick:()=>E(P=>!P),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:N,cursor:"pointer"},children:[r.jsxs("svg",{"data-testid":"update-bell-icon",width:18,height:18,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",style:{display:"block",opacity:t>0||v?1:.75,color:N},children:[r.jsx("path",{d:"M5.5 17h11l-1.2-1.8a2 2 0 0 1-.3-1.1V10a4 4 0 1 0-8 0v4.1a2 2 0 0 1-.3 1.1L5.5 17Z"}),r.jsx("path",{d:"M10 20a2 2 0 0 0 4 0"}),r.jsx("circle",{cx:"17",cy:"7",r:"2.2",fill:"currentColor",stroke:"none"})]}),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:T})]}),S&&r.jsx(p.Suspense,{fallback:r.jsx("span",{"data-testid":"update-bell-fallback",children:"Loading…"}),children:r.jsx(K2,{updates:a,isRefreshing:s,diffSummariesById:b,onRefresh:()=>i(),onSelectSkill:P=>{const k=P.localSkill??P.name.split("/").pop()??"",O=P.localPlugin??"";if(u)u(O,k);else{const B=P.name.split("/"),U=B.length>=2?B[B.length-2]:B[0];c({plugin:U,skill:k,origin:"installed"})}if(!(d??[]).some(B=>B.skill===k&&(O===""||B.plugin===O))){const B=P.installLocations??[];if(B.length>0){const U=x?B.filter(X=>X.agent===x):[],Y=x?B.filter(X=>X.agent!==x):B;if(U.length>0&&Y.length>0){const X=Y.length>=2?`Also installed under ${Y.length} other locations.`:`Also installed under ${Y[0].agentLabel}.`;m({severity:"info",message:X})}else{const X=B[0].agentLabel;m({severity:"info",message:`Skill installed under ${X} — switch to ${X} to view details.`})}}}w()},onViewAll:()=>{window.location.hash="#/updates",w()},onClose:w,anchorRef:C})})]})}function mg(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:navigate-scope",{detail:t}))}function Q2({projectName:t,selected:a,onHome:s,projectPickerSlot:i,onRequestCreateSkill:c,findSkillsSlot:u}){const d=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(F2,{onHome:s}),i?r.jsx("div",{style:{borderLeft:"1px solid var(--border-default)",paddingLeft:10,display:"flex",alignItems:"center"},children:i}):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&&d&&r.jsxs(r.Fragment,{children:[r.jsx(hg,{segment:"origin",onClick:()=>mg({scope:"origin",origin:a.origin}),style:{textTransform:"uppercase",letterSpacing:"0.06em",fontWeight:600,color:a.origin==="installed"?"var(--status-installed)":"var(--status-own)"},children:d}),r.jsx(xg,{}),r.jsx(hg,{segment:"plugin",onClick:()=>mg({scope:"plugin",plugin:a.plugin}),style:{fontFamily:"var(--font-mono)",fontSize:11},children:a.plugin}),r.jsx(xg,{}),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:[u,c&&r.jsxs("button",{type:"button","data-slot":"create-skill-button",onClick:c,"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(X2,{})})]})]})}function hg({segment:t,onClick:a,style:s,children:i}){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:i})}function xg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)",fontSize:10},children:"›"})}const rc="vskill-theme";function ey(t){return t==="light"||t==="dark"||t==="auto"?t:"auto"}function Z2(t,a){return t==="light"||t==="dark"?t:a?"dark":"light"}function J2(t){try{const a=t.getItem(rc);return ey(a)}catch{return"auto"}}function ek(t,a){try{t.setItem(rc,a)}catch{}}function tk(t,a,s){t.dataset.theme=s,t.dataset.themeMode=a}function nk(t){if(!t)return!1;try{return t("(prefers-color-scheme: dark)").matches}catch{return!1}}const ty=p.createContext(null);function rk({storage:t,matchMedia:a,target:s,children:i}){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,x]=p.useState(()=>c?J2(c):"auto"),[m,y]=p.useState(()=>nk(u)),v=p.useMemo(()=>Z2(h,m),[h,m]);p.useEffect(()=>{d&&tk(d,h,v)},[d,h,v]),p.useEffect(()=>{if(!u)return;const E=u("(prefers-color-scheme: dark)"),C=N=>y(N.matches);if(typeof E.addEventListener=="function")return E.addEventListener("change",C),()=>E.removeEventListener("change",C);const w=E;return w.addListener(C),()=>w.removeListener(C)},[u]),p.useEffect(()=>{if(typeof window>"u")return;const E=C=>{C.key===rc&&x(ey(C.newValue))};return window.addEventListener("storage",E),()=>window.removeEventListener("storage",E)},[]),p.useEffect(()=>{if(!u||!d)return;let E;try{E=u("(prefers-contrast: more)")}catch{return}const C=T=>{T?d.dataset.contrast="more":d.dataset.contrast==="more"&&delete d.dataset.contrast};C(E.matches);const w=T=>C(T.matches);if(typeof E.addEventListener=="function")return E.addEventListener("change",w),()=>E.removeEventListener("change",w);const N=E;return N.addListener(w),()=>N.removeListener(w)},[u,d]);const b=p.useCallback(E=>{x(E),c&&ek(c,E)},[c]),S=p.useMemo(()=>({mode:h,resolvedTheme:v,setTheme:b}),[h,v,b]);return r.jsx(ty.Provider,{value:S,children:i})}function ny(){const t=p.useContext(ty);if(!t)throw new Error("useTheme must be used inside <ThemeProvider>. Wrap the app root in main.tsx.");return t}const gg=["claude-cli","anthropic","openrouter","ollama","lm-studio"];function ak(t){const a=new Map(t.map(i=>[i.id,i])),s=[];for(const i of gg){const c=a.get(i);c&&s.push(c)}for(const i of t)gg.includes(i.id)||s.push(i);return s}function lk(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 i=window.matchMedia(`(max-width: ${t}px)`),c=()=>s(i.matches);return(u=i.addEventListener)==null||u.call(i,"change",c),()=>{var d;return(d=i.removeEventListener)==null?void 0:d.call(i,"change",c)}},[t]),a}function sk({providers:t,onOpenSettings:a,onOpenInstallHelp:s}){const i=ak(t),c=lk(640),[u,d]=p.useState(!1),h=p.useCallback(x=>{x.available||x.kind==="api-key"?a==null||a(x.id):s==null||s(x.id)},[a,s]);if(c){const x=i.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":ae.statusBar.providerSummary(x,i.length),style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:11,cursor:"pointer",padding:"0 4px"},children:ae.statusBar.providerSummary(x,i.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:i.map(m=>r.jsx(vg,{p:m,onClick:h},m.id))})]})}return r.jsx("div",{"data-testid":"providers-segment",style:{display:"inline-flex",alignItems:"center",gap:4},children:i.map(x=>r.jsx(vg,{p:x,onClick:h,compact:!0},x.id))})}function vg({p:t,onClick:a,compact:s}){const i=t.available?ae.statusBar.unlocked(t.label):t.kind==="cli-install"?ae.statusBar.lockedCli(t.label):ae.statusBar.locked(t.label);return r.jsxs("button",{type:"button","data-testid":`provider-glyph-${t.id}`,"data-available":t.available,"aria-label":i,title:i,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(of,{unlocked:t.available,size:10}),!s&&r.jsx("span",{children:t.label})]})}function ik(){try{return typeof localStorage>"u"?null:localStorage.getItem(rc)}catch{return null}}function ok({projectPath:t,modelName:a,health:s="ok",onPathClick:i,providers:c,onOpenProviderSettings:u,onOpenProviderInstallHelp:d}){const{mode:h,resolvedTheme:x,setTheme:m}=ny(),v=ik()==="auto",b=ck(h,x,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(yg,{}),r.jsxs("span",{"aria-label":`Health: ${s}`,style:{display:"inline-flex",alignItems:"center",gap:6},children:[r.jsx(uk,{color:S}),r.jsx("span",{style:{textTransform:"capitalize"},children:s})]}),c&&c.length>0&&r.jsxs(r.Fragment,{children:[r.jsx(yg,{}),r.jsx(sk,{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(dk,{mode:h}),r.jsx("span",{style:{textTransform:"capitalize"},children:h})]})]})}function ck(t,a,s){return t==="light"?"dark":t==="dark"?"auto":s?"light":a==="light"?"dark":"light"}function uk({color:t}){return r.jsx("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:"50%",background:t,display:"inline-block",flexShrink:0}})}function yg(){return r.jsx("span",{"aria-hidden":"true",style:{color:"var(--border-default)"},children:"|"})}function dk({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 cf=new Set;function ry(){for(const t of cf)t()}const fk=5,pk=1e3,mk=6e4;function ay(){const[t,a]=p.useState(void 0),[s,i]=p.useState(!1),[c,u]=p.useState(!0),d=p.useRef(0),h=p.useRef(null),x=p.useRef(null),m=p.useRef(!0),y=p.useRef(0),[v,b]=p.useState(0),S=()=>{x.current!==null&&(clearTimeout(x.current),x.current=null)},E=p.useCallback(()=>{h.current&&(h.current.abort(),h.current=null)},[]),C=p.useCallback(async()=>{if(!m.current||document.visibilityState==="hidden")return;E();const N=new AbortController;h.current=N;try{const T=await fetch("/api/plugins",{signal:N.signal});if(!m.current)return;const R=await T.json();if(!m.current)return;d.current=0,a(R.plugins??[]),u(!1),i(!1),x.current=setTimeout(()=>{m.current&&b(_=>_+1)},mk)}catch(T){if(!m.current||T instanceof DOMException&&T.name==="AbortError")return;if(d.current+=1,u(!1),d.current>fk){i(!0);return}const R=pk*Math.pow(2,d.current-1);x.current=setTimeout(()=>{m.current&&b(_=>_+1)},R)}},[E]);p.useEffect(()=>(m.current=!0,()=>{m.current=!1,S(),E()}),[E]),p.useEffect(()=>{document.visibilityState!=="hidden"&&(S(),C())},[v,C]),p.useEffect(()=>{const N=()=>{document.visibilityState==="hidden"?(S(),E()):(d.current=0,i(!1),b(T=>T+1))};return document.addEventListener("visibilitychange",N),()=>{document.removeEventListener("visibilitychange",N)}},[E]);const w=p.useCallback(()=>{d.current=0,i(!1),S(),y.current+=1,b(N=>N+1)},[]);return p.useEffect(()=>(cf.add(w),()=>{cf.delete(w)}),[w]),{plugins:t,paused:s,loading:c,retry:w}}const ac=0,va=1,Vl=2,ly=4;function bg(t){return()=>t}function hk(t){t()}function sy(t,a){return s=>t(a(s))}function jg(t,a){return()=>t(a)}function xk(t,a){return s=>t(a,s)}function Lf(t){return t!==void 0}function gk(...t){return()=>{t.map(hk)}}function Fl(){}function lc(t,a){return a(t),t}function vk(t,a){return a(t)}function Et(...t){return t}function ot(t,a){return t(va,a)}function qe(t,a){t(ac,a)}function zf(t){t(Vl)}function Mt(t){return t(ly)}function Re(t,a){return ot(t,xk(a,ac))}function sr(t,a){const s=t(va,i=>{s(),a(i)});return s}function Sg(t){let a,s;return i=>c=>{a=c,s&&clearTimeout(s),s=setTimeout(()=>{i(a)},t)}}function iy(t,a){return t===a}function Ct(t=iy){let a;return s=>i=>{t(a,i)||(a=i,s(i))}}function Oe(t){return a=>s=>{t(s)&&a(s)}}function we(t){return a=>sy(a,t)}function mr(t){return a=>()=>{a(t)}}function he(t,...a){const s=yk(...a);return((i,c)=>{switch(i){case Vl:zf(t);return;case va:return ot(t,s(c))}})}function hr(t,a){return s=>i=>{s(a=t(a,i))}}function Wa(t){return a=>s=>{t>0?t--:a(s)}}function $r(t){let a=null,s;return i=>c=>{a=c,!s&&(s=setTimeout(()=>{s=void 0,i(a)},t))}}function Ye(...t){const a=new Array(t.length);let s=0,i=null;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;ot(u,x=>{const m=s;s|=h,a[d]=x,m!==c&&s===c&&i&&(i(),i=null)})}),u=>d=>{const h=()=>{u([d].concat(a))};s===c?h():i=h}}function yk(...t){return a=>t.reduceRight(vk,a)}function bk(t){let a,s;const i=()=>a==null?void 0:a();return function(c,u){switch(c){case va:return u?s===u?void 0:(i(),s=u,a=ot(t,u),a):(i(),Fl);case Vl:i(),s=null;return}}}function ge(t){let a=t;const s=et();return((i,c)=>{switch(i){case ac:a=c;break;case va:{c(a);break}case ly:return a}return s(i,c)})}function dn(t,a){return lc(ge(a),s=>Re(t,s))}function et(){const t=[];return((a,s)=>{switch(a){case ac:t.slice().forEach(i=>{i(s)});return;case Vl:t.splice(0,t.length);return;case va:return t.push(s),()=>{const i=t.indexOf(s);i>-1&&t.splice(i,1)}}})}function In(t){return lc(et(),a=>Re(t,a))}function at(t,a=[],{singleton:s}={singleton:!0}){return{constructor:t,dependencies:a,id:jk(),singleton:s}}const jk=()=>Symbol();function Sk(t){const a=new Map,s=({constructor:i,dependencies:c,id:u,singleton:d})=>{if(d&&a.has(u))return a.get(u);const h=i(c.map(x=>s(x)));return d&&a.set(u,h),h};return s(t)}function Vt(...t){const a=et(),s=new Array(t.length);let i=0;const c=2**t.length-1;return t.forEach((u,d)=>{const h=2**d;ot(u,x=>{s[d]=x,i|=h,i===c&&qe(a,s)})}),function(u,d){switch(u){case Vl:{zf(a);return}case va:return i===c&&d(s),ot(a,d)}}}function _e(t,a=iy){return he(t,Ct(a))}function uf(...t){return function(a,s){switch(a){case Vl:return;case va:return gk(...t.map(i=>ot(i,s)))}}}const qt={DEBUG:0,INFO:1,WARN:2,ERROR:3},kk={[qt.DEBUG]:"debug",[qt.ERROR]:"error",[qt.INFO]:"log",[qt.WARN]:"warn"},wk=()=>typeof globalThis>"u"?window:globalThis,ya=at(()=>{const t=ge(qt.ERROR);return{log:ge((a,s,i=qt.INFO)=>{const c=wk().VIRTUOSO_LOG_LEVEL??Mt(t);i>=c&&console[kk[i]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",a,s)}),logLevel:t}},[],{singleton:!0});function Ka(t,a,s){return Df(t,a,s).callbackRef}function Df(t,a,s){const i=Te.useRef(null);let c=d=>{};const u=Te.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(d=>{const h=()=>{const x=d[0].target;x.offsetParent!==null&&t(x)};s?h():requestAnimationFrame(h)}):null,[t,s]);return c=d=>{d&&a?(u==null||u.observe(d),i.current=d):(i.current&&(u==null||u.unobserve(i.current)),i.current=null)},{callbackRef:c,ref:i}}function Ck(t,a,s,i,c,u,d,h,x){const m=Te.useCallback(y=>{const v=Ek(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 E;S&&(E=b.ownerDocument.defaultView);const C=d?h?d.scrollLeft:d.scrollTop:S?h?E.scrollX||E.document.documentElement.scrollLeft:E.scrollY||E.document.documentElement.scrollTop:h?b.scrollLeft:b.scrollTop,w=d?h?d.scrollWidth:d.scrollHeight:S?h?E.document.documentElement.scrollWidth:E.document.documentElement.scrollHeight:h?b.scrollWidth:b.scrollHeight,N=d?h?d.offsetWidth:d.offsetHeight:S?h?E.innerWidth:E.innerHeight:h?b.offsetWidth:b.offsetHeight;i({scrollHeight:w,scrollTop:Math.max(C,0),viewportHeight:N}),u==null||u(h?kg("column-gap",getComputedStyle(y).columnGap,c):kg("row-gap",getComputedStyle(y).rowGap,c)),v!==null&&t(v)},[t,a,c,u,d,i,h]);return Df(m,s,x)}function Ek(t,a,s,i){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 x=parseInt(h.dataset.index),m=parseFloat(h.dataset.knownSize),y=a(h,s);if(y===0&&i("Zero-sized element, this should not happen",{child:h},qt.ERROR),y===m)continue;const v=u[u.length-1];u.length===0||v.size!==y||v.endIndex!==x-1?u.push({endIndex:x,size:y,startIndex:x}):u[u.length-1].endIndex++}return u}function kg(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,qt.WARN),a==="normal"?0:parseInt(a??"0",10)}function oy(t,a,s){const i=Te.useRef(null),c=Te.useCallback(x=>{if(!(x!=null&&x.offsetParent))return;const m=x.getBoundingClientRect(),y=m.width;let v,b;if(a){const S=a.getBoundingClientRect(),E=m.top-S.top;b=S.height-Math.max(0,E),v=E+a.scrollTop}else{const S=d.current.ownerDocument.defaultView;b=S.innerHeight-Math.max(0,m.top),v=m.top+S.scrollY}i.current={listHeight:m.height,offsetTop:v,visibleHeight:b,visibleWidth:y},t(i.current)},[t,a]),{callbackRef:u,ref:d}=Df(c,!0,s),h=Te.useCallback(()=>{c(d.current)},[c,d]);return Te.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 x=(m=d.current)==null?void 0:m.ownerDocument.defaultView;return x==null||x.addEventListener("scroll",h),x==null||x.addEventListener("resize",h),()=>{x==null||x.removeEventListener("scroll",h),x==null||x.removeEventListener("resize",h)}},[h,a,d]),u}const xn=at(()=>{const t=et(),a=et(),s=ge(0),i=et(),c=ge(0),u=et(),d=et(),h=ge(0),x=ge(0),m=ge(0),y=ge(0),v=et(),b=et(),S=ge(!1),E=ge(!1),C=ge(!1);return Re(he(t,we(({scrollTop:w})=>w)),a),Re(he(t,we(({scrollHeight:w})=>w)),d),Re(a,c),{deviation:s,fixedFooterHeight:m,fixedHeaderHeight:x,footerHeight:y,headerHeight:h,horizontalDirection:E,scrollBy:b,scrollContainerState:t,scrollHeight:d,scrollingInProgress:S,scrollTo:v,scrollTop:a,skipAnimationFrameInResizeObserver:C,smoothScrollTargetReached:i,statefulScrollTop:c,viewportHeight:u}},[],{singleton:!0}),Xs={lvl:0};function cy(t,a){const s=t.length;if(s===0)return[];let{index:i,value:c}=a(t[0]);const u=[];for(let d=1;d<s;d++){const{index:h,value:x}=a(t[d]);u.push({end:h-1,start:i,value:c}),i=h,c=x}return u.push({end:1/0,start:i,value:c}),u}function vt(t){return t===Xs}function Qs(t,a){if(!vt(t))return a===t.k?t.v:a<t.k?Qs(t.l,a):Qs(t.r,a)}function or(t,a,s="k"){if(vt(t))return[-1/0,void 0];if(Number(t[s])===a)return[t.k,t.v];if(Number(t[s])<a){const i=or(t.r,a,s);return i[0]===-1/0?[t.k,t.v]:i}return or(t.l,a,s)}function On(t,a,s){return vt(t)?fy(a,s,1):a===t.k?Wt(t,{k:a,v:s}):a<t.k?wg(Wt(t,{l:On(t.l,a,s)})):wg(Wt(t,{r:On(t.r,a,s)}))}function Ol(){return Xs}function Bl(t,a,s){if(vt(t))return[];const i=or(t,a)[0];return Nk(ff(t,i,s))}function df(t,a){if(vt(t))return Xs;const{k:s,l:i,r:c}=t;if(a===s){if(vt(i))return c;if(vt(c))return i;const[u,d]=dy(i);return Uo(Wt(t,{k:u,l:uy(i),v:d}))}return a<s?Uo(Wt(t,{l:df(i,a)})):Uo(Wt(t,{r:df(c,a)}))}function Fa(t){return vt(t)?[]:[...Fa(t.l),{k:t.k,v:t.v},...Fa(t.r)]}function ff(t,a,s){if(vt(t))return[];const{k:i,l:c,r:u,v:d}=t;let h=[];return i>a&&(h=h.concat(ff(c,a,s))),i>=a&&i<=s&&h.push({k:i,v:d}),i<=s&&(h=h.concat(ff(u,a,s))),h}function Uo(t){const{l:a,lvl:s,r:i}=t;if(i.lvl>=s-1&&a.lvl>=s-1)return t;if(s>i.lvl+1){if(zd(a))return py(Wt(t,{lvl:s-1}));if(!vt(a)&&!vt(a.r))return Wt(a.r,{l:Wt(a,{r:a.r.l}),lvl:s,r:Wt(t,{l:a.r.r,lvl:s-1})});throw new Error("Unexpected empty nodes")}if(zd(t))return pf(Wt(t,{lvl:s-1}));if(!vt(i)&&!vt(i.l)){const c=i.l,u=zd(c)?i.lvl-1:i.lvl;return Wt(c,{l:Wt(t,{lvl:s-1,r:c.l}),lvl:c.lvl+1,r:pf(Wt(i,{l:c.r,lvl:u}))})}throw new Error("Unexpected empty nodes")}function Wt(t,a){return fy(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 uy(t){return vt(t.r)?t.l:Uo(Wt(t,{r:uy(t.r)}))}function zd(t){return vt(t)||t.lvl>t.r.lvl}function dy(t){return vt(t.r)?[t.k,t.v]:dy(t.r)}function fy(t,a,s,i=Xs,c=Xs){return{k:t,l:i,lvl:s,r:c,v:a}}function wg(t){return pf(py(t))}function py(t){const{l:a}=t;return!vt(a)&&a.lvl===t.lvl?Wt(a,{r:Wt(t,{l:a.r})}):t}function pf(t){const{lvl:a,r:s}=t;return!vt(s)&&!vt(s.r)&&s.lvl===a&&s.r.lvl===a?Wt(s,{l:Wt(t,{r:s.l}),lvl:a+1}):t}function Nk(t){return cy(t,({k:a,v:s})=>({index:a,value:s}))}function my(t,a){return!!(t&&t.startIndex===a.startIndex&&t.endIndex===a.endIndex)}function Zs(t,a){return!!(t&&t[0]===a[0]&&t[1]===a[1])}const _f=at(()=>({recalcInProgress:ge(!1)}),[],{singleton:!0});function hy(t,a,s){return t[Go(t,a,s)]}function Go(t,a,s,i=0){let c=t.length-1;for(;i<=c;){const u=Math.floor((i+c)/2),d=t[u],h=s(d,a);if(h===0)return u;if(h===-1){if(c-i<2)return u-1;c=u-1}else{if(c===i)return u;i=u+1}}throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${a}`)}function Tk(t,a,s,i){const c=Go(t,a,i),u=Go(t,s,i,c);return t.slice(c,u+1)}function xa(t,a){return Math.round(t.getBoundingClientRect()[a])}function sc(t){return!vt(t.groupOffsetTree)}function Of({index:t},a){return a===t?0:a<t?-1:1}function Rk(){return{groupIndices:[],groupOffsetTree:Ol(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Ol()}}function Ak(t,a){let s=vt(t)?0:1/0;for(const i of a){const{endIndex:c,size:u,startIndex:d}=i;if(s=Math.min(s,d),vt(t)){t=On(t,0,u);continue}const h=Bl(t,d-1,c+1);if(h.some(Bk(i)))continue;let x=!1,m=!1;for(const{end:y,start:v,value:b}of h)x?(c>=v||u===b)&&(t=df(t,v)):(m=b!==u,x=!0),y>c&&c>=v&&b!==u&&(t=On(t,c+1,b));m&&(t=On(t,d,u))}return[t,s]}function Mk(t){return typeof t.groupIndex<"u"}function Lk({offset:t},a){return a===t?0:a<t?-1:1}function Js(t,a,s){if(a.length===0)return 0;const{index:i,offset:c,size:u}=hy(a,t,Of),d=t-i,h=u*d+(d-1)*s+c;return h>0?h+s:h}function xy(t,a){if(!sc(a))return t;let s=0;for(;a.groupIndices[s]<=t+s;)s++;return t+s}function gy(t,a,s){if(Mk(t))return a.groupIndices[t.groupIndex]+1;const i=t.index==="LAST"?s:t.index;let c=xy(i,a);return c=Math.max(0,c,Math.min(s,c)),c}function zk(t,a,s,i=0){return i>0&&(a=Math.max(a,hy(t,i,Of).offset)),cy(Tk(t,a,s,Lk),Ok)}function Dk(t,[a,s,i,c]){a.length>0&&i("received item sizes",a,qt.DEBUG);const u=t.sizeTree;let d=u,h=0;if(s.length>0&&vt(u)&&a.length===2){const b=a[0].size,S=a[1].size;d=s.reduce((E,C)=>On(On(E,C,b),C+1,S),d)}else[d,h]=Ak(d,a);if(d===u)return t;const{lastIndex:x,lastOffset:m,lastSize:y,offsetTree:v}=mf(t.offsetTree,h,d,c);return{groupIndices:s,groupOffsetTree:s.reduce((b,S)=>On(b,S,Js(S,v,c)),Ol()),lastIndex:x,lastOffset:m,lastSize:y,offsetTree:v,sizeTree:d}}function _k(t){return Fa(t).map(({k:a,v:s},i,c)=>{const u=c[i+1];return{endIndex:u!==void 0?u.k-1:1/0,size:s,startIndex:a}})}function Cg(t,a){let s=0,i=0;for(;s<t;)s+=a[i+1]-a[i]-1,i++;return i-(s===t?0:1)}function mf(t,a,s,i){let c=t,u=0,d=0,h=0,x=0;if(a!==0){x=Go(c,a-1,Of),h=c[x].offset;const m=or(s,a-1);u=m[0],d=m[1],c.length&&c[x].size===or(s,a)[1]&&(x-=1),c=c.slice(0,x+1)}else c=[];for(const{start:m,value:y}of Bl(s,a,1/0)){const v=m-u,b=v*d+h+v*i;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 Bk(t){const{endIndex:a,size:s,startIndex:i}=t;return c=>c.start===i&&(c.end===a||c.end===1/0)&&c.value===s}const Ik={offsetHeight:"height",offsetWidth:"width"},vr=at(([{log:t},{recalcInProgress:a}])=>{const s=et(),i=et(),c=dn(i,0),u=et(),d=et(),h=ge(0),x=ge([]),m=ge(void 0),y=ge(void 0),v=ge(void 0),b=ge(void 0),S=ge((k,O)=>xa(k,Ik[O])),E=ge(void 0),C=ge(0),w=Rk(),N=dn(he(s,Ye(x,t,C),hr(Dk,w),Ct()),w),T=dn(he(x,Ct(),hr((k,O)=>({current:O,prev:k.current}),{current:[],prev:[]}),we(({prev:k})=>k)),[]);Re(he(x,Oe(k=>k.length>0),Ye(N,C),we(([k,O,L])=>{const B=k.reduce((U,Y,X)=>On(U,Y,Js(Y,O.offsetTree,L)||X),Ol());return{...O,groupIndices:k,groupOffsetTree:B}})),N),Re(he(i,Ye(N),Oe(([k,{lastIndex:O}])=>k<O),we(([k,{lastIndex:O,lastSize:L}])=>[{endIndex:O,size:L,startIndex:k}])),s),Re(m,y);const R=dn(he(m,we(k=>k===void 0)),!0);Re(he(y,Oe(k=>k!==void 0&&vt(Mt(N).sizeTree)),we(k=>{const O=Mt(v),L=Mt(x).length>0;return O!==void 0&&O!==0?L?[{endIndex:0,size:O,startIndex:0},{endIndex:1,size:k,startIndex:1}]:[]:[{endIndex:0,size:k,startIndex:0}]})),s),Re(he(b,Oe(k=>k!==void 0&&k.length>0&&vt(Mt(N).sizeTree)),we(k=>{const O=[];let L=k[0],B=0;for(let U=1;U<k.length;U++){const Y=k[U];Y!==L&&(O.push({endIndex:U-1,size:L,startIndex:B}),L=Y,B=U)}return O.push({endIndex:k.length-1,size:L,startIndex:B}),O})),s),Re(he(x,Ye(v,y),Oe(([,k,O])=>k!==void 0&&O!==void 0),we(([k,O,L])=>{const B=[];for(let U=0;U<k.length;U++){const Y=k[U],X=k[U+1];B.push({startIndex:Y,endIndex:Y,size:O}),X!==void 0&&B.push({startIndex:Y+1,endIndex:X-1,size:L})}return B})),s);const _=In(he(s,Ye(N),hr(({sizes:k},[O,L])=>({changed:L!==k,sizes:L}),{changed:!1,sizes:w}),we(k=>k.changed)));ot(he(h,hr((k,O)=>({diff:k.prev-O,prev:O}),{diff:0,prev:0}),we(k=>k.diff)),k=>{const{groupIndices:O}=Mt(N);if(k>0)qe(a,!0),qe(u,k+Cg(k,O));else if(k<0){const L=Mt(T);L.length>0&&(k-=Cg(-k,L)),qe(d,k)}}),ot(he(h,Ye(t)),([k,O])=>{k<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},qt.ERROR)});const z=In(u);Re(he(u,Ye(N),we(([k,O])=>{const L=O.groupIndices.length>0,B=[],U=O.lastSize;if(L){const Y=Qs(O.sizeTree,0);let X=0,J=0;for(;X<k;){const M=O.groupIndices[J],I=O.groupIndices.length===J+1?1/0:O.groupIndices[J+1]-M-1;B.push({endIndex:M,size:Y,startIndex:M}),B.push({endIndex:M+1+I-1,size:U,startIndex:M+1}),J++,X+=I+1}const $=Fa(O.sizeTree);return X!==k&&$.shift(),$.reduce((M,{k:I,v:F})=>{let H=M.ranges;return M.prevSize!==0&&(H=[...M.ranges,{endIndex:I+k-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:I+k,prevSize:F,ranges:H}},{prevIndex:k,prevSize:0,ranges:B}).ranges}return Fa(O.sizeTree).reduce((Y,{k:X,v:J})=>({prevIndex:X+k,prevSize:J,ranges:[...Y.ranges,{endIndex:X+k-1,size:Y.prevSize,startIndex:Y.prevIndex}]}),{prevIndex:0,prevSize:U,ranges:[]}).ranges})),s);const P=In(he(d,Ye(N,C),we(([k,{offsetTree:O},L])=>{const B=-k;return Js(B,O,L)})));return Re(he(d,Ye(N,C),we(([k,O,L])=>{if(O.groupIndices.length>0){if(vt(O.sizeTree))return O;let U=Ol();const Y=Mt(T);let X=0,J=0,$=0;for(;X<-k;){$=Y[J];const M=Y[J+1]-$-1;J++,X+=M+1}if(U=Fa(O.sizeTree).reduce((M,{k:I,v:F})=>On(M,Math.max(0,I+k),F),U),X!==-k){const M=Qs(O.sizeTree,$);U=On(U,0,M);const I=or(O.sizeTree,-k+1)[1];U=On(U,1,I)}return{...O,sizeTree:U,...mf(O.offsetTree,0,U,L)}}const B=Fa(O.sizeTree).reduce((U,{k:Y,v:X})=>On(U,Math.max(0,Y+k),X),Ol());return{...O,sizeTree:B,...mf(O.offsetTree,0,B,L)}})),N),{beforeUnshiftWith:z,data:E,defaultItemSize:y,firstItemIndex:h,fixedItemSize:m,fixedGroupSize:v,gap:C,groupIndices:x,heightEstimates:b,itemSize:S,listRefresh:_,shiftWith:d,shiftWithOffset:P,sizeRanges:s,sizes:N,statefulTotalCount:c,totalCount:i,trackItemSizes:R,unshiftWith:u}},Et(ya,_f),{singleton:!0});function $k(t){return t.reduce((a,s)=>(a.groupIndices.push(a.totalCount),a.totalCount+=s+1,a),{groupIndices:[],totalCount:0})}const vy=at(([{groupIndices:t,sizes:a,totalCount:s},{headerHeight:i,scrollTop:c}])=>{const u=et(),d=et(),h=In(he(u,we($k)));return Re(he(h,we(x=>x.totalCount)),s),Re(he(h,we(x=>x.groupIndices)),t),Re(he(Vt(c,a,i),Oe(([x,m])=>sc(m)),we(([x,m,y])=>or(m.groupOffsetTree,Math.max(x-y,0),"v")[0]),Ct(),we(x=>[x])),d),{groupCounts:u,topItemsIndexes:d}},Et(vr,xn)),ba=at(([{log:t}])=>{const a=ge(!1),s=In(he(a,Oe(i=>i),Ct()));return ot(a,i=>{i&&Mt(t)("props updated",{},qt.DEBUG)}),{didMount:s,propsReady:a}},Et(ya),{singleton:!0}),Uk=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function yy(t){const a=typeof t=="number"?{index:t}:t;return a.align||(a.align="start"),(!a.behavior||!Uk)&&(a.behavior="auto"),a.offset===void 0&&(a.offset=0),a}const li=at(([{gap:t,listRefresh:a,sizes:s,totalCount:i},{fixedFooterHeight:c,fixedHeaderHeight:u,footerHeight:d,headerHeight:h,scrollingInProgress:x,scrollTo:m,smoothScrollTargetReached:y,viewportHeight:v},{log:b}])=>{const S=et(),E=et(),C=ge(0);let w=null,N=null,T=null;function R(){w!==null&&(w(),w=null),T!==null&&(T(),T=null),N&&(clearTimeout(N),N=null),qe(x,!1)}return Re(he(S,Ye(s,v,i,C,h,d,b),Ye(t,u,c),we(([[_,z,P,k,O,L,B,U],Y,X,J])=>{const $=yy(_),{align:M,behavior:I,offset:F}=$,H=k-1,re=gy($,z,H);let D=Js(re,z.offsetTree,Y)+L;M==="end"?(D+=X+or(z.sizeTree,re)[1]-P+J,re===H&&(D+=B)):M==="center"?D+=(X+or(z.sizeTree,re)[1]-P+J)/2:D-=O,F!==void 0&&F!==0&&(D+=F);const W=te=>{R(),te?(U("retrying to scroll to",{location:_},qt.DEBUG),qe(S,_)):(qe(E,!0),U("list did not change, scroll successful",{},qt.DEBUG))};if(R(),I==="smooth"){let te=!1;T=ot(a,q=>{te=te||q}),w=sr(y,()=>{W(te)})}else w=sr(he(a,Hk(150)),W);return N=setTimeout(()=>{R()},1200),qe(x,!0),U("scrolling from index to",{behavior:I,index:re,top:D},qt.DEBUG),{behavior:I,top:D}})),m),{scrollTargetReached:E,scrollToIndex:S,topListHeight:C}},Et(vr,xn,ya),{singleton:!0});function Hk(t){return a=>{const s=setTimeout(()=>{a(!1)},t);return i=>{i&&(a(!0),clearTimeout(s))}}}function Bf(t,a){t===0?a():requestAnimationFrame(()=>{Bf(t-1,a)})}function If(t,a){const s=a-1;return typeof t=="number"?t:t.index==="LAST"?s:t.index}const si=at(([{defaultItemSize:t,listRefresh:a,sizes:s},{scrollTop:i},{scrollTargetReached:c,scrollToIndex:u},{didMount:d}])=>{const h=ge(!0),x=ge(0),m=ge(!0);return Re(he(d,Ye(x),Oe(([y,v])=>v!==0),mr(!1)),h),Re(he(d,Ye(x),Oe(([y,v])=>v!==0),mr(!1)),m),ot(he(Vt(a,d),Ye(h,s,t,m),Oe(([[,y],v,{sizeTree:b},S,E])=>y&&(!vt(b)||Lf(S))&&!v&&!E),Ye(x)),([,y])=>{sr(c,()=>{qe(m,!0)}),Bf(4,()=>{sr(i,()=>{qe(h,!0)}),qe(u,y)})}),{initialItemFinalLocationReached:m,initialTopMostItemIndex:x,scrolledToInitialItem:h}},Et(vr,xn,li,ba),{singleton:!0});function by(t,a){return Math.abs(t-a)<1.01}const ei="up",Ws="down",Pk="none",Vk={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Fk=0,ii=at(([{footerHeight:t,headerHeight:a,scrollBy:s,scrollContainerState:i,scrollTop:c,viewportHeight:u}])=>{const d=ge(!1),h=ge(!0),x=et(),m=et(),y=ge(4),v=ge(Fk),b=dn(he(uf(he(_e(c),Wa(1),mr(!0)),he(_e(c),Wa(1),mr(!1),Sg(100))),Ct()),!1),S=dn(he(uf(he(s,mr(!0)),he(s,mr(!1),Sg(200))),Ct()),!1);Re(he(Vt(_e(c),_e(v)),we(([T,R])=>T<=R),Ct()),h),Re(he(h,$r(50)),m);const E=In(he(Vt(i,_e(u),_e(a),_e(t),_e(y)),hr((T,[{scrollHeight:R,scrollTop:_},z,P,k,O])=>{const L=_+z-R>-O,B={scrollHeight:R,scrollTop:_,viewportHeight:z};if(L){let Y,X;return _>T.state.scrollTop?(Y="SCROLLED_DOWN",X=T.state.scrollTop-_):(Y="SIZE_DECREASED",X=T.state.scrollTop-_||T.scrollTopDelta),{atBottom:!0,atBottomBecause:Y,scrollTopDelta:X,state:B}}let U;return B.scrollHeight>T.state.scrollHeight?U="SIZE_INCREASED":z<T.state.viewportHeight?U="VIEWPORT_HEIGHT_DECREASING":_<T.state.scrollTop?U="SCROLLING_UPWARDS":U="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:U,state:B}},Vk),Ct((T,R)=>T!==void 0&&T.atBottom===R.atBottom))),C=dn(he(i,hr((T,{scrollHeight:R,scrollTop:_,viewportHeight:z})=>{if(!by(T.scrollHeight,R)){const P=R-(_+z)<1;return T.scrollTop!==_&&P?{changed:!0,jump:T.scrollTop-_,scrollHeight:R,scrollTop:_}:{changed:!0,jump:0,scrollHeight:R,scrollTop:_}}return{changed:!1,jump:0,scrollHeight:R,scrollTop:_}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),Oe(T=>T.changed),we(T=>T.jump)),0);Re(he(E,we(T=>T.atBottom)),d),Re(he(d,$r(50)),x);const w=ge(Ws);Re(he(i,we(({scrollTop:T})=>T),Ct(),hr((T,R)=>Mt(S)?{direction:T.direction,prevScrollTop:R}:{direction:R<T.prevScrollTop?ei:Ws,prevScrollTop:R},{direction:Ws,prevScrollTop:0}),we(T=>T.direction)),w),Re(he(i,$r(50),mr(Pk)),w);const N=ge(0);return Re(he(b,Oe(T=>!T),mr(0)),N),Re(he(c,$r(100),Ye(b),Oe(([T,R])=>R),hr(([T,R],[_])=>[R,_],[0,0]),we(([T,R])=>R-T)),N),{atBottomState:E,atBottomStateChange:x,atBottomThreshold:y,atTopStateChange:m,atTopThreshold:v,isAtBottom:d,isAtTop:h,isScrolling:b,lastJumpDueToItemResize:C,scrollDirection:w,scrollVelocity:N}},Et(xn)),ti="top",ni="bottom",Eg="none";function Ng(t,a,s){return typeof t=="number"?s===ei&&a===ti||s===Ws&&a===ni?t:0:s===ei?a===ti?t.main:t.reverse:a===ni?t.main:t.reverse}function Tg(t,a){return typeof t=="number"?t:t[a]??0}const $f=at(([{deviation:t,fixedHeaderHeight:a,headerHeight:s,scrollTop:i,viewportHeight:c}])=>{const u=et(),d=ge(0),h=ge(0),x=ge(0),m=dn(he(Vt(_e(i),_e(c),_e(s),_e(u,Zs),_e(x),_e(d),_e(a),_e(t),_e(h)),we(([y,v,b,[S,E],C,w,N,T,R])=>{const _=y-T,z=w+N,P=Math.max(b-_,0);let k=Eg;const O=Tg(R,ti),L=Tg(R,ni);return S-=T,S+=b+N,E+=b+N,E-=T,S>y+z-O&&(k=ei),E<y-P+v+L&&(k=Ws),k!==Eg?[Math.max(_-b-Ng(C,ti,k)-O,0),_-P-N+v+Ng(C,ni,k)+L]:null}),Oe(y=>y!==null),Ct(Zs)),[0,0]);return{increaseViewportBy:h,listBoundary:u,overscan:x,topListHeight:d,visibleRange:m}},Et(xn),{singleton:!0});function Gk(t,a,s){if(sc(a)){const i=xy(t,a);return[{index:or(a.groupOffsetTree,i)[0],offset:0,size:0},{data:s==null?void 0:s[0],index:i,offset:0,size:0}]}return[{data:s==null?void 0:s[0],index:t,offset:0,size:0}]}const Dd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ho(t,a,s,i,c,u){const{lastIndex:d,lastOffset:h,lastSize:x}=c;let m=0,y=0;if(t.length>0){m=t[0].offset;const C=t[t.length-1];y=C.offset+C.size}const v=s-d,b=h+v*x+(v-1)*i,S=m,E=b-y;return{bottom:y,firstItemIndex:u,items:Rg(t,c,u),offsetBottom:E,offsetTop:m,top:S,topItems:Rg(a,c,u),topListHeight:a.reduce((C,w)=>w.size+C,0),totalCount:s}}function jy(t,a,s,i,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,x=If(a,h),m=Array.from({length:h}).map((y,v)=>({data:u[v+x],index:v+x,offset:0,size:0}));return Ho(m,[],h,c,s,i)}function Rg(t,a,s){if(t.length===0)return[];if(!sc(a))return t.map(m=>({...m,index:m.index+s,originalIndex:m.index}));const i=t[0].index,c=t[t.length-1].index,u=[],d=Bl(a.groupOffsetTree,i,c);let h,x=0;for(const m of t){(!h||h.end<m.index)&&(h=d.shift(),x=a.groupIndices.indexOf(h.start));let y;m.index===h.start?y={index:x,type:"group"}:y={groupIndex:x,index:m.index-(x+1)+s},u.push({...y,data:m.data,offset:m.offset,originalIndex:m.index,size:m.size})}return u}function Ag(t,a){return t===void 0?0:typeof t=="number"?t:t[a]??0}const Xa=at(([{data:t,firstItemIndex:a,gap:s,sizes:i,totalCount:c},u,{listBoundary:d,topListHeight:h,visibleRange:x},{initialTopMostItemIndex:m,scrolledToInitialItem:y},{topListHeight:v},b,{didMount:S},{recalcInProgress:E}])=>{const C=ge([]),w=ge(0),N=et(),T=ge(0);Re(u.topItemsIndexes,C);const R=dn(he(Vt(S,E,_e(x,Zs),_e(c),_e(i),_e(m),y,_e(C),_e(a),_e(s),_e(T),t),Oe(([k,O,,L,,,,,,,,B])=>{const U=B!==void 0&&B.length!==L;return k&&!O&&!U}),we(([,,[k,O],L,B,U,Y,X,J,$,M,I])=>{var be,Ne;const F=B,{offsetTree:H,sizeTree:re}=F,D=Mt(w);if(L===0)return{...Dd,totalCount:L};if(k===0&&O===0)return D===0?{...Dd,totalCount:L}:jy(D,U,B,J,$,I||[]);if(vt(re))return D>0?null:Ho(Gk(If(U,L),F,I),[],L,$,F,J);const W=[];if(X.length>0){const Be=X[0],Le=X[X.length-1];let Pe=0;for(const se of Bl(re,Be,Le)){const de=se.value,me=Math.max(se.start,Be),ve=Math.min(se.end,Le);for(let je=me;je<=ve;je++)W.push({data:I==null?void 0:I[je],index:je,offset:Pe,size:de}),Pe+=de}}if(!Y)return Ho([],W,L,$,F,J);const te=X.length>0?X[X.length-1]+1:0,q=zk(H,k,O,te);if(q.length===0)return null;const ce=L-1,Q=lc([],Be=>{for(const Le of q){const Pe=Le.value;let se=Pe.offset,de=Le.start;const me=Pe.size;if(Pe.offset<k){de+=Math.floor((k-Pe.offset+$)/(me+$));const je=de-Le.start;se+=je*me+je*$}de<te&&(se+=(te-de)*me,de=te);const ve=Math.min(Le.end,ce);for(let je=de;je<=ve&&!(se>=O);je++)Be.push({data:I==null?void 0:I[je],index:je,offset:se,size:me}),se+=me+$}}),ye=Ag(M,ti),oe=Ag(M,ni);if(Q.length>0&&(ye>0||oe>0)){const Be=Q[0],Le=Q[Q.length-1];if(ye>0&&Be.index>te){const Pe=Math.min(ye,Be.index-te),se=[];let de=Be.offset;for(let me=Be.index-1;me>=Be.index-Pe;me--){const ve=((be=Bl(re,me,me)[0])==null?void 0:be.value)??Be.size;de-=ve+$,se.unshift({data:I==null?void 0:I[me],index:me,offset:de,size:ve})}Q.unshift(...se)}if(oe>0&&Le.index<ce){const Pe=Math.min(oe,ce-Le.index);let se=Le.offset+Le.size+$;for(let de=Le.index+1;de<=Le.index+Pe;de++){const me=((Ne=Bl(re,de,de)[0])==null?void 0:Ne.value)??Le.size;Q.push({data:I==null?void 0:I[de],index:de,offset:se,size:me}),se+=me+$}}}return Ho(Q,W,L,$,F,J)}),Oe(k=>k!==null),Ct()),Dd);Re(he(t,Oe(Lf),we(k=>k==null?void 0:k.length)),c),Re(he(R,we(k=>k.topListHeight)),v),Re(v,h),Re(he(R,we(k=>[k.top,k.bottom])),d),Re(he(R,we(k=>k.items)),N);const _=In(he(R,Oe(({items:k})=>k.length>0),Ye(c,t),Oe(([{items:k},O])=>k[k.length-1].originalIndex===O-1),we(([,k,O])=>[k-1,O]),Ct(Zs),we(([k])=>k))),z=In(he(R,$r(200),Oe(({items:k,topItems:O})=>k.length>0&&k[0].originalIndex===O.length),we(({items:k})=>k[0].index),Ct())),P=In(he(R,Oe(({items:k})=>k.length>0),we(({items:k})=>{let O=0,L=k.length-1;for(;k[O].type==="group"&&O<L;)O++;for(;k[L].type==="group"&&L>O;)L--;return{endIndex:k[L].index,startIndex:k[O].index}}),Ct(my)));return{endReached:_,initialItemCount:w,itemsRendered:N,listState:R,minOverscanItemCount:T,rangeChanged:P,startReached:z,topItemsIndexes:C,...b}},Et(vr,vy,$f,si,li,ii,ba,_f),{singleton:!0}),Sy=at(([{fixedFooterHeight:t,fixedHeaderHeight:a,footerHeight:s,headerHeight:i},{listState:c}])=>{const u=et(),d=dn(he(Vt(s,t,i,a,c),we(([h,x,m,y,v])=>h+x+m+y+v.offsetBottom+v.bottom)),0);return Re(_e(d),u),{totalListHeight:d,totalListHeightChanged:u}},Et(xn,Xa),{singleton:!0}),Wk=at(([{viewportHeight:t},{totalListHeight:a}])=>{const s=ge(!1),i=dn(he(Vt(s,t,a),Oe(([c])=>c),we(([,c,u])=>Math.max(0,c-u)),$r(0),Ct()),0);return{alignToBottom:s,paddingTopAddition:i}},Et(xn,Sy),{singleton:!0}),ky=at(()=>({context:ge(null)})),qk=({itemBottom:t,itemTop:a,locationParams:{align:s,behavior:i,...c},viewportBottom:u,viewportTop:d})=>a<d?{...c,align:s??"start",...i!==void 0?{behavior:i}:{}}:t>u?{...c,align:s??"end",...i!==void 0?{behavior:i}:{}}:null,wy=at(([{gap:t,sizes:a,totalCount:s},{fixedFooterHeight:i,fixedHeaderHeight:c,headerHeight:u,scrollingInProgress:d,scrollTop:h,viewportHeight:x},{scrollToIndex:m}])=>{const y=et();return Re(he(y,Ye(a,x,s,u,c,i,h),Ye(t),we(([[v,b,S,E,C,w,N,T],R])=>{const{calculateViewLocation:_=qk,done:z,...P}=v,k=gy(v,b,E-1),O=Js(k,b.offsetTree,R)+C+w,L=O+or(b.sizeTree,k)[1],B=T+w,U=T+S-N,Y=_({itemBottom:L,itemTop:O,locationParams:P,viewportBottom:U,viewportTop:B});return Y!==null?z&&sr(he(d,Oe(X=>!X),Wa(Mt(d)?1:2)),z):z==null||z(),Y}),Oe(v=>v!==null)),m),{scrollIntoView:y}},Et(vr,xn,li,Xa,ya),{singleton:!0});function Mg(t){return t===!1?!1:t==="smooth"?"smooth":"auto"}const Yk=(t,a)=>typeof t=="function"?Mg(t(a)):a&&Mg(t),Kk=at(([{listRefresh:t,totalCount:a,fixedItemSize:s,data:i},{atBottomState:c,isAtBottom:u},{scrollToIndex:d},{scrolledToInitialItem:h},{didMount:x,propsReady:m},{log:y},{scrollingInProgress:v},{context:b},{scrollIntoView:S}])=>{const E=ge(!1),C=et();let w=null;function N(z){qe(d,{align:"end",behavior:z,index:"LAST"})}ot(he(Vt(he(_e(a),Wa(1)),x),Ye(_e(E),u,h,v),we(([[z,P],k,O,L,B])=>{let U=P&&L,Y="auto";return U&&(Y=Yk(k,O||B),U=U&&Y!==!1),{followOutputBehavior:Y,shouldFollow:U,totalCount:z}}),Oe(({shouldFollow:z})=>z)),({followOutputBehavior:z,totalCount:P})=>{w!==null&&(w(),w=null),Mt(s)!==void 0?requestAnimationFrame(()=>{Mt(y)("following output to ",{totalCount:P},qt.DEBUG),N(z)}):w=sr(t,()=>{Mt(y)("following output to ",{totalCount:P},qt.DEBUG),N(z),w=null})});function T(z){const P=sr(c,k=>{z&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&w===null&&(Mt(y)("scrolling to bottom due to increased size",{},qt.DEBUG),N("auto"))});setTimeout(P,100)}ot(he(Vt(_e(E),a,m),Oe(([z,,P])=>z!==!1&&P),hr(({value:z},[,P])=>({refreshed:z===P,value:P}),{refreshed:!1,value:0}),Oe(({refreshed:z})=>z),Ye(E,a)),([,z])=>{Mt(h)&&T(z!==!1)}),ot(C,()=>{T(Mt(E)!==!1)}),ot(Vt(_e(E),c),([z,P])=>{z!==!1&&!P.atBottom&&P.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&N("auto")});const R=ge(null),_=et();return Re(uf(he(_e(i),we(z=>(z==null?void 0:z.length)??0)),he(_e(a))),_),ot(he(Vt(he(_,Wa(1)),x),Ye(_e(R),h,v,b),we(([[z,P],k,O,L,B])=>P&&O&&(k==null?void 0:k({context:B,totalCount:z,scrollingInProgress:L}))),Oe(z=>!!z),$r(0)),z=>{w!==null&&(w(),w=null),Mt(s)!==void 0?requestAnimationFrame(()=>{Mt(y)("scrolling into view",{}),qe(S,z)}):w=sr(t,()=>{Mt(y)("scrolling into view",{}),qe(S,z),w=null})}),{autoscrollToBottom:C,followOutput:E,scrollIntoViewOnChange:R}},Et(vr,ii,li,si,ba,ya,xn,ky,wy)),Xk=at(([{data:t,firstItemIndex:a,gap:s,sizes:i},{initialTopMostItemIndex:c},{initialItemCount:u,listState:d},{didMount:h}])=>(Re(he(h,Ye(u),Oe(([,x])=>x!==0),Ye(c,i,a,s,t),we(([[,x],m,y,v,b,S=[]])=>jy(x,m,y,v,b,S))),d),{}),Et(vr,si,Xa,ba),{singleton:!0}),Qk=at(([{didMount:t},{scrollTo:a},{listState:s}])=>{const i=ge(0);return ot(he(t,Ye(i),Oe(([,c])=>c!==0),we(([,c])=>({top:c}))),c=>{sr(he(s,Wa(1),Oe(u=>u.items.length>1)),()=>{requestAnimationFrame(()=>{qe(a,c)})})}),{initialScrollTop:i}},Et(ba,xn,Xa),{singleton:!0}),Cy=at(([{scrollVelocity:t}])=>{const a=ge(!1),s=et(),i=ge(!1);return Re(he(t,Ye(i,a,s),Oe(([c,u])=>u!==!1&&u!==void 0),we(([c,u,d,h])=>{const{enter:x,exit:m}=u;if(d){if(m(c,h))return!1}else if(x(c,h))return!0;return d}),Ct()),a),ot(he(Vt(a,t,s),Ye(i)),([[c,u,d],h])=>{c&&h!==!1&&h!==void 0&&h.change&&h.change(u,d)}),{isSeeking:a,scrollSeekConfiguration:i,scrollSeekRangeChanged:s,scrollVelocity:t}},Et(ii),{singleton:!0}),Uf=at(([{scrollContainerState:t,scrollTo:a}])=>{const s=et(),i=et(),c=et(),u=ge(!1),d=ge(void 0);return Re(he(Vt(s,i),we(([{scrollTop:h,viewportHeight:x},{offsetTop:m,listHeight:y}])=>({scrollHeight:y,scrollTop:Math.max(0,h-m),viewportHeight:x}))),t),Re(he(a,Ye(i),we(([h,{offsetTop:x}])=>({...h,top:h.top+x}))),c),{customScrollParent:d,useWindowScroll:u,windowScrollContainerState:s,windowScrollTo:c,windowViewportRect:i}},Et(xn)),Zk=at(([{sizeRanges:t,sizes:a},{headerHeight:s,scrollTop:i},{initialTopMostItemIndex:c},{didMount:u},{useWindowScroll:d,windowScrollContainerState:h,windowViewportRect:x}])=>{const m=et(),y=ge(void 0),v=ge(null),b=ge(null);return Re(h,v),Re(x,b),ot(he(m,Ye(a,i,d,v,b,s)),([S,E,C,w,N,T,R])=>{const _=_k(E.sizeTree);w&&N!==null&&T!==null&&(C=N.scrollTop-T.offsetTop),C-=R,S({ranges:_,scrollTop:C})}),Re(he(y,Oe(Lf),we(Jk)),c),Re(he(u,Ye(y),Oe(([,S])=>S!==void 0),Ct(),we(([,S])=>S.ranges)),t),{getState:m,restoreStateFrom:y}},Et(vr,xn,si,ba,Uf));function Jk(t){return{align:"start",index:0,offset:t.scrollTop}}const ew=at(([{topItemsIndexes:t}])=>{const a=ge(0);return Re(he(a,Oe(s=>s>=0),we(s=>Array.from({length:s}).map((i,c)=>c))),t),{topItemCount:a}},Et(Xa));function Ey(t){let a=!1,s;return(()=>(a||(a=!0,s=t()),s))}const tw=Ey(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),nw=at(([{deviation:t,scrollBy:a,scrollingInProgress:s,scrollTop:i},{isAtBottom:c,isScrolling:u,lastJumpDueToItemResize:d,scrollDirection:h},{listState:x},{beforeUnshiftWith:m,gap:y,shiftWithOffset:v,sizes:b},{log:S},{recalcInProgress:E}])=>{const C=In(he(x,Ye(d),hr(([,N,T,R],[{bottom:_,items:z,offsetBottom:P,totalCount:k},O])=>{const L=_+P;let B=0;return T===k&&N.length>0&&z.length>0&&(z[0].originalIndex===0&&N[0].originalIndex===0||(B=L-R,B!==0&&(B+=O))),[B,z,k,L]},[0,[],0,0]),Oe(([N])=>N!==0),Ye(i,h,s,c,S,E),Oe(([,N,T,R,,,_])=>!_&&!R&&N!==0&&T===ei),we(([[N],,,,,T])=>(T("Upward scrolling compensation",{amount:N},qt.DEBUG),N))));function w(N){N>0?(qe(a,{behavior:"auto",top:-N}),qe(t,0)):(qe(t,0),qe(a,{behavior:"auto",top:-N}))}return ot(he(C,Ye(t,u)),([N,T,R])=>{R&&tw()?qe(t,T-N):w(-N)}),ot(he(Vt(dn(u,!1),t,E),Oe(([N,T,R])=>!N&&!R&&T!==0),we(([N,T])=>T),$r(1)),w),Re(he(v,we(N=>({top:-N}))),a),ot(he(m,Ye(b,y),we(([N,{groupIndices:T,lastSize:R,sizeTree:_},z])=>{function P(U){return U*(R+z)}if(T.length===0)return P(N);let k=0;const O=Qs(_,0);let L=0,B=0;for(;L<N;){L++,k+=O;let U=T.length===B+1?1/0:T[B+1]-T[B]-1;L+U>N&&(k-=O,U=N-L+1),L+=U,k+=P(U),B++}return k})),N=>{qe(t,N),requestAnimationFrame(()=>{qe(a,{top:N}),requestAnimationFrame(()=>{qe(t,0),qe(E,!1)})})}),{deviation:t}},Et(xn,ii,Xa,vr,ya,_f)),rw=at(([t,a,s,i,c,u,d,h,x,m,y])=>({...t,...a,...s,...i,...c,...u,...d,...h,...x,...m,...y}),Et($f,Xk,ba,Cy,Sy,Qk,Wk,Uf,wy,ya,ky)),Ny=at(([{data:t,defaultItemSize:a,firstItemIndex:s,fixedItemSize:i,fixedGroupSize:c,gap:u,groupIndices:d,heightEstimates:h,itemSize:x,sizeRanges:m,sizes:y,statefulTotalCount:v,totalCount:b,trackItemSizes:S},{initialItemFinalLocationReached:E,initialTopMostItemIndex:C,scrolledToInitialItem:w},N,T,R,_,{scrollToIndex:z},P,{topItemCount:k},{groupCounts:O},L])=>{const{listState:B,minOverscanItemCount:U,topItemsIndexes:Y,rangeChanged:X,...J}=_;return Re(X,L.scrollSeekRangeChanged),Re(he(L.windowViewportRect,we($=>$.visibleHeight)),N.viewportHeight),{data:t,defaultItemHeight:a,firstItemIndex:s,fixedItemHeight:i,fixedGroupHeight:c,gap:u,groupCounts:O,heightEstimates:h,initialItemFinalLocationReached:E,initialTopMostItemIndex:C,scrolledToInitialItem:w,sizeRanges:m,topItemCount:k,topItemsIndexes:Y,totalCount:b,...R,groupIndices:d,itemSize:x,listState:B,minOverscanItemCount:U,scrollToIndex:z,statefulTotalCount:v,trackItemSizes:S,rangeChanged:X,...J,...L,...N,sizes:y,...T}},Et(vr,si,xn,Zk,Kk,Xa,li,nw,ew,vy,rw));function aw(t,a){const s={},i={};let c=0;const u=t.length;for(;c<u;)i[t[c]]=1,c+=1;for(const d in a)Object.hasOwn(i,d)||(s[d]=a[d]);return s}const Eo=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Ty(t,a,s){const i=Object.keys(a.required||{}),c=Object.keys(a.optional||{}),u=Object.keys(a.methods||{}),d=Object.keys(a.events||{}),h=Te.createContext({});function x(w,N){w.propsReady!==void 0&&qe(w.propsReady,!1);for(const T of i){const R=w[a.required[T]];qe(R,N[T])}for(const T of c)if(T in N){const R=w[a.optional[T]];qe(R,N[T])}w.propsReady!==void 0&&qe(w.propsReady,!0)}function m(w){return u.reduce((N,T)=>(N[T]=R=>{const _=w[a.methods[T]];qe(_,R)},N),{})}function y(w){return d.reduce((N,T)=>(N[T]=bk(w[a.events[T]]),N),{})}const v=Te.forwardRef(function(w,N){const{children:T,...R}=w,[_]=Te.useState(()=>lc(Sk(t),k=>{x(k,R)})),[z]=Te.useState(jg(y,_));Eo(()=>{for(const k of d)k in R&&ot(z[k],R[k]);return()=>{Object.values(z).map(zf)}},[R,z,_]),Eo(()=>{x(_,R)}),Te.useImperativeHandle(N,bg(m(_)));const P=s;return r.jsx(h.Provider,{value:_,children:s!==void 0?r.jsx(P,{...aw([...i,...c,...d],R),children:T}):T})}),b=w=>{const N=Te.useContext(h);return Te.useCallback(T=>{qe(N[w],T)},[N,w])},S=w=>{const N=Te.useContext(h)[w],T=Te.useCallback(R=>ot(N,R),[N]);return Te.useSyncExternalStore(T,()=>Mt(N),()=>Mt(N))},E=w=>{const N=Te.useContext(h)[w],[T,R]=Te.useState(jg(Mt,N));return Eo(()=>ot(N,_=>{_!==T&&R(bg(_))}),[N,T]),T},C=parseInt(Te.version)>=18?S:E;return{Component:v,useEmitter:(w,N)=>{const T=Te.useContext(h)[w];Eo(()=>ot(T,N),[N,T])},useEmitterValue:C,usePublisher:b}}const Ry=Te.createContext(void 0),Ay=Te.createContext(void 0),_d="-webkit-sticky",Lg="sticky",Hf=Ey(()=>{if(typeof document>"u")return Lg;const t=document.createElement("div");return t.style.position=_d,t.style.position===_d?_d:Lg}),My=typeof document<"u"?Te.useLayoutEffect:Te.useEffect;function Od(t){return"self"in t}function lw(t){return"body"in t}function Ly(t,a,s,i=Fl,c,u){const d=Te.useRef(null),h=Te.useRef(null),x=Te.useRef(null),m=Te.useCallback(b=>{let S,E,C;const w=b.target;if(lw(w)||Od(w)){const T=Od(w)?w:w.defaultView;C=u===!0?T.scrollX:T.scrollY,S=u===!0?T.document.documentElement.scrollWidth:T.document.documentElement.scrollHeight,E=u===!0?T.innerWidth:T.innerHeight}else C=u===!0?w.scrollLeft:w.scrollTop,S=u===!0?w.scrollWidth:w.scrollHeight,E=u===!0?w.offsetWidth:w.offsetHeight;const N=()=>{t({scrollHeight:S,scrollTop:Math.max(C,0),viewportHeight:E})};b.suppressFlushSync===!0?N():jS.flushSync(N),h.current!==null&&(C===h.current||C<=0||C===S-E)&&(h.current=null,a(!0),x.current&&(clearTimeout(x.current),x.current=null))},[t,a,u]);Te.useEffect(()=>{const b=c||d.current;return i(c||d.current),m({suppressFlushSync:!0,target:b}),b.addEventListener("scroll",m,{passive:!0}),()=>{i(null),b.removeEventListener("scroll",m)}},[d,m,s,i,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 E=b.behavior==="smooth";let C,w,N;Od(S)?(w=Math.max(xa(S.document.documentElement,u===!0?"width":"height"),u===!0?S.document.documentElement.scrollWidth:S.document.documentElement.scrollHeight),C=u===!0?S.innerWidth:S.innerHeight,N=u===!0?window.scrollX:window.scrollY):(w=S[u===!0?"scrollWidth":"scrollHeight"],C=xa(S,u===!0?"width":"height"),N=S[u===!0?"scrollLeft":"scrollTop"]);const T=w-C;if(b.top=Math.ceil(Math.max(Math.min(T,b.top),0)),by(C,w)||b.top===N){t({scrollHeight:w,scrollTop:N,viewportHeight:C}),E&&a(!0);return}E?(h.current=b.top,x.current&&clearTimeout(x.current),x.current=setTimeout(()=>{x.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 Pf(t){return t}const sw=at(()=>{const t=ge(h=>`Item ${h}`),a=ge(h=>`Group ${h}`),s=ge({}),i=ge(Pf),c=ge("div"),u=ge(Fl),d=(h,x=null)=>dn(he(s,we(m=>m[h]),Ct()),x);return{components:s,computeItemKey:i,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")}}),iw=at(([t,a])=>({...t,...a}),Et(Ny,sw)),ow=({height:t})=>r.jsx("div",{style:{height:t}}),cw={overflowAnchor:"none",position:Hf(),zIndex:1},zy={overflowAnchor:"none"},uw={...zy,display:"inline-block",height:"100%"},zg=Te.memo(function({showTopList:t=!1}){const a=$e("listState"),s=Jn("sizeRanges"),i=$e("useWindowScroll"),c=$e("customScrollParent"),u=Jn("windowScrollContainerState"),d=Jn("scrollContainerState"),h=c||i?u:d,x=$e("itemContent"),m=$e("context"),y=$e("groupContent"),v=$e("trackItemSizes"),b=$e("itemSize"),S=$e("log"),E=Jn("gap"),C=$e("horizontalDirection"),{callbackRef:w}=Ck(s,b,v,t?Fl:h,S,E,c,C,$e("skipAnimationFrameInResizeObserver")),[N,T]=Te.useState(0);Vf("deviation",J=>{N!==J&&T(J)});const R=$e("EmptyPlaceholder"),_=$e("ScrollSeekPlaceholder")??ow,z=$e("ListComponent"),P=$e("ItemComponent"),k=$e("GroupComponent"),O=$e("computeItemKey"),L=$e("isSeeking"),B=$e("groupIndices").length>0,U=$e("alignToBottom"),Y=$e("initialItemFinalLocationReached"),X=t?{}:{boxSizing:"border-box",...C?{display:"inline-block",height:"100%",marginLeft:N!==0?N:U?"auto":0,paddingLeft:a.offsetTop,paddingRight:a.offsetBottom,whiteSpace:"nowrap"}:{marginTop:N!==0?N:U?"auto":0,paddingBottom:a.offsetBottom,paddingTop:a.offsetTop},...Y?{}:{visibility:"hidden"}};return!t&&a.totalCount===0&&R!==null&&R!==void 0?r.jsx(R,{...un(R,m)}):r.jsx(z,{...un(z,m),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:w,style:X,children:(t?a.topItems:a.items).map(J=>{const $=J.originalIndex,M=O($+a.firstItemIndex,J.data,m);return L?p.createElement(_,{...un(_,m),height:J.size,index:J.index,key:M,type:J.type||"item",...J.type==="group"?{}:{groupIndex:J.groupIndex}}):J.type==="group"?p.createElement(k,{...un(k,m),"data-index":$,"data-item-index":J.index,"data-known-size":J.size,key:M,style:cw},y(J.index,m)):p.createElement(P,{...un(P,m),...mw(P,J.data),"data-index":$,"data-item-group-index":J.groupIndex,"data-item-index":J.index,"data-known-size":J.size,key:M,style:C?uw:zy},B?x(J.index,J.groupIndex,J.data,m):x(J.index,J.data,m))})})}),dw={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},fw={outline:"none",overflowX:"auto",position:"relative"},ic=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:void 0}),pw={position:Hf(),top:0,width:"100%",zIndex:1};function un(t,a){if(typeof t!="string")return{context:a}}function mw(t,a){return{item:typeof t=="string"?void 0:a}}const hw=Te.memo(function(){const t=$e("HeaderComponent"),a=Jn("headerHeight"),s=$e("HeaderFooterTag"),i=Ka(Te.useMemo(()=>u=>{a(xa(u,"height"))},[a]),!0,$e("skipAnimationFrameInResizeObserver")),c=$e("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...un(t,c)})}):null}),xw=Te.memo(function(){const t=$e("FooterComponent"),a=Jn("footerHeight"),s=$e("HeaderFooterTag"),i=Ka(Te.useMemo(()=>u=>{a(xa(u,"height"))},[a]),!0,$e("skipAnimationFrameInResizeObserver")),c=$e("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...un(t,c)})}):null});function Dy({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:i,style:c,context:u,...d}){const h=s("scrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("scrollerRef"),v=a("horizontalDirection")||!1,{scrollByCallback:b,scrollerRef:S,scrollToCallback:E}=Ly(h,m,x,y,void 0,v);return t("scrollTo",E),t("scrollBy",b),r.jsx(x,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:S,style:{...v?fw:dw,...c},tabIndex:0,...d,...un(x,u),children:i})})}function _y({useEmitter:t,useEmitterValue:a,usePublisher:s}){return Te.memo(function({children:i,style:c,context:u,...d}){const h=s("windowScrollContainerState"),x=a("ScrollerComponent"),m=s("smoothScrollTargetReached"),y=a("totalListHeight"),v=a("deviation"),b=a("customScrollParent"),S=Te.useRef(null),E=a("scrollerRef"),{scrollByCallback:C,scrollerRef:w,scrollToCallback:N}=Ly(h,m,x,E,b);return My(()=>{var T;return w.current=b||((T=S.current)==null?void 0:T.ownerDocument.defaultView),()=>{w.current=null}},[w,b]),t("windowScrollTo",N),t("scrollBy",C),r.jsx(x,{ref:S,"data-virtuoso-scroller":!0,style:{position:"relative",...c,...y!==0?{height:y+v}:void 0},...d,...un(x,u),children:i})})}const gw=({children:t})=>{const a=Te.useContext(Ry),s=Jn("viewportHeight"),i=Jn("fixedItemHeight"),c=$e("alignToBottom"),u=$e("horizontalDirection"),d=Te.useMemo(()=>sy(s,x=>xa(x,u?"width":"height")),[s,u]),h=Ka(d,!0,$e("skipAnimationFrameInResizeObserver"));return Te.useEffect(()=>{a&&(s(a.viewportHeight),i(a.itemHeight))},[a,s,i]),r.jsx("div",{"data-viewport-type":"element",ref:h,style:ic(c),children:t})},vw=({children:t})=>{const a=Te.useContext(Ry),s=Jn("windowViewportRect"),i=Jn("fixedItemHeight"),c=$e("customScrollParent"),u=oy(s,c,$e("skipAnimationFrameInResizeObserver")),d=$e("alignToBottom");return Te.useEffect(()=>{a&&(i(a.itemHeight),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:100}))},[a,s,i]),r.jsx("div",{"data-viewport-type":"window",ref:u,style:ic(d),children:t})},yw=({children:t})=>{const a=$e("TopItemListComponent")??"div",s=$e("headerHeight"),i={...pw,marginTop:`${s}px`},c=$e("context");return r.jsx(a,{style:i,...un(a,c),children:t})},bw=Te.memo(function(t){const a=$e("useWindowScroll"),s=$e("topItemsIndexes").length>0,i=$e("customScrollParent"),c=$e("context");return r.jsxs(i||a?kw:Sw,{...t,context:c,children:[s&&r.jsx(yw,{children:r.jsx(zg,{showTopList:!0})}),r.jsxs(i||a?vw:gw,{children:[r.jsx(hw,{}),r.jsx(zg,{}),r.jsx(xw,{})]})]})}),{Component:jw,useEmitter:Vf,useEmitterValue:$e,usePublisher:Jn}=Ty(iw,{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"}},bw),Sw=Dy({useEmitter:Vf,useEmitterValue:$e,usePublisher:Jn}),kw=_y({useEmitter:Vf,useEmitterValue:$e,usePublisher:Jn}),ww=jw,Cw=at(()=>{const t=ge(m=>r.jsxs("td",{children:["Item $",m]})),a=ge(null),s=ge(m=>r.jsxs("td",{colSpan:1e3,children:["Group ",m]})),i=ge(null),c=ge(null),u=ge({}),d=ge(Pf),h=ge(Fl),x=(m,y=null)=>dn(he(u,we(v=>v[m]),Ct()),y);return{components:u,computeItemKey:d,context:a,EmptyPlaceholder:x("EmptyPlaceholder"),FillerRow:x("FillerRow"),fixedFooterContent:c,fixedHeaderContent:i,itemContent:t,groupContent:s,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder"),TableBodyComponent:x("TableBody","tbody"),TableComponent:x("Table","table"),TableFooterComponent:x("TableFoot","tfoot"),TableHeadComponent:x("TableHead","thead"),TableRowComponent:x("TableRow","tr"),GroupComponent:x("Group","tr")}});Et(Ny,Cw);Hf();const Dg={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},Ew={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:_g,floor:Wo,max:qs,min:Bd,round:Og}=Math;function Bg(t,a,s){return Array.from({length:a-t+1}).map((i,c)=>({data:s===null?null:s[c+t],index:c+t}))}function Nw(t){return{...Ew,items:t}}function No(t,a){return t!==void 0&&t.width===a.width&&t.height===a.height}function Tw(t,a){return t!==void 0&&t.column===a.column&&t.row===a.row}const Rw=at(([{increaseViewportBy:t,listBoundary:a,overscan:s,visibleRange:i},{footerHeight:c,headerHeight:u,scrollBy:d,scrollContainerState:h,scrollTo:x,scrollTop:m,smoothScrollTargetReached:y,viewportHeight:v},b,S,{didMount:E,propsReady:C},{customScrollParent:w,useWindowScroll:N,windowScrollContainerState:T,windowScrollTo:R,windowViewportRect:_},z])=>{const P=ge(0),k=ge(0),O=ge(Dg),L=ge({height:0,width:0}),B=ge({height:0,width:0}),U=et(),Y=et(),X=ge(0),J=ge(null),$=ge({column:0,row:0}),M=et(),I=et(),F=ge(!1),H=ge(0),re=ge(!0),D=ge(!1),W=ge(!1);ot(he(E,Ye(H),Oe(([oe,be])=>be!==0)),()=>{qe(re,!1)}),ot(he(Vt(E,re,B,L,H,D),Oe(([oe,be,Ne,Be,,Le])=>oe&&!be&&Ne.height!==0&&Be.height!==0&&!Le)),([,,,,oe])=>{qe(D,!0),Bf(1,()=>{qe(U,oe)}),sr(he(m),()=>{qe(a,[0,0]),qe(re,!0)})}),Re(he(I,Oe(oe=>oe!=null&&oe.scrollTop>0),mr(0)),k),ot(he(E,Ye(I),Oe(([,oe])=>oe!=null)),([,oe])=>{oe&&(qe(L,oe.viewport),qe(B,oe.item),qe($,oe.gap),oe.scrollTop>0&&(qe(F,!0),sr(he(m,Wa(1)),be=>{qe(F,!1)}),qe(x,{top:oe.scrollTop})))}),Re(he(L,we(({height:oe})=>oe)),v),Re(he(Vt(_e(L,No),_e(B,No),_e($,(oe,be)=>oe!==void 0&&oe.column===be.column&&oe.row===be.row),_e(m)),we(([oe,be,Ne,Be])=>({gap:Ne,item:be,scrollTop:Be,viewport:oe}))),M),Re(he(Vt(_e(P),i,_e($,Tw),_e(B,No),_e(L,No),_e(J),_e(k),_e(F),_e(re),_e(H)),Oe(([,,,,,,,oe])=>!oe),we(([oe,[be,Ne],Be,Le,Pe,se,de,,me,ve])=>{const{column:je,row:Ve}=Be,{height:ct,width:Nt}=Le,{width:tn}=Pe;if(de===0&&(oe===0||tn===0))return Dg;if(Nt===0){const it=If(ve,oe),Tt=it+Math.max(de-1,0);return Nw(Bg(it,Tt,se))}const bt=Oy(tn,Nt,je);let Ge,pt;me?be===0&&Ne===0&&de>0?(Ge=0,pt=de-1):(Ge=bt*Wo((be+Ve)/(ct+Ve)),pt=bt*_g((Ne+Ve)/(ct+Ve))-1,pt=Bd(oe-1,qs(pt,bt-1)),Ge=Bd(pt,qs(0,Ge))):(Ge=0,pt=-1);const mt=Bg(Ge,pt,se),{bottom:jt,top:Kt}=Ig(Pe,Be,Le,mt),xe=_g(oe/bt),tt=xe*ct+(xe-1)*Ve-jt;return{bottom:jt,itemHeight:ct,items:mt,itemWidth:Nt,offsetBottom:tt,offsetTop:Kt,top:Kt}})),O),Re(he(J,Oe(oe=>oe!==null),we(oe=>oe.length)),P),Re(he(Vt(L,B,O,$),Oe(([oe,be,{items:Ne}])=>Ne.length>0&&be.height!==0&&oe.height!==0),we(([oe,be,{items:Ne},Be])=>{const{bottom:Le,top:Pe}=Ig(oe,Be,be,Ne);return[Pe,Le]}),Ct(Zs)),a);const te=ge(!1);Re(he(m,Ye(te),we(([oe,be])=>be||oe!==0)),te);const q=In(he(Vt(O,P),Oe(([{items:oe}])=>oe.length>0),Ye(te),Oe(([[oe,be],Ne])=>{const Be=oe.items[oe.items.length-1].index===be-1;return(Ne||oe.bottom>0&&oe.itemHeight>0&&oe.offsetBottom===0&&oe.items.length===be)&&Be}),we(([[,oe]])=>oe-1),Ct())),ce=In(he(_e(O),Oe(({items:oe})=>oe.length>0&&oe[0].index===0),mr(0),Ct())),Q=In(he(_e(O),Ye(F),Oe(([{items:oe},be])=>oe.length>0&&!be),we(([{items:oe}])=>({endIndex:oe[oe.length-1].index,startIndex:oe[0].index})),Ct(my),$r(0)));Re(Q,S.scrollSeekRangeChanged),Re(he(U,Ye(L,B,P,$),we(([oe,be,Ne,Be,Le])=>{const Pe=yy(oe),{align:se,behavior:de,offset:me}=Pe;let ve=Pe.index;ve==="LAST"&&(ve=Be-1),ve=qs(0,ve,Bd(Be-1,ve));let je=hf(be,Le,Ne,ve);return se==="end"?je=Og(je-be.height+Ne.height):se==="center"&&(je=Og(je-be.height/2+Ne.height/2)),me!==void 0&&me!==0&&(je+=me),{behavior:de,top:je}})),x);const ye=dn(he(O,we(oe=>oe.offsetBottom+oe.bottom)),0);return Re(he(_,we(oe=>({height:oe.visibleHeight,width:oe.visibleWidth}))),L),{customScrollParent:w,data:J,deviation:X,footerHeight:c,gap:$,headerHeight:u,increaseViewportBy:t,initialItemCount:k,itemDimensions:B,overscan:s,restoreStateFrom:I,scrollBy:d,scrollContainerState:h,scrollHeight:Y,scrollTo:x,scrollToIndex:U,scrollTop:m,smoothScrollTargetReached:y,totalCount:P,useWindowScroll:N,viewportDimensions:L,windowScrollContainerState:T,windowScrollTo:R,windowViewportRect:_,...S,gridState:O,horizontalDirection:W,initialTopMostItemIndex:H,totalListHeight:ye,...b,endReached:q,propsReady:C,rangeChanged:Q,startReached:ce,stateChanged:M,stateRestoreInProgress:F,...z}},Et($f,xn,ii,Cy,ba,Uf,ya));function Oy(t,a,s){return qs(1,Wo((t+s)/(Wo(a)+s)))}function Ig(t,a,s,i){const{height:c}=s;if(c===void 0||i.length===0)return{bottom:0,top:0};const u=hf(t,a,s,i[0].index);return{bottom:hf(t,a,s,i[i.length-1].index)+c,top:u}}function hf(t,a,s,i){const c=Oy(t.width,s.width,a.column),u=Wo(i/c),d=u*s.height+qs(0,u-1)*a.row;return d>0?d+a.row:d}const Aw=at(()=>{const t=ge(v=>`Item ${v}`),a=ge({}),s=ge(null),i=ge("virtuoso-grid-item"),c=ge("virtuoso-grid-list"),u=ge(Pf),d=ge("div"),h=ge(Fl),x=(v,b=null)=>dn(he(a,we(S=>S[v]),Ct()),b),m=ge(!1),y=ge(!1);return Re(_e(y),m),{components:a,computeItemKey:u,context:s,FooterComponent:x("Footer"),HeaderComponent:x("Header"),headerFooterTag:d,itemClassName:i,ItemComponent:x("Item","div"),itemContent:t,listClassName:c,ListComponent:x("List","div"),readyStateChanged:m,reportReadyState:y,ScrollerComponent:x("Scroller","div"),scrollerRef:h,ScrollSeekPlaceholder:x("ScrollSeekPlaceholder","div")}}),Mw=at(([t,a])=>({...t,...a}),Et(Rw,Aw)),Lw=Te.memo(function(){const t=At("gridState"),a=At("listClassName"),s=At("itemClassName"),i=At("itemContent"),c=At("computeItemKey"),u=At("isSeeking"),d=er("scrollHeight"),h=At("ItemComponent"),x=At("ListComponent"),m=At("ScrollSeekPlaceholder"),y=At("context"),v=er("itemDimensions"),b=er("gap"),S=At("log"),E=At("stateRestoreInProgress"),C=er("reportReadyState"),w=Ka(Te.useMemo(()=>N=>{const T=N.parentElement.parentElement.scrollHeight;d(T);const R=N.firstChild;if(R!==null){const{height:_,width:z}=R.getBoundingClientRect();v({height:_,width:z})}b({column:$g("column-gap",getComputedStyle(N).columnGap,S),row:$g("row-gap",getComputedStyle(N).rowGap,S)})},[d,v,b,S]),!0,!1);return My(()=>{t.itemHeight>0&&t.itemWidth>0&&C(!0)},[t]),E?null:r.jsx(x,{className:a,ref:w,...un(x,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,{...un(m,y),height:t.itemHeight,index:N.index,width:t.itemWidth},T):p.createElement(h,{...un(h,y),className:s,"data-index":N.index,key:T},i(N.index,N.data,y))})})}),zw=Te.memo(function(){const t=At("HeaderComponent"),a=er("headerHeight"),s=At("headerFooterTag"),i=Ka(Te.useMemo(()=>u=>{a(xa(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...un(t,c)})}):null}),Dw=Te.memo(function(){const t=At("FooterComponent"),a=er("footerHeight"),s=At("headerFooterTag"),i=Ka(Te.useMemo(()=>u=>{a(xa(u,"height"))},[a]),!0,!1),c=At("context");return t!=null?r.jsx(s,{ref:i,children:r.jsx(t,{...un(t,c)})}):null}),_w=({children:t})=>{const a=Te.useContext(Ay),s=er("itemDimensions"),i=er("viewportDimensions"),c=Ka(Te.useMemo(()=>u=>{i(u.getBoundingClientRect())},[i]),!0,!1);return Te.useEffect(()=>{a&&(i({height:a.viewportHeight,width:a.viewportWidth}),s({height:a.itemHeight,width:a.itemWidth}))},[a,i,s]),r.jsx("div",{ref:c,style:ic(!1),children:t})},Ow=({children:t})=>{const a=Te.useContext(Ay),s=er("windowViewportRect"),i=er("itemDimensions"),c=At("customScrollParent"),u=oy(s,c,!1);return Te.useEffect(()=>{a&&(i({height:a.itemHeight,width:a.itemWidth}),s({listHeight:0,offsetTop:0,visibleHeight:a.viewportHeight,visibleWidth:a.viewportWidth}))},[a,s,i]),r.jsx("div",{ref:u,style:ic(!1),children:t})},Bw=Te.memo(function({...t}){const a=At("useWindowScroll"),s=At("customScrollParent"),i=s||a?$w:Iw,c=s||a?Ow:_w,u=At("context");return r.jsx(i,{...t,...un(i,u),children:r.jsxs(c,{children:[r.jsx(zw,{}),r.jsx(Lw,{}),r.jsx(Dw,{})]})})}),{useEmitter:By,useEmitterValue:At,usePublisher:er}=Ty(Mw,{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"}},Bw),Iw=Dy({useEmitter:By,useEmitterValue:At,usePublisher:er}),$w=_y({useEmitter:By,useEmitterValue:At,usePublisher:er});function $g(t,a,s){return a!=="normal"&&(a==null?void 0:a.endsWith("px"))!==!0&&s(`${t} was not resolved to pixel value correctly`,a,qt.WARN),a==="normal"?0:parseInt(a??"0",10)}const Uw={source:"vskill-sidebar-own-collapsed",installed:"vskill-sidebar-installed-collapsed"},Iy={source:"Own",installed:"Installed"};function Hw(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 Pw(t,a){const s=a?"true":"false";try{localStorage.setItem(t,s)}catch{}try{typeof sessionStorage<"u"&&sessionStorage.setItem(t,s)}catch{}}function Ug({origin:t,count:a,filteredCount:s,updateCount:i,children:c}){const u=Uw[t],[d,h]=p.useState(()=>Hw(u)),x=p.useCallback(()=>{h(b=>{const S=!b;return Pw(u,S),S})},[u]),m=Iy[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:x,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(Fw,{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})`}),i!=null&&i>0&&r.jsx(Vw,{origin:t,updateCount:i})]}),!d&&r.jsx("div",{id:v,role:"group","aria-labelledby":y,style:{display:"flex",flexDirection:"column",minHeight:0},children:c})]})}function Vw({origin:t,updateCount:a}){const[s,i]=p.useState(!1),c=Iy[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:()=>i(!0),onBlur:()=>i(!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 Fw({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 Ff(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:i,validationMessage:c="Invalid filter expression"}){const u=p.useRef(null),d=p.useId(),h=!!i&&t.trim()!==""&&!i.test(t);return p.useEffect(()=>{function x(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",x),()=>window.removeEventListener("keydown",x)},[]),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:x=>a(x.currentTarget.value),onKeyDown:x=>{x.key==="Escape"&&(a(""),x.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 Ww({target:t}){const a=typeof t=="string"&&t.length>0,s=a?`symlinked → ${t}`:"symlinked — cycle detected or target unresolved",i=a?`symlinked from ${t}`:"symlinked, target unresolved";return r.jsx("span",{"data-testid":"symlink-chip",role:"img","aria-label":i,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 qw({skill:t}){if(!t.updateAvailable)return null;const a=t.currentVersion??"",s=t.latestVersion,i=s?`Update available: ${a} → ${s}`.trim():"Update available";return r.jsx("span",{"data-testid":"skill-row-update-glyph",title:i,"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 Yw({skillId:t,trackedForUpdates:a}){let s=null;try{s=p.useContext(Yv)}catch{s=null}const i=s==null?void 0:s.updatesById.get(t);if(i){const c=`Update available → ${i.version}${i.diffSummary?` — ${i.diffSummary}`:""}`;return r.jsx("span",{"data-testid":"update-chip-update-dot","aria-label":`Update available: ${i.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 Kw(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 oi(t){const{version:a,showPrefix:s=!0,size:i="md",source:c,pluginName:u}=t,d=typeof a=="string"?a.trim():"",h=d===""||d==="0.0.0"?"1.0.0":d,x=s&&!h.startsWith("v")?`v${h}`:h,m=i==="sm"?10:12,y=i==="sm"?1:2,v=i==="sm"?5:8,b=c==="registry"||c==="plugin",S=Kw(c,h,u),E=t.title??S,C={display:"inline-flex",alignItems:"center",padding:`${y}px ${v}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:m,fontVariantNumeric:"tabular-nums",lineHeight:1.2,whiteSpace:"nowrap",flexShrink:0};return b&&(C.fontStyle="italic"),r.jsx("span",{"data-testid":t["data-testid"]??"version-badge","data-version":h,"data-version-source":c,title:E,style:C,children:x})}function Xw({skill:t,isSelected:a,onSelect:s,onContextMenu:i,dirty:c}){const u=t.origin==="installed"?"var(--status-installed)":"var(--status-own)";return r.jsxs("button",{type:"button",onClick:s,onContextMenu:i?d=>{d.preventDefault(),i(d,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:u,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}),c&&r.jsx("span",{"aria-label":"Uncommitted changes","data-testid":"skill-row-dirty-dot",title:"Uncommitted changes — open this skill, click Publish to commit & push",style:{width:7,height:7,borderRadius:"50%",background:"var(--color-warning, #f59e0b)",display:"inline-block",flexShrink:0,boxShadow:"0 0 0 1px rgba(245,158,11,0.25)"}}),r.jsx(oi,{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(Ww,{target:t.symlinkTarget??null}),r.jsx(qw,{skill:t}),r.jsx(Yw,{skillId:`${t.plugin}/${t.skill}`,trackedForUpdates:t.trackedForUpdates??!0})]})}const qo=p.memo(Xw);function Qw({plugin:t,skills:a,selectedKey:s,onSelect:i,onContextMenu:c,dirtySkillIds:u}){const d=[...a].sort((h,x)=>h.skill.localeCompare(x.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:d.map(h=>{const x=!!s&&s.plugin===h.plugin&&s.skill===h.skill;return r.jsx("div",{role:"listitem",children:r.jsx(qo,{skill:h,isSelected:x,onSelect:()=>i(h),onContextMenu:c,dirty:u==null?void 0:u.has(`${h.plugin}/${h.skill}`)})},`${h.plugin}/${h.skill}`)})})]})}function Zw(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 Hg({skills:t,pluginName:a,initialCollapsed:s=!1,persistKey:i,renderSkill:c,headerActionSlot:u,forceOpen:d=!1}){var S;const h=a??((S=t[0])==null?void 0:S.pluginName)??"unknown-plugin",[x,m]=p.useState(()=>Zw(i,s)),y=d?!1:x,v=p.useCallback(()=>{m(E=>{const C=!E;if(i&&typeof window<"u")try{window.localStorage.setItem(i,String(C))}catch{}return C})},[i]),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(E=>r.jsx("div",{"data-vskill-plugin-skill":E.pluginNamespace??E.skill,children:c(E)},`${E.pluginNamespace??E.skill}`))})]})}function Po({open:t,title:a,body:s,confirmLabel:i="Confirm",cancelLabel:c="Cancel",variant:u="default",onConfirm:d,onCancel:h}){const x=p.useRef(null),m=p.useRef(null),y=p.useRef(null);if(p.useEffect(()=>{if(t)return y.current=document.activeElement??null,requestAnimationFrame(()=>{var E;(E=m.current)==null||E.focus()}),()=>{var E,C;(C=(E=y.current)==null?void 0:E.focus)==null||C.call(E),y.current=null}},[t]),p.useEffect(()=>{if(!t)return;function E(C){if(C.key==="Escape"){C.preventDefault(),h();return}if(C.key==="Tab"&&x.current){const w=x.current.querySelectorAll("button:not([disabled])");if(w.length===0)return;const N=w[0],T=w[w.length-1];C.shiftKey&&document.activeElement===N?(C.preventDefault(),T.focus()):!C.shiftKey&&document.activeElement===T&&(C.preventDefault(),N.focus())}}return window.addEventListener("keydown",E,!0),()=>window.removeEventListener("keydown",E,!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:E=>{E.target===E.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:x,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:i})]})]})})}function Jw(t){const a=(typeof navigator<"u"?navigator.platform:"").toLowerCase();return a.includes("mac")?"system Trash":a.includes("win")?"Recycle Bin":"Trash"}function Id(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function eC({pluginName:t,enabled:a,onAfterAction:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(null),[h,x]=p.useState(null),[m,y]=p.useState(!1),v=p.useRef(null);p.useEffect(()=>{if(!i)return;function E(C){v.current&&!v.current.contains(C.target)&&c(!1)}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[i]);async function b(E){d(E),x(null);try{const C=await fetch(`/api/plugins/${encodeURIComponent(t)}/${E}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),w=await C.json().catch(()=>({}));if(!C.ok||!w.ok){const N=w.error??`${E} failed (${C.status})`;x(N),E==="uninstall"&&Id(`Failed to uninstall ${t}: ${N}`,"error");return}if(E==="uninstall"){const N=w.fallback==="orphan-cache-removed"?`Removed orphaned ${t}`:`Uninstalled ${t}`;Id(N,"success")}Bn("skills"),ry(),s==null||s(),c(!1)}catch(C){const w=C instanceof Error?C.message:String(C);x(w),E==="uninstall"&&Id(`Failed to uninstall ${t}: ${w}`,"error")}finally{d(null)}}function S(){y(!0)}return r.jsxs("div",{ref:v,style:{position:"relative",display:"inline-flex"},children:[r.jsx("button",{type:"button","aria-label":`Manage ${t}`,title:`Manage ${t}`,onClick:E=>{E.stopPropagation(),c(C=>!C)},"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:i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent",color:"var(--text-tertiary)",borderRadius:4,cursor:"pointer",fontSize:14,lineHeight:1},onMouseEnter:E=>{E.currentTarget.style.color="var(--text-primary)",E.currentTarget.style.background="var(--surface-2, rgba(0,0,0,0.06))"},onMouseLeave:E=>{E.currentTarget.style.color="var(--text-tertiary)",E.currentTarget.style.background=i?"var(--surface-2, rgba(0,0,0,0.08))":"transparent"},children:"⋯"}),i&&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($d,{onClick:()=>void b("disable"),disabled:u!==null,busy:u==="disable",label:"Disable",hint:"Keep installed, turn off"}):r.jsx($d,{onClick:()=>void b("enable"),disabled:u!==null,busy:u==="enable",label:"Enable",hint:"Activate plugin"}),r.jsx($d,{onClick:S,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})]}),r.jsx(Po,{open:m,title:`Uninstall ${t}?`,body:`This removes the ${t} plugin and all of its skills. You can reinstall it later from the marketplace.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onCancel:()=>{y(!1),c(!1)},onConfirm:()=>{y(!1),b("uninstall")}})]})}function $d({onClick:t,disabled:a,busy:s,label:i,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?`${i}…`:i}),r.jsx("div",{style:{fontSize:10,color:"var(--text-tertiary)"},children:c})]})}function Pg({name:t,count:a,className:s,variant:i,collapsed:c,onToggle:u,action:d}){const h=i==="authoring"?"var(--color-own, #f59e0b)":"var(--color-accent, #2f6f8f)",x=i==="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:x,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(tC,{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 tC({label:t,title:a,icon:s,onClick:i,accent:c}){return r.jsxs("button",{type:"button","aria-label":t,title:a??t,onClick:u=>{u.stopPropagation(),i()},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 nC(){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 rC(t){const a=t.key.split("+").map(h=>h.trim()).filter(Boolean);let s=!!t.meta,i=!!t.ctrl,c=!!t.shift,u=!!t.alt,d=t.key;if(a.length>1){for(const h of a.slice(0,-1)){const x=h.toLowerCase();x==="cmd"||x==="meta"||x==="⌘"?s=!0:x==="ctrl"||x==="control"?i=!0:x==="shift"?c=!0:(x==="alt"||x==="option")&&(u=!0)}d=a[a.length-1]}return{key:d.length===1?d.toLowerCase():d,meta:s,ctrl:i,shift:c,alt:u,allowInInputs:!!t.allowInInputs,handler:t.handler}}function aC(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 lC(t,a){const s=!!t.metaKey,i=!!t.ctrlKey,c=!!t.shiftKey,u=!!t.altKey;return s!==a.meta||i!==a.ctrl||c!==a.shift||u!==a.alt?!1:(t.key.length===1?t.key.toLowerCase():t.key)===a.key}function xf(t,a={}){const{enabled:s=!0,target:i}=a,c=p.useRef([]),u=Array.isArray(t)?t:[t];c.current=u.map(rC),p.useEffect(()=>{if(!s)return;const d=i??(typeof window<"u"?window:void 0);if(!d)return;function h(x){const m=x,y=aC(m.target);for(const v of c.current){if(!lC(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,i])}function $y(){const{data:t,loading:a,error:s,revalidate:i}=qa("project-github-status",()=>ke.getProjectGitHubStatus());return{status:t,loading:a,error:s,revalidate:i}}function sC(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(`vskill-github-hint-dismissed-${t}`)==="true"}catch{return!1}}function iC({projectRoot:t}){const{status:a,loading:s}=$y();if(s||!a||a.status==="github"||sC(t))return null;const i=a.status==="no-git"?"GitHub not connected — run `gh repo create ...` to publish your skills":"Origin is not GitHub — add a github.com remote to publish",c=()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:focus-publish-row"))};return r.jsx("button",{type:"button","data-testid":"sidebar-github-not-connected","aria-label":"GitHub not connected — click for help",title:i,onClick:c,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,padding:0,background:"transparent",border:"none",cursor:"pointer",color:"var(--color-own, #f59e0b)"},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"m2 2 20 20"}),r.jsx("path",{d:"M5.782 5.782A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.307-.193"}),r.jsx("path",{d:"M21.532 16.5A4.5 4.5 0 0 0 17.5 10h-1.79A7.008 7.008 0 0 0 10 5.07"})]})})}const oC=200;function cC(t){return t.scope==="own"||t.scope==="installed"||t.scope==="global"?t.scope:t.origin==="installed"?"installed":"own"}function uC(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 i(c){const u=c.filter(x=>Ff(x,a)),d={};for(const x of u){const m=x.pluginName??x.plugin;(d[m]||(d[m]=[])).push(x)}const h=Object.entries(d).sort((x,m)=>x[0].localeCompare(m[0]));return{total:c.length,filtered:u.length,byPlugin:h}}return{availableProject:i(s.availableProject),availablePersonal:i(s.availablePersonal),availablePlugin:i(s.availablePlugin),authoringProject:i(s.authoringProject),authoringPlugin:i(s.authoringPlugin)}}function dC(t,a){const s=[],i=[],c=[];for(const d of t){const h=cC(d);h==="global"?c.push(d):h==="installed"?i.push(d):s.push(d)}function u(d){var y;const h=d.filter(v=>Ff(v,a)),x={};for(const v of h)(x[y=v.plugin]||(x[y]=[])).push(v);const m=Object.entries(x).sort((v,b)=>v[0].localeCompare(b[0]));return{total:d.length,filtered:h.length,byPlugin:m}}return{own:u(s),installed:u(i),global:u(c)}}function fC(t,a){const s=[],i=[];for(const u of t)(u.origin==="installed"?i:s).push(u);function c(u){var m;const d=u.filter(y=>Ff(y,a)),h={};for(const y of d)(h[m=y.plugin]||(h[m]=[])).push(y);const x=Object.entries(h).sort((y,v)=>y[0].localeCompare(v[0]));return{total:u.length,filtered:d.length,byPlugin:x}}return{own:c(s),installed:c(i)}}function pC({skills:t,selectedKey:a,onSelect:s,isLoading:i,error:c,onRetry:u,onContextMenu:d,outdatedByOrigin:h,activeAgentId:x,outdatedByScope:m,topSlot:y,revealSkillId:v,onRevealComplete:b,dirtySkillIds:S}){const E=!!x||t.some(q=>q.scope!==void 0&&q.scope!==null),C=x??"claude-cli",[w,N]=p.useState(""),T=p.useDeferredValue(w),R=p.useMemo(()=>dC(t,T),[t,T]),_=p.useMemo(()=>uC(t,T),[t,T]),z=C==="claude-code",{plugins:P}=ay(),k=z?{plugins:P??[]}:void 0,O=p.useMemo(()=>{const q=new Map;for(const ce of(k==null?void 0:k.plugins)??[]){const Q=q.get(ce.name);q.set(ce.name,!!Q||!!ce.enabled)}return q},[k==null?void 0:k.plugins]),[L,B]=p.useState(()=>gf(`vskill-sidebar-${C}-group-available-collapsed`)),[U,Y]=p.useState(()=>gf(`vskill-sidebar-${C}-group-authoring-collapsed`)),X=p.useCallback(q=>{B(q);try{window.localStorage.setItem(`vskill-sidebar-${C}-group-available-collapsed`,String(q))}catch{}},[C]),J=p.useCallback(q=>{Y(q);try{window.localStorage.setItem(`vskill-sidebar-${C}-group-authoring-collapsed`,String(q))}catch{}},[C]),{own:$,installed:M}=p.useMemo(()=>fC(t,T),[t,T]),F=R.own.filtered+R.installed.filtered+R.global.filtered>=oC,H=p.useMemo(()=>{const q=ce=>{const Q=[];for(const[,ye]of ce){const oe=[...ye].sort((be,Ne)=>be.skill.localeCompare(Ne.skill));Q.push(...oe)}return Q};return E?[...q(R.own.byPlugin),...q(R.installed.byPlugin),...q(R.global.byPlugin)]:[...q($.byPlugin),...q(M.byPlugin)]},[E,R.own.byPlugin,R.installed.byPlugin,R.global.byPlugin,$.byPlugin,M.byPlugin]),re=p.useMemo(()=>a?H.findIndex(q=>q.plugin===a.plugin&&q.skill===a.skill):-1,[H,a]),D=p.useCallback(q=>{if(H.length===0)return;const ce=re<0?q>0?0:H.length-1:Math.min(Math.max(re+q,0),H.length-1);s(H[ce])},[H,re,s]),W=p.useMemo(()=>{if(!v)return null;const[q,ce]=v.split("/");if(!q||!ce)return null;const Q=t.find(be=>be.plugin===q&&be.skill===ce);if(!Q)return{plugin:q,skill:ce,bucket:null,pluginName:null};const ye=Q.source==="plugin"?"plugin":"project",oe=ye==="plugin"?Q.pluginName??q:null;return{plugin:q,skill:ce,bucket:ye,pluginName:oe}},[v,t]),te=p.useRef(null);return p.useEffect(()=>{if(!v){te.current=null;return}if(te.current===v)return;const q=typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(v):v.replace(/["\\]/g,"\\$&"),ce=document.querySelector(`[data-skill-id="${q}"]`);ce&&(te.current=v,ce.scrollIntoView({behavior:"smooth",block:"nearest"}),b==null||b())},[v,b,t]),xf([{key:"j",handler:()=>D(1)},{key:"k",handler:()=>D(-1)},{key:"Enter",handler:()=>{re>=0&&s(H[re])}}],{enabled:!i&&!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:w,onChange:N}),i&&r.jsx(bC,{}),!i&&c&&r.jsx(jC,{error:c,onRetry:u}),!i&&!c&&E&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Pg,{name:ae.scopeLabels.groupAvailable.toUpperCase(),variant:"available",collapsed:L,onToggle:X,count:_.availableProject.total+_.availablePersonal.total+_.availablePlugin.total}),!L&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:ae.scopeLabels.sourceProject,storageKey:`vskill-sidebar-${C}-available-project-collapsed`,count:_.availableProject.total,filteredCount:w?_.availableProject.filtered:null,updateCount:(m==null?void 0:m.installed)??(h==null?void 0:h.installed),headerRightSlot:z?r.jsx(iC,{projectRoot:C}):null,children:_.availableProject.filtered===0?r.jsx(Fg,{queryActive:!!w,agentId:C}):r.jsx($s,{items:_.availableProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:F,dirtySkillIds:S})}),r.jsx(Is,{label:ae.scopeLabels.sourcePersonal,storageKey:`vskill-sidebar-${C}-available-personal-collapsed`,count:_.availablePersonal.total,filteredCount:w?_.availablePersonal.filtered:null,updateCount:m==null?void 0:m.global,children:_.availablePersonal.filtered===0?r.jsx(hC,{queryActive:!!w,agentId:C}):r.jsx($s,{items:_.availablePersonal.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:F,dirtySkillIds:S})}),z&&r.jsxs(Is,{label:ae.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${C}-available-plugin-collapsed`,count:_.availablePlugin.total,filteredCount:w?_.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…"]}),_.availablePlugin.filtered===0?r.jsx(xC,{queryActive:!!w,hasInstalled:_.availablePlugin.total>0}):_.availablePlugin.byPlugin.map(([q,ce])=>r.jsx(Hg,{pluginName:q,skills:ce,persistKey:`vskill-plugin-available-${q}-collapsed`,headerActionSlot:z?r.jsx(eC,{pluginName:q,enabled:O.get(q)??!0}):void 0,renderSkill:Q=>r.jsx(qo,{skill:Q,isSelected:(a==null?void 0:a.plugin)===Q.plugin&&(a==null?void 0:a.skill)===Q.skill,onSelect:()=>s(Q),onContextMenu:d,dirty:S==null?void 0:S.has(`${Q.plugin}/${Q.skill}`)})},`available-${q}`))]})]}),r.jsx(yC,{}),r.jsx(Pg,{name:ae.scopeLabels.groupAuthoring.toUpperCase(),variant:"authoring",collapsed:W?!1:U,onToggle:J,count:_.authoringProject.total+_.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||W)&&r.jsxs(r.Fragment,{children:[r.jsx(Is,{label:ae.scopeLabels.authoringSkills,storageKey:`vskill-sidebar-${C}-authoring-project-collapsed`,count:_.authoringProject.total,filteredCount:w?_.authoringProject.filtered:null,updateCount:(m==null?void 0:m.own)??(h==null?void 0:h.source),forceOpen:(W==null?void 0:W.bucket)==="project",children:_.authoringProject.filtered===0?r.jsx(Vg,{queryActive:!!w}):r.jsx($s,{items:_.authoringProject.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:F,dirtySkillIds:S})}),z&&r.jsx(Is,{label:ae.scopeLabels.sourcePlugin,storageKey:`vskill-sidebar-${C}-authoring-plugin-collapsed`,count:_.authoringPlugin.total,filteredCount:w?_.authoringPlugin.filtered:null,forceOpen:(W==null?void 0:W.bucket)==="plugin",children:_.authoringPlugin.filtered===0?r.jsx(gC,{queryActive:!!w,hasSources:_.authoringPlugin.total>0}):_.authoringPlugin.byPlugin.map(([q,ce])=>r.jsx(Hg,{pluginName:q,skills:ce,persistKey:`vskill-plugin-authoring-${q}-collapsed`,forceOpen:(W==null?void 0:W.bucket)==="plugin"&&W.pluginName===q,renderSkill:Q=>r.jsx(qo,{skill:Q,isSelected:(a==null?void 0:a.plugin)===Q.plugin&&(a==null?void 0:a.skill)===Q.skill,onSelect:()=>s(Q),onContextMenu:d,dirty:S==null?void 0:S.has(`${Q.plugin}/${Q.skill}`)})},`authoring-${q}`))})]})]}),!i&&!c&&!E&&r.jsxs("div",{style:{flex:1,overflowY:"auto",minHeight:0},children:[r.jsx(Ug,{origin:"source",count:$.total,filteredCount:w?$.filtered:null,updateCount:h==null?void 0:h.source,children:$.filtered===0?r.jsx(Vg,{queryActive:!!w}):r.jsx($s,{items:$.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:F,dirtySkillIds:S})}),r.jsx(vC,{}),r.jsx(Ug,{origin:"installed",count:M.total,filteredCount:w?M.filtered:null,updateCount:h==null?void 0:h.installed,children:M.filtered===0?r.jsx(Fg,{queryActive:!!w}):r.jsx($s,{items:M.byPlugin,selectedKey:a,onSelect:s,onContextMenu:d,useVirtual:F,dirtySkillIds:S})})]})]})}function gf(t){if(typeof window>"u")return!1;try{return window.localStorage.getItem(t)==="true"}catch{return!1}}function Is({label:t,storageKey:a,count:s,filteredCount:i,updateCount:c,children:u,forceOpen:d=!1,headerRightSlot:h}){const[x,m]=p.useState(()=>gf(a)),y=d?!1:x,v=p.useCallback(()=>{m(S=>{const E=!S;if(typeof window<"u")try{window.localStorage.setItem(a,String(E))}catch{}return E})},[a]),b=i!=null&&i!==s?`${i} of ${s}`:String(s);return r.jsxs("section",{"data-vskill-named-scope":t,children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",padding:"6px 12px",gap:8},children:[r.jsxs("button",{type:"button",onClick:v,"aria-expanded":!y,style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0,padding:0,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:y?"▸":"▾"}),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:["(",b,")"]}),c!=null&&c>0&&r.jsxs("span",{style:{marginLeft:"auto",fontSize:10,color:"var(--color-own, #f59e0b)"},children:[c," update",c!==1?"s":""]})]}),h]}),!y&&r.jsx("div",{style:{paddingLeft:18},children:u})]})}function mC(t){const a=[];for(const[s,i]of t){const c=[...i].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 $s({items:t,selectedKey:a,onSelect:s,onContextMenu:i,useVirtual:c,dirtySkillIds:u}){if(c){const d=mC(t);return r.jsx("div",{"data-virtualized":"true",style:{height:420,minHeight:200},children:r.jsx(ww,{overscan:4,totalCount:d.length,itemContent:h=>{const x=d[h];if(!x)return null;if(x.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:x.plugin}),r.jsxs("span",{style:{fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums",fontFamily:"var(--font-mono)"},children:["(",x.count,")"]})]});const m=x.skill,y=!!a&&a.plugin===m.plugin&&a.skill===m.skill;return r.jsx(qo,{skill:m,isSelected:y,onSelect:()=>s(m),onContextMenu:i,dirty:u==null?void 0:u.has(`${m.plugin}/${m.skill}`)})}})})}return r.jsx("div",{"data-virtualized":"false",children:t.map(([d,h])=>r.jsx(Qw,{plugin:d,skills:h,selectedKey:a,onSelect:s,onContextMenu:i,dirtySkillIds:u},d))})}function Vg({queryActive:t}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No skills yet.",body:r.jsxs(r.Fragment,{children:["Create one with ",r.jsx(ci,{children:"vskill new"})," or the"," ",r.jsx("strong",{style:{color:"var(--text-primary)"},children:"New skill"})," action in the top rail."]})})}function Fg({queryActive:t,agentId:a}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:a?`No skills installed for ${a} in this project.`:"No installed skills.",body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(ci,{children:"vskill install <skill>"})," to add one."]})})}function hC({queryActive:t,agentId:a}){return t?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:`No global skills for ${a}.`,body:r.jsxs(r.Fragment,{children:["Run ",r.jsx(ci,{children:"vskill install --global <skill>"})," to add one."]})})}function xC({queryActive:t,hasInstalled:a}){return t&&a?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No plugin skills installed yet.",body:r.jsxs(r.Fragment,{children:["Click ",r.jsx(ci,{children:"Browse marketplaces…"})," above to add one."]})})}function gC({queryActive:t,hasSources:a}){return t&&a?r.jsx(gr,{headline:"No matches in this section.",body:"Adjust the filter or press Escape to clear."}):r.jsx(gr,{headline:"No plugin sources in this project.",body:r.jsxs(r.Fragment,{children:["Add ",r.jsx(ci,{children:"<plugin>/.claude-plugin/plugin.json"})," to author one."]})})}function gr({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 ci({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 vC(){return r.jsx("div",{"aria-hidden":"true",style:{height:1,background:"var(--border-default)",margin:"4px 14px"}})}function yC(){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 bC(){return r.jsx("div",{style:{padding:"8px 0"},children:[0,1,2,3,4,5].map(t=>r.jsx(nC,{},t))})}function jC({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:SC(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 SC(t){const a=t.split(`
|
|
66
|
-
`)[0]??t;return a.length>80?a.slice(0,77)+"…":a}const Uy=240,Hy=480,Py="vskill-sidebar-width",Ys=320;function Gf(t){return Number.isFinite(t)?Math.round(Math.max(Uy,Math.min(Hy,t))):Ys}function kC(){try{const t=localStorage.getItem(Py);if(!t)return Ys;const a=Number(t);return Number.isFinite(a)?Gf(a):Ys}catch{return Ys}}function wC(t){try{localStorage.setItem(Py,String(Gf(t)))}catch{}}function CC({initialWidth:t,onChange:a}){const s=p.useRef({startX:0,startWidth:t,pointerId:null}),i=p.useRef(t);return p.useEffect(()=>{i.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,x=Gf(s.current.startWidth+h);i.current=x,a(x)}function u(d){s.current.pointerId==null||d.pointerId!==s.current.pointerId||(s.current.pointerId=null,wC(i.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":Uy,"aria-valuemax":Hy,"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=i.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"}})}const EC=/^[ MADRCU?!]{1,2} +/;function NC(t){return t.replace(EC,"")}function TC(t,a){const s=t.endsWith("/")?t:t+"/";return a===t?"":a.startsWith(s)?a.slice(s.length):null}function RC(t,a,s){const i=new Set;if(a.length===0||t.length===0)return i;const c=a.map(u=>NC(u).trim()).filter(u=>u.length>0);for(const u of t){const d=u.dir;if(!d)continue;const h=TC(s,d);if(h===null)continue;const x=`${u.plugin}/${u.skill}`;if(h===""){c.length>0&&i.add(x);continue}const m=h+"/";for(const y of c)if(y===h||y.startsWith(m)){i.add(x);break}}return i}const AC=5e3;function MC(t,a,s=AC){const[i,c]=p.useState([]),u=p.useRef(t);return u.current=t,p.useEffect(()=>{if(!a){c([]);return}let d=!1,h=null;const x=async()=>{try{const y=await ke.gitStatus();d||c(y.paths??[])}catch{d||c([])}d||(h=setTimeout(x,s))};x();const m=()=>{x()};return typeof window<"u"&&window.addEventListener("studio:content-saved",m),()=>{d=!0,h&&clearTimeout(h),typeof window<"u"&&window.removeEventListener("studio:content-saved",m)}},[a,s]),a?RC(u.current,i,a):new Set}function LC({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 Vy(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 Fy(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,(i,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 Ud(){const[t,a]=p.useState([]),[s,i]=p.useState(!1),[c,u]=p.useState(!1),[d,h]=p.useState(null),x=p.useRef(null),m=p.useCallback(async(v,b)=>{a([]),i(!0),u(!1),h(null);const S=new AbortController;x.current=S;try{const E=Fy(b),C=await fetch(v,{method:"POST",headers:{"Content-Type":"application/json"},body:E,signal:S.signal});if(!C.ok||!C.body){let _=`HTTP ${C.status}`,z;try{z=await C.json(),z&&typeof z=="object"&&"error"in z&&typeof z.error=="string"&&(_=z.error)}catch{}throw Vy(C.status,z),new Error(_)}const w=C.body.getReader(),N=new TextDecoder;let T="",R="";for(;;){const{done:_,value:z}=await w.read();if(_)break;T+=N.decode(z,{stream:!0});const P=T.split(`
|
|
67
|
-
`);T=P.pop()||"";for(const k of P)if(k.startsWith("event: "))R=k.slice(7).trim();else if(k.startsWith("data: ")){try{const O=JSON.parse(k.slice(6)),L={event:R,data:O};R==="done"?(u(!0),a(B=>[...B,L])):a(B=>[...B,L])}catch{}R=""}}}catch(E){E.name!=="AbortError"&&h(E.message)}finally{i(!1),x.current=null}},[]),y=p.useCallback(()=>{var v;(v=x.current)==null||v.abort()},[]);return{events:t,running:s,done:c,error:d,start:m,stop:y}}function zC(t){const a=p.useRef(t);a.current=t;const[s,i]=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),i(E=>{const C=new Set(E);return C.add(m),C});try{const E=Fy(v),C=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:E,signal:b.signal});if(!C.ok||!C.body){let _=`HTTP ${C.status}`,z;try{z=await C.json(),z&&typeof z=="object"&&"error"in z&&typeof z.error=="string"&&(_=z.error)}catch{}throw Vy(C.status,z),new Error(_)}const w=C.body.getReader(),N=new TextDecoder;let T="",R="";for(;;){const{done:_,value:z}=await w.read();if(_)break;T+=N.decode(z,{stream:!0});const P=T.split(`
|
|
68
|
-
`);T=P.pop()||"";for(const k of P)if(k.startsWith("event: "))R=k.slice(7).trim();else if(k.startsWith("data: ")){try{const O=JSON.parse(k.slice(6)),L={event:R,data:O};a.current.onEvent(m,L)}catch{}R=""}}a.current.onDone(m)}catch(E){E.name!=="AbortError"&&a.current.onError(m,E.message)}finally{i(E=>{const C=new Set(E);return C.delete(m),C}),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()},[]),x=s.size>0;return{runningSet:s,startCase:u,stopCase:d,stopAll:h,isAnyCaseRunning:x}}const DC={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,activationPromptsSource:null,activationPromptsCanonical:"",savingTestCases:!1,savingTestCasesError:null,savingTestCasesSuccess:null,activationHistory:null,activationHistoryLoading:!1,loading:!0,error:null};function _C(t,a){var s,i;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=((i=(s=a.evals)==null?void 0:s.evals[0])==null?void 0:i.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":{const c=a.prompts===t.activationPromptsCanonical;return{...t,activationPrompts:a.prompts,activationPromptsSource:c?t.activationPromptsSource:t.activationPromptsSource===null||t.activationPromptsSource==="skill-md"||t.activationPromptsSource==="ai-generated"?"user-typed":t.activationPromptsSource}}case"SET_PROMPTS_SOURCE":return{...t,activationPromptsSource:a.source,activationPromptsCanonical:a.canonical??t.activationPromptsCanonical};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"SAVE_TEST_CASES_START":return{...t,savingTestCases:!0,savingTestCasesError:null,savingTestCasesSuccess:null};case"SAVE_TEST_CASES_SUCCESS":return{...t,savingTestCases:!1,savingTestCasesSuccess:`Saved ${a.count} test case${a.count===1?"":"s"} to SKILL.md`,activationPromptsSource:"skill-md",activationPromptsCanonical:t.activationPrompts};case"SAVE_TEST_CASES_ERROR":return{...t,savingTestCases:!1,savingTestCasesError:a.error};case"CLEAR_SAVE_TEST_CASES_FEEDBACK":return{...t,savingTestCasesSuccess:null,savingTestCasesError:null};case"ACTIVATION_HISTORY_LOADED":return{...t,activationHistory:a.runs,activationHistoryLoading:!1};default:return t}}function OC(t){if(t==="unit"||t==="integration")return t}function BC(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 i={assertion_id:s.assertion_id,text:s.text,pass:s.pass,reasoning:s.reasoning};t.assertions.find(c=>c.assertion_id===i.assertion_id)||t.assertions.push(i)}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 Gy=p.createContext(null);function Un(){const t=p.useContext(Gy);if(!t)throw new Error("useWorkspace must be used within WorkspaceProvider");return t}function IC({plugin:t,skill:a,origin:s,children:i}){const c=s==="installed",[u,d]=p.useReducer(_C,{...DC,plugin:t,skill:a}),h=p.useRef(new Set),x=p.useRef(new Set),m=p.useRef(new Map),y=p.useCallback((se,de)=>{let me=m.current.get(se);me||(me={assertions:[]},m.current.set(se,me)),BC(me,de),d({type:"UPDATE_INLINE_RESULT",evalId:se,result:{...me,assertions:[...me.assertions]}})},[]),v=p.useCallback(se=>{if(x.current.has(se))return;x.current.add(se);const de=m.current.get(se)??{assertions:[]};d({type:"CASE_RUN_COMPLETE",caseId:se,result:{...de,assertions:[...de.assertions]}}),h.current.has(se)&&(h.current.delete(se),h.current.size===0&&ke.getLatestBenchmark(t,a).then(me=>d({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null})))},[t,a]),b=p.useCallback((se,de)=>{x.current.has(se)||(x.current.add(se),d({type:"CASE_RUN_ERROR",caseId:se,error:de}),h.current.has(se)&&(h.current.delete(se),h.current.size===0&&ke.getLatestBenchmark(t,a).then(me=>d({type:"BULK_RUN_COMPLETE",benchmark:me})).catch(()=>d({type:"BULK_RUN_COMPLETE",benchmark:null}))))},[t,a]),{startCase:S,stopCase:E,stopAll:C}=zC({onEvent:y,onDone:v,onError:b});p.useEffect(()=>()=>{C()},[C]);const w=p.useCallback(async()=>{try{const se=await fetch(`/api/skills/${t}/${a}/activation-history`);if(!se.ok){if(se.status===404){d({type:"ACTIVATION_HISTORY_LOADED",runs:[]});return}return}const de=await se.json();d({type:"ACTIVATION_HISTORY_LOADED",runs:de.runs||[]})}catch{}},[t,a]);p.useEffect(()=>{let se=!1;async function de(){try{const[me,ve,je]=await Promise.allSettled([ke.getSkillDetail(t,a),ke.getEvals(t,a),ke.getLatestBenchmark(t,a)]);if(se)return;let Ve=null,ct=null;if(ve.status==="fulfilled")Ve=ve.value;else{const Nt=ve.reason;ct=(Nt==null?void 0:Nt.message)??"Failed to load test cases"}d({type:"INIT_DATA",skillContent:me.status==="fulfilled"?me.value.skillContent:"",evals:Ve,evalsError:ct,benchmark:je.status==="fulfilled"?je.value:null})}catch(me){se||d({type:"SET_ERROR",error:me.message})}}return de(),w(),()=>{se=!0}},[t,a,w]);const N=p.useCallback(async se=>{if(c)return;const de=se??u.skillContent;try{await ke.applyImprovement(t,a,de),se!==void 0&&se!==u.skillContent&&d({type:"SET_CONTENT",content:se}),d({type:"CONTENT_SAVED"})}catch(me){d({type:"SET_ERROR",error:me.message})}},[c,t,a,u.skillContent]),T=p.useCallback(async se=>{if(!c)try{const de=await ke.saveEvals(t,a,se);d({type:"SET_EVALS",evals:de})}catch(de){d({type:"SET_ERROR",error:de.message})}},[c,t,a]),R=p.useCallback((se,de="benchmark")=>{if(c)return;const me=u.caseRunStates.get(se);if((me==null?void 0:me.status)!=="running")if(m.current.delete(se),x.current.delete(se),d({type:"CASE_RUN_START",caseId:se,mode:de}),de==="comparison"){const ve=`/api/skills/${t}/${a}/compare`;S(se,ve,{eval_ids:[se]})}else{const ve=`/api/skills/${t}/${a}/benchmark/case/${se}`;S(se,ve,de==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.caseRunStates,S]),_=p.useCallback((se="benchmark")=>{var ve;if(c)return;const de=((ve=u.evals)==null?void 0:ve.evals)??[];if(de.length===0)return;const me=de.map(je=>je.id);for(const je of me)m.current.delete(je),x.current.delete(je);d({type:"BULK_RUN_START",caseIds:me,mode:se}),h.current=new Set(me);for(const je of me)if(se==="comparison")S(je,`/api/skills/${t}/${a}/compare`,{eval_ids:[je]});else{const Ve=`/api/skills/${t}/${a}/benchmark/case/${je}`;S(je,Ve,se==="baseline"?{baseline_only:!0}:void 0)}},[c,t,a,u.evals,S]),z=p.useCallback(se=>{E(se),d({type:"CASE_RUN_CANCEL",caseId:se}),h.current.delete(se),x.current.add(se)},[E]),P=p.useCallback(()=>{C(),d({type:"CANCEL_ALL"}),h.current.clear()},[C]),k=p.useCallback(async(se,de)=>{d({type:"OPEN_IMPROVE",evalId:se})},[]),O=p.useCallback(async(se,de)=>{try{await ke.applyImprovement(t,a,de),d({type:"SET_CONTENT",content:de}),d({type:"CONTENT_SAVED"}),d({type:"CLOSE_IMPROVE"}),R(se,"benchmark")}catch(me){d({type:"SET_ERROR",error:me.message})}},[t,a,R]),L=Ud(),B=p.useRef(null),U=p.useRef(0);p.useEffect(()=>{const se=L.events;for(let de=U.current;de<se.length;de++){const me=se[de],ve=me.data;if(me.event==="progress"&&d({type:"AI_EDIT_PROGRESS",entry:{timestamp:Date.now(),phase:ve.phase,message:ve.message}}),me.event==="done"){const je=ve.improved,Ve=ve.reasoning,ct=ve.evalChanges??[];d({type:"AI_EDIT_RESULT",improved:je,reasoning:Ve,evalChanges:ct})}if(me.event==="error"){const je=ve;d({type:"AI_EDIT_ERROR",message:je.description||"Unknown error",classified:je})}}U.current=se.length},[L.events]),p.useEffect(()=>{L.error&&d({type:"AI_EDIT_ERROR",message:L.error})},[L.error]),p.useEffect(()=>()=>{L.stop()},[L.stop]);const Y=p.useCallback(async(se,de,me)=>{c||(U.current=0,d({type:"AI_EDIT_LOADING"}),B.current=L.stop,L.start(`/api/skills/${t}/${a}/improve?sse`,{mode:"instruct",instruction:se,content:u.skillContent,evals:u.evals??{skill_name:a,evals:[]},provider:de,model:me}))},[c,t,a,u.skillContent,u.evals,L]),X=p.useCallback(()=>{L.stop(),d({type:"AI_EDIT_ERROR",message:"Cancelled"})},[L]),J=p.useCallback(async()=>{const se=u.aiEditResult;if(se!=null&&se.improved)try{if(await ke.applyImprovement(t,a,se.improved),d({type:"SET_CONTENT",content:se.improved}),d({type:"CONTENT_SAVED"}),u.aiEditEvalChanges.length>0&&Array.from(u.aiEditEvalSelections.values()).some(Boolean)){const{mergeEvalChanges:me}=await Pl(async()=>{const{mergeEvalChanges:Ve}=await import("./mergeEvalChanges-Dpbbs4d4.js");return{mergeEvalChanges:Ve}},[]),ve=u.evals??{skill_name:a,evals:[]},je=me(ve,u.aiEditEvalChanges,u.aiEditEvalSelections);try{const Ve=await ke.saveEvals(t,a,je);d({type:"SET_EVALS",evals:Ve})}catch(Ve){d({type:"SET_EVALS_RETRY",evalsFile:je}),d({type:"SET_ERROR",error:`SKILL.md saved, but test cases failed to save: ${Ve.message}. You can retry from the AI Edit panel.`});return}}d({type:"CLOSE_AI_EDIT"})}catch(de){d({type:"SET_ERROR",error:de.message})}},[t,a,u.aiEditResult,u.evals,u.aiEditEvalChanges,u.aiEditEvalSelections]),$=p.useCallback(()=>{d({type:"CLOSE_AI_EDIT"})},[]),M=p.useCallback(se=>{d({type:"TOGGLE_EVAL_CHANGE",index:se})},[]),I=p.useCallback(()=>{d({type:"SELECT_ALL_EVAL_CHANGES"})},[]),F=p.useCallback(()=>{d({type:"DESELECT_ALL_EVAL_CHANGES"})},[]),H=p.useCallback(async()=>{const se=u.aiEditEvalsRetry;if(se)try{const de=await ke.saveEvals(t,a,se);d({type:"SET_EVALS",evals:de}),d({type:"SET_ERROR",error:null}),d({type:"CLOSE_AI_EDIT"})}catch(de){d({type:"SET_ERROR",error:`Retry failed: ${de.message}`})}},[t,a,u.aiEditEvalsRetry]),re=p.useCallback(async()=>{try{const se=await ke.getSkillDetail(t,a);d({type:"SET_CONTENT",content:se.skillContent}),d({type:"CONTENT_SAVED"})}catch{}},[t,a]),{config:D}=Ya(),W=Ud(),te=p.useRef(0);p.useEffect(()=>{const se=W.events;for(let de=te.current;de<se.length;de++){const me=se[de],ve=me.data;if(me.event==="progress"&&d({type:"GENERATE_EVALS_PROGRESS",entry:{timestamp:Date.now(),phase:ve.phase,message:ve.message}}),me.event==="done"){const je=ve;ke.saveEvals(t,a,je).then(Ve=>d({type:"GENERATE_EVALS_DONE",evals:Ve})).catch(Ve=>d({type:"SET_ERROR",error:Ve.message}))}me.event==="error"&&d({type:"GENERATE_EVALS_ERROR",classified:ve})}te.current=se.length},[W.events,t,a]),p.useEffect(()=>{W.error&&d({type:"SET_ERROR",error:W.error})},[W.error]),p.useEffect(()=>()=>{W.stop()},[W.stop]);const q=p.useCallback(async se=>{if(c)return;te.current=0,d({type:"GENERATE_EVALS_START"});const de={};D!=null&&D.provider&&(de.provider=D.provider),D!=null&&D.model&&(de.model=D.model);const me=OC(se==null?void 0:se.testType);me&&(de.testType=me),W.start(`/api/skills/${t}/${a}/generate-evals?sse`,Object.keys(de).length>0?de:void 0)},[c,t,a,W,D]),ce=Ud(),Q=p.useRef(0);p.useEffect(()=>()=>{ce.stop()},[ce.stop]),p.useEffect(()=>{const se=ce.events;for(let de=Q.current;de<se.length;de++){const me=se[de];if(me.event==="classifying"){const ve=me.data;d({type:"ACTIVATION_CLASSIFYING",index:ve.index,total:ve.total})}if(me.event==="prompt_result"&&d({type:"ACTIVATION_RESULT",result:me.data}),me.event==="done"){ye.current&&(clearTimeout(ye.current),ye.current=null);const ve=me.data;if(ve.error)d({type:"ACTIVATION_ERROR",error:ve.error});else{d({type:"ACTIVATION_DONE",summary:ve});const je={id:`run-${Date.now()}`,timestamp:new Date().toISOString(),model:(D==null?void 0:D.model)||"unknown",provider:(D==null?void 0:D.provider)||"unknown",promptCount:ve.total,summary:{precision:ve.precision,recall:ve.recall,reliability:ve.reliability,tp:ve.tp,tn:ve.tn,fp:ve.fp,fn:ve.fn}};d({type:"ACTIVATION_HISTORY_LOADED",runs:[je,...u.activationHistory??[]]})}}}Q.current=se.length},[ce.events,D,u.activationHistory]),p.useEffect(()=>{ce.error&&(ye.current&&(clearTimeout(ye.current),ye.current=null),d({type:"ACTIVATION_ERROR",error:ce.error}))},[ce.error]);const ye=p.useRef(null),oe=p.useCallback(()=>{ye.current&&(clearTimeout(ye.current),ye.current=null),ce.stop(),d({type:"ACTIVATION_CANCEL",totalPrompts:0})},[ce]),be=p.useCallback(se=>{const me=se.trim().split(`
|
|
69
|
-
`).filter(Boolean).map(je=>je.startsWith("!")?{prompt:je.slice(1).trim(),expected:"should_not_activate"}:je.startsWith("+")?{prompt:je.slice(1).trim(),expected:"should_activate"}:{prompt:je.trim(),expected:"auto"});Q.current=0,d({type:"ACTIVATION_START"}),d({type:"SET_ACTIVATION_PROMPTS",prompts:se});const ve={prompts:me};D!=null&&D.provider&&(ve.provider=D.provider),D!=null&&D.model&&(ve.model=D.model),ce.start(`/api/skills/${t}/${a}/activation-test`,ve),ye.current&&clearTimeout(ye.current),ye.current=setTimeout(()=>{ce.stop(),d({type:"ACTIVATION_TIMEOUT"}),ye.current=null},12e4)},[t,a,ce,D]),Ne=p.useCallback(async(se=8)=>{d({type:"GENERATE_PROMPTS_START"});try{const de={count:se};D!=null&&D.provider&&(de.provider=D.provider),D!=null&&D.model&&(de.model=D.model);const me=await fetch(`/api/skills/${t}/${a}/activation-prompts`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(de)});if(!me.ok){let bt=`HTTP ${me.status}`;try{const Ge=await me.json();Ge.error&&(bt=Ge.error)}catch{}throw new Error(bt)}const ve=me.body.getReader(),je=new TextDecoder;let Ve="",ct="",Nt=[];for(;;){const{done:bt,value:Ge}=await ve.read();if(bt)break;Ve+=je.decode(Ge,{stream:!0});const pt=Ve.split(`
|
|
70
|
-
`);Ve=pt.pop()||"";for(const mt of pt)if(mt.startsWith("event: "))ct=mt.slice(7).trim();else if(mt.startsWith("data: ")){try{const jt=JSON.parse(mt.slice(6));if(ct==="done"){if(jt.error)throw new Error(jt.error);Nt=jt.prompts||[]}if(ct==="error")throw new Error(jt.message||jt.description||"Generation failed")}catch(jt){if(!(jt instanceof SyntaxError))throw jt}ct=""}}const tn=Nt.map(bt=>`${bt.expected==="should_activate"?"+":"!"}${bt.prompt}`).join(`
|
|
71
|
-
`);d({type:"SET_PROMPTS_SOURCE",source:"ai-generated",canonical:tn}),d({type:"SET_ACTIVATION_PROMPTS",prompts:tn}),d({type:"GENERATE_PROMPTS_DONE"})}catch(de){d({type:"GENERATE_PROMPTS_ERROR",error:de.message})}},[t,a,D]),Be=p.useCallback(async()=>{try{const se=await fetch(`/api/skills/${t}/${a}/test-cases`);if(!se.ok)return;const de=await se.json();if(!de.prompts||de.prompts.length===0)return;const me=de.prompts.map(ve=>ve.expected==="should_activate"?`+${ve.prompt}`:ve.expected==="should_not_activate"?`!${ve.prompt}`:ve.prompt).join(`
|
|
72
|
-
`);d({type:"SET_PROMPTS_SOURCE",source:"skill-md",canonical:me}),d({type:"SET_ACTIVATION_PROMPTS",prompts:me})}catch{}},[t,a]),Le=p.useCallback(async()=>{d({type:"SAVE_TEST_CASES_START"});try{const de=u.activationPrompts.split(`
|
|
73
|
-
`).map(je=>je.trim()).filter(Boolean).map(je=>je.startsWith("!")?{prompt:je.slice(1).trim(),expected:"should_not_activate"}:je.startsWith("+")?{prompt:je.slice(1).trim(),expected:"should_activate"}:{prompt:je,expected:"auto"}),me=await fetch(`/api/skills/${t}/${a}/test-cases`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompts:de})}),ve=await me.json().catch(()=>({}));if(!me.ok||!ve.ok)throw new Error(ve.error||`HTTP ${me.status}`);d({type:"SAVE_TEST_CASES_SUCCESS",count:ve.count??de.length}),setTimeout(()=>d({type:"CLEAR_SAVE_TEST_CASES_FEEDBACK"}),3e3)}catch(se){d({type:"SAVE_TEST_CASES_ERROR",error:se.message})}},[t,a,u.activationPrompts]),Pe=p.useMemo(()=>({state:u,dispatch:d,isReadOnly:c,saveContent:N,saveEvals:T,runCase:R,runAll:_,cancelCase:z,cancelAll:P,improveForCase:k,applyImproveAndRerun:O,refreshSkillContent:re,generateEvals:q,runActivationTest:be,cancelActivation:oe,generateActivationPrompts:Ne,fetchActivationHistory:w,loadTestCasesFromSkillMd:Be,saveTestCasesToSkillMd:Le,submitAiEdit:Y,cancelAiEdit:X,applyAiEdit:J,discardAiEdit:$,toggleEvalChange:M,selectAllEvalChanges:I,deselectAllEvalChanges:F,retryEvalsSave:H}),[u,c,N,T,R,_,z,P,k,O,re,q,be,oe,Ne,w,Be,Le,Y,X,J,$,M,I,F,H]);return r.jsx(Gy.Provider,{value:Pe,children:i})}function $C(t){if(!t)return[];const a=t.split(`
|
|
74
|
-
`),s=[];for(const i of a)if(!(i.startsWith("--- ")||i.startsWith("+++ "))){if(i.startsWith("@@")){s.push({type:"header",content:i});continue}if(i.startsWith("+")){s.push({type:"add",content:i.slice(1)});continue}if(i.startsWith("-")){s.push({type:"remove",content:i.slice(1)});continue}(i.startsWith(" ")||i===""&&s.length>0)&&s.push({type:"context",content:i.startsWith(" ")?i.slice(1):""})}return s}function Wf({contentDiff:t,fromLabel:a,toLabel:s,diffSummary:i,maxHeight:c=480,collapsible:u=!1,renderContext:d="inline",onRetry:h}){const[x,m]=p.useState(u),[y,v]=p.useState("unified"),b=p.useRef(null),S=p.useRef(null),E=p.useMemo(()=>$C(t),[t]),C=p.useMemo(()=>{const z=E.filter(k=>k.type==="add").length,P=E.filter(k=>k.type==="remove").length;return{added:z,removed:P}},[E]),w=p.useMemo(()=>{let z=0,P=0;return E.filter(k=>k.type!=="header").map(k=>k.type==="remove"?(z++,{...k,origNum:z,newNum:null}):k.type==="add"?(P++,{...k,origNum:null,newNum:P}):(z++,P++,{...k,origNum:z,newNum:P}))},[E]),N=p.useMemo(()=>{const z=[],P=[];for(const k of w)if(k.type==="remove")z.push(k);else if(k.type==="add")P.push(k);else{for(;z.length<P.length;)z.push({type:"context",content:"",origNum:null,newNum:null});for(;P.length<z.length;)P.push({type:"context",content:"",origNum:null,newNum:null});z.push(k),P.push(k)}for(;z.length<P.length;)z.push({type:"context",content:"",origNum:null,newNum:null});for(;P.length<z.length;)P.push({type:"context",content:"",origNum:null,newNum:null});return{left:z,right:P}},[w]),T=p.useCallback(z=>{const P=z==="left"?b.current:S.current,k=z==="left"?S.current:b.current;P&&k&&(k.scrollTop=P.scrollTop)},[]);if(!t||E.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 R=d==="modal"?"fixed inset-0 z-50 flex items-center justify-center bg-black/50":"",_=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:["+",C.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",C.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(!x),className:"btn btn-ghost text-[11px]",children:x?"Expand":"Collapse"})]})]}),i&&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:i}),!x&&(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:w.map((z,P)=>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||""})]},P))})})}):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,P)=>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||""})]},P))})})}),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,P)=>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||""})]},P))})})})]}))]});return d==="modal"?r.jsx("div",{className:R,children:r.jsx("div",{style:{width:"80%",maxWidth:900},children:_})}):_}const Hd="https://verified-skill.com/submit",UC=/^https:\/\/github\.com\/[^/?#@:]+\/[^/?#@:]+(?:[/?#].*)?$/;function HC(t){if(!t)return Hd;const a=t.trim();return!a||!UC.test(a)?Hd:`${Hd}?repo=${encodeURIComponent(a)}`}const PC={sm:{icon:12,fontSize:"0.625rem",gap:"0.25rem",px:"0.375rem",py:"0.125rem",height:"18px",radius:"3px"},md:{icon:14,fontSize:"0.6875rem",gap:"0.3rem",px:"0.5rem",py:"0.15rem",height:"22px",radius:"4px"},lg:{icon:16,fontSize:"0.75rem",gap:"0.375rem",px:"0.625rem",py:"0.2rem",height:"26px",radius:"4px"}};function VC({size:t}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[r.jsx("path",{d:"M10 1L3 4.5V9.5C3 13.64 5.99 17.52 10 18.5C14.01 17.52 17 13.64 17 9.5V4.5L10 1Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),r.jsx("path",{d:"M7.5 10.5L9.5 12.5L13 8",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}function FC({size:t}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[r.jsx("path",{d:"M10 1L11.9 4.1L15.5 3.5L14.2 7L17 9.5L14.2 12L15.5 15.5L11.9 14.9L10 18L8.1 14.9L4.5 15.5L5.8 12L3 9.5L5.8 7L4.5 3.5L8.1 4.1L10 1Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.1",strokeLinejoin:"round"}),r.jsx("path",{d:"M10 6.5L10.9 8.6L13.1 8.8L11.4 10.3L11.9 12.5L10 11.3L8.1 12.5L8.6 10.3L6.9 8.8L9.1 8.6L10 6.5Z",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.4",strokeLinejoin:"round"})]})}const Gg={VERIFIED:{color:"var(--tier-verified)",bg:"var(--tier-verified-bg)",border:"var(--tier-verified-border)"},CERTIFIED:{color:"var(--tier-certified)",bg:"var(--tier-certified-bg)",border:"var(--tier-certified-border)"},TAINTED:{color:"var(--tier-tainted)",bg:"var(--tier-tainted-bg)",border:"var(--tier-tainted-border)"}},GC={VERIFIED:"Security-Scanned",CERTIFIED:"Trusted Publisher",TAINTED:"Tainted"};function Wy(t){return GC[t]??t}function WC({size:t}){return r.jsxs("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[r.jsx("path",{d:"M10 2L1.5 17.5H18.5L10 2Z",fill:"currentColor",fillOpacity:"0.15",stroke:"currentColor",strokeWidth:"1.2",strokeLinejoin:"round"}),r.jsx("path",{d:"M10 8V12",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),r.jsx("circle",{cx:"10",cy:"14.5",r:"1",fill:"currentColor"})]})}function qC({tier:t,size:a}){return t==="TAINTED"?r.jsx(WC,{size:a}):t==="CERTIFIED"?r.jsx(FC,{size:a}):r.jsx(VC,{size:a})}function KR({tier:t,size:a="md",isTainted:s}){const i=PC[a],c=s?"TAINTED":t,u=Gg[c]??Gg.VERIFIED;return r.jsxs("span",{"data-testid":"tier-badge","data-tier":c,style:{display:"inline-flex",alignItems:"center",gap:i.gap,padding:`${i.py} ${i.px}`,height:i.height,borderRadius:i.radius,fontFamily:"var(--font-geist-mono)",fontSize:i.fontSize,fontWeight:600,letterSpacing:"0.03em",whiteSpace:"nowrap",color:u.color,backgroundColor:u.bg,border:`1px solid ${u.border}`,lineHeight:1},children:[r.jsx(qC,{tier:c,size:i.icon}),Wy(c)]})}const Wg={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 YC(t,a){return t?t.length>a?t.slice(0,a)+"…":t:""}function KC(t){if(!t)return"";const a=t.trim();if(!a)return"";const s=a.toLowerCase();return s==="0 files"||s==="no files"||s==="no file changes"?"Metadata-only release — no file changes":a}function XC(){const{state:t}=Un(),{plugin:a,skill:s}=t,i=cr(),{onSkillUpdated:c,updateCount:u}=i,d=p.useMemo(()=>i.state.skills.find(M=>M.plugin===a&&M.skill===s)??null,[i.state.skills,a,s]),h=`versions/${a}/${s}`,x=p.useCallback(()=>ke.getSkillVersions(a,s),[a,s]),{data:m,loading:y}=qa(h,x),[v,b]=p.useState(null),[S,E]=p.useState(null),[C,w]=p.useState(null),[N,T]=p.useState(!1),[R,_]=p.useState("idle"),[z,P]=p.useState(null),k=p.useRef(null),O=p.useRef(null),L=p.useMemo(()=>(m==null?void 0:m.find(M=>M.isInstalled))??null,[m]),B=p.useMemo(()=>(m==null?void 0:m[0])??null,[m]),U=L&&B&&L.version!==B.version,Y=p.useCallback(M=>{v?!S&&M!==v?E(M):(b(M),E(null),w(null)):(b(M),w(null))},[v,S]),X=p.useCallback(async(M,I)=>{T(!0);try{const F=await ke.getVersionDiff(a,s,M,I);w(F)}catch{w(null)}finally{T(!1)}},[a,s]);p.useEffect(()=>{if(v&&S){const M=m||[],I=M.findIndex(D=>D.version===v),F=M.findIndex(D=>D.version===S),[H,re]=I>F?[v,S]:[S,v];X(H,re)}},[v,S,m,X]);const J=p.useCallback(()=>{!L||!B||(b(L.version),E(B.version))},[L,B]),$=p.useCallback(async()=>{_("updating"),P(null);const M=new AbortController;k.current=M;try{const I=await ke.postSkillUpdate(a,s,M.signal);if(I.ok)_("done"),c(a,s);else{const F=`Update failed (HTTP ${I.status}): ${I.body||"no response body"}`;_("error"),P(F)}}catch(I){if(I instanceof DOMException&&I.name==="AbortError")return;const F=I instanceof Error?I.message:"Network error";_("error"),P(F)}finally{k.current===M&&(k.current=null)}},[a,s,c]);if(p.useEffect(()=>()=>{var M;(M=k.current)==null||M.abort(),k.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 I=HC((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:I,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:[U&&r.jsx("button",{onClick:J,className:"btn btn-secondary text-[11px]",children:"View changes since installed"}),U&&R!=="done"&&(R==="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:R!=="idle",className:"btn btn-primary text-[11px]",children:R==="idle"?`Update to ${B==null?void 0:B.version}`:R==="updating"?"Starting update...":R==="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(M=>{const I=Wg[M.certTier]||Wg.COMMUNITY,F=M.version===v||M.version===S,H=M.isInstalled;return r.jsxs("button",{onClick:()=>Y(M.version),className:"w-full text-left pl-8 pr-4 py-3 relative rounded-lg transition-all duration-150",style:{background:F?"var(--accent-muted)":"transparent",border:F?"1px solid var(--accent)":"1px solid transparent",cursor:"pointer"},onMouseEnter:re=>{F||(re.currentTarget.style.background="var(--surface-1)")},onMouseLeave:re=>{F||(re.currentTarget.style.background="transparent")},children:[r.jsx("span",{className:"absolute left-1.5 top-4 rounded-full",style:{width:H?10:8,height:H?10:8,background:H?"var(--accent)":"var(--surface-3)",border:H?"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:M.version}),r.jsx("span",{className:"text-[9px] font-medium px-1.5 py-0.5 rounded-full",style:{background:I.bg,color:I.text},children:Wy(M.certTier)}),H&&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(M.createdAt).toLocaleDateString()})]}),(()=>{const re=KC(M.diffSummary);return re?r.jsx("div",{"data-testid":"version-row-diff-summary",className:"text-[11px] mt-1",style:{color:"var(--text-tertiary)"},children:YC(re,80)}):null})()]},M.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"})}),C&&!N&&r.jsx("div",{className:"mt-4",children:r.jsx(Wf,{contentDiff:C.contentDiff,fromLabel:C.from,toLabel:C.to,diffSummary:C.diffSummary,renderContext:"inline",onRetry:()=>v&&S&&X(C.from,C.to)})})]})}function QC(t){const a=t.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);if(!a)return{metadata:{},body:t};const s=a[1],i=a[2].trim(),c={},u=s.split(`
|
|
75
|
-
`);let d="",h=!1;for(const x of u){const m=x.match(/^[ \t]+([\w-]+):\s*(.*)$/);if(m&&d&&h){const b=m[1],S=m[2].trim();let E=c[d];if((typeof E!="object"||Array.isArray(E))&&(E={},c[d]=E),!S)E[b]=[];else{const C=S.match(/^\[(.+)\]$/);C?E[b]=C[1].split(",").map(w=>w.trim().replace(/^["']|["']$/g,"")).filter(Boolean):E[b]=S.replace(/^["']|["']$/g,"")}continue}const y=x.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=x.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(E=>E.trim().replace(/^["']|["']$/g,"")).filter(Boolean);continue}c[d]=b.replace(/^["']|["']$/g,"")}}return{metadata:c,body:i}}function oc(t){if(!t)return"";try{let a=t.replace(/^---\n[\s\S]*?\n---\n?/,""),s=ZC(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,"&").replace(/</g,"<").replace(/>/g,">")}</pre>`}}function ZC(t){const a=t.split(`
|
|
76
|
-
`),s=[];let i=0;for(;i<a.length;)if(a[i].trim().startsWith("|")&&i+1<a.length&&a[i+1].trim().startsWith("|")&&/\|[\s-:]+\|/.test(a[i+1])){const c=qg(a[i]);i+=2;const u=[];for(;i<a.length&&a[i].trim().startsWith("|");)u.push(qg(a[i])),i++;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 x='<table style="width:100%;border-collapse:collapse;margin:0.5rem 0;border:1px solid var(--border-subtle);border-radius:6px;overflow:hidden">';x+="<thead><tr>";for(const m of c)x+=`<th ${d}>${m}</th>`;x+="</tr></thead><tbody>";for(const m of u){x+="<tr>";for(const y of m)x+=`<td ${h}>${y}</td>`;x+="</tr>"}x+="</tbody></table>",s.push(x)}else s.push(a[i]),i++;return s.join(`
|
|
77
|
-
`)}function qg(t){return t.split("|").map(a=>a.trim()).filter(a=>a.length>0)}function cc(t,a){const s=t.split(`
|
|
78
|
-
`),i=a.split(`
|
|
79
|
-
`);if(s.length>1e3||i.length>1e3)return[...s.map(y=>({type:"unchanged",content:y}))];const c=s.length,u=i.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]===i[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 x=c,m=u;for(;x>0||m>0;)x>0&&m>0&&s[x-1]===i[m-1]?(h.push({type:"unchanged",content:s[x-1]}),x--,m--):m>0&&(x===0||d[x][m-1]>=d[x-1][m])?(h.push({type:"added",content:i[m-1]}),m--):(h.push({type:"removed",content:s[x-1]}),x--);return h.reverse()}function JC(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 i=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:i.has(t)?"var(--accent)":"var(--green)"}})}function ui({entries:t,isRunning:a}){const[s,i]=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:()=>i(!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,x=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:[JC(u.phase,h),r.jsx("span",{className:"font-mono flex-shrink-0",style:{color:"var(--text-tertiary)",width:40},children:x}),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 Yg={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 uc({error:t,onRetry:a,onDismiss:s}){const[i,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(!(i==null||i<=0))return u.current=setInterval(()=>{c(x=>x==null||x<=1?(u.current&&clearInterval(u.current),0):x-1)},1e3),()=>{u.current&&clearInterval(u.current)}},[i!=null&&i>0]);const d=Yg[t.category]||Yg.unknown,h=i!=null&&i>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||i!=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 ${i}s`:"Retry"})})]})]})}function eE({plugin:t,skill:a,skillContent:s,onApplied:i}){const[c,u]=p.useState("closed"),{config:d}=Ya(),[h,x]=p.useState("claude-cli"),[m,y]=p.useState("opus"),[v,b]=p.useState([]),[S,E]=p.useState(""),[C,w]=p.useState(""),[N,T]=p.useState(null),[R,_]=p.useState(null),[z,P]=p.useState([]),[k,O]=p.useState(!1),L=p.useRef(null);p.useEffect(()=>{if(!d)return;d.providers.find(I=>I.id==="claude-cli"&&I.available)&&(x("claude-cli"),y("opus"))},[d]),p.useEffect(()=>()=>{var M;(M=L.current)==null||M.abort()},[]);function B(){return d==null?void 0:d.providers.find(M=>M.id===h&&M.available)}const U=p.useCallback(()=>{var M;(M=L.current)==null||M.abort(),u("open")},[]);async function Y(){u("loading"),T(null),_(null),P([]);const M=new AbortController;L.current=M;try{const I=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:M.signal});if(!I.ok||!I.body){let W=`HTTP ${I.status}`;try{const te=await I.json();te.error&&(W=te.error)}catch{}throw new Error(W)}const F=I.body.getReader(),H=new TextDecoder;let re="",D="";for(;;){const{done:W,value:te}=await F.read();if(W)break;re+=H.decode(te,{stream:!0});const q=re.split(`
|
|
80
|
-
`);re=q.pop()||"";for(const ce of q)if(ce.startsWith("event: "))D=ce.slice(7).trim();else if(ce.startsWith("data: ")){try{const Q=JSON.parse(ce.slice(6));D==="progress"?P(ye=>[...ye,{phase:Q.phase,message:Q.message,timestamp:Date.now()}]):D==="done"||D==="complete"?(E(Q.improved),w(Q.reasoning||""),b(cc(Q.original||s,Q.improved)),u("diff_shown")):D==="error"&&(T(Q.message||Q.description||"Unknown error"),Q.category&&_(Q),u("open"))}catch{}D=""}}}catch(I){I.name!=="AbortError"&&(T(I.message),u("open"))}finally{L.current=null}}async function X(){O(!0);try{await ke.applyImprovement(t,a,S),i(S),u("closed")}catch(M){T(M.message)}finally{O(!1)}}function J(){u("closed"),b([]),E(""),w(""),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 $=B();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:M=>{M.currentTarget.style.background="var(--surface-3)"},onMouseLeave:M=>{M.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:M=>{x(M.target.value);const I=d==null?void 0:d.providers.find(F=>F.id===M.target.value);I!=null&&I.models[0]&&y(I.models[0].id)},disabled:c==="loading",children:d==null?void 0:d.providers.filter(M=>M.available).map(M=>r.jsx("option",{value:M.id,children:M.label},M.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:M=>y(M.target.value),disabled:c==="loading",children:$==null?void 0:$.models.map(M=>r.jsx("option",{value:M.id,children:M.label},M.id))})]}),c==="loading"?r.jsx("button",{onClick:U,className:"btn btn-secondary flex-shrink-0",children:"Cancel"}):r.jsx("button",{onClick:Y,className:"btn btn-primary flex-shrink-0",children:"Improve"})]}),c==="loading"&&z.length>0&&r.jsx("div",{className:"mt-3",children:r.jsx(ui,{entries:z,isRunning:!0})})]}),N&&r.jsx("div",{className:"mb-4",children:R?r.jsx(uc,{error:R,onRetry:Y,onDismiss:()=>{T(null),_(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:[C&&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: "}),C]}),r.jsx("div",{className:"rounded-lg overflow-hidden mb-4",style:{border:"1px solid var(--border-subtle)",maxHeight:"400px",overflowY:"auto"},children:v.map((M,I)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:M.type==="added"?"rgba(34,197,94,0.1)":M.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:M.type==="added"?"var(--green)":M.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:M.type==="added"?"3px solid var(--green)":M.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:M.type==="added"?"+":M.type==="removed"?"-":" "}),M.content]},I))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("button",{onClick:X,disabled:k,className:"btn btn-primary",children:k?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 Kg={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"}},tE={remove:"var(--red)",modify:"#fbbf24",add:"var(--green)"};function nE({change:t,index:a,selected:s,onToggle:i,originalEval:c}){var v;const[u,d]=p.useState(!1),h=Kg[t.action]??Kg.add,x=tE[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(()=>i(a),[i,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 ${x}`,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(rE,{evalCase:t.eval}),t.action==="modify"&&t.eval&&c&&r.jsx(aE,{original:c,proposed:t.eval}),t.action==="remove"&&c&&r.jsx(lE,{evalCase:c})]})]})}function rE({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",children:[r.jsx(vf,{label:"Prompt",value:t.prompt}),r.jsx(vf,{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 aE({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 i=t.assertions??[],c=a.assertions??[],u=new Set(i.map(m=>m.text)),d=new Set(c.map(m=>m.text)),h=c.filter(m=>!u.has(m.text)),x=i.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:["- ",yf(m.old,120)]}),r.jsxs("div",{style:{color:"var(--green)"},children:["+ ",yf(m.new,120)]})]})]},m.label)),(h.length>0||x.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:[x.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&&x.length===0&&r.jsx("div",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:"No visible field changes"})]})}function lE({evalCase:t}){var a;return r.jsxs("div",{className:"pt-2.5 space-y-2",style:{opacity:.7},children:[r.jsx(vf,{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 vf({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:yf(a,300)})]})}function yf(t,a){return t.length>a?t.slice(0,a)+"...":t}const Xg={remove:0,modify:1,add:2};function sE({changes:t,selections:a,currentEvals:s,onToggle:i,onSelectAll:c,onDeselectAll:u}){if(t.length===0)return null;const d=t.map((x,m)=>({change:x,originalIndex:m}));d.sort((x,m)=>(Xg[x.change.action]??2)-(Xg[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:x=>{x.currentTarget.style.background="var(--accent-muted)"},onMouseLeave:x=>{x.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:x=>{x.currentTarget.style.background="var(--surface-3)"},onMouseLeave:x=>{x.currentTarget.style.background="transparent"},children:"Deselect All"})]})]}),r.jsx("div",{className:"space-y-1.5 overflow-auto",style:{maxHeight:240},children:d.map(({change:x,originalIndex:m})=>r.jsx(nE,{change:x,index:m,selected:a.get(m)??!1,onToggle:i,originalEval:x.evalId!=null?s.find(y=>y.id===x.evalId):void 0},m))})]})}function iE(){var M;const{state:t,dispatch:a,submitAiEdit:s,applyAiEdit:i,discardAiEdit:c,cancelAiEdit:u,toggleEvalChange:d,selectAllEvalChanges:h,deselectAllEvalChanges:x,retryEvalsSave:m}=Un(),{aiEditLoading:y,aiEditResult:v,aiEditError:b,aiEditClassifiedError:S,aiEditProgress:E,aiEditEvalChanges:C,aiEditEvalSelections:w,aiEditEvalsRetry:N}=t,[T,R]=p.useState(""),{config:_}=Ya(),[z,P]=p.useState("claude-cli"),[k,O]=p.useState("opus"),L=p.useRef(null);p.useEffect(()=>{var I;(I=L.current)==null||I.focus()},[]),p.useEffect(()=>{if(!_)return;_.providers.find(F=>F.id==="claude-cli"&&F.available)&&(P("claude-cli"),O("opus"))},[_]);const B=_==null?void 0:_.providers.find(I=>I.id===z&&I.available),U=p.useCallback(()=>{const I=T.trim();!I||y||s(I,z,k)},[T,y,s,z,k]),Y=p.useCallback(I=>{I.key==="Enter"&&!I.shiftKey&&(I.preventDefault(),U()),I.key==="Escape"&&(I.preventDefault(),y?u():c())},[U,y,u,c]),X=p.useCallback(()=>{a({type:"CLOSE_AI_EDIT"}),a({type:"OPEN_AI_EDIT"})},[a]),J=v?cc(t.skillContent,v.improved):[],$=((M=t.evals)==null?void 0:M.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:I=>{I.currentTarget.style.background="var(--surface-3)"},onMouseLeave:I=>{I.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:L,value:T,onChange:I=>R(I.target.value),onKeyDown:Y,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:I=>{P(I.target.value);const F=_==null?void 0:_.providers.find(H=>H.id===I.target.value);F!=null&&F.models[0]&&O(F.models[0].id)},disabled:y,style:{width:"100%"},children:_==null?void 0:_.providers.filter(I=>I.available).map(I=>r.jsx("option",{value:I.id,children:I.label},I.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:k,onChange:I=>O(I.target.value),disabled:y,style:{width:"100%"},children:B==null?void 0:B.models.map(I=>r.jsx("option",{value:I.id,children:I.label},I.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:U,disabled:!T.trim(),className:"btn btn-primary flex-shrink-0 text-[11px]",style:{padding:"6px 14px"},children:"Submit"})]}),y&&E.length>0&&r.jsx("div",{className:"mt-2.5",children:r.jsx(ui,{entries:E,isRunning:!0})})]}),b&&r.jsx("div",{className:"mt-3",children:S?r.jsx(uc,{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,F)=>r.jsxs("div",{className:"px-3 py-0.5 text-[10.5px] font-mono",style:{background:I.type==="added"?"rgba(34,197,94,0.1)":I.type==="removed"?"rgba(239,68,68,0.1)":"transparent",color:I.type==="added"?"var(--green)":I.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:I.type==="added"?"3px solid var(--green)":I.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:I.type==="added"?"+":I.type==="removed"?"-":" "}),I.content]},F))}),r.jsx(sE,{changes:C,selections:w,currentEvals:$,onToggle:d,onSelectAll:h,onDeselectAll:x}),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:i,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 oE(t,a){const[s,i]=p.useState([]),[c,u]=p.useState("SKILL.md"),[d,h]=p.useState(null),[x,m]=p.useState(!1),[y,v]=p.useState(null),[b,S]=p.useState(null),E=p.useCallback(async()=>{try{const N=await ke.getSkillFiles(t,a);i(N.files),S(null)}catch(N){i([]),S(N.message??"Unable to load skill files")}},[t,a]);p.useEffect(()=>{u("SKILL.md"),h(null),v(null),S(null),E()},[t,a,E]);const C=p.useCallback(async N=>{if(u(N),N==="SKILL.md"){h(null),v(null);return}m(!0),v(null);try{const T=await ke.getSkillFile(t,a,N);h(T)}catch(T){v(`Unable to open file: ${T.message}`),h(null)}finally{m(!1)}},[t,a]),w=p.useCallback(()=>{E()},[E]);return{files:s,activeFile:c,secondaryContent:d,loading:x,error:y,loadError:b,selectFile:C,refresh:w,isSkillMd:c==="SKILL.md"}}function cE(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function uE(t){const a=[],s=new Map;for(const i of t){const c=i.path.split("/"),d={name:c[c.length-1],path:i.path,type:i.type,size:i.size,children:[]};s.set(i.path,d)}for(const i of t){const c=i.path.split("/");if(c.length===1){const u=s.get(i.path);u&&a.push(u)}else{const u=c.slice(0,-1).join("/"),d=s.get(u),h=s.get(i.path);d&&h&&d.children.push(h)}}return a}function qy({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 Yy(){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 dE(){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 fE(){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 Ky({node:t,depth:a,activeFile:s,onSelect:i}){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(qy,{expanded:c}),r.jsx(Yy,{}),r.jsxs("span",{children:[t.name,"/"]})]}),c&&t.children.map(h=>r.jsx(Ky,{node:h,depth:a+1,activeFile:s,onSelect:i},h.path))]}):r.jsxs("button",{onClick:()=>i(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(dE,{}),r.jsx("span",{style:{flex:1},children:t.name}),r.jsx("span",{style:{fontSize:9,color:"var(--text-tertiary)",marginRight:4,whiteSpace:"nowrap"},children:cE(t.size)})]})}function pE({files:t,activeFile:a,onSelect:s,onRefresh:i,loadError:c}){const[u,d]=p.useState(!1),h=p.useMemo(()=>uE(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:()=>d(!u),children:[r.jsx(qy,{expanded:u}),r.jsx(Yy,{}),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:x=>{x.stopPropagation(),i()},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(fE,{})})]}),u&&r.jsx("div",{style:{maxHeight:240,overflowY:"auto",padding:"2px 4px 4px"},children:c?r.jsx("div",{style:{fontSize:11,color:"var(--text-warning, var(--text-tertiary))",padding:"4px 8px"},title:c,children:"Skill files not accessible from this workspace"}):h.length===0?r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",padding:"4px 8px"},children:"No files found"}):h.map(x=>r.jsx(Ky,{node:x,depth:0,activeFile:a,onSelect:s},x.path))})]})}function To(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function mE(t){try{return JSON.stringify(JSON.parse(t),null,2)}catch{return t}}function hE(t){const a=t.toLowerCase();return a.endsWith(".json")?"json":a.endsWith(".md")?"md":"other"}function Qg({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 Zg({content:t,fileType:a}){if(a==="json"){const s=mE(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:oc(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 Jg(t){try{return JSON.stringify(JSON.parse(t),null,2).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").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,i)=>`: <span style="color:#fb923c">${i}</span>`).replace(/:\s*(true|false|null)/g,(s,i)=>`: <span style="color:#a855f7">${i}</span>`)}catch{return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}}function xE({file:t,loading:a,error:s,viewMode:i,plugin:c,skill:u,onSaved:d,onDirtyChange:h}){const[x,m]=p.useState(i),[y,v]=p.useState(!1),[b,S]=p.useState(""),[E,C]=p.useState(!1),[w,N]=p.useState(null),T=i!==x?i:x;p.useEffect(()=>{h==null||h(y)},[y,h]);const R=p.useCallback(()=>{(t==null?void 0:t.content)!=null&&(S(t.content),v(!0))},[t]),_=p.useCallback(()=>{v(!1)},[]),z=p.useCallback(async()=>{if(!(!c||!u||!t)){C(!0);try{await ke.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{C(!1)}}},[c,u,t,b,d]);if(p.useEffect(()=>{if(!y)return;const O=L=>{(L.ctrlKey||L.metaKey)&&L.key==="s"&&(L.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 (",To(t.size),") — cannot be displayed"]});const P=t.content??"",k=hE(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 ",To(512*1024)," — ",To(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:[(k==="md"||k==="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:[To(t.size),c&&u&&!t.binary&&!y&&r.jsx("button",{onClick:R,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:E,style:{padding:"1px 6px",fontSize:10,background:"var(--accent)",color:"#fff",border:"none",borderRadius:3,cursor:"pointer",opacity:E?.6:1},children:E?"Saving...":"Save"}),r.jsx("button",{onClick:_,style:{padding:"1px 6px",fontSize:10,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:3,cursor:"pointer"},children:"Cancel"})]})]})]}),w&&r.jsx("div",{style:{padding:"4px 12px",background:w.startsWith("Save failed")?"var(--red-muted)":"var(--green-muted)",borderBottom:"1px solid var(--border-subtle)",fontSize:11,color:w.startsWith("Save failed")?"var(--red)":"var(--green)"},children:w}),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:E,style:{padding:"3px 12px",fontSize:11,background:"var(--accent)",color:"#fff",border:"none",borderRadius:4,cursor:"pointer",opacity:E?.6:1},children:E?"Saving...":"Save"}),r.jsx("button",{onClick:_,style:{padding:"3px 12px",fontSize:11,background:"var(--surface-3)",color:"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer"},children:"Cancel"})]})]}):T==="split"&&k!=="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(Qg,{content:P})}),r.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"auto"},children:k==="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:Jg(P)}}):r.jsx(Zg,{content:P,fileType:k})})]}):T==="preview"&&k!=="other"?k==="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:Jg(P)}}):r.jsx(Zg,{content:P,fileType:k}):r.jsx(Qg,{content:P})})]})}const gE=/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/,vE=/^https:\/\/github\.com\/([^/]+)\/(.+?)(?:\.git)?$/;function yE(t){const a=t.trim();if(!a)throw new Error("normalizeRemoteUrl: empty input");let s=a.match(gE);if(s)return`https://github.com/${s[1]}/${s[2]}`;if(s=a.match(vE),s)return`https://github.com/${s[1]}/${s[2]}`;throw new Error(`normalizeRemoteUrl: unrecognized remote URL: ${t}`)}function Xy(t){const a=yE(t);return`https://verified-skill.com/submit?repo=${encodeURIComponent(a)}`}function ev(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function bE({remoteUrl:t,fileCount:a,provider:s,model:i,onClose:c,defaultMode:u="manual"}){const[d,h]=p.useState(u),[x,m]=p.useState(""),[y,v]=p.useState(!1),[b,S]=p.useState(!1),[E,C]=p.useState(null),[w,N]=p.useState(null),T=p.useCallback(async()=>{v(!0),C(null);try{const J=await ke.gitCommitMessage({provider:s,model:i});m(J.message)}catch(J){const $=J instanceof Error?J.message:String(J);C($)}finally{v(!1)}},[s,i]);p.useEffect(()=>{u==="ai"&&!x&&T()},[]);const R=p.useCallback(()=>{h("ai"),N(null),x.trim()||T()},[x,T]),_=p.useCallback(()=>{h("manual"),C(null)},[]),z=p.useCallback(async()=>{const J=x.trim();if(!(!J||b)){S(!0),N(null);try{const $=await ke.gitPublish({commitMessage:J}),M=$.remoteUrl??t,I=Xy(M);window.open(I,"_blank","noopener,noreferrer");const F=($.commitSha??"").slice(0,7),H=$.branch??"";ev(`Opening verified-skill.com — ${F} on ${H}`,"info"),c()}catch($){const M=$ instanceof Error?$.message:String($),I=M.length>200?M.slice(0,200)+"…":M;N(I),ev(`Publish failed: ${I}`,"error")}finally{S(!1)}}},[x,b,t,c]),P=x.trim().length>0&&!b&&!y,k="#E6EDF3",O="#9CA3AF",L="rgba(255,255,255,0.12)",B="#0F1115",U={fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",color:O,fontFamily:"var(--font-mono, monospace)",marginBottom:6,display:"block"},Y={flex:1,height:32,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,fontFamily:"var(--font-mono, monospace)",background:"transparent",color:O,border:"none",cursor:"pointer",transition:"background 120ms ease, color 120ms ease"},X={...Y,background:"rgba(255,255,255,0.08)",color:k,fontWeight:600};return r.jsxs(r.Fragment,{children:[r.jsx("div",{"aria-hidden":"true",onClick:b?void 0:c,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",zIndex:999,animation:"publishDrawerBackdropIn 150ms ease-out"}}),r.jsx("div",{role:"presentation",style:{position:"fixed",inset:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:24,pointerEvents:"none"},children:r.jsxs("div",{role:"dialog","aria-label":"Publish","aria-modal":"true",style:{pointerEvents:"auto",width:520,maxWidth:"calc(100vw - 48px)",maxHeight:"80vh",overflowY:"auto",background:"#1A1D24",border:`1px solid ${L}`,borderRadius:10,padding:24,boxShadow:"0 24px 64px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05)",color:k,fontFamily:"var(--font-mono, monospace)",animation:"publishDrawerIn 180ms cubic-bezier(0.2, 0.8, 0.2, 1)"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",marginBottom:4},children:[r.jsx("strong",{style:{fontSize:16,fontWeight:700,letterSpacing:"-0.01em",color:k,fontFamily:"var(--font-sans, var(--font-mono, sans-serif))"},children:"Publish skill"}),r.jsx("button",{type:"button","aria-label":"Dismiss",onClick:b?void 0:c,disabled:b,style:{background:"none",border:"none",color:O,fontSize:22,lineHeight:1,cursor:b?"not-allowed":"pointer",padding:0,opacity:b?.4:1},children:"×"})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,color:O,fontVariantNumeric:"tabular-nums",marginBottom:18},children:[r.jsx("span",{"aria-hidden":"true",style:{color:"#F59E0B",fontFamily:"monospace"},children:"▮"}),r.jsxs("span",{children:[a," file",a===1?"":"s"," changed"]})]}),r.jsx("div",{style:{height:1,background:L,margin:"0 -24px 18px"}}),r.jsx("span",{style:U,children:"Mode"}),r.jsxs("div",{role:"tablist","aria-label":"Commit message mode","data-testid":"publish-mode-toggle",style:{display:"flex",border:`1px solid ${L}`,borderRadius:6,overflow:"hidden",marginBottom:16,background:B},children:[r.jsx("button",{type:"button",role:"tab","aria-selected":d==="manual","data-testid":"publish-mode-manual",onClick:_,disabled:b,style:d==="manual"?X:Y,children:"Write yourself"}),r.jsx("div",{style:{width:1,background:L}}),r.jsx("button",{type:"button",role:"tab","aria-selected":d==="ai","data-testid":"publish-mode-ai",onClick:R,disabled:b,style:d==="ai"?X:Y,children:y&&d==="ai"?"Generating…":"Generate with AI"})]}),r.jsx("label",{htmlFor:"commit-message",style:U,children:"Commit message"}),r.jsx("textarea",{id:"commit-message",value:x,onChange:J=>m(J.target.value),rows:5,disabled:y||b,placeholder:y?"Generating with AI…":d==="ai"?"Click Generate to draft a message":"Type your commit message…",style:{width:"100%",background:B,border:`1px solid ${L}`,borderRadius:6,padding:"10px 12px",fontFamily:"var(--font-mono, monospace)",fontSize:13,lineHeight:1.6,color:k,resize:"vertical",outline:"none"}}),d==="ai"&&r.jsx("button",{type:"button",onClick:T,disabled:y||b,"data-testid":"publish-generate-button",style:{marginTop:10,padding:"8px 14px",background:y?"rgba(255,255,255,0.06)":"#2563EB",color:y?O:"#FFFFFF",border:"1px solid "+(y?L:"#2563EB"),borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:600,cursor:y||b?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:y?"Generating…":"Generate with AI"}),E&&d==="ai"&&r.jsxs("div",{role:"alert","data-testid":"publish-error-generate",style:{marginTop:10,padding:"8px 12px",border:"1px solid oklch(65% 0.14 25 / 0.35)",background:"oklch(65% 0.14 25 / 0.06)",borderRadius:4,fontSize:11,color:"oklch(70% 0.14 25)",fontFamily:"var(--font-mono, monospace)",lineHeight:1.5},children:[r.jsx("strong",{style:{fontWeight:600},children:"AI generation failed."})," ",E," ",r.jsx("button",{type:"button",onClick:T,disabled:y,style:{background:"none",border:"none",color:"var(--color-accent)",cursor:y?"not-allowed":"pointer",fontFamily:"inherit",fontSize:"inherit",textDecoration:"underline",padding:0},children:"Retry"})]}),w&&r.jsxs("div",{role:"alert","data-testid":"publish-error-push",style:{marginTop:10,padding:"8px 12px",border:"1px solid oklch(65% 0.14 25 / 0.35)",background:"oklch(65% 0.14 25 / 0.06)",borderRadius:4,fontSize:11,color:"oklch(70% 0.14 25)",fontFamily:"var(--font-mono, monospace)",lineHeight:1.5},children:[r.jsx("strong",{style:{fontWeight:600},children:"Publish failed."})," ",w]}),r.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginTop:18,gap:6},children:[r.jsx("div",{style:{minHeight:28},children:d==="ai"&&r.jsx("button",{type:"button","aria-label":"Regenerate",onClick:T,disabled:y||b,className:"btn btn-ghost text-[11px]",style:{padding:"4px 10px"},children:y?"Generating…":"Regenerate"})}),r.jsxs("div",{style:{display:"flex",gap:8},children:[r.jsx("button",{type:"button","aria-label":"Cancel",onClick:c,disabled:b,style:{padding:"8px 14px",background:"transparent",color:k,border:`1px solid ${L}`,borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:500,cursor:b?"not-allowed":"pointer",opacity:b?.5:1},children:"Cancel"}),r.jsx("button",{type:"button","aria-label":"Commit & Push",onClick:z,disabled:!P,"data-testid":"publish-commit-push",style:{padding:"8px 16px",background:P?"#22C55E":"rgba(255,255,255,0.06)",color:P?"#0B0F12":O,border:"1px solid "+(P?"#22C55E":L),borderRadius:6,fontFamily:"var(--font-mono, monospace)",fontSize:12,fontWeight:700,cursor:P?"pointer":"not-allowed"},children:b?"Publishing…":"Commit & Push"})]})]})]})}),r.jsx("style",{children:`
|
|
81
|
-
@keyframes publishDrawerBackdropIn { from { opacity: 0 } to { opacity: 1 } }
|
|
82
|
-
@keyframes publishDrawerIn {
|
|
83
|
-
from { opacity: 0; transform: translateY(4px) }
|
|
84
|
-
to { opacity: 1; transform: translateY(0) }
|
|
85
|
-
}
|
|
86
|
-
@media (prefers-reduced-motion: reduce) {
|
|
87
|
-
[role="dialog"][aria-label="Publish"],
|
|
88
|
-
[role="dialog"][aria-label="Publish"] + * { animation: none !important }
|
|
89
|
-
}
|
|
90
|
-
`})]})}function tv(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function Qy({remoteUrl:t,provider:a,model:s}){const[i,c]=p.useState(!1),[u,d]=p.useState(!1),[h,x]=p.useState(0),m=p.useCallback(async()=>{if(!(i||u)){c(!0);try{let v=!1,b=0;try{const T=await ke.gitDiff();v=!!T.hasChanges,b=T.fileCount??0}catch{}if(v){x(b),d(!0);return}const S=await ke.gitPublish(),E=S.remoteUrl??t,C=Xy(E);window.open(C,"_blank","noopener,noreferrer");const w=(S.commitSha??"").slice(0,7),N=S.branch??"";tv(`Opening verified-skill.com — ${w} on ${N}`,"info")}catch(v){const b=v instanceof Error?v.message:String(v),S=b.length>200?b.slice(0,200)+"…":b;tv(`Publish failed: ${S}`,"error")}finally{c(!1)}}},[i,u,t]),y=p.useCallback(()=>d(!1),[]);return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button","aria-label":"Publish",onClick:m,disabled:i,className:"btn btn-primary text-[11px]",style:{padding:"5px 14px"},title:"Push committed changes and open verified-skill.com to submit",children:i?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"spinner",style:{width:11,height:11,borderWidth:1.5}})," Publishing…"]}):"Publish"}),u&&r.jsx(bE,{remoteUrl:t,fileCount:h,provider:a,model:s,onClose:y})]})}const jE={hasRemote:!1,remoteUrl:null,branch:null,loading:!0,error:null};function SE(){const[t,a]=p.useState(jE);return p.useEffect(()=>{let s=!1;return ke.gitRemote().then(i=>{s||a({hasRemote:!!i.hasRemote,remoteUrl:i.remoteUrl??null,branch:i.branch??null,loading:!1,error:null})}).catch(i=>{s||a({hasRemote:!1,remoteUrl:null,branch:null,loading:!1,error:i instanceof Error?i:new Error(String(i))})}),()=>{s=!0}},[]),t}const kE=/^v?(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;function bf(t){if(typeof t!="string")return null;const a=t.trim().match(kE);return a?{major:Number(a[1]),minor:Number(a[2]),patch:Number(a[3])}:null}function Vs(t,a){const s=bf(t);if(!s)throw new Error(`bumpVersion: not a valid semver: ${JSON.stringify(t)}`);switch(a){case"patch":return`${s.major}.${s.minor}.${s.patch+1}`;case"minor":return`${s.major}.${s.minor+1}.0`;case"major":return`${s.major+1}.0.0`}}function wE(t,a){const s=bf(a);if(!s)return{valid:!1,reason:`Invalid semver: ${JSON.stringify(a)}`};if(t==null)return{valid:!0};const i=bf(t);return i?i.major===s.major&&i.minor===s.minor&&i.patch===s.patch?{valid:!0}:s.major<i.major||s.major===i.major&&s.minor<i.minor||s.major===i.major&&s.minor===i.minor&&s.patch<i.patch?{valid:!1,reason:`Version cannot decrease (from ${t} → ${a}). Use the same or higher version.`}:s.major!==i.major?s.major!==i.major+1?{valid:!1,reason:`Major version can only increase by 1 at a time (got ${i.major} → ${s.major}).`}:s.minor!==0||s.patch!==0?{valid:!1,reason:`When bumping major, minor and patch must be reset to 0 (got ${a}; expected ${s.major}.0.0).`}:{valid:!0}:s.minor!==i.minor?s.minor!==i.minor+1?{valid:!1,reason:`Minor version can only increase by 1 at a time (got ${i.minor} → ${s.minor}).`}:s.patch!==0?{valid:!1,reason:`When bumping minor, patch must be reset to 0 (got ${a}; expected ${s.major}.${s.minor}.0).`}:{valid:!0}:s.patch!==i.patch+1?{valid:!1,reason:`Patch version can only increase by 1 at a time (got ${i.patch} → ${s.patch}).`}:{valid:!0}:{valid:!0}}const Zy=/^---\n([\s\S]*?)\n---(?:\n|$)/,jf=/^version:\s*["']?([^"'\n]+?)["']?\s*$/m;function Yo(t){const a=t.match(Zy);if(!a)return null;const s=a[1].match(jf);return s&&s[1].trim()||null}function Jy(t,a){const s=`version: "${a}"`,i=t.match(Zy);if(!i)return`---
|
|
91
|
-
${s}
|
|
92
|
-
---
|
|
93
|
-
${t}`;const c=i[1],u=(i.index??0)+i[0].length,d=t.slice(u),h=t.slice(0,i.index??0);let x;jf.test(c)?x=c.replace(jf,s):x=`${s}
|
|
94
|
-
${c}`;const m=i[0].endsWith(`---
|
|
95
|
-
`)?`---
|
|
96
|
-
`:"---";return`${h}---
|
|
97
|
-
${x}
|
|
98
|
-
${m}${d}`}function CE(t,a){const s=Yo(a),i=Yo(t);if(s!==null&&i!==null&&s===i)try{const c=Vs(s,"patch");return{contentToSave:Jy(t,c),version:c,fromVersion:s}}catch{return{contentToSave:t,version:i,fromVersion:s}}return{contentToSave:t,version:i,fromVersion:s}}function Pd(t,a){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function EE({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 NE({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 TE({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 RE({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 Vd({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 AE(){const{state:t,dispatch:a,saveContent:s,isReadOnly:i}=Un(),{plugin:c,skill:u,skillContent:d,isDirty:h,improveTarget:x,aiEditOpen:m}=t,[y,v]=p.useState("split"),[b,S]=p.useState(!1),E=p.useRef(null),[C,w]=p.useState(!1),[N,T]=p.useState(""),[R,_]=p.useState(!1),[z,P]=p.useState(null),[k,O]=p.useState([]),[L,B]=p.useState([]),[U,Y]=p.useState(null),X=p.useRef(null),{config:J}=Ya(),$=SE(),{files:M,activeFile:I,secondaryContent:F,loading:H,error:re,loadError:D,selectFile:W,refresh:te,isSkillMd:q}=oE(c??"",u??""),[ce,Q]=p.useState(!1),ye=p.useCallback(xe=>{ce&&!window.confirm("You have unsaved changes. Discard?")||W(xe)},[ce,W]);p.useEffect(()=>()=>{var xe;(xe=X.current)==null||xe.abort()},[]);const{metadata:oe,body:be}=QC(d),Ne=oe["allowed-tools"],Be=Array.isArray(Ne)?Ne:typeof Ne=="string"?[Ne]:[],Le=oe.name,Pe=oe.description,se=oe.metadata,de=typeof se=="object"&&!Array.isArray(se)?se:null,me=oe.version||(de==null?void 0:de.version),ve=oe.tags||(de==null?void 0:de.tags),je=Array.isArray(ve)?ve:typeof ve=="string"?ve.split(",").map(xe=>xe.trim()).filter(Boolean):[],Ve=new Set(["name","description","metadata","allowed-tools","version","tags"]),ct=Object.entries(oe).filter(([xe])=>!Ve.has(xe)),Nt=p.useCallback(async()=>{const{contentToSave:xe,version:tt,fromVersion:it}=CE(d,t.savedContent);if(tt!==null){const Tt=wE(it,tt);if(!Tt.valid){Pd(`Save blocked: ${Tt.reason??"invalid version transition"}`,"error");return}}S(!0),await s(xe),S(!1),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:content-saved",{detail:{plugin:c,skill:u,version:tt}}))},[s,d,t.savedContent,c,u]),tn=p.useCallback(xe=>{const tt=Yo(d)??"1.0.0";let it;try{it=Vs(tt,xe)}catch(Lt){const ut=Lt instanceof Error?Lt.message:String(Lt);Pd(`Bump failed: ${ut}`,"error");return}const Tt=Jy(d,it);a({type:"SET_CONTENT",content:Tt}),Pd(`Bumped to v${it} (${xe}). Click Save to commit.`,"info")},[d,a]),bt=p.useCallback(xe=>{(xe.ctrlKey||xe.metaKey)&&xe.key==="s"&&(xe.preventDefault(),xe.stopPropagation(),h&&Nt()),(xe.ctrlKey||xe.metaKey)&&xe.key==="k"&&(xe.preventDefault(),xe.stopPropagation(),a({type:m?"CLOSE_AI_EDIT":"OPEN_AI_EDIT"}))},[h,Nt,m,a]),Ge=p.useCallback(async()=>{var tt,it;if(!N.trim())return;(tt=X.current)==null||tt.abort();const xe=new AbortController;X.current=xe,_(!0),Y(null),B([]),P(null),O([]);try{const Tt=(J==null?void 0:J.provider)||"claude-cli",Lt=(J==null?void 0:J.model)||"sonnet",ut=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:N,provider:Tt,model:Lt}),signal:xe.signal});if(!ut.ok||!ut.body){let gn=`HTTP ${ut.status}`;try{const Cn=await ut.json();Cn.error&&(gn=Cn.error)}catch{}throw new Error(gn)}const Bt=ut.body.getReader(),It=new TextDecoder;let yr="",Xt="";for(;;){const{done:gn,value:Cn}=await Bt.read();if(gn)break;yr+=It.decode(Cn,{stream:!0});const Hn=yr.split(`
|
|
99
|
-
`);yr=Hn.pop()||"";for(const vn of Hn)if(vn.startsWith("event: "))Xt=vn.slice(7).trim();else if(vn.startsWith("data: ")){try{const St=JSON.parse(vn.slice(6));if(Xt==="progress")B(nn=>[...nn,{phase:St.phase,message:St.message,timestamp:Date.now()}]);else if(Xt==="done"||Xt==="complete"){const nn=["---"];St.name&&nn.push(`name: ${St.name}`),St.description&&nn.push(`description: "${St.description.replace(/"/g,'\\"')}"`),St.model&&nn.push(`model: ${St.model}`),(it=St.allowedTools)!=null&&it.trim()&&nn.push(`allowed-tools: ${St.allowedTools.trim()}`),nn.push("---","",St.body||"");const Ue=nn.join(`
|
|
100
|
-
`);P(Ue),O(cc(d,Ue)),_(!1)}else Xt==="error"&&(Y(St.message||St.description||"Generation failed"),_(!1))}catch{}Xt=""}}}catch(Tt){Tt.name!=="AbortError"&&Y(Tt.message)}finally{_(!1),X.current=null}},[N,J,d]),pt=p.useCallback(()=>{z&&a({type:"SET_CONTENT",content:z}),w(!1),P(null),O([]),T(""),B([])},[z,a]),mt=p.useCallback(()=>{w(!1),P(null),O([]),T(""),B([]),Y(null)},[]),jt=p.useCallback(()=>{var xe;C?((xe=X.current)==null||xe.abort(),mt()):(m&&a({type:"CLOSE_AI_EDIT"}),w(!0))},[C,m,a,mt]),Kt=[{mode:"raw",icon:r.jsx(EE,{}),label:"Editor"},{mode:"split",icon:r.jsx(NE,{}),label:"Split"},{mode:"preview",icon:r.jsx(TE,{}),label:"Preview"}];return r.jsxs("div",{className:"flex flex-col h-full",onKeyDown:bt,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:Kt.map(({mode:xe,icon:tt,label:it})=>r.jsxs("button",{onClick:()=>v(xe),title:it,className:"flex items-center gap-1.5 rounded-md transition-all duration-150",style:{padding:"5px 10px",background:y===xe?"var(--surface-4)":"transparent",color:y===xe?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:y===xe?600:400,border:"none",cursor:"pointer"},children:[tt,r.jsx("span",{style:{letterSpacing:"0.01em"},children:it})]},xe))}),q?i?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"}):(C&&mt(),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(RE,{size:13}),r.jsx("span",{children:"AI Edit"})]}),r.jsxs("button",{onClick:jt,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:C?600:400,border:"none",cursor:"pointer",color:C?"var(--purple)":"var(--text-tertiary)",background:C?"var(--purple-muted)":"transparent"},children:[r.jsx(Vd,{size:13}),r.jsx("span",{children:"Regenerate"})]}),r.jsx("div",{style:{width:1,height:16,background:"var(--border-subtle)"}}),!i&&(()=>{const xe=Yo(d)??"1.0.0";let tt=xe,it=xe,Tt=xe;try{tt=Vs(xe,"patch"),it=Vs(xe,"minor"),Tt=Vs(xe,"major")}catch{}const Lt={padding:"4px 8px"};return r.jsxs("div",{style:{display:"inline-flex",gap:2,alignItems:"center"},"aria-label":"Version bump","data-testid":"version-bump-controls",children:[r.jsx("button",{type:"button",onClick:()=>tn("patch"),title:`Bump patch: ${xe} → ${tt}`,"aria-label":"Bump patch version",className:"btn btn-ghost text-[11px]",style:Lt,children:"+patch"}),r.jsx("button",{type:"button",onClick:()=>tn("minor"),title:`Bump minor: ${xe} → ${it}`,"aria-label":"Bump minor version",className:"btn btn-ghost text-[11px]",style:Lt,children:"+minor"}),r.jsx("button",{type:"button",onClick:()=>tn("major"),title:`Bump major: ${xe} → ${Tt}`,"aria-label":"Bump major version",className:"btn btn-ghost text-[11px]",style:Lt,children:"+major"})]})})(),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:Nt,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"}),$.hasRemote&&$.remoteUrl&&r.jsx(Qy,{remoteUrl:$.remoteUrl,provider:J==null?void 0:J.provider,model:J==null?void 0:J.model})]}):null]}),c&&u&&r.jsx(pE,{files:M,activeFile:I,onSelect:ye,onRefresh:te,loadError:D}),!q&&r.jsx(xE,{file:F,loading:H,error:re,viewMode:y,plugin:c??void 0,skill:u??void 0,onSaved:()=>{W(I),te()},onDirtyChange:Q}),q&&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:E,value:d,onChange:xe=>{!i&&!b&&a({type:"SET_CONTENT",content:xe.target.value})},onKeyDown:bt,spellCheck:!1,readOnly:i||b,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:i?.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:[(Le||me||Pe)&&r.jsxs("div",{style:{marginBottom:20},children:[r.jsxs("div",{className:"flex items-baseline gap-3",style:{marginBottom:8},children:[Le&&r.jsx("h2",{style:{fontSize:18,fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",lineHeight:1.2,margin:0},children:Le}),me&&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",me]})]}),Pe&&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:Pe})]}),je.length>0&&r.jsx("div",{className:"flex flex-wrap items-center gap-1.5",style:{marginBottom:16},children:je.map(xe=>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:xe},xe))}),Be.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"}),Be.map(xe=>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:xe},xe))]})}),ct.length>0&&r.jsx("div",{style:{marginBottom:16,padding:"8px 0",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)"},children:ct.map(([xe,tt],it)=>{const Tt=Array.isArray(tt)?tt.join(", "):typeof tt=="object"?Object.entries(tt).map(([Lt,ut])=>`${Lt}: ${Array.isArray(ut)?ut.join(", "):ut}`).join(" | "):tt;return r.jsxs("div",{className:"flex items-baseline gap-3",style:{padding:"4px 0",borderTop:it>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:xe}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:Tt})]},xe)})}),(Le||Pe||je.length>0||Be.length>0||ct.length>0)&&be&&r.jsx("div",{style:{height:1,background:"linear-gradient(90deg, var(--accent) 0%, var(--border-subtle) 40%, transparent 100%)",marginBottom:20,opacity:.5}}),be&&r.jsx("div",{className:"text-[13px] leading-relaxed overflow-x-auto",style:{color:"var(--text-secondary)",wordBreak:"break-word"},dangerouslySetInnerHTML:{__html:oc(be)}})]})})]}),q&&m&&r.jsx(iE,{}),q&&C&&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(Vd,{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:xe=>T(xe.target.value),placeholder:"Describe what this skill should do...",rows:2,disabled:R,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:R?.5:1},onKeyDown:xe=>{xe.key==="Enter"&&(xe.ctrlKey||xe.metaKey)&&N.trim()&&!R&&(xe.preventDefault(),Ge())}})}),r.jsxs("div",{className:"flex items-center gap-2",children:[R?r.jsx("button",{onClick:()=>{var xe;(xe=X.current)==null||xe.abort(),_(!1)},className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Cancel"}):r.jsx("button",{onClick:Ge,disabled:!N.trim(),className:"btn btn-primary text-[11px]",style:{padding:"4px 12px"},children:"Generate"}),r.jsx("button",{onClick:mt,className:"btn btn-ghost text-[11px]",style:{padding:"4px 8px"},children:"Close"})]}),R&&L.length>0&&r.jsx("div",{className:"mt-2",children:r.jsx(ui,{entries:L,isRunning:!0})}),U&&r.jsxs("div",{className:"mt-2 px-3 py-2 rounded-lg text-[12px]",style:{background:"var(--red-muted)",color:"var(--red)"},children:[U,r.jsx("button",{onClick:Ge,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(Vd,{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:k.map((xe,tt)=>r.jsxs("div",{className:"px-3 py-0.5 text-[11px] font-mono",style:{background:xe.type==="added"?"var(--green-muted)":xe.type==="removed"?"var(--red-muted)":"transparent",color:xe.type==="added"?"var(--green)":xe.type==="removed"?"var(--red)":"var(--text-secondary)",borderLeft:xe.type==="added"?"3px solid var(--green)":xe.type==="removed"?"3px solid var(--red)":"3px solid transparent"},children:[r.jsx("span",{style:{userSelect:"none",opacity:.5,marginRight:8},children:xe.type==="added"?"+":xe.type==="removed"?"-":" "}),xe.content]},tt))}),r.jsxs("div",{className:"flex gap-2",children:[r.jsxs("button",{onClick:pt,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:mt,className:"btn btn-secondary text-[11px]",style:{padding:"4px 12px"},children:"Discard"})]})]})]})}),q&&x!==null&&c&&u&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(eE,{plugin:c,skill:u,skillContent:d,onApplied:xe=>{a({type:"SET_CONTENT",content:xe}),a({type:"CONTENT_SAVED"}),a({type:"CLOSE_IMPROVE"})}})})]})}function Dl(t){return t.testType==="integration"?"integration":"unit"}function $l(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function eb(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 tb(t){return t==null?"--":t>=1e3?`${(t/1e3).toFixed(1)}s`:`${t}ms`}const ME=new Set(["benchmark","comparison","baseline"]);function nv(t,a,s,i){return t.map(({rate:c,idx:u,total:d})=>{const h=i+u/(d-1)*(a-i*2),x=i+(s-i*2)-c*(s-i*2);return`${h},${x}`})}function nb({entries:t}){const a=t.filter(v=>ME.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"}),i=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&&i.length<2)return null;const c=80,u=24,d=2,h=s.length>=2?nv(s,c,u,d):[],x=i.length>=2?nv(i,c,u,d):[],m=h[h.length-1],y=x[x.length-1];return r.jsxs("svg",{width:c,height:u,style:{display:"block",flexShrink:0},children:[x.length>0&&r.jsx("polyline",{points:x.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 rb(t,a,s){const i=isNaN(a)?0:a,c=[],u=[],d=[];if((t==="PASS"||t==="EFFECTIVE")&&i>=.7){const m=c.length>0?` Met criteria: ${c.map(y=>y.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${i.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 ${i.toFixed(2)}): evaluation did not meet expectations.${m}`,recommendations:y}}if(t==="INEFFECTIVE"){if(i<.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 ${i.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 ${i.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 ${i.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 ${i.toFixed(2)}): early promise — focus on weak areas to improve.`,recommendations:m}}const h=c.length>0?` Passing: ${c.map(m=>m.criterion).join(", ")}.`:"",x=d.length>0?` Needs improvement: ${d.map(m=>m.criterion).join(", ")}.`:"";return{explanation:`${t} (score ${i.toFixed(2)}): mixed results.${h}${x}`}}const ab={EFFECTIVE:"Strong Improvement",MARGINAL:"Moderate Improvement",EMERGING:"Early Promise",INEFFECTIVE:"Needs Work",DEGRADING:"Regression"};function LE(t){return Object.hasOwn(ab,t)}function zE(t){return LE(t)?ab[t]:t}function DE(){const{state:t}=Un(),{plugin:a,skill:s}=t,[i,c]=p.useState([]),[u,d]=p.useState([]),[h,x]=p.useState(!0),[m,y]=p.useState(null),[v,b]=p.useState(new Set),[S,E]=p.useState({}),[C,w]=p.useState(null),[N,T]=p.useState(""),[R,_]=p.useState(!1),[z,P]=p.useState(""),[k,O]=p.useState(""),L=p.useCallback(async()=>{x(!0),y(null);try{const[$,M]=await Promise.all([ke.getCredentials(a,s),ke.getParams(a,s)]);c($.credentials),d(M.params)}catch($){y($ instanceof Error?$.message:"Failed to load parameters"),c([]),d([])}finally{x(!1)}},[a,s]);p.useEffect(()=>{L()},[L]);const B=p.useCallback(async($,M)=>{_(!0),y(null);try{await ke.setCredential(a,s,$,M),w(null),T(""),await L()}catch(I){y(I instanceof Error?I.message:`Failed to save ${$}`)}finally{_(!1)}},[a,s,L]),U=p.useCallback(async()=>{const $=z.trim().toUpperCase(),M=k.trim();if(!(!$||!M)){_(!0),y(null);try{await ke.setCredential(a,s,$,M),P(""),O(""),await L()}catch(I){y(I instanceof Error?I.message:`Failed to add ${$}`)}finally{_(!1)}}},[a,s,z,k,L]),Y=p.useCallback(async $=>{if(v.has($)){b(M=>{const I=new Set(M);return I.delete($),I}),E(M=>{const I={...M};return delete I[$],I});return}try{const I=(await ke.getParamsRevealed(a,s,$)).params.find(F=>F.name===$);I!=null&&I.value&&(E(F=>({...F,[$]:I.value})),b(F=>new Set(F).add($)))}catch{}},[a,s,v]),X=new Set(i.map($=>$.name)),J=[...i.map($=>{const M=u.find(I=>I.name===$.name);return{name:$.name,status:$.status,maskedValue:(M==null?void 0:M.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:()=>Y($.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"})]}),C===$.name?r.jsxs("div",{className:"flex gap-1",children:[r.jsx("input",{value:N,onChange:M=>T(M.target.value),onKeyDown:M=>{M.key==="Enter"&&N.trim()&&B($.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:()=>B($.name,N),disabled:R||!N.trim(),className:"text-[10px] font-medium",style:{color:"var(--green)",background:"none",border:"none",cursor:"pointer"},children:"Save"}),r.jsx("button",{onClick:()=>{w(null),T("")},className:"text-[10px]",style:{color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer"},children:"Cancel"})]}):r.jsx("button",{onClick:()=>{w($.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:$=>P($.target.value),className:"input-field text-[10px] font-mono flex-1",placeholder:"KEY_NAME","aria-label":"Parameter key name"}),r.jsx("input",{value:k,onChange:$=>O($.target.value),onKeyDown:$=>{$.key==="Enter"&&z.trim()&&k.trim()&&U()},className:"input-field text-[10px] font-mono flex-1",placeholder:"value",type:"password","aria-label":"Parameter value"}),r.jsx("button",{onClick:U,disabled:R||!z.trim()||!k.trim(),className:"text-[10px] font-medium px-2 py-1 rounded",style:{background:"var(--accent-muted)",color:"var(--accent)",border:"none",cursor:R?"not-allowed":"pointer"},children:"Add"})]})]})]})}const Us="This is an installed copy (read-only). Open the source skill to edit.";function _E(t,a,s){const[i,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),ke.getCaseHistory(t,a,s).then(y=>c(y)).catch(()=>c([])).finally(()=>d(!1)))},[t,a,s]);const x=p.useCallback(()=>{d(!0),h.current="",ke.getCaseHistory(t,a,s).then(m=>c(m)).catch(()=>c([])).finally(()=>d(!1))},[t,a,s]);return{entries:i,loading:u,refetch:x}}function OE(t,a,s){const i={flaky:!1,nonDiscriminating:!1,regression:!1};if(!s||s.length===0)return i;const u=s.slice(0,10).map(x=>x.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&&(i.flaky=!0)}const d=s.find(x=>x.type==="benchmark"),h=s.find(x=>x.type==="baseline");if(d&&h){const x=d.assertions.find(y=>y.id===t),m=h.assertions.find(y=>y.id===t);x!=null&&x.pass&&(m!=null&&m.pass)&&(i.nonDiscriminating=!0)}if(a&&!a.pass&&s.length>=1){const m=s[0].assertions.find(y=>y.id===t);m!=null&&m.pass&&(i.regression=!0)}return i}function BE(){var F;const{state:t,dispatch:a,saveEvals:s,runCase:i,runAll:c,cancelCase:u,cancelAll:d,generateEvals:h,isReadOnly:x}=Un(),{evals:m,evalsError:y,selectedCaseId:v,inlineResults:b,caseRunStates:S,generateEvalsLoading:E,generateEvalsProgress:C,generateEvalsError:w}=t,N=p.useMemo(()=>{for(const H of S.values())if(H.status==="running"||H.status==="queued")return!0;return!1},[S]),[T,R]=p.useState(!1),[_,z]=p.useState("all"),P={skill_name:t.skill,evals:[]},k=m??P,O=k.evals,L=p.useMemo(()=>_==="all"?O:O.filter(H=>Dl(H)===_),[_,O]),B=L.find(H=>H.id===v)??null;p.useEffect(()=>{v!==null&&!L.find(H=>H.id===v)&&a({type:"SELECT_CASE",caseId:L.length>0?L[0].id:null})},[L,v,a]);const[U,Y]=p.useState([]),X=p.useMemo(()=>O.some(H=>Dl(H)==="integration"),[O]);p.useEffect(()=>{X&&ke.getCredentials(t.plugin,t.skill).then(H=>Y(H.credentials)).catch(()=>Y([]))},[t.plugin,t.skill,X]);const J=p.useMemo(()=>new Set(U.filter(H=>H.status==="missing").map(H=>H.name)),[U]),[$,M]=p.useState(!1),I=p.useCallback(H=>{M(!1),h(H?{testType:H}: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:()=>R(!0),disabled:x,title:x?Us: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:()=>I("unit"),disabled:E||x,title:x?Us:void 0,className:"btn btn-secondary text-[12px]",style:{borderTopRightRadius:0,borderBottomRightRadius:0},children:E?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:()=>M(!$),disabled:E||x,title:x?Us: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:()=>I("integration"),className:"w-full text-left px-3 py-2 text-[12px] transition-colors duration-100",style:{color:"var(--text-secondary)",background:"transparent"},onMouseEnter:H=>{H.currentTarget.style.background="var(--surface-2)"},onMouseLeave:H=>{H.currentTarget.style.background="transparent"},children:"Generate Integration Tests"})})]})]}),E&&C.length>0&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(ui,{entries:C,isRunning:!0})}),w&&r.jsx("div",{className:"w-full max-w-md mt-3",children:r.jsx(uc,{error:w,onRetry:()=>I()})}),T&&r.jsx(rv,{evals:k,onSave:H=>{s(H),R(!1)},onCancel:()=>R(!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 (",L.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:L.length===0||x,title:x?Us: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:L.length===0||x,title:x?Us: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(H=>r.jsx("button",{onClick:()=>z(H),style:{padding:"2px 8px",fontSize:10,fontWeight:_===H?600:400,background:_===H?"var(--accent-muted)":"transparent",color:_===H?"var(--accent)":"var(--text-tertiary)",border:"none",borderRadius:4,cursor:"pointer",textTransform:"capitalize"},children:H==="all"?`All (${O.length})`:H==="unit"?`Unit (${O.filter(re=>Dl(re)==="unit").length})`:`Integration (${O.filter(re=>Dl(re)==="integration").length})`},H))}),r.jsxs("div",{className:"py-1",children:[L.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 ",_==="all"?"":_+" ","tests yet"]}),L.map(H=>{var te;const re=b.get(H.id),D=v===H.id,W=Dl(H);return r.jsxs("button",{onClick:()=>a({type:"SELECT_CASE",caseId:H.id}),className:"w-full text-left px-3 py-2.5 transition-all duration-150",style:{background:D?"var(--accent-muted)":"transparent",borderLeft:D?"3px solid var(--accent)":"3px solid transparent"},onMouseEnter:q=>{D||(q.currentTarget.style.background="var(--surface-2)")},onMouseLeave:q=>{D||(q.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:D?"var(--text-primary)":"var(--text-secondary)"},children:["#",H.id," ",H.name,r.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 5px",borderRadius:9999,background:W==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:W==="unit"?"var(--accent)":"var(--orange)",whiteSpace:"nowrap"},children:W==="unit"?"U":"I"}),W==="integration"&&((te=H.requiredCredentials)==null?void 0:te.some(q=>J.has(q)))&&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(lb,{result:re})]}),r.jsxs("div",{className:"text-[11px] flex items-center gap-2",style:{color:"var(--text-tertiary)"},children:[H.assertions.length," assertion",H.assertions.length!==1?"s":"",(re==null?void 0:re.passRate)!=null&&r.jsx(UE,{passRate:re.passRate})]})]},H.id)})]}),r.jsx("div",{className:"px-3 py-2",children:!x&&r.jsx("button",{onClick:()=>R(!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:H=>{H.currentTarget.style.borderColor="var(--accent)",H.currentTarget.style.color="var(--accent)"},onMouseLeave:H=>{H.currentTarget.style.borderColor="var(--border-default)",H.currentTarget.style.color="var(--text-tertiary)"},children:"+ Add Test Case"})}),r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle)"},children:r.jsx(DE,{})})]}),r.jsx("div",{className:"overflow-auto",children:B?r.jsx(IE,{evalCase:B,result:b.get(B.id),evals:m,caseStatus:((F=S.get(B.id))==null?void 0:F.status)??"idle",onSaveEvals:s,onRun:H=>i(H,"benchmark"),onCompare:H=>i(H,"comparison"),onCancel:H=>u(H),onImprove:H=>a({type:"OPEN_IMPROVE",evalId:H})}):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(rv,{evals:k,onSave:H=>{s(H),R(!1)},onCancel:()=>R(!1)})]})}function IE({evalCase:t,result:a,evals:s,caseStatus:i,onSaveEvals:c,onRun:u,onCompare:d,onCancel:h,onImprove:x}){const{state:m,isReadOnly:y}=Un(),{plugin:v,skill:b}=m,{entries:S,loading:E}=_E(v,b,t.id),[C,w]=p.useState(!1),[N,T]=p.useState(t.prompt),[R,_]=p.useState(!1),[z,P]=p.useState(t.expected_output);p.useState(()=>{T(t.prompt),P(t.expected_output)});const k=p.useCallback(H=>{c({...s,evals:s.evals.map(re=>re.id===H.id?H:re)})},[s,c]),O=p.useCallback(()=>{k({...t,prompt:N}),w(!1)},[t,N,k]),L=p.useCallback(()=>{k({...t,expected_output:z}),_(!1)},[t,z,k]),B=p.useCallback(()=>{k({...t,assertions:[...t.assertions,{id:`assert-${Date.now()}`,text:"New assertion",type:"boolean"}]})},[t,k]),U=p.useCallback((H,re)=>{k({...t,assertions:t.assertions.map(D=>D.id===H?{...D,text:re}:D)})},[t,k]),Y=p.useCallback(H=>{k({...t,assertions:t.assertions.filter(re=>re.id!==H)})},[t,k]),X=p.useCallback(()=>{confirm("Delete this test case?")&&c({...s,evals:s.evals.filter(H=>H.id!==t.id)})},[s,t.id,c]),J=a&&a.assertions.length>0&&a.assertions.every(H=>H.pass),$=a&&a.assertions.some(H=>!H.pass),M=Dl(t),I=t.requiredCredentials??[],F=M==="integration"&&I.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:M==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:M==="unit"?"var(--accent)":"var(--orange)"},children:M==="unit"?"Unit":"Integration"}):r.jsx("button",{onClick:()=>{if((M==="unit"?"integration":"unit")==="unit"){const{requiredCredentials:re,requirements:D,cleanup:W,...te}=t;k({...te,testType:"unit"})}else k({...t,testType:"integration"})},title:`Click to switch to ${M==="unit"?"integration":"unit"}`,style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:9999,background:M==="unit"?"var(--accent-muted)":"var(--orange-muted)",color:M==="unit"?"var(--accent)":"var(--orange)",border:"none",cursor:"pointer"},children:M==="unit"?"Unit":"Integration"}),r.jsx(lb,{result:a})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:8,marginLeft:"auto",flexShrink:0},children:[i==="running"||i==="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&&i!=="running"&&i!=="queued"&&r.jsx("button",{onClick:()=>x(t.id),className:"btn btn-secondary text-[12px]",style:{whiteSpace:"nowrap"},children:"Fix with AI"}),!y&&i!=="running"&&i!=="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&&M==="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"})]}),F&&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:I.map(H=>r.jsx("span",{style:{fontSize:10,fontFamily:"var(--font-mono, monospace)",padding:"2px 6px",borderRadius:4,background:"var(--orange-muted)",color:"var(--orange)"},children:H},H))})]}),!y&&M==="integration"&&r.jsx(VE,{evalCase:t,onUpdate:k}),r.jsx(Ro,{title:"Prompt",children:C?r.jsxs("div",{children:[r.jsx("textarea",{value:N,onChange:H=>T(H.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),w(!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||w(!0)},onMouseEnter:H=>{y||(H.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:H=>{H.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(Ro,{title:"Expected Output",children:R?r.jsxs("div",{children:[r.jsx("textarea",{value:z,onChange:H=>P(H.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:L,className:"btn btn-primary text-[12px]",children:"Save"}),r.jsx("button",{onClick:()=>{P(t.expected_output),_(!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||_(!0)},onMouseEnter:H=>{y||(H.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:H=>{H.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(Ro,{title:`Assertions (${t.assertions.length})`,action:y?void 0:r.jsx("button",{onClick:B,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(H=>{const re=a==null?void 0:a.assertions.find(W=>W.assertion_id===H.id),D=OE(H.id,re,S);return r.jsx($E,{assertion:H,result:re,badges:D,isReadOnly:y,onUpdate:W=>U(H.id,W),onDelete:()=>Y(H.id)},H.id)})})}),(a==null?void 0:a.output)&&r.jsx(HE,{output:a.output,durationMs:a.durationMs,tokens:a.tokens}),a&&a.passRate!=null&&a.passRate<.2&&(()=>{const H=rb("INEFFECTIVE",a.passRate);return H.recommendations&&H.recommendations.length>0?r.jsx(Ro,{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:H.recommendations.map((re,D)=>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:"•"}),re]},D))})]})}):null})(),r.jsx(PE,{evalId:t.id,sharedEntries:S,sharedLoading:E})]},t.id)}function $E({assertion:t,result:a,badges:s,isReadOnly:i,onUpdate:c,onDelete:u}){const[d,h]=p.useState(!1),[x,m]=p.useState(t.text),[y,v]=p.useState(!1),b=()=>{c(x),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:x,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:i?"default":"pointer"},onClick:()=>{i||(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})]}),!i&&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 Ro({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 lb({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 i=t.status==="pass",c=t.passRate??0,d=rb(i?"PASS":"FAIL",c);return r.jsxs("span",{className:"pill text-[10px]",style:{background:i?"var(--green-muted)":"var(--red-muted)",color:i?"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 UE({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 HE({output:t,durationMs:a,tokens:s}){const[i,c]=p.useState(!1);return r.jsxs("div",{className:"mb-5",children:[r.jsxs("button",{onClick:()=>c(!i),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:i?"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)"]})]}),i&&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 Fd(t){return t==="baseline"?"right":t==="comparison"?"full":"left"}function Gd({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:eb(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:$l(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:tb(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",i=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:[i,(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 PE({evalId:t,sharedEntries:a,sharedLoading:s}){const{state:i,dispatch:c}=Un(),{plugin:u,skill:d}=i,[h,x]=p.useState(!0),m=a??null,y=s??!1,v=p.useCallback(()=>{x(C=>!C)},[]),b=m?m.slice(0,10):[],S=b.some(C=>{const w=Fd(C.type);return w==="left"||w==="full"}),E=b.some(C=>{const w=Fd(C.type);return w==="right"||w==="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(nb,{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"}),!E&&r.jsx("div",{style:{gridColumn:"2",fontSize:12,color:"var(--text-tertiary)"},children:"No baseline runs"}),b.map((C,w)=>{const N=Fd(C.type);return N==="full"?r.jsx("div",{style:{gridColumn:"1 / -1"},children:r.jsx(Gd,{entry:C})},w):N==="left"?r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"},children:r.jsx(Gd,{entry:C})}),r.jsx("div",{style:{gridColumn:"2"}})]},w):r.jsxs(p.Fragment,{children:[r.jsx("div",{style:{gridColumn:"1"}}),r.jsx("div",{style:{gridColumn:"2"},children:r.jsx(Gd,{entry:C})})]},w)})]}),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:C=>{C.currentTarget.style.textDecoration="underline"},onMouseLeave:C=>{C.currentTarget.style.textDecoration="none"},children:"View full history →"})]})})]})}function rv({evals:t,onSave:a,onCancel:s}){const[i,c]=p.useState(""),[u,d]=p.useState(""),[h,x]=p.useState(""),[m,y]=p.useState([{id:`assert-${Date.now()}`,text:"",type:"boolean"}]),[v,b]=p.useState("unit"),[S,E]=p.useState(""),[C,w]=p.useState([]),[N,T]=p.useState(""),[R,_]=p.useState(""),z=Math.max(0,...t.evals.map(L=>L.id))+1,P=L=>{b(L),L==="unit"&&(w([]),E(""),T(""),_(""))},k=()=>{const L=S.trim().toUpperCase();L&&!C.includes(L)&&w([...C,L]),E("")},O=()=>{if(!i.trim()||!u.trim())return;const L={id:z,name:i.trim(),prompt:u.trim(),expected_output:h.trim(),files:[],assertions:m.filter(B=>B.text.trim()),...v==="integration"?{testType:"integration",...C.length>0?{requiredCredentials:C}:{},...N||R?{requirements:{...N?{platform:N}:{},...R?{chromeProfile:R}:{}}}:{}}:{}};a({...t,evals:[...t.evals,L]})};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(L=>r.jsx("button",{onClick:()=>P(L),className:"px-3 py-1 rounded-md text-[12px] font-medium transition-all duration-150",style:{background:v===L?L==="unit"?"var(--accent-muted)":"var(--orange-muted)":"transparent",color:v===L?L==="unit"?"var(--accent)":"var(--orange)":"var(--text-tertiary)",border:"none",cursor:"pointer",textTransform:"capitalize"},children:L},L))})]}),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:i,onChange:L=>c(L.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:L=>d(L.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:L=>x(L.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((L,B)=>r.jsxs("div",{className:"flex gap-2 mb-2",children:[r.jsx("input",{value:L.text,onChange:U=>y(m.map((Y,X)=>X===B?{...Y,text:U.target.value}:Y)),className:"input-field flex-1 text-[12px]",placeholder:"e.g., Output includes a greeting"}),m.length>1&&r.jsx("button",{onClick:()=>y(m.filter((U,Y)=>Y!==B)),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"})]})})]},L.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:C.map(L=>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:[L,r.jsx("button",{onClick:()=>w(C.filter(B=>B!==L)),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"})]})})]},L))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:S,onChange:L=>E(L.target.value),onKeyDown:L=>{L.key==="Enter"&&(L.preventDefault(),k())},className:"input-field flex-1 text-[11px] font-mono",placeholder:"e.g., SLACK_BOT_TOKEN"}),r.jsx("button",{onClick:k,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:L=>T(L.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:R,onChange:L=>_(L.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:!i.trim()||!u.trim(),className:"btn btn-primary text-[12px]",children:"Save"})]})]})})}function VE({evalCase:t,onUpdate:a}){var d,h;const[s,i]=p.useState(""),c=()=>{const x=s.trim().toUpperCase();x&&!(t.requiredCredentials??[]).includes(x)&&a({...t,requiredCredentials:[...t.requiredCredentials??[],x]}),i("")},u=x=>{const m=(t.requiredCredentials??[]).filter(y=>y!==x);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(x=>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:[x,r.jsx("button",{onClick:()=>u(x),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"})]})})]},x))}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("input",{value:s,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.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:x=>a({...t,requirements:{...t.requirements,platform:x.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:x=>a({...t,requirements:{...t.requirements,chromeProfile:x.target.value||void 0}}),className:"input-field text-[11px]",placeholder:"e.g., Default"})]})]})}function $n(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 sb(t,a){return t==null||a==null?"N/A":`${t.toLocaleString("en-US")} in / ${a.toLocaleString("en-US")} out`}function FE(t){return t==="baseline"?"Baseline Pass Rate":"Skill Pass Rate"}function GE(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 WE(t,a,s){const i=s===1?"test case":"test cases";if(t===0)return`Your skill performs the same as the baseline across ${s} ${i}`;const c=Math.round(Math.abs(t)*a);if(c===0)return`Your skill performs the same as the baseline across ${s} ${i}`;const u=t>0?"more":"fewer";return`Your skill passes ${c} ${u} assertions across ${s} ${i}`}function av(t,a){const s=i=>{const c=i/5*100;return isFinite(c)?Math.round(Math.min(100,Math.max(0,c))):0};return{skill:s(t),baseline:s(a)}}function qE(t){return t==="skill"?{text:"Skill wins",isSkill:!0}:t==="baseline"?{text:"Baseline wins",isSkill:!1}:{text:"Tie",isSkill:!1}}function YE(t,a){const s=t+a,i=s*10,c=s*25,u=d=>d>=60?`${Math.round(d/60)}m`:`${d}s`;return`${u(i)}–${u(c)}`}const KE={anthropic:.01,openrouter:.01,ollama:0,"lm-studio":0,"claude-cli":0,"codex-cli":0,"gemini-cli":0};function XE(t,a){if(!t)return null;const s=KE[t];if(s==null||s===0)return null;const i=s*a*.5,c=s*a*2;return`${$n(i)}–${$n(c)}`}function QE(){const{state:t,runCase:a,runAll:s,cancelCase:i,cancelAll:c,isReadOnly:u}=Un(),{evals:d,caseRunStates:h,bulkRunActive:x,latestBenchmark:m,inlineResults:y}=t,{config:v}=Ya(),b=(d==null?void 0:d.evals)??[],S=p.useMemo(()=>{for(const k of h.values())if(k.status==="running"||k.status==="queued")return!0;return!1},[h]),E=b.filter(k=>{const O=h.get(k.id);return O&&(O.status==="complete"||O.status==="error"||O.status==="cancelled")}).length,C=b.filter(k=>{const O=h.get(k.id);return O&&(O.status==="running"||O.status==="queued")}).length,w=p.useRef(null),[N,T]=p.useState(0);p.useEffect(()=>{if(S&&!w.current&&(w.current=Date.now()),!S){w.current=null,T(0);return}const k=setInterval(()=>{w.current&&T(Math.round((Date.now()-w.current)/1e3))},1e3);return()=>clearInterval(k)},[S]);const R=b.reduce((k,O)=>k+O.assertions.length,0),_=b.length+R,z=p.useMemo(()=>YE(b.length,R),[b.length,R]),P=p.useMemo(()=>XE((v==null?void 0:v.provider)??null,_),[v==null?void 0:v.provider,_]);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:[C," 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]}),P&&r.jsxs("span",{children:["Est. cost: ",P]}),!P&&(v==null?void 0:v.provider)&&(v.provider==="claude-cli"||v.provider==="codex-cli")&&r.jsx("span",{children:"Cost: Included"}),!P&&(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: ",E,"/",b.length," cases"]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[Math.round(E/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:`${E/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(k=>{const O=y.get(k.id),L=h.get(k.id),B=(L==null?void 0:L.status)??"idle",U=m==null?void 0:m.cases.find(Y=>Y.eval_id===k.id);return r.jsx(JE,{name:k.name,evalId:k.id,result:O,caseCost:U==null?void 0:U.cost,caseBillingMode:U==null?void 0:U.billingMode,caseInputTokens:U==null?void 0:U.inputTokens,caseOutputTokens:U==null?void 0:U.outputTokens,caseStatus:B,runMode:(L==null?void 0:L.mode)??null,comparisonDetail:U==null?void 0:U.comparisonDetail,isReadOnly:u,onRun:Y=>a(Y,"benchmark"),onBaseline:Y=>a(Y,"baseline"),onCompare:Y=>a(Y,"comparison"),onCancel:Y=>i(Y)},k.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:FE(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: ${sb(m.totalInputTokens,m.totalOutputTokens)}`,m.totalCost!=null&&` | Cost: ${$n(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 k=GE(m.model,m.timestamp);return k?r.jsx("div",{className:"text-[10px] mt-0.5 mb-3",style:{color:"var(--text-tertiary)"},children:k}):r.jsx("div",{className:"mb-3"})})(),r.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[r.jsx(lv,{label:"Skill",value:m.comparison.skillPassRate,color:"var(--accent)"}),r.jsx(lv,{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&&` | ${zE(m.verdict)}`]}),(()=>{const k=m.cases.reduce((L,B)=>L+B.assertions.length,0),O=WE(m.comparison.delta,k,m.cases.length);return r.jsx("div",{className:"mt-1 text-[11px]",style:{color:"var(--text-tertiary)"},children:O})})()]})]})]})}const ZE={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 JE({name:t,evalId:a,result:s,caseCost:i,caseBillingMode:c,caseInputTokens:u,caseOutputTokens:d,caseStatus:h,runMode:x,comparisonDetail:m,isReadOnly:y,onRun:v,onBaseline:b,onCompare:S,onCancel:E}){const[C,w]=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]}),x&&(N||T)&&(()=>{const R=ZE[x];return R?r.jsx("span",{className:"pill text-[9px] font-semibold",style:{background:R.bg,color:R.color,padding:"1px 6px"},children:R.label}):null})()]}),r.jsxs("div",{className:"flex items-center gap-2",children:[N?r.jsx("button",{onClick:()=>E(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:sb(u,d)}),i!=null&&r.jsx("span",{className:"text-[10px]",style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono, monospace)"},children:$n(i,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(R=>r.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[r.jsx("span",{style:{color:R.pass?"var(--green)":"var(--red)"},children:R.pass?"PASS":"FAIL"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:R.text})]},R.assertion_id))}),s.output&&r.jsx("button",{onClick:()=>w(!C),className:"text-[11px] mt-2 transition-colors duration-150",style:{color:"var(--text-tertiary)"},children:C?"Hide output":"Show output"}),C&&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 R=av(m.skillContentScore,m.baselineContentScore),_=av(m.skillStructureScore,m.baselineStructureScore),z=qE(m.winner);return r.jsxs(r.Fragment,{children:[r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Content: Skill ",R.skill,"% / Baseline ",R.baseline,"%"]}),r.jsx("span",{style:{color:"var(--text-tertiary)"},children:"·"}),r.jsxs("span",{style:{color:"var(--text-secondary)"},children:["Structure: Skill ",_.skill,"% / Baseline ",_.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(eN,{errorMessage:s.errorMessage,classifiedError:s.classifiedError})]})}const Wd={rate_limit:"⏱",context_window:"⚠",auth:"🔒",timeout:"⌛",provider_unavailable:"⚡",parse_error:"❓",unknown:"❌"};function eN({errorMessage:t,classifiedError:a}){const[s,i]=p.useState(!1),c=(a==null?void 0:a.title)??"Error",u=a==null?void 0:a.hint,d=a?Wd[a.category]??Wd.unknown:Wd.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:()=>i(!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 lv({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 sv={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)"},SCOPE_WARNING:{bg:"var(--yellow-muted)",text:"var(--yellow)"},DRIFT_WARNING:{bg:"var(--yellow-muted)",text:"var(--yellow)"}},tN={scope_warning:"Description claims broader scope than name+tags suggest. Either narrow the description or add explicit '+' prefix to confirm intended scope.",drift_warning:"Description omits intent that classifier inferred from name+tags. Description may need to mention this case explicitly."};function nN(){const{state:t,dispatch:a,runActivationTest:s,cancelActivation:i,generateActivationPrompts:c,loadTestCasesFromSkillMd:u,saveTestCasesToSkillMd:d}=Un(),{plugin:h,skill:x,activationPrompts:m,activationResults:y,activationSummary:v,activationRunning:b,activationError:S,activationStartedAt:E,activationClassifyingStatus:C,generatingPrompts:w,generatingPromptsError:N,activationPromptsSource:T,savingTestCases:R,savingTestCasesError:_,savingTestCasesSuccess:z,activationHistory:P}=t,{state:k}=cr(),O=k.skills.find(Q=>Q.plugin===h&&Q.skill===x),L=(O==null?void 0:O.resolvedVersion)??(O==null?void 0:O.version)??null,[B,U]=p.useState(m),[Y,X]=p.useState(null),[J,$]=p.useState(!1);p.useEffect(()=>{m&&m!==B&&U(m)},[m]),p.useEffect(()=>{a({type:"SET_ACTIVATION_PROMPTS",prompts:B})},[B,a]),p.useEffect(()=>{fetch(`/api/skills/${h}/${x}/description`).then(Q=>Q.json()).then(Q=>X(Q.rawContent||Q.description||null)).catch(()=>X(null))},[h,x]),p.useEffect(()=>{(!m||m.trim().length===0)&&u()},[h,x]);function M(){s(B)}function I(){c(8)}function F(){d()}const H=B.trim().split(`
|
|
101
|
-
`).filter(Boolean).length,re=Q=>Q.verdict==="scope_warning"||Q.verdict==="drift_warning",D=y.filter(Q=>(Q.classification==="TP"||Q.classification==="TN")&&!re(Q)),W=y.filter(Q=>(Q.classification==="FP"||Q.classification==="FN")&&!re(Q));y.filter(re);const te=(Y==null?void 0:Y.replace(/^---[\s\S]*?---\s*/,"").trim())??null,q=B.trim().length>0,ce=te?oc(te):"";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.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("label",{className:"text-[11px] font-semibold uppercase tracking-widest",style:{color:"var(--text-tertiary)"},children:"Test Prompts"}),T==="skill-md"&&r.jsx("span",{className:"pill",style:{background:"var(--green-muted)",color:"var(--green)",fontSize:"9px",padding:"1px 5px"},title:"Loaded from the ## Test Cases block in SKILL.md. Save back any edits to persist them.",children:"from SKILL.md"}),T==="ai-generated"&&r.jsx("span",{className:"pill",style:{background:"var(--purple-muted)",color:"var(--purple)",fontSize:"9px",padding:"1px 5px"},title:"AI-generated. Save as test cases to persist into SKILL.md.",children:"AI-generated"})]}),r.jsxs("div",{className:"flex gap-1.5",children:[r.jsx("button",{onClick:F,disabled:R||!q||b,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:R?"var(--surface-3)":"var(--surface-2)",color:q?"var(--green)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:q?1:.5,cursor:q?"pointer":"not-allowed"},title:q?"Write the current prompts back to SKILL.md as a ## Test Cases block":"No prompts to save",onMouseEnter:Q=>{q&&!R&&(Q.currentTarget.style.background="var(--surface-3)")},onMouseLeave:Q=>{R||(Q.currentTarget.style.background="var(--surface-2)")},children:R?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"spinner",style:{borderTopColor:"var(--green)",borderColor:"var(--border-subtle)",width:10,height:10}}),"Saving..."]}):r.jsxs(r.Fragment,{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("path",{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"}),r.jsx("polyline",{points:"17 21 17 13 7 13 7 21"}),r.jsx("polyline",{points:"7 3 7 8 15 8"})]}),"Save as test cases"]})}),r.jsx("button",{onClick:I,disabled:w||!te||b,className:"text-[10px] px-2.5 py-1 rounded-md transition-colors duration-150 flex items-center gap-1.5",style:{background:w?"var(--surface-3)":"var(--surface-2)",color:te?"var(--accent)":"var(--text-tertiary)",border:"1px solid var(--border-subtle)",opacity:te?1:.5,cursor:te?"pointer":"not-allowed"},title:te?void 0:"No skill description available",onMouseEnter:Q=>{te&&!w&&(Q.currentTarget.style.background="var(--surface-3)")},onMouseLeave:Q=>{w||(Q.currentTarget.style.background="var(--surface-2)")},children:w?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"})}),q?"Regenerate":"Generate"," Test Prompts"]})})]})]}),z&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--green)",background:"var(--green-muted)"},"aria-live":"polite",children:z}),_&&r.jsxs("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},"aria-live":"polite",children:["Save failed: ",_]}),!te&&!b&&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."}),N&&r.jsx("div",{className:"text-[11px] px-2 py-1 rounded",style:{color:"var(--red)",background:"var(--red-muted)"},children:N}),r.jsx("textarea",{className:"input-field resize-y font-mono text-[12px]",style:{minHeight:140,height:140},value:B,onChange:Q=>U(Q.target.value),placeholder:`How do I write a unit test?
|
|
102
|
-
What edge cases should I test?
|
|
103
|
-
+Deploy this to production
|
|
104
|
-
!What's the weather like today?
|
|
105
|
-
!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(Ao,{}),r.jsx("span",{children:"No prefix = auto-classify"}),r.jsx(Ao,{}),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(Ao,{}),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(Ao,{}),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:M,disabled:b||!B.trim(),className:"btn btn-primary",children:b?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"]})}),b&&r.jsxs(r.Fragment,{children:[r.jsx("button",{onClick:i,className:"btn btn-secondary text-[12px]",children:"Cancel"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[C||`${y.length} / ${H} prompts tested`,E&&r.jsx(sN,{startedAt:E})]})]})]})]}),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:te?r.jsx("div",{className:"text-[12px] leading-relaxed",style:{color:"var(--text-secondary)"},dangerouslySetInnerHTML:{__html:ce}}):r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:"No description available"})})]})]}),S&&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:S}),b&&y.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..."})]}),y.length>0&&r.jsxs("div",{className:"space-y-5",children:[W.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 (",W.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:W.map((Q,ye)=>r.jsx(iv,{result:Q},`incorrect-${ye}`))})]}),D.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 (",D.length,")"]})]}),r.jsx("div",{className:"space-y-1.5 stagger-children",children:D.map((Q,ye)=>r.jsx(iv,{result:Q},`correct-${ye}`))})]})]}),v&&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"}),v.autoClassifiedCount!=null&&v.autoClassifiedCount>0&&r.jsxs("div",{className:"text-[11px] mb-3",style:{color:"var(--text-tertiary)"},children:[v.autoClassifiedCount," of ",v.total," prompts auto-classified from skill name and tags"]}),r.jsxs("div",{className:"grid grid-cols-3 gap-6 mb-5",children:[r.jsx(qd,{label:"Precision",value:v.precision,description:"Of all activations, how many were correct?",detail:`${v.tp} true / ${v.tp+v.fp} total activations`}),r.jsx(qd,{label:"Recall",value:v.recall,description:"Of expected activations, how many fired?",detail:`${v.tp} activated / ${v.tp+v.fn} expected`}),r.jsx(qd,{label:"Reliability",value:v.reliability,description:"Overall correct classification rate",detail:`${v.tp+v.tn} correct / ${v.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(Mo,{label:"True Positive",abbr:"TP",count:v.tp,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly activated"}),r.jsx(Mo,{label:"False Positive",abbr:"FP",count:v.fp,bg:"var(--red-muted)",color:"var(--red)",description:"Wrongly activated"}),r.jsx(Mo,{label:"False Negative",abbr:"FN",count:v.fn,bg:"var(--red-muted)",color:"var(--red)",description:"Missed activation"}),r.jsx(Mo,{label:"True Negative",abbr:"TN",count:v.tn,bg:"var(--green-muted)",color:"var(--green)",description:"Correctly silent"})]}),r.jsxs("div",{className:"mt-3 max-w-xs mx-auto text-center text-[11px]",style:{color:"var(--text-tertiary)"},title:"Auto-classified disagreements: not real failures, but worth reviewing. Hover a yellow row for details.",children:["Warnings:"," ",r.jsxs("span",{style:{color:(v.scopeWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[v.scopeWarnings??0," scope"]}),", ",r.jsxs("span",{style:{color:(v.driftWarnings??0)>0?"var(--yellow)":"var(--text-tertiary)"},children:[v.driftWarnings??0," drift"]})]})]})]}),r.jsx(rN,{history:P,expanded:J,onToggle:()=>$(!J),skillVersion:L})]})}function rN({history:t,expanded:a,onToggle:s,skillVersion:i}){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(aN,{run:c,skillVersion:i},c.id))})})]})}function aN({run:t,skillVersion:a}){const s=Math.round(t.summary.reliability*100),i=s>=80?"var(--green)":s>=60?"var(--yellow)":"var(--red)",c=s>=80?"Good":s>=60?"Needs Work":"Poor",u=i;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:lN(t.timestamp)}),r.jsx(oi,{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:i,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 lN(t){const a=Date.now(),s=new Date(t).getTime(),i=Math.floor((a-s)/1e3);if(i<60)return"just now";const c=Math.floor(i/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 Ao(){return r.jsx("span",{style:{color:"var(--border-subtle)",userSelect:"none"},children:"·"})}function iv({result:t}){const a=t.verdict==="scope_warning"||t.verdict==="drift_warning",s=a?t.verdict==="scope_warning"?"SCOPE_WARNING":"DRIFT_WARNING":t.classification,i=sv[s]||sv.FN,c=!a&&(t.classification==="TP"||t.classification==="TN"),u=t.verdict==="scope_warning"?"scope warn":t.verdict==="drift_warning"?"drift warn":null,d=t.verdict&&t.verdict!=="ok"?tN[t.verdict]:void 0;return r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-xl transition-all duration-200",style:{background:i.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, ${i.text} 20%, transparent)`},children:c?r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:r.jsx("polyline",{points:"20 6 9 17 4 12"})}):a?r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.text,strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"M10.29 3.86 1.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.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:i.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:i.text,fontWeight:700,fontSize:"10px",padding:"1px 6px"},title:d,children:u??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 qd({label:t,value:a,description:s,detail:i}){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:i})]})}function Mo({abbr:t,count:a,bg:s,color:i,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:i},children:a}),r.jsx("div",{className:"text-[11px] font-semibold",style:{color:i},children:t}),r.jsx("div",{className:"text-[9px] mt-0.5",style:{color:"var(--text-tertiary)"},children:c})]})}function sN({startedAt:t}){const[a,s]=p.useState(0);return p.useEffect(()=>{const i=setInterval(()=>s(Math.floor((Date.now()-t)/1e3)),1e3);return()=>clearInterval(i)},[t]),r.jsxs("span",{className:"ml-2",children:["(",a,"s)"]})}const Yd={benchmark:"#6383ff",comparison:"#a78bfa",baseline:"#fb923c"},ov={benchmark:"Benchmark",comparison:"Comparison",baseline:"Baseline"},Sf=600,kf=180,mn=40,Kd=Sf-mn*2,pa=kf-mn*2,iN=[25,50,75,100];function cv(t){return new Date(t).toLocaleDateString(void 0,{month:"short",day:"numeric"})}function oN(t){return t==null?"--":`${(t/1e3).toFixed(1)}s`}function cN({entries:t,onPointClick:a}){const[s,i]=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=mn+y/(u-1)*Kd,b=m.passRate*100,S=mn+pa-b/100*pa;return{x:v,y:S,pct:b,entry:m}}),h=d.map(m=>`${m.x},${m.y}`).join(" "),x=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:x.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:Yd[m]??"var(--text-tertiary)"}}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-secondary)"},children:ov[m]??m})]},m))}),r.jsxs("svg",{width:Sf,height:kf,viewBox:`0 0 ${Sf} ${kf}`,style:{display:"block",overflow:"visible"},children:[iN.map(m=>{const y=mn+pa-m/100*pa;return r.jsxs("g",{children:[r.jsx("line",{x1:mn,y1:y,x2:mn+Kd,y2:y,stroke:"var(--border-subtle)",strokeWidth:.5,strokeDasharray:"4 4"}),r.jsxs("text",{x:mn-8,y:y+3.5,textAnchor:"end",style:{fill:"var(--text-tertiary)",fontSize:10},children:[m,"%"]})]},m)}),r.jsx("line",{x1:mn,y1:mn+pa,x2:mn+Kd,y2:mn+pa,stroke:"var(--border-subtle)",strokeWidth:1}),r.jsx("text",{x:mn-8,y:mn+pa+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:Yd[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"),i({x:m.x,y:m.y,entry:m.entry})},onMouseLeave:v=>{v.currentTarget.setAttribute("r","5"),i(null)},onClick:()=>a==null?void 0:a(m.entry)},y)),uN(u).map(m=>r.jsx("text",{x:d[m].x,y:mn+pa+16,textAnchor:"middle",style:{fill:"var(--text-tertiary)",fontSize:10},children:cv(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:cv(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:Yd[s.entry.type]??"var(--text-tertiary)",color:"#fff"},children:ov[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:oN(s.entry.totalDurationMs)}),r.jsx("span",{children:s.entry.totalTokens!=null?`${s.entry.totalTokens} tokens`:"--"})]})]})]})}function uN(t){if(t<=3)return Array.from({length:t},(i,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 i=a;i<t-1;i+=a)s.push(i);return s.push(t-1),s}const Fs=new Map;let hn=null,Vo=null,Lo=1e3,_l=0;function ib(){if(hn)return;hn=new EventSource("/api/events");const t=a=>s=>{let i={};try{i=s.data?JSON.parse(s.data):{}}catch{}const c=Fs.get(a);if(c)for(const u of c)u(i)};hn.addEventListener("benchmark:complete",t("benchmark:complete")),hn.addEventListener("history:written",t("history:written")),hn.addEventListener("leaderboard:updated",t("leaderboard:updated")),hn.onerror=()=>{hn==null||hn.close(),hn=null,_l>0&&(Vo=setTimeout(()=>{Lo=Math.min(Lo*2,3e4),ib()},Lo))},hn.onopen=()=>{Lo=1e3}}function dN(){Vo!=null&&(clearTimeout(Vo),Vo=null),hn==null||hn.close(),hn=null}function fN(t,a){return Fs.has(t)||Fs.set(t,new Set),Fs.get(t).add(a),_l++,ib(),()=>{var s;(s=Fs.get(t))==null||s.delete(a),_l--,_l<=0&&(_l=0,queueMicrotask(()=>{_l<=0&&dN()}))}}function Ko(t,a){const s=p.useRef(a);s.current=a,p.useEffect(()=>fN(t,c=>s.current(c)),[t])}function Xo(t){return t>=.8?"var(--green)":t>=.5?"var(--yellow)":"var(--red)"}function pN(t){return t>=1e3?`${(t/1e3).toFixed(1)}s`:`${Math.round(t)}ms`}function mN({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:Xo(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:Xo(t)}})})]})})}function hN({points:t}){if(t.length<2)return null;const a=200,s=48,i=4,c=t.length,u=t.map((x,m)=>{const y=i+m/(c-1)*(a-i*2),v=i+(s-i*2)-x.passRate*(s-i*2);return{x:y,y:v}}),d=`M ${u[0].x},${s-i} `+u.map(x=>`L ${x.x},${x.y}`).join(" ")+` L ${u[u.length-1].x},${s-i} Z`,h=u.map((x,m)=>`${m===0?"M":"L"} ${x.x},${x.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 xN({plugin:t,skill:a}){const s=`stats/${t}/${a}`,i=p.useCallback(()=>ke.getStats(t,a),[t,a]),{data:c,loading:u}=qa(s,i),d=p.useCallback(()=>Bn(s),[s]);if(Ko("benchmark:complete",d),Ko("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,x=c.trendPoints.length>0?c.trendPoints[0].passRate:0,m=h-x,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:Xo(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:$n(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:$n(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(hN,{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:Xo(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:pN(v.avgDurationMs)}),r.jsx("td",{style:{padding:"8px",textAlign:"center",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)"},children:v.avgCost!=null?$n(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(mN,{rate:v.passRate,label:v.text})]},`${v.evalId}:${v.id}`))})]})]})}function gN({plugin:t,skill:a}){const[s,i]=p.useState(null),[c,u]=p.useState(null),[d,h]=p.useState({}),[x,m]=p.useState({});p.useEffect(()=>{ke.getEvals(t,a).then(i).catch(()=>i(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 ke.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,E=x[v.id],C=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:w=>{S||(w.currentTarget.style.background="var(--surface-2)")},onMouseLeave:w=>{S||(w.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(nb,{entries:b}),C!=null&&r.jsxs("span",{className:"text-[12px] font-semibold flex-shrink-0",style:{color:$l(C)},children:[Math.round(C*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:E?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((w,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:eb(w.timestamp)}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:w.model}),r.jsx("span",{className:"pill",style:{fontSize:9,padding:"1px 6px",background:w.type==="benchmark"?"rgba(99,131,255,0.15)":w.type==="comparison"?"var(--purple-muted)":"rgba(251,146,60,0.15)",color:w.type==="benchmark"?"#6383ff":w.type==="comparison"?"var(--purple)":"#fb923c"},children:w.type}),r.jsxs("span",{className:"text-[12px] font-semibold ml-auto",style:{color:$l(w.pass_rate)},children:[Math.round(w.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:[w.durationMs!=null&&r.jsx("span",{children:tb(w.durationMs)}),w.tokens!=null&&r.jsxs("span",{children:[w.tokens>=1e3?`${(w.tokens/1e3).toFixed(1)}k`:w.tokens," tok"]})]}),r.jsx("div",{className:"space-y-1",children:w.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 uv(){const{state:t,dispatch:a}=Un(),{plugin:s,skill:i}=t,{state:c}=cr(),u=c.skills.find(F=>F.plugin===s&&F.skill===i),d=(u==null?void 0:u.resolvedVersion)??(u==null?void 0:u.version)??null,[h,x]=p.useState("timeline"),[m,y]=p.useState(""),[v,b]=p.useState(""),[S,E]=p.useState(!1),[C,w]=p.useState([]),[N,T]=p.useState(null),[R,_]=p.useState(!1),[z,P]=p.useState(null),[k,O]=p.useState(!1),L=`history/${s}/${i}?model=${m}&type=${v}`,B=p.useCallback(()=>ke.getHistory(s,i,{model:m||void 0,type:v||void 0}),[s,i,m,v]),{data:U,loading:Y}=qa(L,B),X=U??[];p.useEffect(()=>{!U||U.length<2||ke.compareRuns(s,i,U[0].timestamp,U[1].timestamp).then(F=>{const H=F.regressions.filter(re=>re.change==="regression");a({type:"SET_REGRESSIONS",regressions:H})}).catch(()=>{})},[U,s,i,a]);const J=p.useCallback(()=>Bn(L),[L]);Ko("history:written",J);const $=p.useCallback(async F=>{if(S){w(H=>H.includes(F)?H.filter(re=>re!==F):H.length>=2?[H[1],F]:[...H,F]);return}O(!0);try{const H=await ke.getHistoryEntry(s,i,F);P(H)}catch{}finally{O(!1)}},[s,i,S]),M=p.useCallback(async()=>{if(C.length===2){_(!0);try{const F=await ke.compareRuns(s,i,C[0],C[1]);T(F)}catch{}finally{_(!1)}}},[s,i,C]),I=[...new Set(X.map(F=>F.model))];return Y?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(F=>r.jsx("button",{onClick:()=>x(F),className:"px-4 py-2 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:h===F?"var(--accent-muted)":"transparent",color:h===F?"var(--accent)":"var(--text-tertiary)"},children:F==="timeline"?"Timeline":F==="per-eval"?"Per Eval":"Statistics"},F))}),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(cN,{entries:X,onPointClick:F=>$(F.timestamp)})}),r.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[r.jsxs("select",{value:m,onChange:F=>y(F.target.value),className:"input-field text-[12px]",style:{width:150},children:[r.jsx("option",{value:"",children:"All Models"}),I.map(F=>r.jsx("option",{value:F,children:F},F))]}),r.jsxs("select",{value:v,onChange:F=>b(F.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:()=>{E(!S),w([]),T(null)},className:`btn text-[12px] ${S?"btn-primary":"btn-secondary"}`,children:S?"Exit Compare":"Compare Runs"}),S&&C.length===2&&r.jsx("button",{onClick:M,disabled:R,className:"btn btn-primary text-[12px]",children:R?"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(F=>{const H=C.includes(F.timestamp);return r.jsx("button",{onClick:()=>$(F.timestamp),className:"w-full text-left rounded-lg px-4 py-3 transition-all duration-150",style:{background:H?"var(--accent-muted)":"var(--surface-1)",border:H?"1px solid var(--accent)":"1px solid var(--border-subtle)"},onMouseEnter:re=>{H||(re.currentTarget.style.borderColor="var(--border-hover)")},onMouseLeave:re=>{H||(re.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:H?"var(--accent)":"var(--border-default)",background:H?"var(--accent)":"transparent"},children:H&&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(F.timestamp).toLocaleString()}),r.jsx("span",{className:"pill text-[9px]",style:{background:F.type==="comparison"?"var(--purple-muted)":F.type==="baseline"?"var(--surface-3)":F.type==="model-compare"?"var(--accent-muted)":F.type==="improve"||F.type==="instruct"?"var(--purple-muted)":F.type==="ai-generate"?"var(--green-muted)":F.type==="eval-generate"?"var(--orange-muted)":"var(--accent-muted)",color:F.type==="comparison"?"var(--purple)":F.type==="baseline"?"var(--text-tertiary)":F.type==="model-compare"?"var(--accent)":F.type==="improve"||F.type==="instruct"?"var(--purple)":F.type==="ai-generate"?"var(--green)":F.type==="eval-generate"?"var(--orange)":"var(--accent)"},children:F.type==="model-compare"?"model compare":F.type==="improve"?"ai improve":F.type==="instruct"?"ai edit":F.type==="ai-generate"?"ai generate":F.type==="eval-generate"?"eval generate":F.type})]}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx(oi,{version:d,size:"sm","data-testid":"history-row-version"}),r.jsx("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:F.model}),F.totalCost!=null&&F.totalCost>0&&r.jsx("span",{className:"text-[11px] font-mono",style:{color:"var(--text-tertiary)"},children:$n(F.totalCost)}),r.jsxs("span",{className:"text-[12px] font-semibold",style:{color:F.passRate>=.8?"var(--green)":F.passRate>=.5?"var(--yellow)":"var(--red)"},children:[Math.round(F.passRate*100),"%"]})]})]})},F.timestamp)})}),N&&r.jsx(vN,{result:N}),z&&!S&&r.jsx(yN,{run:z,onClose:()=>P(null)})]}),h==="per-eval"&&r.jsx(gN,{plugin:s,skill:i}),h==="statistics"&&r.jsx(xN,{plugin:s,skill:i})]})}function vN({result:t}){const a=t.regressions.filter(i=>i.change==="regression"),s=t.regressions.filter(i=>i.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: ",$n(t.runA.totalCost??null)]}),r.jsxs("span",{children:["Run B cost: ",$n(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: ",$n(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(i=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",i.evalId," ",i.evalName,": ",r.jsx("span",{style:{color:"var(--red)"},children:i.assertionId})," (was passing, now failing)"]},`${i.evalId}-${i.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(i=>r.jsxs("div",{className:"text-[12px] py-1",style:{color:"var(--text-secondary)"},children:["#",i.evalId," ",i.evalName,": ",r.jsx("span",{style:{color:"var(--green)"},children:i.assertionId})," (was failing, now passing)"]},`${i.evalId}-${i.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(i=>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:["#",i.eval_id," ",i.eval_name]}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:i.passRateA!=null?i.passRateA>=.8?"var(--green)":i.passRateA>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:i.passRateA!=null?`${Math.round(i.passRateA*100)}%`:i.statusA}),r.jsx("td",{className:"text-right px-3 py-2",style:{color:i.passRateB!=null?i.passRateB>=.8?"var(--green)":i.passRateB>=.5?"var(--yellow)":"var(--red)":"var(--text-tertiary)"},children:i.passRateB!=null?`${Math.round(i.passRateB*100)}%`:i.statusB})]},i.eval_id))})]})})]})}function yN({run:t,onClose:a}){return(t.type==="improve"||t.type==="instruct")&&t.improve?r.jsx(bN,{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: ${$n(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:$n(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 bN({run:t,onClose:a}){var u;const s=p.useMemo(()=>t.improve?cc(t.improve.original,t.improve.improved):[],[t.improve]),i=p.useMemo(()=>{const d=s.filter(x=>x.type==="added").length,h=s.filter(x=>x.type==="removed").length;return{added:d,removed:h}},[s]),c=p.useMemo(()=>{let d=0,h=0;return s.map(x=>x.type==="removed"?(d++,{...x,origNum:d,newNum:null}):x.type==="added"?(h++,{...x,origNum:null,newNum:h}):(d++,h++,{...x,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:["+",i.added]}),r.jsxs("span",{style:{color:"var(--red)"},children:["-",i.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 ob({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,i=24,c=2,u=s-c*2,d=i-c*2,h=a.length,x=Math.min(...a),y=Math.max(...a)-x||1,v=a.map((E,C)=>{const w=c+C/(h-1)*u,N=c+d-(E-x)/y*d;return`${w.toFixed(1)},${N.toFixed(1)}`}),b=a[a.length-1],S=$l(b);return r.jsxs("svg",{width:s,height:i,viewBox:`0 0 ${s} ${i}`,style:{display:"block"},children:[r.jsx("polyline",{points:v.join(" "),fill:"none",stroke:S,strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"}),(()=>{const[E,C]=v[v.length-1].split(",");return r.jsx("circle",{cx:E,cy:C,r:2.5,fill:S})})()]})}function jN(){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 SN({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)",i=t>=0?"+":"";return r.jsxs("span",{className:"pill",style:{background:s,color:a,fontSize:10,fontWeight:600},children:[i,t.toFixed(1),"%"]})}function kN({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)"}},i=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:i.bg,color:i.fg,fontSize:11,fontWeight:600},children:[c,t.toFixed(1),"% (",a.toUpperCase(),")"]})]})}function wN({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 CN({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 EN(t){var i,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 x=`${h.provider}/${h.model}`;a.has(x)||a.set(x,{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(x);m.passRates.push(h.passRate.mean),m.lastRubric=((i=h.rubricScore)==null?void 0:i.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[x,...m]=d.split("/");s.push({rank:0,model:m.join("/"),provider:x,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 x=d.compositeScore??d.passRate;return(h.compositeScore??h.passRate)-x}),s.forEach((d,h)=>{d.rank=h+1}),s.length>0&&(s[0].isBest=!0),s}const cb=(t="left")=>({padding:"10px 12px",fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--text-tertiary)",textAlign:t,whiteSpace:"nowrap"});function NN({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:cb(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(jN,{})]})}),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:$l(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(ob,{data:a.sparklineData})})]},`${a.provider}/${a.model}`))})]})})}function TN({entries:t}){const a=[...t].filter(s=>s.hasBaseline).sort((s,i)=>(i.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:cb(s==="#"?"center":"left"),children:s},s))})}),r.jsx("tbody",{children:a.map((s,i)=>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:i+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:$l(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(SN,{pct:s.amplificationPct}):"--"}),r.jsx("td",{style:{padding:"10px 12px"},children:r.jsx(ob,{data:s.sparklineData})})]},`${s.provider}/${s.model}`))})]})})}function dv(){const{state:t}=Un(),{plugin:a,skill:s}=t,[i,c]=p.useState("rankings"),u=`leaderboard/${a}/${s}`,d=p.useCallback(()=>ke.getLeaderboard(a,s),[a,s]),{data:h,loading:x,error:m}=qa(u,d),y=(h==null?void 0:h.entries)??[],v=(m==null?void 0:m.message)??null;p.useEffect(()=>{c("rankings")},[a,s]);const b=p.useCallback(()=>Bn(u),[u]);Ko("leaderboard:updated",b);const S=p.useMemo(()=>EN(y),[y]),E=S.some(N=>N.hasBaseline),C=y[0],w=C==null?void 0:C.judgeBiasWarning;return x?r.jsx("div",{className:"flex items-center justify-center h-full",children:r.jsx("div",{className:"spinner spinner-lg"})}):v?r.jsx("div",{className:"flex items-center justify-center h-full px-8",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-[14px] font-medium mb-1",style:{color:"var(--red)"},children:"Failed to load leaderboard"}),r.jsx("div",{className:"text-[12px]",style:{color:"var(--text-tertiary)"},children:v})]})}):S.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(CN,{active:i,onChange:c,hasBaseline:E})]}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[y.length," sweep",y.length!==1?"s":""," · ",S.length," model",S.length!==1?"s":""]})]}),w&&r.jsx(wN,{warning:w}),i==="rankings"?r.jsx(NN,{entries:S}):r.jsx(TN,{entries:S}),i==="amplification"&&(C==null?void 0:C.skillQualityScore)!=null&&(C==null?void 0:C.skillQualityRating)&&r.jsx(kN,{score:C.skillQualityScore,rating:C.skillQualityRating})]})}function ub({plugin:t,skill:a}){const[s,i]=p.useState([]),[c,u]=p.useState([]),[d,h]=p.useState(!0),[x,m]=p.useState(null);p.useEffect(()=>{ke.getDependencies(t,a).then(v=>{i(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:x===v.server?"var(--green)":"var(--accent)"},children:x===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 wf({plugin:t,skill:a}){const[s,i]=p.useState([]),[c,u]=p.useState(!0),[d,h]=p.useState(null),[x,m]=p.useState(""),[y,v]=p.useState(!1),[b,S]=p.useState(null),[E,C]=p.useState(""),[w,N]=p.useState(""),[T,R]=p.useState(!1),[_,z]=p.useState(new Set),P=p.useCallback(async()=>{u(!0);try{const[B,U]=await Promise.all([ke.getCredentials(t,a).catch(()=>({credentials:[]})),ke.getParams(t,a).catch(()=>({params:[]}))]),Y=new Map(U.params.map($=>[$.name,$])),X=new Set,J=[];for(const $ of B.credentials){X.add($.name);const M=Y.get($.name);J.push({name:$.name,status:$.status==="ready"||$.status==="resolved"?"ready":"missing",source:$.source,maskedValue:M==null?void 0:M.maskedValue})}for(const $ of U.params)X.has($.name)||J.push({name:$.name,status:$.status,maskedValue:$.maskedValue});i(J)}finally{u(!1)}},[t,a]);p.useEffect(()=>{P()},[P]);const k=p.useCallback(async B=>{if(_.has(B)){z(U=>{const Y=new Set(U);return Y.delete(B),Y}),i(U=>U.map(Y=>Y.name===B?{...Y,revealedValue:void 0}:Y));return}try{const Y=(await ke.getParamsRevealed(t,a,B)).params.find(X=>X.name===B);Y&&(i(X=>X.map(J=>J.name===B?{...J,revealedValue:Y.value}:J)),z(X=>new Set(X).add(B)))}catch{}},[t,a,_]),O=async(B,U)=>{if(!(!B.trim()||!U.trim())){v(!0),S(null);try{await ke.setCredential(t,a,B,U),h(null),m(""),z(new Set),P()}catch(Y){S(Y.message)}finally{v(!1)}}},L=async()=>{if(!(!E.trim()||!w.trim())){v(!0),S(null);try{await ke.setCredential(t,a,E.trim().toUpperCase(),w),C(""),N(""),R(!1),P()}catch(B){S(B.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:()=>R(!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(B=>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:B.name}),B.maskedValue&&r.jsx("span",{className:"text-[10px] font-mono truncate",style:{color:"var(--text-tertiary)",maxWidth:120},children:_.has(B.name)&&B.revealedValue!=null?B.revealedValue:B.maskedValue}),B.maskedValue&&r.jsx("button",{onClick:()=>k(B.name),className:"btn btn-ghost px-1",title:_.has(B.name)?"Hide value":"Reveal value",style:{color:"var(--text-tertiary)",lineHeight:1},children:_.has(B.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:B.status==="ready"?"var(--green-muted)":"var(--orange-muted)",color:B.status==="ready"?"var(--green)":"var(--orange)"},children:B.status==="ready"?"ready":"missing"}),B.source&&r.jsx("span",{className:"text-[9px]",style:{color:"var(--text-tertiary)"},children:B.source}),d===B.name?r.jsxs("div",{className:"flex items-center gap-1.5",children:[r.jsx("input",{value:x,onChange:U=>m(U.target.value),onKeyDown:U=>{U.key==="Enter"&&O(B.name,x)},className:"input-field text-[11px] font-mono",style:{width:160},placeholder:"Value...",autoFocus:!0}),r.jsx("button",{onClick:()=>O(B.name,x),disabled:y||!x.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(B.name),m("")},className:"btn btn-ghost text-[10px] px-2 py-0.5",style:{color:"var(--accent)"},children:"Edit"})]},B.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:E,onChange:B=>C(B.target.value),className:"input-field flex-1 text-[11px] font-mono",placeholder:"KEY_NAME",autoFocus:!0}),r.jsx("input",{value:w,onChange:B=>N(B.target.value),onKeyDown:B=>{B.key==="Enter"&&L()},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:()=>{R(!1),C(""),N("")},className:"btn btn-ghost text-[10px]",children:"Cancel"}),r.jsx("button",{onClick:L,disabled:y||!E.trim()||!w.trim(),className:"btn btn-primary text-[10px]",children:y?"Saving...":"Save"})]})]})]})}function RN(){const{state:t}=Un(),{plugin:a,skill:s}=t,[i,c]=p.useState(null),[u,d]=p.useState(!0);return p.useEffect(()=>{ke.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"})]}):i?r.jsxs("div",{className:"p-5 max-w-3xl",children:[r.jsx(ub,{plugin:a,skill:s}),r.jsx(wf,{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(wf,{plugin:a,skill:s})]})}function AN(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 MN(t){var c;const a=t.userName.trim().length>0,s=t.userPlugin.trim().length>0||t.userNewPlugin.trim().length>0,i=t.forceLayout===3;return{applyName:a?null:t.aiName??null,applySuggestedPlugin:!i&&!s&&!!((c=t.aiSuggestedPlugin)!=null&&c.plugin),suggestedPluginValue:i||s?null:t.aiSuggestedPlugin??null}}function Qo(t,a=!0){let s=t.toLowerCase().replace(/[^a-z0-9]+/g,"-");return a&&(s=s.replace(/^-+|-+$/g,"")),s}function LN(t,a,s,i){const u=`.../${t.split("/").slice(-2).join("/")}`;switch(a){case 1:return`${u}/${s}/skills/${i}/SKILL.md`;case 2:return`${u}/plugins/${s}/skills/${i}/SKILL.md`;case 3:return`${u}/skills/${i}/SKILL.md`}}function zN({onCreated:t,resolveAiConfigOverride:a,forceLayout:s,flushPendingForSkillName:i}){const[c,u]=p.useState("ai"),[d,h]=p.useState(null),[x,m]=p.useState(!0),{config:y}=Ya(),[v,b]=p.useState(""),[S,E]=p.useState(s??3),[C,w]=p.useState(""),[N,T]=p.useState(""),[R,_]=p.useState(""),[z,P]=p.useState(""),[k,O]=p.useState(""),[L,B]=p.useState(""),[U,Y]=p.useState("write"),[X,J]=p.useState([]),[$,M]=p.useState(!1),[I,F]=p.useState(null),[H,re]=p.useState(null),[D,W]=p.useState(null),[te,q]=p.useState("vskill"),[ce,Q]=p.useState("1.0.0"),[ye,oe]=p.useState(!0),be=p.useCallback(async()=>{try{const Ue=await ke.detectEngines();W(Ue),q(lt=>lt!=="vskill"?lt:Ue.vskillSkillBuilder?"vskill":Ue.anthropicSkillCreator?"anthropic-skill-creator":"none")}catch{W({vskillSkillBuilder:!1,anthropicSkillCreator:!1,vskillVersion:null,anthropicPath:null})}},[]);p.useEffect(()=>{be()},[be]);const[Ne,Be]=p.useState(""),[Le,Pe]=p.useState(!1),[se,de]=p.useState(!1),[me,ve]=p.useState(null),[je,Ve]=p.useState(null),[ct,Nt]=p.useState([]),tn=p.useRef(null),bt=p.useRef(null),Ge=p.useRef(null),pt=p.useRef(null),mt=p.useRef(null),[jt,Kt]=p.useState(!1),[xe,tt]=p.useState(!1),it=p.useRef(v),Tt=p.useRef(C),Lt=p.useRef(N);p.useEffect(()=>{it.current=v},[v]),p.useEffect(()=>{Tt.current=C},[C]),p.useEffect(()=>{Lt.current=N},[N]),p.useEffect(()=>{ke.getProjectLayout().then(Ue=>{if(h(Ue),s)return;E(Ue.suggestedLayout);const lt=Ue.detectedLayouts.find(Qt=>Qt.layout===Ue.suggestedLayout);lt!=null&<.existingPlugins.length&&w(lt.existingPlugins[0])}).catch(()=>{}).finally(()=>m(!1))},[s]),p.useEffect(()=>{var Ue;c==="ai"&&((Ue=tn.current)==null||Ue.focus())},[c]),p.useEffect(()=>()=>{var Ue;(Ue=bt.current)==null||Ue.abort()},[]);const ut=p.useMemo(()=>{var Ue;return d?((Ue=d.detectedLayouts.find(lt=>lt.layout===S))==null?void 0:Ue.existingPlugins)||[]:[]},[d,S]),Bt=C==="__new__"?N:C,It=d?LN(d.root,S,Bt||"{plugin}",v||"{skill}"):"",yr=p.useMemo(()=>d?d.detectedLayouts.filter(Ue=>Ue.layout!==4):[],[d]),Xt=p.useMemo(()=>{if(!d)return null;const Ue=d.detectedLayouts.find(rn=>rn.layout===2&&rn.existingPlugins.length>0),lt=d.detectedLayouts.find(rn=>rn.layout===1&&rn.existingPlugins.length>0),Qt=Ue||lt;return Qt?{layout:Qt.layout,plugins:Qt.existingPlugins}:null},[d]),gn=p.useCallback(()=>{if(a)return a();if(!y)return{provider:"claude-cli",model:"sonnet"};const Ue=y.provider||"claude-cli",lt=y.model||"sonnet";return{provider:Ue,model:lt}},[y,a]),Cn=p.useCallback(()=>{var Ue;(Ue=bt.current)==null||Ue.abort(),Pe(!1)},[]),Hn=p.useCallback(()=>{ve(null),Ve(null)},[]),vn=p.useCallback(async()=>{var rn,ie;if(ve(null),Ve(null),Nt([]),Ge.current=null,pt.current=null,!Ne.trim()){ve("Describe what your skill should do");return}Pe(!0);const Ue=new AbortController;bt.current=Ue;const{provider:lt,model:Qt}=gn();try{const Se=await fetch("/api/skills/generate?sse",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(AN({prompt:Ne.trim(),provider:lt,model:Qt,targetAgents:X})),signal:Ue.signal});if(!Se.ok||!Se.body){let Vr=`HTTP ${Se.status}`;try{const ja=await Se.json();ja.error&&(Vr=ja.error)}catch{}throw new Error(Vr)}const Ae=Se.body.getReader(),En=new TextDecoder;let Pr="",nr="";for(;;){const{done:Vr,value:ja}=await Ae.read();if(Vr)break;Pr+=En.decode(ja,{stream:!0});const Gl=Pr.split(`
|
|
106
|
-
`);Pr=Gl.pop()||"";for(const Nn of Gl)if(Nn.startsWith("event: "))nr=Nn.slice(7).trim();else if(Nn.startsWith("data: ")){try{const He=JSON.parse(Nn.slice(6));if(nr==="progress")Nt(Ft=>[...Ft,{phase:He.phase,message:He.message,timestamp:Date.now()}]);else if(nr==="provenance")pt.current={resolvedModelId:typeof He.resolvedModelId=="string"?He.resolvedModelId:null,snapshotDate:typeof He.snapshotDate=="string"?He.snapshotDate:null};else if(nr==="done"||nr==="complete"){const Ft={prompt:Ne.trim(),provider:gn().provider,model:gn().model,resolvedModelId:((rn=pt.current)==null?void 0:rn.resolvedModelId)??null,snapshotDate:((ie=pt.current)==null?void 0:ie.snapshotDate)??null,reasoning:He.reasoning||""},Tn=MN({userName:it.current,userPlugin:Tt.current,userNewPlugin:Lt.current,aiName:He.name,aiSuggestedPlugin:He.suggestedPlugin&&He.suggestedPlugin.plugin?{plugin:He.suggestedPlugin.plugin,layout:He.suggestedPlugin.layout}:null,forceLayout:s});if(Tn.applyName!==null&&b(Tn.applyName),_(He.description),P(He.model||""),O(He.allowedTools||""),B(He.body),de(!0),Ge.current=Ft,u("manual"),s===3)E(3),w(""),T("");else if(Tn.applySuggestedPlugin&&Tn.suggestedPluginValue){const fn=Tn.suggestedPluginValue;if(((d==null?void 0:d.detectedLayouts.flatMap(br=>br.existingPlugins))??[]).includes(fn.plugin))if(w(fn.plugin),fn.layout&&(fn.layout===1||fn.layout===2))E(fn.layout);else{const br=d==null?void 0:d.detectedLayouts.find(Sa=>Sa.existingPlugins.includes(fn.plugin));br&&(br.layout===1||br.layout===2)&&E(br.layout)}else w("__new__"),T(fn.plugin)}else!Tn.applySuggestedPlugin&&Tt.current.trim().length===0&&Lt.current.trim().length===0&&S===3&&Xt&&tt(!0);const Wl={name:He.name,plugin:Bt||"",layout:S,description:He.description,model:He.model||void 0,allowedTools:He.allowedTools||void 0,body:He.body,aiMeta:Ft};ke.saveDraft(Wl).then(fn=>{Kt(!0),fn!=null&&fn.dir&&(mt.current=fn.dir)}).catch(()=>{})}else nr==="error"&&(ve(He.message||He.description||"Unknown error"),He.category&&Ve(He))}catch{}nr=""}}}catch(Se){Se.name!=="AbortError"&&ve(Se.message)}finally{Pe(!1),bt.current=null}},[Ne,gn,S,Xt,Bt,d,X,s]),St=p.useCallback(async()=>{var Ue;if(F(null),re(null),!v.trim()){F("Skill name is required");return}if(!R.trim()){F("Description is required");return}if(S!==3&&!Bt.trim()){F("Plugin name is required");return}if(!ye){F("Version is not valid semver");return}M(!0);try{const lt=Qo(v);i&&await i(lt);const Qt=await ke.createSkill({name:lt,plugin:Bt||"",layout:S,description:R,model:z||void 0,allowedTools:k||void 0,body:L,aiMeta:Ge.current||void 0,draftDir:mt.current||void 0,version:ce.trim()||void 0,engine:te});mt.current=null,t(Qt.plugin,Qt.skill)}catch(lt){if(lt instanceof Ga&<.status===409&&((Ue=lt.details)==null?void 0:Ue.code)==="skill-already-exists"){const Qt=typeof lt.details.plugin=="string"?lt.details.plugin:"",rn=typeof lt.details.skill=="string"?lt.details.skill:Qo(v);re("Skill already existed — opened it."),mt.current=null,t(Qt,rn)}else F(lt.message)}finally{M(!1)}},[v,R,S,Bt,z,k,L,ce,ye,te,t,i]),nn=p.useCallback(()=>{Xt&&(E(Xt.layout),w(Xt.plugins[0]),tt(!1))},[Xt]);return{mode:c,setMode:u,layout:d,layoutLoading:x,selectedLayout:S,setSelectedLayout:E,creatableLayouts:yr,availablePlugins:ut,pathPreview:It,plugin:C,setPlugin:w,newPlugin:N,setNewPlugin:T,effectivePlugin:Bt,name:v,setName:b,description:R,setDescription:_,model:z,setModel:P,allowedTools:k,setAllowedTools:O,body:L,setBody:B,bodyViewMode:U,setBodyViewMode:Y,aiPrompt:Ne,setAiPrompt:Be,generating:Le,aiGenerated:se,aiError:me,aiClassifiedError:je,aiProgress:ct,promptRef:tn,handleGenerate:vn,handleCancelGenerate:Cn,clearAiError:Hn,targetAgents:X,setTargetAgents:J,draftSaved:jt,showPluginRecommendation:xe,setShowPluginRecommendation:tt,pluginLayoutInfo:Xt,applyPluginRecommendation:nn,creating:$,error:I,info:H,handleCreate:St,engineDetection:D,refreshEngineDetection:be,engine:te,setEngine:q,version:ce,setVersion:Q,versionValid:ye,setVersionValid:oe,standaloneLocked:s===3}}function db(){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 DN(){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 fb({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(db,{}):r.jsx(DN,{}),r.jsxs("span",{children:[t.name,t.type==="dir"?"/":""]})]}),(s=t.children)==null?void 0:s.map(i=>r.jsx(fb,{node:i,depth:a+1},i.name))]})}function _N(t,a,s){const i=[];a&&i.push({name:"evals.json",type:"file"}),i.push({name:"history",type:"dir"});const c=[{name:"SKILL.md",type:"file"},{name:"evals",type:"dir",children:i}];return s&&c.push({name:"draft.json",type:"file"}),{name:t||"{skill}",type:"dir",children:c}}function ON({skillName:t,hasEvals:a,isDraft:s}){const i=_N(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(db,{})}),"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(fb,{node:i})})]})}const BN={flushBySkillName:async()=>{}},pb=p.createContext(BN);function IN(){return p.useContext(pb)}const ma={background:"var(--surface-3)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)"};function Xd({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 $N({onCreated:t,onCancel:a}){const{flushBySkillName:s}=IN(),i=zN({onCreated:t,flushPendingForSkillName:s});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:()=>i.setMode("ai"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:i.mode==="ai"?"rgba(168,85,247,0.15)":"transparent",color:i.mode==="ai"?"#a855f7":"var(--text-tertiary)",boxShadow:i.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(Xd,{size:12}),"AI-Assisted"]})}),r.jsx("button",{onClick:()=>i.setMode("manual"),className:"px-3 py-1.5 rounded-md text-[12px] font-medium transition-all duration-200",style:{background:i.mode==="manual"?"var(--surface-4, var(--surface-3))":"transparent",color:i.mode==="manual"?"var(--text-primary)":"var(--text-tertiary)",boxShadow:i.mode==="manual"?"0 1px 3px rgba(0,0,0,0.1)":"none",cursor:"pointer",border:"none"},children:"Manual"})]})})]}),i.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"})]}),!i.layoutLoading&&i.layout&&i.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(Xd,{size:11,color:"#a855f7"})}),"Describe Your Skill"]}),r.jsx("textarea",{ref:i.promptRef,value:i.aiPrompt,onChange:c=>i.setAiPrompt(c.target.value),placeholder:`e.g., A skill that helps format SQL queries, optimize them for performance, and explain query execution plans.
|
|
107
|
-
|
|
108
|
-
Include any specific behaviors, constraints, or output formats you want.`,rows:5,disabled:i.generating,className:"w-full px-3 py-2.5 rounded-lg text-[13px] resize-y",style:{...ma,minHeight:"120px"},onKeyDown:c=>{c.key==="Enter"&&(c.metaKey||c.ctrlKey)&&(c.preventDefault(),i.handleGenerate())}}),r.jsx("p",{className:"text-[11px] mt-2",style:{color:"var(--text-quaternary, var(--text-tertiary))"},children:"Cmd+Enter to generate"})]}),i.generating&&i.aiProgress.length>0&&r.jsx(ui,{entries:i.aiProgress,isRunning:!0}),i.aiError&&r.jsx("div",{children:i.aiClassifiedError?r.jsx(uc,{error:i.aiClassifiedError,onRetry:i.handleGenerate,onDismiss:i.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:i.aiError}),r.jsx("button",{onClick:i.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:[i.generating?r.jsx("button",{onClick:i.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:i.handleGenerate,disabled:!i.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:i.aiPrompt.trim()?"#a855f7":"var(--surface-3)",color:i.aiPrompt.trim()?"#fff":"var(--text-tertiary)",cursor:i.aiPrompt.trim()?"pointer":"not-allowed",border:"none"},children:[r.jsx(Xd,{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"}),!i.generating&&r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:["or fill in the form manually",r.jsx("button",{onClick:()=>i.setMode("manual"),className:"ml-1 font-medium",style:{color:"var(--accent)",background:"none",border:"none",cursor:"pointer"},children:"below"})]})]})]}),!i.layoutLoading&&i.layout&&i.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"}),i.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:i.creatableLayouts.map(c=>r.jsx("button",{onClick:()=>{i.setSelectedLayout(c.layout),i.setPlugin(c.existingPlugins[0]||""),i.setNewPlugin("")},className:"px-3 py-1.5 rounded-lg text-[12px] font-medium transition-all duration-150",style:{background:i.selectedLayout===c.layout?"var(--accent)":"var(--surface-3)",color:i.selectedLayout===c.layout?"#fff":"var(--text-secondary)",border:`1px solid ${i.selectedLayout===c.layout?"var(--accent)":"var(--border-subtle)"}`,cursor:"pointer"},children:c.label},c.layout))})]}),i.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:i.plugin,onChange:c=>{i.setPlugin(c.target.value),i.setNewPlugin("")},className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ma,children:[i.availablePlugins.map(c=>r.jsx("option",{value:c,children:c},c)),r.jsx("option",{value:"__new__",children:"+ New plugin..."})]}),i.plugin==="__new__"&&r.jsx("input",{type:"text",value:i.newPlugin,onChange:c=>i.setNewPlugin(Qo(c.target.value)),placeholder:"my-plugin",className:"w-full mt-2 px-3 py-2 rounded-lg text-[13px]",style:ma})]}),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:i.pathPreview})]}),i.showPluginRecommendation&&i.pluginLayoutInfo&&i.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:i.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:i.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:()=>i.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:i.name,onChange:c=>i.setName(Qo(c.target.value,!1)),placeholder:"my-skill",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ma})]}),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:i.description,onChange:c=>i.setDescription(c.target.value),placeholder:"Brief description",rows:3,className:"w-full px-3 py-2 rounded-lg text-[13px] resize-y",style:{...ma,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:i.model,onChange:c=>i.setModel(c.target.value),className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ma,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:i.allowedTools,onChange:c=>i.setAllowedTools(c.target.value),placeholder:"Read, Write, Edit...",className:"w-full px-3 py-2 rounded-lg text-[13px]",style:ma})]})]})]}),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(c=>r.jsxs("button",{onClick:()=>i.setBodyViewMode(c),className:"flex items-center gap-1 rounded-md transition-all duration-150",style:{padding:"4px 10px",background:i.bodyViewMode===c?"var(--surface-4)":"transparent",color:i.bodyViewMode===c?"var(--text-primary)":"var(--text-tertiary)",fontSize:11,fontWeight:i.bodyViewMode===c?600:400,border:"none",cursor:"pointer"},children:[c==="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:c==="write"?"Write":"Preview"})]},c))})]}),i.bodyViewMode==="write"?r.jsx("textarea",{value:i.body,onChange:c=>i.setBody(c.target.value),placeholder:`# /my-skill
|
|
109
|
-
|
|
110
|
-
You are an expert at...
|
|
111
|
-
`,rows:8,className:"w-full px-3 py-2 rounded-lg text-[13px] font-mono resize-y",style:{...ma,minHeight:"150px"}}):i.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:oc(i.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(ON,{skillName:i.name||"{skill}",hasEvals:!1,isDraft:i.draftSaved}),i.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:i.error}),r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("button",{onClick:i.handleCreate,disabled:i.creating||!i.name||!i.description,className:"px-5 py-2.5 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:i.creating||!i.name||!i.description?"var(--surface-3)":"var(--accent)",color:i.creating||!i.name||!i.description?"var(--text-tertiary)":"#fff",cursor:i.creating||!i.name||!i.description?"not-allowed":"pointer",border:"none"},children:i.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 fv(){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 Gs({variant:t,message:a,onRetry:s}){const{setMode:i,setSearch:c}=cr(),[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(fv,{}):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:()=>i("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==="no-project-skills"?r.jsxs("div",{className:"flex flex-col items-center justify-center h-full px-8 animate-fade-in","data-testid":"empty-state-no-project-skills",children:[r.jsx("div",{className:"mb-5",children:u?r.jsx(fv,{}):r.jsx("img",{src:"/images/empty-studio.webp",width:128,height:128,alt:"",onError:()=>d(!0),style:{objectFit:"contain"}})}),r.jsx("p",{className:"text-[15px] font-medium mb-1",style:{color:"var(--text-primary)"},children:"No skills installed for this project yet."}),r.jsx("p",{className:"text-[12px] mb-5",style:{color:"var(--text-tertiary)",maxWidth:360,textAlign:"center"},children:"Browse the marketplace to install one, or author a new skill from scratch."}),r.jsxs("div",{className:"flex gap-3",children:[r.jsxs("button",{type:"button","data-testid":"empty-state-browse-marketplaces",onClick:()=>{window.dispatchEvent(new CustomEvent("studio:open-marketplace"))},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--accent)",color:"#fff",border:"none",cursor:"pointer"},"aria-label":"Browse marketplaces",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("circle",{cx:"9",cy:"21",r:"1"}),r.jsx("circle",{cx:"20",cy:"21",r:"1"}),r.jsx("path",{d:"M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"})]}),"Browse marketplaces"]}),r.jsxs("button",{type:"button","data-testid":"empty-state-create-skill",onClick:()=>i("create"),className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-[13px] font-medium transition-all duration-150",style:{background:"var(--surface-2)",color:"var(--text-primary)",border:"1px solid var(--border-default, var(--border-subtle))",cursor:"pointer"},"aria-label":"Create new skill",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"})]}),"Create new 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 UN(t,a){const[s,i]=t.split(".").map(Number),[c,u]=a.split(".").map(Number);return c>s?"major":u>i?"minor":"patch"}const HN={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 mb(){const[t,a]=p.useState([]),[s,i]=p.useState(!0),[c,u]=p.useState(new Set),[d,h]=p.useState(new Map),[x,m]=p.useState(!1),[y,v]=p.useState(new Set),[b,S]=p.useState(new Map),[E,C]=p.useState(null),[w,N]=p.useState(null),[T,R]=p.useState(!1),_=p.useCallback(async()=>{i(!0);try{const U=await ke.getSkillUpdates();a(U.filter(Y=>Y.updateAvailable))}catch{a([])}finally{i(!1)}},[]);p.useEffect(()=>{_()},[_]);const z=p.useMemo(()=>t.filter(U=>!U.pinned),[t]),P=p.useCallback(U=>{u(Y=>{const X=new Set(Y);return X.has(U)?X.delete(U):X.add(U),X})},[]),k=p.useCallback(()=>{c.size===z.length?u(new Set):u(new Set(z.map(U=>U.name)))},[c,z]),O=p.useCallback(()=>{const U=[...c];if(!U.length)return;m(!0),h(new Map(U.map(X=>[X,{skill:X,status:"pending"}])));const Y=ke.startBatchUpdate(U);Y.addEventListener("progress",X=>{try{const J=JSON.parse(X.data);h($=>new Map($).set(J.skill,J))}catch{}}),Y.addEventListener("done",X=>{Y.close(),m(!1);try{const J=JSON.parse(X.data);C(`Updated ${J.updated??0} skills, ${J.failed??0} failed`),setTimeout(()=>C(null),5e3)}catch{}_()}),Y.addEventListener("error",()=>{Y.close(),m(!1),C("Batch update failed"),setTimeout(()=>C(null),5e3)})},[c,_]),L=p.useCallback(async U=>{const Y=U.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],J=Y[Y.length-1];v($=>new Set($).add(U.name)),S($=>{const M=new Map($);return M.delete(U.name),M});try{const $=await ke.postSkillUpdate(X,J);if($.ok)_();else{const M=`Update failed (HTTP ${$.status}): ${$.body}`;S(I=>new Map(I).set(U.name,M)),C(`Couldn't update ${J} — HTTP ${$.status}`),setTimeout(()=>C(null),5e3)}}catch($){const M=$ instanceof Error?$.message:"Network error";S(I=>new Map(I).set(U.name,M)),C(`Couldn't update ${J} — ${M}`),setTimeout(()=>C(null),5e3)}finally{v($=>{const M=new Set($);return M.delete(U.name),M})}},[_]),B=p.useCallback(async U=>{if(!U.latest)return;const Y=U.name.split("/"),X=Y.length>=3?Y[Y.length-2]:Y[0],J=Y[Y.length-1];R(!0);try{const $=await ke.getVersionDiff(X,J,U.installed,U.latest);N({skill:U,diff:$})}catch{N(null)}finally{R(!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:_,className:"btn btn-secondary text-[12px]",children:"Refresh"})]}):r.jsxs("div",{"data-testid":"updates-panel",className:"p-6",children:[E&&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:E}),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:_,className:"btn btn-ghost text-[12px]",disabled:x,children:"Refresh"}),r.jsx("button",{onClick:O,disabled:c.size===0||x,className:"btn btn-primary text-[12px]",children:x?"Updating...":`Update Selected (${c.size})`})]})]}),r.jsx("div",{className:"flex items-center gap-2 mb-3",children:r.jsxs("button",{onClick:k,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(U=>{const Y=U.name.split("/").pop()||U.name,X=U.latest?UN(U.installed,U.latest):"patch",J=HN[X],$=!!U.pinned,M=y.has(U.name),I=d.get(U.name),F=c.has(U.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:()=>!$&&P(U.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:F?"var(--accent)":"var(--border-default)",background:F?"var(--accent)":"transparent",opacity:$?.4:1},children:F&&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:Y}),$&&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:[U.installed," → ",U.latest||"?",$&&` (pinned at ${U.pinnedVersion||U.installed})`]})]}),I&&r.jsxs("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded-full",style:{background:I.status==="done"?"var(--green-muted)":I.status==="error"?"var(--red-muted)":"var(--yellow-muted)",color:I.status==="done"?"var(--green)":I.status==="error"?"var(--red)":"var(--yellow)"},children:[I.status,I.error&&`: ${I.error}`]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[r.jsx("button",{onClick:()=>B(U),className:"btn btn-ghost text-[11px]",disabled:T,children:"View Changes"}),r.jsx("button",{onClick:()=>L(U),disabled:$||M||x,title:$?"Pinned — unpin from CLI to update":"",className:`btn ${$?"btn-ghost":"btn-primary"} text-[11px]`,children:M?r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"spinner spinner-sm"})," Updating"]}):(I==null?void 0:I.status)==="done"?r.jsx("span",{style:{color:"var(--green)"},children:"✓"}):"Update"})]})]})},U.name)})}),w&&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:U=>U.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(Wf,{contentDiff:w.diff.contentDiff,fromLabel:w.diff.from,toLabel:w.diff.to,diffSummary:w.diff.diffSummary,renderContext:"inline"})]})})]})}const PN=Object.freeze(Object.defineProperty({__proto__:null,UpdatesPanel:mb},Symbol.toStringTag,{value:"Module"}));function VN(t){return t==null?"var(--text-tertiary)":t>=.7?"var(--green)":t>=.4?"var(--yellow)":"var(--red)"}function FN(t){return t==null?"var(--surface-3)":t>=.7?"var(--green-muted)":t>=.4?"var(--yellow-muted)":"var(--red-muted)"}function GN(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),i=s.hostname.toLowerCase();if(i!=="github.com"&&i!=="www.github.com"&&i!=="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 hb(t){const{author:a,repoUrl:s}=t,i=GN(s??null),c=a&&a.trim()!==""?a:i??"—",[u,d]=p.useState(!1),h=p.useCallback(async()=>{var x;try{await((x=navigator.clipboard)==null?void 0:x.writeText(c)),d(!0),setTimeout(()=>d(!1),1500)}catch{}},[c]);return i?r.jsx("a",{"data-testid":t["data-testid"]??"author-link",href:`https://github.com/${i}`,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 WN(t){let a=t.split("#")[0].split("?")[0].replace(/\/+$/,"");return a=a.replace(/\/(?:tree|blob)\/[^/]+(?:\/.*)?$/,""),a}function qN(t,a){const s=WN(t),i=(a??"").replace(/^\/+/,"").replace(/\/+$/,"");return i?`${s}/blob/HEAD/${i}`:`${s}/blob/HEAD/`}function pv(t){if(!t)return"source";const a=t.replace(/\/+$/,""),s=a.lastIndexOf("/");return s===-1?a:a.slice(s+1)}function xb(t){const{repoUrl:a,skillPath:s,absolutePath:i}=t,[c,u]=p.useState(!1),d=typeof a=="string"&&a.trim()!==""&&/^https?:\/\//.test(a.trim()),h=s?pv(s):i?pv(i):"source",x=p.useCallback(async()=>{var v;const y=i??s??"";if(y)try{await((v=navigator.clipboard)==null?void 0:v.writeText(y)),u(!0),setTimeout(()=>u(!1),1500)}catch{}},[i,s]);if(d){const y=qN(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(!i&&!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=i??s??"";return r.jsxs("button",{type:"button","data-testid":t["data-testid"]??"source-file-copy",title:`Copy ${m}`,onClick:x,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 mv(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function gb(t){return t.skill?KN({skill:t.skill}):QN({state:t.state,isReadOnly:t.isReadOnly,onDelete:t.onDelete})}function YN(t,a=48){if(t.length<=a)return t;const s=t.slice(0,12),i=t.slice(t.length-(a-12-1));return`${s}…${i}`}function KN({skill:t}){const[a,s]=p.useState(!1),i=(t.sourcePath??t.dir)||"—",c=p.useCallback(async()=>{var h;try{await((h=navigator.clipboard)==null?void 0:h.writeText(i)),s(!0),setTimeout(()=>s(!1),1500),mv(ae.toasts.pathCopied,"info")}catch{mv(ae.toasts.permissionDenied,"error")}},[i]),u=t.origin==="installed"?"Project":"Skills",d=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: ${u}`,style:{display:"inline-block",width:7,height:7,borderRadius:999,background:d}}),u]})]}),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.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[r.jsx("span",{"data-testid":"detail-header-version",children:r.jsx(oi,{version:t.resolvedVersion??t.version??null,source:t.versionSource,pluginName:t.pluginName??null})}),t.pluginName&&t.pluginVersion&&r.jsxs("span",{"data-testid":"detail-header-plugin-chip",title:`This skill ships in plugin ${t.pluginName} v${t.pluginVersion}. The plugin version is independent of this skill's own version track.`,style:{display:"inline-flex",alignItems:"baseline",gap:4,fontFamily:"var(--font-sans)",fontSize:11,color:"var(--text-tertiary)",padding:"2px 6px",borderRadius:4,background:"var(--surface-1, transparent)",border:"1px solid var(--border-subtle, transparent)",whiteSpace:"nowrap"},children:[r.jsx("span",{children:"from"}),r.jsx("span",{style:{color:"var(--text-secondary)"},children:t.pluginName}),r.jsx("span",{"aria-hidden":"true",children:"@"}),r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",color:"var(--text-secondary)"},children:t.pluginVersion})]}),t.origin==="source"&&r.jsx("button",{type:"button","data-testid":"detail-header-delete","aria-label":"Delete skill",title:"Delete skill",onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))},className:"flex items-center justify-center transition-colors duration-150",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-tertiary)",padding:4,borderRadius:4},onMouseEnter:h=>{h.currentTarget.style.color="var(--red)"},onMouseLeave:h=>{h.currentTarget.style.color="var(--text-tertiary)"},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("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"})]})})]})]}),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(hb,{author:t.author??null,repoUrl:t.repoUrl??t.homepage??null}),r.jsx(xb,{repoUrl:t.repoUrl??null,skillPath:t.skillPath??null,absolutePath:t.dir})]}),r.jsx(XN,{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:i,"aria-label":`Copy path ${i} to clipboard`,onClick:c,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:YN(i)}),r.jsxs("button",{"data-testid":"detail-header-copy-path",type:"button",onClick:c,"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 XN({skill:t}){const a=t.installMethod,s=t.symlinkTarget;if(!a)return null;let i="";switch(a){case"symlinked":i=s?`Symlinked from ${s}`:"Symlinked (target unresolved)";break;case"copied":i="Copied (independent)";break;case"authored":i="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:i})]})}function QN({state:t,isReadOnly:a,onDelete:s}){const{plugin:i,skill:c,evals:u,latestBenchmark:d,isDirty:h,caseRunStates:x,regressions:m,iterationCount:y}=t,v=Array.from(x.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,E=(u==null?void 0:u.evals.length)??0,C=VN(b),w=FN(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:i}),r.jsx(ZN,{}),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:i,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(JN,{})}),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:w,color:C},children:b!=null?`${Math.round(b*100)}%`:"--"}),r.jsxs("span",{className:"text-[11px]",style:{color:"var(--text-tertiary)"},children:[E," case",E!==1?"s":""," / ",S," assert",S!==1?"s":""]})]})]})}function ZN(){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 JN(){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 ha(t){const{title:a,label:s,value:i,subtitle:c,description:u,linkLabel:d,children:h,onClick:x}=t,m=a??s??"",y=typeof x=="function",v=b=>{y&&(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),x==null||x())};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?()=>x==null?void 0:x():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(i)}),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 eT="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 tT(t){const{onNavigate:a}=t,[s,i]=p.useState(t.open??!1),c=p.useCallback(()=>i(!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),i(!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:()=>i(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:eT}),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:Qd,children:"Tests →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-link-run",onClick:()=>u("run"),style:Qd,children:"Run →"}),r.jsx("button",{type:"button","data-testid":"benchmark-info-close",onClick:c,style:{...Qd,marginLeft:"auto",color:"var(--text-secondary)"},children:"Close"})]})]})]})}const Qd={background:"transparent",border:"none",padding:0,fontFamily:"var(--font-sans)",fontSize:12,color:"var(--text-accent, var(--text-primary))",cursor:"pointer",textDecoration:"underline"};function nT(t){return`gh repo create ${t.trim()||"<repo-name>"} --public --source=. --remote=origin --push`}const rT="Add a GitHub remote: `gh repo create --public --source=.` (replace existing origin if needed).";function aT({value:t}){const[a,s]=p.useState(!1),i=p.useCallback(async()=>{try{await navigator.clipboard.writeText(t),s(!0),setTimeout(()=>s(!1),1500)}catch{}},[t]);return r.jsx("button",{type:"button","data-testid":"publish-status-copy","aria-label":"Copy GitHub setup command",onClick:i,style:{fontSize:11,padding:"3px 8px",borderRadius:4,border:"1px solid var(--border-default, var(--border-subtle))",background:"var(--surface-2)",color:"var(--text-primary)",cursor:"pointer"},children:a?"Copied":"Copy"})}function hv({tone:t,label:a}){const s=t==="ok"?"color-mix(in srgb, var(--color-ok, #22c55e) 18%, transparent)":"color-mix(in srgb, var(--color-own, #f59e0b) 18%, transparent)",i=t==="ok"?"var(--color-ok, #22c55e)":"var(--color-own, #f59e0b)";return r.jsx("span",{style:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:999,fontSize:11,fontWeight:500,color:i,background:s},children:a})}function lT(t={}){const{status:a,loading:s}=$y();if(s||!a)return null;if(a.status==="github")return r.jsxs("div",{"data-testid":"publish-status-row","data-status":"github",style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsx(hv,{tone:"ok",label:"Publish-ready"}),r.jsxs("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:["GitHub origin: ",a.githubOrigin]}),r.jsx("div",{style:{marginLeft:"auto"},children:r.jsx(Qy,{remoteUrl:a.githubOrigin??"",provider:t.provider,model:t.model})})]});const i=a.status==="no-git"?nT(t.projectBasename??""):rT;return r.jsxs("div",{"data-testid":"publish-status-row","data-status":a.status,style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 12px",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:8,background:"var(--bg-surface, var(--surface-1))"},children:[r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[r.jsx(hv,{tone:"warn",label:a.status==="no-git"?"No GitHub repo yet":"Origin is not GitHub"}),r.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Connect GitHub to publish your skills."})]}),r.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[r.jsx("code",{"data-testid":"publish-status-command",style:{flex:1,minWidth:0,padding:"6px 10px",borderRadius:4,background:"var(--surface-2)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:12,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:i}),r.jsx(aT,{value:i})]})]})}function xv({children:t}){return r.jsx("h3",{style:{fontFamily:"var(--font-sans)",fontSize:12,fontWeight:600,textTransform:"uppercase",letterSpacing:.6,color:"var(--text-tertiary)",margin:"0 0 8px"},children:t})}function sT({plugin:t,skill:a}){return r.jsxs("aside",{"data-testid":"skill-overview-rightrail",style:{display:"flex",flexDirection:"column",gap:16},children:[r.jsxs("section",{"data-testid":"overview-rightrail-setup",children:[r.jsx(xv,{children:"Setup"}),r.jsx(ub,{plugin:t,skill:a})]}),r.jsxs("section",{"data-testid":"overview-rightrail-credentials",children:[r.jsx(xv,{children:"Credentials"}),r.jsx(wf,{plugin:t,skill:a})]})]})}function iT(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 Hs(t){if(!t)return"—";const a=new Date(t);if(Number.isNaN(a.getTime()))return t;const s=Date.now()-a.getTime(),i=Math.floor(s/1e3);if(i<60)return"just now";const c=Math.floor(i/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 x=Math.floor(h/12);return`${x} year${x===1?"":"s"} ago`}function oT(t){switch(t.benchmarkStatus){case"pass":case"fail":case"stale":return t.benchmarkStatus==="pass"?"100%":t.benchmarkStatus==="fail"?"0%":"—";default:return"—"}}function cT(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 uT(t){var v,b;const{skill:a,onNavigate:s,activationsCount:i=0,lastRunIso:c=null,repoUrl:u,skillPathInRepo:d}=t,h=u??(dT(a.homepage)?a.homepage??null:null),x=((v=a.mcpDeps)==null?void 0:v.length)??0,m=((b=a.deps)==null?void 0:b.length)??0,y=r.jsxs("div",{"data-testid":"skill-overview-main",style:{display:"flex",flexDirection:"column",gap:12},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(oi,{version:a.resolvedVersion??a.version??null,source:a.versionSource,pluginName:a.pluginName??null}),cT(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(hb,{author:a.author??null,repoUrl:h}),a.category?r.jsxs("span",{children:["· ",a.category]}):null,r.jsx(xb,{repoUrl:h,skillPath:d??null,absolutePath:a.dir}),a.lastModified?r.jsxs("span",{title:a.lastModified,children:["· Updated ",Hs(a.lastModified)]}):null]})]}),r.jsx(lT,{}),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(ha,{title:"Benchmark",value:oT(a),subtitle:a.lastBenchmark?Hs(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(tT,{onNavigate:s})})}),r.jsx(ha,{title:"Tests",value:a.evalCount??0,subtitle:`${a.assertionCount??0} assertions`,"data-testid":"metric-tests",onClick:s?()=>s("tests"):void 0}),r.jsx(ha,{title:"Activations",value:i,subtitle:c?`Last: ${Hs(c)}`:"Never","data-testid":"metric-activations",onClick:s?()=>s("activation"):void 0}),r.jsx(ha,{title:"Last run",value:Hs(c??a.lastBenchmark??null),"data-testid":"metric-last-run",onClick:s?()=>s("history"):void 0}),r.jsx(ha,{title:"MCP deps",value:x,subtitle:x>0&&a.mcpDeps?a.mcpDeps.slice(0,3).join(", "):"None","data-testid":"metric-mcp-deps",onClick:s?()=>s("deps"):void 0}),r.jsx(ha,{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(ha,{title:"Size",value:iT(a.sizeBytes),"data-testid":"metric-size"}),r.jsx(ha,{title:"Last modified",value:Hs(a.lastModified),subtitle:a.lastModified??void 0,"data-testid":"metric-last-modified"})]})]});return r.jsxs("div",{"data-testid":"skill-overview",className:"skill-overview",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) 280px",gap:16,padding:16,alignItems:"start"},children:[y,r.jsx(sT,{plugin:a.plugin,skill:a.skill})]})}function dT(t){return t?/^https?:\/\/(?:www\.)?(?:github\.com|raw\.githubusercontent\.com)\//.test(t):!1}function fT({skill:t}){const{onSkillUpdated:a}=cr(),{toast:s}=nc(),[i,c]=p.useState("idle"),[u,d]=p.useState(null),[h,x]=p.useState(!1),[m,y]=p.useState(null),[v,b]=p.useState(!1),S=p.useRef(null),E=p.useCallback(async()=>{if(!t||i==="updating")return;const T=new AbortController;S.current=T,c("updating"),d(null);try{const R=await ke.postSkillUpdate(t.plugin,t.skill,T.signal);if(R.ok)c("done"),a(t.plugin,t.skill),s({message:`Updated ${t.skill}.`,severity:"success",durationMs:4e3});else{const _=`Update failed (HTTP ${R.status}): ${R.body}`;c("idle"),d(_),s({message:`Couldn't update ${t.skill} — HTTP ${R.status}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}}catch(R){if(R instanceof DOMException&&R.name==="AbortError")return;const _=R instanceof Error?R.message:"Network error";c("idle"),d(_),s({message:`Couldn't update ${t.skill} — ${_}`,severity:"error",durationMs:0,action:{label:"Retry",onInvoke:()=>{E()}}})}finally{S.current===T&&(S.current=null)}},[t,i,a,s]);if(p.useEffect(()=>{if(!h||m!=null||!t||!t.latestVersion)return;let T=!1;return b(!0),ke.getVersionDiff(t.plugin,t.skill,t.currentVersion??"",t.latestVersion).then(R=>{T||y(R)}).catch(()=>{T||y(null)}).finally(()=>{T||b(!1)}),()=>{T=!0}},[h,m,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 T;(T=S.current)==null||T.abort()},[]),!t||t.updateAvailable!==!0)return null;const C=t.latestVersion,w=i==="updating"?"Updating…":C?`Update to ${C}`:"Update",N=i==="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:N,style:{height:36,padding:"0 14px",background:"var(--color-ink)",color:"var(--color-paper)",border:"none",borderRadius:4,cursor:N?"not-allowed":"pointer",fontFamily:"var(--font-sans)",fontSize:13,fontWeight:500},children:w}),r.jsx("button",{type:"button","data-testid":"update-action-toggle-changelog",onClick:()=>x(T=>!T),disabled:N||!C,style:{background:"transparent",border:"none",color:"var(--text-secondary)",fontSize:12,fontFamily:"var(--font-sans)",cursor:"pointer",textDecoration:"underline"},children:h?"Hide changelog":"Preview changelog"})]}),i==="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…"}),u&&i!=="updating"&&r.jsx("div",{"data-testid":"update-action-error",role:"alert",style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--color-error, #d32f2f)"},children:u}),h&&C&&r.jsxs("div",{"data-testid":"update-action-changelog",style:{paddingTop:8},children:[v&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Loading changelog…"}),!v&&m&&r.jsx(Wf,{contentDiff:m.contentDiff,fromLabel:m.from,toLabel:m.to,diffSummary:m.diffSummary??void 0,renderContext:"inline"}),!v&&!m&&r.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)"},children:"Couldn't load changelog."})]})]})}const pT=3e4;function mT({plugin:t,skill:a,trackedForUpdates:s=!0,discoveryBackedOff:i=!1}){const c=cr(),[u,d]=p.useState(!1),[h,x]=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 C=setInterval(()=>m(w=>(w+1)%1e6),250);return()=>clearInterval(C)},[u]),p.useEffect(()=>{if(!u||!S)return;const C=v.current??0;S.receivedAt<C||(y.current&&(clearTimeout(y.current),y.current=null),d(!1),x(!1),v.current=null)},[u,S]),p.useEffect(()=>()=>{y.current&&clearTimeout(y.current)},[]),s===!1||i)return null;const E=async()=>{if(!u){x(!1),d(!0),v.current=Date.now(),y.current=setTimeout(()=>{d(!1),x(!0),y.current=null,v.current=null},pT);try{await ke.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:E,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"})]})}function hT({tabs:t,active:a,onChange:s,parentTabId:i}){return r.jsx("div",{role:"tablist","aria-label":`${i} sub-sections`,"data-testid":`detail-subtab-bar-${i}`,style:{display:"flex",alignItems:"stretch",gap:2,borderBottom:"1px solid var(--border-subtle, var(--border-default))",padding:"0 16px",background:"var(--bg-canvas)",overflowX:"auto"},children:t.map(c=>{const u=c.id===a;return r.jsx("button",{type:"button",role:"tab","aria-selected":u,tabIndex:u?0:-1,id:`detail-subtab-${i}-${c.id}`,"data-testid":`detail-subtab-${i}-${c.id}`,onClick:()=>s(c.id),style:{background:"transparent",border:"none",borderBottom:u?"2px solid var(--text-primary)":"2px solid transparent",padding:"6px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:12,fontWeight:u?500:400,color:u?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:c.label},c.id)})})}const xT=[{id:"overview",label:"Overview"},{id:"editor",label:"Edit",visibleWhen:({isReadOnly:t})=>!t},{id:"tests",label:"Tests",visibleWhen:({isReadOnly:t})=>!t},{id:"run",label:"Run",visibleWhen:({isReadOnly:t})=>!t},{id:"activation",label:"Trigger"},{id:"versions",label:"Versions"}],gT=["overview","editor","tests","run","activation","history","leaderboard","deps","versions"];function vT(t){return typeof t=="string"&&gT.includes(t)}function vb(t){return xT.filter(a=>a.visibleWhen?a.visibleWhen({isReadOnly:t}):!0)}function gv(){if(typeof window>"u")return"overview";const a=new URLSearchParams(window.location.search).get("panel");return a==="trigger"?"activation":vT(a)?a:"overview"}const yT=new Set(["history","leaderboard","deps"]);function yb(t,a){return!a||new Set(vb(!0).map(i=>i.id)).has(t)||yT.has(t)?t:"overview"}const Il={run:[{id:"run",label:"Run"},{id:"history",label:"History"},{id:"models",label:"Models"}],activation:[{id:"run",label:"Run"},{id:"history",label:"History"}]};function bT(t){const a=Il[t];return a&&a.length>0?a[0].id:""}function jT(t,a){const s=Il[t];if(!s)return"";const c=new URLSearchParams(a).get("sub");return c&&s.some(u=>u.id===c)?c:s[0].id}function Zd(){const{state:t,setMobileView:a}=cr();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 ST(t={}){if(t.selectedSkillInfo!==void 0||t.loadError!==void 0)return kT(t);const{state:a,selectSkill:s,setMode:i,refreshSkills:c}=cr(),[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(Zd,{}),r.jsx(mb,{})]});if(a.mode==="create")return r.jsxs("div",{className:"h-full overflow-auto animate-fade-in",children:[r.jsx(Zd,{}),r.jsx($N,{onCreated:async(m,y)=>{i("browse"),await c(),s({plugin:m,skill:y,origin:"source"})},onCancel:()=>i("browse")})]});if(!a.selectedSkill)return a.skillsError?r.jsx(Gs,{variant:"error",message:a.skillsError,onRetry:c}):!a.skillsLoading&&a.skills.length===0?r.jsx(Gs,{variant:"no-skills"}):!a.skillsLoading&&a.skills.length>0&&!a.skills.some(m=>m.scopeV2==="available-project")?r.jsx(Gs,{variant:"no-project-skills"}):r.jsx(Gs,{variant:"no-selection"});const h=a.selectedSkill,x=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(Zd,{}),r.jsx(wT,{skillInfo:x,allSkills:a.skills,onSelectSkill:m=>s(m)})]})}function kT(t){const a=t.selectedSkillInfo??null,s=t.activeDetailTab??"overview";if(a==null)return ET();if(t.loadError)return NT(a,t.loadError);const i=t.allSkills&&t.onSelectSkill?{allSkills:t.allSkills,onSelectSkill:t.onSelectSkill}:void 0;return bb(a,s,t.onDetailTabChange,"",void 0,i)}function wT({skillInfo:t,allSkills:a,onSelectSkill:s}){const[i,c]=p.useState(gv()),[u,d]=p.useState(()=>jT(gv(),typeof window<"u"?window.location.search:""));p.useEffect(()=>{if(!t||!(t.origin==="installed"))return;const m=yb(i,!0);m!==i&&(c(m),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:"This skill is read-only — workbench tabs are hidden.",severity:"info"}})))},[t,i]),p.useEffect(()=>{d(bT(i))},[i]),p.useEffect(()=>{if(typeof window>"u")return;const x=new URLSearchParams(window.location.search);i==="overview"?x.delete("panel"):x.set("panel",i==="activation"?"trigger":i);const m=Il[i];m&&u&&u!==m[0].id?x.set("sub",u):x.delete("sub");const y=x.toString(),v=`${window.location.pathname}${y?"?"+y:""}${window.location.hash}`;window.history.replaceState(null,"",v)},[i,u]);const h=p.useMemo(()=>t?bb(t,i,c,u,d,{}):r.jsx(Gs,{variant:"no-selection"}),[t,i,u,a,s]);return r.jsx("div",{className:"flex flex-col h-full",style:{background:"var(--bg-canvas)"},children:h})}function CT(t,a,s){const i=vb(s);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:i.map(({id:c,label:u})=>{const d=c===t;return r.jsx("button",{type:"button",role:"tab","aria-selected":d,tabIndex:d?0:-1,id:`detail-tab-${c}`,"aria-controls":`detail-panel-${c}`,"data-testid":`detail-tab-${c}`,onClick:()=>a==null?void 0:a(c),style:{background:"transparent",border:"none",borderBottom:d?"2px solid var(--text-primary)":"2px solid transparent",padding:"10px 8px",marginBottom:-1,fontFamily:"var(--font-sans)",fontSize:13,fontWeight:d?500:400,color:d?"var(--text-primary)":"var(--text-secondary)",cursor:"pointer",whiteSpace:"nowrap"},children:u},c)})})}function ET(){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 NT(t,a){return r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,padding:24,background:"var(--bg-canvas)",height:"100%"},children:[gb({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 TT({active:t,sub:a}){return t==="editor"?r.jsx(AE,{}):t==="tests"?r.jsx(BE,{}):t==="run"?a==="history"?r.jsx(uv,{}):a==="models"?r.jsx(dv,{}):r.jsx(QE,{}):t==="activation"?r.jsx(nN,{}):t==="history"?r.jsx(uv,{}):t==="leaderboard"?r.jsx(dv,{}):t==="deps"?r.jsx(RN,{}):t==="versions"?r.jsx(XC,{}):null}function RT({active:t}){const{state:a,dispatch:s}=Un();return p.useEffect(()=>{t!=="overview"&&a.activePanel!==t&&s({type:"SET_PANEL",panel:t})},[t,a.activePanel,s]),null}function bb(t,a,s,i="",c,u){var v;const d=t.origin==="installed",h=yb(a,d),x=b=>{s==null||s(b)},m=r.jsx(uT,{skill:t,onNavigate:x,repoUrl:t.homepage??null}),y=u!=null?r.jsxs(IC,{plugin:t.plugin,skill:t.skill,origin:t.origin,children:[r.jsx(RT,{active:h}),r.jsx(TT,{active:h,sub:i})]},`${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 ",h," 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:gb({skill:t})}),r.jsx(fT,{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",{style:{flex:1,minWidth:0},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.trackedForUpdates&&r.jsx("button",{type:"button","data-testid":"uninstall-button","aria-label":`Uninstall ${t.skill}`,onClick:()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-uninstall",{detail:{skill:{plugin:t.plugin,skill:t.skill,dir:t.dir??"",hasEvals:!1,hasBenchmark:!1,evalCount:0,assertionCount:0,benchmarkStatus:"missing",lastBenchmark:null,origin:"installed"}}}))},style:{flexShrink:0,marginLeft:8,padding:"3px 10px",fontSize:11,fontWeight:500,fontFamily:"var(--font-sans)",color:"var(--text-primary)",background:"transparent",border:"1px solid var(--border-default, var(--border-subtle))",borderRadius:4,cursor:"pointer"},children:"Uninstall"})]}),t.origin==="installed"&&t.scopeV2!=="available-plugin"&&r.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid var(--border-default)"},children:r.jsx(mT,{plugin:t.plugin,skill:t.skill,trackedForUpdates:t.trackedForUpdates})}),CT(h,s,d),Il[h]&&r.jsx(hT,{parentTabId:h,tabs:Il[h],active:i||(((v=Il[h][0])==null?void 0:v.id)??""),onChange:c??(()=>{})}),r.jsx("div",{role:"tabpanel",id:`detail-panel-${h}`,"aria-labelledby":`detail-tab-${h}`,"data-testid":`detail-panel-${h}`,style:{flex:1,minHeight:0,overflow:"auto"},children:h==="overview"?m:y})]})}function AT(){const{updateCount:t,state:a,dismissUpdateNotification:s}=cr(),i=t>0&&!a.updateNotificationDismissed;return p.useEffect(()=>{if(!i)return;const c=setTimeout(()=>s(),1e4);return()=>clearTimeout(c)},[i,s]),i?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 MT=[{name:ae.shortcuts.groupNavigation,items:[{keys:"/",label:ae.shortcuts.search},{keys:"j",label:ae.shortcuts.moveDown},{keys:"k",label:ae.shortcuts.moveUp},{keys:"Enter",label:ae.shortcuts.openSelected},{keys:"Esc",label:"Close / clear"}]},{name:ae.shortcuts.groupActions,items:[{keys:"⌘K",label:ae.shortcuts.openPalette},{keys:"?",label:ae.shortcuts.openShortcuts},{keys:"⌘B",label:ae.shortcuts.toggleSidebar},{keys:"E",label:ae.actions.edit}]},{name:ae.shortcuts.groupTheme,items:[{keys:"⌘⇧D",label:ae.shortcuts.toggleTheme}]}];function LT({open:t,onClose:a,groups:s=MT,title:i=ae.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,x;(x=(h=c.current)==null?void 0:h.focus)==null||x.call(h),c.current=null}},[t]),p.useEffect(()=>{if(!t)return;function d(h){var x;if(h.key==="Escape"){h.preventDefault(),a();return}h.key==="Tab"&&(h.preventDefault(),(x=u.current)==null||x.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:i}),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 zT(t){const a=ae.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 i=[...s];return t.updateAvailable&&i.push({action:"update",label:a.update}),i.push({action:"uninstall",label:a.uninstall}),i.push({action:"delete",label:a.delete,disabled:!0,title:a.deletePluginTooltip}),i}function DT({state:t,onClose:a,onAction:s,itemsOverride:i}){const c=p.useRef(null),u=p.useRef(null),[d,h]=p.useState(0),x=p.useMemo(()=>t.skill?i??zT(t.skill):[],[t.skill,i]),m=p.useMemo(()=>{if(typeof window>"u")return{left:t.x,top:t.y};const v=8,b=220,S=44+x.length*28;let E=t.x,C=t.y;return E+b+v>window.innerWidth&&(E=Math.max(v,t.x-b)),C+S+v>window.innerHeight&&(C=Math.max(v,t.y-S)),{left:E,top:C}},[t.x,t.y,x.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=x[d];!v||v.disabled||(s(v.action,t.skill),a())},[x,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(E=>Math.min(E+1,Math.max(x.length-1,0)));return}if(S.key==="ArrowUp"){S.preventDefault(),h(E=>Math.max(E-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,x.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:x.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))})}const vv=t=>`${t.plugin}/${t.skill}`;function yv(t){const a=(t==null?void 0:t.delayMs)??1e4,s=t==null?void 0:t.onCommit,i=t==null?void 0:t.onFailure,c=(t==null?void 0:t.apiCall)??ke.deleteSkill.bind(ke),u=p.useRef(s),d=p.useRef(i),h=p.useRef(c);u.current=s,d.current=i,h.current=c;const x=p.useRef(new Map),[,m]=p.useState(0),y=p.useCallback(()=>m(R=>R+1),[]),v=p.useCallback(async R=>{var _,z;try{await h.current(R.skill.plugin,R.skill.skill),(_=u.current)==null||_.call(u,R.skill)}catch(P){(z=d.current)==null||z.call(d,R.skill,P)}finally{x.current.delete(vv(R.skill)),y()}},[y]),b=p.useCallback(R=>{const _=vv(R),z=x.current.get(_);z!=null&&z.timeoutId&&clearTimeout(z.timeoutId);const P={skill:R,timeoutId:null};P.timeoutId=setTimeout(()=>{P.timeoutId=null,v(P)},a),x.current.set(_,P),y()},[a,v,y]),S=p.useCallback(R=>{const _=x.current.get(R);_&&(_.timeoutId&&clearTimeout(_.timeoutId),x.current.delete(R),y())},[y]),E=p.useCallback(async()=>{const R=Array.from(x.current.values());for(const _ of R)_.timeoutId&&(clearTimeout(_.timeoutId),_.timeoutId=null);await Promise.all(R.map(_=>v(_)))},[v]),C=p.useCallback(async R=>{R.timeoutId&&(clearTimeout(R.timeoutId),R.timeoutId=null),await v(R)},[v]),w=p.useCallback(async R=>{const _=x.current.get(R);_&&await C(_)},[C]),N=p.useCallback(async R=>{const _=[];for(const z of x.current.values())z.skill.skill===R&&_.push(z);await Promise.all(_.map(C))},[C]),T=p.useCallback(R=>x.current.has(R),[]);return p.useEffect(()=>{const R=()=>{E()};return window.addEventListener("beforeunload",R),()=>{window.removeEventListener("beforeunload",R)}},[E]),p.useEffect(()=>{const R=x.current;return()=>{for(const _ of R.values())_.timeoutId&&(clearTimeout(_.timeoutId),_.timeoutId=null,v(_));R.clear()}},[]),{enqueueDelete:b,cancelDelete:S,flushPending:E,isPending:T,flushKey:w,flushBySkillName:N}}const _T={"anthropic-api":{name:ae.setupProviders.anthropic.name,description:ae.setupProviders.anthropic.description,envVars:ae.setupProviders.anthropic.envVars,keyUrl:ae.setupProviders.anthropic.keyUrl,learnMoreUrl:ae.setupProviders.anthropic.learnMoreUrl},openai:{name:ae.setupProviders.openai.name,description:ae.setupProviders.openai.description,envVars:ae.setupProviders.openai.envVars,keyUrl:ae.setupProviders.openai.keyUrl,learnMoreUrl:ae.setupProviders.openai.learnMoreUrl},openrouter:{name:ae.setupProviders.openrouter.name,description:ae.setupProviders.openrouter.description,envVars:ae.setupProviders.openrouter.envVars,keyUrl:ae.setupProviders.openrouter.keyUrl,learnMoreUrl:ae.setupProviders.openrouter.learnMoreUrl},gemini:{name:ae.setupProviders.gemini.name,description:ae.setupProviders.gemini.description,envVars:ae.setupProviders.gemini.envVars,keyUrl:ae.setupProviders.gemini.keyUrl,learnMoreUrl:ae.setupProviders.gemini.learnMoreUrl},ollama:{name:ae.setupProviders.ollama.name,description:ae.setupProviders.ollama.description,envVars:ae.setupProviders.ollama.envVars,install:[ae.setupProviders.ollama.installCmd],start:[ae.setupProviders.ollama.startCmd],pullExample:ae.setupProviders.ollama.pullExample,learnMoreUrl:ae.setupProviders.ollama.learnMoreUrl},"lm-studio":{name:ae.setupProviders.lmStudio.name,description:ae.setupProviders.lmStudio.description,envVars:ae.setupProviders.lmStudio.envVars,install:[ae.setupProviders.lmStudio.installCmd],start:[ae.setupProviders.lmStudio.startCmd],pullExample:ae.setupProviders.lmStudio.pullExample,learnMoreUrl:ae.setupProviders.lmStudio.learnMoreUrl},"claude-code":{name:ae.setupProviders.claudeCode.name,description:ae.setupProviders.claudeCode.description,envVars:[],notes:[ae.setupProviders.claudeCode.loginHint,ae.claudeCodeLabel.compactLabel],learnMoreUrl:ae.setupProviders.claudeCode.learnMoreUrl}};function OT(t){return t?_T[t]??null:null}function BT({open:t,providerKey:a,onClose:s}){const i=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=i.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=OT(a),u=(c==null?void 0:c.name)??ae.setupDrawer.fallbackTitle;return tc.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:i,role:"dialog","aria-modal":"true","aria-label":ae.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(IT,{title:u,onClose:s}),r.jsx("div",{"data-testid":"setup-drawer-body",style:{flex:1,overflowY:"auto",padding:"16px 20px"},children:c?r.jsx($T,{content:c}):r.jsx(UT,{})}),r.jsx("style",{children:`@keyframes vskillDrawerIn {
|
|
112
|
-
from { transform: translateX(100%); }
|
|
113
|
-
to { transform: translateX(0); }
|
|
114
|
-
}
|
|
115
|
-
@keyframes vskillDrawerBackdropIn {
|
|
116
|
-
from { opacity: 0; }
|
|
117
|
-
to { opacity: 1; }
|
|
118
|
-
}`})]})]}),document.body)}function IT({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:ae.setupDrawer.title(t)}),r.jsx("button",{type:"button","data-testid":"setup-drawer-close",onClick:a,"aria-label":ae.setupDrawer.close,style:{background:"transparent",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,padding:4,lineHeight:1},children:"×"})]})}function $T({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(i=>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:i},i))}),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:ae.setupDrawer.requiredEnv}),r.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:6},children:t.envVars.map(i=>r.jsx("li",{children:r.jsx(HT,{name:i})},i))})]}),t.keyUrl&&r.jsx(PT,{href:t.keyUrl,label:ae.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:ae.setupDrawer.installRun}),r.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(a=t.install)==null?void 0:a.map((i,c)=>r.jsx(Jd,{code:i},`install-${c}`)),(s=t.start)==null?void 0:s.map((i,c)=>r.jsx(Jd,{code:i},`start-${c}`)),t.pullExample&&r.jsx(Jd,{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:[ae.setupDrawer.learnMore," →"]})})]})}function UT(){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:ae.setupDrawer.fallbackTitle}),r.jsx("p",{style:{margin:0,fontSize:13,color:"var(--text-secondary)",lineHeight:1.5},children:ae.setupDrawer.fallbackBody})]})}function HT({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:ae.setupDrawer.copy})]})}function Jd({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 PT({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 VT(){const[t,a]=p.useState(!1),[s,i]=p.useState(null),c=p.useRef(null),u=p.useCallback((h,x)=>{var m;c.current=typeof document<"u"?document.activeElement:null,(m=x==null?void 0:x.beforeOpen)==null||m.call(x),i(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 FT(t){const a=[],s=[],i=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(i.has(u))continue;i.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,x)=>h+x.globalCount,0)});continue}a.push({kind:"individual",key:c.id,agent:c})}return{detected:a,notDetected:s}}function GT({agents:t,activeAgentId:a,focusedAgentId:s,onFocusAgent:i,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 x=p.useMemo(()=>FT(t),[t]),m=t.find(y=>y.id===s)??t.find(y=>y.id===a)??t[0];return typeof document>"u"?null:tc.createPortal(r.jsxs("div",{ref:h,"data-testid":"agent-scope-picker-popover",role:"dialog","aria-label":ae.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:[x.detected.length===0&&x.notDetected.length===0&&r.jsx(bv,{}),x.detected.map(y=>y.kind==="aggregate"?r.jsx(qT,{row:y,onFocus:()=>{var v;return i(((v=y.consumers[0])==null?void 0:v.id)??a??"")}},y.key):r.jsx(WT,{agent:y.agent,focused:y.agent.id===s,active:y.agent.id===a,onClick:()=>i(y.agent.id)},y.key)),x.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:ae.scopePicker.notDetectedSubheading}),x.notDetected.map(y=>r.jsx(YT,{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(KT,{agent:m,activeAgentId:a,onSwitch:()=>c(m.id)}):r.jsx(bv,{})})]}),r.jsx("style",{children:`@keyframes scopePickerFadeIn {
|
|
119
|
-
from { opacity: 0; transform: translateX(-50%) translateY(2px); }
|
|
120
|
-
to { opacity: 1; transform: translateX(-50%) translateY(0); }
|
|
121
|
-
}`})]}),document.body)}function WT({agent:t,focused:a,active:s,onClick:i}){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:i,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",{title:"project · personal · plugins",style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:[t.installedCount,"·",t.globalCount,"·",t.pluginCount??0]})]})}function qT({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 YT({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 KT({agent:t,activeAgentId:a,onSwitch:s}){const i=t.id===a,c=t.isRemoteOnly===!0,u=i||c,d=i?"Active":c?"Remote-only":ae.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":QT(t.health)})]}),r.jsxs("dl",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 12px",margin:0,fontSize:12},children:[r.jsx(zo,{label:ae.scopePicker.statsInstalled,value:String(t.installedCount)}),r.jsx(zo,{label:ae.scopePicker.statsGlobal,value:String(t.globalCount)}),r.jsx(zo,{label:ae.scopePicker.statsPlugins,value:String(t.pluginCount??0)}),r.jsx(zo,{label:ae.scopePicker.statsLastSync,value:t.lastSync?XT(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 zo({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 bv(){return r.jsx("div",{style:{padding:"16px 18px",fontSize:12,color:"var(--text-secondary)"},children:"No agents detected yet."})}function XT(t){try{const a=new Date(t).getTime(),s=Date.now()-a;if(Number.isNaN(a))return"—";const i=Math.round(s/6e4);if(i<1)return"just now";if(i<60)return`${i}m ago`;const c=Math.round(i/60);return c<24?`${c}h ago`:`${Math.round(c/24)}d ago`}catch{return"—"}}function QT(t){switch(t){case"ok":return ae.scopePicker.statsHealthOk;case"stale":return ae.scopePicker.statsHealthStale;case"missing":return ae.scopePicker.statsHealthMissing}}function ZT(t){const a=new Map;for(const s of t.sharedFolders??[])for(const i of s.consumers)a.set(i,s);return t.agents.map(s=>{const i=a.get(s.id);return{id:s.id,displayName:s.displayName,presence:s.detected?"detected":"absent",installedCount:s.localSkillCount,globalCount:s.globalSkillCount,pluginCount:s.pluginSkillCount??0,lastSync:s.lastSync,health:s.health,sharedFolderGroup:i?i.consumers:void 0,sharedFolderPath:i?i.path:void 0,isRemoteOnly:s.isRemoteOnly,resolvedGlobalDir:s.resolvedGlobalDir}})}function JT({agents:t,activeAgentId:a,onActiveAgentChange:s,onOpenSetup:i}){const[c,u]=p.useState(!1),[d,h]=p.useState(null),x=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=x.current)==null||S.focus()},[]),b=p.useCallback(S=>{s(S),u(!1)},[s]);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:x,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",{title:"project · personal · plugins",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," · ",(m==null?void 0:m.pluginCount)??0,")"]}),r.jsx("span",{"aria-hidden":"true",style:{fontSize:10,color:"var(--text-secondary)"},children:"▾"})]}),c&&r.jsx(GT,{agents:t,activeAgentId:a,focusedAgentId:d??a,onFocusAgent:h,onSwitch:b,onOpenSetup:S=>{i(S),v()},onClose:v})]})}const jb="vskill-ccode-banner-dismissed",eR=new Set(["claude-cli","claude-code"]);function tR(){try{return sessionStorage.getItem(jb)==="true"}catch{return!1}}function nR(){try{sessionStorage.setItem(jb,"true")}catch{}}function rR({activeAgentId:t}){const[a,s]=p.useState(()=>tR()),i=p.useCallback(()=>{typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:open-setup-drawer",{detail:{provider:"claude-code"}}))},[]),c=p.useCallback(()=>{nR(),s(!0)},[]);return!t||!eR.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:[ae.claudeCodeLabel.firstUseBanner," "]}),r.jsx("button",{type:"button","data-testid":"claude-code-first-use-banner-learn-more",onClick:i,style:{background:"transparent",border:"none",padding:0,color:"var(--color-accent, var(--accent-surface))",cursor:"pointer",textDecoration:"underline",fontFamily:"inherit",fontSize:"inherit"},children:ae.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 aR(){const[t,a]=p.useState(null),[s,i]=p.useState("loading"),[c,u]=p.useState(null),d=p.useCallback(async()=>{try{const h=await ke.getAgents();a(h),i("ready"),u(null)}catch(h){i("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 Do="workspace",lR=["skills","agents"];async function sR(){const t=await fetch("/api/workspace");if(!t.ok)throw new Error(`GET /api/workspace failed: ${t.status}`);return await t.json()}async function iR(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 oR(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 cR(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 ef(){for(const t of lR)Bn(t)}function uR(){const{data:t,loading:a,error:s,revalidate:i}=qa(Do,sR),c=t,u=c==null?void 0:c.projects.find(m=>m.id===c.activeProjectId),d=p.useCallback(async m=>{await iR(m),Bn(Do),ef()},[]),h=p.useCallback(async m=>{await oR(m),Bn(Do),ef()},[]),x=p.useCallback(async m=>{await cR(m),Bn(Do),ef()},[]);return{workspace:c,activeProject:u,loading:a,error:s,switchProject:d,addProject:h,removeProject:x,revalidate:i}}function dR({workspace:t,onSwitch:a,onAdd:s,onRemove:i,isPathStale:c}){const[u,d]=p.useState(!1),[h,x]=p.useState(!1),[m,y]=p.useState(""),[v,b]=p.useState(null),[S,E]=p.useState(null),[C,w]=p.useState(null),[N,T]=p.useState(!1),R=p.useRef(null),_=(t==null?void 0:t.projects)??[],z=_.find(L=>L.id===(t==null?void 0:t.activeProjectId));p.useEffect(()=>{if(!u)return;function L(B){R.current&&!R.current.contains(B.target)&&(d(!1),x(!1),b(null))}return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[u]);async function P(){b(null);const L=m.trim();if(!L){b("Paste an absolute path (e.g. /Users/you/projects/my-skill)");return}if(!L.startsWith("/")&&!/^[A-Za-z]:[\\/]/.test(L)){b("Path must be absolute. In Terminal, cd to the folder and run: pwd — then paste the result here.");return}try{await s({path:L}),y(""),x(!1)}catch(B){const U=B instanceof Error?B.message:String(B);/does not exist/i.test(U)?b(`Path not found on disk: ${L}`):/Duplicate/i.test(U)?b("That project is already registered."):b(U)}}async function k(){if(b(null),typeof window<"u"&&"showDirectoryPicker"in window)try{const L=await window.showDirectoryPicker();y(L.name),x(!0)}catch{}else x(!0)}function O(L){if(L.length<=50)return L;const B=L.split("/");return B.length<=4?L:`${B.slice(0,3).join("/")}/…/${B.slice(-2).join("/")}`}return r.jsxs("div",{ref:R,"data-vskill-project-picker":!0,style:{position:"relative",display:"inline-block"},children:[r.jsxs("button",{type:"button",onClick:()=>d(L=>!L),"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:[_.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."}),_.length>0&&r.jsx("ul",{role:"none",style:{listStyle:"none",margin:0,padding:4,maxHeight:320,overflowY:"auto"},children:_.map(L=>{const B=c?c(L.path):!1,U=L.id===(t==null?void 0:t.activeProjectId),Y=S===L.id;return r.jsxs("li",{role:"menuitem","data-stale":B?"true":"false",onMouseEnter:()=>E(L.id),onMouseLeave:()=>E(X=>X===L.id?null:X),onClick:()=>{if(!B){if(U){d(!1);return}w(L)}},style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:6,cursor:B?"not-allowed":"pointer",background:Y&&!B?"var(--surface-2, rgba(0,0,0,0.04))":U?"var(--surface-1, rgba(0,0,0,0.02))":"transparent",opacity:B?.5:1,transition:"background-color 120ms ease"},children:[r.jsx("span",{"aria-hidden":!0,style:{width:10,height:10,borderRadius:"50%",flexShrink:0,backgroundColor:L.colorDot,boxShadow:U?"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:U?600:500,color:"var(--text-primary)",lineHeight:1.3},children:[r.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:L.name}),U&&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:L.path,style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-tertiary)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:O(L.path)}),B&&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 ${L.name}`,onClick:X=>{X.stopPropagation(),i(L.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:Y?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"})]})})]},L.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 k(),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:L=>{L.currentTarget.style.backgroundColor="color-mix(in oklch, var(--color-action, #2F5B8E) 10%, transparent)"},onMouseLeave:L=>{L.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:L=>y(L.target.value),onKeyDown:L=>{L.key==="Enter"&&P(),L.key==="Escape"&&(x(!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:()=>{x(!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 P(),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})]})]})]}),C&&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:()=>w(null),children:[r.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.40)"}}),r.jsxs("div",{onClick:L=>L.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 ",C.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 "${C.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 "${C.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:()=>w(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 fR(t,a){const s=a.trim().toLowerCase().split(/\s+/).filter(Boolean);return s.length===0?t:t.filter(i=>{const c=`${i.name} ${i.path}`.toLowerCase();return s.every(u=>c.includes(u))})}function pR({open:t,projects:a,onSwitch:s,onClose:i}){const[c,u]=p.useState(""),[d,h]=p.useState(0),x=p.useMemo(()=>fR(a,c),[a,c]);p.useEffect(()=>{t||(u(""),h(0))},[t]),p.useEffect(()=>{d>=x.length&&h(0)},[x.length,d]);const m=y=>{if(y.key==="Escape"){y.preventDefault(),i();return}if(y.key==="ArrowDown"){y.preventDefault(),h(v=>Math.min(v+1,Math.max(x.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=x[d];v&&(s(v.id),i())}};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:i}),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:[x.length===0&&r.jsx("li",{className:"px-3 py-2 text-xs text-muted-foreground",children:"No matches."}),x.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),i()},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 jv=/^[a-z][a-z0-9-]{0,62}[a-z0-9]$/;function mR({open:t,onClose:a,initialMode:s="standalone",isClaudeCode:i,projectRoot:c,onCreated:u}){const[d,h]=p.useState("destination"),[x,m]=p.useState(s),[y,v]=p.useState(""),[b,S]=p.useState(""),[E,C]=p.useState(""),[w,N]=p.useState([]),[T,R]=p.useState(!1),[_,z]=p.useState(null);if(p.useEffect(()=>{t&&(h("destination"),m(s),v(""),S(""),C(""),z(null))},[t,s]),p.useEffect(()=>{if(!t)return;let $=!0;return fetch("/api/authoring/plugins").then(M=>M.json()).then(M=>{$&&N(M.plugins??[])}).catch(()=>{}),()=>{$=!1}},[t]),p.useEffect(()=>{if(!t)return;function $(M){M.key==="Escape"&&(M.preventDefault(),a())}return document.addEventListener("keydown",$),()=>document.removeEventListener("keydown",$)},[t,a]),!t)return null;const P=w.length>0,k=i&&P,O=i,L=jv.test(y),B=x==="existing-plugin"?b.length>0:jv.test(b),U=!T&&L&&(x==="standalone"||B),Y=hR(c,x,b,y);async function X(){z(null),R(!0);try{const I=new URLSearchParams;I.set("mode",x),I.set("skillName",y),b&&I.set("pluginName",b);const F=await fetch(`/api/authoring/skill-exists?${I.toString()}`),H=await F.json();if(!F.ok){z(H.error??`Check failed: ${F.status}`);return}if(H.exists){z(`Skill '${y}' already exists${H.path?` at ${H.path}`:""}`);return}}catch(I){z(I instanceof Error?I.message:String(I));return}finally{R(!1)}const $=new URLSearchParams;$.set("mode",x),$.set("skillName",y),E.trim()&&$.set("description",E.trim()),b&&$.set("pluginName",b);const M=`#/create?${$.toString()}`;typeof window<"u"&&(window.location.hash=M),a()}async function J(){z(null),R(!0);try{const $=await fetch("/api/authoring/create-skill",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:x,skillName:y,description:E.trim()||void 0,pluginName:x==="standalone"?void 0:b})}),M=await $.json();if(!$.ok||!M.ok){z(M.error??`Create failed: ${$.status}`);return}Bn("skills"),u==null||u({mode:x,skillName:y,pluginName:M.pluginName??null,skillMdPath:M.skillMdPath}),a()}catch($){z($ instanceof Error?$.message:String($))}finally{R(!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(tf,{title:"Standalone skill",subtitle:"A single skill in this project",description:"Lives at <project>/skills/<name>/SKILL.md. Works with every agent.",icon:"📄",selected:x==="standalone",onClick:()=>m("standalone")}),r.jsx(tf,{title:"Add to existing plugin",subtitle:k?`${w.length} plugin source${w.length===1?"":"s"} in this project`:i?"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:!k,selected:x==="existing-plugin",onClick:()=>k&&m("existing-plugin")}),r.jsx(tf,{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:x==="new-plugin",onClick:()=>O&&m("new-plugin")})]}),d==="details"&&r.jsxs("div",{style:{padding:16,display:"flex",flexDirection:"column",gap:12},children:[x==="new-plugin"&&r.jsx(_o,{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:Oo(!b||B)})}),x==="existing-plugin"&&r.jsx(_o,{label:"Plugin",children:r.jsxs("select",{value:b,onChange:$=>S($.target.value),style:{...Oo(!0),fontFamily:"var(--font-mono)"},children:[r.jsx("option",{value:"",children:"Select a plugin…"}),w.map($=>r.jsx("option",{value:$.name,children:$.name},$.path))]})}),r.jsx(_o,{label:"Skill name",hint:"kebab-case",children:r.jsx("input",{type:"text",value:y,onChange:$=>v($.target.value.trim()),placeholder:"my-new-skill",autoFocus:x!=="new-plugin",style:Oo(!y||L)})}),r.jsx(_o,{label:"Description",hint:"One short sentence — shown in frontmatter",children:r.jsx("textarea",{value:E,onChange:$=>C($.target.value),rows:2,placeholder:"Does a thing when Claude needs X",style:{...Oo(!0),resize:"vertical",minHeight:52,fontFamily:"var(--font-sans)"}})}),Y&&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:"}),Y.map(($,M)=>r.jsx("div",{children:$},M))]}),_&&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:_})]}),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:nf,children:"Cancel"}),d==="destination"&&r.jsx("button",{type:"button",onClick:()=>h("details"),style:Sv,children:"Continue →"}),d==="details"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",onClick:()=>h("destination"),style:nf,children:"← Back"}),r.jsx("button",{type:"button",onClick:()=>void X(),disabled:!U,style:{...nf,opacity:U?1:.5,cursor:U?"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:!U,style:{...Sv,opacity:U?1:.5,cursor:U?"pointer":"not-allowed"},title:"Creates an empty SKILL.md scaffold you can fill in by hand",children:T?"Creating…":"Create empty scaffold"})]})]})]})]})}function tf({title:t,subtitle:a,description:s,icon:i,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:i}),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 _o({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 Oo(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 Sv={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"},nf={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 hR(t,a,s,i){const c=i||"<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 Sb(t){return t.trim().toLowerCase()}function xR(t,a){const s=Sb(a);return s?t.filter(i=>i.name.toLowerCase().includes(s)||i.source.toLowerCase().includes(s)):t}function gR(t,a){const s=Sb(a);return s?t.filter(i=>[i.name,i.description??"",i.category??"",i.author??""].join(" ").toLowerCase().includes(s)):t}function vR({open:t,onClose:a,onInstall:s,onUninstall:i,installedNames:c}){const[u,d]=p.useState(null),[h,x]=p.useState([]),[m,y]=p.useState(null),[v,b]=p.useState(null),[S,E]=p.useState(!1),[C,w]=p.useState(null),[N,T]=p.useState(""),[R,_]=p.useState("");p.useEffect(()=>{m?T(""):_("")},[m]);const z=p.useMemo(()=>xR(h,N),[h,N]),P=p.useMemo(()=>gR((v==null?void 0:v.plugins)??[],R),[v,R]);return p.useEffect(()=>{t&&(E(!0),w(null),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);x(k.marketplaces??[])}).catch(k=>w(k instanceof Error?k.message:String(k))).finally(()=>E(!1)))},[t]),p.useEffect(()=>{if(!m){b(null);return}E(!0),w(null),fetch(`/api/plugins/marketplaces/${encodeURIComponent(m)}`).then(k=>k.json()).then(k=>{if(k.error)throw new Error(k.error);b(k)}).catch(k=>w(k instanceof Error?k.message:String(k))).finally(()=>E(!1))},[m]),p.useEffect(()=>{if(!t)return;function k(O){O.key==="Escape"&&a()}return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[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…"}),C&&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:C}),!m&&!S&&h.length===0&&!C&&r.jsx(yR,{}),!m&&h.length>0&&r.jsx(kv,{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(k=>r.jsxs("button",{type:"button",onClick:()=>y(k.name),style:jR,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:k.name}),r.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:k.source})]},k.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(kv,{value:R,onChange:_,placeholder:"Search plugins…",ariaLabel:"Search plugins",testId:"plugin-search"}),v.plugins.length>0&&P.length===0&&r.jsxs("div",{style:{padding:12,fontSize:12,color:"var(--text-tertiary)"},children:["No plugins match “",R,"”."]}),P.map(k=>{const O=c.has(k.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:[k.name,k.version&&r.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-tertiary)"},children:k.version}),k.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:k.category})]}),k.description&&r.jsx("div",{style:{fontSize:11,color:"var(--text-secondary)",marginTop:4,lineHeight:1.5},children:k.description})]}),O&&i?r.jsx("button",{type:"button",disabled:u===k.name,onClick:async()=>{d(k.name);try{await i(k.name)}finally{d(null)}},"aria-label":`Uninstall ${k.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===k.name?"wait":"pointer",opacity:u===k.name?.6:1,fontFamily:"inherit"},children:u===k.name?"Uninstalling…":"Uninstall"}):r.jsx("button",{type:"button",disabled:O,onClick:()=>s(k.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"})]})},k.name)})]})]}),!m&&r.jsx("div",{style:{borderTop:"1px solid var(--border-subtle, rgba(0,0,0,0.08))",padding:12},children:r.jsx(bR,{onAdded:()=>{Bn("marketplaces"),fetch("/api/plugins/marketplaces").then(k=>k.json()).then(k=>x(k.marketplaces??[]))}})})]})]}):null}function kv({value:t,onChange:a,placeholder:s,ariaLabel:i,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":i,"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 yR(){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 bR({onAdded:t}){const[a,s]=p.useState(""),[i,c]=p.useState(!1),[u,d]=p.useState(null);async function h(){const x=a.trim();if(x){c(!0),d(null);try{const m=await fetch("/api/plugins/marketplaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source:x})}),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:x=>s(x.target.value),onKeyDown:x=>{x.key==="Enter"&&h()},placeholder:"anthropics/claude-plugins-official",disabled:i,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:i||!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:i||!a.trim()?"not-allowed":"pointer",opacity:i||!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:i?"Adding…":"Add"})]}),u&&r.jsx("div",{style:{fontSize:11,color:"var(--color-error, #b91c1c)"},children:u})]})}const jR={display:"block",width:"100%",textAlign:"left",padding:"10px 12px",border:"none",borderRadius:6,background:"transparent",cursor:"pointer",fontFamily:"inherit",marginBottom:2},rf=12;function SR({job:t,onDone:a}){const[s,i]=p.useState([]),[c,u]=p.useState("running"),[d,h]=p.useState(!1);if(p.useEffect(()=>{if(!t)return;i([]),u("running"),h(!1);const v=new AbortController;let b=[],S="running";return(async()=>{try{const E=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(!E.ok||!E.body){u("failed"),a({ok:!1,code:E.status,lines:[`HTTP ${E.status}`]});return}const C=E.body.getReader(),w=new TextDecoder;let N="";for(;;){const{value:T,done:R}=await C.read();if(R)break;N+=w.decode(T,{stream:!0});const _=N.split(/\n\n/);N=_.pop()??"";for(const z of _){const P=z.match(/^data:\s*(.*)$/m);if(P)try{const k=JSON.parse(P[1]);k.type==="stdout"&&k.line?(b=[...b,k.line].slice(-rf),i(b)):k.type==="stderr"&&k.line?(b=[...b,`⚠ ${k.line}`].slice(-rf),i(b)):k.type==="done"?(S=k.ok?"ok":"failed",u(S),ry(),Bn("skills"),a({ok:k.ok??!1,code:k.code??null,lines:b})):k.type==="error"&&k.error&&(b=[...b,`✘ ${k.error}`].slice(-rf),i(b))}catch{}}}S==="running"&&a({ok:!0,code:0,lines:b})}catch(E){if(E.name==="AbortError")return;u("failed"),a({ok:!1,code:null,lines:[...b,E instanceof Error?E.message:String(E)]})}})(),()=>v.abort()},[t==null?void 0:t.ref]),!t)return null;const x=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 ${x}`,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:x,width:16,textAlign:"center"},children:c==="running"?r.jsx(kR,{}):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-primary)",marginLeft:4},children:["@",t.marketplace]})]}),!d&&s.length>0&&r.jsx("span",{style:{display:"block",fontFamily:"var(--font-mono)",fontSize:10,color:"var(--text-primary)",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-primary)"},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(`
|
|
122
|
-
`)})]})}function kR(){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 wR=3e3,CR={anthropic:"Anthropic",openai:"OpenAI",openrouter:"OpenRouter"};function wv(t){return t==="anthropic"||t==="openai"||t==="openrouter"}function ER(){const{toast:t}=nc(),a=p.useRef(new Map),s=p.useCallback(i=>{if(!wv(i.provider))return;const c=Date.now(),u=a.current.get(i.provider)??0;if(c-u<wR)return;a.current.set(i.provider,c);const d=CR[i.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:i.provider}}))}}})},[t]);return p.useEffect(()=>{function i(c){const u=c.detail;!u||!wv(u.provider)||s({provider:u.provider})}return window.addEventListener("studio:api-key-error",i),()=>window.removeEventListener("studio:api-key-error",i)},[s]),{report:s}}const kb="vskill.studio.prefs";function wb(){try{return typeof window>"u"?null:window.localStorage??null}catch{return null}}function Cb(){const t=wb();if(!t)return{};try{const a=t.getItem(kb);if(!a)return{};const s=JSON.parse(a);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function NR(t,a){const s=wb();if(s)try{const c={...Cb(),[t]:a};s.setItem(kb,JSON.stringify(c))}catch{}}function TR(t,a){const i=Cb()[t];return i===void 0?a:i}const Cv={open:!1,x:0,y:0,skill:null};function RR(t,a){return{open:!0,x:t.clientX,y:t.clientY,skill:a}}function Ha(t,a="info"){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:toast",{detail:{message:t,severity:a}}))}function AR(t){typeof window>"u"||window.dispatchEvent(new CustomEvent("studio:request-delete",{detail:{skill:t}}))}function MR(t,a){var s;switch(t){case"copy-path":try{(s=navigator.clipboard)==null||s.writeText(a.dir)}catch{Ha(ae.toasts.permissionDenied,"error");return}Ha(ae.toasts.pathCopied,"info");return;case"open":case"reveal":case"edit":Ha(ae.actions.editPlaceholder,"info");return;case"run-benchmark":Ha(ae.toasts.benchmarkQueued,"info");return;case"duplicate":Ha(ae.toasts.skillDuplicated,"info");return;case"update":Ha(ae.toasts.skillUpdated,"info");return;case"uninstall":Ha(ae.actions.editPlaceholder,"info");return;case"delete":AR(a);return;default:return}}function LR(t){return t.startsWith("#/create")}function zR(t){return t.startsWith("#/updates")}function Eb(t){const[a,s]=p.useState(()=>typeof window<"u"&&t(window.location.hash));return p.useEffect(()=>{function i(){s(t(window.location.hash))}return window.addEventListener("hashchange",i),i(),()=>window.removeEventListener("hashchange",i)},[]),a}function DR(){return Eb(LR)}function _R(){return Eb(zR)}function OR(){var i,c;if(typeof navigator>"u")return"⌘K";const t=((i=navigator.platform)==null?void 0:i.toUpperCase())??"",a=((c=navigator.userAgent)==null?void 0:c.toUpperCase())??"";return t.includes("MAC")||a.includes("MAC")?"⌘K":"Ctrl+K"}function BR(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}function IR(){const[t,a]=p.useState("⌘K");p.useEffect(()=>{a(OR())},[]);const s=BR();function i(){window.dispatchEvent(new CustomEvent("openFindSkills"))}return r.jsxs("button",{type:"button",onClick:i,"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 $R=p.lazy(()=>Pl(()=>import("./FindSkillsPalette-CEckFgA2.js"),__vite__mapDeps([2,1])).then(t=>({default:t.FindSkillsPalette}))),UR=p.lazy(()=>Pl(()=>import("./SkillDetailPanel-CYmWPegc.js"),__vite__mapDeps([3,4,1])).then(t=>({default:t.SkillDetailPanel}))),HR=p.lazy(()=>Pl(()=>import("./CreateSkillPage-DOJWF3-Z.js"),__vite__mapDeps([5,1])).then(t=>({default:t.CreateSkillPage}))),PR=p.lazy(()=>Pl(()=>Promise.resolve().then(()=>PN),void 0).then(t=>({default:t.UpdatesPanel})));function VR(){return r.jsx(XS,{children:r.jsx(qS,{children:r.jsxs(q2,{children:[r.jsx(FR,{}),r.jsx(AT,{})]})})})}function FR(){var Qt,rn;const{state:t,selectSkill:a,clearSelection:s,refreshSkills:i,outdatedByOrigin:c,revealSkill:u,clearReveal:d}=cr(),{config:h}=Ya(),{resolvedTheme:x,setTheme:m}=ny(),{toast:y}=nc(),[v,b]=p.useState(()=>kC()),[S]=p.useState(!0),[E,C]=p.useState(!1),[w,N]=p.useState(!1),[T,R]=p.useState("overview"),[_,z]=p.useState(Cv),P=p.useCallback((ie,Se)=>{z(RR(ie,Se))},[]),k=aR(),[O,L]=p.useState(()=>TR("activeAgent",null)),B=p.useCallback(ie=>{L(ie),NR("activeAgent",ie),typeof window<"u"&&window.dispatchEvent(new CustomEvent("studio:agent-changed",{detail:{agentId:ie}}))},[]);p.useEffect(()=>{var ie;!O&&((ie=k.response)!=null&&ie.suggested)&&B(k.response.suggested)},[O,(Qt=k.response)==null?void 0:Qt.suggested,B]);const U=p.useMemo(()=>k.response?ZT(k.response):[],[k.response]),{workspace:Y,switchProject:X,addProject:J,removeProject:$,activeProject:M}=uR(),[I,F]=p.useState(!1),[H,re]=p.useState(!1),[D,W]=p.useState("standalone"),te=p.useCallback((ie="standalone")=>{W(ie),re(!0)},[]);p.useEffect(()=>{function ie(Se){if(!(Se instanceof CustomEvent))return;const Ae=Se.detail;te((Ae==null?void 0:Ae.mode)??"standalone")}return window.addEventListener("studio:request-create-skill",ie),()=>window.removeEventListener("studio:request-create-skill",ie)},[te]);const[q,ce]=p.useState(!1),[Q,ye]=p.useState(null),[oe,be]=p.useState(null);p.useEffect(()=>{function ie(){ce(!0)}return window.addEventListener("studio:open-marketplace",ie),()=>window.removeEventListener("studio:open-marketplace",ie)},[]);const{plugins:Ne}=ay(),Be=p.useMemo(()=>{const ie=new Set;for(const Se of Ne??[])ie.add(Se.name);return ie},[Ne]);xf([{key:"p",meta:!0,handler:ie=>{var Ae;const Se=typeof document<"u"?document.activeElement:null;Se&&Se.tagName==="INPUT"||((Ae=ie==null?void 0:ie.preventDefault)==null||Ae.call(ie),F(En=>!En))}}],{enabled:!0});const Le=VT(),Pe=Le.open;p.useEffect(()=>{function ie(Se){if(!(Se instanceof CustomEvent))return;const Ae=Se.detail;Ae!=null&&Ae.provider&&Pe(Ae.provider)}return window.addEventListener("studio:open-setup-drawer",ie),()=>window.removeEventListener("studio:open-setup-drawer",ie)},[Pe]);const se=p.useCallback(()=>{z(Cv)},[]);p.useEffect(()=>{function ie(Se){if(!(Se instanceof CustomEvent))return;const Ae=Se.detail;Ae!=null&&Ae.message&&y({message:Ae.message,severity:Ae.severity??"info"})}return window.addEventListener("studio:toast",ie),()=>window.removeEventListener("studio:toast",ie)},[y]),ER();const[de,me]=p.useState(!1),[ve,je]=p.useState(void 0);p.useEffect(()=>{function ie(Se){if(!(Se instanceof CustomEvent))return;const Ae=Se.detail;je(Ae==null?void 0:Ae.provider),me(!0)}return window.addEventListener("studio:open-settings",ie),()=>window.removeEventListener("studio:open-settings",ie)},[]),p.useEffect(()=>{document.documentElement.style.setProperty("--sidebar-width",`${v}px`)},[v]),p.useEffect(()=>{function ie(){i()}return window.addEventListener("studio:content-saved",ie),()=>window.removeEventListener("studio:content-saved",ie)},[i]);const[Ve,ct]=p.useState(null),[Nt,tn]=p.useState(()=>new Set),bt=p.useRef(!1),Ge=p.useMemo(()=>Jw(),[]),pt=p.useCallback(ie=>`${ie.plugin}/${ie.skill}`,[]),mt=p.useCallback(ie=>{tn(Se=>{const Ae=new Set(Se);return Ae.add(pt(ie)),Ae})},[pt]),jt=p.useCallback(ie=>{tn(Se=>{const Ae=new Set(Se);return Ae.delete(pt(ie)),Ae})},[pt]),Kt=yv({delayMs:1e4,onCommit:ie=>{i(),jt(ie)},onFailure:(ie,Se)=>{jt(ie),y({message:`Couldn't delete ${ie.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:ae.actions.retry,onInvoke:()=>{mt(ie),Kt.enqueueDelete(ie)}}})}});p.useEffect(()=>{function ie(Se){if(!(Se instanceof CustomEvent))return;const Ae=Se.detail;Ae!=null&&Ae.skill&&ct(Ae.skill)}return window.addEventListener("studio:request-delete",ie),()=>window.removeEventListener("studio:request-delete",ie)},[]);const[xe,tt]=p.useState(null),it=yv({delayMs:250,apiCall:(ie,Se)=>api.uninstallSkill(ie,Se),onCommit:ie=>{i(),jt(ie)},onFailure:(ie,Se)=>{var En;if(jt(ie),(Se instanceof Ga&&typeof((En=Se.details)==null?void 0:En.code)=="string"?Se.details.code:null)==="not-installed"){y({message:`${ie.skill} is a source-authored skill — use Delete instead.`,severity:"info",durationMs:6e3});return}y({message:`Couldn't uninstall ${ie.skill}: ${Se.message}`,severity:"error",durationMs:0,action:{label:ae.actions.retry,onInvoke:()=>{mt(ie),it.enqueueDelete(ie)}}})}});p.useEffect(()=>{function ie(Se){if(!(Se instanceof CustomEvent))return;const Ae=Se.detail;Ae!=null&&Ae.skill&&tt(Ae.skill)}return window.addEventListener("studio:request-uninstall",ie),()=>window.removeEventListener("studio:request-uninstall",ie)},[]);const Tt=p.useCallback(()=>{const ie=xe;if(tt(null),!ie)return;const Se={plugin:ie.plugin,skill:ie.skill};mt(Se),it.enqueueDelete(Se),y({message:`Uninstalled ${ie.skill}. Sent to your ${Ge}.`,severity:"info",durationMs:4e3})},[xe,mt,it,y,Ge]),Lt=p.useCallback(()=>{tt(null)},[]),ut=p.useCallback(()=>{const ie=Ve;if(ct(null),!ie)return;const Se={plugin:ie.plugin,skill:ie.skill};mt(Se),Kt.enqueueDelete(Se);const Ae=bt.current?"":`Sent to your ${Ge}. Open Trash to restore. `;bt.current=!0,y({message:`${Ae}Deleted ${ie.skill}`,severity:"info",durationMs:1e4,action:{label:ae.actions.undo,onInvoke:()=>{Kt.cancelDelete(pt(Se)),jt(Se)}}})},[Ve,mt,jt,Kt,y,Ge,pt]),Bt=p.useCallback(()=>{ct(null)},[]),It=p.useMemo(()=>t.skills.filter(ie=>!Nt.has(pt(ie))),[t.skills,Nt,pt]),yr=MC(It,(M==null?void 0:M.path)??null),Xt=p.useMemo(()=>t.selectedSkill?t.skills.find(ie=>ie.plugin===t.selectedSkill.plugin&&ie.skill===t.selectedSkill.skill)??null:null,[t.skills,t.selectedSkill]),gn=p.useCallback(ie=>{a({plugin:ie.plugin,skill:ie.skill,origin:ie.origin})},[a]),Cn=p.useMemo(()=>{if(!t.selectedSkill)return"";const ie=t.selectedSkill.origin==="installed"?"Installed":"Own";return`Viewing ${t.selectedSkill.skill} (${ie})`},[t.selectedSkill]),[Hn,vn]=p.useState(null);xf([{key:"cmd+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"ctrl+k",handler:()=>{typeof window<"u"&&window.dispatchEvent(new CustomEvent("openFindSkills"))}},{key:"?",handler:()=>C(ie=>!ie)},{key:"cmd+shift+d",handler:()=>m(x==="light"?"dark":"light")},{key:"ctrl+shift+d",handler:()=>m(x==="light"?"dark":"light")},{key:"cmd+b",handler:()=>N(ie=>!ie)},{key:"ctrl+b",handler:()=>N(ie=>!ie)},{key:"e",handler:()=>y({message:ae.actions.editPlaceholder,severity:"info"})}]);const St=DR(),nn=_R(),Ue=p.useMemo(()=>({flushBySkillName:async ie=>{await Promise.all([Kt.flushBySkillName(ie),it.flushBySkillName(ie)])}}),[Kt,it]),lt=nn?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(PR,{})}):St?r.jsx(p.Suspense,{fallback:r.jsx("div",{style:{padding:40},children:"Loading…"}),children:r.jsx(HR,{})}):r.jsx(ST,{selectedSkillInfo:Xt,activeDetailTab:T,onDetailTabChange:R,allSkills:t.skills,onSelectSkill:gn});return r.jsxs(pb.Provider,{value:Ue,children:[r.jsx(QS,{sidebarWidth:v,sidebarHidden:w||t.isMobile&&t.mobileView==="detail",banner:r.jsx(LC,{connected:S}),liveMessage:Cn,topRail:r.jsx(Q2,{projectName:(h==null?void 0:h.projectName)??null,selected:t.selectedSkill,onHome:s,onRequestCreateSkill:()=>te("standalone"),projectPickerSlot:Y&&Y.projects.length>0?r.jsx(dR,{workspace:Y,onSwitch:X,onAdd:J,onRemove:$}):void 0,findSkillsSlot:r.jsx(IR,{})}),sidebar:r.jsx(pC,{skills:It,selectedKey:t.selectedSkill?{plugin:t.selectedSkill.plugin,skill:t.selectedSkill.skill}:null,onSelect:gn,isLoading:t.skillsLoading,error:t.skillsError??null,onRetry:i,onContextMenu:P,outdatedByOrigin:c,activeAgentId:O,revealSkillId:t.revealSkillId,onRevealComplete:d,dirtySkillIds:yr,topSlot:k.status==="ready"&&U.length>0?r.jsxs(r.Fragment,{children:[r.jsx(JT,{agents:U,activeAgentId:O,onActiveAgentChange:B,onOpenSetup:ie=>Le.open(ie)}),r.jsx(rR,{activeAgentId:O})]}):null}),resizeHandle:r.jsx(CC,{initialWidth:v??Ys,onChange:b}),main:lt,statusBar:r.jsx(ok,{projectPath:(h==null?void 0:h.root)??null,modelName:(h==null?void 0:h.model)??null,health:h!=null&&h.error?"degraded":"ok",providers:(rn=h==null?void 0:h.providers)==null?void 0:rn.map(ie=>{const Se=ie.id;return{id:Se,label:ie.label,available:ie.available,kind:Se==="ollama"||Se==="lm-studio"?"start-service":Se==="anthropic"||Se==="openrouter"?"api-key":"cli-install"}})})}),r.jsx(LT,{open:E,onClose:()=>C(!1)}),r.jsx(BT,{open:Le.isOpen,providerKey:Le.providerKey,onClose:Le.close}),r.jsx(DT,{state:_,onClose:se,onAction:(ie,Se)=>MR(ie,Se)}),r.jsx(p.Suspense,{fallback:null,children:r.jsx($R,{onSelect:ie=>{const Se=ie.name.split("/");Se.length===3&&vn({owner:Se[0],repo:Se[1],slug:Se[2],displayName:ie.displayName??ie.name})}})}),Hn&&r.jsx(p.Suspense,{fallback:null,children:r.jsx(UR,{selectedSkill:Hn,onClose:()=>vn(null)})}),r.jsx(pR,{open:I,projects:(Y==null?void 0:Y.projects)??[],onSwitch:ie=>{X(ie)},onClose:()=>F(!1)}),r.jsx(mR,{open:H,onClose:()=>re(!1),initialMode:D,isClaudeCode:O==="claude-code",projectRoot:(M==null?void 0:M.path)??(h==null?void 0:h.projectName)??"",onCreated:ie=>{i(),setTimeout(()=>{u(ie.pluginName??"",ie.skillName)},500)}}),r.jsx(vR,{open:q,onClose:()=>ce(!1),installedNames:Be,onInstall:(ie,Se)=>{ye({plugin:ie,marketplace:Se,ref:`${ie}@${Se}`}),ce(!1)},onUninstall:async ie=>{if(await new Promise(Ae=>{be({plugin:ie,resolve:Ae})}))try{const Ae=await fetch(`/api/plugins/${encodeURIComponent(ie)}/uninstall`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})}),En=await Ae.json().catch(()=>({}));if(!Ae.ok||!En.ok){y({message:En.error??`Uninstall failed (${Ae.status})`,severity:"error"});return}const Pr=En.fallback==="orphan-cache-removed"?`Removed orphaned ${ie}.`:`Uninstalled ${ie}.`;y({message:Pr,severity:"success"}),i()}catch(Ae){y({message:Ae instanceof Error?Ae.message:String(Ae),severity:"error"})}}}),r.jsx(Zv,{open:de,onClose:()=>me(!1),initialProvider:ve,onToast:ie=>y({message:ie,severity:"info"})}),r.jsx(SR,{job:Q,onDone:ie=>{ie.ok&&(i(),setTimeout(()=>ye(null),3e3))}}),r.jsx(Po,{open:Ve!==null,title:Ve?`Delete "${Ve.skill}"?`:"",body:`It will be sent to your ${Ge}. You can recover it from there.`,confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:ut,onCancel:Bt}),r.jsx(Po,{open:xe!==null,title:xe?`Uninstall "${xe.skill}"?`:"",body:`It will be sent to your ${Ge} and the lockfile entry will be removed. You can re-install with vskill install.`,confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:Tt,onCancel:Lt}),r.jsx(Po,{open:oe!==null,title:oe?`Uninstall ${oe.plugin}?`:"",body:oe?`This removes the ${oe.plugin} plugin and all of its skills. You can reinstall it later from the marketplace.`:"",confirmLabel:"Uninstall",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{oe==null||oe.resolve(!0),be(null)},onCancel:()=>{oe==null||oe.resolve(!1),be(null)}})]})}const Ev="vskill.migrations.scope-rename.v1",GR={own:"authoring-project",installed:"available-project",global:"available-personal"},WR=/^vskill-sidebar-(.+)-(own|installed|global)-collapsed$/;function qR(t){if(t.getItem(Ev)==="done")return;const a=[];for(let s=0;s<t.length;s++){const i=t.key(s);if(!i)continue;const c=i.match(WR);if(!c)continue;const[,u,d]=c,h=GR[d];if(!h)continue;const x=t.getItem(i);x!==null&&a.push({oldKey:i,newKey:`vskill-sidebar-${u}-${h}-collapsed`,value:x})}for(const{oldKey:s,newKey:i,value:c}of a)t.getItem(i)===null&&t.setItem(i,c),t.removeItem(s);t.setItem(Ev,"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{qR(window.localStorage)}catch{}F0.createRoot(document.getElementById("root")).render(r.jsx(p.StrictMode,{children:r.jsx(dS,{children:r.jsx(rk,{children:r.jsx(VR,{})})})}));export{uc as E,Gv as L,ui as P,Te as R,ON as S,KR as T,Pl as _,Ya as a,Cb as b,IN as c,zN as d,oc as e,nc as f,TR as g,cr as h,ke as i,r as j,Wy as k,p as r,Qo as t,Ej as u,NR as w};
|